@opengeni/sdk 0.37.0 → 0.41.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.
@@ -1,3 +1,4 @@
1
+ export declare const WORKSPACE_INSTRUCTION_POLICY_CONTENT_MAX_CHARS = 262144;
1
2
  export type WorkspaceInstructionPolicyKind = "charter" | "policy";
2
3
  export type WorkspaceInstructionPolicyScope = "global" | "role";
3
4
  export type WorkspaceInstructionPolicyProvenanceSource = "human" | "onboarding" | "knowledge_proposal" | "legacy_import";
@@ -15,6 +16,7 @@ export type WorkspaceInstructionPolicyRevisionIdentity = {
15
16
  contentHash: string;
16
17
  };
17
18
  export type WorkspaceInstructionPolicyRevision = WorkspaceInstructionPolicyRevisionIdentity & WorkspaceInstructionPolicyTarget & {
19
+ operationId: string;
18
20
  accountId: string;
19
21
  workspaceId: string;
20
22
  content: string;
@@ -36,6 +38,7 @@ export type WorkspaceInstructionPolicyHead = WorkspaceInstructionPolicyTarget &
36
38
  };
37
39
  export type WorkspaceInstructionPolicyActivationEvent = WorkspaceInstructionPolicyTarget & {
38
40
  id: string;
41
+ operationId: string;
39
42
  accountId: string;
40
43
  workspaceId: string;
41
44
  type: WorkspaceInstructionPolicyActivationType;
@@ -47,12 +50,14 @@ export type WorkspaceInstructionPolicyActivationEvent = WorkspaceInstructionPoli
47
50
  createdAt: string;
48
51
  };
49
52
  export type CreateWorkspaceInstructionPolicyDraftRequest = WorkspaceInstructionPolicyTarget & {
53
+ operationId?: string;
50
54
  content: string;
51
55
  provenanceSource?: WorkspaceInstructionPolicyDraftProvenanceSource;
52
56
  provenanceSourceId?: string | null;
53
57
  supersedesRevisionId?: string | null;
54
58
  };
55
59
  export type ImportLegacyWorkspaceInstructionPolicyDraftRequest = {
60
+ operationId?: string;
56
61
  supersedesRevisionId?: string | null;
57
62
  };
58
63
  export type WorkspaceInstructionPolicyListOptions = {
@@ -79,12 +84,16 @@ export type WorkspaceInstructionPolicyDiffResponse = {
79
84
  diff: string;
80
85
  };
81
86
  export type ActivateWorkspaceInstructionPolicyRequest = {
87
+ operationId?: string;
82
88
  expectedCurrentRevisionId: string | null;
89
+ expectedActivationVersion?: number;
83
90
  reason: string;
84
91
  };
85
92
  export type RollbackWorkspaceInstructionPolicyRequest = {
93
+ operationId?: string;
86
94
  targetRevisionId: string;
87
95
  expectedCurrentRevisionId: string;
96
+ expectedActivationVersion?: number;
88
97
  reason: string;
89
98
  };
90
99
  export type WorkspaceInstructionPolicyActivationResponse = {
@@ -96,3 +105,56 @@ export type WorkspaceInstructionPolicyConflictResponse = {
96
105
  message: string;
97
106
  currentHead: WorkspaceInstructionPolicyHead | null;
98
107
  };
108
+ export type WorkspaceInstructionPolicyOperationReuseResponse = {
109
+ code: "WORKSPACE_INSTRUCTION_POLICY_OPERATION_REUSED";
110
+ message: string;
111
+ };
112
+ export type WorkspaceInstructionPolicyOnboardingProposalSource = {
113
+ id: string;
114
+ version: string;
115
+ confidenceBps: number;
116
+ };
117
+ export type CreateWorkspaceInstructionPolicyOnboardingProposalRequest = WorkspaceInstructionPolicyTarget & {
118
+ operationId?: string;
119
+ content: string;
120
+ sourceId: string;
121
+ sourceVersion: string;
122
+ confidenceBps: number;
123
+ expectedCurrentRevisionId: string | null;
124
+ expectedActivationVersion: number;
125
+ };
126
+ export type WorkspaceInstructionPolicyOnboardingProposal = WorkspaceInstructionPolicyTarget & {
127
+ id: string;
128
+ operationId: string;
129
+ accountId: string;
130
+ workspaceId: string;
131
+ source: WorkspaceInstructionPolicyOnboardingProposalSource;
132
+ baseline: WorkspaceInstructionPolicyHead | null;
133
+ draft: WorkspaceInstructionPolicyRevision;
134
+ status: "proposed";
135
+ createdBySubjectId: string;
136
+ createdAt: string;
137
+ };
138
+ export type WorkspaceInstructionPolicyOnboardingProposalListOptions = {
139
+ limit?: number;
140
+ };
141
+ export type WorkspaceInstructionPolicyOnboardingProposalListResponse = {
142
+ proposals: WorkspaceInstructionPolicyOnboardingProposal[];
143
+ truncated: boolean;
144
+ };
145
+ export type WorkspaceInstructionPolicyOnboardingProposalContentErrorResponse = {
146
+ code: "WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_EMPTY" | "WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_OVERSIZED";
147
+ message: string;
148
+ maxChars: number;
149
+ };
150
+ export type WorkspaceInstructionPolicyOnboardingProposalStaleResponse = {
151
+ code: "WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_STALE";
152
+ message: string;
153
+ currentHead: WorkspaceInstructionPolicyHead | null;
154
+ };
155
+ export type WorkspaceInstructionPolicyOnboardingProposalConflictResponse = {
156
+ code: "WORKSPACE_INSTRUCTION_POLICY_ONBOARDING_PROPOSAL_CONFLICT";
157
+ message: string;
158
+ existingProposalId: string;
159
+ existingDraftRevisionId: string;
160
+ };
@@ -31,6 +31,75 @@ export type WorkspaceStateMemoryKindCounts = {
31
31
  preference: number;
32
32
  };
33
33
  export type WorkspaceStateGapCode = "no_document_bases" | "no_visible_documents" | "failed_documents" | "processing_documents" | "missing_topic_coverage" | "no_memory_records" | "pending_memory_review" | "partial_inventory";
34
+ export type WorkspaceStateGovernanceDriftStatus = "identical" | "changed" | "superseded" | "missing" | "unavailable" | "truncated";
35
+ export type WorkspaceStateGetOptions = {
36
+ attemptId?: string;
37
+ };
38
+ export type WorkspaceStateAttemptGovernance = {
39
+ status: "not_requested";
40
+ } | {
41
+ status: "unavailable";
42
+ reason: "attempt_not_found_or_not_authorized";
43
+ driftStatus: "unavailable";
44
+ } | {
45
+ status: "available";
46
+ attemptId: string;
47
+ executionGeneration: number;
48
+ acceptedAt: string;
49
+ policySnapshot: {
50
+ status: "missing";
51
+ } | {
52
+ status: "available";
53
+ id: string;
54
+ createdAt: string;
55
+ entryHash: string;
56
+ policyRole: string | null;
57
+ roleSource: "session_binding" | "metadata_fallback" | "none" | "invalid_metadata_fallback";
58
+ entries: Array<{
59
+ kind: WorkspaceInstructionPolicyKind;
60
+ scope: WorkspaceInstructionPolicyScope;
61
+ roleKey: string | null;
62
+ revisionId: string;
63
+ revision: number;
64
+ contentHash: string;
65
+ activationVersion: number;
66
+ activatedAt: string;
67
+ provenance: {
68
+ source: WorkspaceInstructionPolicyProvenanceSource;
69
+ sourceIdHash: string | null;
70
+ };
71
+ }>;
72
+ };
73
+ preferenceSnapshot: {
74
+ status: "missing";
75
+ } | {
76
+ status: "available";
77
+ id: string;
78
+ createdAt: string;
79
+ descriptorHash: string;
80
+ descriptorCount: number;
81
+ truncated: boolean;
82
+ };
83
+ drift: {
84
+ overall: WorkspaceStateGovernanceDriftStatus;
85
+ policy: {
86
+ status: WorkspaceStateGovernanceDriftStatus;
87
+ snapshotHash: string | null;
88
+ currentHash: string | null;
89
+ snapshotTargetCount: number;
90
+ currentTargetCount: number;
91
+ };
92
+ preferences: {
93
+ status: WorkspaceStateGovernanceDriftStatus;
94
+ snapshotHash: string | null;
95
+ currentHash: string | null;
96
+ snapshotDescriptorCount: number;
97
+ currentDescriptorCount: number;
98
+ snapshotTruncated: boolean;
99
+ currentTruncated: boolean;
100
+ };
101
+ };
102
+ };
34
103
  export type WorkspaceStateResponse = {
35
104
  workspaceId: string;
36
105
  generatedAt: string;
@@ -39,10 +108,7 @@ export type WorkspaceStateResponse = {
39
108
  source: "read_time_projection";
40
109
  capturedAt: string;
41
110
  };
42
- policySnapshot: {
43
- status: "not_captured";
44
- reason: "workspace_instruction_policy_snapshot_not_implemented";
45
- };
111
+ attemptGovernance: WorkspaceStateAttemptGovernance;
46
112
  };
47
113
  policy: {
48
114
  authority: "workspace_instruction_policy_heads";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeni/sdk",
3
- "version": "0.37.0",
3
+ "version": "0.41.0",
4
4
  "description": "Framework-agnostic TypeScript SDK for the OpenGeni API: typed client, session lifecycle, SSE event streaming with reconnect + replay-by-sequence, and proxy re-streaming helpers.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -26,6 +26,10 @@
26
26
  "types": "./dist/core.d.ts",
27
27
  "import": "./dist/core.js"
28
28
  },
29
+ "./realtime": {
30
+ "types": "./dist/realtime.d.ts",
31
+ "import": "./dist/realtime.js"
32
+ },
29
33
  "./codex-realtime-controller": {
30
34
  "types": "./dist/codex-realtime-controller.d.ts",
31
35
  "import": "./dist/codex-realtime-controller.js"
package/src/client.ts CHANGED
@@ -90,6 +90,8 @@ import type {
90
90
  GetPackResponse,
91
91
  GitHubAppInfo,
92
92
  GitHubRepositoriesResponse,
93
+ GoogleDriveDisconnectRequest,
94
+ GoogleDriveLifecycleActionRequest,
93
95
  KnowledgeMemory,
94
96
  KnowledgeMemorySearchRequest,
95
97
  ListApiKeysResponse,
@@ -220,6 +222,7 @@ import type {
220
222
  import type {
221
223
  ActivateWorkspaceInstructionPolicyRequest,
222
224
  CreateWorkspaceInstructionPolicyDraftRequest,
225
+ CreateWorkspaceInstructionPolicyOnboardingProposalRequest,
223
226
  ImportLegacyWorkspaceInstructionPolicyDraftRequest,
224
227
  RollbackWorkspaceInstructionPolicyRequest,
225
228
  WorkspaceInstructionPolicyActivationResponse,
@@ -227,9 +230,12 @@ import type {
227
230
  WorkspaceInstructionPolicyDiffResponse,
228
231
  WorkspaceInstructionPolicyListOptions,
229
232
  WorkspaceInstructionPolicyListResponse,
233
+ WorkspaceInstructionPolicyOnboardingProposal,
234
+ WorkspaceInstructionPolicyOnboardingProposalListOptions,
235
+ WorkspaceInstructionPolicyOnboardingProposalListResponse,
230
236
  WorkspaceInstructionPolicyRevision,
231
237
  } from "./workspace-instruction-policies";
232
- import type { WorkspaceStateResponse } from "./workspace-state";
238
+ import type { WorkspaceStateGetOptions, WorkspaceStateResponse } from "./workspace-state";
233
239
  import type {
234
240
  ActivatePreferenceRegistryRevisionRequest,
235
241
  ChangePreferenceRegistryScopeRequest,
@@ -1892,10 +1898,16 @@ export class OpenGeniClient {
1892
1898
  }
1893
1899
 
1894
1900
  /** Read-time, secret-safe inventory of policy heads and visible workspace knowledge. */
1895
- async getWorkspaceState(workspaceId: string): Promise<WorkspaceStateResponse> {
1901
+ async getWorkspaceState(
1902
+ workspaceId: string,
1903
+ options: WorkspaceStateGetOptions = {},
1904
+ ): Promise<WorkspaceStateResponse> {
1905
+ const params = new URLSearchParams();
1906
+ if (options.attemptId) params.set("attemptId", options.attemptId);
1907
+ const query = params.size > 0 ? `?${params.toString()}` : "";
1896
1908
  return await this.requestJson<WorkspaceStateResponse>(
1897
1909
  "GET",
1898
- `/v1/workspaces/${workspaceId}/workspace-state`,
1910
+ `/v1/workspaces/${workspaceId}/workspace-state${query}`,
1899
1911
  );
1900
1912
  }
1901
1913
 
@@ -1944,6 +1956,32 @@ export class OpenGeniClient {
1944
1956
  );
1945
1957
  }
1946
1958
 
1959
+ /** List the newest immutable onboarding proposals and their inactive policy drafts. */
1960
+ async listWorkspaceInstructionPolicyOnboardingProposals(
1961
+ workspaceId: string,
1962
+ options: WorkspaceInstructionPolicyOnboardingProposalListOptions = {},
1963
+ ): Promise<WorkspaceInstructionPolicyOnboardingProposalListResponse> {
1964
+ const params = new URLSearchParams();
1965
+ if (options.limit !== undefined) params.set("limit", String(options.limit));
1966
+ const query = params.toString();
1967
+ return await this.requestJson<WorkspaceInstructionPolicyOnboardingProposalListResponse>(
1968
+ "GET",
1969
+ `/v1/workspaces/${workspaceId}/instruction-policies/onboarding-proposals${query ? `?${query}` : ""}`,
1970
+ );
1971
+ }
1972
+
1973
+ /** Create one draft-only proposal against an exact active-policy baseline. */
1974
+ async createWorkspaceInstructionPolicyOnboardingProposal(
1975
+ workspaceId: string,
1976
+ request: CreateWorkspaceInstructionPolicyOnboardingProposalRequest,
1977
+ ): Promise<WorkspaceInstructionPolicyOnboardingProposal> {
1978
+ return await this.requestJson<WorkspaceInstructionPolicyOnboardingProposal>(
1979
+ "POST",
1980
+ `/v1/workspaces/${workspaceId}/instruction-policies/onboarding-proposals`,
1981
+ request,
1982
+ );
1983
+ }
1984
+
1947
1985
  /** Import the stored legacy workspace override as an inactive charter draft. */
1948
1986
  async importLegacyWorkspaceInstructionPolicyDraft(
1949
1987
  workspaceId: string,
@@ -3048,6 +3086,32 @@ export class OpenGeniClient {
3048
3086
  return response.connection;
3049
3087
  }
3050
3088
 
3089
+ async disconnectGoogleDriveConnection(
3090
+ workspaceId: string,
3091
+ connectionId: string,
3092
+ request: GoogleDriveDisconnectRequest,
3093
+ ): Promise<ConnectionMetadata> {
3094
+ const response = await this.requestJson<ConnectionResponse>(
3095
+ "DELETE",
3096
+ `/v1/workspaces/${workspaceId}/connections/${connectionId}`,
3097
+ request,
3098
+ );
3099
+ return response.connection;
3100
+ }
3101
+
3102
+ async transitionGoogleDriveLifecycle(
3103
+ workspaceId: string,
3104
+ connectionId: string,
3105
+ request: GoogleDriveLifecycleActionRequest,
3106
+ ): Promise<ConnectionMetadata> {
3107
+ const response = await this.requestJson<ConnectionResponse>(
3108
+ "PATCH",
3109
+ `/v1/workspaces/${workspaceId}/connections/google-drive/${connectionId}/lifecycle`,
3110
+ request,
3111
+ );
3112
+ return response.connection;
3113
+ }
3114
+
3051
3115
  /** Start an OAuth connection flow; redirect the user to the returned `authorizationUrl`. */
3052
3116
  async startConnectionOAuth(
3053
3117
  workspaceId: string,
@@ -147,6 +147,44 @@ export type CodexRealtimeControllerClient = {
147
147
 
148
148
  export type CodexRealtimeOwnerStorage = Pick<Storage, "getItem" | "setItem" | "removeItem">;
149
149
 
150
+ /** Canonical browser-owner storage namespace for a public realtime model. */
151
+ export function sessionRealtimeOwnerStorageNamespace(model: SessionRealtimeModel): string {
152
+ return model === "gpt-live-1-boulder-alpha" ? "codex-realtime-owner" : "gateway-realtime-owner";
153
+ }
154
+
155
+ /** Canonical browser-owner storage key shared by the SDK controller and React facade. */
156
+ export function sessionRealtimeOwnerStorageKey(
157
+ workspaceId: string,
158
+ sessionId: string,
159
+ model: SessionRealtimeModel,
160
+ ): string {
161
+ return ownerStorageKey(workspaceId, sessionId, sessionRealtimeOwnerStorageNamespace(model));
162
+ }
163
+
164
+ /**
165
+ * Preserve the existing pre-controller owner-presence projection used by the
166
+ * lazy React control. The controller remains the sole authority that validates
167
+ * or removes malformed records once it is constructed.
168
+ */
169
+ export function hasStoredSessionRealtimeOwnerProof(input: {
170
+ workspaceId: string;
171
+ sessionId: string;
172
+ model: SessionRealtimeModel;
173
+ storage?: CodexRealtimeOwnerStorage | undefined;
174
+ }): boolean {
175
+ const storage = input.storage ?? defaultStorage();
176
+ if (!storage) return false;
177
+ try {
178
+ return (
179
+ storage.getItem(
180
+ sessionRealtimeOwnerStorageKey(input.workspaceId, input.sessionId, input.model),
181
+ ) !== null
182
+ );
183
+ } catch {
184
+ return false;
185
+ }
186
+ }
187
+
150
188
  export type CreateCodexRealtimeControllerOptions = {
151
189
  client: CodexRealtimeControllerClient;
152
190
  workspaceId: string;
package/src/index.ts CHANGED
@@ -119,10 +119,14 @@ export type {
119
119
  WorkspaceArtifactMutationResponse,
120
120
  WorkspaceArtifactVersion,
121
121
  } from "./workspace-artifacts";
122
- export { normalizeWorkspaceInstructionPolicyRoleKey } from "./workspace-instruction-policies";
122
+ export {
123
+ normalizeWorkspaceInstructionPolicyRoleKey,
124
+ WORKSPACE_INSTRUCTION_POLICY_CONTENT_MAX_CHARS,
125
+ } from "./workspace-instruction-policies";
123
126
  export type {
124
127
  ActivateWorkspaceInstructionPolicyRequest,
125
128
  CreateWorkspaceInstructionPolicyDraftRequest,
129
+ CreateWorkspaceInstructionPolicyOnboardingProposalRequest,
126
130
  ImportLegacyWorkspaceInstructionPolicyDraftRequest,
127
131
  RollbackWorkspaceInstructionPolicyRequest,
128
132
  WorkspaceInstructionPolicyActivationEvent,
@@ -136,6 +140,14 @@ export type {
136
140
  WorkspaceInstructionPolicyKind,
137
141
  WorkspaceInstructionPolicyListOptions,
138
142
  WorkspaceInstructionPolicyListResponse,
143
+ WorkspaceInstructionPolicyOnboardingProposal,
144
+ WorkspaceInstructionPolicyOnboardingProposalConflictResponse,
145
+ WorkspaceInstructionPolicyOnboardingProposalContentErrorResponse,
146
+ WorkspaceInstructionPolicyOnboardingProposalListOptions,
147
+ WorkspaceInstructionPolicyOnboardingProposalListResponse,
148
+ WorkspaceInstructionPolicyOnboardingProposalSource,
149
+ WorkspaceInstructionPolicyOnboardingProposalStaleResponse,
150
+ WorkspaceInstructionPolicyOperationReuseResponse,
139
151
  WorkspaceInstructionPolicyProvenanceSource,
140
152
  WorkspaceInstructionPolicyRevision,
141
153
  WorkspaceInstructionPolicyRevisionIdentity,
@@ -144,7 +156,10 @@ export type {
144
156
  } from "./workspace-instruction-policies";
145
157
  export type {
146
158
  WorkspaceStateDocumentStatusCounts,
159
+ WorkspaceStateAttemptGovernance,
147
160
  WorkspaceStateGapCode,
161
+ WorkspaceStateGetOptions,
162
+ WorkspaceStateGovernanceDriftStatus,
148
163
  WorkspaceStateMemoryKindCounts,
149
164
  WorkspaceStateMemoryStatusCounts,
150
165
  WorkspaceStateResponse,
@@ -208,6 +223,7 @@ export type {
208
223
  WorkspaceTranscriptionTarget,
209
224
  } from "./transcription";
210
225
  export {
226
+ DEFAULT_FILE_RESOURCE_MOUNT_ROOT,
211
227
  KNOWN_PERMISSIONS,
212
228
  KNOWN_USAGE_EVENT_TYPES,
213
229
  OPENGENI_API_CONTRACT_HEADER,
@@ -348,6 +364,7 @@ export type {
348
364
  CreateWorkspaceRequest,
349
365
  DiscoverMcpCapabilitiesResponse,
350
366
  Document,
367
+ DocumentAuthorityKind,
351
368
  DocumentBase,
352
369
  DocumentCuration,
353
370
  DocumentCurationStatus,
@@ -383,7 +400,11 @@ export type {
383
400
  GitHubRepositoriesResponse,
384
401
  GoogleDriveBrowseItem,
385
402
  GoogleDriveBrowseResponse,
403
+ GoogleDriveConnectionLifecycle,
404
+ GoogleDriveConnectionLifecycleState,
386
405
  GoogleDriveConnectionMetadata,
406
+ GoogleDriveDisconnectRequest,
407
+ GoogleDriveLifecycleActionRequest,
387
408
  GoogleDriveOAuthStartRequest,
388
409
  GoogleDriveOAuthStartResponse,
389
410
  GoogleDriveReadPolicy,
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Public, provider-neutral realtime browser SDK.
3
+ *
4
+ * Import this subpath lazily in browser applications. The base `@opengeni/sdk`
5
+ * entry remains free of eager realtime transport initialization.
6
+ */
7
+ import {
8
+ createCodexRealtimeController,
9
+ hasStoredSessionRealtimeOwnerProof,
10
+ sessionRealtimeOwnerStorageKey,
11
+ sessionRealtimeOwnerStorageNamespace,
12
+ type CodexRealtimeController,
13
+ type CodexRealtimeControllerClient,
14
+ type CodexRealtimeControllerSnapshot,
15
+ type CodexRealtimeControllerStatus,
16
+ type CodexRealtimeDiagnostic,
17
+ type CodexRealtimeDiagnosticKind,
18
+ type CodexRealtimeMicrophoneState,
19
+ type CodexRealtimeOwnerStorage,
20
+ type CreateCodexRealtimeControllerOptions,
21
+ type RealtimeControllerTransportStarter,
22
+ } from "./codex-realtime-controller";
23
+ import { createGatewayRealtimeTransportStarter } from "./gateway-realtime-transport";
24
+ import type { SessionRealtimeModel, WorkspaceRealtimeModelCatalogResponse } from "./types";
25
+
26
+ /** Exact backend-facing methods required by the batteries-included realtime SDK. */
27
+ export type SessionRealtimeClientLike = CodexRealtimeControllerClient & {
28
+ getWorkspaceRealtimeModelCatalog(
29
+ workspaceId: string,
30
+ ): Promise<WorkspaceRealtimeModelCatalogResponse>;
31
+ };
32
+
33
+ export type SessionRealtimeTransportKind = "codex" | "gateway";
34
+
35
+ /** Provider-neutral names for the existing, battle-tested controller projection. */
36
+ export type SessionRealtimeController = CodexRealtimeController;
37
+ export type SessionRealtimeControllerSnapshot = CodexRealtimeControllerSnapshot;
38
+ export type SessionRealtimeControllerStatus = CodexRealtimeControllerStatus;
39
+ export type SessionRealtimeDiagnostic = CodexRealtimeDiagnostic;
40
+ export type SessionRealtimeDiagnosticKind = CodexRealtimeDiagnosticKind;
41
+ export type SessionRealtimeMicrophoneState = CodexRealtimeMicrophoneState;
42
+ export type SessionRealtimeOwnerStorage = CodexRealtimeOwnerStorage;
43
+
44
+ export type CreateSessionRealtimeControllerOptions = Omit<
45
+ CreateCodexRealtimeControllerOptions,
46
+ "client" | "model" | "ownerStorageNamespace" | "startTransport"
47
+ > & {
48
+ client: CodexRealtimeControllerClient;
49
+ model: SessionRealtimeModel;
50
+ };
51
+
52
+ /** Select the existing transport without exposing provider mechanics to hosts. */
53
+ export function sessionRealtimeTransportKind(
54
+ model: SessionRealtimeModel,
55
+ ): SessionRealtimeTransportKind {
56
+ return model === "gpt-live-1-boulder-alpha" ? "codex" : "gateway";
57
+ }
58
+
59
+ /**
60
+ * Compose the exact current controller with its existing Codex Live or AI
61
+ * Gateway transport. Wire, ledger, delegation, recovery, and lifecycle
62
+ * semantics remain owned by the existing implementations below this facade.
63
+ */
64
+ export function createSessionRealtimeController(
65
+ options: CreateSessionRealtimeControllerOptions,
66
+ ): SessionRealtimeController {
67
+ const transport = sessionRealtimeTransportKind(options.model);
68
+ return createCodexRealtimeController({
69
+ ...options,
70
+ ownerStorageNamespace: sessionRealtimeOwnerStorageNamespace(options.model),
71
+ ...(transport === "gateway" ? { startTransport: createGatewayRealtimeTransportStarter() } : {}),
72
+ });
73
+ }
74
+
75
+ export {
76
+ createCodexRealtimeController,
77
+ createGatewayRealtimeTransportStarter,
78
+ hasStoredSessionRealtimeOwnerProof,
79
+ sessionRealtimeOwnerStorageKey,
80
+ sessionRealtimeOwnerStorageNamespace,
81
+ };
82
+ export type {
83
+ CodexRealtimeController,
84
+ CodexRealtimeControllerClient,
85
+ CodexRealtimeControllerSnapshot,
86
+ CodexRealtimeControllerStatus,
87
+ CodexRealtimeDiagnostic,
88
+ CodexRealtimeDiagnosticKind,
89
+ CodexRealtimeMicrophoneState,
90
+ CodexRealtimeOwnerStorage,
91
+ CreateCodexRealtimeControllerOptions,
92
+ RealtimeControllerTransportStarter,
93
+ };
94
+
95
+ export {
96
+ CODEX_REALTIME_NEGOTIATION_TIMEOUT_MS,
97
+ projectSessionRealtimeLifecycle,
98
+ } from "./codex-realtime-controller";
99
+ export type { SessionRealtimeLifecycleProjection } from "./codex-realtime-lifecycle";
100
+
101
+ export {
102
+ CodexRealtimeMicrophoneError,
103
+ acquireCodexRealtimeMicrophone,
104
+ codexRealtimeMicrophoneHealthy,
105
+ startCodexRealtimeWebrtc,
106
+ } from "./codex-realtime";
107
+ export type {
108
+ AcquireCodexRealtimeMicrophoneOptions,
109
+ CodexRealtimeAudibleOutputState,
110
+ CodexRealtimeConnectionHealth,
111
+ CodexRealtimeMicrophoneErrorCode,
112
+ CodexRealtimeNegotiator,
113
+ CodexRealtimeWebrtcSession,
114
+ StartCodexRealtimeWebrtcOptions,
115
+ } from "./codex-realtime";
116
+
117
+ export {
118
+ CODEX_REALTIME_CONTEXT_APPEND_MAX_BYTES,
119
+ CODEX_REALTIME_V3_MAX_EVENT_BYTES,
120
+ CODEX_REALTIME_V3_MAX_IDENTIFIER_BYTES,
121
+ CODEX_REALTIME_V3_MAX_TEXT_BYTES,
122
+ CODEX_REALTIME_V3_PENDING_MAX_BYTES,
123
+ CODEX_REALTIME_V3_PENDING_MAX_ENTRIES,
124
+ CODEX_REALTIME_V3_SYNC_MAX_ENTRIES,
125
+ contextAppendChunks,
126
+ createCodexRealtimeV3Bridge,
127
+ encodeCodexRealtimeV3DelegationContextAppend,
128
+ encodeCodexRealtimeV3SessionContextAppend,
129
+ parseCodexRealtimeV3Event,
130
+ } from "./codex-realtime-v3";
131
+ export type {
132
+ CodexRealtimeV3Bridge,
133
+ CodexRealtimeV3BridgeFatal,
134
+ CodexRealtimeV3BridgeOptions,
135
+ CodexRealtimeV3BridgeSnapshot,
136
+ CodexRealtimeV3ContextAppendChannel,
137
+ CodexRealtimeV3DelegationContextAppend,
138
+ CodexRealtimeV3Event,
139
+ CodexRealtimeV3ParseFailure,
140
+ CodexRealtimeV3ParseResult,
141
+ CodexRealtimeV3SessionContextAppend,
142
+ } from "./codex-realtime-v3";
143
+
144
+ export {
145
+ CODEX_REALTIME_INITIAL_ITEMS_MAX_COUNT,
146
+ CODEX_REALTIME_INITIAL_ITEMS_MAX_TOKENS,
147
+ } from "./codex-realtime-v3-wire";
148
+ export type { CodexRealtimeInitialItem } from "./codex-realtime-v3-wire";
149
+
150
+ export type {
151
+ ActivateCodexRealtimeConnectionRequest,
152
+ BeginSessionRealtimeRequest,
153
+ CodexRealtimeVoice,
154
+ CodexRealtimeWebrtcRequest,
155
+ CodexRealtimeWebrtcResponse,
156
+ CodexRealtimeWebrtcVersion,
157
+ EndSessionRealtimeRequest,
158
+ GatewayRealtimeConnectRequest,
159
+ GatewayRealtimeConnectResponse,
160
+ GatewayRealtimeInitialItem,
161
+ RenewSessionRealtimeRequest,
162
+ SessionRealtimeEndReason,
163
+ SessionRealtimeLedgerEntry,
164
+ SessionRealtimeMode,
165
+ SessionRealtimeModel,
166
+ SessionRealtimeMutationResponse,
167
+ SessionRealtimeState,
168
+ SyncSessionRealtimeLedgerRequest,
169
+ SyncSessionRealtimeLedgerResponse,
170
+ WorkspaceRealtimeModelCatalogItem,
171
+ WorkspaceRealtimeModelCatalogResponse,
172
+ } from "./types";