@opengeni/sdk 0.20.0 → 0.25.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
@@ -65,6 +65,9 @@ export type SessionCapabilities = {
65
65
  os: SandboxOs;
66
66
  liveness: "cold" | "warming" | "warm" | "draining";
67
67
  leaseEpoch: number;
68
+ workspaceGeneration: number | null;
69
+ archiveGeneration: number | null;
70
+ archiveComplete: boolean;
68
71
  viewerHeartbeatIntervalMs: number;
69
72
  FileSystem: {
70
73
  available: boolean;
@@ -182,6 +185,9 @@ export type ViewerHolder = {
182
185
  sandboxGroupId: string;
183
186
  liveness: "cold" | "warming" | "warm" | "draining";
184
187
  leaseEpoch: number;
188
+ workspaceGeneration: number | null;
189
+ archiveGeneration: number | null;
190
+ archiveComplete: boolean;
185
191
  viewerHeartbeatIntervalMs: number;
186
192
  dataPlaneUrl: string | null;
187
193
  };
@@ -262,6 +268,35 @@ export type ResourceRef = RepositoryResourceRef | FileResourceRef;
262
268
  export type ToolRef = {
263
269
  kind: "mcp";
264
270
  id: string;
271
+ optional?: boolean | undefined;
272
+ };
273
+
274
+ export type SessionToolPolicy = {
275
+ mode: "workspace_default" | "explicit" | "inherited" | "legacy";
276
+ inheritedFromSessionId: string | null;
277
+ };
278
+
279
+ export type SessionEffectiveToolPolicy = {
280
+ mode: SessionToolPolicy["mode"];
281
+ inheritedFromSessionId: string | null;
282
+ selectedIds: string[];
283
+ effectiveIds: string[];
284
+ mandatoryIds: string[];
285
+ lazyRouter: {
286
+ state: "required" | "disabled";
287
+ deferredIds: string[];
288
+ };
289
+ configuredIds: string[];
290
+ droppedIds: string[];
291
+ counts: {
292
+ selected: number;
293
+ effective: number;
294
+ mandatory: number;
295
+ deferred: number;
296
+ configured: number;
297
+ dropped: number;
298
+ };
299
+ idsTruncated: boolean;
265
300
  };
266
301
 
267
302
  export type GoalSpec = {
@@ -288,15 +323,27 @@ export type SessionMcpCredentialUpdateInput = {
288
323
  headers: Record<string, string>;
289
324
  };
290
325
 
326
+ export type SessionMcpApprovalPolicy = boolean | string[];
327
+
291
328
  export type SessionMcpServerMetadata = {
292
329
  id: string;
293
330
  name: string | null;
294
331
  url: string;
295
332
  headerNames: string[];
296
333
  credentialVersion: number;
334
+ requireApproval: SessionMcpApprovalPolicy;
297
335
  connectionRef: McpServerConnectionRef | null;
298
336
  };
299
337
 
338
+ export type UpdateSessionMcpApprovalPolicyRequest = {
339
+ requireApproval: SessionMcpApprovalPolicy;
340
+ };
341
+
342
+ export type UpdateSessionMcpApprovalPolicyResponse = {
343
+ server: SessionMcpServerMetadata;
344
+ effectiveFrom: "next_attempt";
345
+ };
346
+
300
347
  export type ConnectionKind = "oauth2" | "api_key" | "app_install" | "delegated";
301
348
  export type ConnectionStatus = "active" | "needs_reauth" | "revoked" | "error";
302
349
 
@@ -424,6 +471,8 @@ export type Session = {
424
471
  instructions: string | null;
425
472
  resources: ResourceRef[];
426
473
  tools: ToolRef[];
474
+ toolPolicy?: SessionToolPolicy | undefined;
475
+ effectiveToolPolicy?: SessionEffectiveToolPolicy | undefined;
427
476
  metadata: Record<string, unknown>;
428
477
  /** Frozen creator fact; later turns carry their own independent initiator. */
429
478
  createdBy: TurnInitiator;
@@ -444,6 +493,13 @@ export type Session = {
444
493
  firstPartyMcpPermissions: string[] | null;
445
494
  mcpServers: SessionMcpServerMetadata[];
446
495
  parentSessionId: string | null;
496
+ /** Immutable server-authored nested-agent lineage and policy snapshot. */
497
+ rootSessionId: string;
498
+ nestedAgentDepth: number;
499
+ maxNestedAgentDepthOverride: number | null;
500
+ effectiveMaxNestedAgentDepth: number;
501
+ nestedAgentDepthPolicySource: "session" | "workspace" | "deployment" | "default";
502
+ nestedAgentDepthPolicySessionId: string | null;
447
503
  createIdempotencyKey: string | null;
448
504
  temporalWorkflowId: string | null;
449
505
  activeTurnId: string | null;
@@ -544,6 +600,7 @@ export type SessionTurn = {
544
600
  prompt: string;
545
601
  resources: ResourceRef[];
546
602
  tools: ToolRef[];
603
+ toolsProvided?: boolean | undefined;
547
604
  model: string;
548
605
  reasoningEffort: ReasoningEffort;
549
606
  sandboxBackend: SandboxBackend;
@@ -652,6 +709,7 @@ export const SESSION_EVENT_TYPES = [
652
709
  "agent.reasoning.delta",
653
710
  "agent.toolCall.created",
654
711
  "agent.toolCall.output",
712
+ "agent.model.request",
655
713
  "agent.model.usage",
656
714
  "tool.auth_needed",
657
715
  "credential.auth_needed",
@@ -703,10 +761,13 @@ export const SESSION_EVENT_TYPES = [
703
761
  "terminal.pty.output.delta",
704
762
  "terminal.pty.exited",
705
763
  "session.title_set",
764
+ "session.mcp.approval_policy.updated",
706
765
  // Multi-account Codex (P1): the session's inference account changed.
707
766
  "codex.account.switched",
708
767
  // credential allocator metadata-only per-turn credential selection audit.
709
768
  "codex.credential.selected",
769
+ // Bounded, identity-free deterministic shadow/replay decision.
770
+ "codex.fleet.decision",
710
771
  // credential allocator durable zero-capacity wait lifecycle. These are system/runtime
711
772
  // events, never synthetic user messages.
712
773
  "codex.capacity.waiting",
@@ -770,9 +831,11 @@ export type SessionEventSemanticClass =
770
831
  | "checkpoint"
771
832
  | "tool_receipt"
772
833
  | "provider_account";
834
+ export type SessionEventLatestClass = SessionEventSemanticClass | "receipt";
773
835
  export type SessionEventPayloadMode = "none" | "summary" | "full";
774
836
  export type SessionEventReadMode = "monitoring" | "forensic";
775
837
  export type SessionEventReadDirection = "after" | "before";
838
+ export type SessionEventResultMode = "events" | "compact";
776
839
 
777
840
  type SessionEventListCommonOptions = {
778
841
  after?: number;
@@ -782,6 +845,7 @@ type SessionEventListCommonOptions = {
782
845
  mode?: SessionEventReadMode;
783
846
  direction?: SessionEventReadDirection;
784
847
  payloadMode?: SessionEventPayloadMode;
848
+ resultMode?: "events";
785
849
  };
786
850
 
787
851
  export type SessionEventListOptions = SessionEventListCommonOptions &
@@ -795,7 +859,7 @@ export type SessionEventListOptions = SessionEventListCommonOptions &
795
859
  }
796
860
  | {
797
861
  /** Exclusive lookup for the newest event in exactly this semantic class. */
798
- latest: SessionEventSemanticClass;
862
+ latest: SessionEventLatestClass;
799
863
  includeTypes?: never;
800
864
  excludeTypes?: never;
801
865
  includeClasses?: never;
@@ -803,6 +867,62 @@ export type SessionEventListOptions = SessionEventListCommonOptions &
803
867
  }
804
868
  );
805
869
 
870
+ export type SessionEventCompactResult = {
871
+ version: 1;
872
+ semanticClass: SessionEventSemanticClass;
873
+ source: {
874
+ id: string;
875
+ type: SessionEventType;
876
+ sequence: number;
877
+ occurredAt: string;
878
+ turnId: string | null;
879
+ turnGeneration: number | null;
880
+ turnAttemptId: string | null;
881
+ turnAssociation: SessionEvent["turnAssociation"];
882
+ };
883
+ id: string;
884
+ type: SessionEventType;
885
+ sequence: number;
886
+ occurredAt: string;
887
+ turnId: string | null;
888
+ turnGeneration: number | null;
889
+ turnAttemptId: string | null;
890
+ turnAssociation: SessionEvent["turnAssociation"];
891
+ coveredSequence: { first: number; last: number };
892
+ status:
893
+ | "completed"
894
+ | "failed"
895
+ | "cancelled"
896
+ | "superseded"
897
+ | "checkpoint"
898
+ | "receipt"
899
+ | "unknown";
900
+ text: string | null;
901
+ output: unknown;
902
+ result: unknown;
903
+ failure: {
904
+ error: string | null;
905
+ code: string | null;
906
+ retryable: boolean | null;
907
+ recovery: string | null;
908
+ } | null;
909
+ checkpoint: unknown;
910
+ receipt: unknown;
911
+ truncation: {
912
+ truncated: boolean;
913
+ fields: string[];
914
+ originalBytes: number | null;
915
+ deliveredBytes: number;
916
+ };
917
+ };
918
+
919
+ export type SessionEventCompactResultOptions = {
920
+ latest: SessionEventLatestClass;
921
+ resultMode: "compact";
922
+ mode?: SessionEventReadMode;
923
+ payloadMode?: SessionEventPayloadMode;
924
+ };
925
+
806
926
  export type SessionEventPage = {
807
927
  events: SessionEvent[];
808
928
  mode: SessionEventReadMode;
@@ -852,6 +972,89 @@ export type AgentToolCallCreatedPayload = {
852
972
  export type AgentToolCallOutputPayload = { id: string | null; output: unknown };
853
973
  export type SessionStatusChangedPayload = { status: SessionStatus };
854
974
 
975
+ // Adaptive-fleet shadow event. This is the typed, identity-free view
976
+ // consumed by UI/manager tooling; the durable replay record also contains the
977
+ // complete normalized policy/input needed for offline deterministic replay.
978
+ export type CodexFleetConfidence = "unknown" | "low" | "medium" | "high";
979
+ export type CodexFleetCacheState = "unknown" | "healthy" | "collapsed";
980
+ export type CodexFleetShadowComparison =
981
+ | "match"
982
+ | "different_candidate"
983
+ | "different_outcome"
984
+ | "not_comparable_truncated";
985
+ export type CodexFleetDecisionScore = {
986
+ candidateKey: string;
987
+ eligible: boolean;
988
+ rejectionReason:
989
+ | "allocator_disabled"
990
+ | "unavailable"
991
+ | "cooling"
992
+ | "quota_ceiling"
993
+ | "overlay_isolation"
994
+ | null;
995
+ quotaPressure: number;
996
+ leasePressure: number;
997
+ observedBurnPressure: number;
998
+ inferredBurnPressure: number;
999
+ runwayPressure: number;
1000
+ uncertaintyPressure: number;
1001
+ cacheAffinityBenefit: number;
1002
+ cacheState: CodexFleetCacheState;
1003
+ overlayPreferenceBenefit: number;
1004
+ total: number;
1005
+ confidence: CodexFleetConfidence;
1006
+ };
1007
+ export type CodexFleetDecisionEventPayload = {
1008
+ schemaVersion: 1;
1009
+ mode: "shadow";
1010
+ actual: {
1011
+ outcome: "selected" | "waiting" | "none";
1012
+ candidateKey: string | null;
1013
+ reason: "lease_reused" | "pin" | "rotation" | "active" | "all_capped" | "none";
1014
+ };
1015
+ comparison: CodexFleetShadowComparison;
1016
+ replay: {
1017
+ schemaVersion: 1;
1018
+ policyVersion: "adaptive-shadow-v1";
1019
+ mode: "shadow";
1020
+ input: { candidates: Array<{ key: string }> } & Record<string, unknown>;
1021
+ truncatedCandidateCount: number;
1022
+ inputFingerprint: string;
1023
+ decisionFingerprint: string;
1024
+ decision: {
1025
+ outcome: "selected" | "paced" | "none";
1026
+ selectedCandidateKey: string | null;
1027
+ reason:
1028
+ | "fenced_in_flight"
1029
+ | "fenced_candidate_missing"
1030
+ | "admission_paced"
1031
+ | "no_eligible_candidate"
1032
+ | "overlay_isolated_empty"
1033
+ | "best_score"
1034
+ | "affinity_best"
1035
+ | "hysteresis_hold";
1036
+ admission: {
1037
+ outcome: "admit" | "pace";
1038
+ reason:
1039
+ | "fenced_in_flight"
1040
+ | "pacing_disabled"
1041
+ | "capacity_unknown"
1042
+ | "capacity_available"
1043
+ | "work_conserving_borrow"
1044
+ | "manager_priority"
1045
+ | "standard_starvation_bound"
1046
+ | "capacity_saturated"
1047
+ | "emergency_fuse";
1048
+ borrowedIdleCapacity: boolean;
1049
+ };
1050
+ borrowedOverlayCapacity: boolean;
1051
+ strandedEligibleCount: number;
1052
+ confidence: CodexFleetConfidence;
1053
+ scores: CodexFleetDecisionScore[];
1054
+ };
1055
+ } & Record<string, unknown>;
1056
+ };
1057
+
855
1058
  // Recording payloads (P4.3 — plain TS mirror of the contracts Zod schemas; the
856
1059
  // SDK is zero-runtime-dep so these are TYPES, not Zod, F15). The contract-parity
857
1060
  // test asserts the event-type literals; these shapes document the wire payloads.
@@ -941,7 +1144,7 @@ export type TerminalPtyOutputDeltaPayload = {
941
1144
  export type TerminalPtyExitedPayload = {
942
1145
  ptyId: string;
943
1146
  exitCode: number | null;
944
- reason: "exit" | "killed" | "owner_gone" | "timeout";
1147
+ reason: "exit" | "killed" | "owner_gone" | "timeout" | "lost";
945
1148
  };
946
1149
 
947
1150
  // A2 FileSystem request/response.
@@ -1228,8 +1431,8 @@ export type TerminalExecRequest = {
1228
1431
  export type TerminalExecResponse = {
1229
1432
  stdout: string;
1230
1433
  stderr: string;
1231
- exitCode: number | null;
1232
- running: boolean;
1434
+ exitCode: number;
1435
+ running: false;
1233
1436
  wallTimeSeconds: number;
1234
1437
  };
1235
1438
  export type PtyOpenRequest = {
@@ -1293,6 +1496,7 @@ export type ScheduledTaskAgentConfig = {
1293
1496
  reasoningEffort?: ReasoningEffort | undefined;
1294
1497
  sandboxBackend?: SandboxBackend | undefined;
1295
1498
  goal?: GoalSpec | undefined;
1499
+ maxNestedAgentDepth?: number | undefined;
1296
1500
  };
1297
1501
 
1298
1502
  export type ScheduledTask = {
@@ -1354,6 +1558,10 @@ export type CreateSessionRequest = {
1354
1558
  // double-submit/retry of the same logical create collapse to one session.
1355
1559
  // Distinct from the per-call clientEventId.
1356
1560
  idempotencyKey?: string | undefined;
1561
+ // Exact actor-private pre-session draft revision represented by this create.
1562
+ // The server consumes only this revision after durable initialization.
1563
+ expectedNewSessionDraftRevision?: number | undefined;
1564
+ maxNestedAgentDepth?: number | undefined;
1357
1565
  firstPartyMcpPermissions?: string[] | undefined;
1358
1566
  mcpServers?: SessionMcpServerInput[] | undefined;
1359
1567
  // Shared-sandbox placement (mirror of `@opengeni/contracts` CreateSessionRequest.sandbox,
@@ -1422,6 +1630,68 @@ export type Permission = KnownPermission | (string & {});
1422
1630
 
1423
1631
  export type ProductAccessMode = "local" | "configured" | "managed";
1424
1632
 
1633
+ export type ModelCapabilitySupportV1 = "supported" | "unsupported" | "unknown";
1634
+
1635
+ export type ModelCapabilityStateV1 = {
1636
+ upstream: ModelCapabilitySupportV1;
1637
+ runnable: boolean;
1638
+ };
1639
+
1640
+ export type ModelCapabilitiesV1 = {
1641
+ reasoning: ModelCapabilityStateV1 & {
1642
+ efforts: ReasoningEffort[];
1643
+ defaultEffort: ReasoningEffort | null;
1644
+ required: boolean;
1645
+ };
1646
+ functionCalling: ModelCapabilityStateV1;
1647
+ structuredOutput: ModelCapabilityStateV1;
1648
+ hostedTools: {
1649
+ webSearch: ModelCapabilityStateV1;
1650
+ xSearch: ModelCapabilityStateV1;
1651
+ codeExecution: ModelCapabilityStateV1;
1652
+ };
1653
+ inputModalities: Array<"text" | "image" | "audio">;
1654
+ outputModalities: Array<"text" | "image" | "audio">;
1655
+ transports: {
1656
+ sse: ModelCapabilityStateV1;
1657
+ responsesWebSocket: ModelCapabilityStateV1;
1658
+ realtimeAudio: ModelCapabilityStateV1;
1659
+ };
1660
+ latencyModes: Array<{
1661
+ id: "standard" | "priority" | "fast";
1662
+ upstream: ModelCapabilitySupportV1;
1663
+ runnable: boolean;
1664
+ billingMultiplierBps?: number | undefined;
1665
+ }>;
1666
+ };
1667
+
1668
+ export type ModelCredentialSourceV1 =
1669
+ | { kind: "deployment"; mechanism: "api_key" | "azure_ad_bearer" }
1670
+ | { kind: "connected_subscription"; provider: "codex" }
1671
+ | { kind: "workspace_connection"; mechanism: "api_key" };
1672
+
1673
+ export type ModelBillingAttributionV1 = {
1674
+ upstreamPayer: "deployment" | "workspace" | "connected_subscription";
1675
+ metering: "opengeni_credits" | "external";
1676
+ };
1677
+
1678
+ export type ModelPricingV1 = {
1679
+ inputMicrosPerMillionTokens: number;
1680
+ cachedInputMicrosPerMillionTokens?: number | undefined;
1681
+ outputMicrosPerMillionTokens: number;
1682
+ marginBps?: number | undefined;
1683
+ };
1684
+
1685
+ export type ModelPricingScheduleV1 = {
1686
+ default: ModelPricingV1;
1687
+ inputTokenTiers?:
1688
+ | Array<{
1689
+ minimumInputTokens: number;
1690
+ pricing: ModelPricingV1;
1691
+ }>
1692
+ | undefined;
1693
+ };
1694
+
1425
1695
  /**
1426
1696
  * One model a client may select at send time, plus the provider that serves it.
1427
1697
  * The wire API (`responses` | `chat`) lets a client reason about provider
@@ -1436,6 +1706,64 @@ export type ClientModel = {
1436
1706
  providerLabel: string;
1437
1707
  api: "responses" | "chat";
1438
1708
  contextWindowTokens?: number | undefined;
1709
+ schemaVersion?: 1 | undefined;
1710
+ aliases?: string[] | undefined;
1711
+ deployment?:
1712
+ | {
1713
+ upstreamModelId: string;
1714
+ wireApi: "responses" | "chat";
1715
+ }
1716
+ | undefined;
1717
+ executionLimits?:
1718
+ | {
1719
+ contextWindowTokens: number | null;
1720
+ effectiveContextWindowTokens: number | null;
1721
+ autoCompactTokenLimit: number | null;
1722
+ toolOutputTruncationTokens: number | null;
1723
+ }
1724
+ | undefined;
1725
+ credentialSource?: ModelCredentialSourceV1 | undefined;
1726
+ billing?: ModelBillingAttributionV1 | undefined;
1727
+ capabilities?: ModelCapabilitiesV1 | undefined;
1728
+ pricing?: ModelPricingScheduleV1 | undefined;
1729
+ definitionVersion?: string | undefined;
1730
+ };
1731
+
1732
+ export type ModelAvailabilityV1 = {
1733
+ status: "available" | "unavailable" | "degraded" | "unknown";
1734
+ selectable: boolean;
1735
+ reason:
1736
+ | "missing_credential"
1737
+ | "needs_reauth"
1738
+ | "credential_not_ready"
1739
+ | "not_entitled"
1740
+ | "provider_unhealthy"
1741
+ | "policy_blocked"
1742
+ | "unsupported"
1743
+ | null;
1744
+ checkedAt: string | null;
1745
+ };
1746
+
1747
+ export type ModelCredentialReadinessV1 = {
1748
+ status: "ready" | "not_ready" | "error";
1749
+ reason:
1750
+ | "missing_credential"
1751
+ | "needs_reauth"
1752
+ | "prerequisites_missing"
1753
+ | "resolver_error"
1754
+ | "observation_stale"
1755
+ | null;
1756
+ basis: "configuration" | "connection" | "resolver";
1757
+ checkedAt: string | null;
1758
+ };
1759
+
1760
+ export type WorkspaceModelCatalogModel = ClientModel & {
1761
+ credentialReadiness: ModelCredentialReadinessV1;
1762
+ availability: ModelAvailabilityV1;
1763
+ };
1764
+
1765
+ export type WorkspaceModelCatalogResponse = {
1766
+ models: WorkspaceModelCatalogModel[];
1439
1767
  };
1440
1768
 
1441
1769
  /**
@@ -1487,6 +1815,8 @@ export type CodexUsagePayload = {
1487
1815
  weekly: CodexUsageWindow | null;
1488
1816
  limitReached: boolean;
1489
1817
  fetchedAt: string;
1818
+ /** Authoritative count-only summary from /wham/usage; never synthesized rows. */
1819
+ rateLimitResetCredits?: { availableCount: number; credits: null } | null;
1490
1820
  /** Present only on an auth/refresh failure path. */
1491
1821
  reason?: "needs_relogin";
1492
1822
  additionalLimits?: Array<{
@@ -1523,6 +1853,76 @@ export type CodexAccount = {
1523
1853
  // P3 rotation cooldown: ISO timestamp until which this account is cooling-down
1524
1854
  // (rotated-off after a usage cap). null/absent ⇒ not cooling.
1525
1855
  exhaustedUntil?: string | null;
1856
+ /** Controls only NEW automatic allocations. */
1857
+ allocatorEnabled: boolean;
1858
+ /** Independent OCC sequence; credential/token `version` is never exposed. */
1859
+ allocatorVersion: number;
1860
+ allocatorUpdatedAt?: string | null;
1861
+ /** Cached authoritative summary count, never detailed redemption authority. */
1862
+ resetCreditAvailableCount?: number | null;
1863
+ resetCreditsCheckedAt?: string | null;
1864
+ };
1865
+
1866
+ export type CodexResetCredit = {
1867
+ id: string;
1868
+ resetType: "codexRateLimits" | "unknown";
1869
+ status: "available" | "redeeming" | "redeemed" | "unknown";
1870
+ /** Unix seconds from the provider contract. */
1871
+ grantedAt: number;
1872
+ /** Unix seconds, or null when the provider reports no expiry. */
1873
+ expiresAt: number | null;
1874
+ title: string | null;
1875
+ description: string | null;
1876
+ /** True only for fresh, complete, owning-human provider detail. */
1877
+ actionable: boolean;
1878
+ };
1879
+
1880
+ /** Owning-human recovery metadata. It contains no token, browser-session hash, or provider key. */
1881
+ export type CodexResetRedemptionRecovery = {
1882
+ attemptId: string;
1883
+ creditId: string;
1884
+ status: "provider_started" | "completed";
1885
+ outcome: "reset" | "nothingToReset" | "noCredit" | "alreadyRedeemed" | null;
1886
+ providerStartedAt: string | null;
1887
+ completedAt: string | null;
1888
+ createdAt: string;
1889
+ updatedAt: string;
1890
+ };
1891
+
1892
+ export type CodexAccountOverview = {
1893
+ accountId: string;
1894
+ usage: {
1895
+ source: "provider" | "cache" | "none";
1896
+ fetchedAt: string | null;
1897
+ stale: boolean;
1898
+ error: string | null;
1899
+ value: CodexUsagePayload | null;
1900
+ };
1901
+ resetCredits: {
1902
+ source: "provider" | "cache" | "none";
1903
+ fetchedAt: string | null;
1904
+ stale: boolean;
1905
+ error: string | null;
1906
+ detailState: "detailed" | "count_only" | "capped" | "unsupported" | "unknown" | "error";
1907
+ detailsComplete: boolean;
1908
+ availableCount: number | null;
1909
+ credits: CodexResetCredit[];
1910
+ };
1911
+ canRedeem: boolean;
1912
+ /** Owning managed-cookie human may replay durable completion without a healthy provider token. */
1913
+ canResumeRedemption: boolean;
1914
+ /** Durable owner-scoped ambiguity/completion discovery; never redemption authority for agents. */
1915
+ redemptions: CodexResetRedemptionRecovery[];
1916
+ };
1917
+
1918
+ /** Independently settled live overview keyed by workspace credential id. */
1919
+ export type CodexOverviewResponse = { accounts: Record<string, CodexAccountOverview> };
1920
+
1921
+ export type CodexAllocatorUpdate = {
1922
+ allocatorEnabled: boolean;
1923
+ allocatorVersion: number;
1924
+ allocatorUpdatedAt: string | null;
1925
+ changed: boolean;
1526
1926
  };
1527
1927
 
1528
1928
  /** Per-workspace Codex rotation/active settings. P1: rotation inert, only activeCredentialId loads. */
@@ -1681,12 +2081,14 @@ export type Workspace = {
1681
2081
  export type WorkspaceSettings = {
1682
2082
  memoryEnabled?: boolean | undefined;
1683
2083
  transcription?: WorkspaceTranscriptionPolicy | undefined;
2084
+ maxNestedAgentDepth?: number | null | undefined;
1684
2085
  [key: string]: unknown;
1685
2086
  };
1686
2087
 
1687
2088
  export type UpdateWorkspaceSettingsRequest = {
1688
2089
  memoryEnabled?: boolean | undefined;
1689
2090
  transcription?: WorkspaceTranscriptionPolicy | undefined;
2091
+ maxNestedAgentDepth?: number | null | undefined;
1690
2092
  [key: string]: unknown;
1691
2093
  };
1692
2094
 
@@ -1771,6 +2173,36 @@ export type SessionGoalStatus = "active" | "paused" | "completed";
1771
2173
 
1772
2174
  export type SessionGoalCreatedBy = "api" | "agent" | "scheduled_task";
1773
2175
 
2176
+ export type SessionGoalContinuationState =
2177
+ | "inactive"
2178
+ | "scheduled"
2179
+ | "running"
2180
+ | "blocked"
2181
+ | "invariant_broken";
2182
+
2183
+ export type SessionGoalContinuationReason =
2184
+ | "goal_inactive"
2185
+ | "wake_pending"
2186
+ | "continuation_pending"
2187
+ | "human_work_pending"
2188
+ | "goal_turn_running"
2189
+ | "human_turn_running"
2190
+ | "workstream_paused"
2191
+ | "approval_required"
2192
+ | "provider_backpressure"
2193
+ | "session_cancelled"
2194
+ | "system_work_pending"
2195
+ | "missing_obligation";
2196
+
2197
+ export type SessionGoalContinuation = {
2198
+ state: SessionGoalContinuationState;
2199
+ reason: SessionGoalContinuationReason;
2200
+ wakeRevision: number;
2201
+ observedRevision: number;
2202
+ nextAttemptAt: string | null;
2203
+ lastError: string | null;
2204
+ };
2205
+
1774
2206
  export type SessionGoal = {
1775
2207
  id: string;
1776
2208
  accountId: string;
@@ -1788,6 +2220,8 @@ export type SessionGoal = {
1788
2220
  noProgressStreak: number;
1789
2221
  maxAutoContinuations: number | null;
1790
2222
  metadata: Record<string, unknown>;
2223
+ /** Optional for source compatibility; the API always supplies this projection. */
2224
+ continuation?: SessionGoalContinuation | undefined;
1791
2225
  createdAt: string;
1792
2226
  updatedAt: string;
1793
2227
  };
@@ -1866,6 +2300,8 @@ export type ComposerDraft = {
1866
2300
  text: string;
1867
2301
  resources: ResourceRef[];
1868
2302
  tools: ToolRef[];
2303
+ /** False inherits the session policy; true preserves an explicit array. */
2304
+ toolsProvided: boolean;
1869
2305
  model: string;
1870
2306
  reasoningEffort: ReasoningEffort;
1871
2307
  sourceTurnId: string | null;
@@ -1873,6 +2309,27 @@ export type ComposerDraft = {
1873
2309
  updatedAt: string | null;
1874
2310
  };
1875
2311
 
2312
+ export type NewSessionDraftOptions = {
2313
+ sandboxBackend?: SandboxBackend | undefined;
2314
+ targetSandboxId?: string | undefined;
2315
+ workingDir?: string | undefined;
2316
+ variableSetId?: string | undefined;
2317
+ rigId?: string | undefined;
2318
+ goal?: GoalSpec | undefined;
2319
+ firstPartyMcpPermissions?: Permission[] | undefined;
2320
+ };
2321
+
2322
+ export type NewSessionDraft = {
2323
+ revision: number;
2324
+ text: string;
2325
+ resources: ResourceRef[];
2326
+ tools: ToolRef[];
2327
+ model: string;
2328
+ reasoningEffort: ReasoningEffort;
2329
+ options: NewSessionDraftOptions;
2330
+ updatedAt: string | null;
2331
+ };
2332
+
1876
2333
  export type SessionQueueSnapshot = {
1877
2334
  version: number;
1878
2335
  effectiveControl: EffectiveSessionControl;
@@ -2001,6 +2458,10 @@ export type SaveComposerDraftRequest = Omit<
2001
2458
  "revision" | "sourceTurnId" | "sourceTurnVersion" | "updatedAt"
2002
2459
  > & { expectedRevision: number };
2003
2460
 
2461
+ export type SaveNewSessionDraftRequest = Omit<NewSessionDraft, "revision" | "updatedAt"> & {
2462
+ expectedRevision: number;
2463
+ };
2464
+
2004
2465
  // --- Scheduled tasks: requests + runs ----------------------------------------
2005
2466
 
2006
2467
  /** Input shape for agent config on create/update (server applies defaults). */
@@ -2013,6 +2474,7 @@ export type ScheduledTaskAgentConfigInput = {
2013
2474
  reasoningEffort?: ReasoningEffort | undefined;
2014
2475
  sandboxBackend?: SandboxBackend | undefined;
2015
2476
  goal?: GoalSpec | undefined;
2477
+ maxNestedAgentDepth?: number | undefined;
2016
2478
  };
2017
2479
 
2018
2480
  export type CreateScheduledTaskRequest = {
@@ -2249,6 +2711,67 @@ export type FileAsset = {
2249
2711
  updatedAt: string;
2250
2712
  };
2251
2713
 
2714
+ /** Mirrors the closed, provider-neutral retained-output contract. */
2715
+ export const RETAINED_OUTPUT_DEFAULT_PAGE_BYTES = 256 * 1024;
2716
+ export const RETAINED_OUTPUT_MAX_PAGE_BYTES = 1024 * 1024;
2717
+
2718
+ export type RetainedOutputKind =
2719
+ | "tool_result"
2720
+ | "assistant_completion"
2721
+ | "internal_update"
2722
+ | "event_media"
2723
+ | "file";
2724
+
2725
+ export type RetainedOutputUnavailableReason =
2726
+ | "not_retained"
2727
+ | "pending"
2728
+ | "failed"
2729
+ | "expired"
2730
+ | "deleted"
2731
+ | "missing_storage"
2732
+ | "storage_write_failed"
2733
+ | "unsupported";
2734
+
2735
+ export type RetainedArtifactReference = {
2736
+ available: true;
2737
+ artifactId: string;
2738
+ kind: RetainedOutputKind;
2739
+ contentType: string;
2740
+ originalBytes: number;
2741
+ sha256: string;
2742
+ retainedAt: string;
2743
+ retention: { policy: "workspace_file"; expiresAt: null };
2744
+ retrieval: {
2745
+ method: "GET";
2746
+ path: string;
2747
+ acceptRanges: "bytes";
2748
+ maxRangeBytes: number;
2749
+ };
2750
+ };
2751
+
2752
+ export type RetainedArtifactUnavailable = {
2753
+ available: false;
2754
+ artifactId: string;
2755
+ reason: RetainedOutputUnavailableReason;
2756
+ };
2757
+
2758
+ export type RetainedArtifactMetadata = RetainedArtifactReference | RetainedArtifactUnavailable;
2759
+
2760
+ export type RetainedArtifactContentOptions = {
2761
+ /** One RFC-style bytes range, for example `bytes=1048576-2097151`. */
2762
+ range?: string | undefined;
2763
+ signal?: AbortSignal | undefined;
2764
+ };
2765
+
2766
+ export type RetainedArtifactContent = {
2767
+ bytes: Uint8Array;
2768
+ status: 200 | 206;
2769
+ contentType: string;
2770
+ contentLength: number;
2771
+ contentRange: string | null;
2772
+ acceptRanges: "bytes";
2773
+ };
2774
+
2252
2775
  export type CreateFileUploadRequest = {
2253
2776
  filename: string;
2254
2777
  contentType: string;
@@ -2680,6 +3203,17 @@ export type CapabilityRuntime = {
2680
3203
  mcpServerId?: string | undefined;
2681
3204
  transport?: string | undefined;
2682
3205
  notes: string | null;
3206
+ /** Secret-safe server-derived registry exposure state. */
3207
+ catalogTrust?:
3208
+ | {
3209
+ state: "trusted" | "legacy_active" | "unverified";
3210
+ reason:
3211
+ | "trusted_source"
3212
+ | "verified_probe"
3213
+ | "active_installation_compatibility"
3214
+ | "missing_verification";
3215
+ }
3216
+ | undefined;
2683
3217
  };
2684
3218
 
2685
3219
  export type CapabilityCatalogItem = {
@@ -3008,6 +3542,9 @@ export type MachineView = {
3008
3542
  state: MachineState;
3009
3543
  active: boolean;
3010
3544
  isSessionGroup: boolean;
3545
+ workspaceGeneration: number | null;
3546
+ archiveGeneration: number | null;
3547
+ archiveComplete: boolean;
3011
3548
  os: string;
3012
3549
  arch: string;
3013
3550
  hasDisplay: boolean;
@@ -3057,7 +3594,10 @@ export type SwapActiveSandboxResponse = {
3057
3594
  | "offline_enrollment"
3058
3595
  | "unsupported_backend_context"
3059
3596
  | "transient_establishment"
3060
- | "concurrent_swap";
3597
+ | "concurrent_swap"
3598
+ | "recovery_in_progress"
3599
+ | "recovery_degraded"
3600
+ | "recovery_unrecoverable";
3061
3601
  };
3062
3602
 
3063
3603
  // ── Self-hosted enrollment UX (design 11) ────────────────────────────────────