@opengeni/sdk 0.20.0 → 0.23.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
@@ -262,6 +262,35 @@ export type ResourceRef = RepositoryResourceRef | FileResourceRef;
262
262
  export type ToolRef = {
263
263
  kind: "mcp";
264
264
  id: string;
265
+ optional?: boolean | undefined;
266
+ };
267
+
268
+ export type SessionToolPolicy = {
269
+ mode: "workspace_default" | "explicit" | "inherited" | "legacy";
270
+ inheritedFromSessionId: string | null;
271
+ };
272
+
273
+ export type SessionEffectiveToolPolicy = {
274
+ mode: SessionToolPolicy["mode"];
275
+ inheritedFromSessionId: string | null;
276
+ selectedIds: string[];
277
+ effectiveIds: string[];
278
+ mandatoryIds: string[];
279
+ lazyRouter: {
280
+ state: "required" | "disabled";
281
+ deferredIds: string[];
282
+ };
283
+ configuredIds: string[];
284
+ droppedIds: string[];
285
+ counts: {
286
+ selected: number;
287
+ effective: number;
288
+ mandatory: number;
289
+ deferred: number;
290
+ configured: number;
291
+ dropped: number;
292
+ };
293
+ idsTruncated: boolean;
265
294
  };
266
295
 
267
296
  export type GoalSpec = {
@@ -288,15 +317,27 @@ export type SessionMcpCredentialUpdateInput = {
288
317
  headers: Record<string, string>;
289
318
  };
290
319
 
320
+ export type SessionMcpApprovalPolicy = boolean | string[];
321
+
291
322
  export type SessionMcpServerMetadata = {
292
323
  id: string;
293
324
  name: string | null;
294
325
  url: string;
295
326
  headerNames: string[];
296
327
  credentialVersion: number;
328
+ requireApproval: SessionMcpApprovalPolicy;
297
329
  connectionRef: McpServerConnectionRef | null;
298
330
  };
299
331
 
332
+ export type UpdateSessionMcpApprovalPolicyRequest = {
333
+ requireApproval: SessionMcpApprovalPolicy;
334
+ };
335
+
336
+ export type UpdateSessionMcpApprovalPolicyResponse = {
337
+ server: SessionMcpServerMetadata;
338
+ effectiveFrom: "next_attempt";
339
+ };
340
+
300
341
  export type ConnectionKind = "oauth2" | "api_key" | "app_install" | "delegated";
301
342
  export type ConnectionStatus = "active" | "needs_reauth" | "revoked" | "error";
302
343
 
@@ -424,6 +465,8 @@ export type Session = {
424
465
  instructions: string | null;
425
466
  resources: ResourceRef[];
426
467
  tools: ToolRef[];
468
+ toolPolicy?: SessionToolPolicy | undefined;
469
+ effectiveToolPolicy?: SessionEffectiveToolPolicy | undefined;
427
470
  metadata: Record<string, unknown>;
428
471
  /** Frozen creator fact; later turns carry their own independent initiator. */
429
472
  createdBy: TurnInitiator;
@@ -544,6 +587,7 @@ export type SessionTurn = {
544
587
  prompt: string;
545
588
  resources: ResourceRef[];
546
589
  tools: ToolRef[];
590
+ toolsProvided?: boolean | undefined;
547
591
  model: string;
548
592
  reasoningEffort: ReasoningEffort;
549
593
  sandboxBackend: SandboxBackend;
@@ -652,6 +696,7 @@ export const SESSION_EVENT_TYPES = [
652
696
  "agent.reasoning.delta",
653
697
  "agent.toolCall.created",
654
698
  "agent.toolCall.output",
699
+ "agent.model.request",
655
700
  "agent.model.usage",
656
701
  "tool.auth_needed",
657
702
  "credential.auth_needed",
@@ -703,6 +748,7 @@ export const SESSION_EVENT_TYPES = [
703
748
  "terminal.pty.output.delta",
704
749
  "terminal.pty.exited",
705
750
  "session.title_set",
751
+ "session.mcp.approval_policy.updated",
706
752
  // Multi-account Codex (P1): the session's inference account changed.
707
753
  "codex.account.switched",
708
754
  // credential allocator metadata-only per-turn credential selection audit.
@@ -770,9 +816,11 @@ export type SessionEventSemanticClass =
770
816
  | "checkpoint"
771
817
  | "tool_receipt"
772
818
  | "provider_account";
819
+ export type SessionEventLatestClass = SessionEventSemanticClass | "receipt";
773
820
  export type SessionEventPayloadMode = "none" | "summary" | "full";
774
821
  export type SessionEventReadMode = "monitoring" | "forensic";
775
822
  export type SessionEventReadDirection = "after" | "before";
823
+ export type SessionEventResultMode = "events" | "compact";
776
824
 
777
825
  type SessionEventListCommonOptions = {
778
826
  after?: number;
@@ -782,6 +830,7 @@ type SessionEventListCommonOptions = {
782
830
  mode?: SessionEventReadMode;
783
831
  direction?: SessionEventReadDirection;
784
832
  payloadMode?: SessionEventPayloadMode;
833
+ resultMode?: "events";
785
834
  };
786
835
 
787
836
  export type SessionEventListOptions = SessionEventListCommonOptions &
@@ -795,7 +844,7 @@ export type SessionEventListOptions = SessionEventListCommonOptions &
795
844
  }
796
845
  | {
797
846
  /** Exclusive lookup for the newest event in exactly this semantic class. */
798
- latest: SessionEventSemanticClass;
847
+ latest: SessionEventLatestClass;
799
848
  includeTypes?: never;
800
849
  excludeTypes?: never;
801
850
  includeClasses?: never;
@@ -803,6 +852,62 @@ export type SessionEventListOptions = SessionEventListCommonOptions &
803
852
  }
804
853
  );
805
854
 
855
+ export type SessionEventCompactResult = {
856
+ version: 1;
857
+ semanticClass: SessionEventSemanticClass;
858
+ source: {
859
+ id: string;
860
+ type: SessionEventType;
861
+ sequence: number;
862
+ occurredAt: string;
863
+ turnId: string | null;
864
+ turnGeneration: number | null;
865
+ turnAttemptId: string | null;
866
+ turnAssociation: SessionEvent["turnAssociation"];
867
+ };
868
+ id: string;
869
+ type: SessionEventType;
870
+ sequence: number;
871
+ occurredAt: string;
872
+ turnId: string | null;
873
+ turnGeneration: number | null;
874
+ turnAttemptId: string | null;
875
+ turnAssociation: SessionEvent["turnAssociation"];
876
+ coveredSequence: { first: number; last: number };
877
+ status:
878
+ | "completed"
879
+ | "failed"
880
+ | "cancelled"
881
+ | "superseded"
882
+ | "checkpoint"
883
+ | "receipt"
884
+ | "unknown";
885
+ text: string | null;
886
+ output: unknown;
887
+ result: unknown;
888
+ failure: {
889
+ error: string | null;
890
+ code: string | null;
891
+ retryable: boolean | null;
892
+ recovery: string | null;
893
+ } | null;
894
+ checkpoint: unknown;
895
+ receipt: unknown;
896
+ truncation: {
897
+ truncated: boolean;
898
+ fields: string[];
899
+ originalBytes: number | null;
900
+ deliveredBytes: number;
901
+ };
902
+ };
903
+
904
+ export type SessionEventCompactResultOptions = {
905
+ latest: SessionEventLatestClass;
906
+ resultMode: "compact";
907
+ mode?: SessionEventReadMode;
908
+ payloadMode?: SessionEventPayloadMode;
909
+ };
910
+
806
911
  export type SessionEventPage = {
807
912
  events: SessionEvent[];
808
913
  mode: SessionEventReadMode;
@@ -1422,6 +1527,68 @@ export type Permission = KnownPermission | (string & {});
1422
1527
 
1423
1528
  export type ProductAccessMode = "local" | "configured" | "managed";
1424
1529
 
1530
+ export type ModelCapabilitySupportV1 = "supported" | "unsupported" | "unknown";
1531
+
1532
+ export type ModelCapabilityStateV1 = {
1533
+ upstream: ModelCapabilitySupportV1;
1534
+ runnable: boolean;
1535
+ };
1536
+
1537
+ export type ModelCapabilitiesV1 = {
1538
+ reasoning: ModelCapabilityStateV1 & {
1539
+ efforts: ReasoningEffort[];
1540
+ defaultEffort: ReasoningEffort | null;
1541
+ required: boolean;
1542
+ };
1543
+ functionCalling: ModelCapabilityStateV1;
1544
+ structuredOutput: ModelCapabilityStateV1;
1545
+ hostedTools: {
1546
+ webSearch: ModelCapabilityStateV1;
1547
+ xSearch: ModelCapabilityStateV1;
1548
+ codeExecution: ModelCapabilityStateV1;
1549
+ };
1550
+ inputModalities: Array<"text" | "image" | "audio">;
1551
+ outputModalities: Array<"text" | "image" | "audio">;
1552
+ transports: {
1553
+ sse: ModelCapabilityStateV1;
1554
+ responsesWebSocket: ModelCapabilityStateV1;
1555
+ realtimeAudio: ModelCapabilityStateV1;
1556
+ };
1557
+ latencyModes: Array<{
1558
+ id: "standard" | "priority" | "fast";
1559
+ upstream: ModelCapabilitySupportV1;
1560
+ runnable: boolean;
1561
+ billingMultiplierBps?: number | undefined;
1562
+ }>;
1563
+ };
1564
+
1565
+ export type ModelCredentialSourceV1 =
1566
+ | { kind: "deployment"; mechanism: "api_key" | "azure_ad_bearer" }
1567
+ | { kind: "connected_subscription"; provider: "codex" }
1568
+ | { kind: "workspace_connection"; mechanism: "api_key" };
1569
+
1570
+ export type ModelBillingAttributionV1 = {
1571
+ upstreamPayer: "deployment" | "workspace" | "connected_subscription";
1572
+ metering: "opengeni_credits" | "external";
1573
+ };
1574
+
1575
+ export type ModelPricingV1 = {
1576
+ inputMicrosPerMillionTokens: number;
1577
+ cachedInputMicrosPerMillionTokens?: number | undefined;
1578
+ outputMicrosPerMillionTokens: number;
1579
+ marginBps?: number | undefined;
1580
+ };
1581
+
1582
+ export type ModelPricingScheduleV1 = {
1583
+ default: ModelPricingV1;
1584
+ inputTokenTiers?:
1585
+ | Array<{
1586
+ minimumInputTokens: number;
1587
+ pricing: ModelPricingV1;
1588
+ }>
1589
+ | undefined;
1590
+ };
1591
+
1425
1592
  /**
1426
1593
  * One model a client may select at send time, plus the provider that serves it.
1427
1594
  * The wire API (`responses` | `chat`) lets a client reason about provider
@@ -1436,6 +1603,64 @@ export type ClientModel = {
1436
1603
  providerLabel: string;
1437
1604
  api: "responses" | "chat";
1438
1605
  contextWindowTokens?: number | undefined;
1606
+ schemaVersion?: 1 | undefined;
1607
+ aliases?: string[] | undefined;
1608
+ deployment?:
1609
+ | {
1610
+ upstreamModelId: string;
1611
+ wireApi: "responses" | "chat";
1612
+ }
1613
+ | undefined;
1614
+ executionLimits?:
1615
+ | {
1616
+ contextWindowTokens: number | null;
1617
+ effectiveContextWindowTokens: number | null;
1618
+ autoCompactTokenLimit: number | null;
1619
+ toolOutputTruncationTokens: number | null;
1620
+ }
1621
+ | undefined;
1622
+ credentialSource?: ModelCredentialSourceV1 | undefined;
1623
+ billing?: ModelBillingAttributionV1 | undefined;
1624
+ capabilities?: ModelCapabilitiesV1 | undefined;
1625
+ pricing?: ModelPricingScheduleV1 | undefined;
1626
+ definitionVersion?: string | undefined;
1627
+ };
1628
+
1629
+ export type ModelAvailabilityV1 = {
1630
+ status: "available" | "unavailable" | "degraded" | "unknown";
1631
+ selectable: boolean;
1632
+ reason:
1633
+ | "missing_credential"
1634
+ | "needs_reauth"
1635
+ | "credential_not_ready"
1636
+ | "not_entitled"
1637
+ | "provider_unhealthy"
1638
+ | "policy_blocked"
1639
+ | "unsupported"
1640
+ | null;
1641
+ checkedAt: string | null;
1642
+ };
1643
+
1644
+ export type ModelCredentialReadinessV1 = {
1645
+ status: "ready" | "not_ready" | "error";
1646
+ reason:
1647
+ | "missing_credential"
1648
+ | "needs_reauth"
1649
+ | "prerequisites_missing"
1650
+ | "resolver_error"
1651
+ | "observation_stale"
1652
+ | null;
1653
+ basis: "configuration" | "connection" | "resolver";
1654
+ checkedAt: string | null;
1655
+ };
1656
+
1657
+ export type WorkspaceModelCatalogModel = ClientModel & {
1658
+ credentialReadiness: ModelCredentialReadinessV1;
1659
+ availability: ModelAvailabilityV1;
1660
+ };
1661
+
1662
+ export type WorkspaceModelCatalogResponse = {
1663
+ models: WorkspaceModelCatalogModel[];
1439
1664
  };
1440
1665
 
1441
1666
  /**
@@ -1487,6 +1712,8 @@ export type CodexUsagePayload = {
1487
1712
  weekly: CodexUsageWindow | null;
1488
1713
  limitReached: boolean;
1489
1714
  fetchedAt: string;
1715
+ /** Authoritative count-only summary from /wham/usage; never synthesized rows. */
1716
+ rateLimitResetCredits?: { availableCount: number; credits: null } | null;
1490
1717
  /** Present only on an auth/refresh failure path. */
1491
1718
  reason?: "needs_relogin";
1492
1719
  additionalLimits?: Array<{
@@ -1523,6 +1750,76 @@ export type CodexAccount = {
1523
1750
  // P3 rotation cooldown: ISO timestamp until which this account is cooling-down
1524
1751
  // (rotated-off after a usage cap). null/absent ⇒ not cooling.
1525
1752
  exhaustedUntil?: string | null;
1753
+ /** Controls only NEW automatic allocations. */
1754
+ allocatorEnabled: boolean;
1755
+ /** Independent OCC sequence; credential/token `version` is never exposed. */
1756
+ allocatorVersion: number;
1757
+ allocatorUpdatedAt?: string | null;
1758
+ /** Cached authoritative summary count, never detailed redemption authority. */
1759
+ resetCreditAvailableCount?: number | null;
1760
+ resetCreditsCheckedAt?: string | null;
1761
+ };
1762
+
1763
+ export type CodexResetCredit = {
1764
+ id: string;
1765
+ resetType: "codexRateLimits" | "unknown";
1766
+ status: "available" | "redeeming" | "redeemed" | "unknown";
1767
+ /** Unix seconds from the provider contract. */
1768
+ grantedAt: number;
1769
+ /** Unix seconds, or null when the provider reports no expiry. */
1770
+ expiresAt: number | null;
1771
+ title: string | null;
1772
+ description: string | null;
1773
+ /** True only for fresh, complete, owning-human provider detail. */
1774
+ actionable: boolean;
1775
+ };
1776
+
1777
+ /** Owning-human recovery metadata. It contains no token, browser-session hash, or provider key. */
1778
+ export type CodexResetRedemptionRecovery = {
1779
+ attemptId: string;
1780
+ creditId: string;
1781
+ status: "provider_started" | "completed";
1782
+ outcome: "reset" | "nothingToReset" | "noCredit" | "alreadyRedeemed" | null;
1783
+ providerStartedAt: string | null;
1784
+ completedAt: string | null;
1785
+ createdAt: string;
1786
+ updatedAt: string;
1787
+ };
1788
+
1789
+ export type CodexAccountOverview = {
1790
+ accountId: string;
1791
+ usage: {
1792
+ source: "provider" | "cache" | "none";
1793
+ fetchedAt: string | null;
1794
+ stale: boolean;
1795
+ error: string | null;
1796
+ value: CodexUsagePayload | null;
1797
+ };
1798
+ resetCredits: {
1799
+ source: "provider" | "cache" | "none";
1800
+ fetchedAt: string | null;
1801
+ stale: boolean;
1802
+ error: string | null;
1803
+ detailState: "detailed" | "count_only" | "capped" | "unsupported" | "unknown" | "error";
1804
+ detailsComplete: boolean;
1805
+ availableCount: number | null;
1806
+ credits: CodexResetCredit[];
1807
+ };
1808
+ canRedeem: boolean;
1809
+ /** Owning managed-cookie human may replay durable completion without a healthy provider token. */
1810
+ canResumeRedemption: boolean;
1811
+ /** Durable owner-scoped ambiguity/completion discovery; never redemption authority for agents. */
1812
+ redemptions: CodexResetRedemptionRecovery[];
1813
+ };
1814
+
1815
+ /** Independently settled live overview keyed by workspace credential id. */
1816
+ export type CodexOverviewResponse = { accounts: Record<string, CodexAccountOverview> };
1817
+
1818
+ export type CodexAllocatorUpdate = {
1819
+ allocatorEnabled: boolean;
1820
+ allocatorVersion: number;
1821
+ allocatorUpdatedAt: string | null;
1822
+ changed: boolean;
1526
1823
  };
1527
1824
 
1528
1825
  /** Per-workspace Codex rotation/active settings. P1: rotation inert, only activeCredentialId loads. */
@@ -1866,6 +2163,8 @@ export type ComposerDraft = {
1866
2163
  text: string;
1867
2164
  resources: ResourceRef[];
1868
2165
  tools: ToolRef[];
2166
+ /** False inherits the session policy; true preserves an explicit array. */
2167
+ toolsProvided: boolean;
1869
2168
  model: string;
1870
2169
  reasoningEffort: ReasoningEffort;
1871
2170
  sourceTurnId: string | null;
@@ -2249,6 +2548,67 @@ export type FileAsset = {
2249
2548
  updatedAt: string;
2250
2549
  };
2251
2550
 
2551
+ /** Mirrors the closed, provider-neutral retained-output contract. */
2552
+ export const RETAINED_OUTPUT_DEFAULT_PAGE_BYTES = 256 * 1024;
2553
+ export const RETAINED_OUTPUT_MAX_PAGE_BYTES = 1024 * 1024;
2554
+
2555
+ export type RetainedOutputKind =
2556
+ | "tool_result"
2557
+ | "assistant_completion"
2558
+ | "internal_update"
2559
+ | "event_media"
2560
+ | "file";
2561
+
2562
+ export type RetainedOutputUnavailableReason =
2563
+ | "not_retained"
2564
+ | "pending"
2565
+ | "failed"
2566
+ | "expired"
2567
+ | "deleted"
2568
+ | "missing_storage"
2569
+ | "storage_write_failed"
2570
+ | "unsupported";
2571
+
2572
+ export type RetainedArtifactReference = {
2573
+ available: true;
2574
+ artifactId: string;
2575
+ kind: RetainedOutputKind;
2576
+ contentType: string;
2577
+ originalBytes: number;
2578
+ sha256: string;
2579
+ retainedAt: string;
2580
+ retention: { policy: "workspace_file"; expiresAt: null };
2581
+ retrieval: {
2582
+ method: "GET";
2583
+ path: string;
2584
+ acceptRanges: "bytes";
2585
+ maxRangeBytes: number;
2586
+ };
2587
+ };
2588
+
2589
+ export type RetainedArtifactUnavailable = {
2590
+ available: false;
2591
+ artifactId: string;
2592
+ reason: RetainedOutputUnavailableReason;
2593
+ };
2594
+
2595
+ export type RetainedArtifactMetadata = RetainedArtifactReference | RetainedArtifactUnavailable;
2596
+
2597
+ export type RetainedArtifactContentOptions = {
2598
+ /** One RFC-style bytes range, for example `bytes=1048576-2097151`. */
2599
+ range?: string | undefined;
2600
+ signal?: AbortSignal | undefined;
2601
+ };
2602
+
2603
+ export type RetainedArtifactContent = {
2604
+ bytes: Uint8Array;
2605
+ status: 200 | 206;
2606
+ contentType: string;
2607
+ contentLength: number;
2608
+ contentRange: string | null;
2609
+ acceptRanges: "bytes";
2610
+ };
2611
+
2252
2612
  export type CreateFileUploadRequest = {
2253
2613
  filename: string;
2254
2614
  contentType: string;
@@ -2680,6 +3040,17 @@ export type CapabilityRuntime = {
2680
3040
  mcpServerId?: string | undefined;
2681
3041
  transport?: string | undefined;
2682
3042
  notes: string | null;
3043
+ /** Secret-safe server-derived registry exposure state. */
3044
+ catalogTrust?:
3045
+ | {
3046
+ state: "trusted" | "legacy_active" | "unverified";
3047
+ reason:
3048
+ | "trusted_source"
3049
+ | "verified_probe"
3050
+ | "active_installation_compatibility"
3051
+ | "missing_verification";
3052
+ }
3053
+ | undefined;
2683
3054
  };
2684
3055
 
2685
3056
  export type CapabilityCatalogItem = {