@archboard/codex-realtime-voice 0.5.0 → 0.6.0

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.
Files changed (34) hide show
  1. package/README.md +32 -41
  2. package/dist/browser.d.mts +1 -3
  3. package/dist/browser.mjs +67 -66
  4. package/dist/{contract-CDS04znV.d.mts → contract-B2ILifH5.d.mts} +3 -3
  5. package/dist/{contract-qg6q9-vH.d.mts → contract-CkitFygd.d.mts} +97 -3054
  6. package/dist/{contract-DkiXnfc8.d.mts → contract-D9_WuSxD.d.mts} +3 -3
  7. package/dist/contract.d.mts +1 -1
  8. package/dist/controllers.d.mts +221 -6
  9. package/dist/controllers.mjs +3 -3
  10. package/dist/{gateway-envelope-DRBUhFx9.d.mts → gateway-envelope-O67wCRD7.d.mts} +3 -2
  11. package/dist/{realtime-state-CTBmCjt1.mjs → gateway-envelope-jUP82Pq1.mjs} +71 -3
  12. package/dist/identity-capabilities-3Q_2tJiT.d.mts +147 -0
  13. package/dist/instructions-B-6HVmoD.mjs +1024 -0
  14. package/dist/{contract-JI3xv17m.d.mts → instructions-C6TkBWcp.d.mts} +14 -998
  15. package/dist/{model-DnitkA24.mjs → model-MSyAviwx.mjs} +1652 -85
  16. package/dist/react.d.mts +1 -1
  17. package/dist/{realtime-contract-wHmSyUIe.d.mts → realtime-contract-C-1bMn-F.d.mts} +1 -22
  18. package/dist/realtime.d.mts +2 -3
  19. package/dist/realtime.mjs +1 -3
  20. package/dist/runtime.d.mts +3 -18
  21. package/dist/runtime.mjs +2 -2
  22. package/dist/schemas.d.mts +3 -13
  23. package/dist/schemas.mjs +1 -1
  24. package/dist/server.d.mts +977 -217
  25. package/dist/server.mjs +17771 -10076
  26. package/dist/{snapshot-BCrCORmt.d.mts → snapshot-DCl2vsJl.d.mts} +9 -154
  27. package/dist/{transport-Bqb8KE5T.mjs → transport-DVUz3EK0.mjs} +17 -13
  28. package/package.json +1 -1
  29. package/dist/app-server-contract-D4E5bibD.mjs +0 -177
  30. package/dist/gateway-envelope-DXTRMB3q.mjs +0 -45
  31. package/dist/instructions-8ACs49yJ.mjs +0 -8980
  32. package/dist/media-state-CNkFo93s.d.mts +0 -215
  33. package/dist/realtime-contract-DwkCluo2.mjs +0 -1167
  34. package/dist/realtime-state-DT4uvrIV.d.mts +0 -16
package/dist/server.d.mts CHANGED
@@ -1,12 +1,13 @@
1
- import { A as ApprovalOwnerView, B as DynamicServerRequest, C as WorkbenchExecutionContext, G as SessionResponsePayloads, H as TransportServerRequest, K as SessionThreadItem, L as CODEX_SESSION_THREAD_SOURCE, M as CodexApprovalBroker, N as DeepReadonly, O as WorkbenchContextSource, P as ItemApprovalIdentity, R as CodexSession, S as WorkbenchContextCodec, T as CodexRealtimeAdapter, U as SessionQueuedSubmission, V as TransportServerNotification, W as SessionResponse, a as CodexWorkhorseOperations, c as CodexThreadLinkPort, d as ThreadLinkReasonCode, f as ThreadLinkSnapshot, g as CodexEpochStore, h as ValidDynamicToolResponseSchema, i as CoordinatorCallbacks, j as ApprovalState, k as WorkbenchVoicePolicy, l as ThreadLinkBindingSnapshot, m as UnknownDynamicToolResponseSchema, n as SpokenApprovalSnapshot, o as CodexWorkhorseQueue, p as ThreadLinkTarget, q as SessionTurn, r as CoordinatorCallbackDeliveryReason, s as CodexCoordinator, t as CodexSpokenApprovalGate, u as ThreadLinkCasToken, v as WorkbenchDynamicTools, w as WorkbenchOperation, x as VoiceAgentIdentity, y as WorkbenchInstructions, z as CodexTransport } from "./contract-JI3xv17m.mjs";
2
- import { B as ChildId, G as OperationId, J as ThreadId, M as IdentityAuthorities, P as LogicalToolCallCorrelation, R as BrowserCommandId, S as BrowserDynamicApproval, U as JsonRpcRequestId, Y as TurnId, _ as BrowserVoiceContext, a as BrowserContextDelivery, b as VoiceNarrative, c as BrowserOperationOutcome, d as BrowserSchemas, f as BrowserSettings, i as BrowserCommandLease, o as BrowserCoordinator, p as BrowserSnapshot, q as RealtimeSessionId, r as BrowserCommand, s as BrowserLogin, t as BrowserAccount, u as BrowserReadiness, v as BrowserWorkhorses, w as BrowserDynamicApprovalResponse, y as DeliveryOutcome, z as ChildEpoch } from "./snapshot-BCrCORmt.mjs";
3
- import { i as CodexServerNotificationParamsByMethod, r as CodexResponseByMethod } from "./contract-qg6q9-vH.mjs";
4
- import { f as RealtimeTranscriptRecord, t as AnswerSdp } from "./realtime-contract-wHmSyUIe.mjs";
5
- import { a as BrowserGatewaySnapshotMessage, i as BrowserGatewayMessage, n as BrowserGatewayCommandResult, t as BrowserGatewayAccountReadResult } from "./gateway-envelope-DRBUhFx9.mjs";
1
+ import { S as SessionThreadSource, _ as TransportServerNotification, a as ApprovalSettlement, b as SessionResponse, d as CodexSession, f as SessionNotificationHandler, g as DynamicServerRequest, h as CodexTransport, i as VoiceAgentIdentity, l as ThreadLinkReason$1, m as codexSessionThreadSource, n as WorkbenchInstructions, o as CodexApprovalBroker, p as SessionParams, t as WorkbenchDynamicTools, v as TransportServerRequest, x as SessionThread, y as SessionQueuedSubmission } from "./instructions-C6TkBWcp.mjs";
2
+ import { _ as RealtimeSessionId, c as BrowserCommandId, d as DynamicToolCallId, g as QueuedSubmissionId, h as OperationId, i as LogicalToolCallCorrelation, l as ChildEpoch, p as JsonRpcRequestId, s as ApprovalId, t as IdentityAuthorities, u as ChildId, v as ThreadId, y as TurnId } from "./identity-capabilities-3Q_2tJiT.mjs";
3
+ import { i as CodexThreadStatusType } from "./contract-CkitFygd.mjs";
4
+ import { f as DeliveryOutcome, g as BrowserDynamicApprovalResponse, m as BrowserDynamicApproval, n as BrowserCommand, p as VoiceNarrative, r as BrowserCommandLease, s as BrowserSnapshot } from "./snapshot-DCl2vsJl.mjs";
5
+ import { a as RealtimeCorrelationId, c as RealtimeSemanticEvent, f as RealtimeTranscriptRecord, i as RealtimeCorrelation, l as RealtimeServer, o as RealtimeItemId, r as CreateOfferSdp, t as AnswerSdp, u as RealtimeSessionId$1 } from "./realtime-contract-C-1bMn-F.mjs";
6
+ import { a as BrowserGatewaySnapshotMessage, i as BrowserGatewayMessage, n as BrowserGatewayCommandResult, t as BrowserGatewayAccountReadResult } from "./gateway-envelope-O67wCRD7.mjs";
6
7
  import { z } from "zod";
7
8
  import fs from "node:fs";
8
- import { Server } from "node:http";
9
9
  import { execFileSync } from "node:child_process";
10
+ import { Server } from "node:http";
10
11
  type CodexAmbientEnvironment = Readonly<Record<string, string | undefined>>;
11
12
  type CodexChildEnvironment = Readonly<Record<string, string>>;
12
13
  interface CodexChildEnvironmentInput {
@@ -21,7 +22,7 @@ interface CodexChildEnvironmentInput {
21
22
  /** Absolute directories that lead the resulting PATH, in the supplied order. */
22
23
  readonly pathPrefixes?: readonly string[] | undefined;
23
24
  }
24
- /** Which Codex executable `resolveCodexExecutable` proves. */
25
+ /** Which Codex executable to find and prove. */
25
26
  interface CodexExecutableOptions {
26
27
  /** An absolute path to prove in place of the installed `@openai/codex` package. */
27
28
  readonly executablePath?: string;
@@ -79,221 +80,983 @@ interface CodexProcessOptions extends Pick<CodexChildEnvironmentInput, "hostEnvi
79
80
  /** Secrets supplied by a caller are redacted before process diagnostics are retained. */
80
81
  readonly diagnosticSecrets?: readonly string[];
81
82
  }
82
- /** The schemas that project and parse the browser state. */
83
- type BrowserProjectionModel = Pick<BrowserSchemas, "BrowserSnapshotSchema" | "BrowserSpokenApprovalSchema">;
84
- interface CodexAccountProjectionInput {
85
- readonly kind: "codex_account_response";
86
- readonly response: CodexResponseByMethod["account/read"];
83
+ /** Domain snapshots arrive as complete replacements. The host owns their wording and meaning. */
84
+ interface WorkbenchContextSource {
85
+ readonly read: () => string;
86
+ readonly subscribe: (onChange: () => void, onError: (error: Error) => void) => () => void;
87
87
  }
88
- type BrowserAccountProjectionInput = CodexAccountProjectionInput | Extract<BrowserAccount, {
89
- readonly state: "unknown" | "signed_out" | "login_pending" | "failed";
90
- }>;
91
- type CodexThreadSettings = CodexServerNotificationParamsByMethod["thread/settings/updated"]["threadSettings"];
92
- interface CodexSettingsProjectionInput {
93
- readonly kind: "codex_thread_settings";
94
- readonly owner: BrowserSettings["owner"];
95
- readonly settings: Pick<CodexThreadSettings, "model" | "effort" | "serviceTier" | "approvalPolicy" | "approvalsReviewer" | "sandboxPolicy" | "activePermissionProfile">;
88
+ /** Speakable input is distinct from quiet application context. Neither grants execution authority. */
89
+ interface WorkbenchVoiceInput {
90
+ readonly text: string;
91
+ readonly channel: "speech" | "context";
92
+ }
93
+ /** How voice starts for a narrative, or for an ordinary session with null. */
94
+ interface WorkbenchVoicePolicy<Narrative = unknown> {
95
+ readonly start: (narrative: Narrative | null) => {
96
+ readonly prompt: string;
97
+ readonly suppressCoordinatorSpeech: boolean;
98
+ readonly delegationAckFiller: boolean;
99
+ };
100
+ readonly subscribe?: (narrative: Narrative | null, listener: (input: WorkbenchVoiceInput) => void) => () => void;
101
+ }
102
+ declare const CODEX_EPOCH_MANIFEST_SCHEMA: 1;
103
+ declare const EPOCH_OPERATION_STATUSES: readonly ["staged", "committed", "rolled_back", "inspect_only"];
104
+ declare const EPOCH_OPERATION_OUTCOMES: readonly ["pending", "delivered", "not_delivered", "outcome_unknown"];
105
+ type EpochOperationStatus = (typeof EPOCH_OPERATION_STATUSES)[number];
106
+ type EpochOperationOutcome = (typeof EPOCH_OPERATION_OUTCOMES)[number];
107
+ interface EpochOperationCorrelation {
108
+ readonly childId: ChildId;
109
+ readonly epoch: ChildEpoch;
110
+ readonly operationId: string;
96
111
  }
97
- /**
98
- * One authoritative queued submission, with the operation that queued
99
- * it when this workbench queued it.
100
- *
101
- * The queue port sets a submission's `clientUserMessageId` to the serialized
102
- * OperationId on every add it makes, so the composition root can recover the
103
- * operation from the authoritative list and hand it over here. A null operation
104
- * is a submission this workbench did not queue, and this chat has no authority to
105
- * reorder it.
106
- */
107
- interface CodexQueuedSubmissionProjectionInput extends Pick<SessionQueuedSubmission, "id" | "input"> {
108
- readonly operationId: OperationId | null;
112
+ interface EpochOperationDescriptor {
113
+ readonly id: string;
114
+ readonly kind: string;
115
+ readonly rpc: string | null;
109
116
  }
110
- interface CodexQueueProjectionInput {
111
- readonly kind: "codex_queue";
112
- readonly submissions: readonly CodexQueuedSubmissionProjectionInput[] | null;
117
+ interface EpochProvenance {
118
+ readonly childId: ChildId;
119
+ readonly epoch: ChildEpoch;
120
+ readonly threadId: ThreadId | null;
121
+ readonly turnId: TurnId | null;
122
+ readonly threadSource: string | null;
123
+ readonly workspaceRoot: string;
124
+ readonly instructionHash: string;
125
+ readonly manifestHash: string;
126
+ readonly confirmedAtMs: number | null;
127
+ }
128
+ interface EpochOperationRecord {
129
+ readonly correlation: EpochOperationCorrelation;
130
+ readonly operation: EpochOperationDescriptor;
131
+ readonly status: EpochOperationStatus;
132
+ readonly outcome: EpochOperationOutcome;
133
+ readonly provenance: EpochProvenance;
134
+ readonly reason: string | null;
135
+ readonly createdAtMs: number;
136
+ readonly updatedAtMs: number;
113
137
  }
114
- type SessionItem<Type extends SessionThreadItem["type"]> = Extract<SessionThreadItem, {
115
- readonly type: Type;
116
- }>;
117
- type TimelineSessionItem<Type extends SessionThreadItem["type"], Field extends keyof SessionItem<Type>> = DeepReadonly<Pick<SessionItem<Type>, Field>> & Readonly<Record<string, unknown>>;
118
- interface CodexTimelineUserMessageProjectionInput extends Readonly<Record<string, unknown>> {
119
- readonly kind: "user_message";
120
- readonly item: TimelineSessionItem<"userMessage", "type" | "id">;
121
- /** What the person said, bounded, with each non-text input named in brackets. */
122
- readonly text: string;
138
+ interface ActiveEpoch {
139
+ readonly childId: ChildId;
140
+ readonly epoch: ChildEpoch;
141
+ readonly operationId: string;
123
142
  }
124
- interface CodexTimelineAgentMessageProjectionInput extends Readonly<Record<string, unknown>> {
125
- readonly kind: "agent_message";
126
- readonly item: TimelineSessionItem<"agentMessage", "type" | "id" | "text">;
127
- }
128
- interface CodexTimelineToolProjectionInput extends Readonly<Record<string, unknown>> {
129
- readonly kind: "tool_call";
130
- readonly item: TimelineSessionItem<"mcpToolCall" | "dynamicToolCall", "type" | "id" | "tool" | "status" | "durationMs">;
131
- /** The MCP server, or the dynamic tool's namespace. */
132
- readonly server: string | null;
133
- /** The call's arguments as bounded compact JSON. */
134
- readonly arguments: string | null;
135
- /** Why the call failed, when it reported a failure. */
136
- readonly error: string | null;
137
- }
138
- interface CodexTimelineCommandProjectionInput extends Readonly<Record<string, unknown>> {
139
- readonly kind: "command_execution";
140
- readonly item: TimelineSessionItem<"commandExecution", "type" | "id" | "command" | "status" | "exitCode" | "durationMs">;
141
- /** The working directory, bounded; null when Codex reported none. */
142
- readonly cwd: string | null;
143
- /** The bounded tail of the aggregated output, and whether anything before it was cut. */
144
- readonly output: {
145
- readonly tail: string | null;
146
- readonly truncated: boolean;
143
+ interface EpochManifestPayload {
144
+ readonly schema: typeof CODEX_EPOCH_MANIFEST_SCHEMA;
145
+ readonly revision: number;
146
+ readonly activeEpoch: ActiveEpoch | null;
147
+ readonly records: readonly EpochOperationRecord[];
148
+ }
149
+ interface EpochManifest extends EpochManifestPayload {
150
+ readonly integrity: {
151
+ readonly algorithm: "sha256";
152
+ readonly digest: string;
147
153
  };
148
154
  }
149
- type CodexPatchChangeKind = SessionItem<"fileChange">["changes"][number]["kind"]["type"];
150
- /** One changed file, its diff reduced to line counts. */
151
- interface CodexTimelineFileChangeEntry extends Readonly<Record<string, unknown>> {
152
- readonly path: string;
153
- readonly kind: CodexPatchChangeKind;
154
- readonly movePath: string | null;
155
- readonly added: number;
156
- readonly removed: number;
157
- }
158
- interface CodexTimelineFileChangeProjectionInput extends Readonly<Record<string, unknown>> {
159
- readonly kind: "file_change";
160
- readonly item: TimelineSessionItem<"fileChange", "type" | "id" | "status">;
161
- readonly changes: readonly CodexTimelineFileChangeEntry[];
162
- readonly changesTruncated: boolean;
163
- }
164
- interface CodexTimelineWebSearchProjectionInput extends Readonly<Record<string, unknown>> {
165
- readonly kind: "web_search";
166
- readonly item: TimelineSessionItem<"webSearch", "type" | "id">;
167
- /** The bounded query, or null while Codex has not said what it searched for. */
168
- readonly query: string | null;
169
- }
170
- interface CodexTimelineCompactionProjectionInput extends Readonly<Record<string, unknown>> {
171
- readonly kind: "context_compaction";
172
- readonly item: TimelineSessionItem<"contextCompaction", "type" | "id">;
173
- }
174
- interface CodexTimelineReasoningProjectionInput extends Readonly<Record<string, unknown>> {
175
- readonly kind: "reasoning_summary";
176
- readonly item: TimelineSessionItem<"reasoning", "type" | "id">;
177
- /** The future owner chooses the bounded reasoning presentation from generated arrays. */
178
- readonly text: string;
155
+ interface EpochCasToken {
156
+ readonly revision: number;
157
+ readonly bytesHash: string | null;
179
158
  }
180
- interface CodexTimelinePlanProjectionInput extends Readonly<Record<string, unknown>> {
181
- readonly kind: "plan";
182
- readonly item: TimelineSessionItem<"plan", "type" | "id" | "text">;
183
- }
184
- type TimelineApprovalIdentity = DeepReadonly<Omit<ItemApprovalIdentity, "approvalId"> & {
185
- readonly approvalId: NonNullable<ItemApprovalIdentity["approvalId"]>;
186
- }> & Readonly<Record<string, unknown>>;
187
- interface CodexTimelineApprovalProjectionInput extends Readonly<Record<string, unknown>> {
188
- readonly kind: "approval_request";
189
- readonly identity: TimelineApprovalIdentity;
190
- readonly state: Extract<ApprovalState, "pending" | "settled" | "cancelled">;
191
- }
192
- /** Independent readonly owner presentation; the sole adapter chooses browser media arms. */
193
- type CodexTimelineItemProjectionInput = CodexTimelineUserMessageProjectionInput | CodexTimelineAgentMessageProjectionInput | CodexTimelineToolProjectionInput | CodexTimelineCommandProjectionInput | CodexTimelineFileChangeProjectionInput | CodexTimelineReasoningProjectionInput | CodexTimelinePlanProjectionInput | CodexTimelineWebSearchProjectionInput | CodexTimelineCompactionProjectionInput | CodexTimelineApprovalProjectionInput;
194
- interface CodexTimelineTurnPresentation extends Readonly<Record<string, unknown>> {
195
- readonly summary: string;
196
- readonly outputs: Readonly<{
197
- included: boolean;
198
- truncated: boolean;
199
- }>;
159
+ interface EpochSnapshot {
160
+ readonly manifest: EpochManifest;
161
+ readonly cas: EpochCasToken;
162
+ readonly manifestPath: string;
163
+ }
164
+ interface EpochStageInput {
165
+ readonly childId: ChildId;
166
+ readonly epoch: ChildEpoch;
167
+ readonly operationId: string;
168
+ readonly kind: string;
169
+ readonly rpc?: string | null;
170
+ readonly workspaceRoot: string;
171
+ readonly instructionHash: string;
172
+ readonly manifestHash: string;
173
+ readonly expected?: EpochCasToken;
174
+ }
175
+ interface EpochConfirmation {
176
+ readonly threadId?: ThreadId | null;
177
+ readonly turnId?: TurnId | null;
178
+ readonly threadSource?: string | null;
179
+ readonly confirmedAtMs?: number;
180
+ }
181
+ interface EpochTransaction {
182
+ readonly record: EpochOperationRecord;
183
+ readonly cas: EpochCasToken;
184
+ }
185
+ interface EpochExecutionRequest {
186
+ readonly childId: ChildId;
187
+ readonly epoch: ChildEpoch;
188
+ readonly operationId: string;
189
+ readonly threadId?: ThreadId | null;
190
+ }
191
+ interface EpochExecutionProof {
192
+ readonly record: EpochOperationRecord;
193
+ readonly manifestRevision: number;
200
194
  }
201
- type CodexTurnPlanUpdate = CodexServerNotificationParamsByMethod["turn/plan/updated"];
202
- /** The latest plan Codex published for one turn, bounded by the owner that holds it. */
203
- type CodexTimelinePlanInput = DeepReadonly<Pick<CodexTurnPlanUpdate, "explanation" | "plan">> & Readonly<Record<string, unknown>>;
204
- /** Why a turn failed, bounded. */
205
- interface CodexTimelineTurnErrorInput extends Readonly<Record<string, unknown>> {
195
+ interface CodexEpochStore {
196
+ readonly rootDirectory: string;
197
+ readonly manifestPath: string;
198
+ readonly snapshot: () => EpochSnapshot;
199
+ readonly stageEpoch: (input: EpochStageInput) => EpochTransaction;
200
+ readonly startEpoch: (input: EpochStageInput) => EpochOperationRecord;
201
+ readonly commitEpoch: (transaction: EpochTransaction, confirmation?: EpochConfirmation) => EpochOperationRecord;
202
+ readonly stageOperation: (input: EpochStageInput) => EpochTransaction;
203
+ readonly commitOperation: (transaction: EpochTransaction, confirmation?: EpochConfirmation) => EpochOperationRecord;
204
+ readonly rollbackOperation: (transaction: EpochTransaction, reason: string) => EpochOperationRecord;
205
+ readonly markOutcomeUnknown: (transaction: EpochTransaction, reason: string, confirmation?: EpochConfirmation) => EpochOperationRecord;
206
+ readonly confirmOutcome: (transaction: EpochTransaction, confirmation: EpochConfirmation) => EpochOperationRecord;
207
+ readonly assertCurrent: (request: EpochExecutionRequest) => EpochExecutionProof;
208
+ readonly canExecute: (request: EpochExecutionRequest) => boolean;
209
+ readonly close: () => void;
210
+ }
211
+ type ThreadLinkReason = ThreadLinkReason$1;
212
+ type ThreadLinkReasonCode = ThreadLinkReason;
213
+ type ThreadLinkStatus = SessionThread["status"]["type"];
214
+ type ThreadLinkSource = SessionThreadSource;
215
+ type ThreadLinkAllowedSource = Extract<ThreadLinkSource, "cli" | "vscode" | "exec" | "appServer">;
216
+ type ThreadLinkExecutableStatus = Exclude<ThreadLinkStatus, "notLoaded" | "systemError">;
217
+ type ThreadLinkCurrentEpoch = Pick<ActiveEpoch, "childId" | "epoch">;
218
+ /** A committed epoch record or a proof returned by `assertCurrent`. */
219
+ type ThreadLinkEpochProof = EpochOperationRecord | EpochExecutionProof;
220
+ /** The identity and durable ownership evidence captured by a thread link. */
221
+ interface ThreadLinkTarget {
222
+ readonly threadId: ThreadId;
223
+ readonly childId: ChildId | null;
224
+ readonly epoch: ChildEpoch | null;
225
+ readonly operationId?: string;
226
+ readonly provenance?: ThreadLinkEpochProof | null;
227
+ }
228
+ interface ThreadLinkObservation {
229
+ readonly persisted: boolean;
230
+ readonly persistedRows: number;
231
+ readonly loaded: boolean;
232
+ readonly loadedOccurrences: number;
233
+ readonly source: ThreadLinkSource;
234
+ readonly status: ThreadLinkStatus;
235
+ readonly canAcceptDirectInput: boolean | null;
236
+ }
237
+ interface ExecutableThreadLink {
238
+ readonly kind: "thread_link";
239
+ readonly state: "executable";
240
+ readonly childId: ChildId;
241
+ readonly epoch: ChildEpoch;
242
+ readonly threadId: ThreadId;
243
+ readonly source: ThreadLinkAllowedSource;
244
+ readonly status: ThreadLinkExecutableStatus;
245
+ readonly loaded: true;
246
+ readonly canAcceptDirectInput: true;
247
+ readonly reason: null;
248
+ }
249
+ interface InspectOnlyThreadLink {
250
+ readonly kind: "thread_link";
251
+ readonly state: "inspect_only";
252
+ readonly childId: null;
253
+ readonly epoch: null;
254
+ readonly threadId: ThreadId;
255
+ readonly source: ThreadLinkSource;
256
+ readonly status: ThreadLinkStatus;
257
+ readonly loaded: boolean;
258
+ /** False for every inspect-only link, including an observed null capability. */
259
+ readonly canAcceptDirectInput: false;
260
+ readonly reason: ThreadLinkReason;
261
+ }
262
+ type ThreadLink = ExecutableThreadLink | InspectOnlyThreadLink;
263
+ interface UnboundThreadLink {
264
+ readonly kind: "thread_link";
265
+ readonly state: "unbound";
266
+ readonly childId: null;
267
+ readonly epoch: null;
268
+ readonly threadId: null;
269
+ readonly source: null;
270
+ readonly status: "notLoaded";
271
+ readonly loaded: false;
272
+ readonly canAcceptDirectInput: false;
273
+ readonly reason: null;
274
+ }
275
+ type ThreadLinkSnapshot = ThreadLink | UnboundThreadLink;
276
+ interface ThreadLinkClassification {
277
+ readonly link: ThreadLink;
278
+ readonly thread: SessionThread | null;
279
+ readonly observation: ThreadLinkObservation;
280
+ readonly currentEpoch: ThreadLinkCurrentEpoch | null;
281
+ /** The matching proof read from the live durable epoch authority, if any. */
282
+ readonly proof: EpochExecutionProof | null;
283
+ }
284
+ interface ThreadLinkCasToken {
285
+ readonly revision: number;
286
+ readonly linkKey: string;
287
+ readonly childId: ChildId | null;
288
+ readonly epoch: ChildEpoch | null;
289
+ readonly threadId: ThreadId | null;
290
+ }
291
+ interface ThreadLinkBindingSnapshot {
292
+ readonly linkKey: string;
293
+ readonly revision: number;
294
+ readonly link: ThreadLinkSnapshot;
295
+ readonly cas: ThreadLinkCasToken;
296
+ }
297
+ /** Public CAS accepts only unbound or explicitly inspect-only links. */
298
+ type ThreadLinkNonExecutableSnapshot = InspectOnlyThreadLink | UnboundThreadLink;
299
+ interface ThreadLinkCompareAndSwapInput {
300
+ readonly linkKey: string;
301
+ readonly expected: ThreadLinkCasToken | null;
302
+ readonly next: ThreadLinkNonExecutableSnapshot;
303
+ }
304
+ interface ThreadLinkBindingStore {
305
+ readonly snapshot: (linkKey: string) => ThreadLinkBindingSnapshot;
306
+ readonly read: (linkKey: string) => ThreadLinkBindingSnapshot;
307
+ readonly compareAndSwap: (input: ThreadLinkCompareAndSwapInput) => ThreadLinkBindingSnapshot;
308
+ readonly clear: (linkKey: string, expected: ThreadLinkCasToken | null) => ThreadLinkBindingSnapshot;
309
+ }
310
+ interface CodexThreadLinkClassifier {
311
+ readonly classify: (target: ThreadLinkTarget) => Promise<ThreadLinkClassification>;
312
+ }
313
+ interface CodexThreadLinkPort extends CodexThreadLinkClassifier, ThreadLinkBindingStore {
314
+ /** Classify twice through the live authorities, then adopt the fresh result by CAS. */
315
+ readonly classifyAndBind: (linkKey: string, expected: ThreadLinkCasToken | null, target: ThreadLinkTarget) => Promise<ThreadLinkBindingSnapshot>;
316
+ }
317
+ /**
318
+ * What became of a thread given up: Codex's answer to its unsubscribe, or why the thread could not
319
+ * be read or unsubscribed. The thread keeps its rollout either way.
320
+ */
321
+ type ThreadUnload = {
322
+ readonly threadId: ThreadId;
323
+ readonly outcome: SessionResponse<"thread/unsubscribe">["status"];
324
+ } | {
325
+ readonly threadId: ThreadId;
326
+ readonly outcome: "failed";
206
327
  readonly message: string;
207
- readonly details: string | null;
208
- }
209
- interface CodexTimelineTurnProjectionInput extends Readonly<Record<string, unknown>> {
210
- /** Codex's own turn fields; `startedAt` and `completedAt` are Unix seconds. */
211
- readonly turn: DeepReadonly<Pick<SessionTurn, "id" | "status" | "startedAt" | "completedAt" | "durationMs">> & Readonly<Record<string, unknown>>;
212
- readonly items: readonly CodexTimelineItemProjectionInput[];
213
- readonly presentation: CodexTimelineTurnPresentation;
214
- readonly error: CodexTimelineTurnErrorInput | null;
215
- readonly plan: CodexTimelinePlanInput | null;
216
- }
217
- /** The thread's latest token usage, as Codex last reported it. */
218
- type CodexTimelineUsageInput = DeepReadonly<CodexServerNotificationParamsByMethod["thread/tokenUsage/updated"]["tokenUsage"]> & Readonly<Record<string, unknown>>;
219
- /** Readonly owner view of the timeline. */
220
- interface CodexTimelineProjectionInput extends Readonly<Record<string, unknown>> {
221
- readonly kind: "codex_timeline";
328
+ };
329
+ type CoordinatorStartResponse = SessionResponse<"thread/start">;
330
+ type CoordinatorApprovalPolicy = CoordinatorStartResponse["approvalPolicy"];
331
+ type CoordinatorApprovalsReviewer = CoordinatorStartResponse["approvalsReviewer"];
332
+ type CoordinatorSandboxPolicy = CoordinatorStartResponse["sandbox"];
333
+ type CoordinatorPermissionProfile = CoordinatorStartResponse["activePermissionProfile"];
334
+ interface CoordinatorConfiguredSettings {
335
+ readonly model: string;
336
+ readonly effort: string;
337
+ readonly serviceTier: "priority" | null;
338
+ }
339
+ interface CoordinatorEffectiveSettings {
340
+ readonly model: string;
341
+ readonly effort: CoordinatorStartResponse["reasoningEffort"];
342
+ readonly serviceTier: string | null;
343
+ }
344
+ /** Settings are server facts, not a second mutable settings authority. */
345
+ interface CoordinatorSettings {
346
+ readonly configured: CoordinatorConfiguredSettings;
347
+ readonly effective: CoordinatorEffectiveSettings;
348
+ readonly approvalPolicy: CoordinatorApprovalPolicy;
349
+ readonly approvalsReviewer: CoordinatorApprovalsReviewer;
350
+ readonly sandboxPolicy: CoordinatorSandboxPolicy;
351
+ readonly activePermissionProfile: CoordinatorPermissionProfile;
352
+ }
353
+ interface CoordinatorReviewHashes {
354
+ readonly instructionHash: string;
355
+ /** A stable digest over both reviewed dynamic-tool manifest digests. */
356
+ readonly catalogueHash: string;
357
+ readonly workhorseCatalogueHash: string;
358
+ readonly voiceCatalogueHash: string;
359
+ readonly settingsHash: string;
360
+ }
361
+ /** The serializable evidence the composition root may retain across reload. */
362
+ interface CoordinatorPersistedState {
363
+ readonly childId: ChildId;
364
+ readonly epoch: ChildEpoch;
365
+ readonly threadId: ThreadId;
366
+ readonly operationId: string;
367
+ readonly review: CoordinatorReviewHashes;
368
+ readonly settings: CoordinatorSettings;
369
+ }
370
+ type CoordinatorLifecycleState = "unbound" | "starting" | "ready" | "inspect_only" | "failed";
371
+ interface CoordinatorCapabilityPolicy {
372
+ readonly web: true;
373
+ readonly shell: true;
374
+ readonly repository: true;
375
+ readonly approvals: true;
376
+ readonly sustainedWork: "instruction_policy";
377
+ }
378
+ interface CoordinatorSnapshot {
379
+ readonly state: CoordinatorLifecycleState;
380
+ readonly threadId: ThreadId | null;
381
+ readonly childId: ChildId | null;
382
+ readonly epoch: ChildEpoch | null;
383
+ readonly operationId: string | null;
384
+ readonly configured: CoordinatorConfiguredSettings | null;
385
+ readonly effective: CoordinatorEffectiveSettings | null;
386
+ readonly approvalPolicy: CoordinatorApprovalPolicy | null;
387
+ readonly approvalsReviewer: CoordinatorApprovalsReviewer | null;
388
+ readonly sandboxPolicy: CoordinatorSandboxPolicy | null;
389
+ readonly activePermissionProfile: CoordinatorPermissionProfile | null;
390
+ readonly review: CoordinatorReviewHashes | null;
391
+ readonly capabilities: CoordinatorCapabilityPolicy;
392
+ readonly persistence: CoordinatorPersistedState | null;
393
+ readonly reason: string | null;
394
+ }
395
+ interface CoordinatorEnsureInput {
396
+ /** A fresh server-issued operation id is required for a new or replacement start. */
397
+ readonly operationId?: string;
398
+ /** Undefined uses the coordinator's current retained evidence; null clears it. */
399
+ readonly persisted?: CoordinatorPersistedState | null;
400
+ }
401
+ /** What became of the thread a replacement retired, once it was unsubscribed or could not be. */
402
+ type CoordinatorRetirement = ThreadUnload;
403
+ interface CoordinatorReplaceInput {
404
+ /** The fresh server-issued operation id the replacement start runs under. */
405
+ readonly operationId: string;
406
+ /**
407
+ * Told once what became of the retired thread, after its voice session closed and no turn runs
408
+ * on it. Never told when the replacement failed, because nothing was retired.
409
+ */
410
+ readonly onRetired: (retirement: CoordinatorRetirement) => void;
411
+ }
412
+ interface CodexCoordinator {
413
+ readonly ensure: (input?: CoordinatorEnsureInput) => Promise<CoordinatorSnapshot>;
414
+ /** Start a fresh coordinator in place of the current one, which stays until it is ready. */
415
+ readonly replace: (input: CoordinatorReplaceInput) => Promise<CoordinatorSnapshot>;
416
+ readonly snapshot: () => CoordinatorSnapshot;
417
+ readonly persisted: () => CoordinatorPersistedState | null;
418
+ readonly onNotification: (event: TransportServerNotification) => void;
419
+ }
420
+ /** The execution facts a thread reads; any other key is the host's own data, which these never are. */
421
+ declare const WorkbenchExecutionContextSchema: z.ZodObject<{
422
+ threadLink: z.ZodObject<{
423
+ state: z.ZodEnum<{
424
+ executable: "executable";
425
+ inspect_only: "inspect_only";
426
+ unbound: "unbound";
427
+ }>;
428
+ reason: z.ZodNullable<z.ZodEnum<{
429
+ direct_input_false: "direct_input_false";
430
+ direct_input_unknown: "direct_input_unknown";
431
+ prior_epoch: "prior_epoch";
432
+ stale_child: "stale_child";
433
+ thread_list_ambiguous: "thread_list_ambiguous";
434
+ thread_list_missing: "thread_list_missing";
435
+ thread_loaded_list_ambiguous: "thread_loaded_list_ambiguous";
436
+ thread_loaded_list_missing: "thread_loaded_list_missing";
437
+ thread_source_custom: "thread_source_custom";
438
+ thread_source_subagent: "thread_source_subagent";
439
+ thread_source_unknown: "thread_source_unknown";
440
+ thread_start_outcome_unknown: "thread_start_outcome_unknown";
441
+ thread_status_not_loaded: "thread_status_not_loaded";
442
+ thread_status_system_error: "thread_status_system_error";
443
+ unknown_provenance: "unknown_provenance";
444
+ }>>;
445
+ }, z.core.$strict>;
446
+ child: z.ZodObject<{
447
+ id: z.ZodString;
448
+ epoch: z.ZodString;
449
+ }, z.core.$strict>;
450
+ workhorse: z.ZodObject<{
451
+ threadId: z.ZodNullable<z.ZodString>;
452
+ turnId: z.ZodNullable<z.ZodString>;
453
+ }, z.core.$strict>;
454
+ coordinator: z.ZodObject<{
455
+ threadId: z.ZodNullable<z.ZodString>;
456
+ realtimeSessionId: z.ZodNullable<z.ZodString>;
457
+ }, z.core.$strict>;
458
+ brief: z.ZodObject<{
459
+ text: z.ZodString;
460
+ capturedAtMs: z.ZodNumber;
461
+ freshUntilMs: z.ZodNumber;
462
+ }, z.core.$strict>;
463
+ operation: z.ZodUnion<readonly [z.ZodObject<{
464
+ id: z.ZodNull;
465
+ kind: z.ZodNull;
466
+ rpc: z.ZodNull;
467
+ outcome: z.ZodNull;
468
+ }, z.core.$strict>, z.ZodObject<{
469
+ id: z.ZodString;
470
+ kind: z.ZodEnum<{
471
+ composer_message: "composer_message";
472
+ create_thread_initial_turn: "create_thread_initial_turn";
473
+ delegate_to_workhorse: "delegate_to_workhorse";
474
+ fork_thread_initial_turn: "fork_thread_initial_turn";
475
+ send_message_to_thread: "send_message_to_thread";
476
+ spoken_approval_classifier: "spoken_approval_classifier";
477
+ steer_workhorse: "steer_workhorse";
478
+ workhorse_outcome_report: "workhorse_outcome_report";
479
+ }>;
480
+ rpc: z.ZodEnum<{
481
+ "turn/start": "turn/start";
482
+ "turn/steer": "turn/steer";
483
+ }>;
484
+ outcome: z.ZodNullable<z.ZodEnum<{
485
+ delivered: "delivered";
486
+ not_delivered: "not_delivered";
487
+ outcome_unknown: "outcome_unknown";
488
+ }>>;
489
+ }, z.core.$strict>]>;
490
+ }, z.core.$strip>;
491
+ type WorkbenchExecutionContext = z.infer<typeof WorkbenchExecutionContextSchema>;
492
+ type WorkbenchOperation = WorkbenchExecutionContext["operation"];
493
+ /** The host owns wire conversion. Its payload never changes execution facts. */
494
+ interface WorkbenchContextCodec {
495
+ readonly key: string;
496
+ readonly turnTrigger: string;
497
+ readonly encode: (context: WorkbenchExecutionContext) => string;
498
+ }
499
+ /** The only queue operations exposed to workbench callers. */
500
+ declare const WORKHORSE_QUEUE_OPERATIONS: readonly ["list", "add", "update", "delete", "reorder", "start"];
501
+ type WorkhorseQueueOperation = (typeof WORKHORSE_QUEUE_OPERATIONS)[number];
502
+ type WorkhorseQueueMutation = Exclude<WorkhorseQueueOperation, "list">;
503
+ interface QueueListResult {
504
+ readonly operation: "list";
505
+ readonly queue: QueueSnapshot;
506
+ }
507
+ interface QueueEffectContext {
508
+ readonly operation: WorkhorseQueueMutation;
509
+ readonly target: SessionQueuedSubmission | null;
510
+ }
511
+ type QueueBeforeEffect = (context: QueueEffectContext) => void | Promise<void>;
512
+ interface QueueAddRequest<OperationIdValue extends string> {
513
+ readonly operationId: OperationIdValue;
514
+ readonly prompt: string;
515
+ readonly beforeEffect?: QueueBeforeEffect;
516
+ }
517
+ interface QueueUpdateRequest<OperationIdValue extends string> {
518
+ readonly operationId: OperationIdValue;
519
+ readonly submissionId: QueuedSubmissionId;
520
+ readonly prompt: string;
521
+ readonly beforeEffect?: QueueBeforeEffect;
522
+ }
523
+ interface QueueDeleteRequest<OperationIdValue extends string> {
524
+ readonly operationId: OperationIdValue;
525
+ readonly submissionId: QueuedSubmissionId;
526
+ readonly beforeEffect?: QueueBeforeEffect;
527
+ }
528
+ interface QueueReorderRequest<OperationIdValue extends string> {
529
+ readonly operationId: OperationIdValue;
530
+ readonly orderedSubmissionIds: readonly QueuedSubmissionId[];
531
+ readonly beforeEffect?: QueueBeforeEffect;
532
+ }
533
+ interface QueueStartRequest<OperationIdValue extends string> {
534
+ readonly operationId: OperationIdValue;
535
+ readonly submissionId: QueuedSubmissionId;
536
+ readonly beforeEffect?: QueueBeforeEffect;
537
+ }
538
+ type QueueSnapshot = readonly SessionQueuedSubmission[];
539
+ type QueueMutationOutcome = "delivered" | "not_delivered" | "outcome_unknown";
540
+ interface QueueMutationResult<Operation extends WorkhorseQueueMutation, OperationIdValue extends string> {
541
+ readonly operation: Operation;
542
+ readonly operationId: OperationIdValue;
543
+ readonly outcome: QueueMutationOutcome;
544
+ readonly queue: QueueSnapshot;
545
+ }
546
+ type QueueAddResult<OperationIdValue extends string> = QueueMutationResult<"add", OperationIdValue>;
547
+ type QueueUpdateResult<OperationIdValue extends string> = QueueMutationResult<"update", OperationIdValue>;
548
+ type QueueDeleteResult<OperationIdValue extends string> = QueueMutationResult<"delete", OperationIdValue>;
549
+ type QueueReorderResult<OperationIdValue extends string> = QueueMutationResult<"reorder", OperationIdValue>;
550
+ type QueueStartResult<OperationIdValue extends string> = QueueMutationResult<"start", OperationIdValue> & {
551
+ readonly clientUserMessageId: string;
552
+ readonly turnId: TurnId | null;
553
+ };
554
+ interface CodexWorkhorseQueue<OperationIdValue extends string> {
555
+ readonly list: () => Promise<QueueListResult>;
556
+ readonly add: (request: QueueAddRequest<OperationIdValue>) => Promise<QueueAddResult<OperationIdValue>>;
557
+ readonly update: (request: QueueUpdateRequest<OperationIdValue>) => Promise<QueueUpdateResult<OperationIdValue>>;
558
+ readonly delete: (request: QueueDeleteRequest<OperationIdValue>) => Promise<QueueDeleteResult<OperationIdValue>>;
559
+ readonly reorder: (request: QueueReorderRequest<OperationIdValue>) => Promise<QueueReorderResult<OperationIdValue>>;
560
+ readonly start: (request: QueueStartRequest<OperationIdValue>) => Promise<QueueStartResult<OperationIdValue>>;
561
+ /** Close admission and wait for every operation accepted before this call. */
562
+ readonly shutdown: () => Promise<void>;
563
+ }
564
+ /** The only four operations the coordinator may dispatch to its workhorse. */
565
+ declare const WORKHORSE_OPERATION_NAMES: readonly ["inspect_workhorse", "delegate_to_workhorse", "manage_workhorse_queue", "steer_workhorse"];
566
+ type WorkhorseOperationName = (typeof WORKHORSE_OPERATION_NAMES)[number];
567
+ type WorkhorseOperationRpc = "turn/start" | "turn/steer" | `thread/queue/${WorkhorseQueueMutation}`;
568
+ type WorkhorseOperationDelivery = "pending" | "delivered" | "not_delivered" | "outcome_unknown";
569
+ /** The coordinator call remains an exact, server-validated logical correlation. */
570
+ type WorkhorseCoordinatorCall = LogicalToolCallCorrelation;
571
+ interface InspectWorkhorseRequest {
572
+ readonly call: WorkhorseCoordinatorCall;
573
+ }
574
+ interface DelegateToWorkhorseRequest {
575
+ readonly call: WorkhorseCoordinatorCall;
576
+ /** Reuse this server-issued identity when the dispatcher already owns the effect. */
577
+ readonly operationId?: OperationId;
578
+ readonly input: string;
579
+ readonly transcriptDelta: string;
580
+ }
581
+ type ManageWorkhorseQueueMutationRequest = {
582
+ readonly operation: "add";
583
+ readonly prompt: string;
584
+ } | {
585
+ readonly operation: "update";
586
+ readonly submissionId: QueuedSubmissionId;
587
+ readonly prompt: string;
588
+ } | {
589
+ readonly operation: "delete";
590
+ readonly submissionId: QueuedSubmissionId;
591
+ } | {
592
+ readonly operation: "reorder";
593
+ readonly orderedSubmissionIds: readonly QueuedSubmissionId[];
594
+ } | {
595
+ readonly operation: "start";
596
+ readonly submissionId: QueuedSubmissionId;
597
+ };
598
+ type ManageWorkhorseQueueRequest = {
599
+ readonly call: WorkhorseCoordinatorCall;
600
+ readonly operation: "list";
601
+ } | (ManageWorkhorseQueueMutationRequest & {
602
+ readonly call: WorkhorseCoordinatorCall;
603
+ /** Reuse this server-issued identity when the dispatcher already owns the effect. */
604
+ readonly operationId?: OperationId;
605
+ });
606
+ interface SteerWorkhorseRequest {
607
+ readonly call: WorkhorseCoordinatorCall;
608
+ /** Reuse this server-issued identity when the dispatcher already owns the effect. */
609
+ readonly operationId?: OperationId;
610
+ readonly input: string;
611
+ }
612
+ /** What inspection read about a workhorse. An empty field means Codex reported nothing there. */
613
+ interface InspectWorkhorseResult {
222
614
  readonly threadId: ThreadId;
223
- readonly turns: readonly CodexTimelineTurnProjectionInput[];
224
- readonly cursor: SessionResponsePayloads["thread/timeline/list"]["nextCursor"];
225
- readonly usage: CodexTimelineUsageInput | null;
226
- }
227
- interface CodexContextDeliveryProjectionInput {
228
- readonly kind: "codex_context_delivery";
229
- readonly outcome: {
230
- readonly targetThreadId: BrowserContextDelivery["threadId"] | null;
231
- readonly outcome: BrowserContextDelivery["delivery"];
615
+ readonly status: CodexThreadStatusType;
616
+ /** The turn that runs now, as thread/turns/list names it, or null when none runs. */
617
+ readonly activeTurnId: TurnId | null;
618
+ /** The request that started the newest turn, or null when it carried no text. */
619
+ readonly request: string | null;
620
+ /** What the newest turn did last, oldest first. */
621
+ readonly recentProgress: readonly string[];
622
+ /** Every sub-agent the workhorse spawned, at any depth, with its status. */
623
+ readonly subAgents: readonly {
624
+ readonly threadId: ThreadId;
625
+ readonly status: CodexThreadStatusType;
626
+ }[];
627
+ readonly queuedSubmissionIds: readonly QueuedSubmissionId[];
628
+ /**
629
+ * Each read that failed, or that ownership did not allow, so its field above is empty for that
630
+ * reason and not because Codex reported nothing.
631
+ */
632
+ readonly unavailable: readonly ("turns" | "subAgents" | "queue")[];
633
+ }
634
+ interface DelegateToWorkhorseResult {
635
+ readonly mode: "started" | "queued";
636
+ readonly clientUserMessageId: string;
637
+ readonly queuedSubmissionId: QueuedSubmissionId | null;
638
+ readonly turnId: TurnId | null;
639
+ }
640
+ interface ManageWorkhorseQueueResult {
641
+ readonly operation: WorkhorseQueueOperation;
642
+ readonly queuedSubmissionIds: readonly QueuedSubmissionId[];
643
+ }
644
+ interface SteerWorkhorseResult {
645
+ readonly turnId: TurnId;
646
+ readonly delivery: Exclude<WorkhorseOperationDelivery, "pending">;
647
+ }
648
+ interface WorkhorseOperationCorrelation {
649
+ readonly operationId: OperationId;
650
+ readonly childId: ChildId;
651
+ readonly epoch: ChildEpoch;
652
+ readonly coordinatorThreadId: ThreadId;
653
+ readonly coordinatorTurnId: TurnId;
654
+ readonly workhorseThreadId: ThreadId;
655
+ readonly coordinatorCall: WorkhorseCoordinatorCall;
656
+ readonly clientUserMessageId: string | null;
657
+ readonly queuedSubmissionId: QueuedSubmissionId | null;
658
+ readonly turnId: TurnId | null;
659
+ }
660
+ interface WorkhorseOperationEventBase {
661
+ readonly operation: Exclude<WorkhorseOperationName, "inspect_workhorse">;
662
+ readonly queueOperation: WorkhorseQueueMutation | null;
663
+ readonly rpc: WorkhorseOperationRpc;
664
+ readonly correlation: WorkhorseOperationCorrelation;
665
+ readonly queuedSubmissionIds: readonly QueuedSubmissionId[];
666
+ readonly detail: string | null;
667
+ }
668
+ type WorkhorseOperationEvent = (WorkhorseOperationEventBase & {
669
+ readonly type: "accepted";
670
+ readonly outcome: "pending";
671
+ }) | (WorkhorseOperationEventBase & {
672
+ readonly type: "queued";
673
+ readonly outcome: "delivered";
674
+ }) | (WorkhorseOperationEventBase & {
675
+ readonly type: "started";
676
+ readonly outcome: "delivered";
677
+ }) | (WorkhorseOperationEventBase & {
678
+ readonly type: "progress";
679
+ readonly outcome: "delivered";
680
+ }) | (WorkhorseOperationEventBase & {
681
+ readonly type: "attention";
682
+ readonly outcome: "delivered";
683
+ }) | (WorkhorseOperationEventBase & {
684
+ readonly type: "completed";
685
+ readonly outcome: "delivered";
686
+ }) | (WorkhorseOperationEventBase & {
687
+ readonly type: "failed";
688
+ readonly outcome: "delivered" | "not_delivered";
689
+ }) | (WorkhorseOperationEventBase & {
690
+ readonly type: "outcome_unknown";
691
+ readonly outcome: "outcome_unknown";
692
+ });
693
+ type WorkhorseOperationEventListener = (event: WorkhorseOperationEvent) => void;
694
+ interface CodexWorkhorseOperations {
695
+ readonly inspect: (request: InspectWorkhorseRequest) => Promise<InspectWorkhorseResult>;
696
+ readonly delegate: (request: DelegateToWorkhorseRequest) => Promise<DelegateToWorkhorseResult>;
697
+ readonly manageQueue: (request: ManageWorkhorseQueueRequest) => Promise<ManageWorkhorseQueueResult>;
698
+ readonly steer: (request: SteerWorkhorseRequest) => Promise<SteerWorkhorseResult>;
699
+ /** Raw notifications are an input boundary only; no raw event leaves this port. */
700
+ readonly onNotification: (event: TransportServerNotification) => void;
701
+ readonly subscribe: (listener: WorkhorseOperationEventListener) => () => void;
702
+ }
703
+ /**
704
+ * One announced change for the coordinator or the voice of one tab session, under the execution
705
+ * identities the agent read when it was announced. The callbacks capture their own correlation;
706
+ * these identities only scope the change.
707
+ */
708
+ interface ContextAnnouncementSource {
709
+ readonly kind: "context";
710
+ readonly audience: "coordinator" | "voice";
711
+ readonly child: {
712
+ readonly id: ChildId | null;
713
+ readonly epoch: ChildEpoch | null;
714
+ };
715
+ readonly coordinator: {
716
+ readonly threadId: ThreadId | null;
717
+ readonly realtimeSessionId: RealtimeSessionId | null;
718
+ };
719
+ readonly workhorse: {
720
+ readonly threadId: ThreadId | null;
721
+ readonly turnId: TurnId | null;
722
+ };
723
+ readonly threadLink: {
724
+ readonly state: "executable" | "inspect_only" | "unbound";
232
725
  readonly reason: string | null;
233
- } | null;
726
+ };
727
+ readonly context: AnnouncedContext;
728
+ /**
729
+ * The thread that made the change, or null. A change this session's own workhorse or
730
+ * coordinator made is refused as `own_change` before delivery.
731
+ */
732
+ readonly author: string | null;
733
+ }
734
+ /**
735
+ * One event of the linked workhorse thread itself, whoever started the turn: a turn
736
+ * that ended, one that began waiting on the user, or a message the workhorse sent the coordinator.
737
+ */
738
+ interface WorkhorseNewsSource {
739
+ readonly kind: "workhorse_news";
740
+ readonly type: "completed" | "failed" | "stopped" | "waiting" | "message";
741
+ /** Counts news from one observer, so two waits in one turn are two pieces of news. */
742
+ readonly sequence: number;
743
+ readonly childId: ChildId;
744
+ readonly epoch: ChildEpoch;
745
+ readonly coordinatorThreadId: ThreadId;
746
+ readonly workhorseThreadId: ThreadId;
747
+ readonly turnId: TurnId | null;
748
+ /** What a failed turn's error said, or what the workhorse's message said; null otherwise. */
749
+ readonly detail: string | null;
750
+ }
751
+ type CoordinatorCallbackSource = WorkhorseOperationEvent | ContextAnnouncementSource | WorkhorseNewsSource;
752
+ interface CoordinatorCallbackLinkCorrelation {
753
+ readonly binding: ThreadLinkBindingSnapshot;
754
+ readonly target: ThreadLinkTarget;
755
+ /** The checkout the workhorse works in, which news of it names. */
756
+ readonly checkout: string;
757
+ }
758
+ interface CoordinatorCallbackCorrelation {
759
+ readonly operationId: OperationId | null;
760
+ readonly childId: ChildId | null;
761
+ readonly epoch: ChildEpoch | null;
762
+ readonly coordinatorThreadId: ThreadId | null;
763
+ readonly coordinatorTurnId: TurnId | null;
764
+ readonly workhorseThreadId: ThreadId | null;
765
+ readonly turnId: TurnId | null;
766
+ readonly queuedSubmissionId: QueuedSubmissionId | null;
767
+ readonly clientUserMessageId: string | null;
768
+ readonly realtimeSessionId: RealtimeSessionId | null;
769
+ readonly coordinatorCall: LogicalToolCallCorrelation | null;
770
+ readonly workhorseLink: CoordinatorCallbackLinkCorrelation;
771
+ readonly realtimeGeneration: CoordinatorCallbackRealtimeGeneration | null;
772
+ }
773
+ interface CoordinatorOperationCallbackBase {
774
+ readonly kind: "operation";
775
+ readonly operation: Exclude<WorkhorseOperationEvent["operation"], "inspect_workhorse">;
776
+ readonly queueOperation: WorkhorseOperationEvent["queueOperation"];
777
+ readonly rpc: WorkhorseOperationEvent["rpc"];
778
+ readonly correlation: CoordinatorCallbackCorrelation;
779
+ readonly queuedSubmissionIds: readonly QueuedSubmissionId[];
780
+ readonly detail: string | null;
781
+ }
782
+ type CoordinatorOperationCallback = (CoordinatorOperationCallbackBase & {
783
+ readonly type: "accepted";
784
+ readonly outcome: "pending";
785
+ }) | (CoordinatorOperationCallbackBase & {
786
+ readonly type: "queued";
787
+ readonly outcome: "delivered";
788
+ }) | (CoordinatorOperationCallbackBase & {
789
+ readonly type: "started";
790
+ readonly outcome: "delivered";
791
+ }) | (CoordinatorOperationCallbackBase & {
792
+ readonly type: "progress";
793
+ readonly outcome: "delivered";
794
+ }) | (CoordinatorOperationCallbackBase & {
795
+ readonly type: "attention";
796
+ readonly outcome: "delivered";
797
+ }) | (CoordinatorOperationCallbackBase & {
798
+ readonly type: "completed";
799
+ readonly outcome: "delivered";
800
+ }) | (CoordinatorOperationCallbackBase & {
801
+ readonly type: "failed";
802
+ readonly outcome: "delivered" | "not_delivered";
803
+ }) | (CoordinatorOperationCallbackBase & {
804
+ readonly type: "outcome_unknown";
805
+ readonly outcome: "outcome_unknown";
806
+ });
807
+ /**
808
+ * What a callback carries of one announced change: its identity, its freshness and the host's
809
+ * words. A change is identified by its feed and sequence; two with the same identity share one
810
+ * delivery.
811
+ */
812
+ interface AnnouncedContext {
813
+ /** The host feed the change belongs to. Changes of two feeds never coalesce. */
814
+ readonly feedId: string;
815
+ readonly sequence: number;
816
+ /** When the host captured the change; the delivery record's freshness starts here. */
817
+ readonly capturedAtMs: number;
818
+ /** Until when the change is fresh; the delivery record's freshness ends here. */
819
+ readonly freshUntilMs: number;
820
+ /** What the change is about: a later one of the same feed and topic replaces it while it waits. */
821
+ readonly topic: string | null;
822
+ /** The words to tell, or null when the host withheld them. */
823
+ readonly text: string | null;
824
+ /** Why the host told nothing, or null. */
825
+ readonly withheld: string | null;
826
+ /** Whether the voice answers the words now, rather than keeping them as quiet context. */
827
+ readonly speech: boolean;
828
+ }
829
+ /** One normalized announced change, delivered to the coordinator or to the voice. */
830
+ interface CoordinatorContextCallback {
831
+ readonly kind: "context";
832
+ readonly audience: ContextAnnouncementSource["audience"];
833
+ readonly correlation: CoordinatorCallbackCorrelation;
834
+ readonly threadLinkState: "executable" | "inspect_only" | "unbound";
835
+ readonly threadLinkReason: string | null;
836
+ readonly context: AnnouncedContext;
837
+ }
838
+ /** Workhorse news about the linked workhorse thread, as the coordinator is given it. */
839
+ interface CoordinatorWorkhorseNewsCallback {
840
+ readonly kind: "workhorse_news";
841
+ readonly type: WorkhorseNewsSource["type"];
842
+ readonly sequence: number;
843
+ readonly correlation: CoordinatorCallbackCorrelation;
844
+ readonly detail: string | null;
845
+ }
846
+ type CoordinatorCallback = CoordinatorOperationCallback | CoordinatorContextCallback | CoordinatorWorkhorseNewsCallback;
847
+ interface CoordinatorCallbackRealtimeGeneration {
848
+ readonly childId: ChildId;
849
+ readonly epoch: ChildEpoch;
850
+ readonly coordinatorThreadId: ThreadId;
851
+ readonly wireSessionId: RealtimeSessionId;
852
+ readonly browserSessionId: RealtimeSessionId$1;
853
+ readonly browserCorrelationId: RealtimeCorrelationId;
854
+ }
855
+ /**
856
+ * One append to the live voice session: quiet context the voice model may use, or speech it
857
+ * answers now. In a full-duplex session appended text is quiet whatever role it carries; only
858
+ * speakable text is something the voice model says.
859
+ */
860
+ type CoordinatorCallbackRealtimeRequest = {
861
+ readonly generation: CoordinatorCallbackRealtimeGeneration;
862
+ readonly channel: "context";
863
+ readonly params: SessionParams<"thread/realtime/appendText">;
864
+ } | {
865
+ readonly generation: CoordinatorCallbackRealtimeGeneration;
866
+ readonly channel: "speech";
867
+ readonly params: SessionParams<"thread/realtime/appendSpeech">;
868
+ };
869
+ type CoordinatorCallbackDeliveryOutcome = "delivered" | "not_delivered" | "outcome_unknown";
870
+ type CoordinatorCallbackDeliveryPath = "none" | "silent" | "realtime_appendText" |
871
+ /** Speech the voice model answers now, on the host's choice. */
872
+ "realtime_appendSpeech" |
873
+ /** A developer message in the coordinator's thread, which starts no turn. */
874
+ "coordinator_context" |
875
+ /** The coordinator's running turn or a new one, for a workhorse outcome while voice is live. */
876
+ "coordinator_turn";
877
+ type CallbackBufferOverflowReason = "buffer_overflow" | "coalesced";
878
+ type CoordinatorCallbackDeliveryReason = CallbackBufferOverflowReason | "child_exit" | "disposed" | "invalid_callback" | "not_ready" | "own_change" | "prior_epoch" | "stale_child" | "stale_coordinator" | "stale_link" | "stale_session" | "voice_inactive" |
879
+ /** The host told this audience nothing of the change. */
880
+ "withheld" | "recorded_only" | "session_rejected" | "response_lost" | "transport_failure";
881
+ interface CoordinatorCallbackDeliveryBase {
882
+ readonly kind: "coordinator_callback_delivery";
883
+ readonly callback: CoordinatorCallback | null;
884
+ /** Monotonic first-seen order assigned by this callback owner. */
885
+ readonly sourceOrder: number;
234
886
  readonly freshness: {
235
887
  readonly capturedAtMs: number;
236
888
  readonly freshUntilMs: number;
237
- } | null;
889
+ };
890
+ readonly path: CoordinatorCallbackDeliveryPath;
891
+ readonly reason: CoordinatorCallbackDeliveryReason | null;
892
+ readonly text: string | null;
893
+ readonly realtimeRequest: CoordinatorCallbackRealtimeRequest | null;
238
894
  }
239
- interface CodexCoordinatorProjectionInput {
240
- readonly kind: "codex_coordinator";
241
- readonly state: BrowserCoordinator["state"] | "inspect_only";
242
- readonly threadId: BrowserCoordinator["threadId"];
243
- readonly configured: {
244
- readonly model: string;
245
- readonly effort: string | null;
246
- } | null;
247
- readonly effective: {
248
- readonly model: string;
249
- readonly effort: string | null;
250
- readonly serviceTier: string | null;
251
- } | null;
252
- readonly reason: string | null;
895
+ type CoordinatorCallbackDelivery = CoordinatorCallbackDeliveryBase & ({
896
+ readonly attempted: false;
897
+ readonly attemptedAtMs: null;
898
+ readonly outcome: "not_delivered";
899
+ } | {
900
+ readonly attempted: true;
901
+ readonly attemptedAtMs: number;
902
+ readonly outcome: CoordinatorCallbackDeliveryOutcome;
903
+ });
904
+ interface CoordinatorCallbackHistory {
905
+ readonly deliveries: readonly CoordinatorCallbackDelivery[];
906
+ /** Records evicted before the retained suffix for this exact realtime generation. */
907
+ readonly omittedPrefixCount: number;
908
+ }
909
+ interface CoordinatorCallbacks {
910
+ readonly enqueue: (event: CoordinatorCallbackSource) => Promise<CoordinatorCallbackDelivery>;
911
+ /** Takes every Codex notification, and queues the workhorse news among them. */
912
+ readonly onNotification: (event: TransportServerNotification) => void;
913
+ /** Answers the workhorse's tell_coordinator call, queueing its message as workhorse news. */
914
+ readonly onServerRequest: (request: DynamicServerRequest) => void;
915
+ readonly flush: () => Promise<void>;
916
+ readonly inspect: () => readonly CoordinatorCallbackDelivery[];
917
+ readonly inspectHistory: (generation: CoordinatorCallbackRealtimeGeneration) => CoordinatorCallbackHistory;
918
+ readonly get: (event: CoordinatorCallbackSource) => CoordinatorCallbackDelivery | undefined;
919
+ readonly pendingCount: () => number;
920
+ readonly dispose: () => void;
253
921
  }
254
- interface CodexVoiceProjectionInput {
255
- readonly kind: "codex_voice";
256
- readonly mediaReady: boolean;
257
- readonly generation: {
258
- readonly browserSessionId: string;
259
- } | null;
260
- /** Whether nobody listens live to the session. */
261
- readonly unattended: boolean;
262
- readonly coordinatorState: CodexCoordinatorProjectionInput["state"];
263
- readonly transcript: readonly Pick<RealtimeTranscriptRecord, "itemId" | "sequence" | "role" | "text" | "status">[];
264
- }
265
- interface BrowserProjectionInput {
266
- readonly readiness: BrowserReadiness;
267
- readonly account: BrowserAccountProjectionInput;
268
- readonly login: BrowserLogin;
269
- readonly threadLink: ThreadLinkSnapshot;
270
- readonly timeline: CodexTimelineProjectionInput | null;
271
- /** The voice coordinator's own turns, read the way the timeline is. */
272
- readonly coordinatorTimeline?: CodexTimelineProjectionInput | null;
273
- /** Which coordinator turn delegated each workhorse turn the server has been told of. */
274
- readonly delegations?: ReadonlyMap<TurnId, TurnId>;
275
- readonly queue: CodexQueueProjectionInput;
276
- readonly settings: readonly CodexSettingsProjectionInput[];
277
- readonly approvals: readonly ApprovalOwnerView[];
278
- readonly dynamicApprovals: readonly BrowserDynamicApproval[];
279
- readonly contextDelivery: CodexContextDeliveryProjectionInput;
280
- readonly coordinator: CodexCoordinatorProjectionInput;
281
- readonly voice: CodexVoiceProjectionInput;
282
- readonly spokenApproval: SpokenApprovalSnapshot;
283
- readonly voiceContext?: BrowserVoiceContext | null;
284
- /** The tab session's workhorses and the one whose conversation it shows. */
285
- readonly workhorses?: BrowserWorkhorses;
286
- readonly lease: BrowserCommandLease | null;
287
- readonly operation: BrowserOperationOutcome | null;
288
- }
289
- type BrowserProjectionResult = {
290
- readonly tag: "projected";
291
- readonly snapshot: BrowserSnapshot;
922
+ interface CodexRealtimeBinding {
923
+ readonly child: ChildId;
924
+ readonly epoch: ChildEpoch;
925
+ readonly linkedThreadId: ThreadId;
926
+ readonly coordinatorThreadId: ThreadId;
927
+ }
928
+ interface CodexRealtimeGeneration extends CodexRealtimeBinding {
929
+ readonly browserSessionId: RealtimeSessionId$1;
930
+ readonly browserCorrelationId: RealtimeCorrelationId;
931
+ readonly wireSessionId: RealtimeSessionId;
932
+ /** What the coordinator context read at this realtime start, byte for byte. */
933
+ readonly startBrief: string;
934
+ }
935
+ /** Server-owned protocol half; remote MediaStream attachment remains browser-local. */
936
+ interface CodexRealtimeAdapter extends Omit<RealtimeServer, "attachRemoteMedia" | "createOffer"> {
937
+ /**
938
+ * Accept the browser's offer and start the session, as an ordinary voice session or, given a
939
+ * narrative, one started to present it.
940
+ */
941
+ readonly createOffer: (offer: CreateOfferSdp, narrative?: VoiceNarrative | null) => Promise<AnswerSdp>;
942
+ readonly onNotification: SessionNotificationHandler;
943
+ readonly transcript: () => readonly RealtimeTranscriptRecord[];
944
+ readonly generation: () => CodexRealtimeGeneration | null;
945
+ /** The narrative the live session presents, or null with none or an ordinary one. */
946
+ readonly narrative: () => VoiceNarrative | null;
947
+ readonly dispose: () => void;
948
+ }
949
+ declare const DYNAMIC_TOOL_REFUSAL_REASONS: readonly ["invalid_call", "not_ready", "not_loaded", "not_controllable", "system_error", "stale_child", "prior_epoch", "unknown_provenance", "approval_declined", "cycle", "busy", "expired", "unsupported"];
950
+ type DynamicToolRefusalReason = (typeof DYNAMIC_TOOL_REFUSAL_REASONS)[number];
951
+ /** Responses for calls that passed the coordinator's identity/manifest checks. */
952
+ declare const ValidDynamicToolResponseSchema: z.ZodObject<{
953
+ contentItems: z.ZodTuple<[z.ZodObject<{
954
+ type: z.ZodLiteral<"inputText">;
955
+ text: z.ZodString;
956
+ }, z.core.$strict>], null>;
957
+ success: z.ZodLiteral<true>;
958
+ }, z.core.$strict>;
959
+ /** Responses for calls rejected before a tool call could be established. */
960
+ declare const UnknownDynamicToolResponseSchema: z.ZodObject<{
961
+ contentItems: z.ZodTuple<[z.ZodObject<{
962
+ type: z.ZodLiteral<"inputText">;
963
+ text: z.ZodString;
964
+ }, z.core.$strict>], null>;
965
+ success: z.ZodLiteral<false>;
966
+ }, z.core.$strict>;
967
+ type ToolResponse = z.infer<typeof ValidDynamicToolResponseSchema> | z.infer<typeof UnknownDynamicToolResponseSchema>;
968
+ declare const ResolveSpokenApprovalInputSchema: z.ZodObject<{
969
+ verdict: z.ZodEnum<{
970
+ accept: "accept";
971
+ decline: "decline";
972
+ }>;
973
+ }, z.core.$strict>;
974
+ type ResolveSpokenApprovalInput = z.infer<typeof ResolveSpokenApprovalInputSchema>;
975
+ type SpokenApprovalGateState = "idle" | "awaiting_user" | "classifying" | "awaiting_resolver" | "resolving" | "settled" | "visual_fallback";
976
+ type SpokenApprovalFallbackReason = "approval_unavailable" | "not_eligible" | "coordinator_unavailable" | "realtime_unavailable" | "invalid_context" | "invalid_effect_prompt" | "user_already_spoke" | "missing_user_final" | "assistant_only" | "ambiguous" | "changed_effect" | "stale_realtime_session" | "stale_state" | "timeout" | "classifier_lost" | "resolver_lost" | "child_exit" | "disposed";
977
+ interface SpokenApprovalEffectPrompt {
978
+ readonly itemId: RealtimeItemId;
979
+ readonly sequence: number;
980
+ }
981
+ interface SpokenApprovalClassifierInput {
982
+ /** A server-issued operation identity; this module never mints one. */
983
+ readonly operationId: string;
984
+ /** A server-issued client message identity for the ordinary turn. */
985
+ readonly clientUserMessageId: string;
986
+ readonly context: WorkbenchExecutionContext;
987
+ readonly contextCodec: WorkbenchContextCodec;
988
+ }
989
+ interface SpokenApprovalArmInput {
990
+ readonly requestId: JsonRpcRequestId;
991
+ /** Must equal the broker-derived presentation for this request. */
992
+ readonly effectSummary: string;
993
+ readonly realtime: RealtimeCorrelation;
994
+ readonly effectPrompt: SpokenApprovalEffectPrompt;
995
+ readonly classifier: SpokenApprovalClassifierInput;
996
+ }
997
+ interface SpokenApprovalSnapshot {
998
+ readonly state: SpokenApprovalGateState;
999
+ readonly requestId: JsonRpcRequestId | null;
1000
+ readonly approvalId: ApprovalId | null;
1001
+ readonly child: ChildId | null;
1002
+ readonly epoch: ChildEpoch | null;
1003
+ readonly coordinatorThreadId: ThreadId | null;
1004
+ readonly realtimeSessionId: RealtimeCorrelation["sessionId"] | null;
1005
+ readonly realtimeCorrelationId: RealtimeCorrelation["correlationId"] | null;
1006
+ readonly effectSummary: string | null;
1007
+ readonly effectFingerprint: string | null;
1008
+ readonly effectPromptItemId: RealtimeItemId | null;
1009
+ readonly effectPromptSequence: number | null;
1010
+ readonly finalUserItemId: RealtimeItemId | null;
1011
+ readonly finalUserSequence: number | null;
1012
+ readonly finalUserText: string | null;
1013
+ readonly operationId: string | null;
1014
+ readonly classifierTurnId: TurnId | null;
1015
+ readonly resolverCallId: DynamicToolCallId | null;
1016
+ readonly expiresAtMs: number | null;
1017
+ readonly settlement: ApprovalSettlement | null;
1018
+ readonly reason: SpokenApprovalFallbackReason | null;
1019
+ }
1020
+ type SpokenApprovalToolResult = {
1021
+ readonly tag: "ok";
1022
+ readonly value: {
1023
+ readonly verdict: ResolveSpokenApprovalInput["verdict"];
1024
+ readonly settlement: ApprovalSettlement["outcome"];
1025
+ };
292
1026
  } | {
293
1027
  readonly tag: "refused";
294
- readonly reason: "secret_input" | "invalid_projection";
1028
+ readonly reason: DynamicToolRefusalReason;
295
1029
  readonly message: string;
296
1030
  };
1031
+ interface CodexSpokenApprovalGate {
1032
+ readonly arm: (input: SpokenApprovalArmInput) => SpokenApprovalSnapshot;
1033
+ readonly snapshot: () => SpokenApprovalSnapshot;
1034
+ readonly onSemanticEvent: (event: RealtimeSemanticEvent) => void;
1035
+ readonly onNotification: (event: TransportServerNotification) => void;
1036
+ readonly resolve: (request: DynamicServerRequest) => Promise<SpokenApprovalToolResult>;
1037
+ readonly onChildExit: (exit: {
1038
+ readonly child: ChildId;
1039
+ readonly epoch: ChildEpoch;
1040
+ }) => void;
1041
+ readonly dispose: () => void;
1042
+ }
1043
+ /**
1044
+ * One authoritative queued submission, with the operation that queued
1045
+ * it when this workbench queued it.
1046
+ *
1047
+ * The queue port sets a submission's `clientUserMessageId` to the serialized
1048
+ * OperationId on every add it makes, so the composition root can recover the
1049
+ * operation from the authoritative list and hand it over here. A null operation
1050
+ * is a submission this workbench did not queue, and this chat has no authority to
1051
+ * reorder it.
1052
+ */
1053
+ interface CodexQueuedSubmissionProjectionInput extends Pick<SessionQueuedSubmission, "id" | "input"> {
1054
+ readonly operationId: OperationId | null;
1055
+ }
1056
+ interface CodexQueueProjectionInput {
1057
+ readonly kind: "codex_queue";
1058
+ readonly submissions: readonly CodexQueuedSubmissionProjectionInput[] | null;
1059
+ }
297
1060
  /**
298
1061
  * The tab session a browser tab names on every chat socket: minted by the tab, kept
299
1062
  * in its sessionStorage, shared by every chat of the tab. Opaque to the server beyond its bounds.
@@ -711,7 +1474,7 @@ declare const StopWorkhorsesResultSchema: z.ZodObject<{
711
1474
  stop_workhorses: "stop_workhorses";
712
1475
  }>>;
713
1476
  }, z.core.$strict>>;
714
- }, z.core.$strict>;
1477
+ }, z.core.$strip>;
715
1478
  type StopWorkhorsesResult = z.infer<typeof StopWorkhorsesResultSchema>;
716
1479
  declare const COORDINATOR_TOOLS_OWNER: "codex-coordinator-tools";
717
1480
  type StopEntry = StopWorkhorsesResult["stopped"][number];
@@ -724,7 +1487,7 @@ interface CoordinatorToolStop {
724
1487
  type CoordinatorToolsServerRequest = DynamicServerRequest & {
725
1488
  readonly owner: typeof COORDINATOR_TOOLS_OWNER;
726
1489
  };
727
- type DynamicToolResponse = z.infer<typeof ValidDynamicToolResponseSchema> | z.infer<typeof UnknownDynamicToolResponseSchema>;
1490
+ type DynamicToolResponse = ToolResponse;
728
1491
  interface CoordinatorToolDispatchResult {
729
1492
  readonly response: DynamicToolResponse;
730
1493
  readonly attempted: boolean;
@@ -770,7 +1533,7 @@ interface WorkhorseStartFacts {
770
1533
  readonly cwd: string;
771
1534
  readonly runtimeWorkspaceRoots: readonly string[];
772
1535
  readonly historyMode: "paginated";
773
- readonly source: typeof CODEX_SESSION_THREAD_SOURCE;
1536
+ readonly source: ReturnType<typeof codexSessionThreadSource>;
774
1537
  readonly threadSource: string;
775
1538
  readonly model: string;
776
1539
  readonly modelProvider: string;
@@ -1315,11 +2078,14 @@ interface VoiceAgentOptions {
1315
2078
  readonly ownerDirectory?: string;
1316
2079
  };
1317
2080
  /**
1318
- * How to run Codex: the verified executable path, extra environment, PATH prefixes, secrets
1319
- * to redact from diagnostics, and an optional callback that receives the process group. Read
1320
- * once, when the agent is created.
2081
+ * How to run Codex: which executable, extra environment, PATH prefixes, secrets to redact from
2082
+ * diagnostics, and an optional callback that receives the process group. Read once, when the
2083
+ * agent is created. Without `executablePath`, the agent finds the installed `@openai/codex`
2084
+ * (under `installedIn`, or in the platform package of `releasedIn`) and proves it then, and
2085
+ * throws a `CodexExecutableError` when it cannot. Every start proves the executable again.
2086
+ * Default: the installed `@openai/codex`, anywhere Node resolution finds it.
1321
2087
  */
1322
- readonly codex: CreateCodexWorkbenchOptions["process"];
2088
+ readonly codex?: VoiceAgentCodex;
1323
2089
  /**
1324
2090
  * The checkouts a workhorse may work in: absolute paths, or a function that returns the
1325
2091
  * admitted path for a named checkout and null for a refused one.
@@ -1345,6 +2111,8 @@ interface VoiceAgentOptions {
1345
2111
  /** Domain extensions; see {@link VoiceAgentExtensions}. */
1346
2112
  readonly extensions?: VoiceAgentExtensions;
1347
2113
  }
2114
+ /** The Codex process inputs, with the executable optional and where to find it when left out. */
2115
+ type VoiceAgentCodex = Omit<CreateCodexWorkbenchOptions["process"], "executablePath"> & NonNullable<Parameters<typeof resolveCodexExecutable>[0]>;
1348
2116
  type Workbench = ReturnType<typeof createCodexWorkbench>;
1349
2117
  /** The agent's private Codex process: idle, starting, ready, or failed, with its failure. */
1350
2118
  type VoiceAgentStatus = ReturnType<Workbench["snapshot"]>;
@@ -1422,14 +2190,6 @@ interface VoiceAgent {
1422
2190
  * @returns The agent's lifecycle and browser operations.
1423
2191
  */
1424
2192
  export declare function createVoiceAgent(options: VoiceAgentOptions): VoiceAgent;
1425
- /**
1426
- * Project the owners' state into one validated browser snapshot, refusing
1427
- * input that carries a secret or that the browser contract cannot represent.
1428
- * @param model The browser schema owner.
1429
- * @param input The owners' state for one chat.
1430
- * @returns The projected snapshot, or the refusal.
1431
- */
1432
- export declare function projectCodexBrowserState(model: BrowserProjectionModel, input: BrowserProjectionInput): BrowserProjectionResult;
1433
2193
  /**
1434
2194
  * The checkouts of a tab session's live workhorses: those that have a thread.
1435
2195
  * @param session The tab session.
@@ -1441,4 +2201,4 @@ declare function liveWorkhorseCheckouts(session: Pick<CodexWorkbenchTabSession,
1441
2201
  * @returns The ledger.
1442
2202
  */
1443
2203
  declare function createBrowserLeaseLedger(): BrowserLeaseLedger;
1444
- export { type BrowserProjectionInput, type ContextChange, type TabSessionId, type VoiceAgent, type VoiceAgentBrowserPort, type VoiceAgentExtensions, type VoiceAgentOptions, createBrowserLeaseLedger, createServerCodexBrowserSocketOwner, createServerCodexBrowserSocketSend, liveWorkhorseCheckouts, mountVoiceStartTraceRoute, resolveCodexExecutable };
2204
+ export { type ContextChange, type TabSessionId, type VoiceAgent, type VoiceAgentBrowserPort, type VoiceAgentExtensions, type VoiceAgentOptions, createBrowserLeaseLedger, createServerCodexBrowserSocketOwner, createServerCodexBrowserSocketSend, liveWorkhorseCheckouts, mountVoiceStartTraceRoute };