@opengeni/sdk 0.13.0 → 0.15.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/README.md CHANGED
@@ -70,19 +70,41 @@ the explicit alternative: deliver now by interrupting the running turn.
70
70
 
71
71
  ```ts
72
72
  // Queue (default): stacks behind the running turn.
73
- await client.sendMessage(workspaceId, sessionId, "Also check the nginx config");
73
+ await client.sendMessage(workspaceId, sessionId, {
74
+ text: "Also check the nginx config",
75
+ clientEventId: crypto.randomUUID(),
76
+ });
74
77
 
75
78
  // Steer: send + promote to the queue front + interrupt the running turn.
76
- await client.steerMessage(workspaceId, sessionId, "Stop — prod is paging, look at that first");
79
+ await client.steerMessage(workspaceId, sessionId, {
80
+ text: "Stop — prod is paging, look at that first",
81
+ clientEventId: crypto.randomUUID(),
82
+ });
77
83
 
78
- // Manage the queue while it waits.
79
- const turns = await client.listTurns(workspaceId, sessionId);
80
- await client.updateQueuedTurn(workspaceId, sessionId, turnId, { prompt: "rewritten" });
81
- await client.reorderQueuedTurns(workspaceId, sessionId, [turnB, turnA]);
82
- await client.deleteQueuedTurn(workspaceId, sessionId, turnId);
84
+ // Manage the server-authoritative queue while it waits.
85
+ const queue = await client.getQueue(workspaceId, sessionId);
86
+ const waiting = queue.items.at(-1)!;
87
+ await client.moveQueueItem(workspaceId, sessionId, waiting.id, {
88
+ expectedQueueVersion: queue.version,
89
+ beforeTurnId: queue.items[0]?.id ?? null,
90
+ clientEventId: crypto.randomUUID(),
91
+ });
92
+ await client.editQueueItem(workspaceId, sessionId, waiting.id, {
93
+ expectedTurnVersion: waiting.version,
94
+ expectedDraftRevision: 0,
95
+ replaceDraft: false,
96
+ clientEventId: crypto.randomUUID(),
97
+ });
83
98
 
84
- // Control events.
85
- await client.interrupt(workspaceId, sessionId, { reason: "stop and report" });
99
+ // Pause/Resume is recursive workstream control; it creates no queue row.
100
+ await client.pauseSession(workspaceId, sessionId, {
101
+ reason: "hold this workstream",
102
+ expectedControlEtag: queue.effectiveControl.controlEtag,
103
+ });
104
+ const paused = await client.getQueue(workspaceId, sessionId);
105
+ await client.resumeSession(workspaceId, sessionId, {
106
+ expectedControlEtag: paused.effectiveControl.controlEtag,
107
+ });
86
108
  await client.sendApprovalDecision(workspaceId, sessionId, { approvalId, decision: "approve" });
87
109
  ```
88
110
 
@@ -149,9 +171,9 @@ Every public endpoint group has typed methods:
149
171
  | Group | Methods |
150
172
  | --- | --- |
151
173
  | Access + workspaces | `getAccessContext`, `listWorkspaces`, `createWorkspace`, `getWorkspace`, `updateWorkspace` |
152
- | Sessions + events | `createSession`, `listSessions`, `getSession`, `updateSession`, `listEvents`, `sendEvent`, `sendMessage`, `steerMessage`, `interrupt`, `sendApprovalDecision`, `streamEvents`, `openEventStream` |
174
+ | Sessions + events | `createSession`, `listSessions`, `getSession`, `updateSession`, `listEvents`, `sendEvent`, `sendMessage`, `steerMessage`, `pauseSession`, `resumeSession`, `sendApprovalDecision`, `streamEvents`, `openEventStream` |
153
175
  | Machines (bring-your-own-compute) | `listMachines`, `machineMetricsSeries`, `swapActiveSandbox`, `mintEnrollToken`, `lookupDeviceEnrollment`, `approveDeviceEnrollment`, `denyDeviceEnrollment` |
154
- | Turn queue | `listTurns`, `updateQueuedTurn`, `reorderQueuedTurns`, `deleteQueuedTurn` |
176
+ | Turn queue | `getQueue`, `moveQueueItem`, `editQueueItem`, `steerQueueItem`, `deleteQueueItem` |
155
177
  | Goal | `getGoal`, `updateGoal`, `pauseGoal`, `resumeGoal` |
156
178
  | Scheduled tasks | `createScheduledTask`, `listScheduledTasks`, `getScheduledTask`, `updateScheduledTask`, `pauseScheduledTask`, `resumeScheduledTask`, `triggerScheduledTask`, `deleteScheduledTask`, `listScheduledTaskRuns` |
157
179
  | Variable sets | `listVariable sets`, `createVariable set`, `getVariable set`, `updateVariable set`, `deleteVariable set`, `setVariable setVariable`, `deleteVariable setVariable` (values are write-only) |
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- type SessionStatus = "queued" | "running" | "idle" | "requires_action" | "recovering" | "waiting_capacity" | "paused" | "failed" | "cancelled";
1
+ type SessionStatus = "queued" | "running" | "idle" | "requires_action" | "recovering" | "waiting_capacity" | "failed" | "cancelled";
2
2
  type SandboxBackend = "docker" | "modal" | "local" | "none" | "daytona" | "runloop" | "e2b" | "blaxel" | "cloudflare" | "vercel" | "selfhosted";
3
3
  type SandboxOs = "linux" | "macos" | "windows";
4
4
  type SandboxCapabilityName = "FileSystem" | "Terminal" | "Git" | "DesktopStream" | "Recording";
@@ -287,12 +287,7 @@ type Session = {
287
287
  queueVersion: number;
288
288
  queueHeadPosition: number;
289
289
  queueTailPosition: number;
290
- controlState: "active" | "paused";
291
- controlGeneration: number;
292
- controlReason: string | null;
293
- controlChangedBy: string | null;
294
- controlChangedAt: string | null;
295
- workspaceRunExceptionGeneration: number | null;
290
+ effectiveControl: EffectiveSessionControl;
296
291
  lastSequence: number;
297
292
  /** Multi-account Codex (P1): the account this session is pinned to (null ⇒ follow workspace active). */
298
293
  codexPinnedCredentialId?: string | null;
@@ -337,7 +332,7 @@ type SessionLineageResponse = {
337
332
  children: LineageNode[];
338
333
  truncated: boolean;
339
334
  };
340
- type SessionTurnStatus = "queued" | "running" | "requires_action" | "recovering" | "waiting_capacity" | "completed" | "failed" | "cancelled" | "superseded";
335
+ type SessionTurnStatus = "queued" | "running" | "requires_action" | "recovering" | "waiting_capacity" | "completed" | "failed" | "cancelled" | "superseded" | "withdrawn_for_edit";
341
336
  type SessionTurnSource = "user" | "scheduled_task" | "api" | "goal" | "system" | "compaction";
342
337
  type SessionTurn = {
343
338
  id: string;
@@ -367,7 +362,7 @@ type SessionTurn = {
367
362
  createdAt: string;
368
363
  updatedAt: string;
369
364
  };
370
- declare const SESSION_EVENT_TYPES: readonly ["session.created", "session.status.changed", "session.requiresAction", "session.context.compaction.requested", "session.context.compacted", "session.context.compaction.skipped", "session.context.cleared", "user.message", "user.pause", "user.approvalDecision", "turn.queued", "turn.started", "turn.completed", "turn.failed", "turn.cancelled", "turn.superseded", "turn.recovery.requested", "turn.capacity_waiting", "agent.message.delta", "agent.message.completed", "agent.reasoning.delta", "agent.toolCall.created", "agent.toolCall.output", "agent.model.usage", "tool.auth_needed", "agent.updated", "rig.setup.started", "rig.setup.completed", "rig.setup.skipped", "rig.setup.failed", "sandbox.operation.started", "sandbox.operation.completed", "sandbox.operation.failed", "sandbox.command.output.delta", "artifact.created", "goal.set", "goal.updated", "goal.completed", "goal.paused", "goal.resumed", "goal.cleared", "goal.continuation", "system.update.pending", "system.update.delivered", "session.control.paused", "session.control.resumed", "session.control.steer_requested", "workspace.inference.paused", "workspace.inference.resumed", "session.queue.prompt.cancelled", "session.queue.history", "turn.event.rejected_late", "memory.saved", "memory.corrected", "stream.url.rotated", "stream.opened", "stream.closed", "stream.revoked", "recording.started", "recording.available", "recording.failed", "fs.changed", "git.changed", "terminal.pty.started", "terminal.pty.output.delta", "terminal.pty.exited", "session.title_set", "codex.account.switched", "codex.credential.selected", "codex.capacity.waiting", "codex.capacity.resumed", "codex.capacity.superseded", "sandbox.box.created", "sandbox.box.lost", "sandbox.box.terminated", "sandbox.box.snapshot", "sandbox.env.drift", "session.route.reconciled", "workspace.revision.captured", "workspace.revision.degraded", "machine.op.failed", "machine.op.recovered", "machine.link.lost", "machine.link.restored", "machine.runner.restarted"];
365
+ declare const SESSION_EVENT_TYPES: readonly ["session.created", "session.status.changed", "session.requiresAction", "session.context.compaction.requested", "session.context.compacted", "session.context.compaction.skipped", "session.context.cleared", "user.message", "user.pause", "user.approvalDecision", "turn.queued", "turn.started", "turn.completed", "turn.failed", "turn.cancelled", "turn.superseded", "turn.recovery.requested", "turn.capacity_waiting", "agent.message.delta", "agent.message.completed", "agent.reasoning.delta", "agent.toolCall.created", "agent.toolCall.output", "agent.model.usage", "tool.auth_needed", "agent.updated", "rig.setup.started", "rig.setup.completed", "rig.setup.skipped", "rig.setup.failed", "sandbox.operation.started", "sandbox.operation.completed", "sandbox.operation.failed", "sandbox.command.output.delta", "artifact.created", "goal.set", "goal.updated", "goal.completed", "goal.paused", "goal.resumed", "goal.cleared", "goal.continuation", "system.update.pending", "system.update.delivered", "session.control.paused", "session.control.resumed", "session.control.steer_requested", "workspace.inference.paused", "workspace.inference.resumed", "session.queue.changed", "session.queue.prompt.cancelled", "session.queue.history", "turn.event.rejected_late", "memory.saved", "memory.corrected", "stream.url.rotated", "stream.opened", "stream.closed", "stream.revoked", "recording.started", "recording.available", "recording.failed", "fs.changed", "git.changed", "terminal.pty.started", "terminal.pty.output.delta", "terminal.pty.exited", "session.title_set", "codex.account.switched", "codex.credential.selected", "codex.capacity.waiting", "codex.capacity.resumed", "codex.capacity.superseded", "sandbox.box.created", "sandbox.box.lost", "sandbox.box.terminated", "sandbox.box.snapshot", "sandbox.env.drift", "session.route.reconciled", "workspace.revision.captured", "workspace.revision.degraded", "machine.op.failed", "machine.op.recovered", "machine.link.lost", "machine.link.restored", "machine.runner.restarted"];
371
366
  type KnownSessionEventType = (typeof SESSION_EVENT_TYPES)[number];
372
367
  /**
373
368
  * Event types the SDK knows about today, kept open so a newer OpenGeni server
@@ -1068,6 +1063,8 @@ type ClientAuthConfig = {
1068
1063
  mode: "managedSession";
1069
1064
  session: "cookie";
1070
1065
  };
1066
+ declare const OPENGENI_API_CONTRACT_REVISION: "2026-07-session-control-v1";
1067
+ declare const OPENGENI_API_CONTRACT_HEADER: "x-opengeni-api-contract";
1071
1068
  /**
1072
1069
  * Public, unauthenticated-by-default client bootstrap config returned by
1073
1070
  * `GET /v1/config/client`: which models + reasoning efforts are exposed, the
@@ -1077,6 +1074,8 @@ type ClientAuthConfig = {
1077
1074
  */
1078
1075
  type ClientConfig = {
1079
1076
  deploymentRevision: string;
1077
+ apiContractRevision: typeof OPENGENI_API_CONTRACT_REVISION;
1078
+ serverVersion?: string | undefined;
1080
1079
  defaultModel: string;
1081
1080
  allowedModels: string[];
1082
1081
  models: ClientModel[];
@@ -1133,11 +1132,13 @@ type Workspace = {
1133
1132
  externalId: string | null;
1134
1133
  agentInstructions: string | null;
1135
1134
  settings: Record<string, unknown>;
1136
- inferenceState?: "active" | "paused";
1137
- inferenceGeneration?: number;
1138
- inferenceReason?: string | null;
1139
- inferenceChangedBy?: string | null;
1140
- inferenceChangedAt?: string | null;
1135
+ inferenceControl: {
1136
+ state: "active" | "paused";
1137
+ revision: number;
1138
+ reason: string | null;
1139
+ changedBy: string | null;
1140
+ changedAt: string | null;
1141
+ };
1141
1142
  defaultRigId?: string | null;
1142
1143
  createdAt: string;
1143
1144
  updatedAt: string;
@@ -1246,18 +1247,71 @@ type CompactSessionContextResult = {
1246
1247
  status: "pending" | "completed" | "noop";
1247
1248
  message: string;
1248
1249
  };
1250
+ type EffectiveControlBlocker = {
1251
+ kind: "session" | "workspace";
1252
+ sessionId?: string | undefined;
1253
+ displayName: string;
1254
+ actor: string | null;
1255
+ reason: string | null;
1256
+ changedAt: string | null;
1257
+ revision: number;
1258
+ };
1259
+ type EffectiveControlResumeOption = {
1260
+ scope: "selected" | "session" | "workspace";
1261
+ targetId?: string | undefined;
1262
+ selectedStateAfter: "active" | "paused";
1263
+ remainingPrimaryBlocker?: EffectiveControlBlocker | undefined;
1264
+ impactCopy: string;
1265
+ };
1266
+ type EffectiveSessionControl = {
1267
+ state: "active" | "paused";
1268
+ controlVersion: number;
1269
+ controlEtag: string;
1270
+ directState: "active" | "paused";
1271
+ primaryBlocker: EffectiveControlBlocker | null;
1272
+ additionalBlockerCount: number;
1273
+ blockers: EffectiveControlBlocker[];
1274
+ resumeOptions: EffectiveControlResumeOption[];
1275
+ override: {
1276
+ rootSessionId: string;
1277
+ revision: number;
1278
+ } | null;
1279
+ settlement: {
1280
+ state: "stopping";
1281
+ attemptCount: number;
1282
+ } | null;
1283
+ };
1284
+ type SessionCommandReceipt = {
1285
+ id: string;
1286
+ action: string;
1287
+ operationKey: string;
1288
+ targetSessionId: string | null;
1289
+ targetTurnId: string | null;
1290
+ appliedControlRevision: number | null;
1291
+ appliedQueueVersion: number | null;
1292
+ appliedTurnVersion: number | null;
1293
+ appliedDraftRevision: number | null;
1294
+ createdAt: string;
1295
+ };
1296
+ type ComposerDraft = {
1297
+ revision: number;
1298
+ text: string;
1299
+ resources: ResourceRef[];
1300
+ tools: ToolRef[];
1301
+ model: string;
1302
+ reasoningEffort: ReasoningEffort;
1303
+ sourceTurnId: string | null;
1304
+ sourceTurnVersion: number | null;
1305
+ updatedAt: string | null;
1306
+ };
1249
1307
  type SessionQueueSnapshot = {
1250
1308
  version: number;
1251
- controlState: "active" | "paused";
1252
- controlGeneration: number;
1253
- workspaceInferenceState: "active" | "paused";
1254
- workspaceInferenceGeneration: number;
1255
- workspaceRunExceptionGeneration: number | null;
1309
+ effectiveControl: EffectiveSessionControl;
1256
1310
  items: SessionTurn[];
1257
1311
  };
1258
1312
  type SystemUpdateClassification = "success" | "failure" | "action_required" | "info";
1259
- type SessionSystemUpdateKind = "child_session_update" | "scheduled_wake" | "lifecycle_event" | "runtime_notice";
1260
- type SessionSystemUpdateState = "pending" | "deferred" | "delivered" | "cancelled" | "failed";
1313
+ type SessionSystemUpdateKind = "scheduled_occurrence" | "goal_continuation" | "agent_message" | "agent_steer_instruction" | "child_terminal_result";
1314
+ type SessionSystemUpdateState = "pending" | "deferred" | "delivered" | "cancelled" | "superseded" | "failed";
1261
1315
  type SessionSystemUpdate = {
1262
1316
  id: string;
1263
1317
  sessionId: string;
@@ -1274,29 +1328,61 @@ type SessionSystemUpdate = {
1274
1328
  createdAt: string;
1275
1329
  };
1276
1330
  type SessionControlResponse = {
1277
- operationId: string;
1278
- event: SessionEvent;
1279
- controlState: "active" | "paused";
1280
- controlGeneration: number;
1281
- expectedActiveTurnId: string | null;
1282
- expectedExecutionGeneration: number | null;
1283
- expectedAttemptId: string | null;
1284
- deliveryEventId: string | null;
1285
- shouldSignalControl: boolean;
1286
- shouldWake: boolean;
1331
+ receipt: SessionCommandReceipt;
1332
+ effectiveControl: EffectiveSessionControl;
1333
+ interruptionCount: number;
1334
+ wakeCount: number;
1287
1335
  };
1288
1336
  type WorkspaceInferenceControlResponse = {
1289
- operationId: string;
1337
+ receipt: SessionCommandReceipt;
1290
1338
  state: "active" | "paused";
1291
- generation: number;
1292
- affectedSessionIds: string[];
1293
- controlSessionIds: string[];
1294
- exceptionSessionIds: string[];
1339
+ revision: number;
1340
+ interruptionCount: number;
1341
+ wakeCount: number;
1342
+ };
1343
+ type WorkspaceControlEvent = {
1344
+ id: string;
1345
+ workspaceId: string;
1346
+ /** Same monotonic value as revision; named sequence for SSE resume cursors. */
1347
+ sequence: number;
1348
+ revision: number;
1349
+ type: "workspace.control.changed";
1350
+ scope: "workspace" | "session";
1351
+ rootSessionId: string | null;
1352
+ action: "pause" | "resume";
1353
+ automatic: boolean;
1354
+ reason: string | null;
1355
+ actor: string;
1356
+ occurredAt: string;
1295
1357
  };
1296
1358
  type SessionQueueMutationResponse = {
1359
+ receipt: SessionCommandReceipt;
1297
1360
  snapshot: SessionQueueSnapshot;
1298
- events: SessionEvent[];
1299
- shouldWake: boolean;
1361
+ draft?: ComposerDraft;
1362
+ };
1363
+ type MoveSessionQueueItemRequest = {
1364
+ clientEventId: string;
1365
+ expectedQueueVersion: number;
1366
+ beforeTurnId: string | null;
1367
+ };
1368
+ type EditSessionQueueItemRequest = {
1369
+ clientEventId: string;
1370
+ expectedTurnVersion: number;
1371
+ expectedDraftRevision: number;
1372
+ replaceDraft: boolean;
1373
+ };
1374
+ type SteerSessionQueueItemRequest = {
1375
+ clientEventId: string;
1376
+ expectedTurnVersion: number;
1377
+ controlEtag?: string;
1378
+ };
1379
+ type DeleteSessionQueueItemRequest = {
1380
+ clientEventId: string;
1381
+ expectedTurnVersion: number;
1382
+ reason?: string;
1383
+ };
1384
+ type SaveComposerDraftRequest = Omit<ComposerDraft, "revision" | "sourceTurnId" | "sourceTurnVersion" | "updatedAt"> & {
1385
+ expectedRevision: number;
1300
1386
  };
1301
1387
  /** Input shape for agent config on create/update (server applies defaults). */
1302
1388
  type ScheduledTaskAgentConfigInput = {
@@ -2239,6 +2325,8 @@ type StreamSessionEventsOptions = {
2239
2325
  * reconnects = N+1 total open-stream calls). Defaults to unlimited.
2240
2326
  */
2241
2327
  maxReconnectAttempts?: number;
2328
+ /** Await authoritative client reconciliation before exposing `live`. */
2329
+ beforeLive?: (() => void | Promise<void>) | undefined;
2242
2330
  onStateChange?: (state: StreamConnectionState) => void;
2243
2331
  };
2244
2332
  /**
@@ -2258,6 +2346,17 @@ type StreamSessionEventsOptions = {
2258
2346
  */
2259
2347
  declare function streamSessionEvents(transport: SessionEventStreamTransport, options?: StreamSessionEventsOptions): AsyncGenerator<SessionEvent, void, void>;
2260
2348
 
2349
+ type WorkspaceControlStreamTransport = {
2350
+ /** The server replays every durable event after the cursor before going live. */
2351
+ openStream: (after: number, signal: AbortSignal | undefined) => Promise<ReadableStream<Uint8Array>>;
2352
+ };
2353
+ /**
2354
+ * Reconnecting workspace invalidation stream. Control revisions are monotonic
2355
+ * but can begin above one after the one-way migration, so unlike conversation
2356
+ * events this stream intentionally permits sparse sequence values.
2357
+ */
2358
+ declare function streamWorkspaceControlEvents(transport: WorkspaceControlStreamTransport, options?: StreamSessionEventsOptions): AsyncGenerator<WorkspaceControlEvent, void, void>;
2359
+
2261
2360
  type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
2262
2361
  type OpenGeniClientOptions = {
2263
2362
  /** Base URL of the OpenGeni API, e.g. `https://api.example.com`. */
@@ -2276,8 +2375,8 @@ type SendMessageInput = {
2276
2375
  model?: string;
2277
2376
  reasoningEffort?: ReasoningEffort;
2278
2377
  clientEventId?: string;
2279
- expectedControlGeneration?: number;
2280
- expectedWorkspaceInferenceGeneration?: number;
2378
+ controlEtag?: string;
2379
+ expectedDraftRevision?: number;
2281
2380
  mcpCredentialUpdates?: SessionMcpCredentialUpdateInput[];
2282
2381
  };
2283
2382
  type SteerMessageResult = {
@@ -2396,7 +2495,8 @@ declare class OpenGeniClient {
2396
2495
  pauseSession(workspaceId: string, sessionId: string, options?: {
2397
2496
  reason?: string;
2398
2497
  clientEventId?: string;
2399
- }): Promise<SessionEvent>;
2498
+ expectedControlEtag?: string;
2499
+ }): Promise<SessionControlResponse>;
2400
2500
  sendApprovalDecision(workspaceId: string, sessionId: string, decision: {
2401
2501
  approvalId: string;
2402
2502
  decision: "approve" | "reject";
@@ -2417,33 +2517,39 @@ declare class OpenGeniClient {
2417
2517
  signal?: AbortSignal;
2418
2518
  }): Promise<ReadableStream<Uint8Array>>;
2419
2519
  getQueue(workspaceId: string, sessionId: string): Promise<SessionQueueSnapshot>;
2420
- cancelQueueItem(workspaceId: string, sessionId: string, turnId: string, request: {
2421
- expectedQueueVersion: number;
2422
- expectedItemVersion: number;
2423
- reason?: string;
2424
- }): Promise<SessionQueueMutationResponse>;
2520
+ moveQueueItem(workspaceId: string, sessionId: string, turnId: string, request: MoveSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
2521
+ editQueueItem(workspaceId: string, sessionId: string, turnId: string, request: EditSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
2522
+ steerQueueItem(workspaceId: string, sessionId: string, turnId: string, request: SteerSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
2523
+ deleteQueueItem(workspaceId: string, sessionId: string, turnId: string, request: DeleteSessionQueueItemRequest): Promise<SessionQueueMutationResponse>;
2524
+ getComposerDraft(workspaceId: string, sessionId: string): Promise<ComposerDraft>;
2525
+ saveComposerDraft(workspaceId: string, sessionId: string, request: SaveComposerDraftRequest): Promise<ComposerDraft>;
2425
2526
  controlSession(workspaceId: string, sessionId: string, request: {
2426
- mode: "pause" | "resume";
2527
+ action: "pause" | "resume";
2427
2528
  reason?: string;
2428
- clientEventId?: string;
2429
- expectedControlState?: "active" | "paused";
2430
- expectedControlGeneration?: number;
2431
- expectedWorkspaceInferenceGeneration?: number;
2529
+ clientEventId: string;
2530
+ expectedControlEtag?: string;
2432
2531
  }): Promise<SessionControlResponse>;
2433
2532
  resumeSession(workspaceId: string, sessionId: string, options?: {
2434
2533
  reason?: string;
2435
2534
  clientEventId?: string;
2535
+ expectedControlEtag?: string;
2436
2536
  }): Promise<SessionControlResponse>;
2437
2537
  setWorkspaceInferenceState(workspaceId: string, request: {
2438
- state: "active" | "paused";
2439
- reason: string;
2538
+ action: "pause" | "resume";
2539
+ reason?: string;
2440
2540
  clientEventId: string;
2441
- expectedState: "active" | "paused";
2442
- expectedGeneration: number;
2443
- exceptSessionIds?: string[];
2541
+ expectedRevision?: number;
2444
2542
  }): Promise<WorkspaceInferenceControlResponse>;
2445
- /** Cancel a queued turn before it is claimed. Returns the cancelled turn. */
2446
- deleteQueuedTurn(workspaceId: string, sessionId: string, turnId: string): Promise<SessionTurn>;
2543
+ listWorkspaceControlEvents(workspaceId: string, options?: {
2544
+ after?: number;
2545
+ limit?: number;
2546
+ }): Promise<WorkspaceControlEvent[]>;
2547
+ streamWorkspaceControlEvents(workspaceId: string, options?: StreamSessionEventsOptions): AsyncGenerator<WorkspaceControlEvent, void, void>;
2548
+ workspaceControlStreamTransport(workspaceId: string): WorkspaceControlStreamTransport;
2549
+ openWorkspaceControlEventStream(workspaceId: string, options?: {
2550
+ after?: number;
2551
+ signal?: AbortSignal;
2552
+ }): Promise<ReadableStream<Uint8Array>>;
2447
2553
  /**
2448
2554
  * Steer: atomically put this prompt at the head and supersede the current
2449
2555
  * inference. The client performs one request and renders server order.
@@ -2786,6 +2892,12 @@ declare class OpenGeniApiError extends Error {
2786
2892
  readonly body: string;
2787
2893
  constructor(status: number, body: string);
2788
2894
  }
2895
+ /** The browser bundle and API disagree about their state-changing wire contract. */
2896
+ declare class OpenGeniApiContractMismatchError extends Error {
2897
+ readonly expected: string;
2898
+ readonly actual: string;
2899
+ constructor(expected: string, actual: string);
2900
+ }
2789
2901
  /** Error for an unrecoverable event-stream condition (not a transient drop). */
2790
2902
  declare class OpenGeniStreamError extends Error {
2791
2903
  constructor(message: string);
@@ -2995,4 +3107,4 @@ declare function ttydInputFrame(data: string): string;
2995
3107
  /** Build a client→server RESIZE frame: "1" + JSON.stringify({ columns, rows }). */
2996
3108
  declare function ttydResizeFrame(columns: number, rows: number): string;
2997
3109
 
2998
- export { type AccessContext, type AccessGrant, type AccountGrant, type AccountRole, type AcknowledgeStreamRequest, type AcknowledgeStreamResponse, type AddDocumentRequest, type AddWorkspaceMemberRequest, type AgentMessageCompletedPayload, type AgentTextDeltaPayload, type AgentToolCallCreatedPayload, type AgentToolCallOutputPayload, type ApiKey, type AttachViewerRequest, type AttachViewerResponse, type BillingBalance, type BillingEntitlementsResponse, type BillingMode, type BillingSummary, type BillingUsageResponse, type CapabilityCatalogItem, type CapabilityCatalogResponse, type CapabilityInstallation, type CapabilityInstallationStatus, type CapabilityKind, type CapabilityPack, type CapabilityPackConnector, type CapabilityPackConnectorAuthModel, type CapabilityPackKnowledge, type CapabilityPackScheduledTaskTemplate, type CapabilityPackSkill, type CapabilityPackSkillFile, type CapabilityPackVariableSetSpec, type CapabilityRuntime, type CapabilitySource, type CapabilityUnavailableReason, type ClientAuthConfig, type ClientConfig, type ClientModel, type ClientSessionEventInput, type CodexAccount, type CodexAccountSwitchedPayload, type CodexAccountsResponse, type CodexConnectPoll, type CodexConnectStart, type CodexConnectionStatus, type CodexRotationSettings, type CodexUsage, type CodexUsageMap, type CodexUsagePayload, type CodexUsageWindow, type CompactSessionContextResult, type CompleteFileUploadResponse, type ComputerUseCapability, type ConnectionKind, type ConnectionMetadata, type ConnectionResponse, type ConnectionStatus, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateCapabilityCatalogItemRequest, type CreateCheckoutRequest, type CreateCheckoutResponse, type CreateConnectionRequest, type CreateDocumentBaseRequest, type CreateFileUploadRequest, type CreateFileUploadResponse, type CreateGitHubAppManifestRequest, type CreateGitHubAppManifestResponse, type CreateKnowledgeMemoryRequest, type CreateRigRequest, type CreateScheduledTaskRequest, type CreateSessionRequest, type CreateVariableSetRequest, type CreateWorkspaceEnvironmentRequest, type CreateWorkspaceRequest, type DesktopConnectionState, type DesktopRfbFactory, type DesktopRfbLike, type DesktopStreamCapability, type DesktopStreamEvent, type DeviceEnrollmentApproveRequest, type DeviceEnrollmentApproveResponse, type DeviceEnrollmentDenyRequest, type DeviceEnrollmentDenyResponse, type DeviceEnrollmentLookupMachine, type DeviceEnrollmentLookupRequest, type DeviceEnrollmentLookupResponse, type DiscoverMcpCapabilitiesResponse, type Document, type DocumentBase, type DocumentSearchMode, type DocumentSearchRequest, type DocumentSearchResponse, type DocumentSearchResult, type DocumentStatus, type EnableCapabilityRequest, type EnablePackRequest, type EnrollTokenExchangeRequest, type EnrollTokenExchangeResponse, type EnrollmentCredentials, type EnrollmentOs, type EntitlementValue, type Entitlements, type EntitlementsMode, type FetchLike, type FileAsset, type FileDownloadUrlResponse, type FileResourceRef, type FileStatus, type FileSystemCapability, type FileUploadData, type FsChangeKind, type FsChangedPayload, type FsDeleteRequest, type FsDeleteResponse, type FsEncoding, type FsListRequest, type FsListResponse, type FsMkdirRequest, type FsMkdirResponse, type FsMoveRequest, type FsMoveResponse, type FsNodeType, type FsReadRequest, type FsReadResponse, type FsTreeNode, type FsWriteRequest, type FsWriteResponse, type GetPackResponse, type GetWorkspaceCaptureFileResponse, type GetWorkspaceCaptureResponse, type GitCapability, type GitChangedPayload, type GitCommit, type GitCredentialProvider, type GitDiffHunk, type GitDiffLine, type GitDiffLineType, type GitDiffRequest, type GitDiffResponse, type GitFileDiff, type GitFileStatus, type GitFileStatusCode, type GitHubAppInfo, type GitHubRepositoriesResponse, type GitHubRepository, type GitLogRequest, type GitLogResponse, type GitShowRequest, type GitShowResponse, type GitStatusRequest, type GitStatusResponse, type GoalSpec, type IntegrationClientMetadata, KNOWN_PERMISSIONS, KNOWN_USAGE_EVENT_TYPES, type KnowledgeMemory, type KnowledgeMemoryKind, type KnowledgeMemorySearchRequest, type KnowledgeMemoryStatus, type KnowledgeSourceKind, type KnowledgeSourceRef, type KnownPermission, type KnownSessionEventType, type KnownUsageEventType, type LineageNode, type ListApiKeysResponse, type ListConnectionsResponse, type ListPacksResponse, type ListWorkspaceMembersResponse, type MachineKind, type MachineMetricsSeriesResponse, type MachineState, type MachineView, type MachinesResponse, type McpServerConnectionRef, type MetricSample, type MintEnrollTokenRequest, type MintEnrollTokenResponse, type OAuthStartRequest, type OAuthStartResponse, OpenGeniApiError, OpenGeniClient, type OpenGeniClientOptions, OpenGeniStreamError, type PackInstallation, type PackInstallationStatus, type Permission, type ProductAccessMode, type ProposeRigChangeRequest, type ProxySessionEventStreamOptions, type PtyCloseRequest, type PtyOpenRequest, type PtyOpenResponse, type PtyResizeRequest, type PtyWriteRequest, type ReasoningEffort, type RecordingAvailablePayload, type RecordingCapability, type RecordingCodec, type RecordingContentType, type RecordingFailedPayload, type RecordingFailedReason, type RecordingMode, type RecordingStartedPayload, type RegisterCapabilityPackRequest, type RepositoryResourceRef, type ResourceRef, type Rig, type RigChange, type RigChangeKind, type RigChangeStatus, type RigChangeVerification, type RigCheck, type RigCheckResult, type RigDefinitionEditPayload, type RigSetupAppendPayload, type RigVersion, SESSION_EVENT_TYPES, type SandboxBackend, type SandboxCapabilityName, type SandboxCommandOutputDeltaPayload, type SandboxOs, type ScheduledTask, type ScheduledTaskAgentConfig, type ScheduledTaskAgentConfigInput, type ScheduledTaskDayOfWeek, type ScheduledTaskOverlapPolicy, type ScheduledTaskRun, type ScheduledTaskRunMode, type ScheduledTaskRunStatus, type ScheduledTaskScheduleSpec, type ScheduledTaskStatus, type ScheduledTaskTriggerType, type SendMessageInput, type Session, type SessionCapabilities, type SessionControlResponse, type SessionEvent, type SessionEventStreamTransport, type SessionEventType, type SessionGoal, type SessionGoalCreatedBy, type SessionGoalStatus, type SessionLineageResponse, type SessionListResponse, type SessionMcpCredentialUpdateInput, type SessionMcpServerInput, type SessionMcpServerMetadata, type SessionQueueMutationResponse, type SessionQueueSnapshot, type SessionStatus, type SessionStatusChangedPayload, type SessionStructuredCapabilities, type SessionSummary, type SessionSystemUpdate, type SessionSystemUpdateKind, type SessionSystemUpdateState, type SessionTurn, type SessionTurnSource, type SessionTurnStatus, type SetWorkspaceEnvironmentVariableRequest, type SseMessage, type SseReStreamOptions, type SteerMessageResult, type StreamClosedPayload, type StreamConnectionState, type StreamOpenedPayload, type StreamRevokedPayload, type StreamSessionEventsOptions, type StreamUrlRotatedPayload, type SwapActiveSandboxRequest, type SwapActiveSandboxResponse, TTYD_SUBPROTOCOL, type TerminalCapability, type TerminalExecRequest, type TerminalExecResponse, type TerminalPtyExitedPayload, type TerminalPtyOutputDeltaPayload, type TerminalPtyStartedPayload, type ToolAuthNeededPayload, type ToolRef, TtydClientCommand, TtydServerCommand, type UpdateConnectionRequest, type UpdateKnowledgeMemoryRequest, type UpdateRigRequest, type UpdateScheduledTaskRequest, type UpdateSessionGoalRequest, type UpdateSessionPinRequest, type UpdateSessionRequest, type UpdateVariableSetRequest, type UpdateWorkspaceEnvironmentRequest, type UpdateWorkspaceMemberRequest, type UpdateWorkspaceRequest, type UpdateWorkspaceSettingsRequest, type UploadFileInput, type UsageEvent, type UsageEventType, type UserApprovalDecisionEventInput, type UserMessageEventInput, type VariableSet, type VariableSetVariableMetadata, type ViewerHeartbeatRequest, type ViewerHeartbeatResponse, type ViewerHolder, type Workspace, type WorkspaceCaptureDegradedReason, type WorkspaceCaptureFile, type WorkspaceCaptureManifest, type WorkspaceCaptureRepo, type WorkspaceCaptureSignedUrl, type WorkspaceCaptureStats, type WorkspaceEnvironment, type WorkspaceEnvironmentVariableMetadata, type WorkspaceInferenceControlResponse, type WorkspaceMember, type WorkspaceMemorySearchMode, type WorkspaceMemorySearchRequest, type WorkspaceMemorySearchResponse, type WorkspaceMemorySearchResult, type WorkspaceRegisteredPack, type WorkspaceRevisionCapturedPayload, type WorkspaceRevisionDegradedPayload, type WorkspaceSettings, applyUrlRotation, desktopSocketUrl, formatSseEvent, isRetryableStreamError, nextDesktopState, parseSseStream, proxySessionEventStream, resumeSequenceFromRequest, sessionEventsToSseResponse, sessionEventsToSseStream, streamSessionEvents, terminalSocketUrl, ttydAuthFrame, ttydInputFrame, ttydResizeFrame };
3110
+ export { type AccessContext, type AccessGrant, type AccountGrant, type AccountRole, type AcknowledgeStreamRequest, type AcknowledgeStreamResponse, type AddDocumentRequest, type AddWorkspaceMemberRequest, type AgentMessageCompletedPayload, type AgentTextDeltaPayload, type AgentToolCallCreatedPayload, type AgentToolCallOutputPayload, type ApiKey, type AttachViewerRequest, type AttachViewerResponse, type BillingBalance, type BillingEntitlementsResponse, type BillingMode, type BillingSummary, type BillingUsageResponse, type CapabilityCatalogItem, type CapabilityCatalogResponse, type CapabilityInstallation, type CapabilityInstallationStatus, type CapabilityKind, type CapabilityPack, type CapabilityPackConnector, type CapabilityPackConnectorAuthModel, type CapabilityPackKnowledge, type CapabilityPackScheduledTaskTemplate, type CapabilityPackSkill, type CapabilityPackSkillFile, type CapabilityPackVariableSetSpec, type CapabilityRuntime, type CapabilitySource, type CapabilityUnavailableReason, type ClientAuthConfig, type ClientConfig, type ClientModel, type ClientSessionEventInput, type CodexAccount, type CodexAccountSwitchedPayload, type CodexAccountsResponse, type CodexConnectPoll, type CodexConnectStart, type CodexConnectionStatus, type CodexRotationSettings, type CodexUsage, type CodexUsageMap, type CodexUsagePayload, type CodexUsageWindow, type CompactSessionContextResult, type CompleteFileUploadResponse, type ComposerDraft, type ComputerUseCapability, type ConnectionKind, type ConnectionMetadata, type ConnectionResponse, type ConnectionStatus, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateCapabilityCatalogItemRequest, type CreateCheckoutRequest, type CreateCheckoutResponse, type CreateConnectionRequest, type CreateDocumentBaseRequest, type CreateFileUploadRequest, type CreateFileUploadResponse, type CreateGitHubAppManifestRequest, type CreateGitHubAppManifestResponse, type CreateKnowledgeMemoryRequest, type CreateRigRequest, type CreateScheduledTaskRequest, type CreateSessionRequest, type CreateVariableSetRequest, type CreateWorkspaceEnvironmentRequest, type CreateWorkspaceRequest, type DeleteSessionQueueItemRequest, type DesktopConnectionState, type DesktopRfbFactory, type DesktopRfbLike, type DesktopStreamCapability, type DesktopStreamEvent, type DeviceEnrollmentApproveRequest, type DeviceEnrollmentApproveResponse, type DeviceEnrollmentDenyRequest, type DeviceEnrollmentDenyResponse, type DeviceEnrollmentLookupMachine, type DeviceEnrollmentLookupRequest, type DeviceEnrollmentLookupResponse, type DiscoverMcpCapabilitiesResponse, type Document, type DocumentBase, type DocumentSearchMode, type DocumentSearchRequest, type DocumentSearchResponse, type DocumentSearchResult, type DocumentStatus, type EditSessionQueueItemRequest, type EffectiveControlBlocker, type EffectiveControlResumeOption, type EffectiveSessionControl, type EnableCapabilityRequest, type EnablePackRequest, type EnrollTokenExchangeRequest, type EnrollTokenExchangeResponse, type EnrollmentCredentials, type EnrollmentOs, type EntitlementValue, type Entitlements, type EntitlementsMode, type FetchLike, type FileAsset, type FileDownloadUrlResponse, type FileResourceRef, type FileStatus, type FileSystemCapability, type FileUploadData, type FsChangeKind, type FsChangedPayload, type FsDeleteRequest, type FsDeleteResponse, type FsEncoding, type FsListRequest, type FsListResponse, type FsMkdirRequest, type FsMkdirResponse, type FsMoveRequest, type FsMoveResponse, type FsNodeType, type FsReadRequest, type FsReadResponse, type FsTreeNode, type FsWriteRequest, type FsWriteResponse, type GetPackResponse, type GetWorkspaceCaptureFileResponse, type GetWorkspaceCaptureResponse, type GitCapability, type GitChangedPayload, type GitCommit, type GitCredentialProvider, type GitDiffHunk, type GitDiffLine, type GitDiffLineType, type GitDiffRequest, type GitDiffResponse, type GitFileDiff, type GitFileStatus, type GitFileStatusCode, type GitHubAppInfo, type GitHubRepositoriesResponse, type GitHubRepository, type GitLogRequest, type GitLogResponse, type GitShowRequest, type GitShowResponse, type GitStatusRequest, type GitStatusResponse, type GoalSpec, type IntegrationClientMetadata, KNOWN_PERMISSIONS, KNOWN_USAGE_EVENT_TYPES, type KnowledgeMemory, type KnowledgeMemoryKind, type KnowledgeMemorySearchRequest, type KnowledgeMemoryStatus, type KnowledgeSourceKind, type KnowledgeSourceRef, type KnownPermission, type KnownSessionEventType, type KnownUsageEventType, type LineageNode, type ListApiKeysResponse, type ListConnectionsResponse, type ListPacksResponse, type ListWorkspaceMembersResponse, type MachineKind, type MachineMetricsSeriesResponse, type MachineState, type MachineView, type MachinesResponse, type McpServerConnectionRef, type MetricSample, type MintEnrollTokenRequest, type MintEnrollTokenResponse, type MoveSessionQueueItemRequest, type OAuthStartRequest, type OAuthStartResponse, OPENGENI_API_CONTRACT_HEADER, OPENGENI_API_CONTRACT_REVISION, OpenGeniApiContractMismatchError, OpenGeniApiError, OpenGeniClient, type OpenGeniClientOptions, OpenGeniStreamError, type PackInstallation, type PackInstallationStatus, type Permission, type ProductAccessMode, type ProposeRigChangeRequest, type ProxySessionEventStreamOptions, type PtyCloseRequest, type PtyOpenRequest, type PtyOpenResponse, type PtyResizeRequest, type PtyWriteRequest, type ReasoningEffort, type RecordingAvailablePayload, type RecordingCapability, type RecordingCodec, type RecordingContentType, type RecordingFailedPayload, type RecordingFailedReason, type RecordingMode, type RecordingStartedPayload, type RegisterCapabilityPackRequest, type RepositoryResourceRef, type ResourceRef, type Rig, type RigChange, type RigChangeKind, type RigChangeStatus, type RigChangeVerification, type RigCheck, type RigCheckResult, type RigDefinitionEditPayload, type RigSetupAppendPayload, type RigVersion, SESSION_EVENT_TYPES, type SandboxBackend, type SandboxCapabilityName, type SandboxCommandOutputDeltaPayload, type SandboxOs, type SaveComposerDraftRequest, type ScheduledTask, type ScheduledTaskAgentConfig, type ScheduledTaskAgentConfigInput, type ScheduledTaskDayOfWeek, type ScheduledTaskOverlapPolicy, type ScheduledTaskRun, type ScheduledTaskRunMode, type ScheduledTaskRunStatus, type ScheduledTaskScheduleSpec, type ScheduledTaskStatus, type ScheduledTaskTriggerType, type SendMessageInput, type Session, type SessionCapabilities, type SessionCommandReceipt, type SessionControlResponse, type SessionEvent, type SessionEventStreamTransport, type SessionEventType, type SessionGoal, type SessionGoalCreatedBy, type SessionGoalStatus, type SessionLineageResponse, type SessionListResponse, type SessionMcpCredentialUpdateInput, type SessionMcpServerInput, type SessionMcpServerMetadata, type SessionQueueMutationResponse, type SessionQueueSnapshot, type SessionStatus, type SessionStatusChangedPayload, type SessionStructuredCapabilities, type SessionSummary, type SessionSystemUpdate, type SessionSystemUpdateKind, type SessionSystemUpdateState, type SessionTurn, type SessionTurnSource, type SessionTurnStatus, type SetWorkspaceEnvironmentVariableRequest, type SseMessage, type SseReStreamOptions, type SteerMessageResult, type SteerSessionQueueItemRequest, type StreamClosedPayload, type StreamConnectionState, type StreamOpenedPayload, type StreamRevokedPayload, type StreamSessionEventsOptions, type StreamUrlRotatedPayload, type SwapActiveSandboxRequest, type SwapActiveSandboxResponse, TTYD_SUBPROTOCOL, type TerminalCapability, type TerminalExecRequest, type TerminalExecResponse, type TerminalPtyExitedPayload, type TerminalPtyOutputDeltaPayload, type TerminalPtyStartedPayload, type ToolAuthNeededPayload, type ToolRef, TtydClientCommand, TtydServerCommand, type UpdateConnectionRequest, type UpdateKnowledgeMemoryRequest, type UpdateRigRequest, type UpdateScheduledTaskRequest, type UpdateSessionGoalRequest, type UpdateSessionPinRequest, type UpdateSessionRequest, type UpdateVariableSetRequest, type UpdateWorkspaceEnvironmentRequest, type UpdateWorkspaceMemberRequest, type UpdateWorkspaceRequest, type UpdateWorkspaceSettingsRequest, type UploadFileInput, type UsageEvent, type UsageEventType, type UserApprovalDecisionEventInput, type UserMessageEventInput, type VariableSet, type VariableSetVariableMetadata, type ViewerHeartbeatRequest, type ViewerHeartbeatResponse, type ViewerHolder, type Workspace, type WorkspaceCaptureDegradedReason, type WorkspaceCaptureFile, type WorkspaceCaptureManifest, type WorkspaceCaptureRepo, type WorkspaceCaptureSignedUrl, type WorkspaceCaptureStats, type WorkspaceControlEvent, type WorkspaceControlStreamTransport, type WorkspaceEnvironment, type WorkspaceEnvironmentVariableMetadata, type WorkspaceInferenceControlResponse, type WorkspaceMember, type WorkspaceMemorySearchMode, type WorkspaceMemorySearchRequest, type WorkspaceMemorySearchResponse, type WorkspaceMemorySearchResult, type WorkspaceRegisteredPack, type WorkspaceRevisionCapturedPayload, type WorkspaceRevisionDegradedPayload, type WorkspaceSettings, applyUrlRotation, desktopSocketUrl, formatSseEvent, isRetryableStreamError, nextDesktopState, parseSseStream, proxySessionEventStream, resumeSequenceFromRequest, sessionEventsToSseResponse, sessionEventsToSseStream, streamSessionEvents, streamWorkspaceControlEvents, terminalSocketUrl, ttydAuthFrame, ttydInputFrame, ttydResizeFrame };