@opengeni/sdk 0.9.0 → 0.13.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/src/types.ts CHANGED
@@ -8,6 +8,9 @@ export type SessionStatus =
8
8
  | "running"
9
9
  | "idle"
10
10
  | "requires_action"
11
+ | "recovering"
12
+ | "waiting_capacity"
13
+ | "paused"
11
14
  | "failed"
12
15
  | "cancelled";
13
16
 
@@ -209,6 +212,7 @@ export type ViewerHeartbeatRequest = { leaseEpoch: number };
209
212
  export type ViewerHeartbeatResponse = { alive: boolean };
210
213
 
211
214
  export type ReasoningEffort = "none" | "minimal" | "low" | "medium" | "high" | "xhigh";
215
+ export type GitCredentialProvider = "github" | "gitlab" | "azure_devops";
212
216
 
213
217
  export type RepositoryResourceRef = {
214
218
  kind: "repository";
@@ -216,6 +220,11 @@ export type RepositoryResourceRef = {
216
220
  ref: string;
217
221
  mountPath?: string | undefined;
218
222
  subpath?: string | undefined;
223
+ provider?: GitCredentialProvider | undefined;
224
+ repositoryId?: number | string | undefined;
225
+ installationId?: number | string | undefined;
226
+ projectId?: number | string | undefined;
227
+ connectionId?: string | undefined;
219
228
  githubInstallationId?: number | undefined;
220
229
  githubRepositoryId?: number | undefined;
221
230
  };
@@ -262,6 +271,99 @@ export type SessionMcpServerMetadata = {
262
271
  credentialVersion: number;
263
272
  };
264
273
 
274
+ export type ConnectionKind = "oauth2" | "api_key" | "app_install" | "delegated";
275
+ export type ConnectionStatus = "active" | "needs_reauth" | "revoked" | "error";
276
+
277
+ export type McpServerConnectionRef = {
278
+ connectionId?: string | undefined;
279
+ providerDomain: string;
280
+ kind?: ConnectionKind | undefined;
281
+ scopes?: string[] | undefined;
282
+ resource?: string | undefined;
283
+ subjectScope?: "workspace" | "subject" | undefined;
284
+ };
285
+
286
+ export type ConnectionMetadata = {
287
+ id: string;
288
+ accountId: string;
289
+ workspaceId: string;
290
+ subjectId: string | null;
291
+ providerDomain: string;
292
+ kind: ConnectionKind;
293
+ status: ConnectionStatus;
294
+ grantedScopes: string[];
295
+ expiresAt: string | null;
296
+ lastRefreshAt: string | null;
297
+ lastUsedAt: string | null;
298
+ lastError: string | null;
299
+ version: number;
300
+ metadata: Record<string, unknown>;
301
+ createdBySubjectId: string | null;
302
+ updatedBySubjectId: string | null;
303
+ createdAt: string;
304
+ updatedAt: string;
305
+ };
306
+
307
+ export type CreateConnectionRequest = {
308
+ providerDomain: string;
309
+ kind: ConnectionKind;
310
+ subjectId?: string | null | undefined;
311
+ credential: Record<string, unknown>;
312
+ grantedScopes?: string[] | undefined;
313
+ expiresAt?: string | null | undefined;
314
+ metadata?: Record<string, unknown> | undefined;
315
+ };
316
+
317
+ export type UpdateConnectionRequest = {
318
+ providerDomain?: string | undefined;
319
+ subjectId?: string | null | undefined;
320
+ kind?: ConnectionKind | undefined;
321
+ status?: ConnectionStatus | undefined;
322
+ credential?: Record<string, unknown> | undefined;
323
+ grantedScopes?: string[] | undefined;
324
+ expiresAt?: string | null | undefined;
325
+ metadata?: Record<string, unknown> | undefined;
326
+ };
327
+
328
+ export type ConnectionResponse = {
329
+ connection: ConnectionMetadata;
330
+ };
331
+
332
+ export type ListConnectionsResponse = {
333
+ connections: ConnectionMetadata[];
334
+ };
335
+
336
+ export type OAuthStartRequest = {
337
+ providerDomain?: string | undefined;
338
+ mcpUrl?: string | undefined;
339
+ resource?: string | undefined;
340
+ requestedScopes?: string[] | undefined;
341
+ returnPath?: string | undefined;
342
+ connectionId?: string | undefined;
343
+ oauthClient?:
344
+ | {
345
+ clientId: string;
346
+ clientSecret?: string | undefined;
347
+ tokenEndpointAuthMethod?: "none" | "client_secret_post" | "client_secret_basic" | undefined;
348
+ }
349
+ | undefined;
350
+ };
351
+
352
+ export type OAuthStartResponse = {
353
+ state: string;
354
+ authorizationUrl: string | null;
355
+ expiresAt: string;
356
+ };
357
+
358
+ export type IntegrationClientMetadata = {
359
+ client_id: string;
360
+ client_name: "OpenGeni";
361
+ redirect_uris: string[];
362
+ token_endpoint_auth_method: "none";
363
+ grant_types: Array<"authorization_code" | "refresh_token">;
364
+ response_types: ["code"];
365
+ };
366
+
265
367
  export type Session = {
266
368
  id: string;
267
369
  workspaceId: string;
@@ -278,30 +380,102 @@ export type Session = {
278
380
  metadata: Record<string, unknown>;
279
381
  model: string;
280
382
  sandboxBackend: SandboxBackend;
383
+ sandboxOs: SandboxOs;
384
+ sandboxGroupId: string;
385
+ activeSandboxId: string | null;
386
+ activeEpoch: number;
387
+ variableSetId: string | null;
388
+ /** @deprecated use variableSetId */
281
389
  environmentId: string | null;
390
+ // The rig + frozen rig version this session rides (M3). Both null for a
391
+ // rig-less session. Frozen at create; a later rig promote never moves them.
392
+ rigId: string | null;
393
+ rigVersionId: string | null;
282
394
  firstPartyMcpPermissions: string[] | null;
283
395
  mcpServers: SessionMcpServerMetadata[];
396
+ parentSessionId: string | null;
284
397
  createIdempotencyKey: string | null;
285
398
  temporalWorkflowId: string | null;
286
399
  activeTurnId: string | null;
400
+ queueVersion: number;
401
+ queueHeadPosition: number;
402
+ queueTailPosition: number;
403
+ controlState: "active" | "paused";
404
+ controlGeneration: number;
405
+ controlReason: string | null;
406
+ controlChangedBy: string | null;
407
+ controlChangedAt: string | null;
408
+ workspaceRunExceptionGeneration: number | null;
287
409
  lastSequence: number;
288
410
  /** Multi-account Codex (P1): the account this session is pinned to (null ⇒ follow workspace active). */
289
411
  codexPinnedCredentialId?: string | null;
290
412
  /** Multi-account Codex (P1): the account the most recent turn ran on (the "Running on:" indicator). */
291
413
  codexLastCredentialId?: string | null;
414
+ /** Personal (authenticated subject) workspace pin state, never workspace-global. */
415
+ pinned?: boolean;
416
+ /** Stable pin ordering key; null when this subject has not pinned the session. */
417
+ pinnedAt?: string | null;
418
+ /** Optimistic pin-state revision; zero represents an absent pin relation. */
419
+ pinVersion?: number;
420
+ /** Server-authoritative descendant counts populated by session-list reads. */
421
+ treeStats?:
422
+ | {
423
+ directChildren: number;
424
+ totalDescendants: number;
425
+ runningDescendants: number;
426
+ queuedDescendants: number;
427
+ attentionDescendants: number;
428
+ pausedDescendants: number;
429
+ failedDescendants: number;
430
+ }
431
+ | undefined;
292
432
  createdAt: string;
293
433
  updatedAt: string;
294
434
  };
295
435
 
436
+ export type SessionSummary = Session;
437
+
438
+ /** Canonical session-list page; pinned rows are excluded from ordinary pages. */
439
+ export type SessionListResponse = {
440
+ pinned: Session[];
441
+ sessions: Session[];
442
+ nextCursor: string | null;
443
+ };
444
+
445
+ export type UpdateSessionPinRequest = {
446
+ pinned: boolean;
447
+ expectedVersion?: number;
448
+ };
449
+
450
+ export type LineageNode = {
451
+ session: SessionSummary;
452
+ children: LineageNode[];
453
+ };
454
+
455
+ export type SessionLineageResponse = {
456
+ ancestors: SessionSummary[];
457
+ children: LineageNode[];
458
+ truncated: boolean;
459
+ };
460
+
296
461
  export type SessionTurnStatus =
297
462
  | "queued"
298
463
  | "running"
299
464
  | "requires_action"
465
+ | "recovering"
466
+ | "waiting_capacity"
300
467
  | "completed"
301
468
  | "failed"
302
- | "cancelled";
469
+ | "cancelled"
470
+ | "superseded";
303
471
 
304
- export type SessionTurnSource = "user" | "scheduled_task" | "api" | "goal";
472
+ export type SessionTurnSource =
473
+ | "user"
474
+ | "scheduled_task"
475
+ | "api"
476
+ | "goal"
477
+ | "system"
478
+ | "compaction";
305
479
 
306
480
  export type SessionTurn = {
307
481
  id: string;
@@ -318,7 +492,14 @@ export type SessionTurn = {
318
492
  model: string;
319
493
  reasoningEffort: ReasoningEffort;
320
494
  sandboxBackend: SandboxBackend;
495
+ sandboxOs: SandboxOs | null;
321
496
  metadata: Record<string, unknown>;
497
+ version: number;
498
+ executionGeneration: number;
499
+ activeAttemptId: string | null;
500
+ lineage: Record<string, unknown>;
501
+ cancelledBy?: string | null;
502
+ cancelReason?: string | null;
322
503
  startedAt: string | null;
323
504
  finishedAt: string | null;
324
505
  createdAt: string;
@@ -329,24 +510,33 @@ export const SESSION_EVENT_TYPES = [
329
510
  "session.created",
330
511
  "session.status.changed",
331
512
  "session.requiresAction",
513
+ "session.context.compaction.requested",
332
514
  "session.context.compacted",
515
+ "session.context.compaction.skipped",
333
516
  "session.context.cleared",
334
517
  "user.message",
335
- "user.interrupt",
518
+ "user.pause",
336
519
  "user.approvalDecision",
337
520
  "turn.queued",
338
- "turn.updated",
339
521
  "turn.started",
340
522
  "turn.completed",
341
523
  "turn.failed",
342
524
  "turn.cancelled",
343
- "turn.preempted",
525
+ "turn.superseded",
526
+ "turn.recovery.requested",
527
+ "turn.capacity_waiting",
344
528
  "agent.message.delta",
345
529
  "agent.message.completed",
346
530
  "agent.reasoning.delta",
347
531
  "agent.toolCall.created",
348
532
  "agent.toolCall.output",
533
+ "agent.model.usage",
534
+ "tool.auth_needed",
349
535
  "agent.updated",
536
+ "rig.setup.started",
537
+ "rig.setup.completed",
538
+ "rig.setup.skipped",
539
+ "rig.setup.failed",
350
540
  "sandbox.operation.started",
351
541
  "sandbox.operation.completed",
352
542
  "sandbox.operation.failed",
@@ -357,7 +547,20 @@ export const SESSION_EVENT_TYPES = [
357
547
  "goal.completed",
358
548
  "goal.paused",
359
549
  "goal.resumed",
550
+ "goal.cleared",
360
551
  "goal.continuation",
552
+ "system.update.pending",
553
+ "system.update.delivered",
554
+ "session.control.paused",
555
+ "session.control.resumed",
556
+ "session.control.steer_requested",
557
+ "workspace.inference.paused",
558
+ "workspace.inference.resumed",
559
+ "session.queue.prompt.cancelled",
560
+ "session.queue.history",
561
+ "turn.event.rejected_late",
562
+ "memory.saved",
563
+ "memory.corrected",
361
564
  // Channel-B desktop pixel-plane signals (mirror of contracts SessionEventType;
362
565
  // the contract-parity test asserts sorted equality).
363
566
  "stream.url.rotated",
@@ -378,6 +581,36 @@ export const SESSION_EVENT_TYPES = [
378
581
  "session.title_set",
379
582
  // Multi-account Codex (P1): the session's inference account changed.
380
583
  "codex.account.switched",
584
+ // OPE-21 metadata-only per-turn credential selection audit.
585
+ "codex.credential.selected",
586
+ // OPE-21 durable zero-capacity wait lifecycle. These are system/runtime
587
+ // events, never synthetic user messages.
588
+ "codex.capacity.waiting",
589
+ "codex.capacity.resumed",
590
+ "codex.capacity.superseded",
591
+ // Sandbox durability observability (mirror of contracts SessionEventType):
592
+ // box lifecycle + manifest-env drift, attributable from the DB alone.
593
+ "sandbox.box.created",
594
+ "sandbox.box.lost",
595
+ "sandbox.box.terminated",
596
+ "sandbox.box.snapshot",
597
+ "sandbox.env.drift",
598
+ // Active-sandbox pointer reconcile (issue #341; announce-only; mirror of contracts
599
+ // SessionEventType — the contract-parity test asserts sorted equality).
600
+ "session.route.reconciled",
601
+ // Workbench v2 turn-end workspace capture (announce-only; mirror of contracts
602
+ // SessionEventType — the contract-parity test asserts sorted equality).
603
+ "workspace.revision.captured",
604
+ "workspace.revision.degraded",
605
+ // Connected Machine op-outcome observability (announce-only, quiet; mirror of
606
+ // contracts SessionEventType — the contract-parity test asserts sorted equality).
607
+ "machine.op.failed",
608
+ "machine.op.recovered",
609
+ // Connected Machine link-plane observability (announce-only, quiet; mirror of
610
+ // contracts SessionEventType — the contract-parity test asserts sorted equality).
611
+ "machine.link.lost",
612
+ "machine.link.restored",
613
+ "machine.runner.restarted",
381
614
  ] as const;
382
615
 
383
616
  export type KnownSessionEventType = (typeof SESSION_EVENT_TYPES)[number];
@@ -399,6 +632,23 @@ export type SessionEvent = {
399
632
  occurredAt: string;
400
633
  clientEventId?: string | null | undefined;
401
634
  turnId?: string | null | undefined;
635
+ turnGeneration?: number | null | undefined;
636
+ turnAttemptId?: string | null | undefined;
637
+ turnAssociation?: "current" | "late_rejected" | "duplicate" | null | undefined;
638
+ duplicateOfEventId?: string | null | undefined;
639
+ duplicateReason?: string | null | undefined;
640
+ };
641
+
642
+ export type ToolAuthNeededPayload = {
643
+ serverId: string;
644
+ toolName?: string | null | undefined;
645
+ providerDomain: string;
646
+ connectionId?: string | null | undefined;
647
+ reason: "missing_connection" | "expired" | "insufficient_scope" | "refresh_failed";
648
+ scopes?: string[] | undefined;
649
+ resource?: string | undefined;
650
+ authorizationUrl?: string | undefined;
651
+ subjectId?: string | null | undefined;
402
652
  };
403
653
 
404
654
  // Payload shapes for the high-traffic event types. `SessionEvent.payload` is
@@ -466,7 +716,13 @@ export type SandboxCommandOutputDeltaPayload = {
466
716
  };
467
717
  export type FsChangeKind = "created" | "modified" | "deleted" | "renamed";
468
718
  export type FsChangedPayload = {
469
- changes: { path: string; kind: FsChangeKind; isDir: boolean; sizeBytes: number | null; oldPath?: string | undefined }[];
719
+ changes: {
720
+ path: string;
721
+ kind: FsChangeKind;
722
+ isDir: boolean;
723
+ sizeBytes: number | null;
724
+ oldPath?: string | undefined;
725
+ }[];
470
726
  source: "write" | "watch" | "agent";
471
727
  revision: number;
472
728
  leaseEpoch: number;
@@ -481,9 +737,24 @@ export type GitChangedPayload = {
481
737
  revision: number;
482
738
  leaseEpoch: number;
483
739
  };
484
- export type TerminalPtyStartedPayload = { ptyId: string; cols: number; rows: number; shell: string; cwd: string };
485
- export type TerminalPtyOutputDeltaPayload = { ptyId: string; stream: "stdout" | "stderr"; chunk: string; seq: number };
486
- export type TerminalPtyExitedPayload = { ptyId: string; exitCode: number | null; reason: "exit" | "killed" | "owner_gone" | "timeout" };
740
+ export type TerminalPtyStartedPayload = {
741
+ ptyId: string;
742
+ cols: number;
743
+ rows: number;
744
+ shell: string;
745
+ cwd: string;
746
+ };
747
+ export type TerminalPtyOutputDeltaPayload = {
748
+ ptyId: string;
749
+ stream: "stdout" | "stderr";
750
+ chunk: string;
751
+ seq: number;
752
+ };
753
+ export type TerminalPtyExitedPayload = {
754
+ ptyId: string;
755
+ exitCode: number | null;
756
+ reason: "exit" | "killed" | "owner_gone" | "timeout";
757
+ };
487
758
 
488
759
  // A2 FileSystem request/response.
489
760
  export type FsNodeType = "file" | "dir" | "symlink" | "other";
@@ -498,31 +769,115 @@ export type FsTreeNode = {
498
769
  truncated: boolean;
499
770
  };
500
771
  export type FsEncoding = "utf8" | "base64";
501
- export type FsListRequest = { path?: string; depth?: number; maxEntries?: number; includeHidden?: boolean };
772
+ export type FsListRequest = {
773
+ path?: string;
774
+ depth?: number;
775
+ maxEntries?: number;
776
+ includeHidden?: boolean;
777
+ };
502
778
  export type FsListResponse = { root: FsTreeNode; revision: number; truncated: boolean };
503
779
  export type FsReadRequest = { path: string; encoding?: FsEncoding; maxBytes?: number };
504
- export type FsReadResponse = { path: string; encoding: FsEncoding; content: string; sizeBytes: number; truncated: boolean; isBinary: boolean; revision: number };
505
- export type FsWriteRequest = { path: string; encoding?: FsEncoding; content: string; overwrite?: boolean; createParents?: boolean };
780
+ export type FsReadResponse = {
781
+ path: string;
782
+ encoding: FsEncoding;
783
+ content: string;
784
+ sizeBytes: number;
785
+ truncated: boolean;
786
+ isBinary: boolean;
787
+ revision: number;
788
+ };
789
+ export type FsWriteRequest = {
790
+ path: string;
791
+ encoding?: FsEncoding;
792
+ content: string;
793
+ overwrite?: boolean;
794
+ createParents?: boolean;
795
+ };
506
796
  export type FsWriteResponse = { path: string; sizeBytes: number; revision: number };
507
797
  export type FsDeleteRequest = { path: string; recursive?: boolean };
508
798
  export type FsDeleteResponse = { revision: number };
509
- export type FsMoveRequest = { path: string; newPath: string; overwrite?: boolean; createParents?: boolean };
799
+ export type FsMoveRequest = {
800
+ path: string;
801
+ newPath: string;
802
+ overwrite?: boolean;
803
+ createParents?: boolean;
804
+ };
510
805
  export type FsMoveResponse = { path: string; newPath: string; revision: number };
511
806
  export type FsMkdirRequest = { path: string; recursive?: boolean };
512
807
  export type FsMkdirResponse = { path: string; revision: number };
513
808
 
514
809
  // A2 Git request/response (the Pierre-diff feed).
515
- export type GitFileStatusCode = "added" | "modified" | "deleted" | "renamed" | "copied" | "untracked" | "ignored" | "conflicted" | "typechange";
516
- export type GitFileStatus = { path: string; oldPath: string | null; index: GitFileStatusCode | null; worktree: GitFileStatusCode | null; isConflicted: boolean };
810
+ export type GitFileStatusCode =
811
+ | "added"
812
+ | "modified"
813
+ | "deleted"
814
+ | "renamed"
815
+ | "copied"
816
+ | "untracked"
817
+ | "ignored"
818
+ | "conflicted"
819
+ | "typechange";
820
+ export type GitFileStatus = {
821
+ path: string;
822
+ oldPath: string | null;
823
+ index: GitFileStatusCode | null;
824
+ worktree: GitFileStatusCode | null;
825
+ isConflicted: boolean;
826
+ };
517
827
  export type GitStatusRequest = { path?: string };
518
- export type GitStatusResponse = { isRepo: boolean; head: string | null; detached: boolean; upstream: string | null; ahead: number; behind: number; files: GitFileStatus[]; revision: number };
828
+ export type GitStatusResponse = {
829
+ isRepo: boolean;
830
+ head: string | null;
831
+ detached: boolean;
832
+ upstream: string | null;
833
+ ahead: number;
834
+ behind: number;
835
+ files: GitFileStatus[];
836
+ revision: number;
837
+ };
519
838
  export type GitDiffLineType = "context" | "add" | "del" | "meta";
520
- export type GitDiffLine = { type: GitDiffLineType; oldNo: number | null; newNo: number | null; text: string };
521
- export type GitDiffHunk = { oldStart: number; oldLines: number; newStart: number; newLines: number; header: string; lines: GitDiffLine[] };
522
- export type GitFileDiff = { path: string; oldPath: string | null; status: GitFileStatusCode; isBinary: boolean; isImage: boolean; additions: number; deletions: number; hunks: GitDiffHunk[]; truncated: boolean };
523
- export type GitDiffRequest = { path?: string; staged?: boolean; fromRef?: string; toRef?: string; pathspec?: string[]; contextLines?: number; maxBytesPerFile?: number };
839
+ export type GitDiffLine = {
840
+ type: GitDiffLineType;
841
+ oldNo: number | null;
842
+ newNo: number | null;
843
+ text: string;
844
+ };
845
+ export type GitDiffHunk = {
846
+ oldStart: number;
847
+ oldLines: number;
848
+ newStart: number;
849
+ newLines: number;
850
+ header: string;
851
+ lines: GitDiffLine[];
852
+ };
853
+ export type GitFileDiff = {
854
+ path: string;
855
+ oldPath: string | null;
856
+ status: GitFileStatusCode;
857
+ isBinary: boolean;
858
+ isImage: boolean;
859
+ additions: number;
860
+ deletions: number;
861
+ hunks: GitDiffHunk[];
862
+ truncated: boolean;
863
+ };
864
+ export type GitDiffRequest = {
865
+ path?: string;
866
+ staged?: boolean;
867
+ fromRef?: string;
868
+ toRef?: string;
869
+ pathspec?: string[];
870
+ contextLines?: number;
871
+ maxBytesPerFile?: number;
872
+ };
524
873
  export type GitDiffResponse = { files: GitFileDiff[]; revision: number };
525
- export type GitLogRequest = { path?: string; ref?: string; maxCount?: number; skip?: number; pathspec?: string[] };
874
+ export type GitLogRequest = {
875
+ path?: string;
876
+ ref?: string;
877
+ maxCount?: number;
878
+ skip?: number;
879
+ pathspec?: string[];
880
+ };
526
881
  export type GitCommit = {
527
882
  sha: string;
528
883
  shortSha: string;
@@ -534,12 +889,139 @@ export type GitCommit = {
534
889
  refs: string[];
535
890
  };
536
891
  export type GitLogResponse = { commits: GitCommit[]; hasMore: boolean };
537
- export type GitShowRequest = { path?: string; ref: string; filePath?: string; encoding?: FsEncoding; maxBytesPerFile?: number };
538
- export type GitShowResponse = { commit: GitCommit | null; files: GitFileDiff[]; blob: { content: string; encoding: FsEncoding; sizeBytes: number; truncated: boolean } | null; revision: number };
892
+ export type GitShowRequest = {
893
+ path?: string;
894
+ ref: string;
895
+ filePath?: string;
896
+ encoding?: FsEncoding;
897
+ maxBytesPerFile?: number;
898
+ };
899
+ export type GitShowResponse = {
900
+ commit: GitCommit | null;
901
+ files: GitFileDiff[];
902
+ blob: { content: string; encoding: FsEncoding; sizeBytes: number; truncated: boolean } | null;
903
+ revision: number;
904
+ };
905
+
906
+ // Workbench v2 turn-end capture (mirror of `@opengeni/contracts` WorkspaceCapture*
907
+ // + the M2 read-API response shapes, dossier §10.3). Reuses FsTreeNode /
908
+ // GitFileStatus / GitFileDiff / GitFileStatusCode / FsEncoding above.
909
+ export type WorkspaceCaptureFile = {
910
+ path: string;
911
+ status: GitFileStatusCode;
912
+ hash: string | null;
913
+ baseHash: string | null;
914
+ contentRef: string | null;
915
+ sizeBytes: number;
916
+ isBinary: boolean;
917
+ tooLarge: boolean;
918
+ deleted: boolean;
919
+ };
920
+ export type WorkspaceCaptureRepo = {
921
+ root: string;
922
+ head: string | null;
923
+ detached: boolean;
924
+ upstream: string | null;
925
+ ahead: number;
926
+ behind: number;
927
+ status: GitFileStatus[];
928
+ diff: GitFileDiff[];
929
+ };
930
+ export type WorkspaceCaptureDegradedReason =
931
+ | "repository_discovery_command_failed"
932
+ | "repository_discovery_timed_out"
933
+ | "repository_discovery_result_limit_exceeded";
934
+ export type WorkspaceCaptureStats = {
935
+ repoCount: number;
936
+ fileCount: number;
937
+ additions: number;
938
+ deletions: number;
939
+ totalBytes: number;
940
+ tooLargeCount: number;
941
+ binaryCount: number;
942
+ treeEntryCount: number;
943
+ treeTruncated: boolean;
944
+ durationMs: number;
945
+ fingerprint?: string;
946
+ };
947
+ export type WorkspaceCaptureManifest = {
948
+ version: 1;
949
+ revision: number;
950
+ capturedAt: string;
951
+ turnId: string | null;
952
+ leaseEpoch: number;
953
+ treeIndex: FsTreeNode;
954
+ treeTruncated: boolean;
955
+ repos: WorkspaceCaptureRepo[];
956
+ files: WorkspaceCaptureFile[];
957
+ stats: WorkspaceCaptureStats;
958
+ };
959
+ export type WorkspaceRevisionCapturedPayload = {
960
+ revision: number;
961
+ turnId: string | null;
962
+ capturedAt: string;
963
+ leaseEpoch: number;
964
+ stats: WorkspaceCaptureStats;
965
+ };
966
+ export type WorkspaceRevisionDegradedPayload = {
967
+ revision: number;
968
+ turnId: string | null;
969
+ capturedAt: string;
970
+ leaseEpoch: number;
971
+ reason: WorkspaceCaptureDegradedReason;
972
+ };
973
+ export type WorkspaceCaptureSignedUrl = { url: string; expiresAt: string };
974
+ // GET …/workspace/capture. Exactly one of manifest/manifestUrl is non-null.
975
+ export type GetWorkspaceCaptureResponse =
976
+ | {
977
+ available: false;
978
+ degradedReason?: WorkspaceCaptureDegradedReason | null;
979
+ revision?: number | null;
980
+ capturedAt?: string | null;
981
+ turnId?: string | null;
982
+ leaseEpoch?: number | null;
983
+ }
984
+ | {
985
+ available: true;
986
+ revision: number;
987
+ capturedAt: string;
988
+ turnId: string | null;
989
+ leaseEpoch: number;
990
+ sizeBytes: number;
991
+ stats: WorkspaceCaptureStats;
992
+ manifest: WorkspaceCaptureManifest | null;
993
+ manifestUrl: WorkspaceCaptureSignedUrl | null;
994
+ };
995
+ // GET …/workspace/capture/file. content inline (≤256KB) OR contentUrl OR marker
996
+ // only (tooLarge / missing blob).
997
+ export type GetWorkspaceCaptureFileResponse = {
998
+ path: string;
999
+ revision: number;
1000
+ status: GitFileStatusCode;
1001
+ hash: string | null;
1002
+ baseHash: string | null;
1003
+ sizeBytes: number;
1004
+ isBinary: boolean;
1005
+ tooLarge: boolean;
1006
+ encoding: FsEncoding | null;
1007
+ content: string | null;
1008
+ contentUrl: WorkspaceCaptureSignedUrl | null;
1009
+ };
539
1010
 
540
1011
  // A2 Terminal exec + PTY.
541
- export type TerminalExecRequest = { command: string; cwd?: string; timeoutMs?: number; emitStream?: boolean };
542
- export type TerminalExecResponse = { stdout: string; stderr: string; exitCode: number | null; running: boolean; wallTimeSeconds: number };
1012
+ export type TerminalExecRequest = {
1013
+ command: string;
1014
+ cwd?: string;
1015
+ timeoutMs?: number;
1016
+ emitStream?: boolean;
1017
+ };
1018
+ export type TerminalExecResponse = {
1019
+ stdout: string;
1020
+ stderr: string;
1021
+ exitCode: number | null;
1022
+ running: boolean;
1023
+ wallTimeSeconds: number;
1024
+ };
543
1025
  export type PtyOpenRequest = { cols?: number; rows?: number; cwd?: string; shell?: string };
544
1026
  export type PtyOpenResponse = { ptyId: string; streamVia: "sse-events"; supportsInput: boolean };
545
1027
  export type PtyWriteRequest = { ptyId: string; data: string };
@@ -606,7 +1088,11 @@ export type ScheduledTask = {
606
1088
  overlapPolicy: ScheduledTaskOverlapPolicy;
607
1089
  agentConfig: ScheduledTaskAgentConfig;
608
1090
  reusableSessionId: string | null;
1091
+ variableSetId: string | null;
1092
+ /** @deprecated use variableSetId */
609
1093
  environmentId: string | null;
1094
+ // The rig each run binds to (M3); active version resolved per fire. Null ⇒ rig-less.
1095
+ rigId: string | null;
610
1096
  metadata: Record<string, unknown>;
611
1097
  createdAt: string;
612
1098
  updatedAt: string;
@@ -631,7 +1117,12 @@ export type CreateSessionRequest = {
631
1117
  // Host working directory for a connected-machine target (the agent runs here;
632
1118
  // default = the machine's launch dir). Ignored for managed sandboxes.
633
1119
  workingDir?: string | undefined;
1120
+ variableSetId?: string | undefined;
1121
+ /** @deprecated use variableSetId */
634
1122
  environmentId?: string | undefined;
1123
+ // The rig to bind this session to (M3). Its active version is frozen onto the
1124
+ // session at create. Omitted ⇒ the workspace default rig when set, else rig-less.
1125
+ rigId?: string | undefined;
635
1126
  goal?: GoalSpec | undefined;
636
1127
  clientEventId?: string | undefined;
637
1128
  // Workspace-scoped CREATE idempotency key: forward a STABLE value to make a
@@ -681,12 +1172,19 @@ export const KNOWN_PERMISSIONS = [
681
1172
  "github:manage",
682
1173
  "github:use",
683
1174
  "api_keys:manage",
1175
+ "connections:read",
1176
+ "connections:write",
684
1177
  "environments:manage",
685
1178
  "environments:use",
1179
+ "variable-sets:manage",
1180
+ "variable-sets:use",
686
1181
  "mcp_servers:attach",
1182
+ "toolspace:call",
687
1183
  "goals:manage",
688
1184
  "enrollments:read",
689
1185
  "enrollments:manage",
1186
+ "rigs:use",
1187
+ "rigs:manage",
690
1188
  ] as const;
691
1189
 
692
1190
  export type KnownPermission = (typeof KNOWN_PERMISSIONS)[number];
@@ -762,8 +1260,18 @@ export type CodexUsagePayload = {
762
1260
  fetchedAt: string;
763
1261
  /** Present only on an auth/refresh failure path. */
764
1262
  reason?: "needs_relogin";
765
- additionalLimits?: Array<{ limitName: string; meteredFeature: string; fiveHour: CodexUsageWindow | null; weekly: CodexUsageWindow | null }>;
766
- credits?: { hasCredits: boolean; unlimited: boolean; overageLimitReached: boolean; balance: string };
1263
+ additionalLimits?: Array<{
1264
+ limitName: string;
1265
+ meteredFeature: string;
1266
+ fiveHour: CodexUsageWindow | null;
1267
+ weekly: CodexUsageWindow | null;
1268
+ }>;
1269
+ credits?: {
1270
+ hasCredits: boolean;
1271
+ unlimited: boolean;
1272
+ overageLimitReached: boolean;
1273
+ balance: string;
1274
+ };
767
1275
  };
768
1276
 
769
1277
  /** One connected Codex (ChatGPT) account in a workspace (multi-account P1). Metadata only. */
@@ -828,7 +1336,10 @@ export type CodexConnectPoll =
828
1336
  | { status: "connected"; plan?: string | null; accountId?: string; isActive?: boolean };
829
1337
 
830
1338
  /** Remaining usage/limits for one account. `usage` is the normalized P2 payload. */
831
- export type CodexUsage = { status: "ok" | "limit_reached" | "error" | "no-data"; usage: CodexUsagePayload | null };
1339
+ export type CodexUsage = {
1340
+ status: "ok" | "limit_reached" | "error" | "no-data";
1341
+ usage: CodexUsagePayload | null;
1342
+ };
832
1343
 
833
1344
  /** Batched live-refresh response, keyed by credential id; each entry independently statused. */
834
1345
  export type CodexUsageMap = Record<string, CodexUsage>;
@@ -907,10 +1418,31 @@ export type Workspace = {
907
1418
  externalSource: string | null;
908
1419
  externalId: string | null;
909
1420
  agentInstructions: string | null;
1421
+ settings: Record<string, unknown>;
1422
+ inferenceState?: "active" | "paused";
1423
+ inferenceGeneration?: number;
1424
+ inferenceReason?: string | null;
1425
+ inferenceChangedBy?: string | null;
1426
+ inferenceChangedAt?: string | null;
1427
+ defaultRigId?: string | null;
910
1428
  createdAt: string;
911
1429
  updatedAt: string;
912
1430
  };
913
1431
 
1432
+ export type WorkspaceSettings = {
1433
+ memoryEnabled?: boolean | undefined;
1434
+ [key: string]: unknown;
1435
+ };
1436
+
1437
+ export type UpdateWorkspaceSettingsRequest = {
1438
+ memoryEnabled?: boolean | undefined;
1439
+ [key: string]: unknown;
1440
+ };
1441
+
1442
+ export type SetWorkspaceDefaultRigRequest = {
1443
+ rigId: string | null;
1444
+ };
1445
+
914
1446
  export type CreateWorkspaceRequest = {
915
1447
  accountId?: string | undefined;
916
1448
  name: string;
@@ -1022,24 +1554,80 @@ export type UpdateSessionRequest = {
1022
1554
 
1023
1555
  /** Outcome of a manual /compact trigger. */
1024
1556
  export type CompactSessionContextResult = {
1025
- /**
1026
- * queued: a client-side (Azure) compaction will run before the next turn.
1027
- * noop: nothing to do (server-managed provider, mode off, or no history).
1028
- */
1029
- status: "queued" | "noop";
1557
+ /** pending waits for the current safe boundary; completed ran while idle. */
1558
+ status: "pending" | "completed" | "noop";
1030
1559
  message: string;
1031
1560
  };
1032
1561
 
1033
1562
  // --- Turn queue --------------------------------------------------------------
1034
1563
 
1035
- export type UpdateSessionTurnRequest = {
1036
- prompt?: string | undefined;
1037
- resources?: ResourceRef[] | undefined;
1038
- tools?: ToolRef[] | undefined;
1039
- model?: string | undefined;
1040
- reasoningEffort?: ReasoningEffort | undefined;
1041
- sandboxBackend?: SandboxBackend | undefined;
1042
- metadata?: Record<string, unknown> | undefined;
1564
+ export type SessionQueueSnapshot = {
1565
+ version: number;
1566
+ controlState: "active" | "paused";
1567
+ controlGeneration: number;
1568
+ workspaceInferenceState: "active" | "paused";
1569
+ workspaceInferenceGeneration: number;
1570
+ workspaceRunExceptionGeneration: number | null;
1571
+ items: SessionTurn[];
1572
+ };
1573
+
1574
+ export type SystemUpdateClassification = "success" | "failure" | "action_required" | "info";
1575
+
1576
+ export type SessionSystemUpdateKind =
1577
+ | "child_session_update"
1578
+ | "scheduled_wake"
1579
+ | "lifecycle_event"
1580
+ | "runtime_notice";
1581
+
1582
+ export type SessionSystemUpdateState =
1583
+ | "pending"
1584
+ | "deferred"
1585
+ | "delivered"
1586
+ | "cancelled"
1587
+ | "failed";
1588
+
1589
+ export type SessionSystemUpdate = {
1590
+ id: string;
1591
+ sessionId: string;
1592
+ kind: SessionSystemUpdateKind;
1593
+ classification: SystemUpdateClassification;
1594
+ sourceId: string;
1595
+ dedupeKey: string;
1596
+ summary: string;
1597
+ payload: Record<string, unknown>;
1598
+ lineage: Record<string, unknown>;
1599
+ state: SessionSystemUpdateState;
1600
+ deliveredTurnId: string | null;
1601
+ deliveredAt: string | null;
1602
+ createdAt: string;
1603
+ };
1604
+
1605
+ export type SessionControlResponse = {
1606
+ operationId: string;
1607
+ event: SessionEvent;
1608
+ controlState: "active" | "paused";
1609
+ controlGeneration: number;
1610
+ expectedActiveTurnId: string | null;
1611
+ expectedExecutionGeneration: number | null;
1612
+ expectedAttemptId: string | null;
1613
+ deliveryEventId: string | null;
1614
+ shouldSignalControl: boolean;
1615
+ shouldWake: boolean;
1616
+ };
1617
+
1618
+ export type WorkspaceInferenceControlResponse = {
1619
+ operationId: string;
1620
+ state: "active" | "paused";
1621
+ generation: number;
1622
+ affectedSessionIds: string[];
1623
+ controlSessionIds: string[];
1624
+ exceptionSessionIds: string[];
1625
+ };
1626
+
1627
+ export type SessionQueueMutationResponse = {
1628
+ snapshot: SessionQueueSnapshot;
1629
+ events: SessionEvent[];
1630
+ shouldWake: boolean;
1043
1631
  };
1044
1632
 
1045
1633
  // --- Scheduled tasks: requests + runs ----------------------------------------
@@ -1063,7 +1651,11 @@ export type CreateScheduledTaskRequest = {
1063
1651
  overlapPolicy?: ScheduledTaskOverlapPolicy | undefined;
1064
1652
  agentConfig: ScheduledTaskAgentConfigInput;
1065
1653
  status?: ScheduledTaskStatus | undefined;
1654
+ variableSetId?: string | null | undefined;
1655
+ /** @deprecated use variableSetId */
1066
1656
  environmentId?: string | null | undefined;
1657
+ // The rig each run binds to (M3); active version resolved per fire.
1658
+ rigId?: string | null | undefined;
1067
1659
  metadata?: Record<string, unknown> | undefined;
1068
1660
  };
1069
1661
 
@@ -1074,7 +1666,11 @@ export type UpdateScheduledTaskRequest = {
1074
1666
  overlapPolicy?: ScheduledTaskOverlapPolicy | undefined;
1075
1667
  agentConfig?: ScheduledTaskAgentConfigInput | undefined;
1076
1668
  status?: ScheduledTaskStatus | undefined;
1669
+ variableSetId?: string | null | undefined;
1670
+ /** @deprecated use variableSetId */
1077
1671
  environmentId?: string | null | undefined;
1672
+ // The rig each run binds to (M3); active version resolved per fire.
1673
+ rigId?: string | null | undefined;
1078
1674
  metadata?: Record<string, unknown> | undefined;
1079
1675
  };
1080
1676
 
@@ -1098,43 +1694,171 @@ export type ScheduledTaskRun = {
1098
1694
  updatedAt: string;
1099
1695
  };
1100
1696
 
1101
- // --- Environments -------------------------------------------------------------
1697
+ // --- VariableSets -------------------------------------------------------------
1102
1698
 
1103
1699
  /**
1104
1700
  * Variable values are write-only by design: the API never returns a value, so
1105
1701
  * reads expose name + version metadata only. Values are decrypted exclusively
1106
1702
  * inside the worker at sandbox materialization time.
1107
1703
  */
1108
- export type WorkspaceEnvironmentVariableMetadata = {
1704
+ export type VariableSetVariableMetadata = {
1109
1705
  name: string;
1110
1706
  version: number;
1111
1707
  createdAt: string;
1112
1708
  updatedAt: string;
1113
1709
  };
1114
1710
 
1115
- export type WorkspaceEnvironment = {
1711
+ export type VariableSet = {
1116
1712
  id: string;
1117
1713
  accountId: string;
1118
1714
  workspaceId: string;
1119
1715
  name: string;
1120
1716
  description: string | null;
1121
- variables: WorkspaceEnvironmentVariableMetadata[];
1717
+ variables: VariableSetVariableMetadata[];
1122
1718
  createdAt: string;
1123
1719
  updatedAt: string;
1124
1720
  };
1125
1721
 
1126
- export type CreateWorkspaceEnvironmentRequest = {
1722
+ /** @deprecated use VariableSetVariableMetadata */
1723
+ export type WorkspaceEnvironmentVariableMetadata = VariableSetVariableMetadata;
1724
+
1725
+ /** @deprecated use VariableSet */
1726
+ export type WorkspaceEnvironment = VariableSet;
1727
+
1728
+ export type CreateVariableSetRequest = {
1127
1729
  name: string;
1128
1730
  description?: string | undefined;
1129
1731
  /** Initial variables. Values are write-only: they never come back on reads. */
1130
1732
  variables?: { name: string; value: string }[] | undefined;
1131
1733
  };
1132
1734
 
1133
- export type UpdateWorkspaceEnvironmentRequest = {
1735
+ /** @deprecated use CreateVariableSetRequest */
1736
+ export type CreateWorkspaceEnvironmentRequest = CreateVariableSetRequest;
1737
+
1738
+ export type UpdateVariableSetRequest = {
1134
1739
  name?: string | undefined;
1135
1740
  description?: string | null | undefined;
1136
1741
  };
1137
1742
 
1743
+ /** @deprecated use UpdateVariableSetRequest */
1744
+ export type UpdateWorkspaceEnvironmentRequest = UpdateVariableSetRequest;
1745
+
1746
+ export type SetVariableSetVariableRequest = {
1747
+ value: string;
1748
+ };
1749
+
1750
+ /** @deprecated use SetVariableSetVariableRequest */
1751
+ export type SetWorkspaceEnvironmentVariableRequest = SetVariableSetVariableRequest;
1752
+
1753
+ // --- Rigs ---------------------------------------------------------------------
1754
+ // Workspace-scoped, versioned sandbox machine definitions. Versions are
1755
+ // append-only and content-immutable; exactly one is active per rig.
1756
+
1757
+ export type RigCheck = {
1758
+ name: string;
1759
+ command: string;
1760
+ };
1761
+
1762
+ export type RigVersion = {
1763
+ id: string;
1764
+ rigId: string;
1765
+ version: number;
1766
+ image: string | null;
1767
+ setupScript: string | null;
1768
+ checks: RigCheck[];
1769
+ credentialHooks: string[];
1770
+ defaultVariableSetIds: string[];
1771
+ changelog: string | null;
1772
+ createdBy: string | null;
1773
+ active: boolean;
1774
+ createdAt: string;
1775
+ };
1776
+
1777
+ export type RigVerificationHealth = {
1778
+ checkHealth: "passing" | "failing" | "unknown";
1779
+ lastVerifiedAt: string | null;
1780
+ };
1781
+
1782
+ export type Rig = {
1783
+ id: string;
1784
+ accountId: string;
1785
+ workspaceId: string;
1786
+ name: string;
1787
+ description: string | null;
1788
+ createdBy: string | null;
1789
+ activeVersion: RigVersion | null;
1790
+ activeVersionHealth?: RigVerificationHealth | null;
1791
+ versionCount: number;
1792
+ createdAt: string;
1793
+ updatedAt: string;
1794
+ };
1795
+
1796
+ export type RigChangeKind = "setup_append" | "definition_edit";
1797
+
1798
+ export type RigChangeStatus = "proposed" | "verifying" | "merged" | "rejected" | "failed";
1799
+
1800
+ export type RigCheckResult = {
1801
+ name: string;
1802
+ command: string;
1803
+ exitCode: number | null;
1804
+ output?: string | undefined;
1805
+ };
1806
+
1807
+ export type RigChangeVerification = {
1808
+ startedAt?: string | undefined;
1809
+ finishedAt?: string | undefined;
1810
+ log?: string | undefined;
1811
+ checkResults?: RigCheckResult[] | undefined;
1812
+ [key: string]: unknown;
1813
+ };
1814
+
1815
+ export type RigChange = {
1816
+ id: string;
1817
+ rigId: string;
1818
+ baseVersionId: string | null;
1819
+ kind: RigChangeKind;
1820
+ payload: Record<string, unknown>;
1821
+ status: RigChangeStatus;
1822
+ proposedBy: string | null;
1823
+ verification: RigChangeVerification | null;
1824
+ resultVersionId: string | null;
1825
+ createdAt: string;
1826
+ updatedAt: string;
1827
+ };
1828
+
1829
+ export type CreateRigRequest = {
1830
+ name: string;
1831
+ description?: string | undefined;
1832
+ image?: string | undefined;
1833
+ setupScript?: string | undefined;
1834
+ checks?: RigCheck[] | undefined;
1835
+ credentialHooks?: string[] | undefined;
1836
+ defaultVariableSetIds?: string[] | undefined;
1837
+ };
1838
+
1839
+ export type UpdateRigRequest = {
1840
+ name?: string | undefined;
1841
+ description?: string | null | undefined;
1842
+ };
1843
+
1844
+ export type RigSetupAppendPayload = {
1845
+ command: string;
1846
+ note?: string | undefined;
1847
+ };
1848
+
1849
+ export type RigDefinitionEditPayload = {
1850
+ image?: string | null | undefined;
1851
+ setupScript?: string | null | undefined;
1852
+ checks?: RigCheck[] | undefined;
1853
+ credentialHooks?: string[] | undefined;
1854
+ defaultVariableSetIds?: string[] | undefined;
1855
+ changelog?: string | null | undefined;
1856
+ };
1857
+
1858
+ export type ProposeRigChangeRequest =
1859
+ | { kind: "setup_append"; payload: RigSetupAppendPayload }
1860
+ | { kind: "definition_edit"; payload: RigDefinitionEditPayload };
1861
+
1138
1862
  // --- Files ---------------------------------------------------------------------
1139
1863
 
1140
1864
  export type FileStatus = "pending_upload" | "ready" | "failed" | "expired" | "deleted";
@@ -1194,6 +1918,16 @@ export type UploadFileInput = {
1194
1918
  // --- Documents -------------------------------------------------------------------
1195
1919
 
1196
1920
  export type DocumentStatus = "queued" | "indexing" | "ready" | "failed";
1921
+ export type KnowledgeSourceKind =
1922
+ | "manual_upload"
1923
+ | "meeting_transcript"
1924
+ | "repository"
1925
+ | "email"
1926
+ | "chat"
1927
+ | "document"
1928
+ | "web"
1929
+ | "other";
1930
+ export type DocumentSearchMode = "hybrid" | "vector" | "keyword";
1197
1931
 
1198
1932
  export type DocumentBase = {
1199
1933
  id: string;
@@ -1214,6 +1948,15 @@ export type Document = {
1214
1948
  parser: string;
1215
1949
  chunkCount: number;
1216
1950
  error: string | null;
1951
+ sourceKind: KnowledgeSourceKind;
1952
+ sourceUri: string | null;
1953
+ sourceExternalId: string | null;
1954
+ sourceTitle: string | null;
1955
+ sourceAuthor: string | null;
1956
+ sourceCreatedAt: string | null;
1957
+ sourceUpdatedAt: string | null;
1958
+ sourceVersion: string | null;
1959
+ aclTags: string[];
1217
1960
  createdAt: string;
1218
1961
  updatedAt: string;
1219
1962
  };
@@ -1227,8 +1970,20 @@ export type DocumentSearchResult = {
1227
1970
  title: string;
1228
1971
  text: string;
1229
1972
  score: number;
1973
+ matchType: DocumentSearchMode;
1974
+ vectorScore: number | null;
1975
+ keywordScore: number | null;
1230
1976
  chunkIndex: number;
1231
1977
  metadata: Record<string, unknown>;
1978
+ sourceKind: KnowledgeSourceKind;
1979
+ sourceUri: string | null;
1980
+ sourceExternalId: string | null;
1981
+ sourceTitle: string | null;
1982
+ sourceAuthor: string | null;
1983
+ sourceCreatedAt: string | null;
1984
+ sourceUpdatedAt: string | null;
1985
+ sourceVersion: string | null;
1986
+ aclTags: string[];
1232
1987
  };
1233
1988
 
1234
1989
  export type CreateDocumentBaseRequest = {
@@ -1236,8 +1991,26 @@ export type CreateDocumentBaseRequest = {
1236
1991
  description?: string | undefined;
1237
1992
  };
1238
1993
 
1994
+ export type AddDocumentRequest = {
1995
+ fileId: string;
1996
+ title?: string | undefined;
1997
+ sourceKind?: KnowledgeSourceKind | undefined;
1998
+ sourceUri?: string | undefined;
1999
+ sourceExternalId?: string | undefined;
2000
+ sourceTitle?: string | undefined;
2001
+ sourceAuthor?: string | undefined;
2002
+ sourceCreatedAt?: string | undefined;
2003
+ sourceUpdatedAt?: string | undefined;
2004
+ sourceVersion?: string | undefined;
2005
+ aclTags?: string[] | undefined;
2006
+ };
2007
+
1239
2008
  export type DocumentSearchRequest = {
1240
2009
  query: string;
2010
+ baseIds?: string[] | undefined;
2011
+ mode?: DocumentSearchMode | undefined;
2012
+ sourceKinds?: KnowledgeSourceKind[] | undefined;
2013
+ aclTags?: string[] | undefined;
1241
2014
  limit?: number | undefined;
1242
2015
  };
1243
2016
 
@@ -1245,6 +2018,106 @@ export type DocumentSearchResponse = {
1245
2018
  results: DocumentSearchResult[];
1246
2019
  };
1247
2020
 
2021
+ export type KnowledgeMemoryStatus =
2022
+ | "proposed"
2023
+ | "approved"
2024
+ | "rejected"
2025
+ | "active"
2026
+ | "superseded"
2027
+ | "archived";
2028
+ export type KnowledgeMemoryKind =
2029
+ | "semantic"
2030
+ | "episodic"
2031
+ | "procedural"
2032
+ | "decision"
2033
+ | "preference";
2034
+
2035
+ export type KnowledgeSourceRef = {
2036
+ kind: "document_chunk" | "document" | "session_event" | "memory" | "external";
2037
+ id: string;
2038
+ uri?: string | undefined;
2039
+ title?: string | undefined;
2040
+ metadata?: Record<string, unknown> | undefined;
2041
+ };
2042
+
2043
+ export type KnowledgeMemory = {
2044
+ id: string;
2045
+ workspaceId: string;
2046
+ status: KnowledgeMemoryStatus;
2047
+ kind: KnowledgeMemoryKind;
2048
+ scope: string;
2049
+ text: string;
2050
+ sourceRefs: KnowledgeSourceRef[];
2051
+ confidence: number;
2052
+ metadata: Record<string, unknown>;
2053
+ createdBySessionId: string | null;
2054
+ reviewedBy: string | null;
2055
+ reviewedAt: string | null;
2056
+ pinned: boolean;
2057
+ usageCount: number;
2058
+ lastUsedAt: string | null;
2059
+ supersedesId: string | null;
2060
+ supersededById: string | null;
2061
+ validFrom: string;
2062
+ validUntil: string | null;
2063
+ createdAt: string;
2064
+ updatedAt: string;
2065
+ };
2066
+
2067
+ export type CreateKnowledgeMemoryRequest = {
2068
+ status?: KnowledgeMemoryStatus | undefined;
2069
+ kind?: KnowledgeMemoryKind | undefined;
2070
+ scope?: string | undefined;
2071
+ text: string;
2072
+ sourceRefs?: KnowledgeSourceRef[] | undefined;
2073
+ confidence?: number | undefined;
2074
+ metadata?: Record<string, unknown> | undefined;
2075
+ createdBySessionId?: string | undefined;
2076
+ pinned?: boolean | undefined;
2077
+ replacesId?: string | undefined;
2078
+ };
2079
+
2080
+ export type UpdateKnowledgeMemoryRequest = {
2081
+ status?: KnowledgeMemoryStatus | undefined;
2082
+ kind?: KnowledgeMemoryKind | undefined;
2083
+ scope?: string | undefined;
2084
+ text?: string | undefined;
2085
+ sourceRefs?: KnowledgeSourceRef[] | undefined;
2086
+ confidence?: number | undefined;
2087
+ metadata?: Record<string, unknown> | undefined;
2088
+ reviewedBy?: string | undefined;
2089
+ pinned?: boolean | undefined;
2090
+ };
2091
+
2092
+ export type KnowledgeMemorySearchRequest = {
2093
+ query?: string | undefined;
2094
+ status?: KnowledgeMemoryStatus | undefined;
2095
+ kind?: KnowledgeMemoryKind | undefined;
2096
+ scope?: string | undefined;
2097
+ limit?: number | undefined;
2098
+ };
2099
+
2100
+ export type WorkspaceMemorySearchMode = "hybrid" | "vector" | "keyword";
2101
+
2102
+ export type WorkspaceMemorySearchRequest = {
2103
+ query: string;
2104
+ kind?: KnowledgeMemoryKind | undefined;
2105
+ limit?: number | undefined;
2106
+ mode?: WorkspaceMemorySearchMode | undefined;
2107
+ };
2108
+
2109
+ export type WorkspaceMemorySearchResult = {
2110
+ memory: KnowledgeMemory;
2111
+ score: number;
2112
+ matchType: WorkspaceMemorySearchMode;
2113
+ vectorScore: number | null;
2114
+ keywordScore: number | null;
2115
+ };
2116
+
2117
+ export type WorkspaceMemorySearchResponse = {
2118
+ results: WorkspaceMemorySearchResult[];
2119
+ };
2120
+
1248
2121
  // --- Capability packs ---------------------------------------------------------
1249
2122
 
1250
2123
  export type CapabilityPackConnectorAuthModel =
@@ -1293,7 +2166,7 @@ export type CapabilityPackSkill = {
1293
2166
  files: CapabilityPackSkillFile[];
1294
2167
  };
1295
2168
 
1296
- export type CapabilityPackEnvironmentSpec = {
2169
+ export type CapabilityPackVariableSetSpec = {
1297
2170
  description: string;
1298
2171
  requiredVariables: string[];
1299
2172
  required: boolean;
@@ -1312,7 +2185,7 @@ export type CapabilityPack = {
1312
2185
  connectors: CapabilityPackConnector[];
1313
2186
  knowledge: CapabilityPackKnowledge[];
1314
2187
  scheduledTaskTemplates: CapabilityPackScheduledTaskTemplate[];
1315
- environment?: CapabilityPackEnvironmentSpec | undefined;
2188
+ variableSet?: CapabilityPackVariableSetSpec | undefined;
1316
2189
  metadata: Record<string, unknown>;
1317
2190
  };
1318
2191
 
@@ -1325,43 +2198,53 @@ export type RegisterCapabilityPackRequest = {
1325
2198
  category: string;
1326
2199
  version: string;
1327
2200
  sandboxImage?: string | undefined;
1328
- skills?: {
1329
- name: string;
1330
- description?: string | undefined;
1331
- files: CapabilityPackSkillFile[];
1332
- }[] | undefined;
2201
+ skills?:
2202
+ | {
2203
+ name: string;
2204
+ description?: string | undefined;
2205
+ files: CapabilityPackSkillFile[];
2206
+ }[]
2207
+ | undefined;
1333
2208
  tools?: ToolRef[] | undefined;
1334
- connectors?: {
1335
- id: string;
1336
- name: string;
1337
- category: string;
1338
- authModel: CapabilityPackConnectorAuthModel;
1339
- providers?: string[] | undefined;
1340
- scopes?: string[] | undefined;
1341
- required?: boolean | undefined;
1342
- metadata?: Record<string, unknown> | undefined;
1343
- }[] | undefined;
1344
- knowledge?: {
1345
- type: "document_base";
1346
- id: string;
1347
- name: string;
1348
- description?: string | null | undefined;
1349
- required?: boolean | undefined;
1350
- }[] | undefined;
1351
- scheduledTaskTemplates?: {
1352
- id: string;
1353
- name: string;
1354
- description: string;
1355
- defaultSchedule: ScheduledTaskScheduleSpec;
1356
- defaultRunMode?: ScheduledTaskRunMode | undefined;
1357
- defaultOverlapPolicy?: ScheduledTaskOverlapPolicy | undefined;
1358
- prompt?: string | undefined;
1359
- }[] | undefined;
1360
- environment?: {
1361
- description: string;
1362
- requiredVariables?: string[] | undefined;
1363
- required?: boolean | undefined;
1364
- } | undefined;
2209
+ connectors?:
2210
+ | {
2211
+ id: string;
2212
+ name: string;
2213
+ category: string;
2214
+ authModel: CapabilityPackConnectorAuthModel;
2215
+ providers?: string[] | undefined;
2216
+ scopes?: string[] | undefined;
2217
+ required?: boolean | undefined;
2218
+ metadata?: Record<string, unknown> | undefined;
2219
+ }[]
2220
+ | undefined;
2221
+ knowledge?:
2222
+ | {
2223
+ type: "document_base";
2224
+ id: string;
2225
+ name: string;
2226
+ description?: string | null | undefined;
2227
+ required?: boolean | undefined;
2228
+ }[]
2229
+ | undefined;
2230
+ scheduledTaskTemplates?:
2231
+ | {
2232
+ id: string;
2233
+ name: string;
2234
+ description: string;
2235
+ defaultSchedule: ScheduledTaskScheduleSpec;
2236
+ defaultRunMode?: ScheduledTaskRunMode | undefined;
2237
+ defaultOverlapPolicy?: ScheduledTaskOverlapPolicy | undefined;
2238
+ prompt?: string | undefined;
2239
+ }[]
2240
+ | undefined;
2241
+ variableSet?:
2242
+ | {
2243
+ description: string;
2244
+ requiredVariables?: string[] | undefined;
2245
+ required?: boolean | undefined;
2246
+ }
2247
+ | undefined;
1365
2248
  metadata?: Record<string, unknown> | undefined;
1366
2249
  };
1367
2250
 
@@ -1387,6 +2270,8 @@ export type PackInstallation = {
1387
2270
  };
1388
2271
 
1389
2272
  export type EnablePackRequest = {
2273
+ variableSetId?: string | undefined;
2274
+ /** @deprecated use variableSetId */
1390
2275
  environmentId?: string | undefined;
1391
2276
  metadata?: Record<string, unknown> | undefined;
1392
2277
  };
@@ -1405,10 +2290,19 @@ export type GetPackResponse = {
1405
2290
 
1406
2291
  export type CapabilityKind = "pack" | "mcp" | "api" | "skill" | "plugin";
1407
2292
 
1408
- export type CapabilitySource = "built_in" | "configured" | "public_registry" | "manual";
2293
+ export type CapabilitySource =
2294
+ | "built_in"
2295
+ | "configured"
2296
+ | "public_registry"
2297
+ | "registry"
2298
+ | "manual";
1409
2299
 
1410
2300
  export type CapabilityInstallationStatus = "active" | "disabled";
1411
2301
 
2302
+ export type CapabilityCatalogAuthKind = "oauth2" | "api_key" | "none" | "unknown";
2303
+
2304
+ export type CapabilityCatalogTier = "verified" | "community";
2305
+
1412
2306
  export type CapabilityRuntime = {
1413
2307
  available: boolean;
1414
2308
  mcpServerId?: string | undefined;
@@ -1430,10 +2324,24 @@ export type CapabilityCatalogItem = {
1430
2324
  endpointUrl: string | null;
1431
2325
  installUrl: string | null;
1432
2326
  authModel: string | null;
2327
+ providerDomain: string | null;
2328
+ surfaceType: string | null;
2329
+ transport: string | null;
2330
+ mcpUrl: string | null;
2331
+ authKind: CapabilityCatalogAuthKind | null;
2332
+ credentialFacts: Record<string, unknown>[];
2333
+ tier: CapabilityCatalogTier | null;
2334
+ provenance: string | null;
2335
+ logoAssetPath: string | null;
2336
+ importBatchId: string | null;
2337
+ stale: boolean;
2338
+ staleAt: string | null;
1433
2339
  tools: ToolRef[];
1434
2340
  runtime: CapabilityRuntime;
1435
2341
  enabled: boolean;
1436
2342
  enabledReason: string | null;
2343
+ /** The connection backing this enabled installation, or null when none is involved. */
2344
+ connectionRef: { connectionId: string; providerDomain: string; kind: string } | null;
1437
2345
  metadata: Record<string, unknown>;
1438
2346
  createdAt?: string | undefined;
1439
2347
  updatedAt?: string | undefined;
@@ -1475,6 +2383,7 @@ export type CreateCapabilityCatalogItemRequest = {
1475
2383
  export type EnableCapabilityRequest = {
1476
2384
  config?: Record<string, unknown> | undefined;
1477
2385
  metadata?: Record<string, unknown> | undefined;
2386
+ connectionRef?: McpServerConnectionRef | undefined;
1478
2387
  /**
1479
2388
  * Credential headers for remote MCP capabilities. Write-only: encrypted at
1480
2389
  * rest, injected only into the runtime MCP client, never returned by the
@@ -1482,10 +2391,12 @@ export type EnableCapabilityRequest = {
1482
2391
  */
1483
2392
  headers?: Record<string, string> | undefined;
1484
2393
  /**
1485
- * Initial environment attachment for kind=pack capabilities — mirrors the
2394
+ * Initial variableSet attachment for kind=pack capabilities — mirrors the
1486
2395
  * dedicated POST /packs/:id/enable body. Required to enable an
1487
- * environment.required pack through this unified path; ignored otherwise.
2396
+ * variableSet.required pack through this unified path; ignored otherwise.
1488
2397
  */
2398
+ variableSetId?: string | undefined;
2399
+ /** @deprecated use variableSetId */
1489
2400
  environmentId?: string | undefined;
1490
2401
  };
1491
2402
 
@@ -1634,12 +2545,6 @@ export type UserMessageEventInput = {
1634
2545
  };
1635
2546
  };
1636
2547
 
1637
- export type UserInterruptEventInput = {
1638
- type: "user.interrupt";
1639
- clientEventId?: string | undefined;
1640
- payload?: { reason?: string | undefined } | undefined;
1641
- };
1642
-
1643
2548
  export type UserApprovalDecisionEventInput = {
1644
2549
  type: "user.approvalDecision";
1645
2550
  clientEventId?: string | undefined;
@@ -1651,10 +2556,7 @@ export type UserApprovalDecisionEventInput = {
1651
2556
  };
1652
2557
 
1653
2558
  /** Control/user events a client may POST to a session's event log. */
1654
- export type ClientSessionEventInput =
1655
- | UserMessageEventInput
1656
- | UserInterruptEventInput
1657
- | UserApprovalDecisionEventInput;
2559
+ export type ClientSessionEventInput = UserMessageEventInput | UserApprovalDecisionEventInput;
1658
2560
 
1659
2561
  // ── Bring-your-own-compute: Machines dashboard + per-machine metrics (M10) ────
1660
2562
  // Hand-written mirrors of the `@opengeni/contracts` MetricSample / MachineView /
@@ -1704,6 +2606,10 @@ export type MachineView = {
1704
2606
  os: string;
1705
2607
  arch: string;
1706
2608
  hasDisplay: boolean;
2609
+ /** Non-null only when a display exists but capture is blocked (macOS Screen
2610
+ * Recording / TCC not granted) — the UI can surface "display: capture not
2611
+ * granted". null == capture permitted OR headless. */
2612
+ desktopUnavailableReason?: string | null | undefined;
1707
2613
  allowScreenControl: boolean;
1708
2614
  sharedSessionCount: number;
1709
2615
  lastSeenAt: string | null;
@@ -1739,6 +2645,14 @@ export type SwapActiveSandboxResponse = {
1739
2645
  activeSandboxId: string | null;
1740
2646
  activeEpoch: number;
1741
2647
  reason?: string;
2648
+ // Typed rejection discriminant (issue #341); present only when swapped is false.
2649
+ // Mirror of the `@opengeni/contracts` SwapActiveSandboxResponse.code enum.
2650
+ code?:
2651
+ | "stale_pointer"
2652
+ | "offline_enrollment"
2653
+ | "unsupported_backend_context"
2654
+ | "transient_establishment"
2655
+ | "concurrent_swap";
1742
2656
  };
1743
2657
 
1744
2658
  // ── Self-hosted enrollment UX (design 11) ────────────────────────────────────