Files
plugins/packages/grok/testdata/codex_automation_update_schema.json
yetone a6910fd50a grok 0.1.10: a tool whose parameters are a union at the root reaches Grok as an object, so Codex desktop's turns are no longer refused (yetone/magpie#1271)
xiaocui12: Codex on Grok failed every turn with "[invalid_client_tool_schema]
mcp__codex_app__automation_update: tool parameter root must be an object
type (root schema is an anyOf/oneOf union with a non-object branch)".
Codex desktop's codex_app automation_update has an anyOf at its
parameters' root (ChatGPT.app 26.930 builds it with zod 4's toJSONSchema),
and its create and update branches are unions themselves.

rewrite() now folds a function's parameters to an object root as magpie's
built-in provider.ObjectRoot does, nested union branches folded first so
their fields (name, prompt, rrule, kind...) are kept and only "mode" is
required. Before, the plugin sent the union as it came; magpie's grokBody
folded it for requests through magpie, but not for OpenCode's own.

Verified: the real schema (testdata, rebuilt with zod 4.1.8) sent to the
real Grok subscription raw gets 400 with the reporter's exact message;
folded it gets 200 and a correct create call
({"mode":"create","kind":"heartbeat",...,"rrule":"FREQ=MINUTELY;INTERVAL=30"}).
schema.test.mjs: 2 of its 3 tests fail on 0.1.9 and pass now.
HOME=$(mktemp -d) bun test: the rest of the package matches main (login and
refresh tests time out here on main as well; CI runs them on Linux).
2026-10-08 16:51:46 +08:00

383 lines
6.5 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"anyOf": [
{
"type": "object",
"properties": {
"mode": {
"type": "string",
"const": "view"
},
"id": {
"$ref": "#/$defs/__schema0"
}
},
"required": [
"mode",
"id"
],
"additionalProperties": false
},
{
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/__schema2"
},
"prompt": {
"$ref": "#/$defs/__schema3"
},
"rrule": {
"$ref": "#/$defs/__schema4"
},
"status": {
"$ref": "#/$defs/__schema5"
},
"notificationPolicy": {
"$ref": "#/$defs/__schema6"
},
"kind": {
"$ref": "#/$defs/__schema7"
},
"projectId": {
"$ref": "#/$defs/__schema8"
},
"model": {
"$ref": "#/$defs/__schema9"
},
"reasoningEffort": {
"$ref": "#/$defs/__schema10"
},
"mode": {
"$ref": "#/$defs/__schema11"
},
"destination": {
"type": "string",
"const": "local"
},
"executionEnvironment": {
"type": "string",
"const": "local"
}
},
"required": [
"name",
"prompt",
"rrule",
"status",
"kind",
"projectId",
"model",
"reasoningEffort",
"mode",
"executionEnvironment"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/__schema2"
},
"prompt": {
"$ref": "#/$defs/__schema3"
},
"rrule": {
"$ref": "#/$defs/__schema4"
},
"status": {
"$ref": "#/$defs/__schema5"
},
"notificationPolicy": {
"$ref": "#/$defs/__schema6"
},
"kind": {
"$ref": "#/$defs/__schema12"
},
"destination": {
"$ref": "#/$defs/__schema13"
},
"targetThreadId": {
"$ref": "#/$defs/__schema14"
},
"mode": {
"$ref": "#/$defs/__schema11"
}
},
"required": [
"name",
"prompt",
"rrule",
"status",
"kind",
"mode"
],
"additionalProperties": false
}
]
},
{
"anyOf": [
{
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/__schema2"
},
"prompt": {
"$ref": "#/$defs/__schema3"
},
"rrule": {
"$ref": "#/$defs/__schema15"
},
"status": {
"$ref": "#/$defs/__schema5"
},
"notificationPolicy": {
"$ref": "#/$defs/__schema6"
},
"kind": {
"$ref": "#/$defs/__schema7"
},
"projectId": {
"$ref": "#/$defs/__schema8"
},
"model": {
"$ref": "#/$defs/__schema9"
},
"reasoningEffort": {
"$ref": "#/$defs/__schema10"
},
"mode": {
"$ref": "#/$defs/__schema16"
},
"id": {
"$ref": "#/$defs/__schema0"
},
"destination": {
"type": "string",
"enum": [
"local",
"worktree"
]
},
"executionEnvironment": {
"description": "env",
"type": "string",
"enum": [
"worktree",
"local"
]
},
"localEnvironmentConfigPath": {
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "null"
}
]
}
},
"required": [
"name",
"prompt",
"rrule",
"status",
"kind",
"projectId",
"model",
"reasoningEffort",
"mode",
"id",
"executionEnvironment"
],
"additionalProperties": false
},
{
"type": "object",
"properties": {
"name": {
"$ref": "#/$defs/__schema2"
},
"prompt": {
"$ref": "#/$defs/__schema3"
},
"rrule": {
"$ref": "#/$defs/__schema15"
},
"status": {
"$ref": "#/$defs/__schema5"
},
"notificationPolicy": {
"$ref": "#/$defs/__schema6"
},
"kind": {
"$ref": "#/$defs/__schema12"
},
"destination": {
"$ref": "#/$defs/__schema13"
},
"targetThreadId": {
"$ref": "#/$defs/__schema14"
},
"mode": {
"$ref": "#/$defs/__schema16"
},
"id": {
"$ref": "#/$defs/__schema0"
}
},
"required": [
"name",
"prompt",
"rrule",
"status",
"kind",
"mode",
"id"
],
"additionalProperties": false
}
]
},
{
"type": "object",
"properties": {
"mode": {
"type": "string",
"const": "delete"
},
"id": {
"$ref": "#/$defs/__schema0"
}
},
"required": [
"mode",
"id"
],
"additionalProperties": false
}
],
"$defs": {
"__schema0": {
"description": "Automation id.",
"$ref": "#/$defs/__schema1"
},
"__schema1": {
"type": "string",
"minLength": 1
},
"__schema2": {
"description": "name",
"$ref": "#/$defs/__schema1"
},
"__schema3": {
"description": "prompt",
"$ref": "#/$defs/__schema1"
},
"__schema4": {
"description": "rrule create",
"$ref": "#/$defs/__schema1"
},
"__schema5": {
"description": "status",
"type": "string",
"enum": [
"ACTIVE",
"PAUSED"
]
},
"__schema6": {
"description": "np",
"anyOf": [
{
"type": "string",
"enum": [
"all",
"failed_runs_only"
]
},
{
"type": "null"
}
]
},
"__schema7": {
"description": "cron",
"type": "string",
"const": "cron"
},
"__schema8": {
"description": "project",
"anyOf": [
{
"type": "string",
"minLength": 1
},
{
"type": "null"
}
]
},
"__schema9": {
"description": "model",
"$ref": "#/$defs/__schema1"
},
"__schema10": {
"description": "effort",
"type": "string",
"enum": [
"none",
"minimal",
"low",
"medium",
"high",
"xhigh",
"max",
"ultra"
]
},
"__schema11": {
"type": "string",
"enum": [
"create",
"suggested_create"
]
},
"__schema12": {
"description": "hb",
"type": "string",
"const": "heartbeat"
},
"__schema13": {
"description": "dest",
"type": "string",
"enum": [
"local",
"thread"
]
},
"__schema14": {
"format": "uuid",
"description": "tt",
"$ref": "#/$defs/__schema1"
},
"__schema15": {
"description": "rrule",
"$ref": "#/$defs/__schema1"
},
"__schema16": {
"type": "string",
"enum": [
"update",
"suggested_update"
]
}
}
}