@opengeni/sdk 0.36.1 → 0.40.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.
Files changed (44) hide show
  1. package/README.md +57 -2
  2. package/dist/chunk-DXDL7EEW.js +573 -0
  3. package/dist/chunk-DXDL7EEW.js.map +1 -0
  4. package/dist/chunk-OINSI33U.js +97 -0
  5. package/dist/chunk-OINSI33U.js.map +1 -0
  6. package/dist/{chunk-B7E4FPNZ.js → chunk-SSQPCFEN.js} +159 -108
  7. package/dist/chunk-SSQPCFEN.js.map +1 -0
  8. package/dist/chunk-XBBPYTI5.js +2018 -0
  9. package/dist/chunk-XBBPYTI5.js.map +1 -0
  10. package/dist/client.d.ts +39 -4
  11. package/dist/codex-realtime-controller.d.ts +124 -0
  12. package/dist/codex-realtime-controller.js +18 -0
  13. package/dist/codex-realtime-controller.js.map +1 -0
  14. package/dist/codex-realtime-lifecycle.d.ts +18 -0
  15. package/dist/codex-realtime-v3-wire.d.ts +86 -0
  16. package/dist/codex-realtime-v3.d.ts +52 -0
  17. package/dist/codex-realtime.d.ts +68 -0
  18. package/dist/core.js +6 -4
  19. package/dist/gateway-realtime-transport.d.ts +2 -0
  20. package/dist/gateway-realtime-transport.js +7 -0
  21. package/dist/gateway-realtime-transport.js.map +1 -0
  22. package/dist/index.d.ts +13 -4
  23. package/dist/index.js +40 -6
  24. package/dist/index.js.map +1 -1
  25. package/dist/realtime.d.ts +45 -0
  26. package/dist/realtime.js +73 -0
  27. package/dist/realtime.js.map +1 -0
  28. package/dist/types.d.ts +225 -6
  29. package/dist/workspace-instruction-policies.d.ts +12 -0
  30. package/dist/workspace-state.d.ts +70 -4
  31. package/package.json +14 -1
  32. package/src/client.ts +248 -20
  33. package/src/codex-realtime-controller.ts +1465 -0
  34. package/src/codex-realtime-lifecycle.ts +97 -0
  35. package/src/codex-realtime-v3-wire.ts +349 -0
  36. package/src/codex-realtime-v3.ts +575 -0
  37. package/src/codex-realtime.ts +411 -0
  38. package/src/gateway-realtime-transport.ts +650 -0
  39. package/src/index.ts +81 -0
  40. package/src/realtime.ts +172 -0
  41. package/src/types.ts +280 -6
  42. package/src/workspace-instruction-policies.ts +13 -0
  43. package/src/workspace-state.ts +82 -4
  44. package/dist/chunk-B7E4FPNZ.js.map +0 -1
package/src/client.ts CHANGED
@@ -14,6 +14,7 @@ import {
14
14
  } from "./workspace-control-stream";
15
15
  import type {
16
16
  AccessContext,
17
+ ActivateCodexRealtimeConnectionRequest,
17
18
  AddWorkspaceMemberRequest,
18
19
  ApiKey,
19
20
  BillingEntitlementsResponse,
@@ -23,6 +24,10 @@ import type {
23
24
  CodexOverviewResponse,
24
25
  CodexAllocatorUpdate,
25
26
  CodexConnectionStatus,
27
+ CodexRealtimeWebrtcRequest,
28
+ CodexRealtimeWebrtcResponse,
29
+ GatewayRealtimeConnectRequest,
30
+ GatewayRealtimeConnectResponse,
26
31
  CodexConnectPoll,
27
32
  CodexConnectStart,
28
33
  CodexUsage,
@@ -31,6 +36,7 @@ import type {
31
36
  BillingUsageResponse,
32
37
  InsightsRange,
33
38
  WorkspaceInsightsResponse,
39
+ BeginSessionRealtimeRequest,
34
40
  CapabilityCatalogItem,
35
41
  CapabilityCatalogResponse,
36
42
  CapabilityInstallation,
@@ -39,6 +45,7 @@ import type {
39
45
  MoveDocumentRequest,
40
46
  ClientConfig,
41
47
  WorkspaceModelCatalogResponse,
48
+ WorkspaceRealtimeModelCatalogResponse,
42
49
  ClientSessionEventInput,
43
50
  CompactSessionContextResult,
44
51
  CompleteFileUploadResponse,
@@ -50,6 +57,7 @@ import type {
50
57
  CreateCheckoutResponse,
51
58
  OpenGeniSlackBotInstallRequest,
52
59
  OpenGeniSlackBotInstallStart,
60
+ SlackReactionChannelListResponse,
53
61
  CreateConnectionRequest,
54
62
  CreateDocumentBaseRequest,
55
63
  CreateFileUploadRequest,
@@ -69,6 +77,7 @@ import type {
69
77
  DeviceEnrollmentDenyResponse,
70
78
  DeviceEnrollmentLookupResponse,
71
79
  MintEnrollTokenResponse,
80
+ EndSessionRealtimeRequest,
72
81
  DiscoverMcpCapabilitiesResponse,
73
82
  Document,
74
83
  DocumentBase,
@@ -81,6 +90,8 @@ import type {
81
90
  GetPackResponse,
82
91
  GitHubAppInfo,
83
92
  GitHubRepositoriesResponse,
93
+ GoogleDriveDisconnectRequest,
94
+ GoogleDriveLifecycleActionRequest,
84
95
  KnowledgeMemory,
85
96
  KnowledgeMemorySearchRequest,
86
97
  ListApiKeysResponse,
@@ -114,6 +125,10 @@ import type {
114
125
  SessionGoal,
115
126
  SessionHumanInputRequest,
116
127
  SessionLineageResponse,
128
+ SessionRealtimeMutationResponse,
129
+ SyncSessionRealtimeLedgerRequest,
130
+ SyncSessionRealtimeLedgerResponse,
131
+ RenewSessionRealtimeRequest,
117
132
  SessionMcpCredentialUpdateInput,
118
133
  UpdateSessionMcpApprovalPolicyRequest,
119
134
  UpdateSessionMcpApprovalPolicyResponse,
@@ -216,7 +231,7 @@ import type {
216
231
  WorkspaceInstructionPolicyListResponse,
217
232
  WorkspaceInstructionPolicyRevision,
218
233
  } from "./workspace-instruction-policies";
219
- import type { WorkspaceStateResponse } from "./workspace-state";
234
+ import type { WorkspaceStateGetOptions, WorkspaceStateResponse } from "./workspace-state";
220
235
  import type {
221
236
  ActivatePreferenceRegistryRevisionRequest,
222
237
  ChangePreferenceRegistryScopeRequest,
@@ -564,6 +579,111 @@ export class OpenGeniClient {
564
579
  );
565
580
  }
566
581
 
582
+ /** Negotiate one server-mediated connected-Codex GPT-Live V3 WebRTC call. */
583
+ async negotiateCodexRealtimeWebrtc(
584
+ workspaceId: string,
585
+ sessionId: string,
586
+ request: CodexRealtimeWebrtcRequest,
587
+ options: { signal?: AbortSignal | undefined } = {},
588
+ ): Promise<CodexRealtimeWebrtcResponse> {
589
+ return await this.requestJson<CodexRealtimeWebrtcResponse>(
590
+ "POST",
591
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/webrtc`,
592
+ request,
593
+ {},
594
+ { signal: options.signal },
595
+ );
596
+ }
597
+
598
+ /** Mint a short-lived browser token for one AI Gateway realtime connection. */
599
+ async negotiateGatewayRealtime(
600
+ workspaceId: string,
601
+ sessionId: string,
602
+ request: GatewayRealtimeConnectRequest,
603
+ options: { signal?: AbortSignal | undefined } = {},
604
+ ): Promise<GatewayRealtimeConnectResponse> {
605
+ return await this.requestJson<GatewayRealtimeConnectResponse>(
606
+ "POST",
607
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/gateway`,
608
+ request,
609
+ {},
610
+ { signal: options.signal },
611
+ );
612
+ }
613
+
614
+ /** Promote a negotiated connection only after its browser data channel is ready. */
615
+ async activateCodexRealtimeConnection(
616
+ workspaceId: string,
617
+ sessionId: string,
618
+ realtimeId: string,
619
+ connectionId: string,
620
+ request: ActivateCodexRealtimeConnectionRequest,
621
+ options: { signal?: AbortSignal | undefined } = {},
622
+ ): Promise<SessionRealtimeMutationResponse> {
623
+ return await this.requestJson<SessionRealtimeMutationResponse>(
624
+ "POST",
625
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/${realtimeId}/connections/${connectionId}/activate`,
626
+ request,
627
+ {},
628
+ { signal: options.signal },
629
+ );
630
+ }
631
+
632
+ /** Atomically enter realtime mode for this ordinary session. */
633
+ async beginSessionRealtime(
634
+ workspaceId: string,
635
+ sessionId: string,
636
+ request: BeginSessionRealtimeRequest,
637
+ ): Promise<SessionRealtimeMutationResponse> {
638
+ return await this.requestJson<SessionRealtimeMutationResponse>(
639
+ "POST",
640
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime`,
641
+ request,
642
+ );
643
+ }
644
+
645
+ /** Renew the exact authenticated browser owner's realtime lease. */
646
+ async heartbeatSessionRealtime(
647
+ workspaceId: string,
648
+ sessionId: string,
649
+ realtimeId: string,
650
+ request: RenewSessionRealtimeRequest,
651
+ ): Promise<SessionRealtimeMutationResponse> {
652
+ return await this.requestJson<SessionRealtimeMutationResponse>(
653
+ "PATCH",
654
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/${realtimeId}/heartbeat`,
655
+ request,
656
+ );
657
+ }
658
+
659
+ /** Persist finalized V3 events, acknowledge delivery, and replay pending outbound context. */
660
+ async syncSessionRealtimeLedger(
661
+ workspaceId: string,
662
+ sessionId: string,
663
+ realtimeId: string,
664
+ request: SyncSessionRealtimeLedgerRequest,
665
+ ): Promise<SyncSessionRealtimeLedgerResponse> {
666
+ return await this.requestJson<SyncSessionRealtimeLedgerResponse>(
667
+ "POST",
668
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/${realtimeId}/sync`,
669
+ request,
670
+ );
671
+ }
672
+
673
+ /** End realtime mode and restore ordinary text workflow admission. */
674
+ async endSessionRealtime(
675
+ workspaceId: string,
676
+ sessionId: string,
677
+ realtimeId: string,
678
+ request: EndSessionRealtimeRequest,
679
+ ): Promise<SessionRealtimeMutationResponse> {
680
+ return await this.requestJson<SessionRealtimeMutationResponse>(
681
+ "DELETE",
682
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/${realtimeId}`,
683
+ request,
684
+ );
685
+ }
686
+
567
687
  async listTurns(
568
688
  workspaceId: string,
569
689
  sessionId: string,
@@ -658,7 +778,10 @@ export class OpenGeniClient {
658
778
  return await this.requestJson<DeviceEnrollmentApproveResponse>(
659
779
  "POST",
660
780
  `/v1/workspaces/${workspaceId}/enrollments/device/approve`,
661
- { userCode: request.userCode, allowScreenControl: request.allowScreenControl ?? false },
781
+ {
782
+ userCode: request.userCode,
783
+ allowScreenControl: request.allowScreenControl ?? false,
784
+ },
662
785
  );
663
786
  }
664
787
 
@@ -811,7 +934,10 @@ export class OpenGeniClient {
811
934
  );
812
935
  assertApiContractResponse(response);
813
936
  if (!response.ok) {
814
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
937
+ throw await apiErrorFromResponse(response, {
938
+ method: "GET",
939
+ correlationId,
940
+ });
815
941
  }
816
942
  await assertJsonResponse(response, { method: "GET", correlationId });
817
943
  const body = await response.json();
@@ -871,7 +997,9 @@ export class OpenGeniClient {
871
997
  async getLatestEventResult(
872
998
  workspaceId: string,
873
999
  sessionId: string,
874
- options: Omit<SessionEventCompactResultOptions, "resultMode"> = { latest: "terminal" },
1000
+ options: Omit<SessionEventCompactResultOptions, "resultMode"> = {
1001
+ latest: "terminal",
1002
+ },
875
1003
  ): Promise<SessionEventCompactResult | null> {
876
1004
  return await this.listEventPage(workspaceId, sessionId, {
877
1005
  ...options,
@@ -909,7 +1037,11 @@ export class OpenGeniClient {
909
1037
  async pauseSession(
910
1038
  workspaceId: string,
911
1039
  sessionId: string,
912
- options: { reason?: string; clientEventId?: string; expectedControlEtag?: string } = {},
1040
+ options: {
1041
+ reason?: string;
1042
+ clientEventId?: string;
1043
+ expectedControlEtag?: string;
1044
+ } = {},
913
1045
  ): Promise<SessionControlResponse> {
914
1046
  return await this.controlSession(workspaceId, sessionId, {
915
1047
  action: "pause",
@@ -944,7 +1076,9 @@ export class OpenGeniClient {
944
1076
  status?: SessionHumanInputRequest["status"];
945
1077
  } = {},
946
1078
  ): Promise<SessionHumanInputRequest[]> {
947
- const result = await this.requestJson<{ requests: SessionHumanInputRequest[] }>(
1079
+ const result = await this.requestJson<{
1080
+ requests: SessionHumanInputRequest[];
1081
+ }>(
948
1082
  "GET",
949
1083
  `/v1/workspaces/${workspaceId}/sessions/${sessionId}/human-input-requests`,
950
1084
  undefined,
@@ -1021,7 +1155,10 @@ export class OpenGeniClient {
1021
1155
  });
1022
1156
  assertApiContractResponse(response);
1023
1157
  if (!response.ok) {
1024
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
1158
+ throw await apiErrorFromResponse(response, {
1159
+ method: "GET",
1160
+ correlationId,
1161
+ });
1025
1162
  }
1026
1163
  if (!response.body) {
1027
1164
  throw new OpenGeniApiError(response.status, "SSE response did not include a readable body");
@@ -1113,7 +1250,7 @@ export class OpenGeniClient {
1113
1250
  workspaceId: string,
1114
1251
  sessionId: string,
1115
1252
  request: {
1116
- action: "pause" | "resume";
1253
+ action: "pause" | "resume" | "cancel";
1117
1254
  reason?: string;
1118
1255
  clientEventId: string;
1119
1256
  expectedControlEtag?: string;
@@ -1129,7 +1266,11 @@ export class OpenGeniClient {
1129
1266
  async resumeSession(
1130
1267
  workspaceId: string,
1131
1268
  sessionId: string,
1132
- options: { reason?: string; clientEventId?: string; expectedControlEtag?: string } = {},
1269
+ options: {
1270
+ reason?: string;
1271
+ clientEventId?: string;
1272
+ expectedControlEtag?: string;
1273
+ } = {},
1133
1274
  ): Promise<SessionControlResponse> {
1134
1275
  return await this.controlSession(workspaceId, sessionId, {
1135
1276
  action: "resume",
@@ -1139,6 +1280,24 @@ export class OpenGeniClient {
1139
1280
  });
1140
1281
  }
1141
1282
 
1283
+ /**
1284
+ * Terminally cancel a session subtree. Unlike pause, cancellation drains
1285
+ * queued work and permanently fences new prompts for the session and every
1286
+ * descendant.
1287
+ */
1288
+ async cancelSession(
1289
+ workspaceId: string,
1290
+ sessionId: string,
1291
+ options: { reason?: string; clientEventId?: string; expectedControlEtag?: string } = {},
1292
+ ): Promise<SessionControlResponse> {
1293
+ return await this.controlSession(workspaceId, sessionId, {
1294
+ action: "cancel",
1295
+ clientEventId: options.clientEventId ?? crypto.randomUUID(),
1296
+ ...(options.reason ? { reason: options.reason } : {}),
1297
+ ...(options.expectedControlEtag ? { expectedControlEtag: options.expectedControlEtag } : {}),
1298
+ });
1299
+ }
1300
+
1142
1301
  async setWorkspaceInferenceState(
1143
1302
  workspaceId: string,
1144
1303
  request: {
@@ -1180,7 +1339,10 @@ export class OpenGeniClient {
1180
1339
  );
1181
1340
  assertApiContractResponse(response);
1182
1341
  if (!response.ok) {
1183
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
1342
+ throw await apiErrorFromResponse(response, {
1343
+ method: "GET",
1344
+ correlationId,
1345
+ });
1184
1346
  }
1185
1347
  await assertJsonResponse(response, { method: "GET", correlationId });
1186
1348
  const events = (await response.json()) as WorkspaceControlEvent[];
@@ -1230,13 +1392,19 @@ export class OpenGeniClient {
1230
1392
  }),
1231
1393
  {
1232
1394
  method: "GET",
1233
- headers: { ...this.headers(correlationId), Accept: "text/event-stream" },
1395
+ headers: {
1396
+ ...this.headers(correlationId),
1397
+ Accept: "text/event-stream",
1398
+ },
1234
1399
  ...(options.signal ? { signal: options.signal } : {}),
1235
1400
  },
1236
1401
  );
1237
1402
  assertApiContractResponse(response);
1238
1403
  if (!response.ok) {
1239
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
1404
+ throw await apiErrorFromResponse(response, {
1405
+ method: "GET",
1406
+ correlationId,
1407
+ });
1240
1408
  }
1241
1409
  if (!response.body) {
1242
1410
  throw new OpenGeniApiError(response.status, "SSE response did not include a readable body");
@@ -1698,6 +1866,16 @@ export class OpenGeniClient {
1698
1866
  );
1699
1867
  }
1700
1868
 
1869
+ /** Authenticated realtime voice models and credential readiness. */
1870
+ async getWorkspaceRealtimeModelCatalog(
1871
+ workspaceId: string,
1872
+ ): Promise<WorkspaceRealtimeModelCatalogResponse> {
1873
+ return await this.requestJson<WorkspaceRealtimeModelCatalogResponse>(
1874
+ "GET",
1875
+ `/v1/workspaces/${workspaceId}/realtime-model-catalog`,
1876
+ );
1877
+ }
1878
+
1701
1879
  /** The caller's access context: subject, account + workspace grants, defaults. */
1702
1880
  async getAccessContext(): Promise<AccessContext> {
1703
1881
  return await this.requestJson<AccessContext>("GET", "/v1/access/me");
@@ -1716,10 +1894,16 @@ export class OpenGeniClient {
1716
1894
  }
1717
1895
 
1718
1896
  /** Read-time, secret-safe inventory of policy heads and visible workspace knowledge. */
1719
- async getWorkspaceState(workspaceId: string): Promise<WorkspaceStateResponse> {
1897
+ async getWorkspaceState(
1898
+ workspaceId: string,
1899
+ options: WorkspaceStateGetOptions = {},
1900
+ ): Promise<WorkspaceStateResponse> {
1901
+ const params = new URLSearchParams();
1902
+ if (options.attemptId) params.set("attemptId", options.attemptId);
1903
+ const query = params.size > 0 ? `?${params.toString()}` : "";
1720
1904
  return await this.requestJson<WorkspaceStateResponse>(
1721
1905
  "GET",
1722
- `/v1/workspaces/${workspaceId}/workspace-state`,
1906
+ `/v1/workspaces/${workspaceId}/workspace-state${query}`,
1723
1907
  );
1724
1908
  }
1725
1909
 
@@ -2072,7 +2256,9 @@ export class OpenGeniClient {
2072
2256
  "GET",
2073
2257
  `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}/runs`,
2074
2258
  undefined,
2075
- { ...(options.limit !== undefined ? { limit: String(options.limit) } : {}) },
2259
+ {
2260
+ ...(options.limit !== undefined ? { limit: String(options.limit) } : {}),
2261
+ },
2076
2262
  );
2077
2263
  }
2078
2264
 
@@ -2436,7 +2622,10 @@ export class OpenGeniClient {
2436
2622
  throw error;
2437
2623
  }
2438
2624
  if (!response.ok) {
2439
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
2625
+ throw await apiErrorFromResponse(response, {
2626
+ method: "GET",
2627
+ correlationId,
2628
+ });
2440
2629
  }
2441
2630
  if (response.status !== 200 && response.status !== 206) {
2442
2631
  await cancelResponseBody(response, "unexpected retained artifact response status");
@@ -2833,6 +3022,19 @@ export class OpenGeniClient {
2833
3022
  );
2834
3023
  }
2835
3024
 
3025
+ async listOpenGeniSlackReactionChannels(
3026
+ workspaceId: string,
3027
+ connectionId: string,
3028
+ cursor?: string,
3029
+ ): Promise<SlackReactionChannelListResponse> {
3030
+ const query = new URLSearchParams({ connectionId });
3031
+ if (cursor) query.set("cursor", cursor);
3032
+ return await this.requestJson<SlackReactionChannelListResponse>(
3033
+ "GET",
3034
+ `/v1/workspaces/${workspaceId}/integrations/slack/reaction-channels?${query}`,
3035
+ );
3036
+ }
3037
+
2836
3038
  async updateConnection(
2837
3039
  workspaceId: string,
2838
3040
  connectionId: string,
@@ -2854,6 +3056,32 @@ export class OpenGeniClient {
2854
3056
  return response.connection;
2855
3057
  }
2856
3058
 
3059
+ async disconnectGoogleDriveConnection(
3060
+ workspaceId: string,
3061
+ connectionId: string,
3062
+ request: GoogleDriveDisconnectRequest,
3063
+ ): Promise<ConnectionMetadata> {
3064
+ const response = await this.requestJson<ConnectionResponse>(
3065
+ "DELETE",
3066
+ `/v1/workspaces/${workspaceId}/connections/${connectionId}`,
3067
+ request,
3068
+ );
3069
+ return response.connection;
3070
+ }
3071
+
3072
+ async transitionGoogleDriveLifecycle(
3073
+ workspaceId: string,
3074
+ connectionId: string,
3075
+ request: GoogleDriveLifecycleActionRequest,
3076
+ ): Promise<ConnectionMetadata> {
3077
+ const response = await this.requestJson<ConnectionResponse>(
3078
+ "PATCH",
3079
+ `/v1/workspaces/${workspaceId}/connections/google-drive/${connectionId}/lifecycle`,
3080
+ request,
3081
+ );
3082
+ return response.connection;
3083
+ }
3084
+
2857
3085
  /** Start an OAuth connection flow; redirect the user to the returned `authorizationUrl`. */
2858
3086
  async startConnectionOAuth(
2859
3087
  workspaceId: string,
@@ -3175,10 +3403,10 @@ export class OpenGeniClient {
3175
3403
  workspaceId: string,
3176
3404
  accountId: string,
3177
3405
  ): Promise<{ disconnected: boolean; newActiveId: string | null }> {
3178
- return await this.requestJson<{ disconnected: boolean; newActiveId: string | null }>(
3179
- "DELETE",
3180
- `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}`,
3181
- );
3406
+ return await this.requestJson<{
3407
+ disconnected: boolean;
3408
+ newActiveId: string | null;
3409
+ }>("DELETE", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}`);
3182
3410
  }
3183
3411
 
3184
3412
  /** Rename a Codex account (label only in P1). */