@archboard/codex-realtime-voice 0.0.0-stage → 0.2.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.
- package/LICENSE +21 -0
- package/README.md +621 -2
- package/dist/app-server-contract-D4E5bibD.mjs +177 -0
- package/dist/browser.d.mts +10 -0
- package/dist/browser.mjs +475 -0
- package/dist/contract-CZDUvuVt.d.mts +19587 -0
- package/dist/contract-Cupd2jDS.d.mts +131 -0
- package/dist/contract-DTEwX7x-.d.mts +164 -0
- package/dist/contract-qg6q9-vH.d.mts +6905 -0
- package/dist/contract.d.mts +2 -0
- package/dist/contract.mjs +1 -0
- package/dist/controllers.d.mts +588 -0
- package/dist/controllers.mjs +4754 -0
- package/dist/gateway-envelope-CODkg5rz.mjs +43 -0
- package/dist/gateway-envelope-Ch4BsYcK.d.mts +36 -0
- package/dist/instructions-CmBJHqpa.mjs +8980 -0
- package/dist/media-state-CakgDCk4.d.mts +215 -0
- package/dist/model-YHUwnXnC.mjs +2808 -0
- package/dist/react.d.mts +34 -0
- package/dist/react.mjs +49 -0
- package/dist/realtime-contract-DwkCluo2.mjs +1167 -0
- package/dist/realtime-contract-wHmSyUIe.d.mts +150 -0
- package/dist/realtime-state-CTBmCjt1.mjs +182 -0
- package/dist/realtime-state-DT4uvrIV.d.mts +16 -0
- package/dist/realtime.d.mts +3 -0
- package/dist/realtime.mjs +3 -0
- package/dist/runtime.d.mts +93 -0
- package/dist/runtime.mjs +289 -0
- package/dist/schemas.d.mts +7075 -0
- package/dist/schemas.mjs +1 -0
- package/dist/server.d.mts +1374 -0
- package/dist/server.mjs +38224 -0
- package/dist/snapshot-BCrCORmt.d.mts +8597 -0
- package/dist/transport-CqOvXrAE.mjs +5168 -0
- package/package.json +71 -5
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { S as BrowserDynamicApproval, g as BrowserTimeline, m as BrowserSpokenApproval, n as BrowserApproval, p as BrowserSnapshot, v as BrowserWorkhorses } from "./snapshot-BCrCORmt.mjs";
|
|
2
|
+
export type { BrowserApproval, BrowserDynamicApproval, BrowserSnapshot, BrowserSpokenApproval, BrowserTimeline, BrowserWorkhorses };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,588 @@
|
|
|
1
|
+
import { J as ThreadId, O as DYNAMIC_APPROVAL_DECISIONS, S as BrowserDynamicApproval, W as LoginId, g as BrowserTimeline, h as BrowserThreadLink, i as BrowserCommandLease, l as BrowserQueue, n as BrowserApproval, p as BrowserSnapshot, y as DeliveryOutcome } from "./snapshot-BCrCORmt.mjs";
|
|
2
|
+
import { n as CodexLoginAccountParams, t as CodexCommandExecutionApprovalDecision } from "./contract-qg6q9-vH.mjs";
|
|
3
|
+
import { r as BrowserGatewayErrorCode } from "./gateway-envelope-Ch4BsYcK.mjs";
|
|
4
|
+
import { a as VOICE_OUTPUT_SPEAKING_LEVEL, i as browserAudioElements, n as BrowserWorkbenchMediaOwner, o as VoiceOutputLevelSource, r as BrowserWorkbenchMediaOwnerOptions, t as BrowserAudioElementPort } from "./media-state-CakgDCk4.mjs";
|
|
5
|
+
import { a as BrowserWorkbenchTransportOptions, i as BrowserWorkbenchTransport, r as BrowserWorkbenchState } from "./contract-DTEwX7x-.mjs";
|
|
6
|
+
/**
|
|
7
|
+
* Adapt one chat's server socket to the browser workbench gateway.
|
|
8
|
+
* @param transportOptions Clock and request-id sources.
|
|
9
|
+
* @returns The transport.
|
|
10
|
+
*/
|
|
11
|
+
declare function createBrowserWorkbenchTransport(transportOptions?: BrowserWorkbenchTransportOptions): BrowserWorkbenchTransport;
|
|
12
|
+
/**
|
|
13
|
+
* Creates the owner.
|
|
14
|
+
* @param options The construction options.
|
|
15
|
+
* @returns The owner.
|
|
16
|
+
*/
|
|
17
|
+
declare function createBrowserWorkbenchMediaOwner(options?: BrowserWorkbenchMediaOwnerOptions): BrowserWorkbenchMediaOwner;
|
|
18
|
+
/** The seven ordinary app-server human-interaction request families. */
|
|
19
|
+
type WorkbenchApprovalFamily = BrowserApproval["approvalKind"];
|
|
20
|
+
/** The three dynamic coordination effects a person may approve. */
|
|
21
|
+
type WorkbenchDynamicTool = BrowserDynamicApproval["identity"]["tool"];
|
|
22
|
+
/**
|
|
23
|
+
* One lifecycle position shared by ordinary and dynamic approvals. The
|
|
24
|
+
* ordinary contract spells its terminal delivery inside `lifecycle`; the
|
|
25
|
+
* dynamic contract spells the same fact as a state name. Both reduce to this
|
|
26
|
+
* vocabulary so the surface has one owner per reachable state.
|
|
27
|
+
*/
|
|
28
|
+
type WorkbenchApprovalPhase = "staged" | "pending" | "approved" | "declined" | "cancelled" | "expired" | "stale" | "disconnected" | "delivered" | "not_delivered" | "outcome_unknown";
|
|
29
|
+
type WorkbenchApprovalAuthority = "live" | "removed";
|
|
30
|
+
/** Where one approval stands, and whether this browser may still decide it. */
|
|
31
|
+
interface WorkbenchApprovalStatus {
|
|
32
|
+
readonly phase: WorkbenchApprovalPhase;
|
|
33
|
+
readonly label: string;
|
|
34
|
+
readonly detail: string;
|
|
35
|
+
readonly recovery: string | null;
|
|
36
|
+
/** What the server recorded, in human words, once something was decided. */
|
|
37
|
+
readonly decision: string | null;
|
|
38
|
+
readonly delivery: DeliveryOutcome | null;
|
|
39
|
+
readonly terminal: boolean;
|
|
40
|
+
readonly authority: WorkbenchApprovalAuthority;
|
|
41
|
+
readonly authorityReason: string | null;
|
|
42
|
+
/** Nothing in this surface ever resumes an approval_required tool result. */
|
|
43
|
+
readonly resumable: false;
|
|
44
|
+
}
|
|
45
|
+
/** One disclosed fact. */
|
|
46
|
+
interface WorkbenchApprovalDisclosure {
|
|
47
|
+
readonly label: string;
|
|
48
|
+
readonly value: string;
|
|
49
|
+
/** Technical tokens use the mono family; human phrases use the UI family. */
|
|
50
|
+
readonly technical: boolean;
|
|
51
|
+
}
|
|
52
|
+
/** One safe link. */
|
|
53
|
+
interface WorkbenchApprovalLink {
|
|
54
|
+
readonly label: string;
|
|
55
|
+
readonly href: string;
|
|
56
|
+
}
|
|
57
|
+
type WorkbenchApprovalControl = "text" | "multiline" | "secret" | "number" | "integer" | "boolean" | "enum" | "multi_enum" | "url" | "email" | "date" | "date_time";
|
|
58
|
+
/** One choice of an enumerated field. */
|
|
59
|
+
interface WorkbenchApprovalOption {
|
|
60
|
+
readonly label: string;
|
|
61
|
+
readonly description: string | null;
|
|
62
|
+
}
|
|
63
|
+
/** One reviewed field a decision reads. */
|
|
64
|
+
interface WorkbenchApprovalField {
|
|
65
|
+
/** Stable form key. Ordinary question ids and elicitation names keep theirs. */
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly label: string;
|
|
68
|
+
readonly description: string | null;
|
|
69
|
+
readonly control: WorkbenchApprovalControl;
|
|
70
|
+
readonly required: boolean;
|
|
71
|
+
readonly secret: boolean;
|
|
72
|
+
readonly options: readonly WorkbenchApprovalOption[] | null;
|
|
73
|
+
/** A requestUserInput question that also accepts free text. */
|
|
74
|
+
readonly allowsOther: boolean;
|
|
75
|
+
readonly minimum: number | null;
|
|
76
|
+
readonly maximum: number | null;
|
|
77
|
+
readonly minLength: number | null;
|
|
78
|
+
readonly maxLength: number | null;
|
|
79
|
+
readonly minimumItems: number | null;
|
|
80
|
+
readonly maximumItems: number | null;
|
|
81
|
+
/** Never populated for a secret: the contract refuses to project one. */
|
|
82
|
+
readonly defaultValue: string | null;
|
|
83
|
+
}
|
|
84
|
+
type WorkbenchApprovalTone = "primary" | "secondary" | "quiet";
|
|
85
|
+
/** One decision the model allows. */
|
|
86
|
+
interface WorkbenchApprovalOffer {
|
|
87
|
+
readonly id: string;
|
|
88
|
+
readonly label: string;
|
|
89
|
+
readonly description: string | null;
|
|
90
|
+
readonly tone: WorkbenchApprovalTone;
|
|
91
|
+
/** The offer reads the reviewed fields before it can be sent. */
|
|
92
|
+
readonly submitsForm: boolean;
|
|
93
|
+
/** True only on a genuine ordinary binary accept or decline. */
|
|
94
|
+
readonly spokenEligible: boolean;
|
|
95
|
+
}
|
|
96
|
+
/** Whether, and why, a request may be answered by voice. */
|
|
97
|
+
interface WorkbenchApprovalSpoken {
|
|
98
|
+
readonly eligible: boolean;
|
|
99
|
+
readonly label: string;
|
|
100
|
+
readonly detail: string;
|
|
101
|
+
}
|
|
102
|
+
/** One validation failure. */
|
|
103
|
+
interface WorkbenchApprovalFieldError {
|
|
104
|
+
readonly name: string;
|
|
105
|
+
readonly message: string;
|
|
106
|
+
}
|
|
107
|
+
interface WorkbenchApprovalCardBase {
|
|
108
|
+
readonly key: string;
|
|
109
|
+
readonly title: string;
|
|
110
|
+
readonly summary: string;
|
|
111
|
+
readonly identity: readonly WorkbenchApprovalDisclosure[];
|
|
112
|
+
readonly effect: readonly WorkbenchApprovalDisclosure[];
|
|
113
|
+
readonly offers: readonly WorkbenchApprovalOffer[];
|
|
114
|
+
readonly spoken: WorkbenchApprovalSpoken;
|
|
115
|
+
readonly status: WorkbenchApprovalStatus;
|
|
116
|
+
readonly expiresAtMs: number;
|
|
117
|
+
readonly notices: readonly string[];
|
|
118
|
+
}
|
|
119
|
+
/** One ordinary app-server approval. */
|
|
120
|
+
interface WorkbenchOrdinaryApprovalCard extends WorkbenchApprovalCardBase {
|
|
121
|
+
readonly kind: "ordinary";
|
|
122
|
+
readonly family: WorkbenchApprovalFamily;
|
|
123
|
+
/** The immutable request exactly as the server published it. */
|
|
124
|
+
readonly request: BrowserApproval;
|
|
125
|
+
/** The broker's own identity for this request. */
|
|
126
|
+
readonly broker: readonly WorkbenchApprovalDisclosure[];
|
|
127
|
+
readonly fields: readonly WorkbenchApprovalField[];
|
|
128
|
+
readonly links: readonly WorkbenchApprovalLink[];
|
|
129
|
+
}
|
|
130
|
+
/** One dynamic coordination approval. */
|
|
131
|
+
interface WorkbenchDynamicApprovalCard extends WorkbenchApprovalCardBase {
|
|
132
|
+
readonly kind: "dynamic";
|
|
133
|
+
readonly tool: WorkbenchDynamicTool;
|
|
134
|
+
/** The immutable request exactly as the server published it. */
|
|
135
|
+
readonly request: BrowserDynamicApproval;
|
|
136
|
+
readonly effectHash: string;
|
|
137
|
+
readonly toolResult: string | null;
|
|
138
|
+
}
|
|
139
|
+
type WorkbenchApprovalCard = WorkbenchOrdinaryApprovalCard | WorkbenchDynamicApprovalCard;
|
|
140
|
+
/** One beacon line. */
|
|
141
|
+
interface WorkbenchApprovalBeaconEntry {
|
|
142
|
+
readonly key: string;
|
|
143
|
+
readonly label: string;
|
|
144
|
+
readonly phase: WorkbenchApprovalPhase;
|
|
145
|
+
/** The immutable target this request was raised against. */
|
|
146
|
+
readonly target: string;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* The approval surface is application-global: a person must see a pending
|
|
150
|
+
* request and every terminal outcome whether or not the workbench region has
|
|
151
|
+
* focus, so the beacon carries the same facts as the cards in one live region.
|
|
152
|
+
*/
|
|
153
|
+
interface WorkbenchApprovalsBeacon {
|
|
154
|
+
readonly scope: "app_global";
|
|
155
|
+
readonly pending: number;
|
|
156
|
+
readonly total: number;
|
|
157
|
+
readonly announcement: string;
|
|
158
|
+
readonly entries: readonly WorkbenchApprovalBeaconEntry[];
|
|
159
|
+
}
|
|
160
|
+
/** The server's authoritative outcome for the last operation. */
|
|
161
|
+
interface WorkbenchApprovalsReconciliation {
|
|
162
|
+
readonly operationId: string;
|
|
163
|
+
readonly outcome: DeliveryOutcome;
|
|
164
|
+
readonly label: string;
|
|
165
|
+
readonly detail: string;
|
|
166
|
+
}
|
|
167
|
+
/** Everything the surface shows. */
|
|
168
|
+
interface WorkbenchApprovalsView {
|
|
169
|
+
readonly beacon: WorkbenchApprovalsBeacon;
|
|
170
|
+
readonly cards: readonly WorkbenchApprovalCard[];
|
|
171
|
+
readonly reconciliation: WorkbenchApprovalsReconciliation | null;
|
|
172
|
+
readonly authority: WorkbenchApprovalAuthority;
|
|
173
|
+
readonly authorityReason: string | null;
|
|
174
|
+
readonly empty: string | null;
|
|
175
|
+
}
|
|
176
|
+
type WorkbenchApprovalDecisionResult = {
|
|
177
|
+
readonly status: "invalid";
|
|
178
|
+
readonly errors: readonly WorkbenchApprovalFieldError[];
|
|
179
|
+
} | {
|
|
180
|
+
readonly status: "sent";
|
|
181
|
+
readonly outcome: DeliveryOutcome;
|
|
182
|
+
readonly message: string;
|
|
183
|
+
} | {
|
|
184
|
+
readonly status: "refused";
|
|
185
|
+
readonly code: string;
|
|
186
|
+
readonly outcome: DeliveryOutcome;
|
|
187
|
+
readonly message: string;
|
|
188
|
+
};
|
|
189
|
+
/** A verdict on a dynamic coordination approval, as the shared model spells it. */
|
|
190
|
+
type DynamicApprovalVerdict = (typeof DYNAMIC_APPROVAL_DECISIONS)[number];
|
|
191
|
+
/** A decision on one approval, as the model defines it. */
|
|
192
|
+
type ApprovalChoice = {
|
|
193
|
+
kind: "command_decision";
|
|
194
|
+
decision: CodexCommandExecutionApprovalDecision;
|
|
195
|
+
} | {
|
|
196
|
+
kind: "file_change_decision";
|
|
197
|
+
decision: "accept" | "acceptForSession" | "decline" | "cancel";
|
|
198
|
+
} | {
|
|
199
|
+
kind: "answer";
|
|
200
|
+
questionId: string;
|
|
201
|
+
answer: string;
|
|
202
|
+
} | {
|
|
203
|
+
kind: "approve";
|
|
204
|
+
} | {
|
|
205
|
+
kind: "decline";
|
|
206
|
+
};
|
|
207
|
+
/** The two actions an approval card calls. */
|
|
208
|
+
interface ApprovalCardActions {
|
|
209
|
+
readonly respondToApproval: (approval: BrowserApproval, choice: ApprovalChoice) => void;
|
|
210
|
+
readonly respondToDynamicApproval: (approval: BrowserDynamicApproval, verdict: DynamicApprovalVerdict) => void;
|
|
211
|
+
}
|
|
212
|
+
/** The controller's own state beside the transport's. */
|
|
213
|
+
interface WorkbenchApprovalsDecisionState {
|
|
214
|
+
/** Keys of decisions on the wire: an approval's request id, or a dynamic approval's call id. */
|
|
215
|
+
readonly busyApprovals: readonly string[];
|
|
216
|
+
/** The last result per key, until the server's own record replaces it. */
|
|
217
|
+
readonly results: ReadonlyMap<string, WorkbenchApprovalDecisionResult>;
|
|
218
|
+
}
|
|
219
|
+
/** The approvals controller. */
|
|
220
|
+
interface WorkbenchApprovalsController {
|
|
221
|
+
/** Notified when a decision starts or settles. */
|
|
222
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
223
|
+
readonly decisionState: () => WorkbenchApprovalsDecisionState;
|
|
224
|
+
/** The surface for the current transport state and clock. */
|
|
225
|
+
readonly view: (nowMs: number) => WorkbenchApprovalsView;
|
|
226
|
+
readonly respondToApproval: (approval: BrowserApproval, choice: ApprovalChoice) => Promise<WorkbenchApprovalDecisionResult>;
|
|
227
|
+
readonly respondToDynamicApproval: (approval: BrowserDynamicApproval, verdict: DynamicApprovalVerdict) => Promise<WorkbenchApprovalDecisionResult>;
|
|
228
|
+
/** The actions the committed approvals panel calls. */
|
|
229
|
+
readonly panelActions: ApprovalCardActions;
|
|
230
|
+
}
|
|
231
|
+
/** The workbench identities this composer targets, taken from the closed model. */
|
|
232
|
+
type Timeline = NonNullable<BrowserSnapshot["timeline"]>;
|
|
233
|
+
type WorkbenchComposerThreadId = Timeline["threadId"];
|
|
234
|
+
type WorkbenchComposerTurnId = Timeline["turns"][number]["turnId"];
|
|
235
|
+
type WorkbenchComposerAction = "start" | "steer" | "interrupt" | "queue";
|
|
236
|
+
/**
|
|
237
|
+
* How a submitted message reaches the workhorse. `auto` steers while a turn
|
|
238
|
+
* runs and starts otherwise; `send` always starts, so the server's in-progress
|
|
239
|
+
* guard answers a person who chose it deliberately; `steer` requires the
|
|
240
|
+
* active turn; `queue` parks the message in the thread queue.
|
|
241
|
+
*/
|
|
242
|
+
type WorkbenchComposerDelivery = "auto" | "send" | "steer" | "queue";
|
|
243
|
+
interface WorkbenchComposerRetainedDraft {
|
|
244
|
+
readonly text: string;
|
|
245
|
+
readonly threadId: WorkbenchComposerThreadId;
|
|
246
|
+
readonly reason: string;
|
|
247
|
+
}
|
|
248
|
+
type WorkbenchComposerStatusState = "idle" | "pending" | "refused" | DeliveryOutcome | "unavailable";
|
|
249
|
+
interface WorkbenchComposerStatus {
|
|
250
|
+
readonly role: "status";
|
|
251
|
+
readonly label: "Codex composer status";
|
|
252
|
+
readonly state: WorkbenchComposerStatusState;
|
|
253
|
+
readonly message: string;
|
|
254
|
+
readonly recovery: string | null;
|
|
255
|
+
}
|
|
256
|
+
interface WorkbenchComposerState {
|
|
257
|
+
/** Non-null exactly while one command holds the browser's command lease. */
|
|
258
|
+
readonly pending: WorkbenchComposerAction | null;
|
|
259
|
+
readonly status: WorkbenchComposerStatus;
|
|
260
|
+
readonly retained: WorkbenchComposerRetainedDraft | null;
|
|
261
|
+
/** Advances once per settled command, so a surface can return focus. */
|
|
262
|
+
readonly settled: number;
|
|
263
|
+
}
|
|
264
|
+
/** One submission from the official composer. */
|
|
265
|
+
interface WorkbenchComposerSubmission {
|
|
266
|
+
readonly text: string;
|
|
267
|
+
readonly delivery?: WorkbenchComposerDelivery;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* The workbench's own submission result, shaped for the runtime's `onNew`.
|
|
271
|
+
* `delivered` names the authoritative turn when the server reported one; a
|
|
272
|
+
* queued message has no turn and reports the submission it parked.
|
|
273
|
+
*/
|
|
274
|
+
type WorkbenchComposerSubmissionResult = {
|
|
275
|
+
readonly outcome: "delivered";
|
|
276
|
+
readonly turnId: WorkbenchComposerTurnId;
|
|
277
|
+
} | {
|
|
278
|
+
readonly outcome: "queued";
|
|
279
|
+
} | {
|
|
280
|
+
readonly outcome: "not_delivered";
|
|
281
|
+
readonly reason: string;
|
|
282
|
+
} | {
|
|
283
|
+
readonly outcome: "outcome_unknown";
|
|
284
|
+
readonly reason: string;
|
|
285
|
+
};
|
|
286
|
+
interface WorkbenchComposerCommandResult {
|
|
287
|
+
readonly outcome: DeliveryOutcome;
|
|
288
|
+
readonly reason: string;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* One state owner for submit, steer, queue, interrupt, pending, and the
|
|
292
|
+
* retained draft. Its `submit` is shaped to fit the runtime's `onNew`, so a
|
|
293
|
+
* chat cannot end up with two answers about what is pending or what happened.
|
|
294
|
+
*/
|
|
295
|
+
interface WorkbenchComposerController {
|
|
296
|
+
readonly submit: (submission: WorkbenchComposerSubmission) => Promise<WorkbenchComposerSubmissionResult>;
|
|
297
|
+
readonly interrupt: (turnId: WorkbenchComposerTurnId) => Promise<WorkbenchComposerCommandResult>;
|
|
298
|
+
readonly getState: () => WorkbenchComposerState;
|
|
299
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
300
|
+
readonly dismissRetainedDraft: () => void;
|
|
301
|
+
}
|
|
302
|
+
/** Every error code a transport can carry, gateway and transport-local. */
|
|
303
|
+
type WorkbenchTransportErrorCode = BrowserGatewayErrorCode | "gateway_error" | "socket_unavailable" | "response_lost" | "replaced" | "incompatible_contract";
|
|
304
|
+
/**
|
|
305
|
+
* The six controls this module offers, and nothing else.
|
|
306
|
+
*
|
|
307
|
+
* Five are queue commands the gateway publishes. `list` is not: the closed
|
|
308
|
+
* browser contract has no `queueList` command. Serving a snapshot request
|
|
309
|
+
* re-reads the authoritative queue for the link this chat is on, so a refresh
|
|
310
|
+
* is a genuine read of the server's list rather than a redraw of the last
|
|
311
|
+
* command's result.
|
|
312
|
+
*/
|
|
313
|
+
declare const WORKBENCH_QUEUE_CONTROLS: readonly ["add", "list", "edit", "cancel", "reorder", "start"];
|
|
314
|
+
type WorkbenchQueueControl = (typeof WORKBENCH_QUEUE_CONTROLS)[number];
|
|
315
|
+
type WorkbenchQueueEntry = BrowserQueue["entries"][number];
|
|
316
|
+
type WorkbenchQueueSubmissionId = WorkbenchQueueEntry["submissionId"];
|
|
317
|
+
type WorkbenchQueueOperationId = NonNullable<WorkbenchQueueEntry["operationId"]>;
|
|
318
|
+
type WorkbenchThreadLink = BrowserSnapshot["threadLink"];
|
|
319
|
+
type WorkbenchTimelineTurn = NonNullable<BrowserSnapshot["timeline"]>["turns"][number];
|
|
320
|
+
/**
|
|
321
|
+
* Every state the queue region can be in. `loading`, `restarted` and
|
|
322
|
+
* `outcome_unknown` are not queue statuses on the wire: loading is the window
|
|
323
|
+
* before the first authoritative snapshot, restarted is a child epoch that
|
|
324
|
+
* replaced the one this queue was presented for (a restart voids every
|
|
325
|
+
* execution proof with the child), and outcome_unknown also covers a command
|
|
326
|
+
* whose own outcome was lost.
|
|
327
|
+
*/
|
|
328
|
+
type WorkbenchQueueState = "loading" | "empty" | "queued" | "running" | "interrupted_preserved" | "approval_blocked" | "failed" | "restarted" | "completed" | "stale" | "reconnecting" | "disconnected" | "session_stopped" | "session_incompatible" | "unavailable" | "outcome_unknown";
|
|
329
|
+
/** Whether a control is offered, and why not when it is not. */
|
|
330
|
+
interface WorkbenchQueueAvailability {
|
|
331
|
+
readonly enabled: boolean;
|
|
332
|
+
/** Always present when the control is disabled. */
|
|
333
|
+
readonly reason: string | null;
|
|
334
|
+
}
|
|
335
|
+
/** The exact child identity a presented queue belongs to. */
|
|
336
|
+
interface WorkbenchQueueChildIdentity {
|
|
337
|
+
readonly childId: NonNullable<WorkbenchThreadLink["childId"]>;
|
|
338
|
+
readonly epoch: NonNullable<WorkbenchThreadLink["epoch"]>;
|
|
339
|
+
}
|
|
340
|
+
/** What the queue is, in workhorse and coordinator terms, in every state. */
|
|
341
|
+
interface WorkbenchQueueCorrelation {
|
|
342
|
+
readonly linkState: WorkbenchThreadLink["state"] | null;
|
|
343
|
+
readonly workhorseThreadId: WorkbenchThreadLink["threadId"];
|
|
344
|
+
readonly workhorseThreadStatus: WorkbenchThreadLink["status"] | null;
|
|
345
|
+
readonly child: WorkbenchQueueChildIdentity | null;
|
|
346
|
+
readonly activeTurnId: WorkbenchTimelineTurn["turnId"] | null;
|
|
347
|
+
readonly activeTurnStatus: WorkbenchTimelineTurn["status"] | null;
|
|
348
|
+
readonly coordinatorThreadId: BrowserSnapshot["coordinator"]["threadId"];
|
|
349
|
+
readonly coordinatorState: BrowserSnapshot["coordinator"]["state"] | null;
|
|
350
|
+
readonly blockingApprovals: number;
|
|
351
|
+
readonly sequence: number | null;
|
|
352
|
+
/** One sentence naming the queue, its workhorse, and its coordinator. */
|
|
353
|
+
readonly summary: string;
|
|
354
|
+
}
|
|
355
|
+
type WorkbenchQueueOwnership = "coordinator" | "foreign";
|
|
356
|
+
/** One entry as the server holds it, with what this chat may do to it. */
|
|
357
|
+
interface WorkbenchQueueEntryView {
|
|
358
|
+
readonly submissionId: WorkbenchQueueSubmissionId;
|
|
359
|
+
readonly prompt: string;
|
|
360
|
+
readonly status: WorkbenchQueueEntry["status"];
|
|
361
|
+
readonly statusLabel: string;
|
|
362
|
+
readonly position: number;
|
|
363
|
+
readonly total: number;
|
|
364
|
+
readonly ownership: WorkbenchQueueOwnership;
|
|
365
|
+
readonly ownershipLabel: string;
|
|
366
|
+
readonly coordinatorOperationId: WorkbenchQueueOperationId | null;
|
|
367
|
+
/** Accessible row name: position, ownership, and the prompt's first words. */
|
|
368
|
+
readonly label: string;
|
|
369
|
+
/** How this entry relates to the linked workhorse right now. */
|
|
370
|
+
readonly correlation: string;
|
|
371
|
+
readonly edit: WorkbenchQueueAvailability;
|
|
372
|
+
readonly cancel: WorkbenchQueueAvailability;
|
|
373
|
+
readonly start: WorkbenchQueueAvailability;
|
|
374
|
+
readonly moveEarlier: WorkbenchQueueAvailability;
|
|
375
|
+
readonly moveLater: WorkbenchQueueAvailability;
|
|
376
|
+
}
|
|
377
|
+
/** A queue command that is on the wire and not yet settled. */
|
|
378
|
+
interface WorkbenchQueuePending {
|
|
379
|
+
readonly control: WorkbenchQueueControl;
|
|
380
|
+
readonly submissionId: WorkbenchQueueSubmissionId | null;
|
|
381
|
+
}
|
|
382
|
+
/**
|
|
383
|
+
* Authoritative reconciliation only. `reconciled` means the server answered
|
|
384
|
+
* `delivered` and republished the queue; nothing here reports a terminal or
|
|
385
|
+
* reordered state the server has not confirmed.
|
|
386
|
+
*/
|
|
387
|
+
type WorkbenchQueueSettlementState = "reconciled" | "refused" | "outcome_unknown";
|
|
388
|
+
/** How one queue command settled. */
|
|
389
|
+
interface WorkbenchQueueSettlement {
|
|
390
|
+
readonly control: WorkbenchQueueControl;
|
|
391
|
+
readonly state: WorkbenchQueueSettlementState;
|
|
392
|
+
readonly code: WorkbenchTransportErrorCode | null;
|
|
393
|
+
readonly message: string;
|
|
394
|
+
readonly submissionId: WorkbenchQueueSubmissionId | null;
|
|
395
|
+
}
|
|
396
|
+
/** Everything the queue region shows. */
|
|
397
|
+
interface WorkbenchQueueView {
|
|
398
|
+
readonly state: WorkbenchQueueState;
|
|
399
|
+
readonly label: string;
|
|
400
|
+
readonly detail: string;
|
|
401
|
+
readonly recovery: string;
|
|
402
|
+
readonly correlation: WorkbenchQueueCorrelation;
|
|
403
|
+
readonly entries: readonly WorkbenchQueueEntryView[];
|
|
404
|
+
readonly coordinatorOwnedCount: number;
|
|
405
|
+
readonly foreignCount: number;
|
|
406
|
+
readonly add: WorkbenchQueueAvailability;
|
|
407
|
+
readonly list: WorkbenchQueueAvailability;
|
|
408
|
+
readonly reorder: WorkbenchQueueAvailability;
|
|
409
|
+
/** True while nothing on screen may be treated as current. */
|
|
410
|
+
readonly stale: boolean;
|
|
411
|
+
readonly pending: WorkbenchQueuePending | null;
|
|
412
|
+
readonly settlement: WorkbenchQueueSettlement | null;
|
|
413
|
+
}
|
|
414
|
+
type WorkbenchQueueReorderDirection = "earlier" | "later";
|
|
415
|
+
type WorkbenchQueueReorderMove = Readonly<{
|
|
416
|
+
kind: "step";
|
|
417
|
+
direction: WorkbenchQueueReorderDirection;
|
|
418
|
+
}> |
|
|
419
|
+
/** A pointer drop before the entry currently at this 1-based position. */
|
|
420
|
+
Readonly<{
|
|
421
|
+
kind: "drop";
|
|
422
|
+
position: number;
|
|
423
|
+
}>;
|
|
424
|
+
/** Queue actions, each naming the submission it acts on. */
|
|
425
|
+
interface WorkbenchQueueActions {
|
|
426
|
+
moveUp: (submissionId: string) => void;
|
|
427
|
+
moveDown: (submissionId: string) => void;
|
|
428
|
+
remove: (submissionId: string) => void;
|
|
429
|
+
sendNow: (submissionId: string) => void;
|
|
430
|
+
}
|
|
431
|
+
/** The controller's own state beside the transport's. */
|
|
432
|
+
interface WorkbenchQueueCommandState {
|
|
433
|
+
readonly pending: WorkbenchQueuePending | null;
|
|
434
|
+
readonly settlement: WorkbenchQueueSettlement | null;
|
|
435
|
+
}
|
|
436
|
+
/** The queue controller. */
|
|
437
|
+
interface WorkbenchQueueController {
|
|
438
|
+
/** Notified when the transport or the command state changes. */
|
|
439
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
440
|
+
/** The view for the current transport observation and command state. */
|
|
441
|
+
readonly view: () => WorkbenchQueueView;
|
|
442
|
+
readonly commandState: () => WorkbenchQueueCommandState;
|
|
443
|
+
/** Re-read the authoritative list; the recovery for every unproven state. */
|
|
444
|
+
readonly list: () => Promise<WorkbenchQueueSettlement>;
|
|
445
|
+
/** The composer's explicit queue intent: park a message behind the current turn. */
|
|
446
|
+
readonly add: (prompt: string) => Promise<WorkbenchQueueSettlement>;
|
|
447
|
+
readonly edit: (submissionId: WorkbenchQueueSubmissionId, prompt: string) => Promise<WorkbenchQueueSettlement>;
|
|
448
|
+
readonly cancel: (submissionId: WorkbenchQueueSubmissionId) => Promise<WorkbenchQueueSettlement>;
|
|
449
|
+
readonly start: (submissionId: WorkbenchQueueSubmissionId) => Promise<WorkbenchQueueSettlement>;
|
|
450
|
+
readonly move: (submissionId: WorkbenchQueueSubmissionId, move: WorkbenchQueueReorderMove) => Promise<WorkbenchQueueSettlement>;
|
|
451
|
+
/** The actions the committed queue panel calls. */
|
|
452
|
+
readonly panelActions: WorkbenchQueueActions;
|
|
453
|
+
}
|
|
454
|
+
/** The sign-in variants the closed browser contract admits. */
|
|
455
|
+
type SupportedLoginVariant = "apiKey" | "chatgpt" | "amazonBedrock" | "amazonBedrockAccessKeys";
|
|
456
|
+
/** The account/login/start parameters a browser may send. */
|
|
457
|
+
type ThreadLinkLoginParams = Extract<CodexLoginAccountParams, {
|
|
458
|
+
readonly type: SupportedLoginVariant;
|
|
459
|
+
}>;
|
|
460
|
+
/** The exact lease authority a command is dispatched under. */
|
|
461
|
+
interface WorkbenchCommandTarget {
|
|
462
|
+
readonly commandId: BrowserCommandLease["commandId"];
|
|
463
|
+
readonly chatId: BrowserCommandLease["chatId"];
|
|
464
|
+
readonly childId: BrowserCommandLease["childId"];
|
|
465
|
+
readonly epoch: BrowserCommandLease["epoch"];
|
|
466
|
+
readonly capturedThreadLink: BrowserThreadLink;
|
|
467
|
+
}
|
|
468
|
+
type ThreadLinkActionName = "create" | "login" | "cancel_login" | "logout";
|
|
469
|
+
/**
|
|
470
|
+
* The chat, epoch, lease, and link an action was offered against. The three
|
|
471
|
+
* captured identities are null only when the workbench refused to hand out a
|
|
472
|
+
* target at all, which is itself the reason the action failed.
|
|
473
|
+
*/
|
|
474
|
+
interface ThreadLinkActionTarget {
|
|
475
|
+
readonly chatId: string;
|
|
476
|
+
readonly childId: WorkbenchCommandTarget["childId"] | null;
|
|
477
|
+
readonly epoch: WorkbenchCommandTarget["epoch"] | null;
|
|
478
|
+
readonly commandId: WorkbenchCommandTarget["commandId"] | null;
|
|
479
|
+
readonly capturedLinkState: BrowserThreadLink["state"] | null;
|
|
480
|
+
readonly capturedLinkThreadId: ThreadId | null;
|
|
481
|
+
}
|
|
482
|
+
type ThreadLinkActionSnapshot = {
|
|
483
|
+
readonly state: "idle";
|
|
484
|
+
readonly revision: number;
|
|
485
|
+
} | {
|
|
486
|
+
readonly state: "pending";
|
|
487
|
+
readonly revision: number;
|
|
488
|
+
readonly action: ThreadLinkActionName;
|
|
489
|
+
readonly target: ThreadLinkActionTarget;
|
|
490
|
+
readonly announcement: string;
|
|
491
|
+
} | {
|
|
492
|
+
readonly state: "succeeded" | "inspect_only" | "failed";
|
|
493
|
+
readonly revision: number;
|
|
494
|
+
readonly action: ThreadLinkActionName;
|
|
495
|
+
readonly target: ThreadLinkActionTarget;
|
|
496
|
+
readonly announcement: string;
|
|
497
|
+
};
|
|
498
|
+
/** Applied means this settlement is the published one; ignored means superseded. */
|
|
499
|
+
interface ThreadLinkActionCompletion {
|
|
500
|
+
readonly state: "applied" | "ignored";
|
|
501
|
+
readonly revision: number;
|
|
502
|
+
}
|
|
503
|
+
/** The thread-link action controller. */
|
|
504
|
+
interface ThreadLinkController {
|
|
505
|
+
readonly snapshot: () => ThreadLinkActionSnapshot;
|
|
506
|
+
readonly subscribe: (listener: () => void) => () => void;
|
|
507
|
+
readonly create: () => Promise<ThreadLinkActionCompletion>;
|
|
508
|
+
readonly login: (login: ThreadLinkLoginParams) => Promise<ThreadLinkActionCompletion>;
|
|
509
|
+
readonly cancelLogin: (loginId: LoginId) => Promise<ThreadLinkActionCompletion>;
|
|
510
|
+
readonly logout: () => Promise<ThreadLinkActionCompletion>;
|
|
511
|
+
}
|
|
512
|
+
/** The controllers over one chat's transport. */
|
|
513
|
+
interface ConversationControllers {
|
|
514
|
+
/** Creates and resumes the conversation and runs sign-in. */
|
|
515
|
+
readonly threadLink: ThreadLinkController;
|
|
516
|
+
/** Sends, steers and queues messages, holding a draft that did not land. */
|
|
517
|
+
readonly composer: WorkbenchComposerController;
|
|
518
|
+
/** Reorders, edits, cancels and starts queued messages. */
|
|
519
|
+
readonly queue: WorkbenchQueueController;
|
|
520
|
+
/** Answers ordinary and dynamic approvals against what the card showed. */
|
|
521
|
+
readonly approvals: WorkbenchApprovalsController;
|
|
522
|
+
}
|
|
523
|
+
/** The chat the controllers act for. */
|
|
524
|
+
interface ConversationControllersOptions {
|
|
525
|
+
/** The view in the host page that shows this conversation. */
|
|
526
|
+
readonly chatId: string;
|
|
527
|
+
/** The transport attached to that chat's socket. */
|
|
528
|
+
readonly transport: BrowserWorkbenchTransport;
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Make the conversation controllers of one chat.
|
|
532
|
+
* @param options The chat and its transport.
|
|
533
|
+
* @returns The controllers.
|
|
534
|
+
*/
|
|
535
|
+
declare function createConversationControllers(options: ConversationControllersOptions): ConversationControllers;
|
|
536
|
+
type BrowserTurn = BrowserTimeline["turns"][number];
|
|
537
|
+
/** One item of a turn exactly as the server published it: a prompt, prose, work, a plan, an approval. */
|
|
538
|
+
type ConversationItem = BrowserTurn["items"][number];
|
|
539
|
+
/** The plan Codex published for a turn. */
|
|
540
|
+
type ConversationPlan = NonNullable<BrowserTurn["plan"]>;
|
|
541
|
+
/** How a turn ended, in the workbench's words. */
|
|
542
|
+
type ConversationOutcome = "running" | "completed" | "interrupted" | "failed";
|
|
543
|
+
/** Whose turn it is: the workhorse's, or the voice coordinator's. */
|
|
544
|
+
type ConversationOwner = "workhorse" | "coordinator";
|
|
545
|
+
/** The voice coordinator's turn that handed a workhorse turn its work. */
|
|
546
|
+
interface ConversationDelegation {
|
|
547
|
+
readonly turnId: BrowserTurn["turnId"];
|
|
548
|
+
/** Whether that turn is in the conversation, so the workhorse turn can point to it. */
|
|
549
|
+
readonly shown: boolean;
|
|
550
|
+
}
|
|
551
|
+
/** One turn of the conversation. */
|
|
552
|
+
interface ConversationTurn {
|
|
553
|
+
/** Stable across publications: the thread and the turn. */
|
|
554
|
+
readonly id: string;
|
|
555
|
+
readonly owner: ConversationOwner;
|
|
556
|
+
readonly threadId: BrowserTimeline["threadId"];
|
|
557
|
+
readonly turnId: BrowserTurn["turnId"];
|
|
558
|
+
readonly outcome: ConversationOutcome;
|
|
559
|
+
readonly items: readonly ConversationItem[];
|
|
560
|
+
/** When it started and ended, in milliseconds, when Codex said. */
|
|
561
|
+
readonly startedAtMs: number | null;
|
|
562
|
+
readonly completedAtMs: number | null;
|
|
563
|
+
readonly durationMs: number | null;
|
|
564
|
+
/** Codex's own words for a failure, or null. */
|
|
565
|
+
readonly error: BrowserTurn["error"];
|
|
566
|
+
/** The latest plan Codex published for it, or null. */
|
|
567
|
+
readonly plan: ConversationPlan | null;
|
|
568
|
+
/** The voice coordinator's turn that delegated this one, while the server knows it, or null. */
|
|
569
|
+
readonly delegatedBy: ConversationDelegation | null;
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* The conversation a timeline holds.
|
|
573
|
+
* @param timeline The authoritative timeline.
|
|
574
|
+
* @param owner Whose thread it is.
|
|
575
|
+
* @returns One turn per Codex turn, in order.
|
|
576
|
+
* @throws {Error} When a turn or an item is published twice.
|
|
577
|
+
*/
|
|
578
|
+
declare function projectTimelineTurns(timeline: BrowserTimeline, owner: ConversationOwner): readonly ConversationTurn[];
|
|
579
|
+
/**
|
|
580
|
+
* The workhorse's turns and the voice coordinator's in one conversation, ordered
|
|
581
|
+
* by when each started. Two turns that start together keep the coordinator's
|
|
582
|
+
* first, since it is the one that hands work on.
|
|
583
|
+
* @param workhorse The workhorse's turns, in order.
|
|
584
|
+
* @param coordinator The voice coordinator's turns, in order.
|
|
585
|
+
* @returns The turns, with each delegated one told whether its delegating turn is among them.
|
|
586
|
+
*/
|
|
587
|
+
declare function mergeConversation(workhorse: readonly ConversationTurn[], coordinator: readonly ConversationTurn[]): readonly ConversationTurn[];
|
|
588
|
+
export { type ApprovalChoice, type BrowserAudioElementPort, type BrowserWorkbenchMediaOwner, type BrowserWorkbenchState, type BrowserWorkbenchTransport, type ConversationControllers, type ConversationTurn, VOICE_OUTPUT_SPEAKING_LEVEL, type VoiceOutputLevelSource, browserAudioElements, createBrowserWorkbenchMediaOwner, createBrowserWorkbenchTransport, createConversationControllers, mergeConversation, projectTimelineTurns };
|