@opengeni/sdk 0.23.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/dist/index.d.ts CHANGED
@@ -196,6 +196,9 @@ type SessionCapabilities = {
196
196
  os: SandboxOs;
197
197
  liveness: "cold" | "warming" | "warm" | "draining";
198
198
  leaseEpoch: number;
199
+ workspaceGeneration: number | null;
200
+ archiveGeneration: number | null;
201
+ archiveComplete: boolean;
199
202
  viewerHeartbeatIntervalMs: number;
200
203
  FileSystem: {
201
204
  available: boolean;
@@ -283,6 +286,9 @@ type ViewerHolder = {
283
286
  sandboxGroupId: string;
284
287
  liveness: "cold" | "warming" | "warm" | "draining";
285
288
  leaseEpoch: number;
289
+ workspaceGeneration: number | null;
290
+ archiveGeneration: number | null;
291
+ archiveComplete: boolean;
286
292
  viewerHeartbeatIntervalMs: number;
287
293
  dataPlaneUrl: string | null;
288
294
  };
@@ -542,6 +548,13 @@ type Session = {
542
548
  firstPartyMcpPermissions: string[] | null;
543
549
  mcpServers: SessionMcpServerMetadata[];
544
550
  parentSessionId: string | null;
551
+ /** Immutable server-authored nested-agent lineage and policy snapshot. */
552
+ rootSessionId: string;
553
+ nestedAgentDepth: number;
554
+ maxNestedAgentDepthOverride: number | null;
555
+ effectiveMaxNestedAgentDepth: number;
556
+ nestedAgentDepthPolicySource: "session" | "workspace" | "deployment" | "default";
557
+ nestedAgentDepthPolicySessionId: string | null;
545
558
  createIdempotencyKey: string | null;
546
559
  temporalWorkflowId: string | null;
547
560
  activeTurnId: string | null;
@@ -691,7 +704,7 @@ type SessionHumanInputRequest = {
691
704
  createdAt: string;
692
705
  updatedAt: string;
693
706
  };
694
- declare const SESSION_EVENT_TYPES: readonly ["session.created", "session.event.envelope_omitted", "session.status.changed", "session.requiresAction", "session.humanInput.requested", "session.context.compaction.requested", "session.context.compacted", "session.context.compaction.skipped", "session.context.cleared", "user.message", "user.pause", "user.approvalDecision", "user.humanInputResponse", "turn.queued", "turn.started", "turn.completed", "turn.failed", "turn.cancelled", "turn.superseded", "turn.recovery.requested", "turn.capacity_waiting", "agent.message.delta", "agent.message.completed", "agent.reasoning.delta", "agent.toolCall.created", "agent.toolCall.output", "agent.model.request", "agent.model.usage", "tool.auth_needed", "credential.auth_needed", "agent.updated", "rig.setup.started", "rig.setup.completed", "rig.setup.skipped", "rig.setup.failed", "sandbox.operation.started", "sandbox.operation.completed", "sandbox.operation.failed", "sandbox.command.output.delta", "artifact.created", "goal.set", "goal.updated", "goal.completed", "goal.paused", "goal.resumed", "goal.cleared", "goal.continuation", "system.update.pending", "system.update.delivered", "session.control.paused", "session.control.resumed", "session.control.steer_requested", "workspace.inference.paused", "workspace.inference.resumed", "session.queue.changed", "session.queue.prompt.cancelled", "session.queue.history", "turn.event.rejected_late", "memory.saved", "memory.corrected", "stream.url.rotated", "stream.opened", "stream.closed", "stream.revoked", "recording.started", "recording.available", "recording.failed", "fs.changed", "git.changed", "terminal.pty.started", "terminal.pty.output.delta", "terminal.pty.exited", "session.title_set", "session.mcp.approval_policy.updated", "codex.account.switched", "codex.credential.selected", "codex.capacity.waiting", "codex.capacity.resumed", "codex.capacity.superseded", "sandbox.box.created", "sandbox.box.lost", "sandbox.box.terminated", "sandbox.box.snapshot", "sandbox.env.drift", "session.route.reconciled", "workspace.revision.captured", "workspace.revision.degraded", "machine.op.failed", "machine.op.recovered", "machine.link.lost", "machine.link.restored", "machine.runner.restarted"];
707
+ declare const SESSION_EVENT_TYPES: readonly ["session.created", "session.event.envelope_omitted", "session.status.changed", "session.requiresAction", "session.humanInput.requested", "session.context.compaction.requested", "session.context.compacted", "session.context.compaction.skipped", "session.context.cleared", "user.message", "user.pause", "user.approvalDecision", "user.humanInputResponse", "turn.queued", "turn.started", "turn.completed", "turn.failed", "turn.cancelled", "turn.superseded", "turn.recovery.requested", "turn.capacity_waiting", "agent.message.delta", "agent.message.completed", "agent.reasoning.delta", "agent.toolCall.created", "agent.toolCall.output", "agent.model.request", "agent.model.usage", "tool.auth_needed", "credential.auth_needed", "agent.updated", "rig.setup.started", "rig.setup.completed", "rig.setup.skipped", "rig.setup.failed", "sandbox.operation.started", "sandbox.operation.completed", "sandbox.operation.failed", "sandbox.command.output.delta", "artifact.created", "goal.set", "goal.updated", "goal.completed", "goal.paused", "goal.resumed", "goal.cleared", "goal.continuation", "system.update.pending", "system.update.delivered", "session.control.paused", "session.control.resumed", "session.control.steer_requested", "workspace.inference.paused", "workspace.inference.resumed", "session.queue.changed", "session.queue.prompt.cancelled", "session.queue.history", "turn.event.rejected_late", "memory.saved", "memory.corrected", "stream.url.rotated", "stream.opened", "stream.closed", "stream.revoked", "recording.started", "recording.available", "recording.failed", "fs.changed", "git.changed", "terminal.pty.started", "terminal.pty.output.delta", "terminal.pty.exited", "session.title_set", "session.mcp.approval_policy.updated", "codex.account.switched", "codex.credential.selected", "codex.fleet.decision", "codex.capacity.waiting", "codex.capacity.resumed", "codex.capacity.superseded", "sandbox.box.created", "sandbox.box.lost", "sandbox.box.terminated", "sandbox.box.snapshot", "sandbox.env.drift", "session.route.reconciled", "workspace.revision.captured", "workspace.revision.degraded", "machine.op.failed", "machine.op.recovered", "machine.link.lost", "machine.link.restored", "machine.runner.restarted"];
695
708
  type KnownSessionEventType = (typeof SESSION_EVENT_TYPES)[number];
696
709
  /**
697
710
  * Event types the SDK knows about today, kept open so a newer OpenGeni server
@@ -848,6 +861,62 @@ type AgentToolCallOutputPayload = {
848
861
  type SessionStatusChangedPayload = {
849
862
  status: SessionStatus;
850
863
  };
864
+ type CodexFleetConfidence = "unknown" | "low" | "medium" | "high";
865
+ type CodexFleetCacheState = "unknown" | "healthy" | "collapsed";
866
+ type CodexFleetShadowComparison = "match" | "different_candidate" | "different_outcome" | "not_comparable_truncated";
867
+ type CodexFleetDecisionScore = {
868
+ candidateKey: string;
869
+ eligible: boolean;
870
+ rejectionReason: "allocator_disabled" | "unavailable" | "cooling" | "quota_ceiling" | "overlay_isolation" | null;
871
+ quotaPressure: number;
872
+ leasePressure: number;
873
+ observedBurnPressure: number;
874
+ inferredBurnPressure: number;
875
+ runwayPressure: number;
876
+ uncertaintyPressure: number;
877
+ cacheAffinityBenefit: number;
878
+ cacheState: CodexFleetCacheState;
879
+ overlayPreferenceBenefit: number;
880
+ total: number;
881
+ confidence: CodexFleetConfidence;
882
+ };
883
+ type CodexFleetDecisionEventPayload = {
884
+ schemaVersion: 1;
885
+ mode: "shadow";
886
+ actual: {
887
+ outcome: "selected" | "waiting" | "none";
888
+ candidateKey: string | null;
889
+ reason: "lease_reused" | "pin" | "rotation" | "active" | "all_capped" | "none";
890
+ };
891
+ comparison: CodexFleetShadowComparison;
892
+ replay: {
893
+ schemaVersion: 1;
894
+ policyVersion: "adaptive-shadow-v1";
895
+ mode: "shadow";
896
+ input: {
897
+ candidates: Array<{
898
+ key: string;
899
+ }>;
900
+ } & Record<string, unknown>;
901
+ truncatedCandidateCount: number;
902
+ inputFingerprint: string;
903
+ decisionFingerprint: string;
904
+ decision: {
905
+ outcome: "selected" | "paced" | "none";
906
+ selectedCandidateKey: string | null;
907
+ reason: "fenced_in_flight" | "fenced_candidate_missing" | "admission_paced" | "no_eligible_candidate" | "overlay_isolated_empty" | "best_score" | "affinity_best" | "hysteresis_hold";
908
+ admission: {
909
+ outcome: "admit" | "pace";
910
+ reason: "fenced_in_flight" | "pacing_disabled" | "capacity_unknown" | "capacity_available" | "work_conserving_borrow" | "manager_priority" | "standard_starvation_bound" | "capacity_saturated" | "emergency_fuse";
911
+ borrowedIdleCapacity: boolean;
912
+ };
913
+ borrowedOverlayCapacity: boolean;
914
+ strandedEligibleCount: number;
915
+ confidence: CodexFleetConfidence;
916
+ scores: CodexFleetDecisionScore[];
917
+ };
918
+ } & Record<string, unknown>;
919
+ };
851
920
  type RecordingMode = "manual" | "on-turn" | "on-verify";
852
921
  type RecordingCodec = "h264-mp4" | "vp9-webm";
853
922
  type RecordingContentType = "video/mp4" | "video/webm";
@@ -923,7 +992,7 @@ type TerminalPtyOutputDeltaPayload = {
923
992
  type TerminalPtyExitedPayload = {
924
993
  ptyId: string;
925
994
  exitCode: number | null;
926
- reason: "exit" | "killed" | "owner_gone" | "timeout";
995
+ reason: "exit" | "killed" | "owner_gone" | "timeout" | "lost";
927
996
  };
928
997
  type FsNodeType = "file" | "dir" | "symlink" | "other";
929
998
  type FsTreeNode = {
@@ -1213,8 +1282,8 @@ type TerminalExecRequest = {
1213
1282
  type TerminalExecResponse = {
1214
1283
  stdout: string;
1215
1284
  stderr: string;
1216
- exitCode: number | null;
1217
- running: boolean;
1285
+ exitCode: number;
1286
+ running: false;
1218
1287
  wallTimeSeconds: number;
1219
1288
  };
1220
1289
  type PtyOpenRequest = {
@@ -1287,6 +1356,7 @@ type ScheduledTaskAgentConfig = {
1287
1356
  reasoningEffort?: ReasoningEffort | undefined;
1288
1357
  sandboxBackend?: SandboxBackend | undefined;
1289
1358
  goal?: GoalSpec | undefined;
1359
+ maxNestedAgentDepth?: number | undefined;
1290
1360
  };
1291
1361
  type ScheduledTask = {
1292
1362
  id: string;
@@ -1329,6 +1399,8 @@ type CreateSessionRequest = {
1329
1399
  goal?: GoalSpec | undefined;
1330
1400
  clientEventId?: string | undefined;
1331
1401
  idempotencyKey?: string | undefined;
1402
+ expectedNewSessionDraftRevision?: number | undefined;
1403
+ maxNestedAgentDepth?: number | undefined;
1332
1404
  firstPartyMcpPermissions?: string[] | undefined;
1333
1405
  mcpServers?: SessionMcpServerInput[] | undefined;
1334
1406
  sandbox?: "shared" | "new" | {
@@ -1751,11 +1823,13 @@ type Workspace = {
1751
1823
  type WorkspaceSettings = {
1752
1824
  memoryEnabled?: boolean | undefined;
1753
1825
  transcription?: WorkspaceTranscriptionPolicy | undefined;
1826
+ maxNestedAgentDepth?: number | null | undefined;
1754
1827
  [key: string]: unknown;
1755
1828
  };
1756
1829
  type UpdateWorkspaceSettingsRequest = {
1757
1830
  memoryEnabled?: boolean | undefined;
1758
1831
  transcription?: WorkspaceTranscriptionPolicy | undefined;
1832
+ maxNestedAgentDepth?: number | null | undefined;
1759
1833
  [key: string]: unknown;
1760
1834
  };
1761
1835
  type SetWorkspaceDefaultRigRequest = {
@@ -1821,6 +1895,16 @@ type UpdateWorkspaceMemberRequest = {
1821
1895
  };
1822
1896
  type SessionGoalStatus = "active" | "paused" | "completed";
1823
1897
  type SessionGoalCreatedBy = "api" | "agent" | "scheduled_task";
1898
+ type SessionGoalContinuationState = "inactive" | "scheduled" | "running" | "blocked" | "invariant_broken";
1899
+ type SessionGoalContinuationReason = "goal_inactive" | "wake_pending" | "continuation_pending" | "human_work_pending" | "goal_turn_running" | "human_turn_running" | "workstream_paused" | "approval_required" | "provider_backpressure" | "session_cancelled" | "system_work_pending" | "missing_obligation";
1900
+ type SessionGoalContinuation = {
1901
+ state: SessionGoalContinuationState;
1902
+ reason: SessionGoalContinuationReason;
1903
+ wakeRevision: number;
1904
+ observedRevision: number;
1905
+ nextAttemptAt: string | null;
1906
+ lastError: string | null;
1907
+ };
1824
1908
  type SessionGoal = {
1825
1909
  id: string;
1826
1910
  accountId: string;
@@ -1838,6 +1922,8 @@ type SessionGoal = {
1838
1922
  noProgressStreak: number;
1839
1923
  maxAutoContinuations: number | null;
1840
1924
  metadata: Record<string, unknown>;
1925
+ /** Optional for source compatibility; the API always supplies this projection. */
1926
+ continuation?: SessionGoalContinuation | undefined;
1841
1927
  createdAt: string;
1842
1928
  updatedAt: string;
1843
1929
  };
@@ -1915,6 +2001,25 @@ type ComposerDraft = {
1915
2001
  sourceTurnVersion: number | null;
1916
2002
  updatedAt: string | null;
1917
2003
  };
2004
+ type NewSessionDraftOptions = {
2005
+ sandboxBackend?: SandboxBackend | undefined;
2006
+ targetSandboxId?: string | undefined;
2007
+ workingDir?: string | undefined;
2008
+ variableSetId?: string | undefined;
2009
+ rigId?: string | undefined;
2010
+ goal?: GoalSpec | undefined;
2011
+ firstPartyMcpPermissions?: Permission[] | undefined;
2012
+ };
2013
+ type NewSessionDraft = {
2014
+ revision: number;
2015
+ text: string;
2016
+ resources: ResourceRef[];
2017
+ tools: ToolRef[];
2018
+ model: string;
2019
+ reasoningEffort: ReasoningEffort;
2020
+ options: NewSessionDraftOptions;
2021
+ updatedAt: string | null;
2022
+ };
1918
2023
  type SessionQueueSnapshot = {
1919
2024
  version: number;
1920
2025
  effectiveControl: EffectiveSessionControl;
@@ -2012,6 +2117,9 @@ type DeleteSessionQueueItemRequest = {
2012
2117
  type SaveComposerDraftRequest = Omit<ComposerDraft, "revision" | "sourceTurnId" | "sourceTurnVersion" | "updatedAt"> & {
2013
2118
  expectedRevision: number;
2014
2119
  };
2120
+ type SaveNewSessionDraftRequest = Omit<NewSessionDraft, "revision" | "updatedAt"> & {
2121
+ expectedRevision: number;
2122
+ };
2015
2123
  /** Input shape for agent config on create/update (server applies defaults). */
2016
2124
  type ScheduledTaskAgentConfigInput = {
2017
2125
  prompt: string;
@@ -2022,6 +2130,7 @@ type ScheduledTaskAgentConfigInput = {
2022
2130
  reasoningEffort?: ReasoningEffort | undefined;
2023
2131
  sandboxBackend?: SandboxBackend | undefined;
2024
2132
  goal?: GoalSpec | undefined;
2133
+ maxNestedAgentDepth?: number | undefined;
2025
2134
  };
2026
2135
  type CreateScheduledTaskRequest = {
2027
2136
  name: string;
@@ -2875,6 +2984,9 @@ type MachineView = {
2875
2984
  state: MachineState;
2876
2985
  active: boolean;
2877
2986
  isSessionGroup: boolean;
2987
+ workspaceGeneration: number | null;
2988
+ archiveGeneration: number | null;
2989
+ archiveComplete: boolean;
2878
2990
  os: string;
2879
2991
  arch: string;
2880
2992
  hasDisplay: boolean;
@@ -2913,7 +3025,7 @@ type SwapActiveSandboxResponse = {
2913
3025
  activeSandboxId: string | null;
2914
3026
  activeEpoch: number;
2915
3027
  reason?: string;
2916
- code?: "stale_pointer" | "offline_enrollment" | "unsupported_backend_context" | "transient_establishment" | "concurrent_swap";
3028
+ code?: "stale_pointer" | "offline_enrollment" | "unsupported_backend_context" | "transient_establishment" | "concurrent_swap" | "recovery_in_progress" | "recovery_degraded" | "recovery_unrecoverable";
2917
3029
  };
2918
3030
  /** Mirror of `@opengeni/contracts` EnrollmentOs. */
2919
3031
  type EnrollmentOs = "linux" | "macos" | "windows";
@@ -3107,6 +3219,8 @@ declare class OpenGeniClient {
3107
3219
  private readonly fetchImpl;
3108
3220
  constructor(options: OpenGeniClientOptions);
3109
3221
  createSession(workspaceId: string, request: CreateSessionRequest): Promise<CreateSessionResponse>;
3222
+ getNewSessionDraft(workspaceId: string): Promise<NewSessionDraft>;
3223
+ saveNewSessionDraft(workspaceId: string, request: SaveNewSessionDraftRequest): Promise<NewSessionDraft>;
3110
3224
  getSession(workspaceId: string, sessionId: string): Promise<Session>;
3111
3225
  updateSession(workspaceId: string, sessionId: string, request: UpdateSessionRequest): Promise<Session>;
3112
3226
  /**
@@ -3126,6 +3240,8 @@ declare class OpenGeniClient {
3126
3240
  parentSessionId?: string | null;
3127
3241
  cursor?: string;
3128
3242
  search?: string;
3243
+ /** Return only the complete personal pinned projection. */
3244
+ pinsOnly?: boolean;
3129
3245
  }): Promise<SessionListResponse>;
3130
3246
  /** Set this authenticated member's personal workspace pin for a session. */
3131
3247
  updateSessionPin(workspaceId: string, sessionId: string, request: UpdateSessionPinRequest): Promise<Session>;
@@ -3641,9 +3757,13 @@ declare class OpenGeniClient {
3641
3757
  /** Error for a non-2xx OpenGeni API response. */
3642
3758
  declare class OpenGeniApiError extends Error {
3643
3759
  readonly status: number;
3760
+ readonly code: string | undefined;
3644
3761
  readonly body: string;
3645
3762
  constructor(status: number, body: string);
3646
3763
  }
3764
+ /** A short-lived session-list snapshot cursor can no longer be continued. */
3765
+ declare class OpenGeniSessionListCursorError extends OpenGeniApiError {
3766
+ }
3647
3767
  /** The browser bundle and API disagree about their state-changing wire contract. */
3648
3768
  declare class OpenGeniApiContractMismatchError extends Error {
3649
3769
  readonly expected: string;
@@ -3859,4 +3979,4 @@ declare function ttydInputFrame(data: string): string;
3859
3979
  /** Build a client→server RESIZE frame: "1" + JSON.stringify({ columns, rows }). */
3860
3980
  declare function ttydResizeFrame(columns: number, rows: number): string;
3861
3981
 
3862
- export { type AccessContext, type AccessGrant, type AccountGrant, type AccountRole, type AcknowledgeStreamRequest, type AcknowledgeStreamResponse, type AddDocumentRequest, type AddWorkspaceMemberRequest, type AgentMessageCompletedPayload, type AgentTextDeltaPayload, type AgentToolCallCreatedPayload, type AgentToolCallOutputPayload, type ApiKey, type AttachViewerRequest, type AttachViewerResponse, type BillingBalance, type BillingEntitlementsResponse, type BillingMode, type BillingSummary, type BillingUsageResponse, type CapabilityCatalogItem, type CapabilityCatalogResponse, type CapabilityInstallation, type CapabilityInstallationStatus, type CapabilityKind, type CapabilityPack, type CapabilityPackConnector, type CapabilityPackConnectorAuthModel, type CapabilityPackKnowledge, type CapabilityPackScheduledTaskTemplate, type CapabilityPackSkill, type CapabilityPackSkillFile, type CapabilityPackVariableSetSpec, type CapabilityRuntime, type CapabilitySource, type CapabilityUnavailableReason, type ClientAuthConfig, type ClientConfig, type ClientModel, type ClientSessionEventInput, type CodexAccount, type CodexAccountOverview, type CodexAccountSwitchedPayload, type CodexAccountsResponse, type CodexAllocatorUpdate, type CodexConnectPoll, type CodexConnectStart, type CodexConnectionStatus, type CodexOverviewResponse, type CodexResetCredit, type CodexResetRedemptionRecovery, type CodexRotationSettings, type CodexUsage, type CodexUsageMap, type CodexUsagePayload, type CodexUsageWindow, type CompactSessionContextResult, type CompleteFileUploadResponse, type ComposerDraft, type ComputerUseCapability, type ConnectionKind, type ConnectionMetadata, type ConnectionResponse, type ConnectionStatus, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateCapabilityCatalogItemRequest, type CreateCheckoutRequest, type CreateCheckoutResponse, type CreateConnectionRequest, type CreateDocumentBaseRequest, type CreateFileUploadRequest, type CreateFileUploadResponse, type CreateGitHubAppManifestRequest, type CreateGitHubAppManifestResponse, type CreateKnowledgeMemoryRequest, type CreateRigRequest, type CreateScheduledTaskRequest, type CreateSessionRequest, type CreateVariableSetRequest, type CreateWorkspaceEnvironmentRequest, type CreateWorkspaceRequest, DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY, type DeleteSessionQueueItemRequest, type DesktopConnectionState, type DesktopRfbFactory, type DesktopRfbLike, type DesktopStreamCapability, type DesktopStreamEvent, type DeviceEnrollmentApproveRequest, type DeviceEnrollmentApproveResponse, type DeviceEnrollmentDenyRequest, type DeviceEnrollmentDenyResponse, type DeviceEnrollmentLookupMachine, type DeviceEnrollmentLookupRequest, type DeviceEnrollmentLookupResponse, type DiscoverMcpCapabilitiesResponse, type Document, type DocumentBase, type DocumentSearchMode, type DocumentSearchRequest, type DocumentSearchResponse, type DocumentSearchResult, type DocumentStatus, type EditSessionQueueItemRequest, type EffectiveControlBlocker, type EffectiveControlResumeOption, type EffectiveSessionControl, type EnableCapabilityRequest, type EnablePackRequest, type EnrollTokenExchangeRequest, type EnrollTokenExchangeResponse, type EnrollmentCredentials, type EnrollmentOs, type EntitlementValue, type Entitlements, type EntitlementsMode, type FetchLike, type FileAsset, type FileDownloadUrlResponse, type FileResourceRef, type FileStatus, type FileSystemCapability, type FileUploadData, type FsChangeKind, type FsChangedPayload, type FsDeleteRequest, type FsDeleteResponse, type FsEncoding, type FsListRequest, type FsListResponse, type FsMkdirRequest, type FsMkdirResponse, type FsMoveRequest, type FsMoveResponse, type FsNodeType, type FsReadRequest, type FsReadResponse, type FsTreeNode, type FsWriteRequest, type FsWriteResponse, type GetPackResponse, type GetWorkspaceCaptureFileResponse, type GetWorkspaceCaptureResponse, type GitCapability, type GitChangedPayload, type GitCommit, type GitCredentialBindingId, type GitCredentialProvider, type GitDiffHunk, type GitDiffLine, type GitDiffLineType, type GitDiffRequest, type GitDiffResponse, type GitFileDiff, type GitFileStatus, type GitFileStatusCode, type GitHubAppInfo, type GitHubInstallationBinding, type GitHubRepositoriesResponse, type GitHubRepository, type GitHubRepositoryScope, type GitLogRequest, type GitLogResponse, type GitRepositoryAccess, type GitShowRequest, type GitShowResponse, type GitStatusRequest, type GitStatusResponse, type GoalSpec, type HumanInputAnswer, type HumanInputOption, type HumanInputQuestion, type HumanInputQuestionKind, type HumanInputResponse, type IntegrationClientMetadata, KNOWN_PERMISSIONS, KNOWN_USAGE_EVENT_TYPES, type KnowledgeMemory, type KnowledgeMemoryKind, type KnowledgeMemorySearchRequest, type KnowledgeMemoryStatus, type KnowledgeSourceKind, type KnowledgeSourceRef, type KnownPermission, type KnownSessionEventType, type KnownUsageEventType, type LineageNode, type ListApiKeysResponse, type ListConnectionsResponse, type ListPacksResponse, type ListWorkspaceMembersResponse, type MachineKind, type MachineMetricsSeriesResponse, type MachineState, type MachineView, type MachinesResponse, type McpServerConnectionRef, type MetricSample, type MintEnrollTokenRequest, type MintEnrollTokenResponse, type ModelAvailabilityV1, type ModelBillingAttributionV1, type ModelCapabilitiesV1, type ModelCapabilityStateV1, type ModelCapabilitySupportV1, type ModelCredentialReadinessV1, type ModelCredentialSourceV1, type ModelPricingScheduleV1, type ModelPricingV1, type MoveSessionQueueItemRequest, type OAuthStartRequest, type OAuthStartResponse, OPENGENI_API_CONTRACT_HEADER, OPENGENI_API_CONTRACT_REVISION, OpenGeniApiContractMismatchError, OpenGeniApiError, OpenGeniClient, type OpenGeniClientOptions, type OpenGeniRequestOptions, OpenGeniStreamError, type PackInstallation, type PackInstallationStatus, type Permission, type ProductAccessMode, type ProposeRigChangeRequest, type ProxySessionEventStreamOptions, type PtyCloseRequest, type PtyOpenRequest, type PtyOpenResponse, type PtyResizeRequest, type PtyWriteRequest, RETAINED_OUTPUT_DEFAULT_PAGE_BYTES, RETAINED_OUTPUT_MAX_PAGE_BYTES, type ReasoningEffort, type RecordingAvailablePayload, type RecordingCapability, type RecordingCodec, type RecordingContentType, type RecordingFailedPayload, type RecordingFailedReason, type RecordingMode, type RecordingStartedPayload, type RegisterCapabilityPackRequest, type RepositoryResourceRef, type ResourceRef, type RetainedArtifactContent, type RetainedArtifactContentOptions, type RetainedArtifactMetadata, type RetainedArtifactReference, type RetainedArtifactUnavailable, type RetainedOutputKind, type RetainedOutputUnavailableReason, type Rig, type RigChange, type RigChangeKind, type RigChangeStatus, type RigChangeVerification, type RigCheck, type RigCheckResult, type RigDefinitionEditPayload, type RigSetupAppendPayload, type RigVersion, SESSION_EVENT_TYPES, type SandboxBackend, type SandboxCapabilityName, type SandboxCommandOutputDeltaPayload, type SandboxOs, type SaveComposerDraftRequest, type ScheduledTask, type ScheduledTaskAgentConfig, type ScheduledTaskAgentConfigInput, type ScheduledTaskDayOfWeek, type ScheduledTaskOverlapPolicy, type ScheduledTaskRun, type ScheduledTaskRunMode, type ScheduledTaskRunStatus, type ScheduledTaskScheduleSpec, type ScheduledTaskStatus, type ScheduledTaskTriggerType, type SendMessageInput, type ServiceTurnInitiator, type ServiceTurnInitiatorContext, type Session, type SessionCapabilities, type SessionCommandReceipt, type SessionControlResponse, type SessionEffectiveToolPolicy, type SessionEvent, type SessionEventCompactResult, type SessionEventCompactResultOptions, type SessionEventLatestClass, type SessionEventListOptions, type SessionEventPage, type SessionEventPayloadMode, type SessionEventReadDirection, type SessionEventReadMode, type SessionEventResultMode, type SessionEventSemanticClass, type SessionEventStreamTransport, type SessionEventType, type SessionGoal, type SessionGoalCreatedBy, type SessionGoalStatus, type SessionHumanInputRequest, type SessionLineageResponse, type SessionListResponse, type SessionMcpApprovalPolicy, type SessionMcpCredentialUpdateInput, type SessionMcpServerInput, type SessionMcpServerMetadata, type SessionQueueMutationResponse, type SessionQueueSnapshot, type SessionStatus, type SessionStatusChangedPayload, type SessionStructuredCapabilities, type SessionSummary, type SessionSystemUpdate, type SessionSystemUpdateKind, type SessionSystemUpdateState, type SessionToolPolicy, type SessionTurn, type SessionTurnSource, type SessionTurnStatus, type SetWorkspaceEnvironmentVariableRequest, type SseMessage, type SseReStreamOptions, type SteerMessageResult, type SteerSessionQueueItemRequest, type StreamClosedPayload, type StreamConnectionState, type StreamOpenedPayload, type StreamRevokedPayload, type StreamSessionEventsOptions, type StreamUrlRotatedPayload, type SubmitHumanInputResponseRequest, type SwapActiveSandboxRequest, type SwapActiveSandboxResponse, TTYD_SUBPROTOCOL, type TerminalCapability, type TerminalExecRequest, type TerminalExecResponse, type TerminalPtyExitedPayload, type TerminalPtyOutputDeltaPayload, type TerminalPtyStartedPayload, type ToolAuthNeededPayload, type ToolRef, type TranscriptionAdapter, type TranscriptionAdapterDescriptor, type TranscriptionAdapterStartContext, type TranscriptionAuthorization, type TranscriptionCredentialMode, type TranscriptionDiagnostic, type TranscriptionErrorCode, type TranscriptionEvent, type TranscriptionEventListener, type TranscriptionLifecycleStatus, type TranscriptionPolicyBlockReason, type TranscriptionResultMetadata, type TranscriptionSession, type TranscriptionSessionRequest, type TranscriptionSpeaker, type TranscriptionTargetSelection, type TranscriptionTimeSpan, type TranscriptionWord, TtydClientCommand, TtydServerCommand, type TurnInitiator, type UpdateConnectionRequest, type UpdateKnowledgeMemoryRequest, type UpdateRigRequest, type UpdateScheduledTaskRequest, type UpdateSessionGoalRequest, type UpdateSessionMcpApprovalPolicyRequest, type UpdateSessionMcpApprovalPolicyResponse, type UpdateSessionPinRequest, type UpdateSessionRequest, type UpdateVariableSetRequest, type UpdateWorkspaceEnvironmentRequest, type UpdateWorkspaceMemberRequest, type UpdateWorkspaceRequest, type UpdateWorkspaceSettingsRequest, type UploadFileInput, type UsageEvent, type UsageEventType, type UserApprovalDecisionEventInput, type UserHumanInputResponseEventInput, type UserMessageEventInput, type VariableSet, type VariableSetVariableMetadata, type ViewerHeartbeatRequest, type ViewerHeartbeatResponse, type ViewerHolder, type Workspace, type WorkspaceCaptureDegradedReason, type WorkspaceCaptureFile, type WorkspaceCaptureManifest, type WorkspaceCaptureRepo, type WorkspaceCaptureSignedUrl, type WorkspaceCaptureStats, type WorkspaceControlEvent, type WorkspaceControlEventPage, type WorkspaceControlStreamTransport, type WorkspaceEnvironment, type WorkspaceEnvironmentVariableMetadata, type WorkspaceInferenceControlResponse, type WorkspaceMember, type WorkspaceMemorySearchMode, type WorkspaceMemorySearchRequest, type WorkspaceMemorySearchResponse, type WorkspaceMemorySearchResult, type WorkspaceModelCatalogModel, type WorkspaceModelCatalogResponse, type WorkspaceRegisteredPack, type WorkspaceRevisionCapturedPayload, type WorkspaceRevisionDegradedPayload, type WorkspaceSettings, type WorkspaceTranscriptionPolicy, type WorkspaceTranscriptionTarget, applyUrlRotation, authorizeTranscriptionAdapter, createTranscriptionSessionRequest, desktopSocketUrl, formatSseEvent, isRetryableStreamError, nextDesktopState, parseSseStream, proxySessionEventStream, resolveWorkspaceTranscriptionPolicy, resumeSequenceFromRequest, sessionEventsToSseResponse, sessionEventsToSseStream, streamSessionEvents, streamWorkspaceControlEvents, terminalSocketUrl, ttydAuthFrame, ttydInputFrame, ttydResizeFrame };
3982
+ export { type AccessContext, type AccessGrant, type AccountGrant, type AccountRole, type AcknowledgeStreamRequest, type AcknowledgeStreamResponse, type AddDocumentRequest, type AddWorkspaceMemberRequest, type AgentMessageCompletedPayload, type AgentTextDeltaPayload, type AgentToolCallCreatedPayload, type AgentToolCallOutputPayload, type ApiKey, type AttachViewerRequest, type AttachViewerResponse, type BillingBalance, type BillingEntitlementsResponse, type BillingMode, type BillingSummary, type BillingUsageResponse, type CapabilityCatalogItem, type CapabilityCatalogResponse, type CapabilityInstallation, type CapabilityInstallationStatus, type CapabilityKind, type CapabilityPack, type CapabilityPackConnector, type CapabilityPackConnectorAuthModel, type CapabilityPackKnowledge, type CapabilityPackScheduledTaskTemplate, type CapabilityPackSkill, type CapabilityPackSkillFile, type CapabilityPackVariableSetSpec, type CapabilityRuntime, type CapabilitySource, type CapabilityUnavailableReason, type ClientAuthConfig, type ClientConfig, type ClientModel, type ClientSessionEventInput, type CodexAccount, type CodexAccountOverview, type CodexAccountSwitchedPayload, type CodexAccountsResponse, type CodexAllocatorUpdate, type CodexConnectPoll, type CodexConnectStart, type CodexConnectionStatus, type CodexFleetCacheState, type CodexFleetConfidence, type CodexFleetDecisionEventPayload, type CodexFleetDecisionScore, type CodexFleetShadowComparison, type CodexOverviewResponse, type CodexResetCredit, type CodexResetRedemptionRecovery, type CodexRotationSettings, type CodexUsage, type CodexUsageMap, type CodexUsagePayload, type CodexUsageWindow, type CompactSessionContextResult, type CompleteFileUploadResponse, type ComposerDraft, type ComputerUseCapability, type ConnectionKind, type ConnectionMetadata, type ConnectionResponse, type ConnectionStatus, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateCapabilityCatalogItemRequest, type CreateCheckoutRequest, type CreateCheckoutResponse, type CreateConnectionRequest, type CreateDocumentBaseRequest, type CreateFileUploadRequest, type CreateFileUploadResponse, type CreateGitHubAppManifestRequest, type CreateGitHubAppManifestResponse, type CreateKnowledgeMemoryRequest, type CreateRigRequest, type CreateScheduledTaskRequest, type CreateSessionRequest, type CreateVariableSetRequest, type CreateWorkspaceEnvironmentRequest, type CreateWorkspaceRequest, DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY, type DeleteSessionQueueItemRequest, type DesktopConnectionState, type DesktopRfbFactory, type DesktopRfbLike, type DesktopStreamCapability, type DesktopStreamEvent, type DeviceEnrollmentApproveRequest, type DeviceEnrollmentApproveResponse, type DeviceEnrollmentDenyRequest, type DeviceEnrollmentDenyResponse, type DeviceEnrollmentLookupMachine, type DeviceEnrollmentLookupRequest, type DeviceEnrollmentLookupResponse, type DiscoverMcpCapabilitiesResponse, type Document, type DocumentBase, type DocumentSearchMode, type DocumentSearchRequest, type DocumentSearchResponse, type DocumentSearchResult, type DocumentStatus, type EditSessionQueueItemRequest, type EffectiveControlBlocker, type EffectiveControlResumeOption, type EffectiveSessionControl, type EnableCapabilityRequest, type EnablePackRequest, type EnrollTokenExchangeRequest, type EnrollTokenExchangeResponse, type EnrollmentCredentials, type EnrollmentOs, type EntitlementValue, type Entitlements, type EntitlementsMode, type FetchLike, type FileAsset, type FileDownloadUrlResponse, type FileResourceRef, type FileStatus, type FileSystemCapability, type FileUploadData, type FsChangeKind, type FsChangedPayload, type FsDeleteRequest, type FsDeleteResponse, type FsEncoding, type FsListRequest, type FsListResponse, type FsMkdirRequest, type FsMkdirResponse, type FsMoveRequest, type FsMoveResponse, type FsNodeType, type FsReadRequest, type FsReadResponse, type FsTreeNode, type FsWriteRequest, type FsWriteResponse, type GetPackResponse, type GetWorkspaceCaptureFileResponse, type GetWorkspaceCaptureResponse, type GitCapability, type GitChangedPayload, type GitCommit, type GitCredentialBindingId, type GitCredentialProvider, type GitDiffHunk, type GitDiffLine, type GitDiffLineType, type GitDiffRequest, type GitDiffResponse, type GitFileDiff, type GitFileStatus, type GitFileStatusCode, type GitHubAppInfo, type GitHubInstallationBinding, type GitHubRepositoriesResponse, type GitHubRepository, type GitHubRepositoryScope, type GitLogRequest, type GitLogResponse, type GitRepositoryAccess, type GitShowRequest, type GitShowResponse, type GitStatusRequest, type GitStatusResponse, type GoalSpec, type HumanInputAnswer, type HumanInputOption, type HumanInputQuestion, type HumanInputQuestionKind, type HumanInputResponse, type IntegrationClientMetadata, KNOWN_PERMISSIONS, KNOWN_USAGE_EVENT_TYPES, type KnowledgeMemory, type KnowledgeMemoryKind, type KnowledgeMemorySearchRequest, type KnowledgeMemoryStatus, type KnowledgeSourceKind, type KnowledgeSourceRef, type KnownPermission, type KnownSessionEventType, type KnownUsageEventType, type LineageNode, type ListApiKeysResponse, type ListConnectionsResponse, type ListPacksResponse, type ListWorkspaceMembersResponse, type MachineKind, type MachineMetricsSeriesResponse, type MachineState, type MachineView, type MachinesResponse, type McpServerConnectionRef, type MetricSample, type MintEnrollTokenRequest, type MintEnrollTokenResponse, type ModelAvailabilityV1, type ModelBillingAttributionV1, type ModelCapabilitiesV1, type ModelCapabilityStateV1, type ModelCapabilitySupportV1, type ModelCredentialReadinessV1, type ModelCredentialSourceV1, type ModelPricingScheduleV1, type ModelPricingV1, type MoveSessionQueueItemRequest, type NewSessionDraft, type NewSessionDraftOptions, type OAuthStartRequest, type OAuthStartResponse, OPENGENI_API_CONTRACT_HEADER, OPENGENI_API_CONTRACT_REVISION, OpenGeniApiContractMismatchError, OpenGeniApiError, OpenGeniClient, type OpenGeniClientOptions, type OpenGeniRequestOptions, OpenGeniSessionListCursorError, OpenGeniStreamError, type PackInstallation, type PackInstallationStatus, type Permission, type ProductAccessMode, type ProposeRigChangeRequest, type ProxySessionEventStreamOptions, type PtyCloseRequest, type PtyOpenRequest, type PtyOpenResponse, type PtyResizeRequest, type PtyWriteRequest, RETAINED_OUTPUT_DEFAULT_PAGE_BYTES, RETAINED_OUTPUT_MAX_PAGE_BYTES, type ReasoningEffort, type RecordingAvailablePayload, type RecordingCapability, type RecordingCodec, type RecordingContentType, type RecordingFailedPayload, type RecordingFailedReason, type RecordingMode, type RecordingStartedPayload, type RegisterCapabilityPackRequest, type RepositoryResourceRef, type ResourceRef, type RetainedArtifactContent, type RetainedArtifactContentOptions, type RetainedArtifactMetadata, type RetainedArtifactReference, type RetainedArtifactUnavailable, type RetainedOutputKind, type RetainedOutputUnavailableReason, type Rig, type RigChange, type RigChangeKind, type RigChangeStatus, type RigChangeVerification, type RigCheck, type RigCheckResult, type RigDefinitionEditPayload, type RigSetupAppendPayload, type RigVersion, SESSION_EVENT_TYPES, type SandboxBackend, type SandboxCapabilityName, type SandboxCommandOutputDeltaPayload, type SandboxOs, type SaveComposerDraftRequest, type SaveNewSessionDraftRequest, type ScheduledTask, type ScheduledTaskAgentConfig, type ScheduledTaskAgentConfigInput, type ScheduledTaskDayOfWeek, type ScheduledTaskOverlapPolicy, type ScheduledTaskRun, type ScheduledTaskRunMode, type ScheduledTaskRunStatus, type ScheduledTaskScheduleSpec, type ScheduledTaskStatus, type ScheduledTaskTriggerType, type SendMessageInput, type ServiceTurnInitiator, type ServiceTurnInitiatorContext, type Session, type SessionCapabilities, type SessionCommandReceipt, type SessionControlResponse, type SessionEffectiveToolPolicy, type SessionEvent, type SessionEventCompactResult, type SessionEventCompactResultOptions, type SessionEventLatestClass, type SessionEventListOptions, type SessionEventPage, type SessionEventPayloadMode, type SessionEventReadDirection, type SessionEventReadMode, type SessionEventResultMode, type SessionEventSemanticClass, type SessionEventStreamTransport, type SessionEventType, type SessionGoal, type SessionGoalCreatedBy, type SessionGoalStatus, type SessionHumanInputRequest, type SessionLineageResponse, type SessionListResponse, type SessionMcpApprovalPolicy, type SessionMcpCredentialUpdateInput, type SessionMcpServerInput, type SessionMcpServerMetadata, type SessionQueueMutationResponse, type SessionQueueSnapshot, type SessionStatus, type SessionStatusChangedPayload, type SessionStructuredCapabilities, type SessionSummary, type SessionSystemUpdate, type SessionSystemUpdateKind, type SessionSystemUpdateState, type SessionToolPolicy, type SessionTurn, type SessionTurnSource, type SessionTurnStatus, type SetWorkspaceEnvironmentVariableRequest, type SseMessage, type SseReStreamOptions, type SteerMessageResult, type SteerSessionQueueItemRequest, type StreamClosedPayload, type StreamConnectionState, type StreamOpenedPayload, type StreamRevokedPayload, type StreamSessionEventsOptions, type StreamUrlRotatedPayload, type SubmitHumanInputResponseRequest, type SwapActiveSandboxRequest, type SwapActiveSandboxResponse, TTYD_SUBPROTOCOL, type TerminalCapability, type TerminalExecRequest, type TerminalExecResponse, type TerminalPtyExitedPayload, type TerminalPtyOutputDeltaPayload, type TerminalPtyStartedPayload, type ToolAuthNeededPayload, type ToolRef, type TranscriptionAdapter, type TranscriptionAdapterDescriptor, type TranscriptionAdapterStartContext, type TranscriptionAuthorization, type TranscriptionCredentialMode, type TranscriptionDiagnostic, type TranscriptionErrorCode, type TranscriptionEvent, type TranscriptionEventListener, type TranscriptionLifecycleStatus, type TranscriptionPolicyBlockReason, type TranscriptionResultMetadata, type TranscriptionSession, type TranscriptionSessionRequest, type TranscriptionSpeaker, type TranscriptionTargetSelection, type TranscriptionTimeSpan, type TranscriptionWord, TtydClientCommand, TtydServerCommand, type TurnInitiator, type UpdateConnectionRequest, type UpdateKnowledgeMemoryRequest, type UpdateRigRequest, type UpdateScheduledTaskRequest, type UpdateSessionGoalRequest, type UpdateSessionMcpApprovalPolicyRequest, type UpdateSessionMcpApprovalPolicyResponse, type UpdateSessionPinRequest, type UpdateSessionRequest, type UpdateVariableSetRequest, type UpdateWorkspaceEnvironmentRequest, type UpdateWorkspaceMemberRequest, type UpdateWorkspaceRequest, type UpdateWorkspaceSettingsRequest, type UploadFileInput, type UsageEvent, type UsageEventType, type UserApprovalDecisionEventInput, type UserHumanInputResponseEventInput, type UserMessageEventInput, type VariableSet, type VariableSetVariableMetadata, type ViewerHeartbeatRequest, type ViewerHeartbeatResponse, type ViewerHolder, type Workspace, type WorkspaceCaptureDegradedReason, type WorkspaceCaptureFile, type WorkspaceCaptureManifest, type WorkspaceCaptureRepo, type WorkspaceCaptureSignedUrl, type WorkspaceCaptureStats, type WorkspaceControlEvent, type WorkspaceControlEventPage, type WorkspaceControlStreamTransport, type WorkspaceEnvironment, type WorkspaceEnvironmentVariableMetadata, type WorkspaceInferenceControlResponse, type WorkspaceMember, type WorkspaceMemorySearchMode, type WorkspaceMemorySearchRequest, type WorkspaceMemorySearchResponse, type WorkspaceMemorySearchResult, type WorkspaceModelCatalogModel, type WorkspaceModelCatalogResponse, type WorkspaceRegisteredPack, type WorkspaceRevisionCapturedPayload, type WorkspaceRevisionDegradedPayload, type WorkspaceSettings, type WorkspaceTranscriptionPolicy, type WorkspaceTranscriptionTarget, applyUrlRotation, authorizeTranscriptionAdapter, createTranscriptionSessionRequest, desktopSocketUrl, formatSseEvent, isRetryableStreamError, nextDesktopState, parseSseStream, proxySessionEventStream, resolveWorkspaceTranscriptionPolicy, resumeSequenceFromRequest, sessionEventsToSseResponse, sessionEventsToSseStream, streamSessionEvents, streamWorkspaceControlEvents, terminalSocketUrl, ttydAuthFrame, ttydInputFrame, ttydResizeFrame };
package/dist/index.js CHANGED
@@ -1,14 +1,33 @@
1
1
  // src/errors.ts
2
2
  var OpenGeniApiError = class extends Error {
3
3
  status;
4
+ code;
4
5
  body;
5
6
  constructor(status, body) {
6
- super(`OpenGeni API ${status}: ${body || "(empty body)"}`);
7
+ const decoded = decodeApiErrorBody(body);
8
+ super(`OpenGeni API ${status}: ${decoded.message ?? (body || "(empty body)")}`);
7
9
  this.name = "OpenGeniApiError";
8
10
  this.status = status;
11
+ this.code = decoded.code;
9
12
  this.body = body;
10
13
  }
11
14
  };
15
+ function decodeApiErrorBody(body) {
16
+ if (!body) return {};
17
+ try {
18
+ const decoded = JSON.parse(body);
19
+ if (!decoded || typeof decoded !== "object" || Array.isArray(decoded)) return {};
20
+ const record = decoded;
21
+ return {
22
+ ...typeof record.code === "string" && record.code ? { code: record.code } : {},
23
+ ...typeof record.message === "string" && record.message ? { message: record.message } : {}
24
+ };
25
+ } catch {
26
+ return {};
27
+ }
28
+ }
29
+ var OpenGeniSessionListCursorError = class extends OpenGeniApiError {
30
+ };
12
31
  var OpenGeniApiContractMismatchError = class extends Error {
13
32
  expected;
14
33
  actual;
@@ -376,6 +395,8 @@ var SESSION_EVENT_TYPES = [
376
395
  "codex.account.switched",
377
396
  // credential allocator metadata-only per-turn credential selection audit.
378
397
  "codex.credential.selected",
398
+ // Bounded, identity-free deterministic shadow/replay decision.
399
+ "codex.fleet.decision",
379
400
  // credential allocator durable zero-capacity wait lifecycle. These are system/runtime
380
401
  // events, never synthetic user messages.
381
402
  "codex.capacity.waiting",
@@ -469,6 +490,13 @@ var KNOWN_USAGE_EVENT_TYPES = [
469
490
  ];
470
491
 
471
492
  // src/client.ts
493
+ function sessionListQuery(options) {
494
+ const { limit, parentSessionId } = options;
495
+ return {
496
+ ...limit === void 0 ? {} : { limit: String(limit) },
497
+ ...parentSessionId === void 0 ? {} : { parentSessionId: parentSessionId ?? "null" }
498
+ };
499
+ }
472
500
  var OpenGeniClient = class {
473
501
  baseUrl;
474
502
  options;
@@ -486,6 +514,19 @@ var OpenGeniClient = class {
486
514
  request
487
515
  );
488
516
  }
517
+ async getNewSessionDraft(workspaceId) {
518
+ return await this.requestJson(
519
+ "GET",
520
+ `/v1/workspaces/${workspaceId}/new-session-draft`
521
+ );
522
+ }
523
+ async saveNewSessionDraft(workspaceId, request) {
524
+ return await this.requestJson(
525
+ "PUT",
526
+ `/v1/workspaces/${workspaceId}/new-session-draft`,
527
+ request
528
+ );
529
+ }
489
530
  async getSession(workspaceId, sessionId) {
490
531
  return await this.requestJson(
491
532
  "GET",
@@ -512,35 +553,53 @@ var OpenGeniClient = class {
512
553
  );
513
554
  }
514
555
  async listSessions(workspaceId, options = {}) {
556
+ if (options.search?.trim()) {
557
+ const page = await this.listSessionPage(workspaceId, options);
558
+ return [...page.pinned, ...page.sessions];
559
+ }
515
560
  return await this.requestJson(
516
561
  "GET",
517
562
  `/v1/workspaces/${workspaceId}/sessions`,
518
563
  void 0,
519
- {
520
- ...options.limit !== void 0 ? { limit: String(options.limit) } : {},
521
- ...options.search?.trim() ? { search: options.search.trim() } : {},
522
- ...Object.prototype.hasOwnProperty.call(options, "parentSessionId") && options.parentSessionId !== void 0 ? {
523
- parentSessionId: options.parentSessionId === null ? "null" : String(options.parentSessionId)
524
- } : {}
525
- }
564
+ sessionListQuery(options)
526
565
  );
527
566
  }
528
567
  /** Pin-aware ordinary-session page with a stable keyset cursor. */
529
568
  async listSessionPage(workspaceId, options = {}) {
530
- return await this.requestJson(
531
- "GET",
532
- `/v1/workspaces/${workspaceId}/sessions`,
533
- void 0,
534
- {
535
- view: "page",
536
- ...options.limit !== void 0 ? { limit: String(options.limit) } : {},
537
- ...options.cursor !== void 0 ? { cursor: options.cursor } : {},
538
- ...options.search?.trim() ? { search: options.search.trim() } : {},
539
- ...Object.prototype.hasOwnProperty.call(options, "parentSessionId") && options.parentSessionId !== void 0 ? {
540
- parentSessionId: options.parentSessionId === null ? "null" : String(options.parentSessionId)
541
- } : {}
569
+ const search = options.search?.trim();
570
+ let response;
571
+ try {
572
+ response = await this.requestJson(
573
+ "GET",
574
+ `/v1/workspaces/${workspaceId}/sessions`,
575
+ void 0,
576
+ {
577
+ view: "page",
578
+ ...sessionListQuery(options),
579
+ ...options.cursor !== void 0 ? { cursor: options.cursor } : {},
580
+ ...search ? { search } : {},
581
+ ...options.pinsOnly ? { pinsOnly: "true" } : {}
582
+ }
583
+ );
584
+ } catch (error) {
585
+ if (error instanceof OpenGeniApiError && error.status === 410) {
586
+ throw new OpenGeniSessionListCursorError(error.status, error.body);
542
587
  }
543
- );
588
+ throw error;
589
+ }
590
+ if (Array.isArray(response)) {
591
+ if (options.cursor) {
592
+ throw new Error("The connected OpenGeni API does not support stable session-page cursors");
593
+ }
594
+ if (search) {
595
+ throw new Error("The connected OpenGeni API does not support session search");
596
+ }
597
+ if (options.pinsOnly) {
598
+ throw new Error("The connected OpenGeni API does not support pins-only session lists");
599
+ }
600
+ return { pinned: [], sessions: response, nextCursor: null };
601
+ }
602
+ return response;
544
603
  }
545
604
  /** Set this authenticated member's personal workspace pin for a session. */
546
605
  async updateSessionPin(workspaceId, sessionId, request) {
@@ -1604,13 +1663,14 @@ var OpenGeniClient = class {
1604
1663
  * -> complete. Returns the ready `FileAsset`.
1605
1664
  */
1606
1665
  async uploadFile(workspaceId, input) {
1607
- const body = input.data instanceof Uint8Array ? new Blob([input.data.slice()]) : input.data;
1666
+ const body = input.data instanceof Uint8Array ? new Blob([input.data.slice()]) : input.data instanceof ArrayBuffer ? input.data.slice(0) : input.data;
1608
1667
  const sizeBytes = typeof body === "string" ? new TextEncoder().encode(body).byteLength : body instanceof Blob ? body.size : body.byteLength;
1668
+ const sha256 = input.sha256 ?? await sha256ForUpload(body);
1609
1669
  const upload = await this.beginFileUpload(workspaceId, {
1610
1670
  filename: input.filename,
1611
1671
  contentType: input.contentType,
1612
1672
  sizeBytes,
1613
- ...input.sha256 !== void 0 ? { sha256: input.sha256 } : {}
1673
+ sha256
1614
1674
  });
1615
1675
  const putResponse = await this.fetchImpl(upload.putUrl, {
1616
1676
  method: "PUT",
@@ -2199,6 +2259,11 @@ function assertApiContractResponse(response) {
2199
2259
  throw new OpenGeniApiContractMismatchError(OPENGENI_API_CONTRACT_REVISION, actual);
2200
2260
  }
2201
2261
  }
2262
+ async function sha256ForUpload(body) {
2263
+ const bytes = typeof body === "string" ? new TextEncoder().encode(body) : body instanceof Blob ? new Uint8Array(await body.arrayBuffer()) : new Uint8Array(body);
2264
+ const digest = await globalThis.crypto.subtle.digest("SHA-256", bytes);
2265
+ return [...new Uint8Array(digest)].map((byte) => byte.toString(16).padStart(2, "0")).join("");
2266
+ }
2202
2267
  async function safeText(response) {
2203
2268
  try {
2204
2269
  return await response.text();
@@ -2667,6 +2732,7 @@ export {
2667
2732
  OpenGeniApiContractMismatchError,
2668
2733
  OpenGeniApiError,
2669
2734
  OpenGeniClient,
2735
+ OpenGeniSessionListCursorError,
2670
2736
  OpenGeniStreamError,
2671
2737
  RETAINED_OUTPUT_DEFAULT_PAGE_BYTES,
2672
2738
  RETAINED_OUTPUT_MAX_PAGE_BYTES,