@openclaw/codex 2026.9.2 → 2026.9.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/api.js +14 -19
- package/dist/apply-B6el6hdO.js +357 -0
- package/dist/{attempt-client-cleanup-Bp1ZOnk2.js → attempt-client-cleanup-D6cR54TV.js} +39 -19
- package/dist/{attempt-context-CSazkWns.js → attempt-context-AO4DSjE0.js} +8 -6
- package/dist/{event-projector-usage-ZqEVbAEY.js → attempt-notifications--H8zXR5-.js} +3 -106
- package/dist/auth-cache-key-Kq6oerr6.js +498 -0
- package/dist/auth-profile-CwzO4_RG.js +43 -0
- package/dist/auth-profile-selection-DFu9e167.js +45 -0
- package/dist/binding-connection-QqgcPCgk.js +60 -0
- package/dist/{bounded-turn-DxGJRYbY.js → bounded-turn-lRpmZHFv.js} +25 -122
- package/dist/build-state-6RL6qohz.js +19 -0
- package/dist/{capabilities-B1mgvpP8.js → capabilities-BeqLPbtM.js} +1 -1
- package/dist/cli-metadata.js +1 -1
- package/dist/client-BEKu4yDx.js +3983 -0
- package/dist/command-dispatch-CisT9Jqq.js +21 -0
- package/dist/{command-formatters-DSbGMXA0.js → command-formatters-DeTfrapr.js} +2 -2
- package/dist/{command-handlers-DOJvGv6-.js → command-handlers-BfIsJEuA.js} +31 -21
- package/dist/command-rpc-BMqRQOFX.js +226 -0
- package/dist/{compact-Y_xBqrHN.js → compact-CGJZ2rlb.js} +19 -14
- package/dist/config-JDfTI4VI.js +106 -0
- package/dist/{config-CyapYSji.js → config-options-jnIFvwxD.js} +204 -592
- package/dist/config-runtime-BWf6JLWG.js +11 -0
- package/dist/conversation-binding-CxOlHiix.js +889 -0
- package/dist/{plugin-marketplace-discovery-B7gHXJ3d.js → conversation-control-CUCrSIQI.js} +10 -142
- package/dist/doctor-contract-api.js +5 -5
- package/dist/{dynamic-tools-BwpvTxaX.js → dynamic-tools-D-JBoaLt.js} +66 -70
- package/dist/{effective-mcp-catalog-CY9Jn4bA.js → effective-mcp-catalog-J_5Ep5Um.js} +3 -3
- package/dist/{elicitation-input-DMkeki8d.js → elicitation-input-DPoK8F7w.js} +8 -22
- package/dist/ephemeral-turn-DSwzP8YY.js +101 -0
- package/dist/{event-projector-assistant-message-B9kp6iGC.js → event-projector-assistant-message-BmBM4qBV.js} +12 -25
- package/dist/event-projector-usage-CIyrYYid.js +102 -0
- package/dist/{harness-Czh2Sdoc.js → harness-FR6eQgyO.js} +31 -24
- package/dist/harness.js +1 -1
- package/dist/history-rejection-B4nOXNXF.js +13 -0
- package/dist/incognito-session-uhrBF6wJ.js +15 -0
- package/dist/index.js +411 -2875
- package/dist/{isolated-completion-CRh-51AK.js → isolated-completion-DHBefrzg.js} +7 -4
- package/dist/launch-args-RXQwn8zV.js +90 -0
- package/dist/{managed-binary-DcpnJF9x.js → managed-binary-DrjjRRUD.js} +4 -103
- package/dist/managed-thread-store-D1t5jh3G.js +66 -0
- package/dist/media-understanding-provider.js +4 -1
- package/dist/{model-catalog-DT5vo6qo.js → model-catalog-B_6M04Wo.js} +6 -5
- package/dist/{models-CcrgSMQR.js → models-P9k2qAof.js} +3 -3
- package/dist/native-execution-policy-umd0tgh4.js +128 -0
- package/dist/{native-subagent-monitor-B3bvQGcg.js → native-subagent-monitor-BbCUKRwC.js} +69 -42
- package/dist/node-cli-sessions-rj0ysJwM.js +527 -0
- package/dist/{node-exec-server.runtime-nfbUOtUB.js → node-exec-server.runtime-BY_ctYnT.js} +53 -22
- package/dist/plan-BMJdMOEF.js +711 -0
- package/dist/plugin-activation-BQK-f5sV.js +133 -0
- package/dist/{thread-resume-BLgqkUc1.js → plugin-app-cache-key-CdSQzWyX.js} +4 -52
- package/dist/{plugin-approval-roundtrip-aQVdyL5g.js → plugin-approval-roundtrip-DeW95wB5.js} +1 -1
- package/dist/plugin-inventory-CoRCzWW4.js +325 -0
- package/dist/plugin-marketplace-discovery-3akBizzF.js +134 -0
- package/dist/{plugin-metadata-cache-BwCLTY_U.js → plugin-metadata-cache-DgNfRAGA.js} +13 -9
- package/dist/protocol-CAAcVIKF.js +275 -0
- package/dist/{provider-capabilities-BpG9Ltc5.js → provider-capabilities-W4tfK5Y5.js} +2 -2
- package/dist/{rate-limits-Fx_l4eNa.js → rate-limits-Bqnx1N4z.js} +1 -1
- package/dist/request-CGvGOpeR.js +198 -0
- package/dist/{run-attempt-BzthFQSM.js → run-attempt-DwKds3DN.js} +589 -373
- package/dist/{runtime-artifact-Bh_gf6-t.js → runtime-artifact-T-NwqeSH.js} +27 -27
- package/dist/sandbox-guard-BcT66fWy.js +165 -0
- package/dist/{session-binding-4Ki04sW-.js → session-binding-CKSepwIC.js} +29 -47
- package/dist/{session-binding-record-CyaXZvTe.js → session-binding-record-CaZjYwNS.js} +11 -25
- package/dist/session-catalog-HaDcp7Sv.js +1533 -0
- package/dist/session-catalog-adoption-BKLtSrwi.js +251 -0
- package/dist/session-catalog-archive-D0i2pGj2.js +56 -0
- package/dist/session-catalog-home-id-D7-aLiNt.js +190 -0
- package/dist/session-catalog-node-adoption-BUuDYY8R.js +182 -0
- package/dist/session-catalog-node-continue-CBtc4wkI.js +238 -0
- package/dist/session-catalog-parsing-CdD3JhdM.js +280 -0
- package/dist/session-catalog-provenance-DkJHo735.js +124 -0
- package/dist/{session-cli-BjLhpmS1.js → session-cli-CbgaHh0f.js} +3 -2
- package/dist/{session-history-DWmMqiqW.js → session-history-Cz-tOOYj.js} +6 -3
- package/dist/{session-upstream-marker-DReTpGz6.js → session-history-import-DFN7sWRU.js} +5 -50
- package/dist/{session-history-read-LHldwvyh.js → session-history-read-cxPUxyVV.js} +21 -7
- package/dist/session-history-worker-runtime.js +18 -6
- package/dist/{session-history.worker-zZVcx0ME.js → session-history.worker-CNEvGaU5.js} +58 -51
- package/dist/session-history.worker.js +1 -1
- package/dist/{session-initialization-BCFVnLL4.js → session-initialization-Jo86C60I.js} +2 -2
- package/dist/{session-permission-policy-BaueHmSj.js → session-permission-policy-B22InTp_.js} +4 -7
- package/dist/{session-retirement-DNdmYdFc.js → session-retirement-BSNG_mhf.js} +6 -5
- package/dist/session-upstream-marker-D15C9NHp.js +46 -0
- package/dist/{settled-turn-context-BOM3Y1pl.js → settled-turn-context-Du6gdUDd.js} +9 -9
- package/dist/{settled-turn-finalizer-BI-b1sry.js → settled-turn-finalizer-BuLUrZl2.js} +7 -6
- package/dist/shared-client-CVhez2Uo.js +2911 -0
- package/dist/{side-question-B6DWAw1A.js → side-question-DLbr2vUU.js} +64 -169
- package/dist/source-Da-h6f7e.js +518 -0
- package/dist/thread-archive-guard-D1bP04Tf.js +53 -0
- package/dist/{thread-lifecycle-DPK30jad.js → thread-lifecycle-D1pzRwHB.js} +112 -616
- package/dist/{thread-ownership-CbucAmmp.js → thread-ownership-D6oASVRu.js} +13 -15
- package/dist/thread-policy-D8kI7yAO.js +54 -0
- package/dist/thread-resume-T5cveyxA.js +52 -0
- package/dist/timeout-BVw8aaM1.js +33 -0
- package/dist/{transcript-mirror-attestation-Byl34PC-.js → transcript-mirror-attestation-DibE0krH.js} +17 -4
- package/dist/{transcript-mirror-_njEB84z.js → transcript-mirror-t5TOccct.js} +50 -260
- package/dist/{transport-stdio-CzTngV0j.js → transport-stdio-BGjHoYLr.js} +73 -43
- package/dist/{upstream-session-fork-1fwbNKzQ.js → upstream-session-fork-De-sLJ2r.js} +26 -18
- package/dist/{usage-i9fv5-4m.js → usage-CPPTmBvZ.js} +4 -3
- package/dist/version-omm6IPI3.js +12 -0
- package/dist/{web-search-provider.runtime-DKQn67A7.js → web-search-provider.runtime-CSVgQL0w.js} +3 -3
- package/openclaw.plugin.json +22 -1
- package/package.json +4 -4
- package/dist/request-C8H22rPi.js +0 -475
- package/dist/session-catalog-B47uwekb.js +0 -3272
- package/dist/shared-client-CKhX2kFt.js +0 -7505
- package/dist/thread-policy-CTalhWFy.js +0 -105
- package/dist/{auth-binding-Ds_QVm-X.js → auth-binding-Co2Vfcf_.js} +1 -1
|
@@ -0,0 +1,3983 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-8H4AJuhK.js";
|
|
2
|
+
import { l as resolveCodexAppServerUserHomeDir, o as isJsonObject } from "./protocol-CAAcVIKF.js";
|
|
3
|
+
import { r as MIN_SUPPORTED_CODEX_APP_SERVER_VERSION, t as CODEX_APP_SERVER_VERSION } from "./version-omm6IPI3.js";
|
|
4
|
+
import { a as hasCodexAppServerNaturalExit, i as closeCodexAppServerTransportAndWait, r as closeCodexAppServerTransport, t as createStdioTransport } from "./transport-stdio-BGjHoYLr.js";
|
|
5
|
+
import { r as CodexAppServerRpcError } from "./session-catalog-provenance-DkJHo735.js";
|
|
6
|
+
import "./config-JDfTI4VI.js";
|
|
7
|
+
import { n as resolveCodexAppServerRuntimeOptions } from "./config-runtime-BWf6JLWG.js";
|
|
8
|
+
import { isRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
9
|
+
import { randomUUID } from "node:crypto";
|
|
10
|
+
import { addTimerTimeoutGraceMs, parseStrictNonNegativeInteger } from "openclaw/plugin-sdk/number-runtime";
|
|
11
|
+
import path from "node:path";
|
|
12
|
+
import { EventEmitter } from "node:events";
|
|
13
|
+
import { coerceErrorMessage, toStringifiedError } from "openclaw/plugin-sdk/error-runtime";
|
|
14
|
+
import { sliceUtf16Safe, truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
|
|
15
|
+
import { OPENCLAW_VERSION, embeddedAgentLog, formatToolExecutionErrorMessage, normalizeQuestionTimeoutSeconds, resolveToolExecutionErrorKind } from "openclaw/plugin-sdk/agent-harness-runtime";
|
|
16
|
+
import { createInterface } from "node:readline";
|
|
17
|
+
import { parse } from "semver";
|
|
18
|
+
import { hasPendingInternalDiagnosticEvent } from "openclaw/plugin-sdk/diagnostic-runtime";
|
|
19
|
+
import { Compile } from "typebox/compile";
|
|
20
|
+
import net from "node:net";
|
|
21
|
+
import { PassThrough, Writable } from "node:stream";
|
|
22
|
+
import { StringDecoder } from "node:string_decoder";
|
|
23
|
+
import WebSocket from "ws";
|
|
24
|
+
//#region extensions/codex/src/app-server/protocol-json.ts
|
|
25
|
+
function isRpcResponse(message) {
|
|
26
|
+
return "id" in message && !("method" in message);
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region extensions/codex/src/app-server/dynamic-tool-response-state.ts
|
|
30
|
+
/** Retains the host-owned app preview without adding it to Codex's response payload. */
|
|
31
|
+
function withDynamicToolTranscriptDetails(response, details) {
|
|
32
|
+
if (details === void 0) return response;
|
|
33
|
+
Object.defineProperty(response, "transcriptDetails", {
|
|
34
|
+
configurable: true,
|
|
35
|
+
enumerable: false,
|
|
36
|
+
value: details
|
|
37
|
+
});
|
|
38
|
+
return response;
|
|
39
|
+
}
|
|
40
|
+
function withDynamicToolTerminalResolution(response, terminalResolution) {
|
|
41
|
+
if (terminalResolution) {
|
|
42
|
+
Object.defineProperties(response, {
|
|
43
|
+
terminalResolution: {
|
|
44
|
+
configurable: true,
|
|
45
|
+
enumerable: false,
|
|
46
|
+
value: terminalResolution
|
|
47
|
+
},
|
|
48
|
+
executionStarted: {
|
|
49
|
+
configurable: true,
|
|
50
|
+
enumerable: false,
|
|
51
|
+
value: terminalResolution.executionStarted
|
|
52
|
+
},
|
|
53
|
+
...terminalResolution.executedArguments ? { executedArguments: {
|
|
54
|
+
configurable: true,
|
|
55
|
+
enumerable: false,
|
|
56
|
+
value: terminalResolution.executedArguments
|
|
57
|
+
} } : {}
|
|
58
|
+
});
|
|
59
|
+
withDynamicToolSideEffectEvidence(response, terminalResolution.sideEffectEvidence);
|
|
60
|
+
}
|
|
61
|
+
return response;
|
|
62
|
+
}
|
|
63
|
+
function withDynamicToolExecutionState(response, state) {
|
|
64
|
+
Object.defineProperties(response, {
|
|
65
|
+
executedArguments: {
|
|
66
|
+
configurable: true,
|
|
67
|
+
enumerable: false,
|
|
68
|
+
value: state.executedArguments
|
|
69
|
+
},
|
|
70
|
+
executionStarted: {
|
|
71
|
+
configurable: true,
|
|
72
|
+
enumerable: false,
|
|
73
|
+
value: state.executionStarted
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
return withDynamicToolSideEffectEvidence(response, state.sideEffectEvidence === true);
|
|
77
|
+
}
|
|
78
|
+
function withDynamicToolSideEffectEvidence(response, sideEffectEvidence) {
|
|
79
|
+
if (!sideEffectEvidence) {
|
|
80
|
+
delete response.sideEffectEvidence;
|
|
81
|
+
return response;
|
|
82
|
+
}
|
|
83
|
+
Object.defineProperty(response, "sideEffectEvidence", {
|
|
84
|
+
configurable: true,
|
|
85
|
+
enumerable: false,
|
|
86
|
+
value: true
|
|
87
|
+
});
|
|
88
|
+
return response;
|
|
89
|
+
}
|
|
90
|
+
function createFailedDynamicToolResponse(message, options) {
|
|
91
|
+
const response = {
|
|
92
|
+
contentItems: [{
|
|
93
|
+
type: "inputText",
|
|
94
|
+
text: message
|
|
95
|
+
}],
|
|
96
|
+
success: false
|
|
97
|
+
};
|
|
98
|
+
Object.defineProperties(response, {
|
|
99
|
+
diagnosticTerminalReason: {
|
|
100
|
+
configurable: true,
|
|
101
|
+
enumerable: false,
|
|
102
|
+
value: options?.terminalReason ?? "failed"
|
|
103
|
+
},
|
|
104
|
+
diagnosticTerminalType: {
|
|
105
|
+
configurable: true,
|
|
106
|
+
enumerable: false,
|
|
107
|
+
value: "error"
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
if (options?.executionStarted !== void 0) Object.defineProperty(response, "executionStarted", {
|
|
111
|
+
configurable: true,
|
|
112
|
+
enumerable: false,
|
|
113
|
+
value: options.executionStarted
|
|
114
|
+
});
|
|
115
|
+
if (options?.executedArguments !== void 0) Object.defineProperty(response, "executedArguments", {
|
|
116
|
+
configurable: true,
|
|
117
|
+
enumerable: false,
|
|
118
|
+
value: options.executedArguments
|
|
119
|
+
});
|
|
120
|
+
return withDynamicToolSideEffectEvidence(response, options?.sideEffectEvidence === true);
|
|
121
|
+
}
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region extensions/codex/src/app-server/tool-abort-terminal-reason.ts
|
|
124
|
+
/** Leaf helper shared by native and dynamic tool diagnostics. */
|
|
125
|
+
const CODEX_TIMEOUT_ABORT_REASONS = /* @__PURE__ */ new Set([
|
|
126
|
+
"codex_startup_timeout",
|
|
127
|
+
"turn_completion_idle_timeout",
|
|
128
|
+
"turn_progress_idle_timeout",
|
|
129
|
+
"turn_terminal_idle_timeout"
|
|
130
|
+
]);
|
|
131
|
+
/** Preserves timeout provenance when an enclosing run aborts an active tool. */
|
|
132
|
+
function resolveCodexToolAbortTerminalReason(signal) {
|
|
133
|
+
try {
|
|
134
|
+
const reason = signal.reason;
|
|
135
|
+
if (typeof reason === "string") {
|
|
136
|
+
if (CODEX_TIMEOUT_ABORT_REASONS.has(reason)) return "timed_out";
|
|
137
|
+
return reason === "client_closed" ? "failed" : "cancelled";
|
|
138
|
+
}
|
|
139
|
+
if (reason && typeof reason === "object") {
|
|
140
|
+
const record = reason;
|
|
141
|
+
if (record.name === "TimeoutError" || record.reason === "timeout") return "timed_out";
|
|
142
|
+
}
|
|
143
|
+
} catch {
|
|
144
|
+
return "cancelled";
|
|
145
|
+
}
|
|
146
|
+
return "cancelled";
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region extensions/codex/src/app-server/dynamic-tool-execution.ts
|
|
150
|
+
/**
|
|
151
|
+
* Timeout, terminal-release, and diagnostic helpers for Codex dynamic tool
|
|
152
|
+
* calls.
|
|
153
|
+
*/
|
|
154
|
+
/** Default timeout for Codex dynamic tool calls. */
|
|
155
|
+
const CODEX_DYNAMIC_TOOL_TIMEOUT_MS = 9e4;
|
|
156
|
+
/** Hard cap for per-call Codex dynamic tool timeout overrides. */
|
|
157
|
+
const CODEX_DYNAMIC_TOOL_MAX_TIMEOUT_MS = 6e5;
|
|
158
|
+
const CODEX_DYNAMIC_TOOL_TIMEOUT_SECONDS_GRACE_MS = 3e4;
|
|
159
|
+
const CODEX_DYNAMIC_IMAGE_GENERATION_TOOL_TIMEOUT_MS = 12e4;
|
|
160
|
+
const CODEX_DYNAMIC_COMPUTER_GATEWAY_TIMEOUT_MS = 3e4;
|
|
161
|
+
const CODEX_DYNAMIC_COMPUTER_COMPLETION_GRACE_MS = 3e4;
|
|
162
|
+
/** Timeout for image-understanding style dynamic tool calls. */
|
|
163
|
+
const CODEX_DYNAMIC_IMAGE_TOOL_TIMEOUT_MS = 6e4;
|
|
164
|
+
/** Timeout for message-delivery dynamic tool calls. */
|
|
165
|
+
const CODEX_DYNAMIC_MESSAGE_TOOL_TIMEOUT_MS = 6e5;
|
|
166
|
+
/** Outer default for collector waits: full swarm budget plus completion grace. */
|
|
167
|
+
const CODEX_DYNAMIC_AGENTS_WAIT_TOOL_TIMEOUT_MS = 63e4;
|
|
168
|
+
const LOG_FIELD_MAX_LENGTH = 160;
|
|
169
|
+
function normalizeLogField(value) {
|
|
170
|
+
if (typeof value !== "string") return;
|
|
171
|
+
const normalized = value.replaceAll(String.fromCharCode(27), " ").replaceAll("\r", " ").replaceAll("\n", " ").replaceAll(" ", " ").trim();
|
|
172
|
+
if (!normalized) return;
|
|
173
|
+
return normalized.length > LOG_FIELD_MAX_LENGTH ? `${truncateUtf16Safe(normalized, 157)}...` : normalized;
|
|
174
|
+
}
|
|
175
|
+
function readNumericTimeoutMs(value) {
|
|
176
|
+
if (typeof value === "number" && Number.isFinite(value)) return Math.max(0, Math.floor(value));
|
|
177
|
+
if (typeof value === "string") {
|
|
178
|
+
const parsed = parseStrictNonNegativeInteger(value);
|
|
179
|
+
if (parsed !== void 0) return Math.max(0, Math.floor(parsed));
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function formatDynamicToolTimeoutDetails(params) {
|
|
183
|
+
const tool = normalizeLogField(params.call.tool) ?? "unknown";
|
|
184
|
+
const baseMeta = {
|
|
185
|
+
tool: params.call.tool,
|
|
186
|
+
toolCallId: params.call.callId,
|
|
187
|
+
threadId: params.call.threadId,
|
|
188
|
+
turnId: params.call.turnId,
|
|
189
|
+
timeoutMs: params.timeoutMs,
|
|
190
|
+
timeoutKind: "codex_dynamic_tool_rpc"
|
|
191
|
+
};
|
|
192
|
+
if (tool !== "process" || !isJsonObject(params.call.arguments)) return {
|
|
193
|
+
responseMessage: `OpenClaw dynamic tool call timed out after ${params.timeoutMs}ms while running tool ${tool}.`,
|
|
194
|
+
consoleMessage: `codex dynamic tool timeout: tool=${tool} toolTimeoutMs=${params.timeoutMs}; per-tool-call watchdog, not session idle`,
|
|
195
|
+
meta: baseMeta
|
|
196
|
+
};
|
|
197
|
+
const action = normalizeLogField(params.call.arguments.action);
|
|
198
|
+
const sessionId = normalizeLogField(params.call.arguments.sessionId);
|
|
199
|
+
const requestedTimeoutMs = readNumericTimeoutMs(params.call.arguments.timeout);
|
|
200
|
+
const actionPart = action ? ` action=${action}` : "";
|
|
201
|
+
const sessionPart = sessionId ? ` sessionId=${sessionId}` : "";
|
|
202
|
+
const requestedPart = requestedTimeoutMs === void 0 ? "" : ` requestedWaitMs=${requestedTimeoutMs}`;
|
|
203
|
+
const retryHint = action === "poll" ? "; repeated lines usually mean process-poll retry churn, not model progress" : "";
|
|
204
|
+
const responseTarget = action || sessionId ? ` while waiting for process${actionPart}${sessionPart}` : " while waiting for the process tool";
|
|
205
|
+
return {
|
|
206
|
+
responseMessage: `OpenClaw dynamic tool call timed out after ${params.timeoutMs}ms${responseTarget}. This is a tool RPC timeout, not a session idle timeout.`,
|
|
207
|
+
consoleMessage: `codex process tool timeout:${actionPart}${sessionPart} toolTimeoutMs=${params.timeoutMs}${requestedPart}; per-tool-call watchdog, not session idle${retryHint}`,
|
|
208
|
+
meta: {
|
|
209
|
+
...baseMeta,
|
|
210
|
+
processAction: action,
|
|
211
|
+
processSessionId: sessionId,
|
|
212
|
+
processRequestedTimeoutMs: requestedTimeoutMs
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Runs a dynamic tool call with run-abort and the budget prepared by
|
|
218
|
+
* resolveDynamicToolCallTimeoutMs, preserving tool-specific completion grace.
|
|
219
|
+
*/
|
|
220
|
+
async function handleDynamicToolCallWithTimeout(params) {
|
|
221
|
+
let didNotifyAgentToolResult = false;
|
|
222
|
+
const conservativeRaceResponses = /* @__PURE__ */ new WeakSet();
|
|
223
|
+
const finalizeTerminal = (response) => {
|
|
224
|
+
const executionSnapshot = params.toolBridge.consumeToolExecutionSnapshot?.(params.call.callId);
|
|
225
|
+
const ownerKey = params.toolBridge.sideEffectOwnerKeyForTool?.(params.call.tool);
|
|
226
|
+
const observedExecutionStarted = executionSnapshot?.executionStarted ?? (conservativeRaceResponses.has(response) ? void 0 : response.executionStarted);
|
|
227
|
+
const terminalResolution = params.observeToolTerminal?.({
|
|
228
|
+
toolCallId: params.call.callId,
|
|
229
|
+
toolName: params.call.tool,
|
|
230
|
+
result: response,
|
|
231
|
+
arguments: response.executedArguments ?? executionSnapshot?.executedArguments ?? params.call.arguments,
|
|
232
|
+
...params.toolMeta ? { meta: params.toolMeta } : {},
|
|
233
|
+
...ownerKey ? { ownerMutation: { ownerKey } } : {},
|
|
234
|
+
...observedExecutionStarted !== void 0 ? { executionStarted: observedExecutionStarted } : {},
|
|
235
|
+
outcome: response.success ? "success" : "failure",
|
|
236
|
+
...!response.success ? { failure: { error: readDynamicToolResponseText(response) } } : {}
|
|
237
|
+
});
|
|
238
|
+
return withDynamicToolTerminalResolution(response, terminalResolution);
|
|
239
|
+
};
|
|
240
|
+
const createFailedAfterPossibleDispatch = (message, terminalReason) => {
|
|
241
|
+
const response = createFailedDynamicToolResponse(message, {
|
|
242
|
+
executionStarted: true,
|
|
243
|
+
sideEffectEvidence: true,
|
|
244
|
+
terminalReason
|
|
245
|
+
});
|
|
246
|
+
conservativeRaceResponses.add(response);
|
|
247
|
+
return response;
|
|
248
|
+
};
|
|
249
|
+
const notifyAgentToolResult = (event) => {
|
|
250
|
+
if (didNotifyAgentToolResult) return;
|
|
251
|
+
didNotifyAgentToolResult = true;
|
|
252
|
+
try {
|
|
253
|
+
params.onAgentToolResult?.(event);
|
|
254
|
+
} catch (error) {
|
|
255
|
+
const message = formatToolExecutionErrorMessage(error, "Unknown error");
|
|
256
|
+
embeddedAgentLog.warn(`onAgentToolResult handler failed: tool=${params.call.tool} error=${message}`);
|
|
257
|
+
}
|
|
258
|
+
};
|
|
259
|
+
const notifyFailedToolResult = (message, terminalReason = "failed") => {
|
|
260
|
+
notifyAgentToolResult({
|
|
261
|
+
toolName: params.call.tool,
|
|
262
|
+
result: {
|
|
263
|
+
content: [{
|
|
264
|
+
type: "text",
|
|
265
|
+
text: message
|
|
266
|
+
}],
|
|
267
|
+
details: {
|
|
268
|
+
status: terminalReason,
|
|
269
|
+
error: message
|
|
270
|
+
}
|
|
271
|
+
},
|
|
272
|
+
isError: true
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
if (params.signal.aborted) {
|
|
276
|
+
const message = "OpenClaw dynamic tool call aborted before execution.";
|
|
277
|
+
const terminalReason = resolveCodexToolAbortTerminalReason(params.signal);
|
|
278
|
+
params.onFallbackSelected?.();
|
|
279
|
+
notifyFailedToolResult(message, terminalReason);
|
|
280
|
+
return finalizeTerminal(createFailedDynamicToolResponse(message, {
|
|
281
|
+
executionStarted: false,
|
|
282
|
+
terminalReason
|
|
283
|
+
}));
|
|
284
|
+
}
|
|
285
|
+
const controller = new AbortController();
|
|
286
|
+
let timeout;
|
|
287
|
+
let timedOut = false;
|
|
288
|
+
let resolveAbort;
|
|
289
|
+
const abortFromRun = () => {
|
|
290
|
+
const message = "OpenClaw dynamic tool call aborted.";
|
|
291
|
+
const terminalReason = resolveCodexToolAbortTerminalReason(params.signal);
|
|
292
|
+
params.onFallbackSelected?.();
|
|
293
|
+
controller.abort(params.signal.reason ?? /* @__PURE__ */ new Error(message));
|
|
294
|
+
notifyFailedToolResult(message, terminalReason);
|
|
295
|
+
resolveAbort?.(createFailedAfterPossibleDispatch(message, terminalReason));
|
|
296
|
+
};
|
|
297
|
+
const abortPromise = new Promise((resolve) => {
|
|
298
|
+
resolveAbort = resolve;
|
|
299
|
+
});
|
|
300
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
301
|
+
const { timeoutMs } = params;
|
|
302
|
+
timeout = setTimeout(() => {
|
|
303
|
+
timedOut = true;
|
|
304
|
+
const timeoutDetails = formatDynamicToolTimeoutDetails({
|
|
305
|
+
call: params.call,
|
|
306
|
+
timeoutMs
|
|
307
|
+
});
|
|
308
|
+
params.onFallbackSelected?.();
|
|
309
|
+
controller.abort(new Error(timeoutDetails.responseMessage));
|
|
310
|
+
params.onTimeout?.();
|
|
311
|
+
embeddedAgentLog.warn("codex dynamic tool call timed out", {
|
|
312
|
+
...timeoutDetails.meta,
|
|
313
|
+
consoleMessage: timeoutDetails.consoleMessage
|
|
314
|
+
});
|
|
315
|
+
notifyFailedToolResult(timeoutDetails.responseMessage, "timed_out");
|
|
316
|
+
resolve(createFailedAfterPossibleDispatch(timeoutDetails.responseMessage, "timed_out"));
|
|
317
|
+
}, timeoutMs);
|
|
318
|
+
timeout.unref?.();
|
|
319
|
+
});
|
|
320
|
+
try {
|
|
321
|
+
params.signal.addEventListener("abort", abortFromRun, { once: true });
|
|
322
|
+
if (params.signal.aborted) abortFromRun();
|
|
323
|
+
const response = await Promise.race([
|
|
324
|
+
params.toolBridge.handleToolCall(params.call, {
|
|
325
|
+
signal: controller.signal,
|
|
326
|
+
onAgentToolResult: notifyAgentToolResult,
|
|
327
|
+
toolCallOrdinal: params.toolCallOrdinal,
|
|
328
|
+
retainExecutionSnapshot: true
|
|
329
|
+
}),
|
|
330
|
+
abortPromise,
|
|
331
|
+
timeoutPromise
|
|
332
|
+
]);
|
|
333
|
+
if (!response.success && !didNotifyAgentToolResult) notifyFailedToolResult(readDynamicToolResponseText(response), response.diagnosticTerminalReason ?? "failed");
|
|
334
|
+
return finalizeTerminal(response);
|
|
335
|
+
} catch (error) {
|
|
336
|
+
const terminalReason = params.signal.aborted ? resolveCodexToolAbortTerminalReason(params.signal) : resolveToolExecutionErrorKind(error);
|
|
337
|
+
const message = formatToolExecutionErrorMessage(error, "OpenClaw dynamic tool call failed.");
|
|
338
|
+
notifyFailedToolResult(message, terminalReason);
|
|
339
|
+
return finalizeTerminal(createFailedAfterPossibleDispatch(message, terminalReason));
|
|
340
|
+
} finally {
|
|
341
|
+
if (timeout) clearTimeout(timeout);
|
|
342
|
+
params.signal.removeEventListener("abort", abortFromRun);
|
|
343
|
+
resolveAbort = void 0;
|
|
344
|
+
if (!timedOut && !controller.signal.aborted) controller.abort(/* @__PURE__ */ new Error("OpenClaw dynamic tool call finished."));
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
function readDynamicToolResponseText(response) {
|
|
348
|
+
return response.contentItems.flatMap((item) => item.type === "inputText" && typeof item.text === "string" ? [item.text] : []).join("\n").trim() || "OpenClaw dynamic tool call failed.";
|
|
349
|
+
}
|
|
350
|
+
/** Strips OpenClaw-only metadata before sending a dynamic tool response to Codex. */
|
|
351
|
+
function toCodexDynamicToolProtocolResponse(response) {
|
|
352
|
+
return {
|
|
353
|
+
contentItems: response.contentItems,
|
|
354
|
+
success: response.success
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/** Adds async-started progress details when a tool result continues out of band. */
|
|
358
|
+
function toCodexDynamicToolProgressResponse(response, protocolResponse) {
|
|
359
|
+
const transcriptDetails = isJsonObject(response.transcriptDetails) ? response.transcriptDetails : void 0;
|
|
360
|
+
const mcpAppPreview = isJsonObject(transcriptDetails?.mcpAppPreview) ? transcriptDetails.mcpAppPreview : void 0;
|
|
361
|
+
const progressDetails = mcpAppPreview ? { mcpAppPreview } : void 0;
|
|
362
|
+
if (response.asyncStarted !== true && progressDetails === void 0) return protocolResponse;
|
|
363
|
+
return {
|
|
364
|
+
...protocolResponse,
|
|
365
|
+
...progressDetails ? { details: progressDetails } : {},
|
|
366
|
+
...response.asyncStarted === true ? { details: {
|
|
367
|
+
...progressDetails,
|
|
368
|
+
async: true,
|
|
369
|
+
status: "started"
|
|
370
|
+
} } : {}
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
/** Decides whether a terminal dynamic tool response can release the Codex turn. */
|
|
374
|
+
function shouldReleaseTurnAfterTerminalDynamicTool(state) {
|
|
375
|
+
return !state.completed && !state.aborted && state.responseSuccess && !state.currentTurnHadNonTerminalDynamicToolResult && state.activeAppServerTurnRequests === 0 && state.activeTurnItemIdsCount === 0 && state.pendingOpenClawDynamicToolCompletionIdsCount === 0;
|
|
376
|
+
}
|
|
377
|
+
/** Returns true when a non-async result should block terminal-release shortcuts. */
|
|
378
|
+
function shouldBlockTerminalReleaseForNonTerminalDynamicToolResult(response) {
|
|
379
|
+
return response.asyncStarted !== true;
|
|
380
|
+
}
|
|
381
|
+
/** Resolves whether terminal diagnostic state should release, wait, or stay idle. */
|
|
382
|
+
function resolveTerminalDynamicToolBatchAction(state) {
|
|
383
|
+
if (state.activeAppServerTurnRequests > 0 || state.activeTurnItemIdsCount > 0 || state.pendingOpenClawDynamicToolCompletionIdsCount > 0) return "wait";
|
|
384
|
+
if (state.currentTurnHadNonTerminalDynamicToolResult) return "clear-nonterminal-batch";
|
|
385
|
+
if (state.hasPendingTerminalDynamicToolRelease) return "release-pending-terminal";
|
|
386
|
+
return "idle";
|
|
387
|
+
}
|
|
388
|
+
/** Returns true for diagnostic events that terminate a dynamic tool call. */
|
|
389
|
+
function isDynamicToolTerminalDiagnosticEvent(event) {
|
|
390
|
+
return event.type === "tool.execution.completed" || event.type === "tool.execution.error" || event.type === "tool.execution.blocked";
|
|
391
|
+
}
|
|
392
|
+
/** Matches terminal diagnostics to a specific dynamic tool call id/name. */
|
|
393
|
+
function isMatchingDynamicToolTerminalDiagnostic(params) {
|
|
394
|
+
if (params.event.toolCallId !== params.call.callId || params.event.toolName !== params.call.tool) return false;
|
|
395
|
+
if (params.runId !== void 0) return params.event.runId === params.runId;
|
|
396
|
+
if (params.sessionId !== void 0) return params.event.sessionId === params.sessionId;
|
|
397
|
+
if (params.sessionKey !== void 0) return params.event.sessionKey === params.sessionKey;
|
|
398
|
+
return params.event.runId === void 0 && params.event.sessionId === void 0 && params.event.sessionKey === void 0;
|
|
399
|
+
}
|
|
400
|
+
/** Checks pending diagnostics for a terminal event matching a tool call. */
|
|
401
|
+
function hasPendingDynamicToolTerminalDiagnostic(params) {
|
|
402
|
+
return hasPendingInternalDiagnosticEvent((event) => {
|
|
403
|
+
if (!isDynamicToolTerminalDiagnosticEvent(event)) return false;
|
|
404
|
+
return isMatchingDynamicToolTerminalDiagnostic({
|
|
405
|
+
event,
|
|
406
|
+
call: params.call,
|
|
407
|
+
runId: params.runId,
|
|
408
|
+
sessionId: params.sessionId,
|
|
409
|
+
sessionKey: params.sessionKey
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
}
|
|
413
|
+
/** Resolves per-tool timeout, applying media/message defaults and hard caps. */
|
|
414
|
+
function resolveDynamicToolCallTimeoutMs(params) {
|
|
415
|
+
const args = isJsonObject(params.call.arguments) ? params.call.arguments : void 0;
|
|
416
|
+
if (params.call.tool === "openclaw" || params.call.tool === "ask_user" || params.call.tool === "secrets" && args?.action === "request") try {
|
|
417
|
+
const timeoutSeconds = params.call.tool === "openclaw" ? void 0 : args?.timeoutSeconds;
|
|
418
|
+
return normalizeQuestionTimeoutSeconds(timeoutSeconds) * 1e3 + CODEX_DYNAMIC_TOOL_TIMEOUT_SECONDS_GRACE_MS;
|
|
419
|
+
} catch {
|
|
420
|
+
return CODEX_DYNAMIC_TOOL_TIMEOUT_MS;
|
|
421
|
+
}
|
|
422
|
+
if (params.call.tool === "computer") return clampDynamicToolTimeoutMs(readComputerToolTimeoutMs(params.call.arguments));
|
|
423
|
+
if (params.call.tool === "message") return CODEX_DYNAMIC_MESSAGE_TOOL_TIMEOUT_MS;
|
|
424
|
+
if (params.call.tool === "agents_wait") {
|
|
425
|
+
const requestedMs = readDynamicToolCallTimeoutMs(params.call.arguments) ?? readConfiguredDynamicToolTimeoutMs(params.call.tool, params.config) ?? CODEX_DYNAMIC_AGENTS_WAIT_TOOL_TIMEOUT_MS;
|
|
426
|
+
return Math.max(1, Math.min(63e4, Math.floor(requestedMs)));
|
|
427
|
+
}
|
|
428
|
+
return clampDynamicToolTimeoutMs(readDynamicToolCallTimeoutMs(params.call.arguments) ?? readConfiguredDynamicToolTimeoutMs(params.call.tool, params.config) ?? CODEX_DYNAMIC_TOOL_TIMEOUT_MS);
|
|
429
|
+
}
|
|
430
|
+
/** Transport guard stays outside the handler's bounded tool wait and completion grace. */
|
|
431
|
+
function resolveDynamicToolServerRequestTimeoutMs(call) {
|
|
432
|
+
return Math.max(63e4, call ? resolveDynamicToolCallTimeoutMs({
|
|
433
|
+
call,
|
|
434
|
+
config: void 0
|
|
435
|
+
}) : 0) + CODEX_DYNAMIC_TOOL_TIMEOUT_SECONDS_GRACE_MS;
|
|
436
|
+
}
|
|
437
|
+
function readComputerToolTimeoutMs(value) {
|
|
438
|
+
const args = isJsonObject(value) ? value : void 0;
|
|
439
|
+
const action = typeof args?.action === "string" ? args.action : void 0;
|
|
440
|
+
const gatewayTimeoutMs = readPositiveFiniteTimeoutMs(args?.timeoutMs) ?? CODEX_DYNAMIC_COMPUTER_GATEWAY_TIMEOUT_MS;
|
|
441
|
+
const gatewayCallCount = action === "screenshot" || action === "wait" ? 3 : 4;
|
|
442
|
+
return (action === "wait" || action === "hold_key" ? Math.max(0, Number(args?.duration) || 0) * 1e3 : 0) + gatewayCallCount * gatewayTimeoutMs + CODEX_DYNAMIC_COMPUTER_COMPLETION_GRACE_MS;
|
|
443
|
+
}
|
|
444
|
+
function readDynamicToolCallTimeoutMs(value) {
|
|
445
|
+
if (!isJsonObject(value)) return;
|
|
446
|
+
const timeoutMs = readPositiveFiniteTimeoutMs(value.timeoutMs);
|
|
447
|
+
if (timeoutMs !== void 0) return timeoutMs;
|
|
448
|
+
const timeoutSecondsMs = readDynamicToolTimeoutSecondsAsMs(value.timeoutSeconds);
|
|
449
|
+
return timeoutSecondsMs === void 0 ? void 0 : addTimerTimeoutGraceMs(timeoutSecondsMs, CODEX_DYNAMIC_TOOL_TIMEOUT_SECONDS_GRACE_MS);
|
|
450
|
+
}
|
|
451
|
+
function readConfiguredDynamicToolTimeoutMs(toolName, config) {
|
|
452
|
+
if (toolName === "image_generate") {
|
|
453
|
+
const imageModel = config?.agents?.defaults?.mediaModels?.image;
|
|
454
|
+
if (!imageModel || typeof imageModel !== "object") return CODEX_DYNAMIC_IMAGE_GENERATION_TOOL_TIMEOUT_MS;
|
|
455
|
+
return readPositiveFiniteTimeoutMs(imageModel.timeoutMs) ?? CODEX_DYNAMIC_IMAGE_GENERATION_TOOL_TIMEOUT_MS;
|
|
456
|
+
}
|
|
457
|
+
if (toolName === "view_image") {
|
|
458
|
+
const candidates = (config?.tools?.media?.models ?? []).filter((entry) => !entry.capabilities || entry.capabilities.includes("image"));
|
|
459
|
+
const capabilityTimeoutMs = readTimeoutSecondsAsMs(config?.tools?.media?.image?.timeoutSeconds);
|
|
460
|
+
return Math.max(capabilityTimeoutMs ?? CODEX_DYNAMIC_IMAGE_TOOL_TIMEOUT_MS, ...candidates.map((entry) => readTimeoutSecondsAsMs(entry.timeoutSeconds) ?? capabilityTimeoutMs ?? CODEX_DYNAMIC_IMAGE_TOOL_TIMEOUT_MS));
|
|
461
|
+
}
|
|
462
|
+
if (toolName === "message") return CODEX_DYNAMIC_MESSAGE_TOOL_TIMEOUT_MS;
|
|
463
|
+
}
|
|
464
|
+
function readTimeoutSecondsAsMs(value) {
|
|
465
|
+
const seconds = readPositiveFiniteTimeoutMs(value);
|
|
466
|
+
return seconds === void 0 ? void 0 : seconds * 1e3;
|
|
467
|
+
}
|
|
468
|
+
function readDynamicToolTimeoutSecondsAsMs(value) {
|
|
469
|
+
if (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value) || value <= 0) return;
|
|
470
|
+
return value * 1e3;
|
|
471
|
+
}
|
|
472
|
+
function readPositiveFiniteTimeoutMs(value) {
|
|
473
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? Math.floor(value) : void 0;
|
|
474
|
+
}
|
|
475
|
+
function clampDynamicToolTimeoutMs(timeoutMs) {
|
|
476
|
+
return Math.max(1, Math.min(CODEX_DYNAMIC_TOOL_MAX_TIMEOUT_MS, Math.floor(timeoutMs)));
|
|
477
|
+
}
|
|
478
|
+
//#endregion
|
|
479
|
+
//#region extensions/codex/src/app-server/elicitation-response.ts
|
|
480
|
+
function createCodexElicitationResponse(action, content = null, meta = null) {
|
|
481
|
+
return {
|
|
482
|
+
action,
|
|
483
|
+
content,
|
|
484
|
+
_meta: meta
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
//#endregion
|
|
488
|
+
//#region extensions/codex/src/app-server/protocol-generated/json/DynamicToolCallParams.json
|
|
489
|
+
var DynamicToolCallParams_default = {
|
|
490
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
491
|
+
properties: {
|
|
492
|
+
"arguments": true,
|
|
493
|
+
"callId": { "type": "string" },
|
|
494
|
+
"namespace": { "type": ["string", "null"] },
|
|
495
|
+
"threadId": { "type": "string" },
|
|
496
|
+
"tool": { "type": "string" },
|
|
497
|
+
"turnId": { "type": "string" }
|
|
498
|
+
},
|
|
499
|
+
required: [
|
|
500
|
+
"arguments",
|
|
501
|
+
"callId",
|
|
502
|
+
"threadId",
|
|
503
|
+
"tool",
|
|
504
|
+
"turnId"
|
|
505
|
+
],
|
|
506
|
+
title: "DynamicToolCallParams",
|
|
507
|
+
type: "object"
|
|
508
|
+
};
|
|
509
|
+
//#endregion
|
|
510
|
+
//#region extensions/codex/src/app-server/protocol-generated/json/v2/CodexAppServerProtocolDefinitions.json
|
|
511
|
+
var definitions = {
|
|
512
|
+
"AbsolutePathBuf": {
|
|
513
|
+
"description": "A path that is guaranteed to be absolute and normalized (though it is not guaranteed to be canonicalized or exist on the filesystem).\n\nIMPORTANT: When deserializing an `AbsolutePathBuf`, a base path must be set using [AbsolutePathBufGuard::new]. If no base path is set, the deserialization will fail unless the path being deserialized is already absolute.",
|
|
514
|
+
"type": "string"
|
|
515
|
+
},
|
|
516
|
+
"Account": { "oneOf": [
|
|
517
|
+
{
|
|
518
|
+
"properties": { "type": {
|
|
519
|
+
"enum": ["apiKey"],
|
|
520
|
+
"title": "ApiKeyAccountType",
|
|
521
|
+
"type": "string"
|
|
522
|
+
} },
|
|
523
|
+
"required": ["type"],
|
|
524
|
+
"title": "ApiKeyAccount",
|
|
525
|
+
"type": "object"
|
|
526
|
+
},
|
|
527
|
+
{
|
|
528
|
+
"properties": {
|
|
529
|
+
"email": { "type": ["string", "null"] },
|
|
530
|
+
"planType": { "$ref": "#/definitions/PlanType" },
|
|
531
|
+
"type": {
|
|
532
|
+
"enum": ["chatgpt"],
|
|
533
|
+
"title": "ChatgptAccountType",
|
|
534
|
+
"type": "string"
|
|
535
|
+
}
|
|
536
|
+
},
|
|
537
|
+
"required": [
|
|
538
|
+
"email",
|
|
539
|
+
"planType",
|
|
540
|
+
"type"
|
|
541
|
+
],
|
|
542
|
+
"title": "ChatgptAccount",
|
|
543
|
+
"type": "object"
|
|
544
|
+
},
|
|
545
|
+
{
|
|
546
|
+
"properties": {
|
|
547
|
+
"type": {
|
|
548
|
+
"enum": ["amazonBedrock"],
|
|
549
|
+
"title": "AmazonBedrockAccountType",
|
|
550
|
+
"type": "string"
|
|
551
|
+
},
|
|
552
|
+
"usesCodexManagedCredentials": {
|
|
553
|
+
"default": false,
|
|
554
|
+
"type": "boolean"
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
"required": ["type"],
|
|
558
|
+
"title": "AmazonBedrockAccount",
|
|
559
|
+
"type": "object"
|
|
560
|
+
}
|
|
561
|
+
] },
|
|
562
|
+
"ActivePermissionProfile": {
|
|
563
|
+
"properties": {
|
|
564
|
+
"extends": {
|
|
565
|
+
"default": null,
|
|
566
|
+
"description": "Parent profile identifier from the selected permissions profile's `extends` setting, when present.",
|
|
567
|
+
"type": ["string", "null"]
|
|
568
|
+
},
|
|
569
|
+
"id": {
|
|
570
|
+
"description": "Identifier from `default_permissions` or the implicit built-in default, such as `:workspace` or a user-defined `[permissions.<id>]` profile.",
|
|
571
|
+
"type": "string"
|
|
572
|
+
}
|
|
573
|
+
},
|
|
574
|
+
"required": ["id"],
|
|
575
|
+
"type": "object"
|
|
576
|
+
},
|
|
577
|
+
"AgentMessageDelivery": {
|
|
578
|
+
"enum": ["async"],
|
|
579
|
+
"type": "string"
|
|
580
|
+
},
|
|
581
|
+
"AgentPath": { "type": "string" },
|
|
582
|
+
"ApprovalsReviewer": {
|
|
583
|
+
"description": "Configures who approval requests are routed to for review. Examples include sandbox escapes, blocked network access, MCP approval prompts, and ARC escalations. Defaults to `user`. `auto_review` uses a carefully prompted subagent to gather relevant context and apply a risk-based decision framework before approving or denying the request. The legacy value `guardian_subagent` is accepted for compatibility.",
|
|
584
|
+
"enum": [
|
|
585
|
+
"user",
|
|
586
|
+
"auto_review",
|
|
587
|
+
"guardian_subagent"
|
|
588
|
+
],
|
|
589
|
+
"type": "string"
|
|
590
|
+
},
|
|
591
|
+
"AskForApproval": { "oneOf": [{
|
|
592
|
+
"additionalProperties": false,
|
|
593
|
+
"properties": { "granular": {
|
|
594
|
+
"properties": {
|
|
595
|
+
"mcp_elicitations": { "type": "boolean" },
|
|
596
|
+
"request_permissions": {
|
|
597
|
+
"default": false,
|
|
598
|
+
"type": "boolean"
|
|
599
|
+
},
|
|
600
|
+
"rules": { "type": "boolean" },
|
|
601
|
+
"sandbox_approval": { "type": "boolean" },
|
|
602
|
+
"skill_approval": {
|
|
603
|
+
"default": false,
|
|
604
|
+
"type": "boolean"
|
|
605
|
+
}
|
|
606
|
+
},
|
|
607
|
+
"required": [
|
|
608
|
+
"mcp_elicitations",
|
|
609
|
+
"rules",
|
|
610
|
+
"sandbox_approval"
|
|
611
|
+
],
|
|
612
|
+
"type": "object"
|
|
613
|
+
} },
|
|
614
|
+
"required": ["granular"],
|
|
615
|
+
"title": "GranularAskForApproval",
|
|
616
|
+
"type": "object"
|
|
617
|
+
}, {
|
|
618
|
+
"enum": [
|
|
619
|
+
"untrusted",
|
|
620
|
+
"on-request",
|
|
621
|
+
"never"
|
|
622
|
+
],
|
|
623
|
+
"type": "string"
|
|
624
|
+
}] },
|
|
625
|
+
"AsyncUserInputQuestion": {
|
|
626
|
+
"additionalProperties": false,
|
|
627
|
+
"properties": {
|
|
628
|
+
"options": {
|
|
629
|
+
"items": { "type": "string" },
|
|
630
|
+
"type": ["array", "null"]
|
|
631
|
+
},
|
|
632
|
+
"title": { "type": "string" }
|
|
633
|
+
},
|
|
634
|
+
"required": ["title"],
|
|
635
|
+
"type": "object"
|
|
636
|
+
},
|
|
637
|
+
"ByteRange": {
|
|
638
|
+
"properties": {
|
|
639
|
+
"end": {
|
|
640
|
+
"format": "uint",
|
|
641
|
+
"minimum": 0,
|
|
642
|
+
"type": "integer"
|
|
643
|
+
},
|
|
644
|
+
"start": {
|
|
645
|
+
"format": "uint",
|
|
646
|
+
"minimum": 0,
|
|
647
|
+
"type": "integer"
|
|
648
|
+
}
|
|
649
|
+
},
|
|
650
|
+
"required": ["end", "start"],
|
|
651
|
+
"type": "object"
|
|
652
|
+
},
|
|
653
|
+
"CodexErrorInfo": {
|
|
654
|
+
"description": "This translation layer make sure that we expose codex error code in camel case.\n\nWhen an upstream HTTP status is available (for example, from the Responses API or a provider), it is forwarded in `httpStatusCode` on the relevant `codexErrorInfo` variant.",
|
|
655
|
+
"oneOf": [
|
|
656
|
+
{
|
|
657
|
+
"additionalProperties": false,
|
|
658
|
+
"properties": { "httpConnectionFailed": {
|
|
659
|
+
"properties": { "httpStatusCode": {
|
|
660
|
+
"format": "uint16",
|
|
661
|
+
"minimum": 0,
|
|
662
|
+
"type": ["integer", "null"]
|
|
663
|
+
} },
|
|
664
|
+
"type": "object"
|
|
665
|
+
} },
|
|
666
|
+
"required": ["httpConnectionFailed"],
|
|
667
|
+
"title": "HttpConnectionFailedCodexErrorInfo",
|
|
668
|
+
"type": "object"
|
|
669
|
+
},
|
|
670
|
+
{
|
|
671
|
+
"additionalProperties": false,
|
|
672
|
+
"description": "Failed to connect to the response SSE stream.",
|
|
673
|
+
"properties": { "responseStreamConnectionFailed": {
|
|
674
|
+
"properties": { "httpStatusCode": {
|
|
675
|
+
"format": "uint16",
|
|
676
|
+
"minimum": 0,
|
|
677
|
+
"type": ["integer", "null"]
|
|
678
|
+
} },
|
|
679
|
+
"type": "object"
|
|
680
|
+
} },
|
|
681
|
+
"required": ["responseStreamConnectionFailed"],
|
|
682
|
+
"title": "ResponseStreamConnectionFailedCodexErrorInfo",
|
|
683
|
+
"type": "object"
|
|
684
|
+
},
|
|
685
|
+
{
|
|
686
|
+
"additionalProperties": false,
|
|
687
|
+
"description": "The response SSE stream disconnected in the middle of a turn before completion.",
|
|
688
|
+
"properties": { "responseStreamDisconnected": {
|
|
689
|
+
"properties": { "httpStatusCode": {
|
|
690
|
+
"format": "uint16",
|
|
691
|
+
"minimum": 0,
|
|
692
|
+
"type": ["integer", "null"]
|
|
693
|
+
} },
|
|
694
|
+
"type": "object"
|
|
695
|
+
} },
|
|
696
|
+
"required": ["responseStreamDisconnected"],
|
|
697
|
+
"title": "ResponseStreamDisconnectedCodexErrorInfo",
|
|
698
|
+
"type": "object"
|
|
699
|
+
},
|
|
700
|
+
{
|
|
701
|
+
"additionalProperties": false,
|
|
702
|
+
"description": "Reached the retry limit for responses.",
|
|
703
|
+
"properties": { "responseTooManyFailedAttempts": {
|
|
704
|
+
"properties": { "httpStatusCode": {
|
|
705
|
+
"format": "uint16",
|
|
706
|
+
"minimum": 0,
|
|
707
|
+
"type": ["integer", "null"]
|
|
708
|
+
} },
|
|
709
|
+
"type": "object"
|
|
710
|
+
} },
|
|
711
|
+
"required": ["responseTooManyFailedAttempts"],
|
|
712
|
+
"title": "ResponseTooManyFailedAttemptsCodexErrorInfo",
|
|
713
|
+
"type": "object"
|
|
714
|
+
},
|
|
715
|
+
{
|
|
716
|
+
"additionalProperties": false,
|
|
717
|
+
"description": "Returned when `turn/start` or `turn/steer` is submitted while the current active turn cannot accept same-turn steering, for example `/review` or manual `/compact`.",
|
|
718
|
+
"properties": { "activeTurnNotSteerable": {
|
|
719
|
+
"properties": { "turnKind": { "$ref": "#/definitions/NonSteerableTurnKind" } },
|
|
720
|
+
"required": ["turnKind"],
|
|
721
|
+
"type": "object"
|
|
722
|
+
} },
|
|
723
|
+
"required": ["activeTurnNotSteerable"],
|
|
724
|
+
"title": "ActiveTurnNotSteerableCodexErrorInfo",
|
|
725
|
+
"type": "object"
|
|
726
|
+
},
|
|
727
|
+
{
|
|
728
|
+
"enum": [
|
|
729
|
+
"contextWindowExceeded",
|
|
730
|
+
"sessionBudgetExceeded",
|
|
731
|
+
"usageLimitExceeded",
|
|
732
|
+
"rateLimitExceeded",
|
|
733
|
+
"serverOverloaded",
|
|
734
|
+
"cyberPolicy",
|
|
735
|
+
"misalignmentPolicyViolation",
|
|
736
|
+
"internalServerError",
|
|
737
|
+
"unauthorized",
|
|
738
|
+
"badRequest",
|
|
739
|
+
"threadRollbackFailed",
|
|
740
|
+
"sandboxError",
|
|
741
|
+
"other"
|
|
742
|
+
],
|
|
743
|
+
"type": "string"
|
|
744
|
+
}
|
|
745
|
+
]
|
|
746
|
+
},
|
|
747
|
+
"CollabAgentState": {
|
|
748
|
+
"properties": {
|
|
749
|
+
"message": { "type": ["string", "null"] },
|
|
750
|
+
"status": { "$ref": "#/definitions/CollabAgentStatus" }
|
|
751
|
+
},
|
|
752
|
+
"required": ["status"],
|
|
753
|
+
"type": "object"
|
|
754
|
+
},
|
|
755
|
+
"CollabAgentStatus": {
|
|
756
|
+
"enum": [
|
|
757
|
+
"pendingInit",
|
|
758
|
+
"running",
|
|
759
|
+
"interrupted",
|
|
760
|
+
"completed",
|
|
761
|
+
"errored",
|
|
762
|
+
"shutdown",
|
|
763
|
+
"notFound"
|
|
764
|
+
],
|
|
765
|
+
"type": "string"
|
|
766
|
+
},
|
|
767
|
+
"CollabAgentTool": {
|
|
768
|
+
"enum": [
|
|
769
|
+
"spawnAgent",
|
|
770
|
+
"sendInput",
|
|
771
|
+
"resumeAgent",
|
|
772
|
+
"wait",
|
|
773
|
+
"closeAgent",
|
|
774
|
+
"sendMessage",
|
|
775
|
+
"followupTask",
|
|
776
|
+
"interruptAgent",
|
|
777
|
+
"listAgents"
|
|
778
|
+
],
|
|
779
|
+
"type": "string"
|
|
780
|
+
},
|
|
781
|
+
"CollabAgentToolCallStatus": {
|
|
782
|
+
"enum": [
|
|
783
|
+
"inProgress",
|
|
784
|
+
"completed",
|
|
785
|
+
"failed",
|
|
786
|
+
"interrupted"
|
|
787
|
+
],
|
|
788
|
+
"type": "string"
|
|
789
|
+
},
|
|
790
|
+
"CommandAction": { "oneOf": [
|
|
791
|
+
{
|
|
792
|
+
"properties": {
|
|
793
|
+
"command": { "type": "string" },
|
|
794
|
+
"name": { "type": "string" },
|
|
795
|
+
"path": { "$ref": "#/definitions/LegacyAppPathString" },
|
|
796
|
+
"type": {
|
|
797
|
+
"enum": ["read"],
|
|
798
|
+
"title": "ReadCommandActionType",
|
|
799
|
+
"type": "string"
|
|
800
|
+
}
|
|
801
|
+
},
|
|
802
|
+
"required": [
|
|
803
|
+
"command",
|
|
804
|
+
"name",
|
|
805
|
+
"path",
|
|
806
|
+
"type"
|
|
807
|
+
],
|
|
808
|
+
"title": "ReadCommandAction",
|
|
809
|
+
"type": "object"
|
|
810
|
+
},
|
|
811
|
+
{
|
|
812
|
+
"properties": {
|
|
813
|
+
"command": { "type": "string" },
|
|
814
|
+
"path": { "type": ["string", "null"] },
|
|
815
|
+
"type": {
|
|
816
|
+
"enum": ["listFiles"],
|
|
817
|
+
"title": "ListFilesCommandActionType",
|
|
818
|
+
"type": "string"
|
|
819
|
+
}
|
|
820
|
+
},
|
|
821
|
+
"required": ["command", "type"],
|
|
822
|
+
"title": "ListFilesCommandAction",
|
|
823
|
+
"type": "object"
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
"properties": {
|
|
827
|
+
"command": { "type": "string" },
|
|
828
|
+
"path": { "type": ["string", "null"] },
|
|
829
|
+
"query": { "type": ["string", "null"] },
|
|
830
|
+
"type": {
|
|
831
|
+
"enum": ["search"],
|
|
832
|
+
"title": "SearchCommandActionType",
|
|
833
|
+
"type": "string"
|
|
834
|
+
}
|
|
835
|
+
},
|
|
836
|
+
"required": ["command", "type"],
|
|
837
|
+
"title": "SearchCommandAction",
|
|
838
|
+
"type": "object"
|
|
839
|
+
},
|
|
840
|
+
{
|
|
841
|
+
"properties": {
|
|
842
|
+
"command": { "type": "string" },
|
|
843
|
+
"type": {
|
|
844
|
+
"enum": ["unknown"],
|
|
845
|
+
"title": "UnknownCommandActionType",
|
|
846
|
+
"type": "string"
|
|
847
|
+
}
|
|
848
|
+
},
|
|
849
|
+
"required": ["command", "type"],
|
|
850
|
+
"title": "UnknownCommandAction",
|
|
851
|
+
"type": "object"
|
|
852
|
+
}
|
|
853
|
+
] },
|
|
854
|
+
"CommandExecutionSource": {
|
|
855
|
+
"enum": [
|
|
856
|
+
"agent",
|
|
857
|
+
"userShell",
|
|
858
|
+
"unifiedExecStartup",
|
|
859
|
+
"unifiedExecInteraction"
|
|
860
|
+
],
|
|
861
|
+
"type": "string"
|
|
862
|
+
},
|
|
863
|
+
"CommandExecutionStatus": {
|
|
864
|
+
"enum": [
|
|
865
|
+
"inProgress",
|
|
866
|
+
"completed",
|
|
867
|
+
"failed",
|
|
868
|
+
"declined"
|
|
869
|
+
],
|
|
870
|
+
"type": "string"
|
|
871
|
+
},
|
|
872
|
+
"DynamicToolCallOutputContentItem": { "oneOf": [
|
|
873
|
+
{
|
|
874
|
+
"properties": {
|
|
875
|
+
"text": { "type": "string" },
|
|
876
|
+
"type": {
|
|
877
|
+
"enum": ["inputText"],
|
|
878
|
+
"title": "InputTextDynamicToolCallOutputContentItemType",
|
|
879
|
+
"type": "string"
|
|
880
|
+
}
|
|
881
|
+
},
|
|
882
|
+
"required": ["text", "type"],
|
|
883
|
+
"title": "InputTextDynamicToolCallOutputContentItem",
|
|
884
|
+
"type": "object"
|
|
885
|
+
},
|
|
886
|
+
{
|
|
887
|
+
"properties": {
|
|
888
|
+
"imageUrl": { "type": "string" },
|
|
889
|
+
"type": {
|
|
890
|
+
"enum": ["inputImage"],
|
|
891
|
+
"title": "InputImageDynamicToolCallOutputContentItemType",
|
|
892
|
+
"type": "string"
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
"required": ["imageUrl", "type"],
|
|
896
|
+
"title": "InputImageDynamicToolCallOutputContentItem",
|
|
897
|
+
"type": "object"
|
|
898
|
+
},
|
|
899
|
+
{
|
|
900
|
+
"properties": {
|
|
901
|
+
"audioUrl": { "type": "string" },
|
|
902
|
+
"type": {
|
|
903
|
+
"enum": ["inputAudio"],
|
|
904
|
+
"title": "InputAudioDynamicToolCallOutputContentItemType",
|
|
905
|
+
"type": "string"
|
|
906
|
+
}
|
|
907
|
+
},
|
|
908
|
+
"required": ["audioUrl", "type"],
|
|
909
|
+
"title": "InputAudioDynamicToolCallOutputContentItem",
|
|
910
|
+
"type": "object"
|
|
911
|
+
}
|
|
912
|
+
] },
|
|
913
|
+
"DynamicToolCallStatus": {
|
|
914
|
+
"enum": [
|
|
915
|
+
"inProgress",
|
|
916
|
+
"completed",
|
|
917
|
+
"failed"
|
|
918
|
+
],
|
|
919
|
+
"type": "string"
|
|
920
|
+
},
|
|
921
|
+
"FileUpdateChange": {
|
|
922
|
+
"properties": {
|
|
923
|
+
"diff": { "type": "string" },
|
|
924
|
+
"kind": { "$ref": "#/definitions/PatchChangeKind" },
|
|
925
|
+
"path": { "type": "string" }
|
|
926
|
+
},
|
|
927
|
+
"required": [
|
|
928
|
+
"diff",
|
|
929
|
+
"kind",
|
|
930
|
+
"path"
|
|
931
|
+
],
|
|
932
|
+
"type": "object"
|
|
933
|
+
},
|
|
934
|
+
"FunctionCallOutputBody": { "anyOf": [{
|
|
935
|
+
"items": { "$ref": "#/definitions/FunctionCallOutputContentItem" },
|
|
936
|
+
"type": "array"
|
|
937
|
+
}, { "type": "string" }] },
|
|
938
|
+
"FunctionCallOutputContentItem": {
|
|
939
|
+
"description": "Responses API compatible content items that can be returned by a tool call. This is a subset of ContentItem with the types we support as function call outputs.",
|
|
940
|
+
"oneOf": [
|
|
941
|
+
{
|
|
942
|
+
"properties": {
|
|
943
|
+
"text": { "type": "string" },
|
|
944
|
+
"type": {
|
|
945
|
+
"enum": ["input_text"],
|
|
946
|
+
"title": "InputTextFunctionCallOutputContentItemType",
|
|
947
|
+
"type": "string"
|
|
948
|
+
}
|
|
949
|
+
},
|
|
950
|
+
"required": ["text", "type"],
|
|
951
|
+
"title": "InputTextFunctionCallOutputContentItem",
|
|
952
|
+
"type": "object"
|
|
953
|
+
},
|
|
954
|
+
{
|
|
955
|
+
"properties": {
|
|
956
|
+
"detail": { "anyOf": [{ "$ref": "#/definitions/ImageDetail" }, { "type": "null" }] },
|
|
957
|
+
"image_url": { "type": "string" },
|
|
958
|
+
"type": {
|
|
959
|
+
"enum": ["input_image"],
|
|
960
|
+
"title": "InputImageFunctionCallOutputContentItemType",
|
|
961
|
+
"type": "string"
|
|
962
|
+
}
|
|
963
|
+
},
|
|
964
|
+
"required": ["image_url", "type"],
|
|
965
|
+
"title": "InputImageFunctionCallOutputContentItem",
|
|
966
|
+
"type": "object"
|
|
967
|
+
},
|
|
968
|
+
{
|
|
969
|
+
"properties": {
|
|
970
|
+
"audio_url": { "type": "string" },
|
|
971
|
+
"type": {
|
|
972
|
+
"enum": ["input_audio"],
|
|
973
|
+
"title": "InputAudioFunctionCallOutputContentItemType",
|
|
974
|
+
"type": "string"
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
"required": ["audio_url", "type"],
|
|
978
|
+
"title": "InputAudioFunctionCallOutputContentItem",
|
|
979
|
+
"type": "object"
|
|
980
|
+
},
|
|
981
|
+
{
|
|
982
|
+
"properties": {
|
|
983
|
+
"encrypted_content": { "type": "string" },
|
|
984
|
+
"type": {
|
|
985
|
+
"enum": ["encrypted_content"],
|
|
986
|
+
"title": "EncryptedContentFunctionCallOutputContentItemType",
|
|
987
|
+
"type": "string"
|
|
988
|
+
}
|
|
989
|
+
},
|
|
990
|
+
"required": ["encrypted_content", "type"],
|
|
991
|
+
"title": "EncryptedContentFunctionCallOutputContentItem",
|
|
992
|
+
"type": "object"
|
|
993
|
+
}
|
|
994
|
+
]
|
|
995
|
+
},
|
|
996
|
+
"GitInfo": {
|
|
997
|
+
"properties": {
|
|
998
|
+
"branch": { "type": ["string", "null"] },
|
|
999
|
+
"originUrl": { "type": ["string", "null"] },
|
|
1000
|
+
"sha": { "type": ["string", "null"] }
|
|
1001
|
+
},
|
|
1002
|
+
"type": "object"
|
|
1003
|
+
},
|
|
1004
|
+
"HookPromptFragment": {
|
|
1005
|
+
"properties": {
|
|
1006
|
+
"hookRunId": { "type": "string" },
|
|
1007
|
+
"text": { "type": "string" }
|
|
1008
|
+
},
|
|
1009
|
+
"required": ["hookRunId", "text"],
|
|
1010
|
+
"type": "object"
|
|
1011
|
+
},
|
|
1012
|
+
"ImageDetail": {
|
|
1013
|
+
"enum": [
|
|
1014
|
+
"auto",
|
|
1015
|
+
"low",
|
|
1016
|
+
"high",
|
|
1017
|
+
"original"
|
|
1018
|
+
],
|
|
1019
|
+
"type": "string"
|
|
1020
|
+
},
|
|
1021
|
+
"ImageGenerationFailure": { "oneOf": [{
|
|
1022
|
+
"properties": {
|
|
1023
|
+
"limitId": { "type": "string" },
|
|
1024
|
+
"resetsAt": {
|
|
1025
|
+
"format": "int64",
|
|
1026
|
+
"type": ["integer", "null"]
|
|
1027
|
+
},
|
|
1028
|
+
"type": {
|
|
1029
|
+
"enum": ["usageLimitExceeded"],
|
|
1030
|
+
"title": "UsageLimitExceededImageGenerationFailureType",
|
|
1031
|
+
"type": "string"
|
|
1032
|
+
}
|
|
1033
|
+
},
|
|
1034
|
+
"required": ["limitId", "type"],
|
|
1035
|
+
"title": "UsageLimitExceededImageGenerationFailure",
|
|
1036
|
+
"type": "object"
|
|
1037
|
+
}] },
|
|
1038
|
+
"InputModality": {
|
|
1039
|
+
"description": "Canonical user-input modality tags advertised by a model.",
|
|
1040
|
+
"oneOf": [
|
|
1041
|
+
{
|
|
1042
|
+
"description": "Plain text turns and tool payloads.",
|
|
1043
|
+
"enum": ["text"],
|
|
1044
|
+
"type": "string"
|
|
1045
|
+
},
|
|
1046
|
+
{
|
|
1047
|
+
"description": "Image attachments included in user turns.",
|
|
1048
|
+
"enum": ["image"],
|
|
1049
|
+
"type": "string"
|
|
1050
|
+
},
|
|
1051
|
+
{
|
|
1052
|
+
"description": "Audio attachments included in user turns.",
|
|
1053
|
+
"enum": ["audio"],
|
|
1054
|
+
"type": "string"
|
|
1055
|
+
}
|
|
1056
|
+
]
|
|
1057
|
+
},
|
|
1058
|
+
"LegacyAppPathString": { "type": "string" },
|
|
1059
|
+
"McpToolCallAppContext": {
|
|
1060
|
+
"properties": {
|
|
1061
|
+
"actionName": { "type": ["string", "null"] },
|
|
1062
|
+
"appName": { "type": ["string", "null"] },
|
|
1063
|
+
"connectorId": { "type": "string" },
|
|
1064
|
+
"linkId": { "type": ["string", "null"] },
|
|
1065
|
+
"resourceUri": { "type": ["string", "null"] }
|
|
1066
|
+
},
|
|
1067
|
+
"required": ["connectorId"],
|
|
1068
|
+
"type": "object"
|
|
1069
|
+
},
|
|
1070
|
+
"McpToolCallError": {
|
|
1071
|
+
"properties": { "message": { "type": "string" } },
|
|
1072
|
+
"required": ["message"],
|
|
1073
|
+
"type": "object"
|
|
1074
|
+
},
|
|
1075
|
+
"McpToolCallResult": {
|
|
1076
|
+
"properties": {
|
|
1077
|
+
"_meta": true,
|
|
1078
|
+
"content": {
|
|
1079
|
+
"items": true,
|
|
1080
|
+
"type": "array"
|
|
1081
|
+
},
|
|
1082
|
+
"structuredContent": true
|
|
1083
|
+
},
|
|
1084
|
+
"required": ["content"],
|
|
1085
|
+
"type": "object"
|
|
1086
|
+
},
|
|
1087
|
+
"McpToolCallStatus": {
|
|
1088
|
+
"enum": [
|
|
1089
|
+
"inProgress",
|
|
1090
|
+
"completed",
|
|
1091
|
+
"failed"
|
|
1092
|
+
],
|
|
1093
|
+
"type": "string"
|
|
1094
|
+
},
|
|
1095
|
+
"MemoryCitation": {
|
|
1096
|
+
"properties": {
|
|
1097
|
+
"entries": {
|
|
1098
|
+
"items": { "$ref": "#/definitions/MemoryCitationEntry" },
|
|
1099
|
+
"type": "array"
|
|
1100
|
+
},
|
|
1101
|
+
"threadIds": {
|
|
1102
|
+
"items": { "type": "string" },
|
|
1103
|
+
"type": "array"
|
|
1104
|
+
}
|
|
1105
|
+
},
|
|
1106
|
+
"required": ["entries", "threadIds"],
|
|
1107
|
+
"type": "object"
|
|
1108
|
+
},
|
|
1109
|
+
"MemoryCitationEntry": {
|
|
1110
|
+
"properties": {
|
|
1111
|
+
"lineEnd": {
|
|
1112
|
+
"format": "uint32",
|
|
1113
|
+
"minimum": 0,
|
|
1114
|
+
"type": "integer"
|
|
1115
|
+
},
|
|
1116
|
+
"lineStart": {
|
|
1117
|
+
"format": "uint32",
|
|
1118
|
+
"minimum": 0,
|
|
1119
|
+
"type": "integer"
|
|
1120
|
+
},
|
|
1121
|
+
"note": { "type": "string" },
|
|
1122
|
+
"path": { "type": "string" }
|
|
1123
|
+
},
|
|
1124
|
+
"required": [
|
|
1125
|
+
"lineEnd",
|
|
1126
|
+
"lineStart",
|
|
1127
|
+
"note",
|
|
1128
|
+
"path"
|
|
1129
|
+
],
|
|
1130
|
+
"type": "object"
|
|
1131
|
+
},
|
|
1132
|
+
"MessagePhase": {
|
|
1133
|
+
"description": "Classifies an assistant message as interim commentary or final answer text.\n\nProviders do not emit this consistently, so callers must treat `None` as \"phase unknown\" and keep compatibility behavior for legacy models.",
|
|
1134
|
+
"oneOf": [{
|
|
1135
|
+
"description": "Mid-turn assistant text (for example preamble/progress narration).\n\nAdditional tool calls or assistant output may follow before turn completion.",
|
|
1136
|
+
"enum": ["commentary"],
|
|
1137
|
+
"type": "string"
|
|
1138
|
+
}, {
|
|
1139
|
+
"description": "The assistant's terminal answer text for the current turn.",
|
|
1140
|
+
"enum": ["final_answer"],
|
|
1141
|
+
"type": "string"
|
|
1142
|
+
}]
|
|
1143
|
+
},
|
|
1144
|
+
"MisalignmentErrorDetails": {
|
|
1145
|
+
"properties": {
|
|
1146
|
+
"detailedExplanation": {
|
|
1147
|
+
"description": "A substantive localized explanation is required before offering continuation.",
|
|
1148
|
+
"type": ["string", "null"]
|
|
1149
|
+
},
|
|
1150
|
+
"errorType": {
|
|
1151
|
+
"description": "Open-ended classification; clients must accept categories added by Responses.",
|
|
1152
|
+
"type": ["string", "null"]
|
|
1153
|
+
},
|
|
1154
|
+
"steer": {
|
|
1155
|
+
"anyOf": [{ "$ref": "#/definitions/MisalignmentSteer" }, { "type": "null" }],
|
|
1156
|
+
"description": "Instruction to submit as the next turn's user input if continuation is confirmed."
|
|
1157
|
+
}
|
|
1158
|
+
},
|
|
1159
|
+
"type": "object"
|
|
1160
|
+
},
|
|
1161
|
+
"MisalignmentSteer": {
|
|
1162
|
+
"properties": { "message": { "type": "string" } },
|
|
1163
|
+
"required": ["message"],
|
|
1164
|
+
"type": "object"
|
|
1165
|
+
},
|
|
1166
|
+
"Model": {
|
|
1167
|
+
"properties": {
|
|
1168
|
+
"additionalSpeedTiers": {
|
|
1169
|
+
"default": [],
|
|
1170
|
+
"description": "Deprecated: use `serviceTiers` instead.",
|
|
1171
|
+
"items": { "type": "string" },
|
|
1172
|
+
"type": "array"
|
|
1173
|
+
},
|
|
1174
|
+
"availabilityNux": { "anyOf": [{ "$ref": "#/definitions/ModelAvailabilityNux" }, { "type": "null" }] },
|
|
1175
|
+
"defaultReasoningEffort": { "$ref": "#/definitions/ReasoningEffort" },
|
|
1176
|
+
"defaultServiceTier": {
|
|
1177
|
+
"default": null,
|
|
1178
|
+
"description": "Catalog default service tier id for this model, when one is configured.",
|
|
1179
|
+
"type": ["string", "null"]
|
|
1180
|
+
},
|
|
1181
|
+
"description": { "type": "string" },
|
|
1182
|
+
"displayName": { "type": "string" },
|
|
1183
|
+
"hidden": { "type": "boolean" },
|
|
1184
|
+
"id": { "type": "string" },
|
|
1185
|
+
"inputModalities": {
|
|
1186
|
+
"default": ["text", "image"],
|
|
1187
|
+
"items": { "$ref": "#/definitions/InputModality" },
|
|
1188
|
+
"type": "array"
|
|
1189
|
+
},
|
|
1190
|
+
"isDefault": { "type": "boolean" },
|
|
1191
|
+
"model": { "type": "string" },
|
|
1192
|
+
"modelSpecialty": {
|
|
1193
|
+
"default": null,
|
|
1194
|
+
"type": ["string", "null"]
|
|
1195
|
+
},
|
|
1196
|
+
"multiAgentVersion": {
|
|
1197
|
+
"anyOf": [{ "$ref": "#/definitions/MultiAgentVersion" }, { "type": "null" }],
|
|
1198
|
+
"description": "Multi-agent runtime declared by this model, when available."
|
|
1199
|
+
},
|
|
1200
|
+
"serviceTiers": {
|
|
1201
|
+
"default": [],
|
|
1202
|
+
"items": { "$ref": "#/definitions/ModelServiceTier" },
|
|
1203
|
+
"type": "array"
|
|
1204
|
+
},
|
|
1205
|
+
"supportedReasoningEfforts": {
|
|
1206
|
+
"items": { "$ref": "#/definitions/ReasoningEffortOption" },
|
|
1207
|
+
"type": "array"
|
|
1208
|
+
},
|
|
1209
|
+
"supportsPersonality": {
|
|
1210
|
+
"default": false,
|
|
1211
|
+
"type": "boolean"
|
|
1212
|
+
},
|
|
1213
|
+
"upgrade": { "type": ["string", "null"] },
|
|
1214
|
+
"upgradeInfo": { "anyOf": [{ "$ref": "#/definitions/ModelUpgradeInfo" }, { "type": "null" }] }
|
|
1215
|
+
},
|
|
1216
|
+
"required": [
|
|
1217
|
+
"defaultReasoningEffort",
|
|
1218
|
+
"description",
|
|
1219
|
+
"displayName",
|
|
1220
|
+
"hidden",
|
|
1221
|
+
"id",
|
|
1222
|
+
"isDefault",
|
|
1223
|
+
"model",
|
|
1224
|
+
"supportedReasoningEfforts"
|
|
1225
|
+
],
|
|
1226
|
+
"type": "object"
|
|
1227
|
+
},
|
|
1228
|
+
"ModelAvailabilityNux": {
|
|
1229
|
+
"properties": { "message": { "type": "string" } },
|
|
1230
|
+
"required": ["message"],
|
|
1231
|
+
"type": "object"
|
|
1232
|
+
},
|
|
1233
|
+
"ModelServiceTier": {
|
|
1234
|
+
"properties": {
|
|
1235
|
+
"description": { "type": "string" },
|
|
1236
|
+
"id": { "type": "string" },
|
|
1237
|
+
"name": { "type": "string" }
|
|
1238
|
+
},
|
|
1239
|
+
"required": [
|
|
1240
|
+
"description",
|
|
1241
|
+
"id",
|
|
1242
|
+
"name"
|
|
1243
|
+
],
|
|
1244
|
+
"type": "object"
|
|
1245
|
+
},
|
|
1246
|
+
"ModelUpgradeInfo": {
|
|
1247
|
+
"properties": {
|
|
1248
|
+
"migrationMarkdown": { "type": ["string", "null"] },
|
|
1249
|
+
"model": { "type": "string" },
|
|
1250
|
+
"modelLink": { "type": ["string", "null"] },
|
|
1251
|
+
"retirementAt": {
|
|
1252
|
+
"description": "Informational Unix timestamp for this upgrade's scheduled retirement, if known.",
|
|
1253
|
+
"format": "int64",
|
|
1254
|
+
"type": ["integer", "null"]
|
|
1255
|
+
},
|
|
1256
|
+
"upgradeCopy": { "type": ["string", "null"] }
|
|
1257
|
+
},
|
|
1258
|
+
"required": ["model"],
|
|
1259
|
+
"type": "object"
|
|
1260
|
+
},
|
|
1261
|
+
"MultiAgentMode": {
|
|
1262
|
+
"description": "Controls the effective multi-agent delegation instructions for a turn. `custom` means the configured mode hint defines the policy instead of a built-in policy.",
|
|
1263
|
+
"oneOf": [{
|
|
1264
|
+
"additionalProperties": false,
|
|
1265
|
+
"properties": { "custom": { "type": "string" } },
|
|
1266
|
+
"required": ["custom"],
|
|
1267
|
+
"title": "CustomMultiAgentMode",
|
|
1268
|
+
"type": "object"
|
|
1269
|
+
}, {
|
|
1270
|
+
"enum": ["explicitRequestOnly", "proactive"],
|
|
1271
|
+
"type": "string"
|
|
1272
|
+
}]
|
|
1273
|
+
},
|
|
1274
|
+
"MultiAgentVersion": {
|
|
1275
|
+
"description": "Multi-agent runtime supported by a model.",
|
|
1276
|
+
"enum": [
|
|
1277
|
+
"disabled",
|
|
1278
|
+
"v1",
|
|
1279
|
+
"v2"
|
|
1280
|
+
],
|
|
1281
|
+
"type": "string"
|
|
1282
|
+
},
|
|
1283
|
+
"NetworkAccess": {
|
|
1284
|
+
"enum": ["restricted", "enabled"],
|
|
1285
|
+
"type": "string"
|
|
1286
|
+
},
|
|
1287
|
+
"NonSteerableTurnKind": {
|
|
1288
|
+
"enum": ["review", "compact"],
|
|
1289
|
+
"type": "string"
|
|
1290
|
+
},
|
|
1291
|
+
"PatchApplyStatus": {
|
|
1292
|
+
"enum": [
|
|
1293
|
+
"inProgress",
|
|
1294
|
+
"completed",
|
|
1295
|
+
"failed",
|
|
1296
|
+
"declined"
|
|
1297
|
+
],
|
|
1298
|
+
"type": "string"
|
|
1299
|
+
},
|
|
1300
|
+
"PatchChangeKind": { "oneOf": [
|
|
1301
|
+
{
|
|
1302
|
+
"properties": { "type": {
|
|
1303
|
+
"enum": ["add"],
|
|
1304
|
+
"title": "AddPatchChangeKindType",
|
|
1305
|
+
"type": "string"
|
|
1306
|
+
} },
|
|
1307
|
+
"required": ["type"],
|
|
1308
|
+
"title": "AddPatchChangeKind",
|
|
1309
|
+
"type": "object"
|
|
1310
|
+
},
|
|
1311
|
+
{
|
|
1312
|
+
"properties": { "type": {
|
|
1313
|
+
"enum": ["delete"],
|
|
1314
|
+
"title": "DeletePatchChangeKindType",
|
|
1315
|
+
"type": "string"
|
|
1316
|
+
} },
|
|
1317
|
+
"required": ["type"],
|
|
1318
|
+
"title": "DeletePatchChangeKind",
|
|
1319
|
+
"type": "object"
|
|
1320
|
+
},
|
|
1321
|
+
{
|
|
1322
|
+
"properties": {
|
|
1323
|
+
"move_path": { "type": ["string", "null"] },
|
|
1324
|
+
"type": {
|
|
1325
|
+
"enum": ["update"],
|
|
1326
|
+
"title": "UpdatePatchChangeKindType",
|
|
1327
|
+
"type": "string"
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
"required": ["type"],
|
|
1331
|
+
"title": "UpdatePatchChangeKind",
|
|
1332
|
+
"type": "object"
|
|
1333
|
+
}
|
|
1334
|
+
] },
|
|
1335
|
+
"PlanType": {
|
|
1336
|
+
"enum": [
|
|
1337
|
+
"free",
|
|
1338
|
+
"go",
|
|
1339
|
+
"plus",
|
|
1340
|
+
"pro",
|
|
1341
|
+
"prolite",
|
|
1342
|
+
"team",
|
|
1343
|
+
"self_serve_business_prolite",
|
|
1344
|
+
"self_serve_business_usage_based",
|
|
1345
|
+
"business",
|
|
1346
|
+
"ent26",
|
|
1347
|
+
"enterprise_cbp_automation",
|
|
1348
|
+
"enterprise_cbp_usage_based",
|
|
1349
|
+
"enterprise",
|
|
1350
|
+
"edu",
|
|
1351
|
+
"edu_plus",
|
|
1352
|
+
"edu_pro",
|
|
1353
|
+
"unknown"
|
|
1354
|
+
],
|
|
1355
|
+
"type": "string"
|
|
1356
|
+
},
|
|
1357
|
+
"ReasoningEffort": {
|
|
1358
|
+
"description": "A non-empty reasoning effort value advertised by the model.",
|
|
1359
|
+
"minLength": 1,
|
|
1360
|
+
"type": "string"
|
|
1361
|
+
},
|
|
1362
|
+
"ReasoningEffortOption": {
|
|
1363
|
+
"properties": {
|
|
1364
|
+
"description": { "type": "string" },
|
|
1365
|
+
"reasoningEffort": { "$ref": "#/definitions/ReasoningEffort" }
|
|
1366
|
+
},
|
|
1367
|
+
"required": ["description", "reasoningEffort"],
|
|
1368
|
+
"type": "object"
|
|
1369
|
+
},
|
|
1370
|
+
"SandboxPolicy": { "oneOf": [
|
|
1371
|
+
{
|
|
1372
|
+
"properties": { "type": {
|
|
1373
|
+
"enum": ["dangerFullAccess"],
|
|
1374
|
+
"title": "DangerFullAccessSandboxPolicyType",
|
|
1375
|
+
"type": "string"
|
|
1376
|
+
} },
|
|
1377
|
+
"required": ["type"],
|
|
1378
|
+
"title": "DangerFullAccessSandboxPolicy",
|
|
1379
|
+
"type": "object"
|
|
1380
|
+
},
|
|
1381
|
+
{
|
|
1382
|
+
"properties": {
|
|
1383
|
+
"networkAccess": {
|
|
1384
|
+
"default": false,
|
|
1385
|
+
"type": "boolean"
|
|
1386
|
+
},
|
|
1387
|
+
"type": {
|
|
1388
|
+
"enum": ["readOnly"],
|
|
1389
|
+
"title": "ReadOnlySandboxPolicyType",
|
|
1390
|
+
"type": "string"
|
|
1391
|
+
}
|
|
1392
|
+
},
|
|
1393
|
+
"required": ["type"],
|
|
1394
|
+
"title": "ReadOnlySandboxPolicy",
|
|
1395
|
+
"type": "object"
|
|
1396
|
+
},
|
|
1397
|
+
{
|
|
1398
|
+
"properties": {
|
|
1399
|
+
"networkAccess": {
|
|
1400
|
+
"allOf": [{ "$ref": "#/definitions/NetworkAccess" }],
|
|
1401
|
+
"default": "restricted"
|
|
1402
|
+
},
|
|
1403
|
+
"type": {
|
|
1404
|
+
"enum": ["externalSandbox"],
|
|
1405
|
+
"title": "ExternalSandboxSandboxPolicyType",
|
|
1406
|
+
"type": "string"
|
|
1407
|
+
}
|
|
1408
|
+
},
|
|
1409
|
+
"required": ["type"],
|
|
1410
|
+
"title": "ExternalSandboxSandboxPolicy",
|
|
1411
|
+
"type": "object"
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
"properties": {
|
|
1415
|
+
"excludeSlashTmp": {
|
|
1416
|
+
"default": false,
|
|
1417
|
+
"type": "boolean"
|
|
1418
|
+
},
|
|
1419
|
+
"excludeTmpdirEnvVar": {
|
|
1420
|
+
"default": false,
|
|
1421
|
+
"type": "boolean"
|
|
1422
|
+
},
|
|
1423
|
+
"networkAccess": {
|
|
1424
|
+
"default": false,
|
|
1425
|
+
"type": "boolean"
|
|
1426
|
+
},
|
|
1427
|
+
"type": {
|
|
1428
|
+
"enum": ["workspaceWrite"],
|
|
1429
|
+
"title": "WorkspaceWriteSandboxPolicyType",
|
|
1430
|
+
"type": "string"
|
|
1431
|
+
},
|
|
1432
|
+
"writableRoots": {
|
|
1433
|
+
"default": [],
|
|
1434
|
+
"items": { "$ref": "#/definitions/AbsolutePathBuf" },
|
|
1435
|
+
"type": "array"
|
|
1436
|
+
}
|
|
1437
|
+
},
|
|
1438
|
+
"required": ["type"],
|
|
1439
|
+
"title": "WorkspaceWriteSandboxPolicy",
|
|
1440
|
+
"type": "object"
|
|
1441
|
+
}
|
|
1442
|
+
] },
|
|
1443
|
+
"SessionSource": { "oneOf": [
|
|
1444
|
+
{
|
|
1445
|
+
"additionalProperties": false,
|
|
1446
|
+
"properties": { "custom": { "type": "string" } },
|
|
1447
|
+
"required": ["custom"],
|
|
1448
|
+
"title": "CustomSessionSource",
|
|
1449
|
+
"type": "object"
|
|
1450
|
+
},
|
|
1451
|
+
{
|
|
1452
|
+
"additionalProperties": false,
|
|
1453
|
+
"properties": { "subAgent": { "$ref": "#/definitions/SubAgentSource" } },
|
|
1454
|
+
"required": ["subAgent"],
|
|
1455
|
+
"title": "SubAgentSessionSource",
|
|
1456
|
+
"type": "object"
|
|
1457
|
+
},
|
|
1458
|
+
{
|
|
1459
|
+
"enum": [
|
|
1460
|
+
"cli",
|
|
1461
|
+
"vscode",
|
|
1462
|
+
"exec",
|
|
1463
|
+
"appServer",
|
|
1464
|
+
"unknown"
|
|
1465
|
+
],
|
|
1466
|
+
"type": "string"
|
|
1467
|
+
}
|
|
1468
|
+
] },
|
|
1469
|
+
"SubAgentActivityKind": {
|
|
1470
|
+
"enum": [
|
|
1471
|
+
"started",
|
|
1472
|
+
"interacted",
|
|
1473
|
+
"interrupted",
|
|
1474
|
+
"completed"
|
|
1475
|
+
],
|
|
1476
|
+
"type": "string"
|
|
1477
|
+
},
|
|
1478
|
+
"SubAgentSource": { "oneOf": [
|
|
1479
|
+
{
|
|
1480
|
+
"additionalProperties": false,
|
|
1481
|
+
"properties": { "thread_spawn": {
|
|
1482
|
+
"properties": {
|
|
1483
|
+
"agent_nickname": {
|
|
1484
|
+
"default": null,
|
|
1485
|
+
"type": ["string", "null"]
|
|
1486
|
+
},
|
|
1487
|
+
"agent_path": {
|
|
1488
|
+
"anyOf": [{ "$ref": "#/definitions/AgentPath" }, { "type": "null" }],
|
|
1489
|
+
"default": null
|
|
1490
|
+
},
|
|
1491
|
+
"agent_role": {
|
|
1492
|
+
"default": null,
|
|
1493
|
+
"type": ["string", "null"]
|
|
1494
|
+
},
|
|
1495
|
+
"depth": {
|
|
1496
|
+
"format": "int32",
|
|
1497
|
+
"type": "integer"
|
|
1498
|
+
},
|
|
1499
|
+
"parent_thread_id": { "$ref": "#/definitions/ThreadId" }
|
|
1500
|
+
},
|
|
1501
|
+
"required": ["depth", "parent_thread_id"],
|
|
1502
|
+
"type": "object"
|
|
1503
|
+
} },
|
|
1504
|
+
"required": ["thread_spawn"],
|
|
1505
|
+
"title": "ThreadSpawnSubAgentSource",
|
|
1506
|
+
"type": "object"
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
"additionalProperties": false,
|
|
1510
|
+
"properties": { "other": { "type": "string" } },
|
|
1511
|
+
"required": ["other"],
|
|
1512
|
+
"title": "OtherSubAgentSource",
|
|
1513
|
+
"type": "object"
|
|
1514
|
+
},
|
|
1515
|
+
{
|
|
1516
|
+
"enum": [
|
|
1517
|
+
"review",
|
|
1518
|
+
"compact",
|
|
1519
|
+
"memory_consolidation"
|
|
1520
|
+
],
|
|
1521
|
+
"type": "string"
|
|
1522
|
+
}
|
|
1523
|
+
] },
|
|
1524
|
+
"TextElement": {
|
|
1525
|
+
"properties": {
|
|
1526
|
+
"byteRange": {
|
|
1527
|
+
"allOf": [{ "$ref": "#/definitions/ByteRange" }],
|
|
1528
|
+
"description": "Byte range in the parent `text` buffer that this element occupies."
|
|
1529
|
+
},
|
|
1530
|
+
"placeholder": {
|
|
1531
|
+
"description": "Optional human-readable placeholder for the element, displayed in the UI.",
|
|
1532
|
+
"type": ["string", "null"]
|
|
1533
|
+
}
|
|
1534
|
+
},
|
|
1535
|
+
"required": ["byteRange"],
|
|
1536
|
+
"type": "object"
|
|
1537
|
+
},
|
|
1538
|
+
"Thread": {
|
|
1539
|
+
"properties": {
|
|
1540
|
+
"agentNickname": {
|
|
1541
|
+
"description": "Optional random unique nickname assigned to an AgentControl-spawned sub-agent.",
|
|
1542
|
+
"type": ["string", "null"]
|
|
1543
|
+
},
|
|
1544
|
+
"agentRole": {
|
|
1545
|
+
"description": "Optional role (agent_role) assigned to an AgentControl-spawned sub-agent.",
|
|
1546
|
+
"type": ["string", "null"]
|
|
1547
|
+
},
|
|
1548
|
+
"canAcceptDirectInput": {
|
|
1549
|
+
"description": "Whether the app server accepts direct turn input for this loaded thread. `None` means the capability is unavailable, such as for an unloaded stored thread.",
|
|
1550
|
+
"type": ["boolean", "null"]
|
|
1551
|
+
},
|
|
1552
|
+
"cliVersion": {
|
|
1553
|
+
"description": "Version of the CLI that created the thread.",
|
|
1554
|
+
"type": "string"
|
|
1555
|
+
},
|
|
1556
|
+
"createdAt": {
|
|
1557
|
+
"description": "Unix timestamp (in seconds) when the thread was created.",
|
|
1558
|
+
"format": "int64",
|
|
1559
|
+
"type": "integer"
|
|
1560
|
+
},
|
|
1561
|
+
"cwd": {
|
|
1562
|
+
"allOf": [{ "$ref": "#/definitions/AbsolutePathBuf" }],
|
|
1563
|
+
"description": "Working directory captured for the thread."
|
|
1564
|
+
},
|
|
1565
|
+
"ephemeral": {
|
|
1566
|
+
"description": "Whether the thread is ephemeral and should not be materialized on disk.",
|
|
1567
|
+
"type": "boolean"
|
|
1568
|
+
},
|
|
1569
|
+
"extra": {
|
|
1570
|
+
"anyOf": [{ "$ref": "#/definitions/ThreadExtra" }, { "type": "null" }],
|
|
1571
|
+
"description": "Optional implementation-specific thread data."
|
|
1572
|
+
},
|
|
1573
|
+
"forkedFromId": {
|
|
1574
|
+
"description": "Source thread id when this thread was created by forking another thread.",
|
|
1575
|
+
"type": ["string", "null"]
|
|
1576
|
+
},
|
|
1577
|
+
"gitInfo": {
|
|
1578
|
+
"anyOf": [{ "$ref": "#/definitions/GitInfo" }, { "type": "null" }],
|
|
1579
|
+
"description": "Optional Git metadata captured when the thread was created."
|
|
1580
|
+
},
|
|
1581
|
+
"historyMode": {
|
|
1582
|
+
"allOf": [{ "$ref": "#/definitions/ThreadHistoryMode" }],
|
|
1583
|
+
"default": "legacy",
|
|
1584
|
+
"description": "Persisted thread history contract selected when this thread was created."
|
|
1585
|
+
},
|
|
1586
|
+
"id": {
|
|
1587
|
+
"description": "Identifier for this thread. Codex-generated thread IDs are UUIDv7.",
|
|
1588
|
+
"type": "string"
|
|
1589
|
+
},
|
|
1590
|
+
"model": {
|
|
1591
|
+
"description": "Current configured model when loaded, otherwise the latest persisted model. Null when unavailable. This is not per-turn execution telemetry.",
|
|
1592
|
+
"type": ["string", "null"]
|
|
1593
|
+
},
|
|
1594
|
+
"modelProvider": {
|
|
1595
|
+
"description": "Model provider used for this thread (for example, 'openai').",
|
|
1596
|
+
"type": "string"
|
|
1597
|
+
},
|
|
1598
|
+
"name": {
|
|
1599
|
+
"description": "Optional user-facing thread title.",
|
|
1600
|
+
"type": ["string", "null"]
|
|
1601
|
+
},
|
|
1602
|
+
"parentThreadId": {
|
|
1603
|
+
"description": "The ID of the parent thread. This will only be set if this thread is a subagent.",
|
|
1604
|
+
"type": ["string", "null"]
|
|
1605
|
+
},
|
|
1606
|
+
"path": {
|
|
1607
|
+
"description": "[UNSTABLE] Path to the thread on disk.",
|
|
1608
|
+
"type": ["string", "null"]
|
|
1609
|
+
},
|
|
1610
|
+
"preview": {
|
|
1611
|
+
"description": "Usually the first user message in the thread, if available.",
|
|
1612
|
+
"type": "string"
|
|
1613
|
+
},
|
|
1614
|
+
"projectId": {
|
|
1615
|
+
"description": "Canonical project assignment owned by app-server, if any.",
|
|
1616
|
+
"type": ["string", "null"]
|
|
1617
|
+
},
|
|
1618
|
+
"reasoningEffort": {
|
|
1619
|
+
"anyOf": [{ "$ref": "#/definitions/ReasoningEffort" }, { "type": "null" }],
|
|
1620
|
+
"description": "Current configured reasoning effort when loaded, otherwise the latest persisted effort. Null when unset or unavailable. This is not per-turn execution telemetry."
|
|
1621
|
+
},
|
|
1622
|
+
"recencyAt": {
|
|
1623
|
+
"description": "Unix timestamp (in seconds) used for thread recency ordering.",
|
|
1624
|
+
"format": "int64",
|
|
1625
|
+
"type": ["integer", "null"]
|
|
1626
|
+
},
|
|
1627
|
+
"section": {
|
|
1628
|
+
"anyOf": [{ "$ref": "#/definitions/ThreadSection" }, { "type": "null" }],
|
|
1629
|
+
"default": null,
|
|
1630
|
+
"description": "The independently persisted section selected for this thread, if any."
|
|
1631
|
+
},
|
|
1632
|
+
"sectionEnteredAt": {
|
|
1633
|
+
"default": null,
|
|
1634
|
+
"description": "Unix timestamp in seconds when the thread entered its current section.",
|
|
1635
|
+
"format": "int64",
|
|
1636
|
+
"type": ["integer", "null"]
|
|
1637
|
+
},
|
|
1638
|
+
"sessionId": {
|
|
1639
|
+
"description": "Session id shared by threads that belong to the same session tree.",
|
|
1640
|
+
"type": "string"
|
|
1641
|
+
},
|
|
1642
|
+
"source": {
|
|
1643
|
+
"allOf": [{ "$ref": "#/definitions/SessionSource" }],
|
|
1644
|
+
"description": "Origin of the thread (CLI, VSCode, codex exec, codex app-server, etc.)."
|
|
1645
|
+
},
|
|
1646
|
+
"status": {
|
|
1647
|
+
"allOf": [{ "$ref": "#/definitions/ThreadStatus" }],
|
|
1648
|
+
"description": "Current runtime status for the thread."
|
|
1649
|
+
},
|
|
1650
|
+
"threadSource": {
|
|
1651
|
+
"anyOf": [{ "$ref": "#/definitions/ThreadSource" }, { "type": "null" }],
|
|
1652
|
+
"description": "Optional analytics source classification for this thread."
|
|
1653
|
+
},
|
|
1654
|
+
"turns": {
|
|
1655
|
+
"description": "Only populated on `thread/resume`, `thread/rollback`, `thread/fork`, and `thread/read` (when `includeTurns` is true) responses. For all other responses and notifications returning a Thread, the turns field will be an empty list.",
|
|
1656
|
+
"items": { "$ref": "#/definitions/Turn" },
|
|
1657
|
+
"type": "array"
|
|
1658
|
+
},
|
|
1659
|
+
"updatedAt": {
|
|
1660
|
+
"description": "Unix timestamp (in seconds) when the thread was last updated.",
|
|
1661
|
+
"format": "int64",
|
|
1662
|
+
"type": "integer"
|
|
1663
|
+
}
|
|
1664
|
+
},
|
|
1665
|
+
"required": [
|
|
1666
|
+
"cliVersion",
|
|
1667
|
+
"createdAt",
|
|
1668
|
+
"cwd",
|
|
1669
|
+
"ephemeral",
|
|
1670
|
+
"id",
|
|
1671
|
+
"modelProvider",
|
|
1672
|
+
"preview",
|
|
1673
|
+
"projectId",
|
|
1674
|
+
"sessionId",
|
|
1675
|
+
"source",
|
|
1676
|
+
"status",
|
|
1677
|
+
"turns",
|
|
1678
|
+
"updatedAt"
|
|
1679
|
+
],
|
|
1680
|
+
"type": "object"
|
|
1681
|
+
},
|
|
1682
|
+
"ThreadActiveFlag": {
|
|
1683
|
+
"enum": ["waitingOnApproval", "waitingOnUserInput"],
|
|
1684
|
+
"type": "string"
|
|
1685
|
+
},
|
|
1686
|
+
"ThreadExtra": {
|
|
1687
|
+
"description": "Extra app-server data for a thread.",
|
|
1688
|
+
"type": "object"
|
|
1689
|
+
},
|
|
1690
|
+
"ThreadHistoryMode": {
|
|
1691
|
+
"enum": ["legacy", "paginated"],
|
|
1692
|
+
"type": "string"
|
|
1693
|
+
},
|
|
1694
|
+
"ThreadId": { "type": "string" },
|
|
1695
|
+
"ThreadItem": { "oneOf": [
|
|
1696
|
+
{
|
|
1697
|
+
"properties": {
|
|
1698
|
+
"clientId": { "type": ["string", "null"] },
|
|
1699
|
+
"content": {
|
|
1700
|
+
"items": { "$ref": "#/definitions/UserInput" },
|
|
1701
|
+
"type": "array"
|
|
1702
|
+
},
|
|
1703
|
+
"id": { "type": "string" },
|
|
1704
|
+
"type": {
|
|
1705
|
+
"enum": ["userMessage"],
|
|
1706
|
+
"title": "UserMessageThreadItemType",
|
|
1707
|
+
"type": "string"
|
|
1708
|
+
}
|
|
1709
|
+
},
|
|
1710
|
+
"required": [
|
|
1711
|
+
"content",
|
|
1712
|
+
"id",
|
|
1713
|
+
"type"
|
|
1714
|
+
],
|
|
1715
|
+
"title": "UserMessageThreadItem",
|
|
1716
|
+
"type": "object"
|
|
1717
|
+
},
|
|
1718
|
+
{
|
|
1719
|
+
"properties": {
|
|
1720
|
+
"fragments": {
|
|
1721
|
+
"items": { "$ref": "#/definitions/HookPromptFragment" },
|
|
1722
|
+
"type": "array"
|
|
1723
|
+
},
|
|
1724
|
+
"id": { "type": "string" },
|
|
1725
|
+
"type": {
|
|
1726
|
+
"enum": ["hookPrompt"],
|
|
1727
|
+
"title": "HookPromptThreadItemType",
|
|
1728
|
+
"type": "string"
|
|
1729
|
+
}
|
|
1730
|
+
},
|
|
1731
|
+
"required": [
|
|
1732
|
+
"fragments",
|
|
1733
|
+
"id",
|
|
1734
|
+
"type"
|
|
1735
|
+
],
|
|
1736
|
+
"title": "HookPromptThreadItem",
|
|
1737
|
+
"type": "object"
|
|
1738
|
+
},
|
|
1739
|
+
{
|
|
1740
|
+
"properties": {
|
|
1741
|
+
"delivery": {
|
|
1742
|
+
"anyOf": [{ "$ref": "#/definitions/AgentMessageDelivery" }, { "type": "null" }],
|
|
1743
|
+
"default": null
|
|
1744
|
+
},
|
|
1745
|
+
"id": { "type": "string" },
|
|
1746
|
+
"memoryCitation": {
|
|
1747
|
+
"anyOf": [{ "$ref": "#/definitions/MemoryCitation" }, { "type": "null" }],
|
|
1748
|
+
"default": null
|
|
1749
|
+
},
|
|
1750
|
+
"phase": {
|
|
1751
|
+
"anyOf": [{ "$ref": "#/definitions/MessagePhase" }, { "type": "null" }],
|
|
1752
|
+
"default": null
|
|
1753
|
+
},
|
|
1754
|
+
"questions": {
|
|
1755
|
+
"default": null,
|
|
1756
|
+
"items": { "$ref": "#/definitions/AsyncUserInputQuestion" },
|
|
1757
|
+
"type": ["array", "null"]
|
|
1758
|
+
},
|
|
1759
|
+
"text": { "type": "string" },
|
|
1760
|
+
"type": {
|
|
1761
|
+
"enum": ["agentMessage"],
|
|
1762
|
+
"title": "AgentMessageThreadItemType",
|
|
1763
|
+
"type": "string"
|
|
1764
|
+
}
|
|
1765
|
+
},
|
|
1766
|
+
"required": [
|
|
1767
|
+
"id",
|
|
1768
|
+
"text",
|
|
1769
|
+
"type"
|
|
1770
|
+
],
|
|
1771
|
+
"title": "AgentMessageThreadItem",
|
|
1772
|
+
"type": "object"
|
|
1773
|
+
},
|
|
1774
|
+
{
|
|
1775
|
+
"properties": {
|
|
1776
|
+
"id": { "type": "string" },
|
|
1777
|
+
"name": { "type": "string" },
|
|
1778
|
+
"namespace": { "type": ["string", "null"] },
|
|
1779
|
+
"output": { "$ref": "#/definitions/FunctionCallOutputBody" },
|
|
1780
|
+
"type": {
|
|
1781
|
+
"enum": ["functionCallOutput"],
|
|
1782
|
+
"title": "FunctionCallOutputThreadItemType",
|
|
1783
|
+
"type": "string"
|
|
1784
|
+
}
|
|
1785
|
+
},
|
|
1786
|
+
"required": [
|
|
1787
|
+
"id",
|
|
1788
|
+
"name",
|
|
1789
|
+
"output",
|
|
1790
|
+
"type"
|
|
1791
|
+
],
|
|
1792
|
+
"title": "FunctionCallOutputThreadItem",
|
|
1793
|
+
"type": "object"
|
|
1794
|
+
},
|
|
1795
|
+
{
|
|
1796
|
+
"description": "EXPERIMENTAL - proposed plan item content. The completed plan item is authoritative and may not match the concatenation of `PlanDelta` text.",
|
|
1797
|
+
"properties": {
|
|
1798
|
+
"id": { "type": "string" },
|
|
1799
|
+
"text": { "type": "string" },
|
|
1800
|
+
"type": {
|
|
1801
|
+
"enum": ["plan"],
|
|
1802
|
+
"title": "PlanThreadItemType",
|
|
1803
|
+
"type": "string"
|
|
1804
|
+
}
|
|
1805
|
+
},
|
|
1806
|
+
"required": [
|
|
1807
|
+
"id",
|
|
1808
|
+
"text",
|
|
1809
|
+
"type"
|
|
1810
|
+
],
|
|
1811
|
+
"title": "PlanThreadItem",
|
|
1812
|
+
"type": "object"
|
|
1813
|
+
},
|
|
1814
|
+
{
|
|
1815
|
+
"properties": {
|
|
1816
|
+
"content": {
|
|
1817
|
+
"default": [],
|
|
1818
|
+
"items": { "type": "string" },
|
|
1819
|
+
"type": "array"
|
|
1820
|
+
},
|
|
1821
|
+
"id": { "type": "string" },
|
|
1822
|
+
"summary": {
|
|
1823
|
+
"default": [],
|
|
1824
|
+
"items": { "type": "string" },
|
|
1825
|
+
"type": "array"
|
|
1826
|
+
},
|
|
1827
|
+
"type": {
|
|
1828
|
+
"enum": ["reasoning"],
|
|
1829
|
+
"title": "ReasoningThreadItemType",
|
|
1830
|
+
"type": "string"
|
|
1831
|
+
}
|
|
1832
|
+
},
|
|
1833
|
+
"required": ["id", "type"],
|
|
1834
|
+
"title": "ReasoningThreadItem",
|
|
1835
|
+
"type": "object"
|
|
1836
|
+
},
|
|
1837
|
+
{
|
|
1838
|
+
"properties": {
|
|
1839
|
+
"aggregatedOutput": {
|
|
1840
|
+
"description": "The command's output, aggregated from stdout and stderr.",
|
|
1841
|
+
"type": ["string", "null"]
|
|
1842
|
+
},
|
|
1843
|
+
"command": {
|
|
1844
|
+
"description": "The command to be executed.",
|
|
1845
|
+
"type": "string"
|
|
1846
|
+
},
|
|
1847
|
+
"commandActions": {
|
|
1848
|
+
"description": "A best-effort parsing of the command to understand the action(s) it will perform. This returns a list of CommandAction objects because a single shell command may be composed of many commands piped together.",
|
|
1849
|
+
"items": { "$ref": "#/definitions/CommandAction" },
|
|
1850
|
+
"type": "array"
|
|
1851
|
+
},
|
|
1852
|
+
"cwd": {
|
|
1853
|
+
"allOf": [{ "$ref": "#/definitions/LegacyAppPathString" }],
|
|
1854
|
+
"description": "The command's working directory."
|
|
1855
|
+
},
|
|
1856
|
+
"durationMs": {
|
|
1857
|
+
"description": "The duration of the command execution in milliseconds.",
|
|
1858
|
+
"format": "int64",
|
|
1859
|
+
"type": ["integer", "null"]
|
|
1860
|
+
},
|
|
1861
|
+
"exitCode": {
|
|
1862
|
+
"description": "The command's exit code.",
|
|
1863
|
+
"format": "int32",
|
|
1864
|
+
"type": ["integer", "null"]
|
|
1865
|
+
},
|
|
1866
|
+
"id": { "type": "string" },
|
|
1867
|
+
"pluginId": {
|
|
1868
|
+
"default": null,
|
|
1869
|
+
"description": "Trusted first-party plugin id when this command resolves to one plugin script.",
|
|
1870
|
+
"type": ["string", "null"]
|
|
1871
|
+
},
|
|
1872
|
+
"processId": {
|
|
1873
|
+
"description": "Identifier for the underlying PTY process (when available).",
|
|
1874
|
+
"type": ["string", "null"]
|
|
1875
|
+
},
|
|
1876
|
+
"scriptPath": {
|
|
1877
|
+
"default": null,
|
|
1878
|
+
"description": "Safe plugin-relative path when this command resolves to one plugin script.",
|
|
1879
|
+
"type": ["string", "null"]
|
|
1880
|
+
},
|
|
1881
|
+
"source": {
|
|
1882
|
+
"allOf": [{ "$ref": "#/definitions/CommandExecutionSource" }],
|
|
1883
|
+
"default": "agent"
|
|
1884
|
+
},
|
|
1885
|
+
"status": { "$ref": "#/definitions/CommandExecutionStatus" },
|
|
1886
|
+
"type": {
|
|
1887
|
+
"enum": ["commandExecution"],
|
|
1888
|
+
"title": "CommandExecutionThreadItemType",
|
|
1889
|
+
"type": "string"
|
|
1890
|
+
}
|
|
1891
|
+
},
|
|
1892
|
+
"required": [
|
|
1893
|
+
"command",
|
|
1894
|
+
"commandActions",
|
|
1895
|
+
"cwd",
|
|
1896
|
+
"id",
|
|
1897
|
+
"status",
|
|
1898
|
+
"type"
|
|
1899
|
+
],
|
|
1900
|
+
"title": "CommandExecutionThreadItem",
|
|
1901
|
+
"type": "object"
|
|
1902
|
+
},
|
|
1903
|
+
{
|
|
1904
|
+
"properties": {
|
|
1905
|
+
"changes": {
|
|
1906
|
+
"items": { "$ref": "#/definitions/FileUpdateChange" },
|
|
1907
|
+
"type": "array"
|
|
1908
|
+
},
|
|
1909
|
+
"id": { "type": "string" },
|
|
1910
|
+
"status": { "$ref": "#/definitions/PatchApplyStatus" },
|
|
1911
|
+
"type": {
|
|
1912
|
+
"enum": ["fileChange"],
|
|
1913
|
+
"title": "FileChangeThreadItemType",
|
|
1914
|
+
"type": "string"
|
|
1915
|
+
}
|
|
1916
|
+
},
|
|
1917
|
+
"required": [
|
|
1918
|
+
"changes",
|
|
1919
|
+
"id",
|
|
1920
|
+
"status",
|
|
1921
|
+
"type"
|
|
1922
|
+
],
|
|
1923
|
+
"title": "FileChangeThreadItem",
|
|
1924
|
+
"type": "object"
|
|
1925
|
+
},
|
|
1926
|
+
{
|
|
1927
|
+
"properties": {
|
|
1928
|
+
"appContext": { "anyOf": [{ "$ref": "#/definitions/McpToolCallAppContext" }, { "type": "null" }] },
|
|
1929
|
+
"arguments": true,
|
|
1930
|
+
"durationMs": {
|
|
1931
|
+
"description": "The duration of the MCP tool call in milliseconds.",
|
|
1932
|
+
"format": "int64",
|
|
1933
|
+
"type": ["integer", "null"]
|
|
1934
|
+
},
|
|
1935
|
+
"error": { "anyOf": [{ "$ref": "#/definitions/McpToolCallError" }, { "type": "null" }] },
|
|
1936
|
+
"id": { "type": "string" },
|
|
1937
|
+
"mcpAppResourceUri": {
|
|
1938
|
+
"description": "Deprecated: use `appContext.resourceUri` instead.",
|
|
1939
|
+
"type": ["string", "null"]
|
|
1940
|
+
},
|
|
1941
|
+
"pluginId": { "type": ["string", "null"] },
|
|
1942
|
+
"readOnlyHint": { "type": ["boolean", "null"] },
|
|
1943
|
+
"result": { "anyOf": [{ "$ref": "#/definitions/McpToolCallResult" }, { "type": "null" }] },
|
|
1944
|
+
"server": { "type": "string" },
|
|
1945
|
+
"status": { "$ref": "#/definitions/McpToolCallStatus" },
|
|
1946
|
+
"tool": { "type": "string" },
|
|
1947
|
+
"type": {
|
|
1948
|
+
"enum": ["mcpToolCall"],
|
|
1949
|
+
"title": "McpToolCallThreadItemType",
|
|
1950
|
+
"type": "string"
|
|
1951
|
+
}
|
|
1952
|
+
},
|
|
1953
|
+
"required": [
|
|
1954
|
+
"arguments",
|
|
1955
|
+
"id",
|
|
1956
|
+
"server",
|
|
1957
|
+
"status",
|
|
1958
|
+
"tool",
|
|
1959
|
+
"type"
|
|
1960
|
+
],
|
|
1961
|
+
"title": "McpToolCallThreadItem",
|
|
1962
|
+
"type": "object"
|
|
1963
|
+
},
|
|
1964
|
+
{
|
|
1965
|
+
"properties": {
|
|
1966
|
+
"arguments": true,
|
|
1967
|
+
"contentItems": {
|
|
1968
|
+
"items": { "$ref": "#/definitions/DynamicToolCallOutputContentItem" },
|
|
1969
|
+
"type": ["array", "null"]
|
|
1970
|
+
},
|
|
1971
|
+
"durationMs": {
|
|
1972
|
+
"description": "The duration of the dynamic tool call in milliseconds.",
|
|
1973
|
+
"format": "int64",
|
|
1974
|
+
"type": ["integer", "null"]
|
|
1975
|
+
},
|
|
1976
|
+
"id": { "type": "string" },
|
|
1977
|
+
"namespace": { "type": ["string", "null"] },
|
|
1978
|
+
"status": { "$ref": "#/definitions/DynamicToolCallStatus" },
|
|
1979
|
+
"success": { "type": ["boolean", "null"] },
|
|
1980
|
+
"tool": { "type": "string" },
|
|
1981
|
+
"type": {
|
|
1982
|
+
"enum": ["dynamicToolCall"],
|
|
1983
|
+
"title": "DynamicToolCallThreadItemType",
|
|
1984
|
+
"type": "string"
|
|
1985
|
+
}
|
|
1986
|
+
},
|
|
1987
|
+
"required": [
|
|
1988
|
+
"arguments",
|
|
1989
|
+
"id",
|
|
1990
|
+
"status",
|
|
1991
|
+
"tool",
|
|
1992
|
+
"type"
|
|
1993
|
+
],
|
|
1994
|
+
"title": "DynamicToolCallThreadItem",
|
|
1995
|
+
"type": "object"
|
|
1996
|
+
},
|
|
1997
|
+
{
|
|
1998
|
+
"properties": {
|
|
1999
|
+
"agentsStates": {
|
|
2000
|
+
"additionalProperties": { "$ref": "#/definitions/CollabAgentState" },
|
|
2001
|
+
"description": "Last known status of the target agents, when available.",
|
|
2002
|
+
"type": "object"
|
|
2003
|
+
},
|
|
2004
|
+
"id": {
|
|
2005
|
+
"description": "Unique identifier for this collab tool call.",
|
|
2006
|
+
"type": "string"
|
|
2007
|
+
},
|
|
2008
|
+
"model": {
|
|
2009
|
+
"description": "Model requested for the spawned agent, when applicable.",
|
|
2010
|
+
"type": ["string", "null"]
|
|
2011
|
+
},
|
|
2012
|
+
"prompt": {
|
|
2013
|
+
"description": "Prompt text sent as part of the collab tool call, when available.",
|
|
2014
|
+
"type": ["string", "null"]
|
|
2015
|
+
},
|
|
2016
|
+
"reasoningEffort": {
|
|
2017
|
+
"anyOf": [{ "$ref": "#/definitions/ReasoningEffort" }, { "type": "null" }],
|
|
2018
|
+
"description": "Reasoning effort requested for the spawned agent, when applicable."
|
|
2019
|
+
},
|
|
2020
|
+
"receiverThreadIds": {
|
|
2021
|
+
"description": "Thread ID of the receiving agent, when applicable. In case of spawn operation, this corresponds to the newly spawned agent.",
|
|
2022
|
+
"items": { "type": "string" },
|
|
2023
|
+
"type": "array"
|
|
2024
|
+
},
|
|
2025
|
+
"senderThreadId": {
|
|
2026
|
+
"description": "Thread ID of the agent issuing the collab request.",
|
|
2027
|
+
"type": "string"
|
|
2028
|
+
},
|
|
2029
|
+
"status": {
|
|
2030
|
+
"allOf": [{ "$ref": "#/definitions/CollabAgentToolCallStatus" }],
|
|
2031
|
+
"description": "Current status of the collab tool call."
|
|
2032
|
+
},
|
|
2033
|
+
"tool": {
|
|
2034
|
+
"allOf": [{ "$ref": "#/definitions/CollabAgentTool" }],
|
|
2035
|
+
"description": "Name of the collab tool that was invoked."
|
|
2036
|
+
},
|
|
2037
|
+
"type": {
|
|
2038
|
+
"enum": ["collabAgentToolCall"],
|
|
2039
|
+
"title": "CollabAgentToolCallThreadItemType",
|
|
2040
|
+
"type": "string"
|
|
2041
|
+
}
|
|
2042
|
+
},
|
|
2043
|
+
"required": [
|
|
2044
|
+
"agentsStates",
|
|
2045
|
+
"id",
|
|
2046
|
+
"receiverThreadIds",
|
|
2047
|
+
"senderThreadId",
|
|
2048
|
+
"status",
|
|
2049
|
+
"tool",
|
|
2050
|
+
"type"
|
|
2051
|
+
],
|
|
2052
|
+
"title": "CollabAgentToolCallThreadItem",
|
|
2053
|
+
"type": "object"
|
|
2054
|
+
},
|
|
2055
|
+
{
|
|
2056
|
+
"properties": {
|
|
2057
|
+
"agentPath": { "type": "string" },
|
|
2058
|
+
"agentThreadId": { "type": "string" },
|
|
2059
|
+
"id": { "type": "string" },
|
|
2060
|
+
"kind": { "$ref": "#/definitions/SubAgentActivityKind" },
|
|
2061
|
+
"type": {
|
|
2062
|
+
"enum": ["subAgentActivity"],
|
|
2063
|
+
"title": "SubAgentActivityThreadItemType",
|
|
2064
|
+
"type": "string"
|
|
2065
|
+
}
|
|
2066
|
+
},
|
|
2067
|
+
"required": [
|
|
2068
|
+
"agentPath",
|
|
2069
|
+
"agentThreadId",
|
|
2070
|
+
"id",
|
|
2071
|
+
"kind",
|
|
2072
|
+
"type"
|
|
2073
|
+
],
|
|
2074
|
+
"title": "SubAgentActivityThreadItem",
|
|
2075
|
+
"type": "object"
|
|
2076
|
+
},
|
|
2077
|
+
{
|
|
2078
|
+
"properties": {
|
|
2079
|
+
"action": { "anyOf": [{ "$ref": "#/definitions/WebSearchAction" }, { "type": "null" }] },
|
|
2080
|
+
"id": { "type": "string" },
|
|
2081
|
+
"query": { "type": "string" },
|
|
2082
|
+
"results": {
|
|
2083
|
+
"default": null,
|
|
2084
|
+
"description": "Structured search results returned out-of-band by standalone web search.\n\nThese stay as opaque JSON at the extension/app-server boundary so new result fields and result types can pass through without a Codex release.",
|
|
2085
|
+
"items": true,
|
|
2086
|
+
"type": ["array", "null"]
|
|
2087
|
+
},
|
|
2088
|
+
"type": {
|
|
2089
|
+
"enum": ["webSearch"],
|
|
2090
|
+
"title": "WebSearchThreadItemType",
|
|
2091
|
+
"type": "string"
|
|
2092
|
+
}
|
|
2093
|
+
},
|
|
2094
|
+
"required": [
|
|
2095
|
+
"id",
|
|
2096
|
+
"query",
|
|
2097
|
+
"type"
|
|
2098
|
+
],
|
|
2099
|
+
"title": "WebSearchThreadItem",
|
|
2100
|
+
"type": "object"
|
|
2101
|
+
},
|
|
2102
|
+
{
|
|
2103
|
+
"properties": {
|
|
2104
|
+
"id": { "type": "string" },
|
|
2105
|
+
"path": { "$ref": "#/definitions/LegacyAppPathString" },
|
|
2106
|
+
"type": {
|
|
2107
|
+
"enum": ["imageView"],
|
|
2108
|
+
"title": "ImageViewThreadItemType",
|
|
2109
|
+
"type": "string"
|
|
2110
|
+
}
|
|
2111
|
+
},
|
|
2112
|
+
"required": [
|
|
2113
|
+
"id",
|
|
2114
|
+
"path",
|
|
2115
|
+
"type"
|
|
2116
|
+
],
|
|
2117
|
+
"title": "ImageViewThreadItem",
|
|
2118
|
+
"type": "object"
|
|
2119
|
+
},
|
|
2120
|
+
{
|
|
2121
|
+
"description": "Display item emitted by the interruptible `clock.sleep` tool.",
|
|
2122
|
+
"properties": {
|
|
2123
|
+
"durationMs": {
|
|
2124
|
+
"format": "uint64",
|
|
2125
|
+
"minimum": 0,
|
|
2126
|
+
"type": "integer"
|
|
2127
|
+
},
|
|
2128
|
+
"id": { "type": "string" },
|
|
2129
|
+
"type": {
|
|
2130
|
+
"enum": ["sleep"],
|
|
2131
|
+
"title": "SleepThreadItemType",
|
|
2132
|
+
"type": "string"
|
|
2133
|
+
}
|
|
2134
|
+
},
|
|
2135
|
+
"required": [
|
|
2136
|
+
"durationMs",
|
|
2137
|
+
"id",
|
|
2138
|
+
"type"
|
|
2139
|
+
],
|
|
2140
|
+
"title": "SleepThreadItem",
|
|
2141
|
+
"type": "object"
|
|
2142
|
+
},
|
|
2143
|
+
{
|
|
2144
|
+
"properties": {
|
|
2145
|
+
"failure": {
|
|
2146
|
+
"anyOf": [{ "$ref": "#/definitions/ImageGenerationFailure" }, { "type": "null" }],
|
|
2147
|
+
"default": null
|
|
2148
|
+
},
|
|
2149
|
+
"id": { "type": "string" },
|
|
2150
|
+
"result": { "type": "string" },
|
|
2151
|
+
"revisedPrompt": { "type": ["string", "null"] },
|
|
2152
|
+
"savedPath": { "anyOf": [{ "$ref": "#/definitions/AbsolutePathBuf" }, { "type": "null" }] },
|
|
2153
|
+
"status": { "type": "string" },
|
|
2154
|
+
"transparentBackground": {
|
|
2155
|
+
"default": null,
|
|
2156
|
+
"type": ["boolean", "null"]
|
|
2157
|
+
},
|
|
2158
|
+
"type": {
|
|
2159
|
+
"enum": ["imageGeneration"],
|
|
2160
|
+
"title": "ImageGenerationThreadItemType",
|
|
2161
|
+
"type": "string"
|
|
2162
|
+
}
|
|
2163
|
+
},
|
|
2164
|
+
"required": [
|
|
2165
|
+
"id",
|
|
2166
|
+
"result",
|
|
2167
|
+
"status",
|
|
2168
|
+
"type"
|
|
2169
|
+
],
|
|
2170
|
+
"title": "ImageGenerationThreadItem",
|
|
2171
|
+
"type": "object"
|
|
2172
|
+
},
|
|
2173
|
+
{
|
|
2174
|
+
"properties": {
|
|
2175
|
+
"id": { "type": "string" },
|
|
2176
|
+
"review": { "type": "string" },
|
|
2177
|
+
"type": {
|
|
2178
|
+
"enum": ["enteredReviewMode"],
|
|
2179
|
+
"title": "EnteredReviewModeThreadItemType",
|
|
2180
|
+
"type": "string"
|
|
2181
|
+
}
|
|
2182
|
+
},
|
|
2183
|
+
"required": [
|
|
2184
|
+
"id",
|
|
2185
|
+
"review",
|
|
2186
|
+
"type"
|
|
2187
|
+
],
|
|
2188
|
+
"title": "EnteredReviewModeThreadItem",
|
|
2189
|
+
"type": "object"
|
|
2190
|
+
},
|
|
2191
|
+
{
|
|
2192
|
+
"properties": {
|
|
2193
|
+
"id": { "type": "string" },
|
|
2194
|
+
"review": { "type": "string" },
|
|
2195
|
+
"type": {
|
|
2196
|
+
"enum": ["exitedReviewMode"],
|
|
2197
|
+
"title": "ExitedReviewModeThreadItemType",
|
|
2198
|
+
"type": "string"
|
|
2199
|
+
}
|
|
2200
|
+
},
|
|
2201
|
+
"required": [
|
|
2202
|
+
"id",
|
|
2203
|
+
"review",
|
|
2204
|
+
"type"
|
|
2205
|
+
],
|
|
2206
|
+
"title": "ExitedReviewModeThreadItem",
|
|
2207
|
+
"type": "object"
|
|
2208
|
+
},
|
|
2209
|
+
{
|
|
2210
|
+
"properties": {
|
|
2211
|
+
"id": { "type": "string" },
|
|
2212
|
+
"type": {
|
|
2213
|
+
"enum": ["contextCompaction"],
|
|
2214
|
+
"title": "ContextCompactionThreadItemType",
|
|
2215
|
+
"type": "string"
|
|
2216
|
+
}
|
|
2217
|
+
},
|
|
2218
|
+
"required": ["id", "type"],
|
|
2219
|
+
"title": "ContextCompactionThreadItem",
|
|
2220
|
+
"type": "object"
|
|
2221
|
+
}
|
|
2222
|
+
] },
|
|
2223
|
+
"ThreadSection": {
|
|
2224
|
+
"description": "An independently persisted, user-visible thread section.",
|
|
2225
|
+
"properties": {
|
|
2226
|
+
"appearance": {
|
|
2227
|
+
"anyOf": [{ "$ref": "#/definitions/ThreadSectionAppearance" }, { "type": "null" }],
|
|
2228
|
+
"default": null,
|
|
2229
|
+
"description": "Optional appearance synchronized across clients."
|
|
2230
|
+
},
|
|
2231
|
+
"id": {
|
|
2232
|
+
"description": "Opaque UUIDv7 identity that remains stable when the section is renamed.",
|
|
2233
|
+
"type": "string"
|
|
2234
|
+
},
|
|
2235
|
+
"name": {
|
|
2236
|
+
"description": "The current user-visible section name.",
|
|
2237
|
+
"type": "string"
|
|
2238
|
+
}
|
|
2239
|
+
},
|
|
2240
|
+
"required": ["id", "name"],
|
|
2241
|
+
"type": "object"
|
|
2242
|
+
},
|
|
2243
|
+
"ThreadSectionAppearance": {
|
|
2244
|
+
"description": "Extensible visual presentation for a custom thread section.",
|
|
2245
|
+
"properties": {
|
|
2246
|
+
"color": { "type": ["string", "null"] },
|
|
2247
|
+
"icon": { "type": ["string", "null"] }
|
|
2248
|
+
},
|
|
2249
|
+
"type": "object"
|
|
2250
|
+
},
|
|
2251
|
+
"ThreadSource": { "type": "string" },
|
|
2252
|
+
"ThreadStatus": { "oneOf": [
|
|
2253
|
+
{
|
|
2254
|
+
"properties": { "type": {
|
|
2255
|
+
"enum": ["notLoaded"],
|
|
2256
|
+
"title": "NotLoadedThreadStatusType",
|
|
2257
|
+
"type": "string"
|
|
2258
|
+
} },
|
|
2259
|
+
"required": ["type"],
|
|
2260
|
+
"title": "NotLoadedThreadStatus",
|
|
2261
|
+
"type": "object"
|
|
2262
|
+
},
|
|
2263
|
+
{
|
|
2264
|
+
"properties": { "type": {
|
|
2265
|
+
"enum": ["idle"],
|
|
2266
|
+
"title": "IdleThreadStatusType",
|
|
2267
|
+
"type": "string"
|
|
2268
|
+
} },
|
|
2269
|
+
"required": ["type"],
|
|
2270
|
+
"title": "IdleThreadStatus",
|
|
2271
|
+
"type": "object"
|
|
2272
|
+
},
|
|
2273
|
+
{
|
|
2274
|
+
"properties": { "type": {
|
|
2275
|
+
"enum": ["systemError"],
|
|
2276
|
+
"title": "SystemErrorThreadStatusType",
|
|
2277
|
+
"type": "string"
|
|
2278
|
+
} },
|
|
2279
|
+
"required": ["type"],
|
|
2280
|
+
"title": "SystemErrorThreadStatus",
|
|
2281
|
+
"type": "object"
|
|
2282
|
+
},
|
|
2283
|
+
{
|
|
2284
|
+
"properties": {
|
|
2285
|
+
"activeFlags": {
|
|
2286
|
+
"items": { "$ref": "#/definitions/ThreadActiveFlag" },
|
|
2287
|
+
"type": "array"
|
|
2288
|
+
},
|
|
2289
|
+
"type": {
|
|
2290
|
+
"enum": ["active"],
|
|
2291
|
+
"title": "ActiveThreadStatusType",
|
|
2292
|
+
"type": "string"
|
|
2293
|
+
}
|
|
2294
|
+
},
|
|
2295
|
+
"required": ["activeFlags", "type"],
|
|
2296
|
+
"title": "ActiveThreadStatus",
|
|
2297
|
+
"type": "object"
|
|
2298
|
+
}
|
|
2299
|
+
] },
|
|
2300
|
+
"Turn": {
|
|
2301
|
+
"properties": {
|
|
2302
|
+
"completedAt": {
|
|
2303
|
+
"description": "Unix timestamp (in seconds) when the turn completed.",
|
|
2304
|
+
"format": "int64",
|
|
2305
|
+
"type": ["integer", "null"]
|
|
2306
|
+
},
|
|
2307
|
+
"durationMs": {
|
|
2308
|
+
"description": "Duration between turn start and completion in milliseconds, if known.",
|
|
2309
|
+
"format": "int64",
|
|
2310
|
+
"type": ["integer", "null"]
|
|
2311
|
+
},
|
|
2312
|
+
"error": {
|
|
2313
|
+
"anyOf": [{ "$ref": "#/definitions/TurnError" }, { "type": "null" }],
|
|
2314
|
+
"description": "Only populated when the Turn's status is failed."
|
|
2315
|
+
},
|
|
2316
|
+
"id": {
|
|
2317
|
+
"description": "Identifier for this turn. Codex-generated turn IDs are UUIDv7.",
|
|
2318
|
+
"type": "string"
|
|
2319
|
+
},
|
|
2320
|
+
"items": {
|
|
2321
|
+
"description": "Thread items currently included in this turn payload.",
|
|
2322
|
+
"items": { "$ref": "#/definitions/ThreadItem" },
|
|
2323
|
+
"type": "array"
|
|
2324
|
+
},
|
|
2325
|
+
"itemsView": {
|
|
2326
|
+
"allOf": [{ "$ref": "#/definitions/TurnItemsView" }],
|
|
2327
|
+
"default": "full",
|
|
2328
|
+
"description": "Describes how much of `items` has been loaded for this turn."
|
|
2329
|
+
},
|
|
2330
|
+
"startedAt": {
|
|
2331
|
+
"description": "Unix timestamp (in seconds) when the turn started.",
|
|
2332
|
+
"format": "int64",
|
|
2333
|
+
"type": ["integer", "null"]
|
|
2334
|
+
},
|
|
2335
|
+
"status": { "$ref": "#/definitions/TurnStatus" }
|
|
2336
|
+
},
|
|
2337
|
+
"required": [
|
|
2338
|
+
"id",
|
|
2339
|
+
"items",
|
|
2340
|
+
"status"
|
|
2341
|
+
],
|
|
2342
|
+
"type": "object"
|
|
2343
|
+
},
|
|
2344
|
+
"TurnError": {
|
|
2345
|
+
"properties": {
|
|
2346
|
+
"additionalDetails": {
|
|
2347
|
+
"default": null,
|
|
2348
|
+
"type": ["string", "null"]
|
|
2349
|
+
},
|
|
2350
|
+
"codexErrorInfo": { "anyOf": [{ "$ref": "#/definitions/CodexErrorInfo" }, { "type": "null" }] },
|
|
2351
|
+
"message": { "type": "string" },
|
|
2352
|
+
"misalignment": {
|
|
2353
|
+
"anyOf": [{ "$ref": "#/definitions/MisalignmentErrorDetails" }, { "type": "null" }],
|
|
2354
|
+
"default": null,
|
|
2355
|
+
"description": "Optional public explanation and continuation instruction for a misalignment block."
|
|
2356
|
+
}
|
|
2357
|
+
},
|
|
2358
|
+
"required": ["message"],
|
|
2359
|
+
"type": "object"
|
|
2360
|
+
},
|
|
2361
|
+
"TurnItemsView": { "oneOf": [
|
|
2362
|
+
{
|
|
2363
|
+
"description": "`items` was not loaded for this turn. The field is intentionally empty.",
|
|
2364
|
+
"enum": ["notLoaded"],
|
|
2365
|
+
"type": "string"
|
|
2366
|
+
},
|
|
2367
|
+
{
|
|
2368
|
+
"description": "`items` contains only a display summary for this turn.",
|
|
2369
|
+
"enum": ["summary"],
|
|
2370
|
+
"type": "string"
|
|
2371
|
+
},
|
|
2372
|
+
{
|
|
2373
|
+
"description": "`items` contains every ThreadItem available from persisted app-server history for this turn.",
|
|
2374
|
+
"enum": ["full"],
|
|
2375
|
+
"type": "string"
|
|
2376
|
+
}
|
|
2377
|
+
] },
|
|
2378
|
+
"TurnStatus": {
|
|
2379
|
+
"enum": [
|
|
2380
|
+
"completed",
|
|
2381
|
+
"interrupted",
|
|
2382
|
+
"failed",
|
|
2383
|
+
"inProgress"
|
|
2384
|
+
],
|
|
2385
|
+
"type": "string"
|
|
2386
|
+
},
|
|
2387
|
+
"TurnsPage": {
|
|
2388
|
+
"properties": {
|
|
2389
|
+
"backwardsCursor": { "type": ["string", "null"] },
|
|
2390
|
+
"data": {
|
|
2391
|
+
"items": { "$ref": "#/definitions/Turn" },
|
|
2392
|
+
"type": "array"
|
|
2393
|
+
},
|
|
2394
|
+
"nextCursor": { "type": ["string", "null"] }
|
|
2395
|
+
},
|
|
2396
|
+
"required": ["data"],
|
|
2397
|
+
"type": "object"
|
|
2398
|
+
},
|
|
2399
|
+
"UserInput": { "oneOf": [
|
|
2400
|
+
{
|
|
2401
|
+
"properties": {
|
|
2402
|
+
"text": { "type": "string" },
|
|
2403
|
+
"text_elements": {
|
|
2404
|
+
"default": [],
|
|
2405
|
+
"description": "UI-defined spans within `text` used to render or persist special elements.",
|
|
2406
|
+
"items": { "$ref": "#/definitions/TextElement" },
|
|
2407
|
+
"type": "array"
|
|
2408
|
+
},
|
|
2409
|
+
"type": {
|
|
2410
|
+
"enum": ["text"],
|
|
2411
|
+
"title": "TextUserInputType",
|
|
2412
|
+
"type": "string"
|
|
2413
|
+
}
|
|
2414
|
+
},
|
|
2415
|
+
"required": ["text", "type"],
|
|
2416
|
+
"title": "TextUserInput",
|
|
2417
|
+
"type": "object"
|
|
2418
|
+
},
|
|
2419
|
+
{
|
|
2420
|
+
"properties": {
|
|
2421
|
+
"detail": {
|
|
2422
|
+
"anyOf": [{ "$ref": "#/definitions/ImageDetail" }, { "type": "null" }],
|
|
2423
|
+
"default": null
|
|
2424
|
+
},
|
|
2425
|
+
"type": {
|
|
2426
|
+
"enum": ["image"],
|
|
2427
|
+
"title": "ImageUserInputType",
|
|
2428
|
+
"type": "string"
|
|
2429
|
+
},
|
|
2430
|
+
"url": { "type": "string" }
|
|
2431
|
+
},
|
|
2432
|
+
"required": ["type", "url"],
|
|
2433
|
+
"title": "ImageUserInput",
|
|
2434
|
+
"type": "object"
|
|
2435
|
+
},
|
|
2436
|
+
{
|
|
2437
|
+
"properties": {
|
|
2438
|
+
"detail": {
|
|
2439
|
+
"anyOf": [{ "$ref": "#/definitions/ImageDetail" }, { "type": "null" }],
|
|
2440
|
+
"default": null
|
|
2441
|
+
},
|
|
2442
|
+
"path": { "type": "string" },
|
|
2443
|
+
"type": {
|
|
2444
|
+
"enum": ["localImage"],
|
|
2445
|
+
"title": "LocalImageUserInputType",
|
|
2446
|
+
"type": "string"
|
|
2447
|
+
}
|
|
2448
|
+
},
|
|
2449
|
+
"required": ["path", "type"],
|
|
2450
|
+
"title": "LocalImageUserInput",
|
|
2451
|
+
"type": "object"
|
|
2452
|
+
},
|
|
2453
|
+
{
|
|
2454
|
+
"properties": {
|
|
2455
|
+
"type": {
|
|
2456
|
+
"enum": ["audio"],
|
|
2457
|
+
"title": "AudioUserInputType",
|
|
2458
|
+
"type": "string"
|
|
2459
|
+
},
|
|
2460
|
+
"url": { "type": "string" }
|
|
2461
|
+
},
|
|
2462
|
+
"required": ["type", "url"],
|
|
2463
|
+
"title": "AudioUserInput",
|
|
2464
|
+
"type": "object"
|
|
2465
|
+
},
|
|
2466
|
+
{
|
|
2467
|
+
"properties": {
|
|
2468
|
+
"path": { "type": "string" },
|
|
2469
|
+
"type": {
|
|
2470
|
+
"enum": ["localAudio"],
|
|
2471
|
+
"title": "LocalAudioUserInputType",
|
|
2472
|
+
"type": "string"
|
|
2473
|
+
}
|
|
2474
|
+
},
|
|
2475
|
+
"required": ["path", "type"],
|
|
2476
|
+
"title": "LocalAudioUserInput",
|
|
2477
|
+
"type": "object"
|
|
2478
|
+
},
|
|
2479
|
+
{
|
|
2480
|
+
"properties": {
|
|
2481
|
+
"name": { "type": "string" },
|
|
2482
|
+
"path": { "type": "string" },
|
|
2483
|
+
"type": {
|
|
2484
|
+
"enum": ["skill"],
|
|
2485
|
+
"title": "SkillUserInputType",
|
|
2486
|
+
"type": "string"
|
|
2487
|
+
}
|
|
2488
|
+
},
|
|
2489
|
+
"required": [
|
|
2490
|
+
"name",
|
|
2491
|
+
"path",
|
|
2492
|
+
"type"
|
|
2493
|
+
],
|
|
2494
|
+
"title": "SkillUserInput",
|
|
2495
|
+
"type": "object"
|
|
2496
|
+
},
|
|
2497
|
+
{
|
|
2498
|
+
"properties": {
|
|
2499
|
+
"name": { "type": "string" },
|
|
2500
|
+
"path": { "type": "string" },
|
|
2501
|
+
"type": {
|
|
2502
|
+
"enum": ["mention"],
|
|
2503
|
+
"title": "MentionUserInputType",
|
|
2504
|
+
"type": "string"
|
|
2505
|
+
}
|
|
2506
|
+
},
|
|
2507
|
+
"required": [
|
|
2508
|
+
"name",
|
|
2509
|
+
"path",
|
|
2510
|
+
"type"
|
|
2511
|
+
],
|
|
2512
|
+
"title": "MentionUserInput",
|
|
2513
|
+
"type": "object"
|
|
2514
|
+
}
|
|
2515
|
+
] },
|
|
2516
|
+
"WebSearchAction": { "oneOf": [
|
|
2517
|
+
{
|
|
2518
|
+
"properties": {
|
|
2519
|
+
"queries": {
|
|
2520
|
+
"items": { "type": "string" },
|
|
2521
|
+
"type": ["array", "null"]
|
|
2522
|
+
},
|
|
2523
|
+
"query": { "type": ["string", "null"] },
|
|
2524
|
+
"type": {
|
|
2525
|
+
"enum": ["search"],
|
|
2526
|
+
"title": "SearchWebSearchActionType",
|
|
2527
|
+
"type": "string"
|
|
2528
|
+
}
|
|
2529
|
+
},
|
|
2530
|
+
"required": ["type"],
|
|
2531
|
+
"title": "SearchWebSearchAction",
|
|
2532
|
+
"type": "object"
|
|
2533
|
+
},
|
|
2534
|
+
{
|
|
2535
|
+
"properties": {
|
|
2536
|
+
"type": {
|
|
2537
|
+
"enum": ["openPage"],
|
|
2538
|
+
"title": "OpenPageWebSearchActionType",
|
|
2539
|
+
"type": "string"
|
|
2540
|
+
},
|
|
2541
|
+
"url": { "type": ["string", "null"] }
|
|
2542
|
+
},
|
|
2543
|
+
"required": ["type"],
|
|
2544
|
+
"title": "OpenPageWebSearchAction",
|
|
2545
|
+
"type": "object"
|
|
2546
|
+
},
|
|
2547
|
+
{
|
|
2548
|
+
"properties": {
|
|
2549
|
+
"pattern": { "type": ["string", "null"] },
|
|
2550
|
+
"type": {
|
|
2551
|
+
"enum": ["findInPage"],
|
|
2552
|
+
"title": "FindInPageWebSearchActionType",
|
|
2553
|
+
"type": "string"
|
|
2554
|
+
},
|
|
2555
|
+
"url": { "type": ["string", "null"] }
|
|
2556
|
+
},
|
|
2557
|
+
"required": ["type"],
|
|
2558
|
+
"title": "FindInPageWebSearchAction",
|
|
2559
|
+
"type": "object"
|
|
2560
|
+
},
|
|
2561
|
+
{
|
|
2562
|
+
"properties": { "type": {
|
|
2563
|
+
"enum": ["other"],
|
|
2564
|
+
"title": "OtherWebSearchActionType",
|
|
2565
|
+
"type": "string"
|
|
2566
|
+
} },
|
|
2567
|
+
"required": ["type"],
|
|
2568
|
+
"title": "OtherWebSearchAction",
|
|
2569
|
+
"type": "object"
|
|
2570
|
+
}
|
|
2571
|
+
] }
|
|
2572
|
+
};
|
|
2573
|
+
//#endregion
|
|
2574
|
+
//#region extensions/codex/src/app-server/protocol-generated/json/v2/ErrorNotification.json
|
|
2575
|
+
var ErrorNotification_default = {
|
|
2576
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
2577
|
+
properties: {
|
|
2578
|
+
"error": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/TurnError" },
|
|
2579
|
+
"threadId": { "type": "string" },
|
|
2580
|
+
"turnId": { "type": "string" },
|
|
2581
|
+
"willRetry": { "type": "boolean" }
|
|
2582
|
+
},
|
|
2583
|
+
required: [
|
|
2584
|
+
"error",
|
|
2585
|
+
"threadId",
|
|
2586
|
+
"turnId",
|
|
2587
|
+
"willRetry"
|
|
2588
|
+
],
|
|
2589
|
+
title: "ErrorNotification",
|
|
2590
|
+
type: "object"
|
|
2591
|
+
};
|
|
2592
|
+
//#endregion
|
|
2593
|
+
//#region extensions/codex/src/app-server/protocol-generated/json/v2/ModelListResponse.json
|
|
2594
|
+
var ModelListResponse_default = {
|
|
2595
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
2596
|
+
properties: {
|
|
2597
|
+
"data": {
|
|
2598
|
+
"items": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/Model" },
|
|
2599
|
+
"type": "array"
|
|
2600
|
+
},
|
|
2601
|
+
"nextCursor": {
|
|
2602
|
+
"description": "Opaque cursor to pass to the next call to continue after the last item. If None, there are no more items to return.",
|
|
2603
|
+
"type": ["string", "null"]
|
|
2604
|
+
}
|
|
2605
|
+
},
|
|
2606
|
+
required: ["data"],
|
|
2607
|
+
title: "ModelListResponse",
|
|
2608
|
+
type: "object"
|
|
2609
|
+
};
|
|
2610
|
+
//#endregion
|
|
2611
|
+
//#region extensions/codex/src/app-server/protocol-generated/json/v2/ThreadResumeResponse.json
|
|
2612
|
+
var ThreadResumeResponse_default = {
|
|
2613
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
2614
|
+
properties: {
|
|
2615
|
+
"activePermissionProfile": {
|
|
2616
|
+
"anyOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/ActivePermissionProfile" }, { "type": "null" }],
|
|
2617
|
+
"default": null,
|
|
2618
|
+
"description": "Named or implicit built-in profile that produced the active permissions, when known."
|
|
2619
|
+
},
|
|
2620
|
+
"approvalPolicy": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/AskForApproval" },
|
|
2621
|
+
"approvalsReviewer": {
|
|
2622
|
+
"allOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/ApprovalsReviewer" }],
|
|
2623
|
+
"description": "Reviewer currently used for approval requests on this thread."
|
|
2624
|
+
},
|
|
2625
|
+
"cwd": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/AbsolutePathBuf" },
|
|
2626
|
+
"initialTurnsPage": {
|
|
2627
|
+
"anyOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/TurnsPage" }, { "type": "null" }],
|
|
2628
|
+
"default": null,
|
|
2629
|
+
"description": "`thread/turns/list` page returned when requested by `initialTurnsPage`."
|
|
2630
|
+
},
|
|
2631
|
+
"instructionSources": {
|
|
2632
|
+
"default": [],
|
|
2633
|
+
"description": "Environment-native paths to instruction source files currently loaded for this thread.",
|
|
2634
|
+
"items": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/LegacyAppPathString" },
|
|
2635
|
+
"type": "array"
|
|
2636
|
+
},
|
|
2637
|
+
"itemsBackwardsCursor": {
|
|
2638
|
+
"default": null,
|
|
2639
|
+
"description": "Opaque cursor for hydrating paginated items backwards.\n\nPass this as `cursor` to `thread/items/list` with `sortDirection: \"desc\"`. The first page includes the item identified by the cursor.",
|
|
2640
|
+
"type": ["string", "null"]
|
|
2641
|
+
},
|
|
2642
|
+
"model": { "type": "string" },
|
|
2643
|
+
"modelProvider": { "type": "string" },
|
|
2644
|
+
"multiAgentMode": {
|
|
2645
|
+
"allOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/MultiAgentMode" }],
|
|
2646
|
+
"default": "explicitRequestOnly",
|
|
2647
|
+
"description": "@deprecated Always `explicitRequestOnly`. Use `reasoningEffort` for Ultra behavior."
|
|
2648
|
+
},
|
|
2649
|
+
"reasoningEffort": { "anyOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/ReasoningEffort" }, { "type": "null" }] },
|
|
2650
|
+
"runtimeWorkspaceRoots": {
|
|
2651
|
+
"default": [],
|
|
2652
|
+
"description": "Thread-scoped runtime workspace roots used to materialize `:workspace_roots`.",
|
|
2653
|
+
"items": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/AbsolutePathBuf" },
|
|
2654
|
+
"type": "array"
|
|
2655
|
+
},
|
|
2656
|
+
"sandbox": {
|
|
2657
|
+
"allOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/SandboxPolicy" }],
|
|
2658
|
+
"description": "Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
|
|
2659
|
+
},
|
|
2660
|
+
"serviceTier": { "type": ["string", "null"] },
|
|
2661
|
+
"thread": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/Thread" },
|
|
2662
|
+
"turnsBackwardsCursor": {
|
|
2663
|
+
"default": null,
|
|
2664
|
+
"description": "Opaque cursor for hydrating paginated turns backwards.\n\nPass this as `cursor` to `thread/turns/list` with `sortDirection: \"desc\"`. The first page includes the turn identified by the cursor.",
|
|
2665
|
+
"type": ["string", "null"]
|
|
2666
|
+
}
|
|
2667
|
+
},
|
|
2668
|
+
required: [
|
|
2669
|
+
"approvalPolicy",
|
|
2670
|
+
"approvalsReviewer",
|
|
2671
|
+
"cwd",
|
|
2672
|
+
"model",
|
|
2673
|
+
"modelProvider",
|
|
2674
|
+
"sandbox",
|
|
2675
|
+
"thread"
|
|
2676
|
+
],
|
|
2677
|
+
title: "ThreadResumeResponse",
|
|
2678
|
+
type: "object"
|
|
2679
|
+
};
|
|
2680
|
+
//#endregion
|
|
2681
|
+
//#region extensions/codex/src/app-server/protocol-generated/json/v2/ThreadStartResponse.json
|
|
2682
|
+
var ThreadStartResponse_default = {
|
|
2683
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
2684
|
+
properties: {
|
|
2685
|
+
"activePermissionProfile": {
|
|
2686
|
+
"anyOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/ActivePermissionProfile" }, { "type": "null" }],
|
|
2687
|
+
"default": null,
|
|
2688
|
+
"description": "Named or implicit built-in profile that produced the active permissions, when known."
|
|
2689
|
+
},
|
|
2690
|
+
"approvalPolicy": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/AskForApproval" },
|
|
2691
|
+
"approvalsReviewer": {
|
|
2692
|
+
"allOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/ApprovalsReviewer" }],
|
|
2693
|
+
"description": "Reviewer currently used for approval requests on this thread."
|
|
2694
|
+
},
|
|
2695
|
+
"cwd": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/AbsolutePathBuf" },
|
|
2696
|
+
"instructionSources": {
|
|
2697
|
+
"default": [],
|
|
2698
|
+
"description": "Environment-native paths to instruction source files currently loaded for this thread.",
|
|
2699
|
+
"items": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/LegacyAppPathString" },
|
|
2700
|
+
"type": "array"
|
|
2701
|
+
},
|
|
2702
|
+
"model": { "type": "string" },
|
|
2703
|
+
"modelProvider": { "type": "string" },
|
|
2704
|
+
"multiAgentMode": {
|
|
2705
|
+
"allOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/MultiAgentMode" }],
|
|
2706
|
+
"default": "explicitRequestOnly",
|
|
2707
|
+
"description": "@deprecated Always `explicitRequestOnly`. Use `reasoningEffort` for Ultra behavior."
|
|
2708
|
+
},
|
|
2709
|
+
"reasoningEffort": { "anyOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/ReasoningEffort" }, { "type": "null" }] },
|
|
2710
|
+
"runtimeWorkspaceRoots": {
|
|
2711
|
+
"default": [],
|
|
2712
|
+
"description": "Thread-scoped runtime workspace roots used to materialize `:workspace_roots`.",
|
|
2713
|
+
"items": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/AbsolutePathBuf" },
|
|
2714
|
+
"type": "array"
|
|
2715
|
+
},
|
|
2716
|
+
"sandbox": {
|
|
2717
|
+
"allOf": [{ "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/SandboxPolicy" }],
|
|
2718
|
+
"description": "Legacy sandbox policy retained for compatibility. Experimental clients should prefer `activePermissionProfile` for profile provenance."
|
|
2719
|
+
},
|
|
2720
|
+
"serviceTier": { "type": ["string", "null"] },
|
|
2721
|
+
"thread": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/Thread" }
|
|
2722
|
+
},
|
|
2723
|
+
required: [
|
|
2724
|
+
"approvalPolicy",
|
|
2725
|
+
"approvalsReviewer",
|
|
2726
|
+
"cwd",
|
|
2727
|
+
"model",
|
|
2728
|
+
"modelProvider",
|
|
2729
|
+
"sandbox",
|
|
2730
|
+
"thread"
|
|
2731
|
+
],
|
|
2732
|
+
title: "ThreadStartResponse",
|
|
2733
|
+
type: "object"
|
|
2734
|
+
};
|
|
2735
|
+
//#endregion
|
|
2736
|
+
//#region extensions/codex/src/app-server/protocol-generated/json/v2/TurnCompletedNotification.json
|
|
2737
|
+
var TurnCompletedNotification_default = {
|
|
2738
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
2739
|
+
properties: {
|
|
2740
|
+
"threadId": { "type": "string" },
|
|
2741
|
+
"turn": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/Turn" }
|
|
2742
|
+
},
|
|
2743
|
+
required: ["threadId", "turn"],
|
|
2744
|
+
title: "TurnCompletedNotification",
|
|
2745
|
+
type: "object"
|
|
2746
|
+
};
|
|
2747
|
+
//#endregion
|
|
2748
|
+
//#region extensions/codex/src/app-server/protocol-generated/json/v2/TurnStartResponse.json
|
|
2749
|
+
var TurnStartResponse_default = {
|
|
2750
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
2751
|
+
properties: { "turn": { "$ref": "./CodexAppServerProtocolDefinitions.json#/definitions/Turn" } },
|
|
2752
|
+
required: ["turn"],
|
|
2753
|
+
title: "TurnStartResponse",
|
|
2754
|
+
type: "object"
|
|
2755
|
+
};
|
|
2756
|
+
//#endregion
|
|
2757
|
+
//#region extensions/codex/src/app-server/protocol-validators.ts
|
|
2758
|
+
/**
|
|
2759
|
+
* Runtime validators for Codex app-server protocol payloads, including schema
|
|
2760
|
+
* normalization for generated JSON Schema before TypeBox compilation.
|
|
2761
|
+
*/
|
|
2762
|
+
const externalDefinitionRefPrefix = "./CodexAppServerProtocolDefinitions.json#/definitions/";
|
|
2763
|
+
const rootExternalDefinitionRefPrefix = "./v2/CodexAppServerProtocolDefinitions.json#/definitions/";
|
|
2764
|
+
const localDefinitionRefPrefix = "#/definitions/";
|
|
2765
|
+
function materializeCodexSchema(schema, externalRefPrefix = externalDefinitionRefPrefix) {
|
|
2766
|
+
const sharedDefinitions = definitions;
|
|
2767
|
+
if (!isRecord(schema) || !isRecord(sharedDefinitions)) return schema;
|
|
2768
|
+
const reachable = collectDefinitionRefs(schema, externalRefPrefix);
|
|
2769
|
+
const pending = [...reachable];
|
|
2770
|
+
while (pending.length > 0) {
|
|
2771
|
+
const name = pending.pop();
|
|
2772
|
+
if (name === void 0) continue;
|
|
2773
|
+
const definition = sharedDefinitions[name];
|
|
2774
|
+
if (definition === void 0) throw new Error(`Missing generated Codex schema definition: ${name}`);
|
|
2775
|
+
for (const dependency of collectDefinitionRefs(definition, localDefinitionRefPrefix)) if (!reachable.has(dependency)) {
|
|
2776
|
+
reachable.add(dependency);
|
|
2777
|
+
pending.push(dependency);
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
if (reachable.size === 0) return schema;
|
|
2781
|
+
const definitions$1 = Object.fromEntries(Object.entries(sharedDefinitions).filter(([name]) => reachable.has(name)));
|
|
2782
|
+
return rewriteDefinitionRefs({
|
|
2783
|
+
...schema,
|
|
2784
|
+
definitions: definitions$1
|
|
2785
|
+
}, externalRefPrefix);
|
|
2786
|
+
}
|
|
2787
|
+
function collectDefinitionRefs(value, prefix, names = /* @__PURE__ */ new Set()) {
|
|
2788
|
+
if (Array.isArray(value)) for (const entry of value) collectDefinitionRefs(entry, prefix, names);
|
|
2789
|
+
else if (isRecord(value)) {
|
|
2790
|
+
if (typeof value.$ref === "string" && value.$ref.startsWith(prefix)) {
|
|
2791
|
+
const name = value.$ref.slice(prefix.length).split("/", 1)[0];
|
|
2792
|
+
if (name) names.add(name.replaceAll("~1", "/").replaceAll("~0", "~"));
|
|
2793
|
+
}
|
|
2794
|
+
for (const entry of Object.values(value)) collectDefinitionRefs(entry, prefix, names);
|
|
2795
|
+
}
|
|
2796
|
+
return names;
|
|
2797
|
+
}
|
|
2798
|
+
function rewriteDefinitionRefs(value, externalRefPrefix) {
|
|
2799
|
+
if (Array.isArray(value)) return value.map((entry) => rewriteDefinitionRefs(entry, externalRefPrefix));
|
|
2800
|
+
if (!isRecord(value)) return value;
|
|
2801
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, key === "$ref" && typeof entry === "string" && entry.startsWith(externalRefPrefix) ? `${localDefinitionRefPrefix}${entry.slice(externalRefPrefix.length)}` : rewriteDefinitionRefs(entry, externalRefPrefix)]));
|
|
2802
|
+
}
|
|
2803
|
+
const dynamicToolCallParamsSchema = materializeCodexSchema(DynamicToolCallParams_default, rootExternalDefinitionRefPrefix);
|
|
2804
|
+
const errorNotificationSchema = materializeCodexSchema(ErrorNotification_default);
|
|
2805
|
+
const modelListResponseSchema = materializeCodexSchema(ModelListResponse_default);
|
|
2806
|
+
const threadResumeResponseSchema = materializeCodexSchema(ThreadResumeResponse_default);
|
|
2807
|
+
const threadStartResponseSchema = materializeCodexSchema(ThreadStartResponse_default);
|
|
2808
|
+
const turnCompletedNotificationSchema = materializeCodexSchema(TurnCompletedNotification_default);
|
|
2809
|
+
const turnStartResponseSchema = materializeCodexSchema(TurnStartResponse_default);
|
|
2810
|
+
function compileCodexSchema(schema) {
|
|
2811
|
+
const validator = Compile(normalizeJsonSchemaNode(schema));
|
|
2812
|
+
return {
|
|
2813
|
+
check: (value) => validator.Check(value),
|
|
2814
|
+
errors: (value) => [...validator.Errors(value)]
|
|
2815
|
+
};
|
|
2816
|
+
}
|
|
2817
|
+
const schemaMapKeywords = /* @__PURE__ */ new Set([
|
|
2818
|
+
"$defs",
|
|
2819
|
+
"definitions",
|
|
2820
|
+
"dependentSchemas",
|
|
2821
|
+
"patternProperties",
|
|
2822
|
+
"properties"
|
|
2823
|
+
]);
|
|
2824
|
+
const schemaValueKeywords = /* @__PURE__ */ new Set([
|
|
2825
|
+
"additionalItems",
|
|
2826
|
+
"additionalProperties",
|
|
2827
|
+
"contains",
|
|
2828
|
+
"else",
|
|
2829
|
+
"if",
|
|
2830
|
+
"items",
|
|
2831
|
+
"not",
|
|
2832
|
+
"propertyNames",
|
|
2833
|
+
"then",
|
|
2834
|
+
"unevaluatedItems",
|
|
2835
|
+
"unevaluatedProperties"
|
|
2836
|
+
]);
|
|
2837
|
+
const schemaArrayKeywords = /* @__PURE__ */ new Set([
|
|
2838
|
+
"allOf",
|
|
2839
|
+
"anyOf",
|
|
2840
|
+
"oneOf",
|
|
2841
|
+
"prefixItems"
|
|
2842
|
+
]);
|
|
2843
|
+
function schemaTypeIncludes(schema, type) {
|
|
2844
|
+
return schema.type === type || Array.isArray(schema.type) && schema.type.includes(type);
|
|
2845
|
+
}
|
|
2846
|
+
function normalizeSchemaMap(value) {
|
|
2847
|
+
if (!isRecord(value)) return value;
|
|
2848
|
+
return Object.fromEntries(Object.entries(value).map(([key, entry]) => [key, normalizeJsonSchemaNode(entry)]));
|
|
2849
|
+
}
|
|
2850
|
+
function expandJsonSchemaTypeArray(schema) {
|
|
2851
|
+
const { type, ...rest } = schema;
|
|
2852
|
+
if (!Array.isArray(type)) return schema;
|
|
2853
|
+
return { anyOf: type.map((entry) => Object.assign({}, rest, { type: entry })) };
|
|
2854
|
+
}
|
|
2855
|
+
function normalizeJsonSchemaNode(schema) {
|
|
2856
|
+
if (Array.isArray(schema)) return schema.map((entry) => normalizeJsonSchemaNode(entry));
|
|
2857
|
+
if (!isRecord(schema)) return schema;
|
|
2858
|
+
const normalizedSchema = expandJsonSchemaTypeArray(schema);
|
|
2859
|
+
return Object.fromEntries(Object.entries(normalizedSchema).map(([key, value]) => {
|
|
2860
|
+
if (schemaMapKeywords.has(key)) return [key, normalizeSchemaMap(value)];
|
|
2861
|
+
if (schemaValueKeywords.has(key) || schemaArrayKeywords.has(key)) return [key, normalizeJsonSchemaNode(value)];
|
|
2862
|
+
return [key, value];
|
|
2863
|
+
}));
|
|
2864
|
+
}
|
|
2865
|
+
function readDefault(schema) {
|
|
2866
|
+
if (!isRecord(schema) || !Object.hasOwn(schema, "default")) return;
|
|
2867
|
+
return structuredClone(schema.default);
|
|
2868
|
+
}
|
|
2869
|
+
function decodePointerSegment(segment) {
|
|
2870
|
+
return segment.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
2871
|
+
}
|
|
2872
|
+
function resolveLocalRef(root, ref) {
|
|
2873
|
+
if (ref === "#") return root;
|
|
2874
|
+
if (!ref.startsWith("#/")) return;
|
|
2875
|
+
let current = root;
|
|
2876
|
+
for (const segment of ref.slice(2).split("/").map(decodePointerSegment)) {
|
|
2877
|
+
if (!isRecord(current)) return;
|
|
2878
|
+
current = current[segment];
|
|
2879
|
+
}
|
|
2880
|
+
return current;
|
|
2881
|
+
}
|
|
2882
|
+
function applySchemaDefaults(schema, value, root = schema, resolvingRefs = /* @__PURE__ */ new Set()) {
|
|
2883
|
+
if (value === void 0) {
|
|
2884
|
+
const defaultValue = readDefault(schema);
|
|
2885
|
+
if (defaultValue !== void 0) return defaultValue;
|
|
2886
|
+
}
|
|
2887
|
+
if (!isRecord(schema)) return value;
|
|
2888
|
+
let nextValue = value;
|
|
2889
|
+
if (typeof schema.$ref === "string" && !resolvingRefs.has(schema.$ref)) {
|
|
2890
|
+
const target = resolveLocalRef(root, schema.$ref);
|
|
2891
|
+
if (target !== void 0) {
|
|
2892
|
+
resolvingRefs.add(schema.$ref);
|
|
2893
|
+
nextValue = applySchemaDefaults(target, nextValue, root, resolvingRefs);
|
|
2894
|
+
resolvingRefs.delete(schema.$ref);
|
|
2895
|
+
}
|
|
2896
|
+
}
|
|
2897
|
+
for (const key of ["allOf"]) {
|
|
2898
|
+
const branches = schema[key];
|
|
2899
|
+
if (Array.isArray(branches)) for (const branch of branches) nextValue = applySchemaDefaults(branch, nextValue, root, resolvingRefs);
|
|
2900
|
+
}
|
|
2901
|
+
if (schemaTypeIncludes(schema, "object") && isRecord(nextValue) && isRecord(schema.properties)) {
|
|
2902
|
+
for (const [key, propertySchema] of Object.entries(schema.properties)) {
|
|
2903
|
+
const currentValue = nextValue[key];
|
|
2904
|
+
const defaultedValue = applySchemaDefaults(propertySchema, currentValue, root, resolvingRefs);
|
|
2905
|
+
if (defaultedValue !== void 0 && defaultedValue !== currentValue) nextValue[key] = defaultedValue;
|
|
2906
|
+
}
|
|
2907
|
+
if (isRecord(schema.additionalProperties)) for (const key of Object.keys(nextValue)) {
|
|
2908
|
+
if (Object.hasOwn(schema.properties, key)) continue;
|
|
2909
|
+
nextValue[key] = applySchemaDefaults(schema.additionalProperties, nextValue[key], root, resolvingRefs);
|
|
2910
|
+
}
|
|
2911
|
+
}
|
|
2912
|
+
if (schemaTypeIncludes(schema, "array") && Array.isArray(nextValue) && isRecord(schema.items)) return nextValue.map((entry) => applySchemaDefaults(schema.items, entry, root, resolvingRefs));
|
|
2913
|
+
return nextValue;
|
|
2914
|
+
}
|
|
2915
|
+
function normalizeWithDefaults(schema, value) {
|
|
2916
|
+
if (value === void 0 || value === null) return value;
|
|
2917
|
+
return applySchemaDefaults(schema, structuredClone(value));
|
|
2918
|
+
}
|
|
2919
|
+
const validateDynamicToolCallParams = compileCodexSchema(dynamicToolCallParamsSchema);
|
|
2920
|
+
const validateErrorNotification = compileCodexSchema(errorNotificationSchema);
|
|
2921
|
+
const validateModelListResponse = compileCodexSchema(modelListResponseSchema);
|
|
2922
|
+
const validateThreadResumeResponse = compileCodexSchema(threadResumeResponseSchema);
|
|
2923
|
+
const validateThreadStartResponse = compileCodexSchema(threadStartResponseSchema);
|
|
2924
|
+
const validateTurnCompletedNotification = compileCodexSchema(turnCompletedNotificationSchema);
|
|
2925
|
+
const validateTurnStartResponse = compileCodexSchema(turnStartResponseSchema);
|
|
2926
|
+
/** Asserts and normalizes a Codex thread/start response. */
|
|
2927
|
+
function assertCodexThreadStartResponse(value) {
|
|
2928
|
+
const normalized = normalizeWithDefaults(threadStartResponseSchema, value);
|
|
2929
|
+
return assertCodexShape(validateThreadStartResponse, normalized, "thread/start response");
|
|
2930
|
+
}
|
|
2931
|
+
/** Asserts and normalizes a Codex thread/fork response. */
|
|
2932
|
+
function assertCodexThreadForkResponse(value) {
|
|
2933
|
+
const normalized = normalizeWithDefaults(threadStartResponseSchema, value);
|
|
2934
|
+
return assertCodexShape(validateThreadStartResponse, normalized, "thread/fork response");
|
|
2935
|
+
}
|
|
2936
|
+
/** Asserts and normalizes a Codex thread/resume response. */
|
|
2937
|
+
function assertCodexThreadResumeResponse(value) {
|
|
2938
|
+
const normalized = normalizeWithDefaults(threadResumeResponseSchema, value);
|
|
2939
|
+
return assertCodexShape(validateThreadResumeResponse, normalized, "thread/resume response");
|
|
2940
|
+
}
|
|
2941
|
+
var CodexThreadDirectInputError = class extends Error {
|
|
2942
|
+
constructor(threadId) {
|
|
2943
|
+
super(`Codex thread ${threadId} is controlled by its parent and cannot accept direct input. Continue its parent thread, or use /new for a separate OpenClaw session.`);
|
|
2944
|
+
this.name = "CodexThreadDirectInputError";
|
|
2945
|
+
}
|
|
2946
|
+
};
|
|
2947
|
+
/** Native V2 children allow observation, but only their parent may supply turn input. */
|
|
2948
|
+
function assertCodexThreadAcceptsDirectInput(thread) {
|
|
2949
|
+
if (thread.canAcceptDirectInput === false) throw new CodexThreadDirectInputError(thread.id);
|
|
2950
|
+
}
|
|
2951
|
+
/** Asserts and normalizes a Codex turn/start response. */
|
|
2952
|
+
function assertCodexTurnStartResponse(value) {
|
|
2953
|
+
const normalized = normalizeWithDefaults(turnStartResponseSchema, normalizeTurnEnvelope(value));
|
|
2954
|
+
return assertCodexShape(validateTurnStartResponse, normalized, "turn/start response");
|
|
2955
|
+
}
|
|
2956
|
+
/** Only the current text prompt may be echoed; capabilities and historical items are not passive. */
|
|
2957
|
+
function assertCodexPassiveTurnItems(items, prompt, taskLabel) {
|
|
2958
|
+
let promptEchoSeen = false;
|
|
2959
|
+
for (const item of items) {
|
|
2960
|
+
if (item.type === "agentMessage" || item.type === "reasoning") continue;
|
|
2961
|
+
if (item.type === "userMessage" && !promptEchoSeen) {
|
|
2962
|
+
const content = Array.isArray(item.content) ? item.content : [];
|
|
2963
|
+
const input = content[0];
|
|
2964
|
+
if (content.length === 1 && isJsonObject(input) && input.type === "text" && input.text === prompt) {
|
|
2965
|
+
promptEchoSeen = true;
|
|
2966
|
+
continue;
|
|
2967
|
+
}
|
|
2968
|
+
}
|
|
2969
|
+
throw new Error(`Codex ${taskLabel} returned unexpected native item: ${item.type}`);
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
/** Reads Codex dynamic-tool call params, returning undefined for invalid payloads. */
|
|
2973
|
+
function readCodexDynamicToolCallParams(value) {
|
|
2974
|
+
return readCodexShape(validateDynamicToolCallParams, normalizeWithDefaults(dynamicToolCallParamsSchema, value));
|
|
2975
|
+
}
|
|
2976
|
+
/** Reads a Codex error notification payload if it matches the protocol schema. */
|
|
2977
|
+
function readCodexErrorNotification(value) {
|
|
2978
|
+
return readCodexShape(validateErrorNotification, normalizeWithDefaults(errorNotificationSchema, value));
|
|
2979
|
+
}
|
|
2980
|
+
/** Asserts and normalizes a Codex model/list response. */
|
|
2981
|
+
function assertCodexModelListResponse(value) {
|
|
2982
|
+
return assertCodexShape(validateModelListResponse, normalizeWithDefaults(modelListResponseSchema, value), "model/list response");
|
|
2983
|
+
}
|
|
2984
|
+
/** Reads and normalizes a Codex turn object. */
|
|
2985
|
+
function readCodexTurn(value) {
|
|
2986
|
+
return readCodexShape(validateTurnStartResponse, normalizeWithDefaults(turnStartResponseSchema, { turn: normalizeTurn(value) }))?.turn;
|
|
2987
|
+
}
|
|
2988
|
+
/** Reads a Codex turn/completed notification payload if it matches the protocol schema. */
|
|
2989
|
+
function readCodexTurnCompletedNotification(value) {
|
|
2990
|
+
return readCodexShape(validateTurnCompletedNotification, normalizeWithDefaults(turnCompletedNotificationSchema, normalizeTurnEnvelope(value)));
|
|
2991
|
+
}
|
|
2992
|
+
function assertCodexShape(validate, value, label) {
|
|
2993
|
+
if (validate.check(value)) return value;
|
|
2994
|
+
throw new Error(`Invalid Codex app-server ${label}: ${formatValidationErrors(validate, value)}`);
|
|
2995
|
+
}
|
|
2996
|
+
function readCodexShape(validate, value) {
|
|
2997
|
+
return validate.check(value) ? value : void 0;
|
|
2998
|
+
}
|
|
2999
|
+
function normalizeTurn(value) {
|
|
3000
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
3001
|
+
return {
|
|
3002
|
+
error: null,
|
|
3003
|
+
startedAt: null,
|
|
3004
|
+
completedAt: null,
|
|
3005
|
+
durationMs: null,
|
|
3006
|
+
...value,
|
|
3007
|
+
items: Array.isArray(value.items) ? value.items.map(normalizeThreadItem) : []
|
|
3008
|
+
};
|
|
3009
|
+
}
|
|
3010
|
+
function normalizeThreadItem(value) {
|
|
3011
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return value;
|
|
3012
|
+
switch (value.type) {
|
|
3013
|
+
case "agentMessage": return {
|
|
3014
|
+
phase: null,
|
|
3015
|
+
delivery: null,
|
|
3016
|
+
memoryCitation: null,
|
|
3017
|
+
...value
|
|
3018
|
+
};
|
|
3019
|
+
case "plan": return {
|
|
3020
|
+
text: "",
|
|
3021
|
+
...value
|
|
3022
|
+
};
|
|
3023
|
+
case "reasoning": return {
|
|
3024
|
+
summary: [],
|
|
3025
|
+
content: [],
|
|
3026
|
+
...value
|
|
3027
|
+
};
|
|
3028
|
+
case "dynamicToolCall": return {
|
|
3029
|
+
namespace: null,
|
|
3030
|
+
arguments: null,
|
|
3031
|
+
status: "completed",
|
|
3032
|
+
contentItems: null,
|
|
3033
|
+
success: null,
|
|
3034
|
+
durationMs: null,
|
|
3035
|
+
...value
|
|
3036
|
+
};
|
|
3037
|
+
default: return value;
|
|
3038
|
+
}
|
|
3039
|
+
}
|
|
3040
|
+
function normalizeTurnEnvelope(value) {
|
|
3041
|
+
if (!value || typeof value !== "object" || Array.isArray(value) || !("turn" in value)) return value;
|
|
3042
|
+
return {
|
|
3043
|
+
...value,
|
|
3044
|
+
turn: normalizeTurn(value.turn)
|
|
3045
|
+
};
|
|
3046
|
+
}
|
|
3047
|
+
function formatValidationErrors(validate, value) {
|
|
3048
|
+
const errors = validate.errors(value);
|
|
3049
|
+
if (!errors || errors.length === 0) return "schema validation failed";
|
|
3050
|
+
return errors.map((error) => {
|
|
3051
|
+
const message = error.message?.trim() || "schema validation failed";
|
|
3052
|
+
return error.instancePath ? `${error.instancePath} ${message}` : message;
|
|
3053
|
+
}).join("; ");
|
|
3054
|
+
}
|
|
3055
|
+
//#endregion
|
|
3056
|
+
//#region extensions/codex/src/app-server/transport-websocket.ts
|
|
3057
|
+
/**
|
|
3058
|
+
* Adapts a remote Codex app-server WebSocket endpoint to the shared stdio-like
|
|
3059
|
+
* transport interface.
|
|
3060
|
+
*/
|
|
3061
|
+
const WEBSOCKET_HANDSHAKE_TIMEOUT_MS = 1e4;
|
|
3062
|
+
const WEBSOCKET_PING_INTERVAL_MS = 2e4;
|
|
3063
|
+
const WEBSOCKET_PONG_TIMEOUT_MS = 2e4;
|
|
3064
|
+
const MAX_CONSECUTIVE_MISSED_WEBSOCKET_PONGS = 5;
|
|
3065
|
+
/** Opens a WebSocket app-server transport and maps newline-delimited frames to stdout/stdin. */
|
|
3066
|
+
function createWebSocketTransport(options) {
|
|
3067
|
+
if (!options.url) throw new Error("codex app-server websocket transport requires plugins.entries.codex.config.appServer.url");
|
|
3068
|
+
const events = new EventEmitter();
|
|
3069
|
+
const stdout = new PassThrough();
|
|
3070
|
+
const stderr = new PassThrough();
|
|
3071
|
+
const websocketOptions = {
|
|
3072
|
+
headers: {
|
|
3073
|
+
...options.headers,
|
|
3074
|
+
...options.authToken ? { Authorization: `Bearer ${options.authToken}` } : {}
|
|
3075
|
+
},
|
|
3076
|
+
perMessageDeflate: false,
|
|
3077
|
+
...options.transport === "websocket" ? { handshakeTimeout: WEBSOCKET_HANDSHAKE_TIMEOUT_MS } : {}
|
|
3078
|
+
};
|
|
3079
|
+
const unixSocketPath = resolveCodexAppServerUnixSocketPath(options);
|
|
3080
|
+
const socket = unixSocketPath ? new WebSocket("ws://localhost/", {
|
|
3081
|
+
...websocketOptions,
|
|
3082
|
+
createConnection: () => connectCodexAppServerUnixSocket(unixSocketPath)
|
|
3083
|
+
}) : new WebSocket(options.url, websocketOptions);
|
|
3084
|
+
const pendingFrames = [];
|
|
3085
|
+
const stdinDecoder = new StringDecoder("utf8");
|
|
3086
|
+
let pendingLine = "";
|
|
3087
|
+
let killed = false;
|
|
3088
|
+
let pingTimeout;
|
|
3089
|
+
let pongTimeout;
|
|
3090
|
+
let expectedPong;
|
|
3091
|
+
let consecutiveMissedPongs = 0;
|
|
3092
|
+
let heartbeatSequence = 0;
|
|
3093
|
+
const clearConnectionHealthTimers = () => {
|
|
3094
|
+
if (pingTimeout) {
|
|
3095
|
+
clearTimeout(pingTimeout);
|
|
3096
|
+
pingTimeout = void 0;
|
|
3097
|
+
}
|
|
3098
|
+
if (pongTimeout) {
|
|
3099
|
+
clearTimeout(pongTimeout);
|
|
3100
|
+
pongTimeout = void 0;
|
|
3101
|
+
}
|
|
3102
|
+
expectedPong = void 0;
|
|
3103
|
+
};
|
|
3104
|
+
const sendHeartbeatPing = () => {
|
|
3105
|
+
if (socket.readyState !== WebSocket.OPEN || pongTimeout) return;
|
|
3106
|
+
const payload = Buffer.from(`openclaw-codex-${++heartbeatSequence}`);
|
|
3107
|
+
expectedPong = payload;
|
|
3108
|
+
pongTimeout = setTimeout(() => {
|
|
3109
|
+
pongTimeout = void 0;
|
|
3110
|
+
expectedPong = void 0;
|
|
3111
|
+
consecutiveMissedPongs += 1;
|
|
3112
|
+
if (consecutiveMissedPongs >= MAX_CONSECUTIVE_MISSED_WEBSOCKET_PONGS) {
|
|
3113
|
+
socket.terminate();
|
|
3114
|
+
return;
|
|
3115
|
+
}
|
|
3116
|
+
sendHeartbeatPing();
|
|
3117
|
+
}, WEBSOCKET_PONG_TIMEOUT_MS);
|
|
3118
|
+
pongTimeout.unref();
|
|
3119
|
+
socket.ping(payload, void 0, (error) => {
|
|
3120
|
+
if (error) socket.terminate();
|
|
3121
|
+
});
|
|
3122
|
+
};
|
|
3123
|
+
const scheduleHeartbeatPing = () => {
|
|
3124
|
+
if (options.transport !== "websocket" || socket.readyState !== WebSocket.OPEN || pingTimeout || pongTimeout) return;
|
|
3125
|
+
pingTimeout = setTimeout(() => {
|
|
3126
|
+
pingTimeout = void 0;
|
|
3127
|
+
sendHeartbeatPing();
|
|
3128
|
+
}, WEBSOCKET_PING_INTERVAL_MS);
|
|
3129
|
+
pingTimeout.unref();
|
|
3130
|
+
};
|
|
3131
|
+
const recordConnectionActivity = () => {
|
|
3132
|
+
consecutiveMissedPongs = 0;
|
|
3133
|
+
if (pongTimeout) {
|
|
3134
|
+
clearTimeout(pongTimeout);
|
|
3135
|
+
pongTimeout = void 0;
|
|
3136
|
+
}
|
|
3137
|
+
expectedPong = void 0;
|
|
3138
|
+
scheduleHeartbeatPing();
|
|
3139
|
+
};
|
|
3140
|
+
const sendFrame = (frame) => {
|
|
3141
|
+
const trimmed = frame.trim();
|
|
3142
|
+
if (!trimmed) return;
|
|
3143
|
+
if (socket.readyState === WebSocket.OPEN) {
|
|
3144
|
+
socket.send(trimmed);
|
|
3145
|
+
return;
|
|
3146
|
+
}
|
|
3147
|
+
pendingFrames.push(trimmed);
|
|
3148
|
+
};
|
|
3149
|
+
socket.once("open", () => {
|
|
3150
|
+
for (const frame of pendingFrames.splice(0)) socket.send(frame);
|
|
3151
|
+
scheduleHeartbeatPing();
|
|
3152
|
+
});
|
|
3153
|
+
socket.on("pong", (payload) => {
|
|
3154
|
+
if (expectedPong?.equals(payload)) recordConnectionActivity();
|
|
3155
|
+
});
|
|
3156
|
+
socket.once("error", (error) => {
|
|
3157
|
+
clearConnectionHealthTimers();
|
|
3158
|
+
events.emit("error", error);
|
|
3159
|
+
});
|
|
3160
|
+
socket.once("close", (code, reason) => {
|
|
3161
|
+
clearConnectionHealthTimers();
|
|
3162
|
+
killed = true;
|
|
3163
|
+
events.emit("exit", code, reason.toString("utf8"));
|
|
3164
|
+
});
|
|
3165
|
+
socket.on("message", (data) => {
|
|
3166
|
+
if (options.transport === "websocket") recordConnectionActivity();
|
|
3167
|
+
const text = websocketFrameToText(data);
|
|
3168
|
+
stdout.write(text.endsWith("\n") ? text : `${text}\n`);
|
|
3169
|
+
});
|
|
3170
|
+
const stdin = new Writable({
|
|
3171
|
+
write(chunk, _encoding, callback) {
|
|
3172
|
+
pendingLine += stdinDecoder.write(chunk);
|
|
3173
|
+
const lines = pendingLine.split("\n");
|
|
3174
|
+
pendingLine = lines.pop() ?? "";
|
|
3175
|
+
for (const frame of lines) sendFrame(frame);
|
|
3176
|
+
callback();
|
|
3177
|
+
},
|
|
3178
|
+
final(callback) {
|
|
3179
|
+
pendingLine += stdinDecoder.end();
|
|
3180
|
+
if (pendingLine) sendFrame(pendingLine);
|
|
3181
|
+
pendingLine = "";
|
|
3182
|
+
callback();
|
|
3183
|
+
}
|
|
3184
|
+
});
|
|
3185
|
+
const closeSocket = () => {
|
|
3186
|
+
if (socket.readyState === WebSocket.CLOSED || socket.readyState === WebSocket.CLOSING) return;
|
|
3187
|
+
socket.close();
|
|
3188
|
+
};
|
|
3189
|
+
stdin.once("finish", closeSocket);
|
|
3190
|
+
stdin.once("close", closeSocket);
|
|
3191
|
+
return {
|
|
3192
|
+
maxFrameBytes: 16777216,
|
|
3193
|
+
stdin,
|
|
3194
|
+
stdout,
|
|
3195
|
+
stderr,
|
|
3196
|
+
get killed() {
|
|
3197
|
+
return killed;
|
|
3198
|
+
},
|
|
3199
|
+
kill: () => {
|
|
3200
|
+
killed = true;
|
|
3201
|
+
clearConnectionHealthTimers();
|
|
3202
|
+
socket.close();
|
|
3203
|
+
},
|
|
3204
|
+
once: (event, listener) => events.once(event, listener)
|
|
3205
|
+
};
|
|
3206
|
+
}
|
|
3207
|
+
/** Opens the owner-scoped Codex control socket used by the WebSocket upgrade. */
|
|
3208
|
+
function connectCodexAppServerUnixSocket(socketPath) {
|
|
3209
|
+
return net.createConnection(socketPath);
|
|
3210
|
+
}
|
|
3211
|
+
/** Resolves the canonical or explicitly configured Codex control socket. */
|
|
3212
|
+
function resolveCodexAppServerUnixSocketPath(options) {
|
|
3213
|
+
if (options.transport !== "unix") {
|
|
3214
|
+
if (options.url?.startsWith("unix://")) throw new Error("codex app-server unix URL requires unix transport");
|
|
3215
|
+
return;
|
|
3216
|
+
}
|
|
3217
|
+
const url = options.url ?? "unix://";
|
|
3218
|
+
if (!url.startsWith("unix://")) throw new Error("codex app-server unix transport requires a unix:// URL");
|
|
3219
|
+
return url.slice(7) || path.join(resolveCodexAppServerUserHomeDir(options.env ?? process.env), "app-server-control", "app-server-control.sock");
|
|
3220
|
+
}
|
|
3221
|
+
function websocketFrameToText(data) {
|
|
3222
|
+
if (typeof data === "string") return data;
|
|
3223
|
+
if (Buffer.isBuffer(data)) return data.toString("utf8");
|
|
3224
|
+
if (Array.isArray(data)) return Buffer.concat(data).toString("utf8");
|
|
3225
|
+
return Buffer.from(data).toString("utf8");
|
|
3226
|
+
}
|
|
3227
|
+
//#endregion
|
|
3228
|
+
//#region extensions/codex/src/app-server/client.ts
|
|
3229
|
+
/**
|
|
3230
|
+
* JSON-RPC client for Codex app-server transports, including request/response
|
|
3231
|
+
* routing, notification fanout, server request handlers, and version checks.
|
|
3232
|
+
*/
|
|
3233
|
+
var client_exports = /* @__PURE__ */ __exportAll({
|
|
3234
|
+
CodexAppServerClient: () => CodexAppServerClient,
|
|
3235
|
+
getCodexAppServerClientInstanceId: () => getCodexAppServerClientInstanceId,
|
|
3236
|
+
isCodexAppServerApprovalRequest: () => isCodexAppServerApprovalRequest,
|
|
3237
|
+
isCodexAppServerBrokenPipeError: () => isCodexAppServerBrokenPipeError,
|
|
3238
|
+
isCodexAppServerConnectionClosedError: () => isCodexAppServerConnectionClosedError,
|
|
3239
|
+
isCodexAppServerIndeterminateRequestCancellationError: () => isCodexAppServerIndeterminateRequestCancellationError,
|
|
3240
|
+
isCodexAppServerIndeterminateTransportError: () => isCodexAppServerIndeterminateTransportError,
|
|
3241
|
+
isCodexAppServerOverloadError: () => isCodexAppServerOverloadError,
|
|
3242
|
+
isCodexAppServerPrewriteRequestCancellationError: () => isCodexAppServerPrewriteRequestCancellationError,
|
|
3243
|
+
isCodexAppServerRequestTimeoutError: () => isCodexAppServerRequestTimeoutError,
|
|
3244
|
+
isUnsupportedCodexAppServerVersionError: () => isUnsupportedCodexAppServerVersionError,
|
|
3245
|
+
resolveCodexAppServerClientInstanceId: () => resolveCodexAppServerClientInstanceId
|
|
3246
|
+
});
|
|
3247
|
+
const CODEX_APP_SERVER_PARSE_LOG_MAX = 500;
|
|
3248
|
+
const CODEX_APP_SERVER_PARSE_BUFFER_MAX = 8388608;
|
|
3249
|
+
const CODEX_APP_SERVER_PARSE_BUFFER_MAX_LINES = 1e3;
|
|
3250
|
+
const CODEX_APP_SERVER_STDERR_TAIL_MAX = 2e3;
|
|
3251
|
+
const CODEX_APP_SERVER_OVERLOADED_ERROR_CODE = -32001;
|
|
3252
|
+
const CODEX_APP_SERVER_OVERLOAD_MAX_RETRIES = 3;
|
|
3253
|
+
const CODEX_APP_SERVER_OVERLOAD_RETRY_BASE_MS = 50;
|
|
3254
|
+
const CODEX_APP_SERVER_PENDING_STARTUP_WARNINGS_MAX = 32;
|
|
3255
|
+
const CODEX_APP_SERVER_CLIENT_INSTANCE_IDS = /* @__PURE__ */ new WeakMap();
|
|
3256
|
+
const UNPAIRED_SURROGATE_RE = /[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/g;
|
|
3257
|
+
/** Process-local generation fence for bindings tied to one app-server client instance. */
|
|
3258
|
+
function getCodexAppServerClientInstanceId(client) {
|
|
3259
|
+
const current = CODEX_APP_SERVER_CLIENT_INSTANCE_IDS.get(client);
|
|
3260
|
+
if (current) return current;
|
|
3261
|
+
const created = randomUUID();
|
|
3262
|
+
CODEX_APP_SERVER_CLIENT_INSTANCE_IDS.set(client, created);
|
|
3263
|
+
return created;
|
|
3264
|
+
}
|
|
3265
|
+
function resolveCodexAppServerClientInstanceId(client) {
|
|
3266
|
+
return client.getInstanceId?.call(client) ?? getCodexAppServerClientInstanceId(client);
|
|
3267
|
+
}
|
|
3268
|
+
/** Codex rejects this exact code before enqueueing, including mutating requests. */
|
|
3269
|
+
function isCodexAppServerOverloadError(error) {
|
|
3270
|
+
return error instanceof CodexAppServerRpcError && error.code === CODEX_APP_SERVER_OVERLOADED_ERROR_CODE;
|
|
3271
|
+
}
|
|
3272
|
+
var CodexAppServerLocalRequestCancellationError = class extends Error {
|
|
3273
|
+
constructor(method, reason, mayHaveWritten) {
|
|
3274
|
+
super(`${method} ${reason}`);
|
|
3275
|
+
this.reason = reason;
|
|
3276
|
+
this.mayHaveWritten = mayHaveWritten;
|
|
3277
|
+
this.code = "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED";
|
|
3278
|
+
this.name = "CodexAppServerLocalRequestCancellationError";
|
|
3279
|
+
}
|
|
3280
|
+
};
|
|
3281
|
+
function isCodexAppServerRequestTimeoutError(error) {
|
|
3282
|
+
return error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED" && "reason" in error && error.reason === "timed out";
|
|
3283
|
+
}
|
|
3284
|
+
function isCodexAppServerBrokenPipeError(error) {
|
|
3285
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3286
|
+
let current = error;
|
|
3287
|
+
while (current && typeof current === "object" && !seen.has(current)) {
|
|
3288
|
+
seen.add(current);
|
|
3289
|
+
if ("code" in current && current.code === "EPIPE") return true;
|
|
3290
|
+
current = "cause" in current ? current.cause : void 0;
|
|
3291
|
+
}
|
|
3292
|
+
return false;
|
|
3293
|
+
}
|
|
3294
|
+
var CodexAppServerIndeterminateTransportError = class extends Error {
|
|
3295
|
+
constructor(method, cause) {
|
|
3296
|
+
super(`${method} transport failed after request write: ${cause.message}`, { cause });
|
|
3297
|
+
this.code = "CODEX_APP_SERVER_REQUEST_TRANSPORT_INDETERMINATE";
|
|
3298
|
+
this.mayHaveWritten = true;
|
|
3299
|
+
this.name = "CodexAppServerIndeterminateTransportError";
|
|
3300
|
+
}
|
|
3301
|
+
};
|
|
3302
|
+
/** True when a local cancellation can leave an app-server request in flight. */
|
|
3303
|
+
function isCodexAppServerIndeterminateRequestCancellationError(error) {
|
|
3304
|
+
return error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED" && "mayHaveWritten" in error && error.mayHaveWritten === true;
|
|
3305
|
+
}
|
|
3306
|
+
/** True when local cancellation happened before a request write was attempted. */
|
|
3307
|
+
function isCodexAppServerPrewriteRequestCancellationError(error) {
|
|
3308
|
+
return error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_LOCAL_REQUEST_CANCELLED" && "mayHaveWritten" in error && error.mayHaveWritten === false;
|
|
3309
|
+
}
|
|
3310
|
+
/** True when transport failure cannot prove a written request stopped running. */
|
|
3311
|
+
function isCodexAppServerIndeterminateTransportError(error) {
|
|
3312
|
+
return error instanceof Error && "code" in error && error.code === "CODEX_APP_SERVER_REQUEST_TRANSPORT_INDETERMINATE" && "mayHaveWritten" in error && error.mayHaveWritten === true;
|
|
3313
|
+
}
|
|
3314
|
+
/** Returns true for errors that mean the app-server transport is closed. */
|
|
3315
|
+
function isCodexAppServerConnectionClosedError(error) {
|
|
3316
|
+
if (!(error instanceof Error)) return false;
|
|
3317
|
+
if (isCodexAppServerIndeterminateTransportError(error)) return true;
|
|
3318
|
+
return error.message === "codex app-server client is closed" || error.message.startsWith("codex app-server exited:");
|
|
3319
|
+
}
|
|
3320
|
+
/** Stateful app-server JSON-RPC client over stdio or websocket transport. */
|
|
3321
|
+
var CodexAppServerClient = class CodexAppServerClient {
|
|
3322
|
+
constructor(child) {
|
|
3323
|
+
this.instanceId = randomUUID();
|
|
3324
|
+
this.pending = /* @__PURE__ */ new Map();
|
|
3325
|
+
this.requestHandlers = /* @__PURE__ */ new Set();
|
|
3326
|
+
this.notificationHandlers = /* @__PURE__ */ new Set();
|
|
3327
|
+
this.pendingStartupWarnings = [];
|
|
3328
|
+
this.closeHandlers = /* @__PURE__ */ new Set();
|
|
3329
|
+
this.nextId = 1;
|
|
3330
|
+
this.initialized = false;
|
|
3331
|
+
this.modelCatalogRevision = 0;
|
|
3332
|
+
this.closed = false;
|
|
3333
|
+
this.transportExited = false;
|
|
3334
|
+
this.nativeExecutionObserved = false;
|
|
3335
|
+
this.stderrTail = "";
|
|
3336
|
+
this.child = child;
|
|
3337
|
+
this.lines = createInterface({ input: child.stdout });
|
|
3338
|
+
this.lines.on("line", (line) => this.handleLine(line));
|
|
3339
|
+
this.lines.on("error", (error) => this.closeWithError(toStringifiedError(error)));
|
|
3340
|
+
child.stdout.on("error", (error) => this.closeWithError(toStringifiedError(error)));
|
|
3341
|
+
child.stderr.setEncoding("utf8");
|
|
3342
|
+
child.stderr.on("data", (text) => {
|
|
3343
|
+
this.stderrTail = appendBoundedTail(this.stderrTail, text, CODEX_APP_SERVER_STDERR_TAIL_MAX);
|
|
3344
|
+
const trimmed = text.trim();
|
|
3345
|
+
if (trimmed) embeddedAgentLog.debug(`codex app-server stderr: ${trimmed}`);
|
|
3346
|
+
});
|
|
3347
|
+
child.stderr.on("error", (error) => {
|
|
3348
|
+
embeddedAgentLog.warn("codex app-server stderr stream failed", { error });
|
|
3349
|
+
});
|
|
3350
|
+
child.once("error", (error) => this.closeWithError(toStringifiedError(error)));
|
|
3351
|
+
child.once("exit", (code, signal) => {
|
|
3352
|
+
this.transportExited = true;
|
|
3353
|
+
this.closeWithError(buildCodexAppServerExitError(code, signal, this.stderrTail));
|
|
3354
|
+
});
|
|
3355
|
+
child.stdin.on?.("error", (error) => this.closeWithError(toStringifiedError(error)));
|
|
3356
|
+
}
|
|
3357
|
+
/** Starts a new app-server client using resolved runtime start options. */
|
|
3358
|
+
static async start(options, assertCurrent) {
|
|
3359
|
+
const defaults = resolveCodexAppServerRuntimeOptions().start;
|
|
3360
|
+
const startOptions = {
|
|
3361
|
+
...defaults,
|
|
3362
|
+
...options,
|
|
3363
|
+
headers: options?.headers ?? defaults.headers
|
|
3364
|
+
};
|
|
3365
|
+
if (startOptions.transport === "stdio" && startOptions.commandSource === "managed") throw new Error("Managed Codex app-server start options must be resolved before spawn.");
|
|
3366
|
+
if (startOptions.transport === "websocket" || startOptions.transport === "unix") return new CodexAppServerClient(createWebSocketTransport(startOptions));
|
|
3367
|
+
let client;
|
|
3368
|
+
try {
|
|
3369
|
+
await createStdioTransport(startOptions, process.env, assertCurrent, (child) => {
|
|
3370
|
+
client = new CodexAppServerClient(child);
|
|
3371
|
+
});
|
|
3372
|
+
return client;
|
|
3373
|
+
} catch (error) {
|
|
3374
|
+
assertCurrent?.();
|
|
3375
|
+
if (client?.transportExited && hasCodexAppServerNaturalExit(client.child)) throw buildCodexAppServerExitError(client.child.exitCode, client.child.signalCode, client.stderrTail);
|
|
3376
|
+
const stderr = client?.getStderrDiagnostic();
|
|
3377
|
+
throw stderr ? new Error(`${coerceErrorMessage(error)}; stderr=${JSON.stringify(stderr)}`, { cause: error }) : error;
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
/** Builds a client around a fake transport for tests. */
|
|
3381
|
+
static fromTransportForTests(child) {
|
|
3382
|
+
return new CodexAppServerClient(child);
|
|
3383
|
+
}
|
|
3384
|
+
/** Performs the app-server initialize handshake and validates protocol version. */
|
|
3385
|
+
async initialize() {
|
|
3386
|
+
if (this.initialized) return;
|
|
3387
|
+
const response = await this.request("initialize", {
|
|
3388
|
+
clientInfo: {
|
|
3389
|
+
name: "openclaw",
|
|
3390
|
+
title: "OpenClaw",
|
|
3391
|
+
version: OPENCLAW_VERSION
|
|
3392
|
+
},
|
|
3393
|
+
capabilities: {
|
|
3394
|
+
experimentalApi: true,
|
|
3395
|
+
extensions: {
|
|
3396
|
+
"openai/standard-form-input": {},
|
|
3397
|
+
"openai/form": {},
|
|
3398
|
+
"io.modelcontextprotocol/ui": { mimeTypes: ["text/html;profile=mcp-app"] }
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
});
|
|
3402
|
+
this.serverVersion = assertSupportedCodexAppServerVersion(response);
|
|
3403
|
+
this.runtimeIdentity = buildCodexAppServerRuntimeIdentity(response, this.serverVersion);
|
|
3404
|
+
this.notify("initialized");
|
|
3405
|
+
this.initialized = true;
|
|
3406
|
+
}
|
|
3407
|
+
/** Returns the version detected during initialize. */
|
|
3408
|
+
getServerVersion() {
|
|
3409
|
+
return this.serverVersion;
|
|
3410
|
+
}
|
|
3411
|
+
/** Returns runtime metadata detected during initialize. */
|
|
3412
|
+
getRuntimeIdentity() {
|
|
3413
|
+
return this.runtimeIdentity ? { ...this.runtimeIdentity } : void 0;
|
|
3414
|
+
}
|
|
3415
|
+
/** Returns a bounded, redacted stderr diagnostic from the app-server process. */
|
|
3416
|
+
getStderrDiagnostic() {
|
|
3417
|
+
return redactCodexAppServerLinePreview(this.stderrTail) || void 0;
|
|
3418
|
+
}
|
|
3419
|
+
/** Returns the terminal transport error that closed this physical client. */
|
|
3420
|
+
getCloseError() {
|
|
3421
|
+
return this.closeError;
|
|
3422
|
+
}
|
|
3423
|
+
/** Stable generation id for this exact physical client instance. */
|
|
3424
|
+
getInstanceId() {
|
|
3425
|
+
return this.instanceId;
|
|
3426
|
+
}
|
|
3427
|
+
/** Account/config observations become stale before a mutation can enter the wire. */
|
|
3428
|
+
getModelCatalogRevision() {
|
|
3429
|
+
return this.modelCatalogRevision;
|
|
3430
|
+
}
|
|
3431
|
+
/** Installs the spawn-owner check run before config-loading thread requests. */
|
|
3432
|
+
setThreadSessionRequestGuard(guard) {
|
|
3433
|
+
this.threadSessionRequestGuard = guard;
|
|
3434
|
+
}
|
|
3435
|
+
/** Returns the local transport PID for scoped child-process cleanup, when available. */
|
|
3436
|
+
getTransportPid() {
|
|
3437
|
+
return this.child.pid;
|
|
3438
|
+
}
|
|
3439
|
+
request(method, params, optionsInput) {
|
|
3440
|
+
const options = optionsInput ?? {};
|
|
3441
|
+
if (this.closed) return Promise.reject(this.closeError ?? /* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
3442
|
+
if (options.signal?.aborted) return Promise.reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3443
|
+
const guard = method === "thread/start" || method === "thread/resume" || method === "thread/fork" ? this.threadSessionRequestGuard : void 0;
|
|
3444
|
+
if (guard) {
|
|
3445
|
+
if (!options.signal && !(options.timeoutMs !== void 0 && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0)) return Promise.reject(/* @__PURE__ */ new TypeError(`${method} requires a positive finite timeout or abort signal`));
|
|
3446
|
+
return (async () => {
|
|
3447
|
+
const guardStartedAt = Date.now();
|
|
3448
|
+
const timeoutMessage = `${method} timed out`;
|
|
3449
|
+
const abortMessage = `${method} aborted`;
|
|
3450
|
+
let releaseGuard;
|
|
3451
|
+
try {
|
|
3452
|
+
releaseGuard = await guard({
|
|
3453
|
+
signal: options.signal,
|
|
3454
|
+
timeoutMs: options.timeoutMs,
|
|
3455
|
+
timeoutMessage,
|
|
3456
|
+
abortMessage
|
|
3457
|
+
});
|
|
3458
|
+
} catch (error) {
|
|
3459
|
+
if (error instanceof Error && error.message === timeoutMessage) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3460
|
+
if (error instanceof Error && error.message === abortMessage) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false);
|
|
3461
|
+
throw error;
|
|
3462
|
+
}
|
|
3463
|
+
let released = false;
|
|
3464
|
+
const release = () => {
|
|
3465
|
+
if (released) return;
|
|
3466
|
+
released = true;
|
|
3467
|
+
releaseGuard();
|
|
3468
|
+
};
|
|
3469
|
+
let releaseWhenRequestSettles = true;
|
|
3470
|
+
let requestMayHaveWritten = false;
|
|
3471
|
+
try {
|
|
3472
|
+
const elapsedMs = Date.now() - guardStartedAt;
|
|
3473
|
+
const remainingTimeoutMs = options.timeoutMs === void 0 ? void 0 : options.timeoutMs - elapsedMs;
|
|
3474
|
+
if (remainingTimeoutMs !== void 0 && remainingTimeoutMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3475
|
+
return await this.requestWithOverloadRetry(method, params, {
|
|
3476
|
+
...options,
|
|
3477
|
+
...remainingTimeoutMs !== void 0 ? { timeoutMs: remainingTimeoutMs } : {}
|
|
3478
|
+
}, (mayHaveWritten) => {
|
|
3479
|
+
requestMayHaveWritten = mayHaveWritten;
|
|
3480
|
+
});
|
|
3481
|
+
} catch (error) {
|
|
3482
|
+
if (requestMayHaveWritten && !(error instanceof CodexAppServerRpcError)) {
|
|
3483
|
+
releaseWhenRequestSettles = false;
|
|
3484
|
+
await this.closeAndRunAfterExit(release, method);
|
|
3485
|
+
}
|
|
3486
|
+
throw error;
|
|
3487
|
+
} finally {
|
|
3488
|
+
if (releaseWhenRequestSettles) release();
|
|
3489
|
+
}
|
|
3490
|
+
})();
|
|
3491
|
+
}
|
|
3492
|
+
return this.requestWithOverloadRetry(method, params, options);
|
|
3493
|
+
}
|
|
3494
|
+
async requestWithOverloadRetry(method, params, options, onWriteStateChange) {
|
|
3495
|
+
const deadline = options.timeoutMs !== void 0 && Number.isFinite(options.timeoutMs) ? Date.now() + options.timeoutMs : void 0;
|
|
3496
|
+
for (let retry = 0;; retry += 1) {
|
|
3497
|
+
if (options.signal?.aborted) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false);
|
|
3498
|
+
const remainingTimeoutMs = deadline === void 0 ? void 0 : deadline - Date.now();
|
|
3499
|
+
if (remainingTimeoutMs !== void 0 && remainingTimeoutMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3500
|
+
try {
|
|
3501
|
+
return await this.requestOnce(method, params, {
|
|
3502
|
+
...options,
|
|
3503
|
+
...remainingTimeoutMs !== void 0 ? { timeoutMs: remainingTimeoutMs } : {}
|
|
3504
|
+
}, onWriteStateChange);
|
|
3505
|
+
} catch (error) {
|
|
3506
|
+
if (!isCodexAppServerOverloadError(error) || retry >= CODEX_APP_SERVER_OVERLOAD_MAX_RETRIES) throw error;
|
|
3507
|
+
onWriteStateChange?.(false);
|
|
3508
|
+
const backoffMs = Math.round(CODEX_APP_SERVER_OVERLOAD_RETRY_BASE_MS * 2 ** retry * (.75 + Math.random() * .5));
|
|
3509
|
+
await this.waitForOverloadRetry(method, backoffMs, deadline, options.signal);
|
|
3510
|
+
}
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
async waitForOverloadRetry(method, backoffMs, deadline, signal) {
|
|
3514
|
+
if (signal?.aborted) throw new CodexAppServerLocalRequestCancellationError(method, "aborted", false);
|
|
3515
|
+
const remainingMs = deadline === void 0 ? void 0 : deadline - Date.now();
|
|
3516
|
+
if (remainingMs !== void 0 && remainingMs <= 0) throw new CodexAppServerLocalRequestCancellationError(method, "timed out", false);
|
|
3517
|
+
const delayMs = remainingMs === void 0 ? backoffMs : Math.min(backoffMs, remainingMs);
|
|
3518
|
+
await new Promise((resolve, reject) => {
|
|
3519
|
+
const timer = setTimeout(() => {
|
|
3520
|
+
cleanup();
|
|
3521
|
+
resolve();
|
|
3522
|
+
}, delayMs);
|
|
3523
|
+
timer.unref?.();
|
|
3524
|
+
const abortListener = () => {
|
|
3525
|
+
cleanup();
|
|
3526
|
+
reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3527
|
+
};
|
|
3528
|
+
const cleanup = () => {
|
|
3529
|
+
clearTimeout(timer);
|
|
3530
|
+
signal?.removeEventListener("abort", abortListener);
|
|
3531
|
+
};
|
|
3532
|
+
signal?.addEventListener("abort", abortListener, { once: true });
|
|
3533
|
+
if (signal?.aborted) abortListener();
|
|
3534
|
+
});
|
|
3535
|
+
}
|
|
3536
|
+
requestOnce(method, params, options, onWriteStateChange) {
|
|
3537
|
+
if (this.closed) return Promise.reject(this.closeError ?? /* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
3538
|
+
if (options.signal?.aborted) return Promise.reject(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3539
|
+
const id = this.nextId++;
|
|
3540
|
+
if (method === "account/login/start" || method === "account/logout" || method === "config/value/write" || method === "config/batchWrite") this.modelCatalogRevision += 1;
|
|
3541
|
+
const message = {
|
|
3542
|
+
id,
|
|
3543
|
+
method,
|
|
3544
|
+
params
|
|
3545
|
+
};
|
|
3546
|
+
return new Promise((resolve, reject) => {
|
|
3547
|
+
let timeout;
|
|
3548
|
+
let cleanupAbort;
|
|
3549
|
+
let mayHaveWritten = false;
|
|
3550
|
+
const cleanup = () => {
|
|
3551
|
+
if (timeout) {
|
|
3552
|
+
clearTimeout(timeout);
|
|
3553
|
+
timeout = void 0;
|
|
3554
|
+
}
|
|
3555
|
+
cleanupAbort?.();
|
|
3556
|
+
cleanupAbort = void 0;
|
|
3557
|
+
};
|
|
3558
|
+
const rejectPending = (error) => {
|
|
3559
|
+
if (!this.pending.has(id)) return;
|
|
3560
|
+
this.pending.delete(id);
|
|
3561
|
+
cleanup();
|
|
3562
|
+
reject(mayHaveWritten && !(error instanceof CodexAppServerRpcError) && !isCodexAppServerIndeterminateRequestCancellationError(error) && !isCodexAppServerIndeterminateTransportError(error) ? new CodexAppServerIndeterminateTransportError(method, error) : error);
|
|
3563
|
+
};
|
|
3564
|
+
if (options.timeoutMs && Number.isFinite(options.timeoutMs) && options.timeoutMs > 0) {
|
|
3565
|
+
timeout = setTimeout(() => rejectPending(new CodexAppServerLocalRequestCancellationError(method, "timed out", mayHaveWritten)), Math.max(100, options.timeoutMs));
|
|
3566
|
+
timeout.unref?.();
|
|
3567
|
+
}
|
|
3568
|
+
if (options.signal) {
|
|
3569
|
+
const abortListener = () => rejectPending(new CodexAppServerLocalRequestCancellationError(method, "aborted", mayHaveWritten));
|
|
3570
|
+
options.signal.addEventListener("abort", abortListener, { once: true });
|
|
3571
|
+
cleanupAbort = () => options.signal?.removeEventListener("abort", abortListener);
|
|
3572
|
+
}
|
|
3573
|
+
this.pending.set(id, {
|
|
3574
|
+
method,
|
|
3575
|
+
resolve: (value) => {
|
|
3576
|
+
cleanup();
|
|
3577
|
+
resolve(value);
|
|
3578
|
+
},
|
|
3579
|
+
reject: (error) => {
|
|
3580
|
+
cleanup();
|
|
3581
|
+
reject(mayHaveWritten && !(error instanceof CodexAppServerRpcError) && !isCodexAppServerIndeterminateRequestCancellationError(error) && !isCodexAppServerIndeterminateTransportError(error) ? new CodexAppServerIndeterminateTransportError(method, error) : error);
|
|
3582
|
+
},
|
|
3583
|
+
cleanup
|
|
3584
|
+
});
|
|
3585
|
+
if (options.signal?.aborted) {
|
|
3586
|
+
rejectPending(new CodexAppServerLocalRequestCancellationError(method, "aborted", false));
|
|
3587
|
+
return;
|
|
3588
|
+
}
|
|
3589
|
+
try {
|
|
3590
|
+
options.assertCurrent?.();
|
|
3591
|
+
this.writeMessage(message, (error) => rejectPending(error), () => {
|
|
3592
|
+
mayHaveWritten = true;
|
|
3593
|
+
onWriteStateChange?.(true);
|
|
3594
|
+
});
|
|
3595
|
+
} catch (error) {
|
|
3596
|
+
rejectPending(toStringifiedError(error));
|
|
3597
|
+
}
|
|
3598
|
+
});
|
|
3599
|
+
}
|
|
3600
|
+
/** Sends a fire-and-forget JSON-RPC notification to the app-server. */
|
|
3601
|
+
notify(method, params) {
|
|
3602
|
+
this.writeMessage({
|
|
3603
|
+
method,
|
|
3604
|
+
params
|
|
3605
|
+
});
|
|
3606
|
+
}
|
|
3607
|
+
/** Registers a handler for app-server requests sent back to OpenClaw. */
|
|
3608
|
+
addRequestHandler(handler) {
|
|
3609
|
+
this.requestHandlers.add(handler);
|
|
3610
|
+
return () => this.requestHandlers.delete(handler);
|
|
3611
|
+
}
|
|
3612
|
+
/** Registers a notification handler and returns its disposer. */
|
|
3613
|
+
addNotificationHandler(handler) {
|
|
3614
|
+
this.notificationHandlers.add(handler);
|
|
3615
|
+
for (const notification of this.pendingStartupWarnings.splice(0)) this.handleNotification(notification);
|
|
3616
|
+
return () => this.notificationHandlers.delete(handler);
|
|
3617
|
+
}
|
|
3618
|
+
/** Registers a close handler and returns its disposer. */
|
|
3619
|
+
addCloseHandler(handler) {
|
|
3620
|
+
this.closeHandlers.add(handler);
|
|
3621
|
+
return () => this.closeHandlers.delete(handler);
|
|
3622
|
+
}
|
|
3623
|
+
/** Registers a handler for physical transport exit and returns its disposer. */
|
|
3624
|
+
addTransportExitHandler(handler) {
|
|
3625
|
+
if (this.transportExited) {
|
|
3626
|
+
handler(this);
|
|
3627
|
+
return () => void 0;
|
|
3628
|
+
}
|
|
3629
|
+
const onExit = () => handler(this);
|
|
3630
|
+
this.child.once("exit", onExit);
|
|
3631
|
+
return () => this.child.off?.("exit", onExit);
|
|
3632
|
+
}
|
|
3633
|
+
/** Closes the transport without waiting for process/socket shutdown. */
|
|
3634
|
+
close() {
|
|
3635
|
+
if (!this.markClosed(/* @__PURE__ */ new Error("codex app-server client is closed"))) return;
|
|
3636
|
+
closeCodexAppServerTransport(this.child);
|
|
3637
|
+
}
|
|
3638
|
+
/** Closes the transport and waits for shutdown according to transport policy. */
|
|
3639
|
+
async closeAndWait(options) {
|
|
3640
|
+
this.markClosed(/* @__PURE__ */ new Error("codex app-server client is closed"));
|
|
3641
|
+
const result = await closeCodexAppServerTransportAndWait(this.child, options);
|
|
3642
|
+
return this.nativeExecutionObserved ? {
|
|
3643
|
+
...result,
|
|
3644
|
+
cleanup: "uncertain"
|
|
3645
|
+
} : result;
|
|
3646
|
+
}
|
|
3647
|
+
/** Closes this transport and runs cleanup only after physical process exit. */
|
|
3648
|
+
async closeAndRunAfterExit(onExit, operation) {
|
|
3649
|
+
let settled = false;
|
|
3650
|
+
const runOnExit = () => {
|
|
3651
|
+
if (settled) return;
|
|
3652
|
+
settled = true;
|
|
3653
|
+
onExit();
|
|
3654
|
+
};
|
|
3655
|
+
if (this.transportExited) {
|
|
3656
|
+
runOnExit();
|
|
3657
|
+
return;
|
|
3658
|
+
}
|
|
3659
|
+
this.child.once("exit", runOnExit);
|
|
3660
|
+
try {
|
|
3661
|
+
await this.closeAndWait();
|
|
3662
|
+
} catch (closeError) {
|
|
3663
|
+
embeddedAgentLog.warn("codex app-server shutdown after indeterminate request failed", {
|
|
3664
|
+
closeError,
|
|
3665
|
+
operation
|
|
3666
|
+
});
|
|
3667
|
+
}
|
|
3668
|
+
}
|
|
3669
|
+
writeMessage(message, onError, beforeWrite) {
|
|
3670
|
+
if (this.closed) return;
|
|
3671
|
+
const id = "id" in message ? message.id : void 0;
|
|
3672
|
+
const method = "method" in message ? message.method : void 0;
|
|
3673
|
+
const frame = stringifyCodexAppServerMessage(message);
|
|
3674
|
+
if (this.child.maxFrameBytes && Buffer.byteLength(frame) > this.child.maxFrameBytes) throw new Error("Codex request exceeds the transport frame limit; reduce attached images or context.");
|
|
3675
|
+
beforeWrite?.();
|
|
3676
|
+
if (method === "command/exec") this.nativeExecutionObserved = true;
|
|
3677
|
+
this.child.stdin.write(`${frame}\n`, (error) => {
|
|
3678
|
+
if (error) {
|
|
3679
|
+
embeddedAgentLog.warn("codex app-server write failed", {
|
|
3680
|
+
error,
|
|
3681
|
+
id,
|
|
3682
|
+
method
|
|
3683
|
+
});
|
|
3684
|
+
onError?.(error);
|
|
3685
|
+
}
|
|
3686
|
+
});
|
|
3687
|
+
}
|
|
3688
|
+
handleLine(line) {
|
|
3689
|
+
const rawLine = line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
3690
|
+
if (this.pendingParse) {
|
|
3691
|
+
this.handlePendingParseLine(rawLine);
|
|
3692
|
+
return;
|
|
3693
|
+
}
|
|
3694
|
+
const trimmed = rawLine.trim();
|
|
3695
|
+
if (!trimmed) return;
|
|
3696
|
+
let parsed;
|
|
3697
|
+
try {
|
|
3698
|
+
parsed = JSON.parse(trimmed);
|
|
3699
|
+
} catch (error) {
|
|
3700
|
+
if (shouldBufferCodexAppServerParseFailure(trimmed, error)) {
|
|
3701
|
+
this.pendingParse = {
|
|
3702
|
+
text: trimmed,
|
|
3703
|
+
lineCount: 1,
|
|
3704
|
+
firstError: error
|
|
3705
|
+
};
|
|
3706
|
+
return;
|
|
3707
|
+
}
|
|
3708
|
+
logCodexAppServerParseFailure(trimmed, error, 1);
|
|
3709
|
+
return;
|
|
3710
|
+
}
|
|
3711
|
+
this.handleParsedMessage(parsed);
|
|
3712
|
+
}
|
|
3713
|
+
handlePendingParseLine(line) {
|
|
3714
|
+
const pending = this.pendingParse;
|
|
3715
|
+
if (!pending) return;
|
|
3716
|
+
const candidate = `${pending.text}\\n${line}`;
|
|
3717
|
+
let parsed;
|
|
3718
|
+
try {
|
|
3719
|
+
parsed = JSON.parse(candidate);
|
|
3720
|
+
} catch (error) {
|
|
3721
|
+
const lineCount = pending.lineCount + 1;
|
|
3722
|
+
if (shouldBufferCodexAppServerParseFailure(candidate.trim(), error) && candidate.length <= CODEX_APP_SERVER_PARSE_BUFFER_MAX && lineCount <= CODEX_APP_SERVER_PARSE_BUFFER_MAX_LINES) {
|
|
3723
|
+
this.pendingParse = {
|
|
3724
|
+
text: candidate,
|
|
3725
|
+
lineCount,
|
|
3726
|
+
firstError: pending.firstError
|
|
3727
|
+
};
|
|
3728
|
+
return;
|
|
3729
|
+
}
|
|
3730
|
+
this.pendingParse = void 0;
|
|
3731
|
+
logCodexAppServerParseFailure(candidate, error, lineCount);
|
|
3732
|
+
return;
|
|
3733
|
+
}
|
|
3734
|
+
this.pendingParse = void 0;
|
|
3735
|
+
this.handleParsedMessage(parsed);
|
|
3736
|
+
}
|
|
3737
|
+
handleParsedMessage(parsed) {
|
|
3738
|
+
if (!parsed || typeof parsed !== "object") return;
|
|
3739
|
+
const message = parsed;
|
|
3740
|
+
if (isRpcResponse(message)) {
|
|
3741
|
+
this.handleResponse(message);
|
|
3742
|
+
return;
|
|
3743
|
+
}
|
|
3744
|
+
if (!("method" in message)) return;
|
|
3745
|
+
if ("id" in message && message.id !== void 0) {
|
|
3746
|
+
this.handleServerRequest({
|
|
3747
|
+
id: message.id,
|
|
3748
|
+
method: message.method,
|
|
3749
|
+
params: message.params
|
|
3750
|
+
});
|
|
3751
|
+
return;
|
|
3752
|
+
}
|
|
3753
|
+
this.handleNotification({
|
|
3754
|
+
method: message.method,
|
|
3755
|
+
params: message.params
|
|
3756
|
+
});
|
|
3757
|
+
}
|
|
3758
|
+
handleResponse(response) {
|
|
3759
|
+
const pending = this.pending.get(response.id);
|
|
3760
|
+
if (!pending) return;
|
|
3761
|
+
this.pending.delete(response.id);
|
|
3762
|
+
if (response.error) {
|
|
3763
|
+
pending.reject(new CodexAppServerRpcError(response.error, pending.method));
|
|
3764
|
+
return;
|
|
3765
|
+
}
|
|
3766
|
+
if (pending.method === "thread/backgroundTerminals/list" && isJsonObject(response.result) && Array.isArray(response.result.data) && response.result.data.length > 0) this.nativeExecutionObserved = true;
|
|
3767
|
+
pending.resolve(response.result);
|
|
3768
|
+
}
|
|
3769
|
+
async handleServerRequest(request) {
|
|
3770
|
+
try {
|
|
3771
|
+
const result = await this.runServerRequestHandlers(request);
|
|
3772
|
+
if (result !== void 0) {
|
|
3773
|
+
this.writeMessage({
|
|
3774
|
+
id: request.id,
|
|
3775
|
+
result
|
|
3776
|
+
});
|
|
3777
|
+
return;
|
|
3778
|
+
}
|
|
3779
|
+
this.writeMessage({
|
|
3780
|
+
id: request.id,
|
|
3781
|
+
result: defaultServerRequestResponse(request)
|
|
3782
|
+
});
|
|
3783
|
+
} catch (error) {
|
|
3784
|
+
const message = coerceErrorMessage(error);
|
|
3785
|
+
embeddedAgentLog.warn("codex app-server server request handler failed", {
|
|
3786
|
+
id: request.id,
|
|
3787
|
+
method: request.method,
|
|
3788
|
+
error
|
|
3789
|
+
});
|
|
3790
|
+
this.writeMessage({
|
|
3791
|
+
id: request.id,
|
|
3792
|
+
error: {
|
|
3793
|
+
code: -32603,
|
|
3794
|
+
message
|
|
3795
|
+
}
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3798
|
+
}
|
|
3799
|
+
async runServerRequestHandlers(request) {
|
|
3800
|
+
const controller = new AbortController();
|
|
3801
|
+
if (request.method !== "item/tool/call") return await this.runServerRequestHandlersWithoutTimeout(request, controller.signal);
|
|
3802
|
+
const timeoutMs = resolveDynamicToolServerRequestTimeoutMs(readCodexDynamicToolCallParams(request.params));
|
|
3803
|
+
const timeoutResponse = timeoutServerRequestResponse(timeoutMs);
|
|
3804
|
+
let timeout;
|
|
3805
|
+
try {
|
|
3806
|
+
return await Promise.race([this.runServerRequestHandlersWithoutTimeout(request, controller.signal), new Promise((resolve) => {
|
|
3807
|
+
timeout = setTimeout(() => {
|
|
3808
|
+
embeddedAgentLog.warn("codex app-server server request timed out", {
|
|
3809
|
+
id: request.id,
|
|
3810
|
+
method: request.method,
|
|
3811
|
+
timeoutMs
|
|
3812
|
+
});
|
|
3813
|
+
controller.abort(/* @__PURE__ */ new Error("codex app-server server request timed out"));
|
|
3814
|
+
resolve(timeoutResponse);
|
|
3815
|
+
}, timeoutMs);
|
|
3816
|
+
timeout.unref?.();
|
|
3817
|
+
})]);
|
|
3818
|
+
} finally {
|
|
3819
|
+
if (timeout) clearTimeout(timeout);
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
async runServerRequestHandlersWithoutTimeout(request, signal) {
|
|
3823
|
+
for (const handler of this.requestHandlers) {
|
|
3824
|
+
if (signal.aborted) return;
|
|
3825
|
+
const result = await handler(request, signal);
|
|
3826
|
+
if (result !== void 0) return result;
|
|
3827
|
+
}
|
|
3828
|
+
}
|
|
3829
|
+
handleNotification(notification) {
|
|
3830
|
+
const params = notification.params;
|
|
3831
|
+
if (notification.method === "item/commandExecution/outputDelta" || notification.method === "item/commandExecution/terminalInteraction" || isJsonObject(params) && (isJsonObject(params.item) && params.item.type === "commandExecution" || isJsonObject(params.turn) && Array.isArray(params.turn.items) && params.turn.items.some((item) => isJsonObject(item) && item.type === "commandExecution"))) this.nativeExecutionObserved = true;
|
|
3832
|
+
if (notification.method === "account/updated") this.modelCatalogRevision += 1;
|
|
3833
|
+
if (this.notificationHandlers.size === 0 && notification.method === "configWarning") {
|
|
3834
|
+
if (this.pendingStartupWarnings.length === CODEX_APP_SERVER_PENDING_STARTUP_WARNINGS_MAX) this.pendingStartupWarnings.shift();
|
|
3835
|
+
this.pendingStartupWarnings.push(notification);
|
|
3836
|
+
return;
|
|
3837
|
+
}
|
|
3838
|
+
for (const handler of this.notificationHandlers) try {
|
|
3839
|
+
Promise.resolve(handler(notification)).catch((error) => {
|
|
3840
|
+
embeddedAgentLog.warn("codex app-server notification handler failed", { error });
|
|
3841
|
+
});
|
|
3842
|
+
} catch (error) {
|
|
3843
|
+
embeddedAgentLog.warn("codex app-server notification handler failed", { error });
|
|
3844
|
+
}
|
|
3845
|
+
}
|
|
3846
|
+
closeWithError(error) {
|
|
3847
|
+
if (this.markClosed(error)) closeCodexAppServerTransport(this.child);
|
|
3848
|
+
}
|
|
3849
|
+
markClosed(error) {
|
|
3850
|
+
if (this.closed) return false;
|
|
3851
|
+
this.closed = true;
|
|
3852
|
+
this.closeError = error;
|
|
3853
|
+
this.lines.close();
|
|
3854
|
+
this.rejectPendingRequests(error);
|
|
3855
|
+
return true;
|
|
3856
|
+
}
|
|
3857
|
+
rejectPendingRequests(error) {
|
|
3858
|
+
for (const pending of this.pending.values()) {
|
|
3859
|
+
pending.cleanup();
|
|
3860
|
+
pending.reject(error);
|
|
3861
|
+
}
|
|
3862
|
+
this.pending.clear();
|
|
3863
|
+
for (const handler of this.closeHandlers) try {
|
|
3864
|
+
handler(this);
|
|
3865
|
+
} catch (closeError) {
|
|
3866
|
+
embeddedAgentLog.warn("codex app-server close handler failed", { error: closeError });
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
};
|
|
3870
|
+
function defaultServerRequestResponse(request) {
|
|
3871
|
+
if (request.method === "item/tool/call") return {
|
|
3872
|
+
contentItems: [{
|
|
3873
|
+
type: "inputText",
|
|
3874
|
+
text: "OpenClaw did not register a handler for this app-server tool call."
|
|
3875
|
+
}],
|
|
3876
|
+
success: false
|
|
3877
|
+
};
|
|
3878
|
+
if (request.method === "item/commandExecution/requestApproval" || request.method === "item/fileChange/requestApproval") return { decision: "decline" };
|
|
3879
|
+
if (request.method === "item/permissions/requestApproval") return {
|
|
3880
|
+
permissions: {},
|
|
3881
|
+
scope: "turn"
|
|
3882
|
+
};
|
|
3883
|
+
if (request.method === "item/tool/requestUserInput") return { answers: {} };
|
|
3884
|
+
if (request.method === "mcpServer/elicitation/request") return createCodexElicitationResponse("decline", null, { message: "OpenClaw has no interactive handler for this elicitation." });
|
|
3885
|
+
return {};
|
|
3886
|
+
}
|
|
3887
|
+
function stringifyCodexAppServerMessage(message) {
|
|
3888
|
+
return JSON.stringify(message, (_key, value) => typeof value === "string" ? value.replace(UNPAIRED_SURROGATE_RE, "") : value) ?? "null";
|
|
3889
|
+
}
|
|
3890
|
+
function timeoutServerRequestResponse(timeoutMs) {
|
|
3891
|
+
return {
|
|
3892
|
+
contentItems: [{
|
|
3893
|
+
type: "inputText",
|
|
3894
|
+
text: `OpenClaw dynamic tool call timed out after ${timeoutMs}ms before sending a response to Codex.`
|
|
3895
|
+
}],
|
|
3896
|
+
success: false
|
|
3897
|
+
};
|
|
3898
|
+
}
|
|
3899
|
+
/** Raised when the initialize handshake detects an unsupported app-server version. */
|
|
3900
|
+
var CodexAppServerVersionError = class extends Error {
|
|
3901
|
+
constructor(detectedVersion) {
|
|
3902
|
+
const detected = detectedVersion ? `detected ${detectedVersion}` : "OpenClaw could not determine the running Codex version";
|
|
3903
|
+
super(`Codex app-server ${MIN_SUPPORTED_CODEX_APP_SERVER_VERSION} or newer is required, but ${detected}. Update the configured Codex app-server binary, or remove custom command overrides to use the managed binary.`);
|
|
3904
|
+
this.name = "CodexAppServerVersionError";
|
|
3905
|
+
this.detectedVersion = detectedVersion;
|
|
3906
|
+
}
|
|
3907
|
+
};
|
|
3908
|
+
function assertSupportedCodexAppServerVersion(response) {
|
|
3909
|
+
const detectedVersion = readCodexVersionFromUserAgent(response.userAgent);
|
|
3910
|
+
if (!detectedVersion) throw new CodexAppServerVersionError(detectedVersion);
|
|
3911
|
+
const detected = parse(detectedVersion);
|
|
3912
|
+
if (!detected || detected.compare("0.149.0") < 0) throw new CodexAppServerVersionError(detectedVersion);
|
|
3913
|
+
if (detected.compare("0.153.4") > 0) embeddedAgentLog.warn("codex app-server is newer than OpenClaw's managed runtime; continuing with normal startup validation", {
|
|
3914
|
+
detectedVersion,
|
|
3915
|
+
validatedVersion: CODEX_APP_SERVER_VERSION
|
|
3916
|
+
});
|
|
3917
|
+
return detectedVersion;
|
|
3918
|
+
}
|
|
3919
|
+
function isUnsupportedCodexAppServerVersionError(error) {
|
|
3920
|
+
return error instanceof CodexAppServerVersionError;
|
|
3921
|
+
}
|
|
3922
|
+
function buildCodexAppServerRuntimeIdentity(response, serverVersion) {
|
|
3923
|
+
const userAgent = normalizeOptionalString(response.userAgent);
|
|
3924
|
+
const codexHome = normalizeOptionalString(response.codexHome);
|
|
3925
|
+
const platformFamily = normalizeOptionalString(response.platformFamily);
|
|
3926
|
+
const platformOs = normalizeOptionalString(response.platformOs);
|
|
3927
|
+
return {
|
|
3928
|
+
serverVersion,
|
|
3929
|
+
...userAgent ? { userAgent } : {},
|
|
3930
|
+
...codexHome ? { codexHome } : {},
|
|
3931
|
+
...platformFamily ? { platformFamily } : {},
|
|
3932
|
+
...platformOs ? { platformOs } : {}
|
|
3933
|
+
};
|
|
3934
|
+
}
|
|
3935
|
+
/** Extracts the Codex version from the app-server initialize user-agent field. */
|
|
3936
|
+
function readCodexVersionFromUserAgent(userAgent) {
|
|
3937
|
+
return (userAgent?.match(/^[^/]+\/(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?)(?:[\s(]|$)/))?.[1];
|
|
3938
|
+
}
|
|
3939
|
+
function redactCodexAppServerLinePreview(value) {
|
|
3940
|
+
const redacted = value.replace(/\s+/g, " ").trim().replace(/(Bearer\s+)[A-Za-z0-9._~+/-]+/gi, "$1<redacted>").replace(/("(?:api_?key|authorization|token|access_token|refresh_token)"\s*:\s*")([^"]+)(")/gi, "$1<redacted>$3").replace(/\b([a-z0-9_]*(?:api_?key|authorization|access_token|refresh_token|token))(\s*=\s*)(["']?)[^\s"']+(\3)/gi, "$1$2$3<redacted>$4");
|
|
3941
|
+
return redacted.length > CODEX_APP_SERVER_PARSE_LOG_MAX ? `${truncateUtf16Safe(redacted, CODEX_APP_SERVER_PARSE_LOG_MAX)}...` : redacted;
|
|
3942
|
+
}
|
|
3943
|
+
function appendBoundedTail(current, next, maxLength) {
|
|
3944
|
+
const combined = `${current}${next}`;
|
|
3945
|
+
return combined.length > maxLength ? sliceUtf16Safe(combined, -maxLength) : combined;
|
|
3946
|
+
}
|
|
3947
|
+
function buildCodexAppServerExitError(code, signal, stderrTail) {
|
|
3948
|
+
const stderrPreview = redactCodexAppServerLinePreview(stderrTail);
|
|
3949
|
+
const suffix = stderrPreview ? ` stderr=${JSON.stringify(stderrPreview)}` : "";
|
|
3950
|
+
return /* @__PURE__ */ new Error(`codex app-server exited: code=${formatExitValue(code)} signal=${formatExitValue(signal)}${suffix}`);
|
|
3951
|
+
}
|
|
3952
|
+
function shouldBufferCodexAppServerParseFailure(value, error) {
|
|
3953
|
+
if (!value.startsWith("{") && !value.startsWith("[")) return false;
|
|
3954
|
+
const message = coerceErrorMessage(error);
|
|
3955
|
+
return message.includes("Unterminated string") || message.includes("Unexpected end of JSON input");
|
|
3956
|
+
}
|
|
3957
|
+
function logCodexAppServerParseFailure(value, error, fragmentCount) {
|
|
3958
|
+
const linePreview = redactCodexAppServerLinePreview(value);
|
|
3959
|
+
const suffix = fragmentCount > 1 ? ` fragments=${fragmentCount}` : "";
|
|
3960
|
+
embeddedAgentLog.warn("failed to parse codex app-server message", {
|
|
3961
|
+
error,
|
|
3962
|
+
errorMessage: coerceErrorMessage(error),
|
|
3963
|
+
fragmentCount,
|
|
3964
|
+
linePreview,
|
|
3965
|
+
consoleMessage: `failed to parse codex app-server message${suffix}: preview=${JSON.stringify(linePreview)}`
|
|
3966
|
+
});
|
|
3967
|
+
}
|
|
3968
|
+
const CODEX_APP_SERVER_APPROVAL_REQUEST_METHODS = /* @__PURE__ */ new Set([
|
|
3969
|
+
"item/commandExecution/requestApproval",
|
|
3970
|
+
"item/fileChange/requestApproval",
|
|
3971
|
+
"item/permissions/requestApproval"
|
|
3972
|
+
]);
|
|
3973
|
+
/** Returns true for app-server approval request methods OpenClaw can answer. */
|
|
3974
|
+
function isCodexAppServerApprovalRequest(method) {
|
|
3975
|
+
return CODEX_APP_SERVER_APPROVAL_REQUEST_METHODS.has(method);
|
|
3976
|
+
}
|
|
3977
|
+
function formatExitValue(value) {
|
|
3978
|
+
if (value === null || value === void 0) return "null";
|
|
3979
|
+
if (typeof value === "string" || typeof value === "number") return String(value);
|
|
3980
|
+
return "unknown";
|
|
3981
|
+
}
|
|
3982
|
+
//#endregion
|
|
3983
|
+
export { isMatchingDynamicToolTerminalDiagnostic as A, withDynamicToolTranscriptDetails as B, readCodexErrorNotification as C, handleDynamicToolCallWithTimeout as D, createCodexElicitationResponse as E, toCodexDynamicToolProgressResponse as F, toCodexDynamicToolProtocolResponse as I, resolveCodexToolAbortTerminalReason as L, resolveTerminalDynamicToolBatchAction as M, shouldBlockTerminalReleaseForNonTerminalDynamicToolResult as N, hasPendingDynamicToolTerminalDiagnostic as O, shouldReleaseTurnAfterTerminalDynamicTool as P, createFailedDynamicToolResponse as R, readCodexDynamicToolCallParams as S, readCodexTurnCompletedNotification as T, assertCodexThreadAcceptsDirectInput as _, isCodexAppServerBrokenPipeError as a, assertCodexThreadStartResponse as b, isCodexAppServerIndeterminateTransportError as c, isCodexAppServerRequestTimeoutError as d, isUnsupportedCodexAppServerVersionError as f, assertCodexPassiveTurnItems as g, assertCodexModelListResponse as h, isCodexAppServerApprovalRequest as i, resolveDynamicToolCallTimeoutMs as j, isDynamicToolTerminalDiagnosticEvent as k, isCodexAppServerOverloadError as l, CodexThreadDirectInputError as m, client_exports as n, isCodexAppServerConnectionClosedError as o, resolveCodexAppServerClientInstanceId as p, getCodexAppServerClientInstanceId as r, isCodexAppServerIndeterminateRequestCancellationError as s, CodexAppServerClient as t, isCodexAppServerPrewriteRequestCancellationError as u, assertCodexThreadForkResponse as v, readCodexTurn as w, assertCodexTurnStartResponse as x, assertCodexThreadResumeResponse as y, withDynamicToolExecutionState as z };
|