@opengeni/sdk 0.36.0 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/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,
@@ -114,6 +123,10 @@ import type {
114
123
  SessionGoal,
115
124
  SessionHumanInputRequest,
116
125
  SessionLineageResponse,
126
+ SessionRealtimeMutationResponse,
127
+ SyncSessionRealtimeLedgerRequest,
128
+ SyncSessionRealtimeLedgerResponse,
129
+ RenewSessionRealtimeRequest,
117
130
  SessionMcpCredentialUpdateInput,
118
131
  UpdateSessionMcpApprovalPolicyRequest,
119
132
  UpdateSessionMcpApprovalPolicyResponse,
@@ -564,6 +577,111 @@ export class OpenGeniClient {
564
577
  );
565
578
  }
566
579
 
580
+ /** Negotiate one server-mediated connected-Codex GPT-Live V3 WebRTC call. */
581
+ async negotiateCodexRealtimeWebrtc(
582
+ workspaceId: string,
583
+ sessionId: string,
584
+ request: CodexRealtimeWebrtcRequest,
585
+ options: { signal?: AbortSignal | undefined } = {},
586
+ ): Promise<CodexRealtimeWebrtcResponse> {
587
+ return await this.requestJson<CodexRealtimeWebrtcResponse>(
588
+ "POST",
589
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/webrtc`,
590
+ request,
591
+ {},
592
+ { signal: options.signal },
593
+ );
594
+ }
595
+
596
+ /** Mint a short-lived browser token for one AI Gateway realtime connection. */
597
+ async negotiateGatewayRealtime(
598
+ workspaceId: string,
599
+ sessionId: string,
600
+ request: GatewayRealtimeConnectRequest,
601
+ options: { signal?: AbortSignal | undefined } = {},
602
+ ): Promise<GatewayRealtimeConnectResponse> {
603
+ return await this.requestJson<GatewayRealtimeConnectResponse>(
604
+ "POST",
605
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/gateway`,
606
+ request,
607
+ {},
608
+ { signal: options.signal },
609
+ );
610
+ }
611
+
612
+ /** Promote a negotiated connection only after its browser data channel is ready. */
613
+ async activateCodexRealtimeConnection(
614
+ workspaceId: string,
615
+ sessionId: string,
616
+ realtimeId: string,
617
+ connectionId: string,
618
+ request: ActivateCodexRealtimeConnectionRequest,
619
+ options: { signal?: AbortSignal | undefined } = {},
620
+ ): Promise<SessionRealtimeMutationResponse> {
621
+ return await this.requestJson<SessionRealtimeMutationResponse>(
622
+ "POST",
623
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/${realtimeId}/connections/${connectionId}/activate`,
624
+ request,
625
+ {},
626
+ { signal: options.signal },
627
+ );
628
+ }
629
+
630
+ /** Atomically enter realtime mode for this ordinary session. */
631
+ async beginSessionRealtime(
632
+ workspaceId: string,
633
+ sessionId: string,
634
+ request: BeginSessionRealtimeRequest,
635
+ ): Promise<SessionRealtimeMutationResponse> {
636
+ return await this.requestJson<SessionRealtimeMutationResponse>(
637
+ "POST",
638
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime`,
639
+ request,
640
+ );
641
+ }
642
+
643
+ /** Renew the exact authenticated browser owner's realtime lease. */
644
+ async heartbeatSessionRealtime(
645
+ workspaceId: string,
646
+ sessionId: string,
647
+ realtimeId: string,
648
+ request: RenewSessionRealtimeRequest,
649
+ ): Promise<SessionRealtimeMutationResponse> {
650
+ return await this.requestJson<SessionRealtimeMutationResponse>(
651
+ "PATCH",
652
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/${realtimeId}/heartbeat`,
653
+ request,
654
+ );
655
+ }
656
+
657
+ /** Persist finalized V3 events, acknowledge delivery, and replay pending outbound context. */
658
+ async syncSessionRealtimeLedger(
659
+ workspaceId: string,
660
+ sessionId: string,
661
+ realtimeId: string,
662
+ request: SyncSessionRealtimeLedgerRequest,
663
+ ): Promise<SyncSessionRealtimeLedgerResponse> {
664
+ return await this.requestJson<SyncSessionRealtimeLedgerResponse>(
665
+ "POST",
666
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/${realtimeId}/sync`,
667
+ request,
668
+ );
669
+ }
670
+
671
+ /** End realtime mode and restore ordinary text workflow admission. */
672
+ async endSessionRealtime(
673
+ workspaceId: string,
674
+ sessionId: string,
675
+ realtimeId: string,
676
+ request: EndSessionRealtimeRequest,
677
+ ): Promise<SessionRealtimeMutationResponse> {
678
+ return await this.requestJson<SessionRealtimeMutationResponse>(
679
+ "DELETE",
680
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/${realtimeId}`,
681
+ request,
682
+ );
683
+ }
684
+
567
685
  async listTurns(
568
686
  workspaceId: string,
569
687
  sessionId: string,
@@ -658,7 +776,10 @@ export class OpenGeniClient {
658
776
  return await this.requestJson<DeviceEnrollmentApproveResponse>(
659
777
  "POST",
660
778
  `/v1/workspaces/${workspaceId}/enrollments/device/approve`,
661
- { userCode: request.userCode, allowScreenControl: request.allowScreenControl ?? false },
779
+ {
780
+ userCode: request.userCode,
781
+ allowScreenControl: request.allowScreenControl ?? false,
782
+ },
662
783
  );
663
784
  }
664
785
 
@@ -811,7 +932,10 @@ export class OpenGeniClient {
811
932
  );
812
933
  assertApiContractResponse(response);
813
934
  if (!response.ok) {
814
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
935
+ throw await apiErrorFromResponse(response, {
936
+ method: "GET",
937
+ correlationId,
938
+ });
815
939
  }
816
940
  await assertJsonResponse(response, { method: "GET", correlationId });
817
941
  const body = await response.json();
@@ -871,7 +995,9 @@ export class OpenGeniClient {
871
995
  async getLatestEventResult(
872
996
  workspaceId: string,
873
997
  sessionId: string,
874
- options: Omit<SessionEventCompactResultOptions, "resultMode"> = { latest: "terminal" },
998
+ options: Omit<SessionEventCompactResultOptions, "resultMode"> = {
999
+ latest: "terminal",
1000
+ },
875
1001
  ): Promise<SessionEventCompactResult | null> {
876
1002
  return await this.listEventPage(workspaceId, sessionId, {
877
1003
  ...options,
@@ -909,7 +1035,11 @@ export class OpenGeniClient {
909
1035
  async pauseSession(
910
1036
  workspaceId: string,
911
1037
  sessionId: string,
912
- options: { reason?: string; clientEventId?: string; expectedControlEtag?: string } = {},
1038
+ options: {
1039
+ reason?: string;
1040
+ clientEventId?: string;
1041
+ expectedControlEtag?: string;
1042
+ } = {},
913
1043
  ): Promise<SessionControlResponse> {
914
1044
  return await this.controlSession(workspaceId, sessionId, {
915
1045
  action: "pause",
@@ -944,7 +1074,9 @@ export class OpenGeniClient {
944
1074
  status?: SessionHumanInputRequest["status"];
945
1075
  } = {},
946
1076
  ): Promise<SessionHumanInputRequest[]> {
947
- const result = await this.requestJson<{ requests: SessionHumanInputRequest[] }>(
1077
+ const result = await this.requestJson<{
1078
+ requests: SessionHumanInputRequest[];
1079
+ }>(
948
1080
  "GET",
949
1081
  `/v1/workspaces/${workspaceId}/sessions/${sessionId}/human-input-requests`,
950
1082
  undefined,
@@ -1021,7 +1153,10 @@ export class OpenGeniClient {
1021
1153
  });
1022
1154
  assertApiContractResponse(response);
1023
1155
  if (!response.ok) {
1024
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
1156
+ throw await apiErrorFromResponse(response, {
1157
+ method: "GET",
1158
+ correlationId,
1159
+ });
1025
1160
  }
1026
1161
  if (!response.body) {
1027
1162
  throw new OpenGeniApiError(response.status, "SSE response did not include a readable body");
@@ -1113,7 +1248,7 @@ export class OpenGeniClient {
1113
1248
  workspaceId: string,
1114
1249
  sessionId: string,
1115
1250
  request: {
1116
- action: "pause" | "resume";
1251
+ action: "pause" | "resume" | "cancel";
1117
1252
  reason?: string;
1118
1253
  clientEventId: string;
1119
1254
  expectedControlEtag?: string;
@@ -1129,7 +1264,11 @@ export class OpenGeniClient {
1129
1264
  async resumeSession(
1130
1265
  workspaceId: string,
1131
1266
  sessionId: string,
1132
- options: { reason?: string; clientEventId?: string; expectedControlEtag?: string } = {},
1267
+ options: {
1268
+ reason?: string;
1269
+ clientEventId?: string;
1270
+ expectedControlEtag?: string;
1271
+ } = {},
1133
1272
  ): Promise<SessionControlResponse> {
1134
1273
  return await this.controlSession(workspaceId, sessionId, {
1135
1274
  action: "resume",
@@ -1139,6 +1278,24 @@ export class OpenGeniClient {
1139
1278
  });
1140
1279
  }
1141
1280
 
1281
+ /**
1282
+ * Terminally cancel a session subtree. Unlike pause, cancellation drains
1283
+ * queued work and permanently fences new prompts for the session and every
1284
+ * descendant.
1285
+ */
1286
+ async cancelSession(
1287
+ workspaceId: string,
1288
+ sessionId: string,
1289
+ options: { reason?: string; clientEventId?: string; expectedControlEtag?: string } = {},
1290
+ ): Promise<SessionControlResponse> {
1291
+ return await this.controlSession(workspaceId, sessionId, {
1292
+ action: "cancel",
1293
+ clientEventId: options.clientEventId ?? crypto.randomUUID(),
1294
+ ...(options.reason ? { reason: options.reason } : {}),
1295
+ ...(options.expectedControlEtag ? { expectedControlEtag: options.expectedControlEtag } : {}),
1296
+ });
1297
+ }
1298
+
1142
1299
  async setWorkspaceInferenceState(
1143
1300
  workspaceId: string,
1144
1301
  request: {
@@ -1180,7 +1337,10 @@ export class OpenGeniClient {
1180
1337
  );
1181
1338
  assertApiContractResponse(response);
1182
1339
  if (!response.ok) {
1183
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
1340
+ throw await apiErrorFromResponse(response, {
1341
+ method: "GET",
1342
+ correlationId,
1343
+ });
1184
1344
  }
1185
1345
  await assertJsonResponse(response, { method: "GET", correlationId });
1186
1346
  const events = (await response.json()) as WorkspaceControlEvent[];
@@ -1230,13 +1390,19 @@ export class OpenGeniClient {
1230
1390
  }),
1231
1391
  {
1232
1392
  method: "GET",
1233
- headers: { ...this.headers(correlationId), Accept: "text/event-stream" },
1393
+ headers: {
1394
+ ...this.headers(correlationId),
1395
+ Accept: "text/event-stream",
1396
+ },
1234
1397
  ...(options.signal ? { signal: options.signal } : {}),
1235
1398
  },
1236
1399
  );
1237
1400
  assertApiContractResponse(response);
1238
1401
  if (!response.ok) {
1239
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
1402
+ throw await apiErrorFromResponse(response, {
1403
+ method: "GET",
1404
+ correlationId,
1405
+ });
1240
1406
  }
1241
1407
  if (!response.body) {
1242
1408
  throw new OpenGeniApiError(response.status, "SSE response did not include a readable body");
@@ -1698,6 +1864,16 @@ export class OpenGeniClient {
1698
1864
  );
1699
1865
  }
1700
1866
 
1867
+ /** Authenticated realtime voice models and credential readiness. */
1868
+ async getWorkspaceRealtimeModelCatalog(
1869
+ workspaceId: string,
1870
+ ): Promise<WorkspaceRealtimeModelCatalogResponse> {
1871
+ return await this.requestJson<WorkspaceRealtimeModelCatalogResponse>(
1872
+ "GET",
1873
+ `/v1/workspaces/${workspaceId}/realtime-model-catalog`,
1874
+ );
1875
+ }
1876
+
1701
1877
  /** The caller's access context: subject, account + workspace grants, defaults. */
1702
1878
  async getAccessContext(): Promise<AccessContext> {
1703
1879
  return await this.requestJson<AccessContext>("GET", "/v1/access/me");
@@ -2072,7 +2248,9 @@ export class OpenGeniClient {
2072
2248
  "GET",
2073
2249
  `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}/runs`,
2074
2250
  undefined,
2075
- { ...(options.limit !== undefined ? { limit: String(options.limit) } : {}) },
2251
+ {
2252
+ ...(options.limit !== undefined ? { limit: String(options.limit) } : {}),
2253
+ },
2076
2254
  );
2077
2255
  }
2078
2256
 
@@ -2436,7 +2614,10 @@ export class OpenGeniClient {
2436
2614
  throw error;
2437
2615
  }
2438
2616
  if (!response.ok) {
2439
- throw await apiErrorFromResponse(response, { method: "GET", correlationId });
2617
+ throw await apiErrorFromResponse(response, {
2618
+ method: "GET",
2619
+ correlationId,
2620
+ });
2440
2621
  }
2441
2622
  if (response.status !== 200 && response.status !== 206) {
2442
2623
  await cancelResponseBody(response, "unexpected retained artifact response status");
@@ -2833,6 +3014,19 @@ export class OpenGeniClient {
2833
3014
  );
2834
3015
  }
2835
3016
 
3017
+ async listOpenGeniSlackReactionChannels(
3018
+ workspaceId: string,
3019
+ connectionId: string,
3020
+ cursor?: string,
3021
+ ): Promise<SlackReactionChannelListResponse> {
3022
+ const query = new URLSearchParams({ connectionId });
3023
+ if (cursor) query.set("cursor", cursor);
3024
+ return await this.requestJson<SlackReactionChannelListResponse>(
3025
+ "GET",
3026
+ `/v1/workspaces/${workspaceId}/integrations/slack/reaction-channels?${query}`,
3027
+ );
3028
+ }
3029
+
2836
3030
  async updateConnection(
2837
3031
  workspaceId: string,
2838
3032
  connectionId: string,
@@ -3175,10 +3369,10 @@ export class OpenGeniClient {
3175
3369
  workspaceId: string,
3176
3370
  accountId: string,
3177
3371
  ): 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
- );
3372
+ return await this.requestJson<{
3373
+ disconnected: boolean;
3374
+ newActiveId: string | null;
3375
+ }>("DELETE", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}`);
3182
3376
  }
3183
3377
 
3184
3378
  /** Rename a Codex account (label only in P1). */