@opengeni/sdk 0.48.0 → 0.57.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 (122) hide show
  1. package/README.md +147 -1
  2. package/dist/artifact-client.d.ts +20 -2
  3. package/dist/artifacts.d.ts +4 -0
  4. package/dist/artifacts.js +11 -0
  5. package/dist/artifacts.js.map +1 -0
  6. package/dist/{chunk-V5F253OG.js → chunk-GU6JF75T.js} +6 -3
  7. package/dist/chunk-GU6JF75T.js.map +1 -0
  8. package/dist/chunk-HJ3HHUT5.js +222 -0
  9. package/dist/chunk-HJ3HHUT5.js.map +1 -0
  10. package/dist/{chunk-KIHGPM7H.js → chunk-JDLDDRNE.js} +20 -14
  11. package/dist/chunk-JDLDDRNE.js.map +1 -0
  12. package/dist/chunk-JRPFWI6T.js +128 -0
  13. package/dist/chunk-JRPFWI6T.js.map +1 -0
  14. package/dist/{chunk-MBGBLVUV.js → chunk-PKQ377ED.js} +1725 -555
  15. package/dist/chunk-PKQ377ED.js.map +1 -0
  16. package/dist/chunk-ST5DDKJP.js +987 -0
  17. package/dist/chunk-ST5DDKJP.js.map +1 -0
  18. package/dist/chunk-VWE2QIVO.js +1162 -0
  19. package/dist/chunk-VWE2QIVO.js.map +1 -0
  20. package/dist/chunk-VYCTL62C.js +230 -0
  21. package/dist/chunk-VYCTL62C.js.map +1 -0
  22. package/dist/{chunk-DXDL7EEW.js → chunk-YKZME56C.js} +197 -113
  23. package/dist/chunk-YKZME56C.js.map +1 -0
  24. package/dist/client.d.ts +240 -16
  25. package/dist/codex-realtime-controller.d.ts +9 -6
  26. package/dist/codex-realtime-controller.js +2 -2
  27. package/dist/codex-realtime-lifecycle.d.ts +1 -1
  28. package/dist/codex-realtime-v3.d.ts +3 -3
  29. package/dist/codex-realtime.d.ts +1 -1
  30. package/dist/company-profile.d.ts +100 -0
  31. package/dist/core.d.ts +5 -5
  32. package/dist/core.js +10 -5
  33. package/dist/desktop.d.ts +9 -1
  34. package/dist/editable-artifact-resources.d.ts +96 -0
  35. package/dist/editable-artifacts/browser-session.d.ts +35 -0
  36. package/dist/editable-artifacts/controller.d.ts +60 -0
  37. package/dist/editable-artifacts/errors.d.ts +23 -0
  38. package/dist/editable-artifacts/http-live-transport.d.ts +46 -0
  39. package/dist/editable-artifacts/index.d.ts +19 -0
  40. package/dist/editable-artifacts/pool.d.ts +15 -0
  41. package/dist/editable-artifacts/session.d.ts +96 -0
  42. package/dist/editable-artifacts/storage.d.ts +72 -0
  43. package/dist/editable-artifacts/types.d.ts +416 -0
  44. package/dist/editable-artifacts/worker/browser-client.d.ts +80 -0
  45. package/dist/editable-artifacts/worker/browser-entry.d.ts +6 -0
  46. package/dist/editable-artifacts/worker/kernel-adapter.d.ts +45 -0
  47. package/dist/editable-artifacts/worker/rpc-protocol.d.ts +92 -0
  48. package/dist/editable-artifacts/worker/runtime.d.ts +66 -0
  49. package/dist/editable-artifacts/worker/wire-codec.d.ts +52 -0
  50. package/dist/editable-artifacts-worker.d.ts +8 -0
  51. package/dist/editable-artifacts-worker.js +1708 -0
  52. package/dist/editable-artifacts-worker.js.map +1 -0
  53. package/dist/editable-artifacts.d.ts +6 -0
  54. package/dist/editable-artifacts.js +5954 -0
  55. package/dist/editable-artifacts.js.map +1 -0
  56. package/dist/gateway-realtime-transport.d.ts +2 -1
  57. package/dist/gateway-realtime-transport.js +5 -3
  58. package/dist/index.d.ts +45 -35
  59. package/dist/index.js +134 -64
  60. package/dist/index.js.map +1 -1
  61. package/dist/interaction-revision-stream.d.ts +11 -0
  62. package/dist/interaction.d.ts +1484 -0
  63. package/dist/interaction.js +81 -0
  64. package/dist/interaction.js.map +1 -0
  65. package/dist/memory-slack-client.d.ts +13 -0
  66. package/dist/memory-slack-delivery.d.ts +99 -0
  67. package/dist/memory-slack.d.ts +4 -0
  68. package/dist/memory-slack.js +44 -0
  69. package/dist/memory-slack.js.map +1 -0
  70. package/dist/proxy.d.ts +3 -3
  71. package/dist/realtime.d.ts +14 -14
  72. package/dist/realtime.js +11 -7
  73. package/dist/realtime.js.map +1 -1
  74. package/dist/retained-artifacts.d.ts +12 -0
  75. package/dist/stream.d.ts +1 -1
  76. package/dist/terminal.d.ts +1 -1
  77. package/dist/types.d.ts +1347 -34
  78. package/dist/workspace-control-stream.d.ts +2 -2
  79. package/dist/workspace-live-stream.d.ts +14 -0
  80. package/dist/workspace-state.d.ts +1 -1
  81. package/package.json +29 -3
  82. package/src/artifact-client.ts +129 -0
  83. package/src/artifacts.ts +17 -0
  84. package/src/client.ts +3022 -910
  85. package/src/codex-realtime-controller.ts +25 -7
  86. package/src/codex-realtime-lifecycle.ts +1 -0
  87. package/src/company-profile.ts +92 -0
  88. package/src/desktop.ts +11 -1
  89. package/src/editable-artifact-resources.ts +119 -0
  90. package/src/editable-artifacts/browser-session.ts +176 -0
  91. package/src/editable-artifacts/controller.ts +2632 -0
  92. package/src/editable-artifacts/errors.ts +52 -0
  93. package/src/editable-artifacts/http-live-transport.ts +1449 -0
  94. package/src/editable-artifacts/index.ts +175 -0
  95. package/src/editable-artifacts/pool.ts +81 -0
  96. package/src/editable-artifacts/session.ts +778 -0
  97. package/src/editable-artifacts/storage.ts +1718 -0
  98. package/src/editable-artifacts/types.ts +499 -0
  99. package/src/editable-artifacts/worker/browser-client.ts +1167 -0
  100. package/src/editable-artifacts/worker/browser-entry.ts +57 -0
  101. package/src/editable-artifacts/worker/kernel-adapter.ts +1039 -0
  102. package/src/editable-artifacts/worker/rpc-protocol.ts +622 -0
  103. package/src/editable-artifacts/worker/runtime.ts +1204 -0
  104. package/src/editable-artifacts/worker/wire-codec.ts +852 -0
  105. package/src/editable-artifacts-worker.ts +8 -0
  106. package/src/editable-artifacts.ts +6 -0
  107. package/src/errors.ts +16 -2
  108. package/src/gateway-realtime-transport.ts +252 -109
  109. package/src/index.ts +215 -1
  110. package/src/interaction-revision-stream.ts +117 -0
  111. package/src/interaction.ts +2874 -0
  112. package/src/memory-slack-client.ts +71 -0
  113. package/src/memory-slack-delivery.ts +128 -0
  114. package/src/memory-slack.ts +19 -0
  115. package/src/realtime.ts +14 -4
  116. package/src/retained-artifacts.ts +326 -0
  117. package/src/types.ts +1636 -52
  118. package/src/workspace-live-stream.ts +137 -0
  119. package/dist/chunk-DXDL7EEW.js.map +0 -1
  120. package/dist/chunk-KIHGPM7H.js.map +0 -1
  121. package/dist/chunk-MBGBLVUV.js.map +0 -1
  122. package/dist/chunk-V5F253OG.js.map +0 -1
@@ -1,3 +1,11 @@
1
+ import {
2
+ COMPUTER_SCREENSHOT_MAX_BYTES,
3
+ GENERATED_VIDEO_MAX_BYTES,
4
+ OPENGENI_API_CONTRACT_HEADER,
5
+ OPENGENI_API_CONTRACT_REVISION,
6
+ OPENGENI_CORRELATION_HEADER,
7
+ RETAINED_OUTPUT_MAX_PAGE_BYTES
8
+ } from "./chunk-HJ3HHUT5.js";
1
9
  import {
2
10
  OpenGeniApiContractMismatchError,
3
11
  OpenGeniApiError,
@@ -5,7 +13,10 @@ import {
5
13
  OpenGeniStreamError,
6
14
  isAbortError,
7
15
  isRetryableStreamError
8
- } from "./chunk-V5F253OG.js";
16
+ } from "./chunk-GU6JF75T.js";
17
+ import {
18
+ OpenGeniInteractionClient
19
+ } from "./chunk-ST5DDKJP.js";
9
20
 
10
21
  // src/sse.ts
11
22
  async function* parseSseStream(stream) {
@@ -342,203 +353,348 @@ async function sleep2(delayMs, signal) {
342
353
  });
343
354
  }
344
355
 
345
- // src/types.ts
346
- var DEFAULT_FILE_RESOURCE_MOUNT_ROOT = ".opengeni/files";
347
- var SESSION_EVENT_TYPES = [
348
- "session.created",
349
- // Defensive bounded projection for malformed/legacy oversized envelopes.
350
- "session.event.envelope_omitted",
351
- "session.status.changed",
352
- "session.realtime.started",
353
- "session.realtime.ended",
354
- "session.requiresAction",
355
- "session.humanInput.requested",
356
- "session.context.compaction.requested",
357
- "session.context.compaction.started",
358
- "session.context.compacted",
359
- "session.context.compaction.skipped",
360
- "session.context.cleared",
361
- "user.message",
362
- "user.pause",
363
- "user.approvalDecision",
364
- "user.humanInputResponse",
365
- "turn.queued",
366
- "turn.started",
367
- "turn.completed",
368
- "turn.failed",
369
- "turn.cancelled",
370
- "turn.superseded",
371
- "turn.recovery.requested",
372
- "turn.capacity_waiting",
373
- "agent.message.delta",
374
- "agent.message.completed",
375
- "agent.reasoning.delta",
376
- "agent.toolCall.created",
377
- "agent.toolCall.output",
378
- "agent.model.request",
379
- "agent.model.usage",
380
- "tool.auth_needed",
381
- "credential.auth_needed",
382
- "agent.updated",
383
- "rig.setup.started",
384
- "rig.setup.completed",
385
- "rig.setup.skipped",
386
- "rig.setup.failed",
387
- "sandbox.operation.started",
388
- "sandbox.operation.completed",
389
- "sandbox.operation.failed",
390
- "sandbox.command.output.delta",
391
- "artifact.created",
392
- "goal.set",
393
- "goal.updated",
394
- "goal.completed",
395
- "goal.paused",
396
- "goal.resumed",
397
- "goal.cleared",
398
- "goal.continuation",
399
- "system.update.pending",
400
- "system.update.delivered",
401
- "system.update.superseded",
402
- "system.update.cancelled",
403
- "system.update.settled",
404
- "session.control.paused",
405
- "session.control.resumed",
406
- "session.control.steer_requested",
407
- "workspace.inference.paused",
408
- "workspace.inference.resumed",
409
- "session.queue.changed",
410
- "session.queue.prompt.cancelled",
411
- "session.queue.history",
412
- "turn.event.rejected_late",
413
- "memory.saved",
414
- "memory.corrected",
415
- // Channel-B desktop pixel-plane signals (mirror of contracts SessionEventType;
416
- // the contract-parity test asserts sorted equality).
417
- "stream.url.rotated",
418
- "stream.opened",
419
- "stream.closed",
420
- "stream.revoked",
421
- // Channel-B recording signals (P4.3 — "agent films itself proving the fix").
422
- "recording.started",
423
- "recording.available",
424
- "recording.failed",
425
- // Channel-A structured-service notifications (P4.4; mirror of contracts
426
- // SessionEventType the contract-parity test asserts sorted equality).
427
- "fs.changed",
428
- "git.changed",
429
- "terminal.pty.started",
430
- "terminal.pty.output.delta",
431
- "terminal.pty.exited",
432
- "session.title_set",
433
- "session.mcp.approval_policy.updated",
434
- "session.tool_policy.updated",
435
- // Multi-account Codex (P1): the session's inference account changed.
436
- "codex.account.switched",
437
- // credential allocator metadata-only per-turn credential selection audit.
438
- "codex.credential.selected",
439
- // Bounded, identity-free deterministic shadow/replay decision.
440
- "codex.fleet.decision",
441
- // credential allocator durable zero-capacity wait lifecycle. These are system/runtime
442
- // events, never synthetic user messages.
443
- "codex.capacity.waiting",
444
- "codex.capacity.resumed",
445
- "codex.capacity.superseded",
446
- // Sandbox durability observability (mirror of contracts SessionEventType):
447
- // box lifecycle + manifest-env drift, attributable from the DB alone.
448
- "sandbox.box.created",
449
- "sandbox.box.lost",
450
- "sandbox.box.terminated",
451
- "sandbox.box.snapshot",
452
- "sandbox.env.drift",
453
- // Active-sandbox pointer reconcile (issue #341; announce-only; mirror of contracts
454
- // SessionEventType the contract-parity test asserts sorted equality).
455
- "session.route.reconciled",
456
- // Workbench v2 turn-end workspace capture (announce-only; mirror of contracts
457
- // SessionEventType the contract-parity test asserts sorted equality).
458
- "workspace.revision.captured",
459
- "workspace.revision.degraded",
460
- // Connected Machine op-outcome observability (announce-only, quiet; mirror of
461
- // contracts SessionEventType — the contract-parity test asserts sorted equality).
462
- "machine.op.failed",
463
- "machine.op.recovered",
464
- // Connected Machine link-plane observability (announce-only, quiet; mirror of
465
- // contracts SessionEventType — the contract-parity test asserts sorted equality).
466
- "machine.link.lost",
467
- "machine.link.restored",
468
- "machine.runner.restarted"
469
- ];
470
- var KNOWN_PERMISSIONS = [
471
- "account:read",
472
- "account:admin",
473
- "members:manage",
474
- "workspace:create",
475
- "billing:read",
476
- "billing:manage",
477
- "workspace:read",
478
- "workspace:admin",
479
- "sessions:create",
480
- "sessions:read",
481
- "sessions:control",
482
- // sandbox workspace (mirror of @opengeni/contracts Permission). stream:view is
483
- // strictly broader than sessions:read (un-redacted pixels); stream:control is
484
- // the never-granted-v1 raw-input plane; stream:acknowledge is the secret-leak
485
- // consent gate.
486
- "stream:view",
487
- "stream:control",
488
- "stream:acknowledge",
489
- "files:upload",
490
- "files:read",
491
- "files:write",
492
- "terminal:attach",
493
- "documents:manage",
494
- "documents:search",
495
- "scheduled_tasks:manage",
496
- "scheduled_tasks:run",
497
- "github:manage",
498
- "github:use",
499
- "api_keys:manage",
500
- "connections:read",
501
- "connections:write",
502
- "environments:manage",
503
- "environments:use",
504
- "variable-sets:list",
505
- "variable-sets:read",
506
- "variable-sets:write",
507
- "variable-sets:manage",
508
- "variable-sets:use",
509
- "secrets:list",
510
- "secrets:read",
511
- "secrets:write",
512
- "mcp_servers:attach",
513
- "toolspace:call",
514
- "goals:manage",
515
- "enrollments:read",
516
- "enrollments:manage",
517
- "rigs:use",
518
- "rigs:manage",
519
- "artifacts:read",
520
- "artifacts:publish"
521
- ];
522
- var OPENGENI_API_CONTRACT_REVISION = "2026-07-workspace-artifacts-v1";
523
- var OPENGENI_API_CONTRACT_HEADER = "x-opengeni-api-contract";
524
- var OPENGENI_CORRELATION_HEADER = "x-opengeni-correlation-id";
525
- var RETAINED_OUTPUT_DEFAULT_PAGE_BYTES = 256 * 1024;
526
- var RETAINED_OUTPUT_MAX_PAGE_BYTES = 1024 * 1024;
527
- var COMPUTER_SCREENSHOT_MAX_BYTES = 32 * 1024 * 1024;
528
- var KNOWN_USAGE_EVENT_TYPES = [
529
- "agent_run.created",
530
- "agent_run.completed",
531
- "model.tokens",
532
- "model.cost",
533
- "file.uploaded",
534
- "file.deleted",
535
- "document.indexed",
536
- "scheduled_task.fired",
537
- "api_key.request",
538
- // sandbox warm-time metering (P2.1) — mirrors contracts UsageEventType.
539
- "sandbox.warm_seconds",
540
- "sandbox.warm_cost"
541
- ];
356
+ // src/interaction-revision-stream.ts
357
+ async function* streamWorkspaceInteractionRevisions(transport, options = {}) {
358
+ const signal = options.signal;
359
+ const reconnect = options.reconnect ?? true;
360
+ const baseDelayMs = options.reconnectDelayMs ?? 500;
361
+ const maxDelayMs = options.maxReconnectDelayMs ?? 1e4;
362
+ const jitterRatio = options.reconnectJitterRatio ?? 0.2;
363
+ const beforeLiveTimeoutMs = options.beforeLiveTimeoutMs ?? 15e3;
364
+ const heartbeatTimeoutMs = options.heartbeatTimeoutMs ?? 45e3;
365
+ const maxAttempts = options.maxReconnectAttempts ?? Number.POSITIVE_INFINITY;
366
+ let cursor = options.after ?? 0;
367
+ let failures = 0;
368
+ let delayMs = baseDelayMs;
369
+ let everConnected = false;
370
+ for (; ; ) {
371
+ if (signal?.aborted) return;
372
+ options.onStateChange?.(everConnected || failures > 0 ? "reconnecting" : "connecting");
373
+ const cursorAtOpen = cursor;
374
+ try {
375
+ const body = await transport.openStream(cursor, signal);
376
+ everConnected = true;
377
+ failures = 0;
378
+ delayMs = baseDelayMs;
379
+ await runBeforeLive(options.beforeLive, beforeLiveTimeoutMs, signal);
380
+ options.onStateChange?.("live");
381
+ for await (const message of parseSseStream(
382
+ withStreamInactivityTimeout(body, heartbeatTimeoutMs, signal)
383
+ )) {
384
+ if (signal?.aborted) return;
385
+ const event = parseWorkspaceInteractionRevision(message.data);
386
+ if (!event || event.sequence <= cursor) continue;
387
+ cursor = event.sequence;
388
+ yield event;
389
+ }
390
+ if (!reconnect) return;
391
+ if (cursor === cursorAtOpen) await sleep3(jitteredDelay(baseDelayMs, jitterRatio), signal);
392
+ continue;
393
+ } catch (error) {
394
+ if (signal?.aborted || isAbortError(error)) return;
395
+ if (!reconnect || !isRetryableStreamError(error)) throw error;
396
+ failures += 1;
397
+ if (failures > maxAttempts) {
398
+ throw new OpenGeniStreamError(
399
+ `workspace interaction stream gave up after ${maxAttempts} reconnect attempts: ${error instanceof Error ? error.message : String(error)}`
400
+ );
401
+ }
402
+ }
403
+ await sleep3(jitteredDelay(delayMs, jitterRatio), signal);
404
+ delayMs = Math.min(Math.max(delayMs * 2, baseDelayMs), maxDelayMs);
405
+ }
406
+ }
407
+ function parseWorkspaceInteractionRevision(data) {
408
+ let value;
409
+ try {
410
+ value = JSON.parse(data);
411
+ } catch {
412
+ return null;
413
+ }
414
+ if (!isRecord(value) || value.type !== "workspace.interaction.changed" || typeof value.workspaceId !== "string" || typeof value.sequence !== "number" || !Number.isSafeInteger(value.sequence) || value.sequence < 0 || value.revision !== value.sequence || typeof value.occurredAt !== "string") {
415
+ return null;
416
+ }
417
+ return value;
418
+ }
419
+ function isRecord(value) {
420
+ return typeof value === "object" && value !== null && !Array.isArray(value);
421
+ }
422
+ async function sleep3(delayMs, signal) {
423
+ if (signal?.aborted || delayMs <= 0) return;
424
+ await new Promise((resolve) => {
425
+ const timer = setTimeout(done, delayMs);
426
+ function done() {
427
+ clearTimeout(timer);
428
+ signal?.removeEventListener("abort", done);
429
+ resolve();
430
+ }
431
+ signal?.addEventListener("abort", done, { once: true });
432
+ });
433
+ }
434
+
435
+ // src/workspace-live-stream.ts
436
+ async function* streamWorkspaceLiveEvents(transport, options = {}) {
437
+ const signal = options.signal;
438
+ const reconnect = options.reconnect ?? true;
439
+ const baseDelayMs = options.reconnectDelayMs ?? 500;
440
+ const maxDelayMs = options.maxReconnectDelayMs ?? 1e4;
441
+ const jitterRatio = options.reconnectJitterRatio ?? 0.2;
442
+ const beforeLiveTimeoutMs = options.beforeLiveTimeoutMs ?? 15e3;
443
+ const heartbeatTimeoutMs = options.heartbeatTimeoutMs ?? 45e3;
444
+ const maxAttempts = options.maxReconnectAttempts ?? Number.POSITIVE_INFINITY;
445
+ let controlCursor = options.controlAfter ?? 0;
446
+ let interactionCursor = options.interactionAfter ?? 0;
447
+ let failures = 0;
448
+ let delayMs = baseDelayMs;
449
+ let everConnected = false;
450
+ for (; ; ) {
451
+ if (signal?.aborted) return;
452
+ options.onStateChange?.(everConnected || failures > 0 ? "reconnecting" : "connecting");
453
+ const cursorsAtOpen = `${controlCursor}:${interactionCursor}`;
454
+ try {
455
+ const body = await transport.openStream(controlCursor, interactionCursor, signal);
456
+ everConnected = true;
457
+ failures = 0;
458
+ delayMs = baseDelayMs;
459
+ await runBeforeLive(options.beforeLive, beforeLiveTimeoutMs, signal);
460
+ options.onStateChange?.("live");
461
+ for await (const message of parseSseStream(
462
+ withStreamInactivityTimeout(body, heartbeatTimeoutMs, signal)
463
+ )) {
464
+ if (signal?.aborted) return;
465
+ const event = parseWorkspaceLiveEvent(message.data);
466
+ if (!event) continue;
467
+ if (event.type === "workspace.control.changed") {
468
+ if (event.sequence <= controlCursor) continue;
469
+ controlCursor = event.sequence;
470
+ } else {
471
+ if (event.sequence <= interactionCursor) continue;
472
+ interactionCursor = event.sequence;
473
+ }
474
+ yield event;
475
+ }
476
+ if (!reconnect) return;
477
+ if (`${controlCursor}:${interactionCursor}` === cursorsAtOpen) {
478
+ await sleep4(jitteredDelay(baseDelayMs, jitterRatio), signal);
479
+ }
480
+ continue;
481
+ } catch (error) {
482
+ if (signal?.aborted || isAbortError(error)) return;
483
+ if (!reconnect || !isRetryableStreamError(error)) throw error;
484
+ failures += 1;
485
+ if (failures > maxAttempts) {
486
+ throw new OpenGeniStreamError(
487
+ `workspace live stream gave up after ${maxAttempts} reconnect attempts: ${error instanceof Error ? error.message : String(error)}`
488
+ );
489
+ }
490
+ }
491
+ await sleep4(jitteredDelay(delayMs, jitterRatio), signal);
492
+ delayMs = Math.min(Math.max(delayMs * 2, baseDelayMs), maxDelayMs);
493
+ }
494
+ }
495
+ function parseWorkspaceLiveEvent(data) {
496
+ let value;
497
+ try {
498
+ value = JSON.parse(data);
499
+ } catch {
500
+ return null;
501
+ }
502
+ if (!isRecord2(value) || typeof value.sequence !== "number") return null;
503
+ if (value.type === "workspace.control.changed" && typeof value.id === "string" && Number.isSafeInteger(value.sequence)) {
504
+ return value;
505
+ }
506
+ if (value.type === "workspace.interaction.changed" && typeof value.workspaceId === "string" && Number.isSafeInteger(value.sequence) && value.sequence >= 0 && value.revision === value.sequence && typeof value.occurredAt === "string") {
507
+ return value;
508
+ }
509
+ return null;
510
+ }
511
+ function isRecord2(value) {
512
+ return typeof value === "object" && value !== null && !Array.isArray(value);
513
+ }
514
+ async function sleep4(delayMs, signal) {
515
+ if (signal?.aborted || delayMs <= 0) return;
516
+ await new Promise((resolve) => {
517
+ const timer = setTimeout(done, delayMs);
518
+ function done() {
519
+ clearTimeout(timer);
520
+ signal?.removeEventListener("abort", done);
521
+ resolve();
522
+ }
523
+ signal?.addEventListener("abort", done, { once: true });
524
+ });
525
+ }
526
+
527
+ // src/retained-artifacts.ts
528
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
529
+ var SHA256 = /^[0-9a-f]{64}$/;
530
+ var ISO_DATETIME_WITH_OFFSET = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/;
531
+ var WORKSPACE_PATH = /^\/v1\/workspaces\/([0-9a-f-]+)\/artifacts\/([0-9a-f-]+)\/content$/;
532
+ var MAX_BYTES = 64 * 1024 * 1024;
533
+ var MAX_VIDEO_BYTES = 512 * 1024 * 1024;
534
+ var MAX_DIMENSION = 16384;
535
+ var MAX_PIXELS = 67108864;
536
+ var MAX_RANGE_BYTES = 1024 * 1024;
537
+ function parseRetainedGeneratedImageReference(value, expectedWorkspaceId) {
538
+ if (!recordWithKeys(value, GENERATED_IMAGE_REFERENCE_KEYS)) return null;
539
+ const artifact = value;
540
+ if (artifact.available !== true || artifact.kind !== "generated_image" || typeof artifact.artifactId !== "string" || !UUID.test(artifact.artifactId) || !["image/png", "image/jpeg", "image/webp"].includes(String(artifact.contentType)) || !safeIntegerBetween(artifact.originalBytes, 1, MAX_BYTES) || typeof artifact.sha256 !== "string" || !SHA256.test(artifact.sha256) || typeof artifact.retainedAt !== "string" || artifact.retainedAt.length > 64 || !ISO_DATETIME_WITH_OFFSET.test(artifact.retainedAt) || !Number.isFinite(Date.parse(artifact.retainedAt)) || !recordWithKeys(artifact.dimensions, DIMENSION_KEYS) || !recordWithKeys(artifact.retention, RETENTION_KEYS) || !recordWithKeys(artifact.retrieval, RETRIEVAL_KEYS)) {
541
+ return null;
542
+ }
543
+ const dimensions = artifact.dimensions;
544
+ if (!safeIntegerBetween(dimensions.width, 1, MAX_DIMENSION) || !safeIntegerBetween(dimensions.height, 1, MAX_DIMENSION) || Number(dimensions.width) * Number(dimensions.height) > MAX_PIXELS) {
545
+ return null;
546
+ }
547
+ const retention = artifact.retention;
548
+ if (retention.policy !== "workspace_file" || retention.expiresAt !== null) return null;
549
+ const retrieval = artifact.retrieval;
550
+ if (retrieval.method !== "GET" || retrieval.acceptRanges !== "bytes" || retrieval.maxRangeBytes !== MAX_RANGE_BYTES || typeof retrieval.path !== "string" || retrieval.path.length > 256) {
551
+ return null;
552
+ }
553
+ const match = WORKSPACE_PATH.exec(retrieval.path);
554
+ if (!match || !UUID.test(match[1] ?? "") || match[2] !== artifact.artifactId || expectedWorkspaceId !== void 0 && match[1] !== expectedWorkspaceId) {
555
+ return null;
556
+ }
557
+ return value;
558
+ }
559
+ function generatedImageSandboxPathMatches(artifact, sandboxPath) {
560
+ if (typeof sandboxPath !== "string") return false;
561
+ const extension = artifact.contentType === "image/png" ? "png" : artifact.contentType === "image/jpeg" ? "jpg" : artifact.contentType === "image/webp" ? "webp" : null;
562
+ return extension !== null && sandboxPath === `/workspace/generated-images/generated-image-${artifact.artifactId}.${extension}`;
563
+ }
564
+ function parseGeneratedImageReceipt(value, expectedWorkspaceId) {
565
+ if (typeof value === "string" && value.length <= 4096) {
566
+ try {
567
+ return parseGeneratedImageReceipt(JSON.parse(value), expectedWorkspaceId);
568
+ } catch {
569
+ return null;
570
+ }
571
+ }
572
+ if (!recordWithKeys(value, GENERATED_IMAGE_RECEIPT_KEYS)) return null;
573
+ if (value.type !== "generated_image") return null;
574
+ const artifact = parseRetainedGeneratedImageReference(value.artifact, expectedWorkspaceId);
575
+ if (!artifact || !generatedImageSandboxPathMatches(artifact, value.sandboxPath)) return null;
576
+ return { type: "generated_image", artifact, sandboxPath: value.sandboxPath };
577
+ }
578
+ function parseRetainedGeneratedVideoReference(value, expectedWorkspaceId) {
579
+ if (!recordWithKeys(value, GENERATED_IMAGE_REFERENCE_KEYS)) return null;
580
+ const artifact = value;
581
+ if (artifact.available !== true || artifact.kind !== "generated_video" || typeof artifact.artifactId !== "string" || !UUID.test(artifact.artifactId) || artifact.contentType !== "video/mp4" || !safeIntegerBetween(artifact.originalBytes, 1, MAX_VIDEO_BYTES) || typeof artifact.sha256 !== "string" || !SHA256.test(artifact.sha256) || typeof artifact.retainedAt !== "string" || artifact.retainedAt.length > 64 || !ISO_DATETIME_WITH_OFFSET.test(artifact.retainedAt) || !Number.isFinite(Date.parse(artifact.retainedAt)) || !recordWithKeys(artifact.dimensions, DIMENSION_KEYS) || !recordWithKeys(artifact.retention, RETENTION_KEYS) || !recordWithKeys(artifact.retrieval, RETRIEVAL_KEYS)) {
582
+ return null;
583
+ }
584
+ const dimensions = artifact.dimensions;
585
+ if (!safeIntegerBetween(dimensions.width, 1, 8192) || !safeIntegerBetween(dimensions.height, 1, 8192)) {
586
+ return null;
587
+ }
588
+ const retention = artifact.retention;
589
+ if (retention.policy !== "workspace_file" || retention.expiresAt !== null) return null;
590
+ const retrieval = artifact.retrieval;
591
+ if (retrieval.method !== "GET" || retrieval.acceptRanges !== "bytes" || retrieval.maxRangeBytes !== MAX_RANGE_BYTES || typeof retrieval.path !== "string" || retrieval.path.length > 256) {
592
+ return null;
593
+ }
594
+ const match = WORKSPACE_PATH.exec(retrieval.path);
595
+ if (!match || !UUID.test(match[1] ?? "") || match[2] !== artifact.artifactId || expectedWorkspaceId !== void 0 && match[1] !== expectedWorkspaceId) {
596
+ return null;
597
+ }
598
+ return value;
599
+ }
600
+ function parseGeneratedVideoReceipt(value, expectedWorkspaceId) {
601
+ if (typeof value === "string" && value.length <= 8192) {
602
+ try {
603
+ return parseGeneratedVideoReceipt(JSON.parse(value), expectedWorkspaceId);
604
+ } catch {
605
+ return null;
606
+ }
607
+ }
608
+ if (!recordWithKeys(value, GENERATED_VIDEO_RECEIPT_KEYS)) return null;
609
+ if (value.type !== "generated_video" || value.schemaVersion !== 1 || typeof value.operationId !== "string" || !UUID.test(value.operationId) || !recordWithKeys(value.video, GENERATED_VIDEO_FACT_KEYS)) {
610
+ return null;
611
+ }
612
+ const artifact = parseRetainedGeneratedVideoReference(value.artifact, expectedWorkspaceId);
613
+ const video = value.video;
614
+ if (!artifact || typeof value.sandboxPath !== "string" || value.sandboxPath !== `/workspace/generated-videos/generated-video-${artifact.artifactId}.mp4` || typeof video.durationSeconds !== "number" || !Number.isFinite(video.durationSeconds) || video.durationSeconds <= 0 || video.durationSeconds > 120 || video.width !== artifact.dimensions?.width || video.height !== artifact.dimensions?.height || typeof video.fps !== "number" || !Number.isFinite(video.fps) || video.fps <= 0 || video.fps > 120 || typeof video.hasAudio !== "boolean" || video.videoCodec !== "h264" || video.audioCodec !== null && video.audioCodec !== "aac") {
615
+ return null;
616
+ }
617
+ return value;
618
+ }
619
+ function parseMediaGenerationResult(value, expectedWorkspaceId) {
620
+ if (typeof value === "string" && value.length <= 12e3) {
621
+ try {
622
+ return parseMediaGenerationResult(JSON.parse(value), expectedWorkspaceId);
623
+ } catch {
624
+ return null;
625
+ }
626
+ }
627
+ if (!value || typeof value !== "object" || Array.isArray(value)) return null;
628
+ const result = value;
629
+ if (result.type !== "media_generation_result" || result.schemaVersion !== 1 || typeof result.operationId !== "string" || !UUID.test(result.operationId)) {
630
+ return null;
631
+ }
632
+ if (result.status === "ready") {
633
+ if (!recordWithKeys(result, MEDIA_RESULT_READY_KEYS)) return null;
634
+ const receipt = parseGeneratedVideoReceipt(result.receipt, expectedWorkspaceId);
635
+ if (!receipt || receipt.operationId !== result.operationId) return null;
636
+ return value;
637
+ }
638
+ if (!["provider_failed", "retention_failed", "cancelled_before_submit", "outcome_unknown"].includes(
639
+ String(result.status)
640
+ ) || !recordWithKeys(result, MEDIA_RESULT_FAILURE_KEYS) || typeof result.boundedPublicReason !== "string" || result.boundedPublicReason.length < 1 || result.boundedPublicReason.length > 1e3) {
641
+ return null;
642
+ }
643
+ return value;
644
+ }
645
+ var GENERATED_IMAGE_REFERENCE_KEYS = /* @__PURE__ */ new Set([
646
+ "available",
647
+ "artifactId",
648
+ "kind",
649
+ "contentType",
650
+ "originalBytes",
651
+ "sha256",
652
+ "retainedAt",
653
+ "dimensions",
654
+ "retention",
655
+ "retrieval"
656
+ ]);
657
+ var DIMENSION_KEYS = /* @__PURE__ */ new Set(["width", "height"]);
658
+ var RETENTION_KEYS = /* @__PURE__ */ new Set(["policy", "expiresAt"]);
659
+ var RETRIEVAL_KEYS = /* @__PURE__ */ new Set(["method", "path", "acceptRanges", "maxRangeBytes"]);
660
+ var GENERATED_IMAGE_RECEIPT_KEYS = /* @__PURE__ */ new Set(["type", "artifact", "sandboxPath"]);
661
+ var GENERATED_VIDEO_RECEIPT_KEYS = /* @__PURE__ */ new Set([
662
+ "type",
663
+ "schemaVersion",
664
+ "operationId",
665
+ "artifact",
666
+ "video",
667
+ "sandboxPath"
668
+ ]);
669
+ var GENERATED_VIDEO_FACT_KEYS = /* @__PURE__ */ new Set([
670
+ "durationSeconds",
671
+ "width",
672
+ "height",
673
+ "fps",
674
+ "hasAudio",
675
+ "videoCodec",
676
+ "audioCodec"
677
+ ]);
678
+ var MEDIA_RESULT_READY_KEYS = /* @__PURE__ */ new Set([
679
+ "type",
680
+ "schemaVersion",
681
+ "status",
682
+ "operationId",
683
+ "receipt"
684
+ ]);
685
+ var MEDIA_RESULT_FAILURE_KEYS = /* @__PURE__ */ new Set([
686
+ "type",
687
+ "schemaVersion",
688
+ "status",
689
+ "operationId",
690
+ "boundedPublicReason"
691
+ ]);
692
+ function recordWithKeys(value, allowed) {
693
+ return value !== null && typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === allowed.size && Object.keys(value).every((key) => allowed.has(key));
694
+ }
695
+ function safeIntegerBetween(value, min, max) {
696
+ return Number.isSafeInteger(value) && Number(value) >= min && Number(value) <= max;
697
+ }
542
698
 
543
699
  // src/client.ts
544
700
  function sessionListQuery(options) {
@@ -554,10 +710,13 @@ var OpenGeniClient = class {
554
710
  fetchImpl;
555
711
  readInFlight = /* @__PURE__ */ new Map();
556
712
  readTrailing = /* @__PURE__ */ new Map();
713
+ /** Resource-oriented Browser/Computer facade over this exact authenticated client. */
714
+ interaction;
557
715
  constructor(options) {
558
716
  this.baseUrl = options.baseUrl.replace(/\/+$/, "");
559
717
  this.options = options;
560
718
  this.fetchImpl = options.fetch ?? ((input, init) => fetch(input, init));
719
+ this.interaction = new OpenGeniInteractionClient(this);
561
720
  }
562
721
  // --- Session lifecycle ---------------------------------------------------
563
722
  /** Make one finalization attempt for a recording; callers may retry retained audio. */
@@ -839,6 +998,21 @@ var OpenGeniClient = class {
839
998
  }
840
999
  return response;
841
1000
  }
1001
+ /** Compact, bounded workspace agent hierarchy page. */
1002
+ async listAgentTopology(workspaceId, options = {}) {
1003
+ const search = options.search?.trim();
1004
+ return await this.requestJson(
1005
+ "GET",
1006
+ `/v1/workspaces/${workspaceId}/agent-topology`,
1007
+ void 0,
1008
+ {
1009
+ ...options.limit !== void 0 ? { limit: String(options.limit) } : {},
1010
+ ...options.parentSessionId === void 0 ? {} : { parentSessionId: options.parentSessionId ?? "null" },
1011
+ ...options.cursor ? { cursor: options.cursor } : {},
1012
+ ...search ? { search } : {}
1013
+ }
1014
+ );
1015
+ }
842
1016
  /** Set this authenticated member's personal workspace pin for a session. */
843
1017
  async updateSessionPin(workspaceId, sessionId, request) {
844
1018
  return await this.requestJson(
@@ -897,6 +1071,16 @@ var OpenGeniClient = class {
897
1071
  { signal: options.signal }
898
1072
  );
899
1073
  }
1074
+ /** Mint a short-lived browser token from a connected SuperGrok account. */
1075
+ async negotiateXaiSubscriptionRealtime(workspaceId, sessionId, request, options = {}) {
1076
+ return await this.requestJson(
1077
+ "POST",
1078
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/realtime/supergrok`,
1079
+ request,
1080
+ {},
1081
+ { signal: options.signal }
1082
+ );
1083
+ }
900
1084
  /** Promote a negotiated connection only after its browser data channel is ready. */
901
1085
  async activateCodexRealtimeConnection(workspaceId, sessionId, realtimeId, connectionId, request, options = {}) {
902
1086
  return await this.requestJson(
@@ -1406,6 +1590,50 @@ var OpenGeniClient = class {
1406
1590
  streamWorkspaceControlEvents(workspaceId, options = {}) {
1407
1591
  return streamWorkspaceControlEvents(this.workspaceControlStreamTransport(workspaceId), options);
1408
1592
  }
1593
+ /**
1594
+ * Multiplex workspace control and interaction invalidations over one HTTP
1595
+ * connection while retaining an independent durable cursor for each domain.
1596
+ */
1597
+ streamWorkspaceLiveEvents(workspaceId, options = {}) {
1598
+ return streamWorkspaceLiveEvents(this.workspaceLiveStreamTransport(workspaceId), options);
1599
+ }
1600
+ workspaceLiveStreamTransport(workspaceId) {
1601
+ return {
1602
+ openStream: async (controlAfter, interactionAfter, signal) => await this.openWorkspaceLiveEventStream(workspaceId, {
1603
+ controlAfter,
1604
+ interactionAfter,
1605
+ ...signal ? { signal } : {}
1606
+ })
1607
+ };
1608
+ }
1609
+ async openWorkspaceLiveEventStream(workspaceId, options = {}) {
1610
+ const correlationId = crypto.randomUUID();
1611
+ const response = await this.fetchImpl(
1612
+ this.url(`/v1/workspaces/${workspaceId}/live-events/stream`, {
1613
+ controlAfter: String(options.controlAfter ?? 0),
1614
+ interactionAfter: String(options.interactionAfter ?? 0)
1615
+ }),
1616
+ {
1617
+ method: "GET",
1618
+ headers: {
1619
+ ...this.headers(correlationId),
1620
+ Accept: "text/event-stream"
1621
+ },
1622
+ ...options.signal ? { signal: options.signal } : {}
1623
+ }
1624
+ );
1625
+ assertApiContractResponse(response);
1626
+ if (!response.ok) {
1627
+ throw await apiErrorFromResponse(response, {
1628
+ method: "GET",
1629
+ correlationId
1630
+ });
1631
+ }
1632
+ if (!response.body) {
1633
+ throw new OpenGeniApiError(response.status, "SSE response did not include a readable body");
1634
+ }
1635
+ return response.body;
1636
+ }
1409
1637
  workspaceControlStreamTransport(workspaceId) {
1410
1638
  return {
1411
1639
  openStream: async (after, signal) => await this.openWorkspaceControlEventStream(workspaceId, {
@@ -1466,6 +1694,19 @@ var OpenGeniClient = class {
1466
1694
  request
1467
1695
  );
1468
1696
  }
1697
+ async listGoalRevisions(workspaceId, sessionId) {
1698
+ return await this.requestJson(
1699
+ "GET",
1700
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/goal/revisions`
1701
+ );
1702
+ }
1703
+ async applyGoalRevision(workspaceId, sessionId, revisionId, request) {
1704
+ return await this.requestJson(
1705
+ "POST",
1706
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/goal/revisions/${revisionId}/apply`,
1707
+ request
1708
+ );
1709
+ }
1469
1710
  async deleteGoal(workspaceId, sessionId) {
1470
1711
  await this.requestVoid("DELETE", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/goal`);
1471
1712
  }
@@ -1714,13 +1955,11 @@ var OpenGeniClient = class {
1714
1955
  );
1715
1956
  }
1716
1957
  /** Attach a viewer holder (refcounted liveness — keeps the box warm while
1717
- * watched/used), spinning the box up in-process when cold, and mint the scoped
1718
- * direct-to-provider URLs for the requested plane(s). `request.desktop:true`
1719
- * opts into the un-redacted pixel plane and mints the noVNC URL — that plane
1720
- * alone throws `OpenGeniApiError(409)` when the un-redacted/shared
1721
- * acknowledgment is missing (the consent gate). A terminal-only attach
1722
- * (`desktop` omitted/false) warms the box + mints the pty-ws terminal cell with
1723
- * NO consent gate. An omitted `viewerId` mints a fresh one. */
1958
+ * watched/used), spinning the box up in-process when cold. Exact plane flags
1959
+ * mint only the requested short-lived credentials and enforce that plane's
1960
+ * permission. `desktop:true` alone carries the un-redacted/shared consent
1961
+ * gate. An entirely omitted plane set retains the legacy terminal-only
1962
+ * meaning; current clients should send all three flags. */
1724
1963
  async attachViewer(workspaceId, sessionId, request = {}) {
1725
1964
  return await this.requestJson(
1726
1965
  "POST",
@@ -1745,15 +1984,604 @@ var OpenGeniClient = class {
1745
1984
  `/v1/workspaces/${workspaceId}/sessions/${sessionId}/viewers/${viewerId}`
1746
1985
  );
1747
1986
  }
1748
- // --- Access + workspaces -----------------------------------------------------
1749
- /**
1750
- * The deployment's public client bootstrap config: the host-exposed models
1751
- * (provider-grouped in `models`, flat in `allowedModels` for back-compat),
1752
- * reasoning efforts, MCP servers, file-upload limits, and how the client is
1753
- * expected to authenticate. Drives a composer's model picker without prior
1754
- * knowledge of the host setup; safe to call before any auth is established.
1755
- */
1756
- async getClientConfig() {
1987
+ // --- Browser / Computer interaction resources --------------------------------
1988
+ streamWorkspaceInteractionRevisions(workspaceId, options = {}) {
1989
+ return streamWorkspaceInteractionRevisions(
1990
+ this.workspaceInteractionRevisionStreamTransport(workspaceId),
1991
+ options
1992
+ );
1993
+ }
1994
+ workspaceInteractionRevisionStreamTransport(workspaceId) {
1995
+ return {
1996
+ openStream: async (after, signal) => await this.openWorkspaceInteractionRevisionStream(workspaceId, {
1997
+ after,
1998
+ ...signal ? { signal } : {}
1999
+ })
2000
+ };
2001
+ }
2002
+ async openWorkspaceInteractionRevisionStream(workspaceId, options = {}) {
2003
+ const correlationId = crypto.randomUUID();
2004
+ const response = await this.fetchImpl(
2005
+ this.url(`/v1/workspaces/${workspaceId}/interaction-events/stream`, {
2006
+ after: String(options.after ?? 0)
2007
+ }),
2008
+ {
2009
+ method: "GET",
2010
+ headers: {
2011
+ ...this.headers(correlationId),
2012
+ Accept: "text/event-stream"
2013
+ },
2014
+ ...options.signal ? { signal: options.signal } : {}
2015
+ }
2016
+ );
2017
+ assertApiContractResponse(response);
2018
+ if (!response.ok) {
2019
+ throw await apiErrorFromResponse(response, {
2020
+ method: "GET",
2021
+ correlationId
2022
+ });
2023
+ }
2024
+ if (!response.body) {
2025
+ throw new OpenGeniApiError(response.status, "SSE response did not include a readable body");
2026
+ }
2027
+ return response.body;
2028
+ }
2029
+ async listNetworkRoutes(workspaceId, options = {}) {
2030
+ return await this.requestJson(
2031
+ "GET",
2032
+ `/v1/workspaces/${workspaceId}/network-routes`,
2033
+ void 0,
2034
+ options.includeArchived ? { includeArchived: "true" } : {},
2035
+ options
2036
+ );
2037
+ }
2038
+ async getNetworkRoute(workspaceId, networkRouteId, options = {}) {
2039
+ return await this.requestJson(
2040
+ "GET",
2041
+ `/v1/workspaces/${workspaceId}/network-routes/${encodeURIComponent(networkRouteId)}`,
2042
+ void 0,
2043
+ {},
2044
+ options
2045
+ );
2046
+ }
2047
+ async createNetworkRoute(workspaceId, request, options = {}) {
2048
+ return await this.requestJson(
2049
+ "POST",
2050
+ `/v1/workspaces/${workspaceId}/network-routes`,
2051
+ request,
2052
+ {},
2053
+ options
2054
+ );
2055
+ }
2056
+ async updateNetworkRoute(workspaceId, networkRouteId, request, options = {}) {
2057
+ return await this.requestJson(
2058
+ "PATCH",
2059
+ `/v1/workspaces/${workspaceId}/network-routes/${encodeURIComponent(networkRouteId)}`,
2060
+ request,
2061
+ {},
2062
+ options
2063
+ );
2064
+ }
2065
+ async listSiteAuthConnections(workspaceId, options = {}) {
2066
+ return await this.requestJson(
2067
+ "GET",
2068
+ `/v1/workspaces/${workspaceId}/site-auth-connections`,
2069
+ void 0,
2070
+ options.includeArchived ? { includeArchived: "true" } : {},
2071
+ options
2072
+ );
2073
+ }
2074
+ async getSiteAuthConnection(workspaceId, siteAuthConnectionId, options = {}) {
2075
+ return await this.requestJson(
2076
+ "GET",
2077
+ `/v1/workspaces/${workspaceId}/site-auth-connections/${encodeURIComponent(siteAuthConnectionId)}`,
2078
+ void 0,
2079
+ {},
2080
+ options
2081
+ );
2082
+ }
2083
+ async createSiteAuthConnection(workspaceId, request, options = {}) {
2084
+ return await this.requestJson(
2085
+ "POST",
2086
+ `/v1/workspaces/${workspaceId}/site-auth-connections`,
2087
+ request,
2088
+ {},
2089
+ options
2090
+ );
2091
+ }
2092
+ async updateSiteAuthConnection(workspaceId, siteAuthConnectionId, request, options = {}) {
2093
+ return await this.requestJson(
2094
+ "PATCH",
2095
+ `/v1/workspaces/${workspaceId}/site-auth-connections/${encodeURIComponent(siteAuthConnectionId)}`,
2096
+ request,
2097
+ {},
2098
+ options
2099
+ );
2100
+ }
2101
+ async listAuthRuns(workspaceId, options = {}) {
2102
+ return await this.requestJson(
2103
+ "GET",
2104
+ `/v1/workspaces/${workspaceId}/auth-runs`,
2105
+ void 0,
2106
+ {
2107
+ ...options.browserSessionId ? { browserSessionId: options.browserSessionId } : {},
2108
+ ...options.siteAuthConnectionId ? { siteAuthConnectionId: options.siteAuthConnectionId } : {},
2109
+ ...options.includeSettled ? { includeSettled: "true" } : {}
2110
+ },
2111
+ options
2112
+ );
2113
+ }
2114
+ async getAuthRun(workspaceId, authRunId, options = {}) {
2115
+ return await this.requestJson(
2116
+ "GET",
2117
+ `/v1/workspaces/${workspaceId}/auth-runs/${encodeURIComponent(authRunId)}`,
2118
+ void 0,
2119
+ {},
2120
+ options
2121
+ );
2122
+ }
2123
+ async startBrowserAuthRun(workspaceId, browserSessionId, request, options = {}) {
2124
+ return await this.requestJson(
2125
+ "POST",
2126
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/auth-runs`,
2127
+ request,
2128
+ {},
2129
+ options
2130
+ );
2131
+ }
2132
+ async reportBrowserAuthRun(workspaceId, browserSessionId, authRunId, request, options = {}) {
2133
+ return await this.requestJson(
2134
+ "POST",
2135
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/auth-runs/${encodeURIComponent(authRunId)}/report`,
2136
+ request,
2137
+ {},
2138
+ options
2139
+ );
2140
+ }
2141
+ async protectedBrowserAuthFill(workspaceId, browserSessionId, authRunId, request, options = {}) {
2142
+ return await this.requestJson(
2143
+ "POST",
2144
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/auth-runs/${encodeURIComponent(authRunId)}/protected-fill`,
2145
+ request,
2146
+ {},
2147
+ options
2148
+ );
2149
+ }
2150
+ async advanceExternalBrowserAuthRun(workspaceId, browserSessionId, authRunId, request, options = {}) {
2151
+ return await this.requestJson(
2152
+ "POST",
2153
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/auth-runs/${encodeURIComponent(authRunId)}/external-auth`,
2154
+ request,
2155
+ {},
2156
+ options
2157
+ );
2158
+ }
2159
+ async openExternalBrowserAuthFlow(workspaceId, browserSessionId, authRunId, request, options = {}) {
2160
+ return await this.requestJson(
2161
+ "POST",
2162
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/auth-runs/${encodeURIComponent(authRunId)}/external-auth/interactive`,
2163
+ request,
2164
+ {},
2165
+ options
2166
+ );
2167
+ }
2168
+ async verifyBrowserAuthRun(workspaceId, browserSessionId, authRunId, request, options = {}) {
2169
+ return await this.requestJson(
2170
+ "POST",
2171
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/auth-runs/${encodeURIComponent(authRunId)}/verify`,
2172
+ request,
2173
+ {},
2174
+ options
2175
+ );
2176
+ }
2177
+ async listInteractionInterventions(workspaceId, options = {}) {
2178
+ return await this.requestJson(
2179
+ "GET",
2180
+ `/v1/workspaces/${workspaceId}/interaction-interventions`,
2181
+ void 0,
2182
+ {
2183
+ ...options.resourceKind ? { resourceKind: options.resourceKind } : {},
2184
+ ...options.resourceId ? { resourceId: options.resourceId } : {},
2185
+ ...options.includeSettled ? { includeSettled: "true" } : {}
2186
+ },
2187
+ options
2188
+ );
2189
+ }
2190
+ async getInteractionIntervention(workspaceId, interventionId, options = {}) {
2191
+ return await this.requestJson(
2192
+ "GET",
2193
+ `/v1/workspaces/${workspaceId}/interaction-interventions/${encodeURIComponent(interventionId)}`,
2194
+ void 0,
2195
+ {},
2196
+ options
2197
+ );
2198
+ }
2199
+ async createInteractionIntervention(workspaceId, request, options = {}) {
2200
+ return await this.requestJson(
2201
+ "POST",
2202
+ `/v1/workspaces/${workspaceId}/interaction-interventions`,
2203
+ request,
2204
+ {},
2205
+ options
2206
+ );
2207
+ }
2208
+ async resolveInteractionIntervention(workspaceId, interventionId, request, options = {}) {
2209
+ return await this.requestJson(
2210
+ "POST",
2211
+ `/v1/workspaces/${workspaceId}/interaction-interventions/${encodeURIComponent(interventionId)}/resolve`,
2212
+ request,
2213
+ {},
2214
+ options
2215
+ );
2216
+ }
2217
+ async listAttachedBrowsers(workspaceId, options = {}) {
2218
+ return await this.requestJson(
2219
+ "GET",
2220
+ `/v1/workspaces/${workspaceId}/attached-browsers`,
2221
+ void 0,
2222
+ options.includeDisconnected ? { includeDisconnected: "true" } : {},
2223
+ options
2224
+ );
2225
+ }
2226
+ async getAttachedBrowser(workspaceId, deviceId, options = {}) {
2227
+ return await this.requestJson(
2228
+ "GET",
2229
+ `/v1/workspaces/${workspaceId}/attached-browsers/${encodeURIComponent(deviceId)}`,
2230
+ void 0,
2231
+ {},
2232
+ options
2233
+ );
2234
+ }
2235
+ async listBrowserIdentities(workspaceId, options = {}) {
2236
+ return await this.requestJson(
2237
+ "GET",
2238
+ `/v1/workspaces/${workspaceId}/browser-identities`,
2239
+ void 0,
2240
+ options.includeArchived ? { includeArchived: "true" } : {},
2241
+ options
2242
+ );
2243
+ }
2244
+ async getBrowserIdentity(workspaceId, identityId, options = {}) {
2245
+ return await this.requestJson(
2246
+ "GET",
2247
+ `/v1/workspaces/${workspaceId}/browser-identities/${encodeURIComponent(identityId)}`,
2248
+ void 0,
2249
+ {},
2250
+ options
2251
+ );
2252
+ }
2253
+ async createBrowserIdentity(workspaceId, request, options = {}) {
2254
+ return await this.requestJson(
2255
+ "POST",
2256
+ `/v1/workspaces/${workspaceId}/browser-identities`,
2257
+ request,
2258
+ {},
2259
+ options
2260
+ );
2261
+ }
2262
+ async updateBrowserIdentity(workspaceId, identityId, request, options = {}) {
2263
+ return await this.requestJson(
2264
+ "PATCH",
2265
+ `/v1/workspaces/${workspaceId}/browser-identities/${encodeURIComponent(identityId)}`,
2266
+ request,
2267
+ {},
2268
+ options
2269
+ );
2270
+ }
2271
+ async listBrowserRevisions(workspaceId, identityId, options = {}) {
2272
+ return await this.requestJson(
2273
+ "GET",
2274
+ `/v1/workspaces/${workspaceId}/browser-identities/${encodeURIComponent(identityId)}/revisions`,
2275
+ void 0,
2276
+ {},
2277
+ options
2278
+ );
2279
+ }
2280
+ /** Workspace-wide BrowserSession inventory. Associations express relevance,
2281
+ * not access: peers and child agents intentionally remain discoverable. */
2282
+ async listBrowserSessions(workspaceId, options = {}) {
2283
+ return await this.requestJson(
2284
+ "GET",
2285
+ `/v1/workspaces/${workspaceId}/browser-sessions`,
2286
+ void 0,
2287
+ {},
2288
+ options
2289
+ );
2290
+ }
2291
+ async getBrowserSession(workspaceId, browserSessionId, options = {}) {
2292
+ return await this.requestJson(
2293
+ "GET",
2294
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}`,
2295
+ void 0,
2296
+ {},
2297
+ options
2298
+ );
2299
+ }
2300
+ async readBrowserClipboard(workspaceId, browserSessionId, options = {}) {
2301
+ return await this.requestJson(
2302
+ "GET",
2303
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/clipboard`,
2304
+ void 0,
2305
+ {},
2306
+ options
2307
+ );
2308
+ }
2309
+ async listBrowserDownloads(workspaceId, browserSessionId, options = {}) {
2310
+ return await this.requestJson(
2311
+ "GET",
2312
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/downloads`,
2313
+ void 0,
2314
+ {},
2315
+ options
2316
+ );
2317
+ }
2318
+ async getBrowserDownload(workspaceId, browserSessionId, downloadId, options = {}) {
2319
+ return await this.requestJson(
2320
+ "GET",
2321
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/downloads/${encodeURIComponent(downloadId)}`,
2322
+ void 0,
2323
+ {},
2324
+ options
2325
+ );
2326
+ }
2327
+ async saveBrowserDownload(workspaceId, browserSessionId, downloadId, request, options = {}) {
2328
+ return await this.requestJson(
2329
+ "POST",
2330
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/downloads/${encodeURIComponent(downloadId)}/save`,
2331
+ request,
2332
+ {},
2333
+ options
2334
+ );
2335
+ }
2336
+ async createBrowserSession(workspaceId, request, options = {}) {
2337
+ return await this.requestJson(
2338
+ "POST",
2339
+ `/v1/workspaces/${workspaceId}/browser-sessions`,
2340
+ request,
2341
+ {},
2342
+ options
2343
+ );
2344
+ }
2345
+ async listBrowserTargets(workspaceId, browserSessionId, options = {}) {
2346
+ return await this.requestJson(
2347
+ "GET",
2348
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/targets`,
2349
+ void 0,
2350
+ {},
2351
+ options
2352
+ );
2353
+ }
2354
+ async openBrowserTarget(workspaceId, browserSessionId, request = {}, options = {}) {
2355
+ return await this.requestJson(
2356
+ "POST",
2357
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/targets`,
2358
+ request,
2359
+ {},
2360
+ options
2361
+ );
2362
+ }
2363
+ async selectBrowserTarget(workspaceId, browserSessionId, targetId, options = {}) {
2364
+ return await this.requestJson(
2365
+ "POST",
2366
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/targets/${encodeURIComponent(targetId)}/select`,
2367
+ {},
2368
+ {},
2369
+ options
2370
+ );
2371
+ }
2372
+ async closeBrowserTarget(workspaceId, browserSessionId, targetId, options = {}) {
2373
+ return await this.requestJson(
2374
+ "DELETE",
2375
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/targets/${encodeURIComponent(targetId)}`,
2376
+ void 0,
2377
+ {},
2378
+ options
2379
+ );
2380
+ }
2381
+ async observeBrowserTarget(workspaceId, browserSessionId, targetId, options = {}) {
2382
+ return await this.requestJson(
2383
+ "GET",
2384
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/targets/${encodeURIComponent(targetId)}/observation`,
2385
+ void 0,
2386
+ {},
2387
+ options
2388
+ );
2389
+ }
2390
+ async actInBrowser(workspaceId, browserSessionId, request, options = {}) {
2391
+ return await this.requestJson(
2392
+ "POST",
2393
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/actions`,
2394
+ request,
2395
+ {},
2396
+ options
2397
+ );
2398
+ }
2399
+ async getBrowserActionReceipt(workspaceId, browserSessionId, operationId, options = {}) {
2400
+ return await this.requestJson(
2401
+ "GET",
2402
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/operations/${encodeURIComponent(operationId)}`,
2403
+ void 0,
2404
+ {},
2405
+ options
2406
+ );
2407
+ }
2408
+ async listBrowserDiagnostics(workspaceId, browserSessionId, targetId, options = {}) {
2409
+ return await this.requestJson(
2410
+ "GET",
2411
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/targets/${encodeURIComponent(targetId)}/diagnostics`,
2412
+ void 0,
2413
+ {
2414
+ ...options.kinds?.length ? { kinds: options.kinds.join(",") } : {},
2415
+ ...options.after !== void 0 ? { after: String(options.after) } : {},
2416
+ ...options.limit !== void 0 ? { limit: String(options.limit) } : {}
2417
+ },
2418
+ options.signal ? { signal: options.signal } : {}
2419
+ );
2420
+ }
2421
+ async attachBrowserSession(workspaceId, browserSessionId, request, options = {}) {
2422
+ return await this.requestJson(
2423
+ "POST",
2424
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/attachments`,
2425
+ request,
2426
+ {},
2427
+ options
2428
+ );
2429
+ }
2430
+ async heartbeatBrowserSession(workspaceId, browserSessionId, options = {}) {
2431
+ return await this.requestJson(
2432
+ "POST",
2433
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/heartbeat`,
2434
+ {},
2435
+ {},
2436
+ options
2437
+ );
2438
+ }
2439
+ async publishBrowserRevision(workspaceId, browserSessionId, request, options = {}) {
2440
+ return await this.requestJson(
2441
+ "POST",
2442
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/revisions`,
2443
+ request,
2444
+ {},
2445
+ options
2446
+ );
2447
+ }
2448
+ async suspendBrowserSession(workspaceId, browserSessionId, request, options = {}) {
2449
+ return await this.requestJson(
2450
+ "POST",
2451
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/suspend`,
2452
+ request,
2453
+ {},
2454
+ options
2455
+ );
2456
+ }
2457
+ async resumeBrowserSession(workspaceId, browserSessionId, request, options = {}) {
2458
+ return await this.requestJson(
2459
+ "POST",
2460
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/resume`,
2461
+ request,
2462
+ {},
2463
+ options
2464
+ );
2465
+ }
2466
+ async endBrowserSession(workspaceId, browserSessionId, request, options = {}) {
2467
+ return await this.requestJson(
2468
+ "POST",
2469
+ `/v1/workspaces/${workspaceId}/browser-sessions/${encodeURIComponent(browserSessionId)}/end`,
2470
+ request,
2471
+ {},
2472
+ options
2473
+ );
2474
+ }
2475
+ /** Workspace-wide ComputerSession inventory. Associations express
2476
+ * relevance, not access; peer sessions intentionally remain discoverable. */
2477
+ async listComputerSessions(workspaceId, options = {}) {
2478
+ return await this.requestJson(
2479
+ "GET",
2480
+ `/v1/workspaces/${workspaceId}/computer-sessions`,
2481
+ void 0,
2482
+ {},
2483
+ options
2484
+ );
2485
+ }
2486
+ async getComputerSession(workspaceId, computerSessionId, options = {}) {
2487
+ return await this.requestJson(
2488
+ "GET",
2489
+ `/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}`,
2490
+ void 0,
2491
+ {},
2492
+ options
2493
+ );
2494
+ }
2495
+ async readComputerClipboard(workspaceId, computerSessionId, options = {}) {
2496
+ return await this.requestJson(
2497
+ "GET",
2498
+ `/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}/clipboard`,
2499
+ void 0,
2500
+ {},
2501
+ options
2502
+ );
2503
+ }
2504
+ async createComputerSession(workspaceId, request, options = {}) {
2505
+ return await this.requestJson(
2506
+ "POST",
2507
+ `/v1/workspaces/${workspaceId}/computer-sessions`,
2508
+ request,
2509
+ {},
2510
+ options
2511
+ );
2512
+ }
2513
+ async listComputerTargets(workspaceId, computerSessionId, options = {}) {
2514
+ return await this.requestJson(
2515
+ "GET",
2516
+ `/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}/targets`,
2517
+ void 0,
2518
+ {},
2519
+ options
2520
+ );
2521
+ }
2522
+ async observeComputerTarget(workspaceId, computerSessionId, targetId, options = {}) {
2523
+ return await this.requestJson(
2524
+ "GET",
2525
+ `/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}/targets/${encodeURIComponent(targetId)}/observation`,
2526
+ void 0,
2527
+ {},
2528
+ options
2529
+ );
2530
+ }
2531
+ async actInComputer(workspaceId, computerSessionId, request, options = {}) {
2532
+ return await this.requestJson(
2533
+ "POST",
2534
+ `/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}/actions`,
2535
+ request,
2536
+ {},
2537
+ options
2538
+ );
2539
+ }
2540
+ async getComputerActionReceipt(workspaceId, computerSessionId, operationId, options = {}) {
2541
+ return await this.requestJson(
2542
+ "GET",
2543
+ `/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}/operations/${encodeURIComponent(operationId)}`,
2544
+ void 0,
2545
+ {},
2546
+ options
2547
+ );
2548
+ }
2549
+ async attachComputerSession(workspaceId, computerSessionId, request, options = {}) {
2550
+ return await this.requestJson(
2551
+ "POST",
2552
+ `/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}/attachments`,
2553
+ request,
2554
+ {},
2555
+ options
2556
+ );
2557
+ }
2558
+ async heartbeatComputerSession(workspaceId, computerSessionId, options = {}) {
2559
+ return await this.requestJson(
2560
+ "POST",
2561
+ `/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}/heartbeat`,
2562
+ {},
2563
+ {},
2564
+ options
2565
+ );
2566
+ }
2567
+ async endComputerSession(workspaceId, computerSessionId, request, options = {}) {
2568
+ return await this.requestJson(
2569
+ "POST",
2570
+ `/v1/workspaces/${workspaceId}/computer-sessions/${encodeURIComponent(computerSessionId)}/end`,
2571
+ request,
2572
+ {},
2573
+ options
2574
+ );
2575
+ }
2576
+ // --- Access + workspaces -----------------------------------------------------
2577
+ /**
2578
+ * The deployment's public client bootstrap config: the host-exposed models
2579
+ * (provider-grouped in `models`, flat in `allowedModels` for back-compat),
2580
+ * reasoning efforts, MCP servers, file-upload limits, and how the client is
2581
+ * expected to authenticate. Drives a composer's model picker without prior
2582
+ * knowledge of the host setup; safe to call before any auth is established.
2583
+ */
2584
+ async getClientConfig() {
1757
2585
  const config = await this.requestJson("GET", "/v1/config/client");
1758
2586
  if (config.apiContractRevision !== OPENGENI_API_CONTRACT_REVISION) {
1759
2587
  throw new OpenGeniApiContractMismatchError(
@@ -1781,6 +2609,13 @@ var OpenGeniClient = class {
1781
2609
  async getAccessContext() {
1782
2610
  return await this.requestJson("GET", "/v1/access/me");
1783
2611
  }
2612
+ /** Active organization memberships proven by the current managed-human session. */
2613
+ async listOrganizationMemberships() {
2614
+ return await this.requestJson(
2615
+ "GET",
2616
+ "/v1/organization-memberships"
2617
+ );
2618
+ }
1784
2619
  async listWorkspaces() {
1785
2620
  return await this.requestJson("GET", "/v1/workspaces");
1786
2621
  }
@@ -1892,6 +2727,52 @@ var OpenGeniClient = class {
1892
2727
  request
1893
2728
  );
1894
2729
  }
2730
+ /** Read the current organization profile plus immutable revision and activation history. */
2731
+ async listCompanyProfile(workspaceId, options = {}) {
2732
+ const params = new URLSearchParams();
2733
+ if (options.afterRevision !== void 0)
2734
+ params.set("afterRevision", String(options.afterRevision));
2735
+ if (options.limit !== void 0) params.set("limit", String(options.limit));
2736
+ const query = params.toString();
2737
+ return await this.requestJson(
2738
+ "GET",
2739
+ `/v1/workspaces/${workspaceId}/company-profile${query ? `?${query}` : ""}`
2740
+ );
2741
+ }
2742
+ async getCompanyProfileRevision(workspaceId, revisionId) {
2743
+ return await this.requestJson(
2744
+ "GET",
2745
+ `/v1/workspaces/${workspaceId}/company-profile/revisions/${encodeURIComponent(revisionId)}`
2746
+ );
2747
+ }
2748
+ async updateCompanyProfile(workspaceId, request) {
2749
+ return await this.requestJson(
2750
+ "PUT",
2751
+ `/v1/workspaces/${workspaceId}/company-profile`,
2752
+ request
2753
+ );
2754
+ }
2755
+ async diffCompanyProfileRevisions(workspaceId, request) {
2756
+ const params = new URLSearchParams(request);
2757
+ return await this.requestJson(
2758
+ "GET",
2759
+ `/v1/workspaces/${workspaceId}/company-profile/diff?${params}`
2760
+ );
2761
+ }
2762
+ async activateCompanyProfileRevision(workspaceId, revisionId, request) {
2763
+ return await this.requestJson(
2764
+ "POST",
2765
+ `/v1/workspaces/${workspaceId}/company-profile/revisions/${encodeURIComponent(revisionId)}/activate`,
2766
+ request
2767
+ );
2768
+ }
2769
+ async rollbackCompanyProfile(workspaceId, request) {
2770
+ return await this.requestJson(
2771
+ "POST",
2772
+ `/v1/workspaces/${workspaceId}/company-profile/rollback`,
2773
+ request
2774
+ );
2775
+ }
1895
2776
  async listPreferenceRegistry(workspaceId, options = {}) {
1896
2777
  const params = new URLSearchParams();
1897
2778
  if (options.scope) params.set("scope", options.scope);
@@ -1998,21 +2879,70 @@ var OpenGeniClient = class {
1998
2879
  request
1999
2880
  );
2000
2881
  }
2001
- async updateWorkspaceMember(workspaceId, subjectId, request) {
2882
+ async updateWorkspaceMember(workspaceId, subjectId, request) {
2883
+ return await this.requestJson(
2884
+ "PATCH",
2885
+ `/v1/workspaces/${workspaceId}/members/${encodeURIComponent(subjectId)}`,
2886
+ request
2887
+ );
2888
+ }
2889
+ /**
2890
+ * Remove a member. Refused (409) for your own membership and for the last
2891
+ * member who can still manage the workspace.
2892
+ */
2893
+ async removeWorkspaceMember(workspaceId, subjectId) {
2894
+ await this.requestVoid(
2895
+ "DELETE",
2896
+ `/v1/workspaces/${workspaceId}/members/${encodeURIComponent(subjectId)}`
2897
+ );
2898
+ }
2899
+ /** Exchange one signed Slack bearer for durable, token-free continuation state. */
2900
+ async prepareSlackUserLinkAccess(workspaceId, request) {
2901
+ return await this.requestJson(
2902
+ "POST",
2903
+ `/v1/workspaces/${workspaceId}/integrations/slack/user-link-intents`,
2904
+ request
2905
+ );
2906
+ }
2907
+ async getSlackUserLinkAccess(workspaceId, requestId) {
2908
+ return await this.requestJson(
2909
+ "GET",
2910
+ `/v1/workspaces/${workspaceId}/integrations/slack/user-link-intents/${requestId}`
2911
+ );
2912
+ }
2913
+ async requestSlackUserLinkWorkspaceAccess(workspaceId, requestId, request) {
2914
+ return await this.requestJson(
2915
+ "POST",
2916
+ `/v1/workspaces/${workspaceId}/integrations/slack/user-link-intents/${requestId}/request-access`,
2917
+ request
2918
+ );
2919
+ }
2920
+ async cancelSlackUserLinkAccess(workspaceId, requestId, request) {
2921
+ return await this.requestJson(
2922
+ "POST",
2923
+ `/v1/workspaces/${workspaceId}/integrations/slack/user-link-intents/${requestId}/cancel`,
2924
+ request
2925
+ );
2926
+ }
2927
+ async listSlackUserLinkAccessRequests(workspaceId) {
2928
+ const response = await this.requestJson(
2929
+ "GET",
2930
+ `/v1/workspaces/${workspaceId}/members/access-requests/slack`
2931
+ );
2932
+ return response.requests;
2933
+ }
2934
+ async approveSlackUserLinkAccessRequest(workspaceId, requestId, request) {
2002
2935
  return await this.requestJson(
2003
- "PATCH",
2004
- `/v1/workspaces/${workspaceId}/members/${encodeURIComponent(subjectId)}`,
2936
+ "POST",
2937
+ `/v1/workspaces/${workspaceId}/members/access-requests/slack/${requestId}/approve`,
2005
2938
  request
2006
2939
  );
2007
2940
  }
2008
- /**
2009
- * Remove a member. Refused (409) for your own membership and for the last
2010
- * member who can still manage the workspace.
2011
- */
2012
- async removeWorkspaceMember(workspaceId, subjectId) {
2013
- await this.requestVoid(
2014
- "DELETE",
2015
- `/v1/workspaces/${workspaceId}/members/${encodeURIComponent(subjectId)}`
2941
+ async denySlackUserLinkAccessRequest(workspaceId, requestId, request) {
2942
+ return await this.requestJson(
2943
+ "POST",
2944
+ `/v1/workspaces/${workspaceId}/members/access-requests/slack/${requestId}/deny`,
2945
+ request
2016
2946
  );
2017
2947
  }
2018
2948
  // --- Scheduled tasks (write + runs) -------------------------------------------
@@ -2125,6 +3055,41 @@ var OpenGeniClient = class {
2125
3055
  `/v1/workspaces/${workspaceId}/variable-sets/${variableSetId}/variables/${encodeURIComponent(name)}`
2126
3056
  );
2127
3057
  }
3058
+ // --- Channels --------------------------------------------------------------
3059
+ // Workspace-shared rail organization for root sessions. sessions:read gates
3060
+ // list; sessions:create gates create / update / delete; sessions:control
3061
+ // gates re-filing a session.
3062
+ async listChannels(workspaceId) {
3063
+ return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/channels`);
3064
+ }
3065
+ async createChannel(workspaceId, request) {
3066
+ return await this.requestJson(
3067
+ "POST",
3068
+ `/v1/workspaces/${workspaceId}/channels`,
3069
+ request
3070
+ );
3071
+ }
3072
+ async updateChannel(workspaceId, channelId, request) {
3073
+ return await this.requestJson(
3074
+ "PATCH",
3075
+ `/v1/workspaces/${workspaceId}/channels/${channelId}`,
3076
+ request
3077
+ );
3078
+ }
3079
+ async deleteChannel(workspaceId, channelId) {
3080
+ await this.requestJson(
3081
+ "DELETE",
3082
+ `/v1/workspaces/${workspaceId}/channels/${channelId}`
3083
+ );
3084
+ }
3085
+ /** Re-file a session into a channel (null = back to the unfiled inbox). */
3086
+ async updateSessionChannel(workspaceId, sessionId, request) {
3087
+ return await this.requestJson(
3088
+ "PUT",
3089
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/channel`,
3090
+ request
3091
+ );
3092
+ }
2128
3093
  // --- Rigs ------------------------------------------------------------------
2129
3094
  // Workspace-scoped, versioned sandbox machine definitions. rigs:use gates read
2130
3095
  // + proposeRigChange; rigs:manage gates create / update / delete / activate.
@@ -2367,21 +3332,38 @@ var OpenGeniClient = class {
2367
3332
  options
2368
3333
  );
2369
3334
  }
3335
+ /** Assemble one permanent generated-image receipt from bounded authenticated ranges. */
3336
+ async downloadRetainedArtifact(workspaceId, artifact, options = {}) {
3337
+ assertRetainedGeneratedImageReceipt(workspaceId, artifact);
3338
+ const bytes = await this.downloadRetainedArtifactBytes(artifact, options);
3339
+ return { artifact, bytes };
3340
+ }
3341
+ /** Mint a short-lived, zero-copy browser source for a validated generated image. */
3342
+ async createRetainedArtifactDownloadUrl(workspaceId, artifact, options = {}) {
3343
+ assertRetainedGeneratedImageReceipt(workspaceId, artifact);
3344
+ const download = await this.createFileDownloadUrl(workspaceId, artifact.artifactId, options);
3345
+ assertSafeArtifactDownloadUrl(download);
3346
+ return download;
3347
+ }
2370
3348
  /** Assemble one retained screenshot from bounded authenticated API ranges. */
2371
3349
  async downloadRetainedScreenshot(workspaceId, sessionId, artifactId, options = {}) {
2372
- const maxRetries = options.maxRetries ?? 2;
2373
- if (!Number.isInteger(maxRetries) || maxRetries < 0 || maxRetries > 3) {
2374
- throw new RangeError("retained screenshot maxRetries must be an integer from 0 to 3");
2375
- }
2376
3350
  const metadata = await this.getSessionRetainedArtifact(workspaceId, sessionId, artifactId);
2377
3351
  if (!metadata.available) return { metadata, bytes: null };
2378
3352
  if (metadata.kind !== "computer_screenshot" || metadata.contentType !== "image/png" || !metadata.dimensions || metadata.originalBytes <= 0 || metadata.originalBytes > COMPUTER_SCREENSHOT_MAX_BYTES) {
2379
3353
  throw new OpenGeniApiError(502, "retained screenshot metadata is invalid");
2380
3354
  }
2381
- const bytes = new Uint8Array(metadata.originalBytes);
2382
- const pageBytes = Math.min(metadata.retrieval.maxRangeBytes, RETAINED_OUTPUT_MAX_PAGE_BYTES);
3355
+ const bytes = await this.downloadRetainedArtifactBytes(metadata, options);
3356
+ return { metadata, bytes };
3357
+ }
3358
+ async downloadRetainedArtifactBytes(artifact, options) {
3359
+ const maxRetries = options.maxRetries ?? 2;
3360
+ if (!Number.isInteger(maxRetries) || maxRetries < 0 || maxRetries > 3) {
3361
+ throw new RangeError("retained artifact maxRetries must be an integer from 0 to 3");
3362
+ }
3363
+ const bytes = new Uint8Array(artifact.originalBytes);
3364
+ const pageBytes = Math.min(artifact.retrieval.maxRangeBytes, RETAINED_OUTPUT_MAX_PAGE_BYTES);
2383
3365
  if (!Number.isSafeInteger(pageBytes) || pageBytes <= 0) {
2384
- throw new OpenGeniApiError(502, "retained screenshot range metadata is invalid");
3366
+ throw new OpenGeniApiError(502, "retained artifact range metadata is invalid");
2385
3367
  }
2386
3368
  for (let start = 0; start < bytes.byteLength; start += pageBytes) {
2387
3369
  options.signal?.throwIfAborted();
@@ -2389,7 +3371,7 @@ var OpenGeniClient = class {
2389
3371
  let page = null;
2390
3372
  for (let attempt = 0; attempt <= maxRetries; attempt += 1) {
2391
3373
  try {
2392
- page = await this.getSessionRetainedArtifactContent(workspaceId, sessionId, artifactId, {
3374
+ page = await this.getRetainedArtifactContentAtPath(artifact.retrieval.path, {
2393
3375
  range: `bytes=${start}-${end}`,
2394
3376
  ...options.signal ? { signal: options.signal } : {}
2395
3377
  });
@@ -2401,17 +3383,17 @@ var OpenGeniClient = class {
2401
3383
  }
2402
3384
  }
2403
3385
  }
2404
- if (!page) throw new OpenGeniApiError(502, "retained screenshot range retry exhausted");
3386
+ if (!page) throw new OpenGeniApiError(502, "retained artifact range retry exhausted");
2405
3387
  const expectedLength = end - start + 1;
2406
- if (page.status !== 206 || page.contentType !== metadata.contentType || page.contentLength !== expectedLength || page.contentRange !== `bytes ${start}-${end}/${metadata.originalBytes}`) {
2407
- throw new OpenGeniApiError(502, "retained screenshot range response is invalid");
3388
+ if (page.status !== 206 || page.contentType !== artifact.contentType || page.contentLength !== expectedLength || page.contentRange !== `bytes ${start}-${end}/${artifact.originalBytes}`) {
3389
+ throw new OpenGeniApiError(502, "retained artifact range response is invalid");
2408
3390
  }
2409
3391
  bytes.set(page.bytes, start);
2410
3392
  }
2411
- if (await sha256Hex(bytes) !== metadata.sha256) {
2412
- throw new OpenGeniApiError(502, "retained screenshot checksum mismatch");
3393
+ if (await sha256Hex(bytes) !== artifact.sha256) {
3394
+ throw new OpenGeniApiError(502, "retained artifact checksum mismatch");
2413
3395
  }
2414
- return { metadata, bytes };
3396
+ return bytes;
2415
3397
  }
2416
3398
  async getRetainedArtifactContentAtPath(path, options) {
2417
3399
  if (options.range && (options.range.length > 128 || /[^\x20-\x7e]/.test(options.range))) {
@@ -2469,11 +3451,57 @@ var OpenGeniClient = class {
2469
3451
  };
2470
3452
  }
2471
3453
  /** Mint a short-lived signed download URL for a ready file. */
2472
- async createFileDownloadUrl(workspaceId, fileId) {
3454
+ async createFileDownloadUrl(workspaceId, fileId, options = {}) {
3455
+ return await this.requestJson(
3456
+ "POST",
3457
+ `/v1/workspaces/${workspaceId}/files/${fileId}/download-url`,
3458
+ void 0,
3459
+ {},
3460
+ options
3461
+ );
3462
+ }
3463
+ // --- Video generation ---------------------------------------------------------------
3464
+ /** Read the effective workspace policy and executable Seedance capabilities. */
3465
+ async getVideoGenerationSettings(workspaceId, options = {}) {
3466
+ return await this.requestJson(
3467
+ "GET",
3468
+ `/v1/workspaces/${workspaceId}/video-generation`,
3469
+ void 0,
3470
+ {},
3471
+ options
3472
+ );
3473
+ }
3474
+ /** Replace the enabled video models/default under optimistic policy revision control. */
3475
+ async updateVideoGenerationPolicy(workspaceId, request, options = {}) {
2473
3476
  return await this.requestJson(
3477
+ "PUT",
3478
+ `/v1/workspaces/${workspaceId}/video-generation/policy`,
3479
+ request,
3480
+ {},
3481
+ options
3482
+ );
3483
+ }
3484
+ /** Read durable progress for one accepted video generation operation. */
3485
+ async getVideoGenerationOperation(workspaceId, operationId, options = {}) {
3486
+ return await this.requestJson(
3487
+ "GET",
3488
+ `/v1/workspaces/${workspaceId}/video-generation/operations/${operationId}`,
3489
+ void 0,
3490
+ {},
3491
+ options
3492
+ );
3493
+ }
3494
+ /** Mint a short-lived zero-copy URL for native Range-based video playback. */
3495
+ async createVideoArtifactPlaybackSource(workspaceId, artifactId, options = {}) {
3496
+ const source = await this.requestJson(
2474
3497
  "POST",
2475
- `/v1/workspaces/${workspaceId}/files/${fileId}/download-url`
3498
+ `/v1/workspaces/${workspaceId}/artifacts/${artifactId}/playback-source`,
3499
+ void 0,
3500
+ {},
3501
+ options
2476
3502
  );
3503
+ assertSafeVideoArtifactPlaybackSource(source, artifactId);
3504
+ return source;
2477
3505
  }
2478
3506
  // --- Documents ----------------------------------------------------------------------
2479
3507
  async createDocumentBase(workspaceId, request) {
@@ -2550,153 +3578,382 @@ var OpenGeniClient = class {
2550
3578
  `/v1/workspaces/${workspaceId}/document-bases/${baseId}/documents/${documentId}`
2551
3579
  );
2552
3580
  }
2553
- async searchDocuments(workspaceId, baseId, request) {
3581
+ async searchDocuments(workspaceId, baseId, request) {
3582
+ return await this.requestJson(
3583
+ "POST",
3584
+ `/v1/workspaces/${workspaceId}/document-bases/${baseId}/search`,
3585
+ request
3586
+ );
3587
+ }
3588
+ async searchKnowledge(workspaceId, request) {
3589
+ return await this.requestJson(
3590
+ "POST",
3591
+ `/v1/workspaces/${workspaceId}/knowledge/search`,
3592
+ request
3593
+ );
3594
+ }
3595
+ async listKnowledgeMemories(workspaceId, request = {}) {
3596
+ const params = new URLSearchParams();
3597
+ if (request.query) params.set("query", request.query);
3598
+ if (request.status) params.set("status", request.status);
3599
+ if (request.kind) params.set("kind", request.kind);
3600
+ if (request.scope) params.set("scope", request.scope);
3601
+ if (request.limit) params.set("limit", String(request.limit));
3602
+ const query = params.toString();
3603
+ return await this.requestJson(
3604
+ "GET",
3605
+ `/v1/workspaces/${workspaceId}/knowledge/memories${query ? `?${query}` : ""}`
3606
+ );
3607
+ }
3608
+ async getKnowledgeMemory(workspaceId, memoryId) {
3609
+ return await this.requestJson(
3610
+ "GET",
3611
+ `/v1/workspaces/${workspaceId}/knowledge/memories/${memoryId}`
3612
+ );
3613
+ }
3614
+ async createKnowledgeMemory(workspaceId, request) {
3615
+ return await this.requestJson(
3616
+ "POST",
3617
+ `/v1/workspaces/${workspaceId}/knowledge/memories`,
3618
+ request
3619
+ );
3620
+ }
3621
+ async updateKnowledgeMemory(workspaceId, memoryId, request) {
3622
+ return await this.requestJson(
3623
+ "PATCH",
3624
+ `/v1/workspaces/${workspaceId}/knowledge/memories/${memoryId}`,
3625
+ request
3626
+ );
3627
+ }
3628
+ /** Hybrid (semantic + keyword) search over the workspace's agent-visible memory. */
3629
+ async searchWorkspaceMemories(workspaceId, request) {
3630
+ return await this.requestJson(
3631
+ "POST",
3632
+ `/v1/workspaces/${workspaceId}/knowledge/memories/search`,
3633
+ request
3634
+ );
3635
+ }
3636
+ /** Deep-merge a settings patch into the workspace (preserves unknown keys). */
3637
+ async updateWorkspaceSettings(workspaceId, request) {
3638
+ return await this.requestJson(
3639
+ "PATCH",
3640
+ `/v1/workspaces/${workspaceId}/settings`,
3641
+ request
3642
+ );
3643
+ }
3644
+ async setWorkspaceDefaultRig(workspaceId, request) {
3645
+ return await this.requestJson(
3646
+ "PUT",
3647
+ `/v1/workspaces/${workspaceId}/default-rig`,
3648
+ request
3649
+ );
3650
+ }
3651
+ // --- Capability packs ------------------------------------------------------------------
3652
+ /** Built-in + registered packs, with the workspace's installations. */
3653
+ async listPacks(workspaceId) {
3654
+ return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/packs`);
3655
+ }
3656
+ /** Register (or replace) a workspace-scoped pack from a manifest. */
3657
+ async registerPack(workspaceId, manifest) {
3658
+ return await this.requestJson(
3659
+ "POST",
3660
+ `/v1/workspaces/${workspaceId}/packs`,
3661
+ manifest
3662
+ );
3663
+ }
3664
+ async getPack(workspaceId, packId) {
3665
+ return await this.requestJson(
3666
+ "GET",
3667
+ `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}`
3668
+ );
3669
+ }
3670
+ async enablePack(workspaceId, packId, request = {}) {
3671
+ return await this.requestJson(
3672
+ "POST",
3673
+ `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}/enable`,
3674
+ request
3675
+ );
3676
+ }
3677
+ /** Resolve pinned components, Variable Set, and Rig requirements before installation. */
3678
+ async previewPackInstallation(workspaceId, packId, request = {}) {
3679
+ return await this.requestJson(
3680
+ "POST",
3681
+ `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}/installation-preview`,
3682
+ request
3683
+ );
3684
+ }
3685
+ /** Install, update, or repair a Pack from an exact previewed manifest. */
3686
+ async installPack(workspaceId, packId, request) {
3687
+ return await this.requestJson(
3688
+ "POST",
3689
+ `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}/install`,
3690
+ request
3691
+ );
3692
+ }
3693
+ /** Preview which Pack-owned components will be retained by other owners. */
3694
+ async previewPackUninstall(workspaceId, packId) {
3695
+ return await this.requestJson(
3696
+ "GET",
3697
+ `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}/uninstall-preview`
3698
+ );
3699
+ }
3700
+ /** Safely release Pack ownership and disable only now-ownerless components. */
3701
+ async uninstallPack(workspaceId, packId, request) {
3702
+ return await this.requestJson(
3703
+ "DELETE",
3704
+ `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}/installation`,
3705
+ request
3706
+ );
3707
+ }
3708
+ /** Unregister a workspace-scoped pack (built-in packs cannot be deleted). */
3709
+ async deletePack(workspaceId, packId) {
3710
+ await this.requestVoid(
3711
+ "DELETE",
3712
+ `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}`
3713
+ );
3714
+ }
3715
+ async listPackInstallations(workspaceId) {
3716
+ return await this.requestJson(
3717
+ "GET",
3718
+ `/v1/workspaces/${workspaceId}/packs/installations`
3719
+ );
3720
+ }
3721
+ // --- Capabilities -------------------------------------------------------------------------
3722
+ async listCapabilities(workspaceId) {
3723
+ return await this.requestJson(
3724
+ "GET",
3725
+ `/v1/workspaces/${workspaceId}/capabilities`
3726
+ );
3727
+ }
3728
+ /** Add a manual capability catalog item (e.g. a remote MCP server). */
3729
+ async createCapability(workspaceId, request) {
3730
+ return await this.requestJson(
3731
+ "POST",
3732
+ `/v1/workspaces/${workspaceId}/capabilities`,
3733
+ request
3734
+ );
3735
+ }
3736
+ async enableCapability(workspaceId, capabilityId, request = {}) {
3737
+ return await this.requestJson(
3738
+ "POST",
3739
+ `/v1/workspaces/${workspaceId}/capabilities/${encodeURIComponent(capabilityId)}/enable`,
3740
+ request
3741
+ );
3742
+ }
3743
+ async disableCapability(workspaceId, capabilityId) {
3744
+ return await this.requestJson(
3745
+ "POST",
3746
+ `/v1/workspaces/${workspaceId}/capabilities/${encodeURIComponent(capabilityId)}/disable`
3747
+ );
3748
+ }
3749
+ /** Search the official MCP registry for installable capabilities. */
3750
+ async discoverMcpCapabilities(workspaceId, options = {}) {
3751
+ return await this.requestJson(
3752
+ "GET",
3753
+ `/v1/workspaces/${workspaceId}/capabilities/discovery/mcp-registry`,
3754
+ void 0,
3755
+ {
3756
+ ...options.query !== void 0 ? { query: options.query } : {},
3757
+ ...options.limit !== void 0 ? { limit: String(options.limit) } : {}
3758
+ }
3759
+ );
3760
+ }
3761
+ /** List installed protocol-neutral OpenAPI and GraphQL Integrations. */
3762
+ async listApiIntegrations(workspaceId) {
3763
+ return await this.requestJson(
3764
+ "GET",
3765
+ `/v1/workspaces/${workspaceId}/integrations`
3766
+ );
3767
+ }
3768
+ /** List curated provider definitions without exposing deployment OAuth credentials. */
3769
+ async listIntegrationDefinitions(workspaceId) {
3770
+ return await this.requestJson(
3771
+ "GET",
3772
+ `/v1/workspaces/${workspaceId}/integrations/definitions`
3773
+ );
3774
+ }
3775
+ /** Detect and compile an Integration without mutating workspace state. */
3776
+ async previewApiIntegration(workspaceId, request) {
2554
3777
  return await this.requestJson(
2555
3778
  "POST",
2556
- `/v1/workspaces/${workspaceId}/document-bases/${baseId}/search`,
3779
+ `/v1/workspaces/${workspaceId}/integrations/preview`,
2557
3780
  request
2558
3781
  );
2559
3782
  }
2560
- async searchKnowledge(workspaceId, request) {
3783
+ /** Start a signed PKCE OAuth flow for a built-in Google or Microsoft definition. */
3784
+ async startApiIntegrationOAuth(workspaceId, request) {
2561
3785
  return await this.requestJson(
2562
3786
  "POST",
2563
- `/v1/workspaces/${workspaceId}/knowledge/search`,
3787
+ `/v1/workspaces/${workspaceId}/integrations/oauth/start`,
2564
3788
  request
2565
3789
  );
2566
3790
  }
2567
- async listKnowledgeMemories(workspaceId, request = {}) {
2568
- const params = new URLSearchParams();
2569
- if (request.query) params.set("query", request.query);
2570
- if (request.status) params.set("status", request.status);
2571
- if (request.kind) params.set("kind", request.kind);
2572
- if (request.scope) params.set("scope", request.scope);
2573
- if (request.limit) params.set("limit", String(request.limit));
2574
- const query = params.toString();
3791
+ /** Install only the exact immutable revision and digest accepted in preview. */
3792
+ async installApiIntegration(workspaceId, request) {
2575
3793
  return await this.requestJson(
2576
- "GET",
2577
- `/v1/workspaces/${workspaceId}/knowledge/memories${query ? `?${query}` : ""}`
3794
+ "POST",
3795
+ `/v1/workspaces/${workspaceId}/integrations/install`,
3796
+ request
2578
3797
  );
2579
3798
  }
2580
- async getKnowledgeMemory(workspaceId, memoryId) {
3799
+ async previewApiIntegrationUninstall(workspaceId, capabilityId, instanceKey) {
2581
3800
  return await this.requestJson(
2582
3801
  "GET",
2583
- `/v1/workspaces/${workspaceId}/knowledge/memories/${memoryId}`
3802
+ `/v1/workspaces/${workspaceId}/integrations/${encodeURIComponent(capabilityId)}/instances/${encodeURIComponent(instanceKey)}/uninstall-preview`
2584
3803
  );
2585
3804
  }
2586
- async createKnowledgeMemory(workspaceId, request) {
3805
+ /** Remove one Integration instance without deleting its Connection or sibling instances. */
3806
+ async uninstallApiIntegration(workspaceId, capabilityId, instanceKey, request) {
2587
3807
  return await this.requestJson(
2588
- "POST",
2589
- `/v1/workspaces/${workspaceId}/knowledge/memories`,
3808
+ "DELETE",
3809
+ `/v1/workspaces/${workspaceId}/integrations/${encodeURIComponent(capabilityId)}/instances/${encodeURIComponent(instanceKey)}`,
2590
3810
  request
2591
3811
  );
2592
3812
  }
2593
- async updateKnowledgeMemory(workspaceId, memoryId, request) {
3813
+ /** List immutable provider facets and their exact per-account bindings. */
3814
+ async listIntegrationFacets(workspaceId, capabilityId, instanceKey) {
2594
3815
  return await this.requestJson(
2595
- "PATCH",
2596
- `/v1/workspaces/${workspaceId}/knowledge/memories/${memoryId}`,
2597
- request
3816
+ "GET",
3817
+ `/v1/workspaces/${workspaceId}/integrations/${encodeURIComponent(capabilityId)}/instances/${encodeURIComponent(instanceKey)}/facets`
2598
3818
  );
2599
3819
  }
2600
- /** Hybrid (semantic + keyword) search over the workspace's agent-visible memory. */
2601
- async searchWorkspaceMemories(workspaceId, request) {
3820
+ /** Configure or OCC-update one adapter-owned facet on an Integration instance. */
3821
+ async configureIntegrationFacet(workspaceId, capabilityId, instanceKey, facetKey, request) {
2602
3822
  return await this.requestJson(
2603
- "POST",
2604
- `/v1/workspaces/${workspaceId}/knowledge/memories/search`,
3823
+ "PUT",
3824
+ `/v1/workspaces/${workspaceId}/integrations/${encodeURIComponent(capabilityId)}/instances/${encodeURIComponent(instanceKey)}/facets/${encodeURIComponent(facetKey)}`,
2605
3825
  request
2606
3826
  );
2607
3827
  }
2608
- /** Deep-merge a settings patch into the workspace (preserves unknown keys). */
2609
- async updateWorkspaceSettings(workspaceId, request) {
3828
+ /** Browse source metadata through one exact Google Drive Integration instance. */
3829
+ async browseGoogleDriveFacetSource(workspaceId, capabilityId, instanceKey, facetKey, options = {}) {
3830
+ const query = new URLSearchParams();
3831
+ if (options.parentId) query.set("parentId", options.parentId);
3832
+ if (options.pageToken) query.set("pageToken", options.pageToken);
3833
+ const suffix = query.size > 0 ? `?${query}` : "";
2610
3834
  return await this.requestJson(
2611
- "PATCH",
2612
- `/v1/workspaces/${workspaceId}/settings`,
2613
- request
3835
+ "GET",
3836
+ `/v1/workspaces/${workspaceId}/integrations/${encodeURIComponent(capabilityId)}/instances/${encodeURIComponent(instanceKey)}/facets/${encodeURIComponent(facetKey)}/browse${suffix}`
2614
3837
  );
2615
3838
  }
2616
- async setWorkspaceDefaultRig(workspaceId, request) {
3839
+ /** Verify and bind document sources to one exact Google Drive Integration instance. */
3840
+ async saveGoogleDriveFacetSource(workspaceId, capabilityId, instanceKey, facetKey, request) {
2617
3841
  return await this.requestJson(
2618
3842
  "PUT",
2619
- `/v1/workspaces/${workspaceId}/default-rig`,
3843
+ `/v1/workspaces/${workspaceId}/integrations/${encodeURIComponent(capabilityId)}/instances/${encodeURIComponent(instanceKey)}/facets/${encodeURIComponent(facetKey)}/source`,
2620
3844
  request
2621
3845
  );
2622
3846
  }
2623
- // --- Capability packs ------------------------------------------------------------------
2624
- /** Built-in + registered packs, with the workspace's installations. */
2625
- async listPacks(workspaceId) {
2626
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/packs`);
3847
+ async pauseIntegrationFacet(workspaceId, capabilityId, instanceKey, facetKey, request) {
3848
+ return await this.mutateIntegrationFacetLifecycle(
3849
+ workspaceId,
3850
+ capabilityId,
3851
+ instanceKey,
3852
+ facetKey,
3853
+ "pause",
3854
+ request
3855
+ );
2627
3856
  }
2628
- /** Register (or replace) a workspace-scoped pack from a manifest. */
2629
- async registerPack(workspaceId, manifest) {
2630
- return await this.requestJson(
2631
- "POST",
2632
- `/v1/workspaces/${workspaceId}/packs`,
2633
- manifest
3857
+ async resumeIntegrationFacet(workspaceId, capabilityId, instanceKey, facetKey, request) {
3858
+ return await this.mutateIntegrationFacetLifecycle(
3859
+ workspaceId,
3860
+ capabilityId,
3861
+ instanceKey,
3862
+ facetKey,
3863
+ "resume",
3864
+ request
2634
3865
  );
2635
3866
  }
2636
- async getPack(workspaceId, packId) {
3867
+ async removeIntegrationFacet(workspaceId, capabilityId, instanceKey, facetKey, request) {
2637
3868
  return await this.requestJson(
2638
- "GET",
2639
- `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}`
3869
+ "DELETE",
3870
+ `/v1/workspaces/${workspaceId}/integrations/${encodeURIComponent(capabilityId)}/instances/${encodeURIComponent(instanceKey)}/facets/${encodeURIComponent(facetKey)}`,
3871
+ request
2640
3872
  );
2641
3873
  }
2642
- async enablePack(workspaceId, packId, request = {}) {
3874
+ async mutateIntegrationFacetLifecycle(workspaceId, capabilityId, instanceKey, facetKey, action, request) {
2643
3875
  return await this.requestJson(
2644
3876
  "POST",
2645
- `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}/enable`,
3877
+ `/v1/workspaces/${workspaceId}/integrations/${encodeURIComponent(capabilityId)}/instances/${encodeURIComponent(instanceKey)}/facets/${encodeURIComponent(facetKey)}/${action}`,
2646
3878
  request
2647
3879
  );
2648
3880
  }
2649
- /** Unregister a workspace-scoped pack (built-in packs cannot be deleted). */
2650
- async deletePack(workspaceId, packId) {
2651
- await this.requestVoid(
2652
- "DELETE",
2653
- `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}`
3881
+ async previewPlugin(workspaceId, request) {
3882
+ return await this.requestJson(
3883
+ "POST",
3884
+ `/v1/workspaces/${workspaceId}/plugins/preview`,
3885
+ request
2654
3886
  );
2655
3887
  }
2656
- async listPackInstallations(workspaceId) {
3888
+ async listInstalledPlugins(workspaceId) {
2657
3889
  return await this.requestJson(
2658
3890
  "GET",
2659
- `/v1/workspaces/${workspaceId}/packs/installations`
3891
+ `/v1/workspaces/${workspaceId}/plugins`
2660
3892
  );
2661
3893
  }
2662
- // --- Capabilities -------------------------------------------------------------------------
2663
- async listCapabilities(workspaceId) {
3894
+ async installPlugin(workspaceId, request) {
3895
+ return await this.requestJson(
3896
+ "POST",
3897
+ `/v1/workspaces/${workspaceId}/plugins/install`,
3898
+ request
3899
+ );
3900
+ }
3901
+ async previewPluginUninstall(workspaceId, pluginKey) {
2664
3902
  return await this.requestJson(
2665
3903
  "GET",
2666
- `/v1/workspaces/${workspaceId}/capabilities`
3904
+ `/v1/workspaces/${workspaceId}/plugins/${encodeURIComponent(pluginKey)}/uninstall-preview`
2667
3905
  );
2668
3906
  }
2669
- /** Add a manual capability catalog item (e.g. a remote MCP server). */
2670
- async createCapability(workspaceId, request) {
3907
+ async uninstallPlugin(workspaceId, pluginKey, request) {
3908
+ return await this.requestJson(
3909
+ "DELETE",
3910
+ `/v1/workspaces/${workspaceId}/plugins/${encodeURIComponent(pluginKey)}`,
3911
+ request
3912
+ );
3913
+ }
3914
+ /** Resolve one public skills.sh or GitHub Skill folder to an immutable review preview. */
3915
+ async previewSkillImport(workspaceId, request) {
2671
3916
  return await this.requestJson(
2672
3917
  "POST",
2673
- `/v1/workspaces/${workspaceId}/capabilities`,
3918
+ `/v1/workspaces/${workspaceId}/skills/preview`,
2674
3919
  request
2675
3920
  );
2676
3921
  }
2677
- async enableCapability(workspaceId, capabilityId, request = {}) {
3922
+ /** Install only the exact commit and full-content digest accepted during preview. */
3923
+ async installSkill(workspaceId, request) {
2678
3924
  return await this.requestJson(
2679
3925
  "POST",
2680
- `/v1/workspaces/${workspaceId}/capabilities/${encodeURIComponent(capabilityId)}/enable`,
3926
+ `/v1/workspaces/${workspaceId}/skills/install`,
2681
3927
  request
2682
3928
  );
2683
3929
  }
2684
- async disableCapability(workspaceId, capabilityId) {
3930
+ /** List Skills from the authoritative Plugin/Skill-Facet installation ledger. */
3931
+ async listInstalledSkills(workspaceId) {
3932
+ return await this.requestJson(
3933
+ "GET",
3934
+ `/v1/workspaces/${workspaceId}/skills`
3935
+ );
3936
+ }
3937
+ /** Install one exact reviewed curated-library Skill through the Skill domain. */
3938
+ async installLibrarySkill(workspaceId, libraryId, request) {
2685
3939
  return await this.requestJson(
2686
3940
  "POST",
2687
- `/v1/workspaces/${workspaceId}/capabilities/${encodeURIComponent(capabilityId)}/disable`
3941
+ `/v1/workspaces/${workspaceId}/skills/library/${encodeURIComponent(libraryId)}/install`,
3942
+ request
2688
3943
  );
2689
3944
  }
2690
- /** Search the official MCP registry for installable capabilities. */
2691
- async discoverMcpCapabilities(workspaceId, options = {}) {
3945
+ async previewSkillUninstall(workspaceId, capabilityId) {
2692
3946
  return await this.requestJson(
2693
3947
  "GET",
2694
- `/v1/workspaces/${workspaceId}/capabilities/discovery/mcp-registry`,
2695
- void 0,
2696
- {
2697
- ...options.query !== void 0 ? { query: options.query } : {},
2698
- ...options.limit !== void 0 ? { limit: String(options.limit) } : {}
2699
- }
3948
+ `/v1/workspaces/${workspaceId}/skills/${encodeURIComponent(capabilityId)}/uninstall-preview`
3949
+ );
3950
+ }
3951
+ /** Remove the direct owner under an optimistic installation-version fence. */
3952
+ async uninstallSkill(workspaceId, capabilityId, request) {
3953
+ return await this.requestJson(
3954
+ "DELETE",
3955
+ `/v1/workspaces/${workspaceId}/skills/${encodeURIComponent(capabilityId)}`,
3956
+ request
2700
3957
  );
2701
3958
  }
2702
3959
  // --- Connections -------------------------------------------------------------------------------
@@ -2707,6 +3964,14 @@ var OpenGeniClient = class {
2707
3964
  );
2708
3965
  return response.connections;
2709
3966
  }
3967
+ /** List the secret-free Slack team -> OpenGeni tenant routing authority. */
3968
+ async listSlackInstallationBindings(workspaceId) {
3969
+ const response = await this.requestJson(
3970
+ "GET",
3971
+ `/v1/workspaces/${workspaceId}/connections/slack-bot/bindings`
3972
+ );
3973
+ return response.bindings;
3974
+ }
2710
3975
  async createConnection(workspaceId, request) {
2711
3976
  const response = await this.requestJson(
2712
3977
  "POST",
@@ -2715,6 +3980,26 @@ var OpenGeniClient = class {
2715
3980
  );
2716
3981
  return response.connection;
2717
3982
  }
3983
+ /**
3984
+ * Verify a pasted Fiken personal API token and store it as the
3985
+ * workspace-shared Fiken connection (or rewrite an existing one in place).
3986
+ */
3987
+ async installFikenConnection(workspaceId, request) {
3988
+ const response = await this.requestJson(
3989
+ "POST",
3990
+ `/v1/workspaces/${workspaceId}/connections/fiken/install`,
3991
+ request
3992
+ );
3993
+ return response.connection;
3994
+ }
3995
+ /** Start the Fiken OAuth flow for the workspace-shared Fiken connection. */
3996
+ async startFikenOAuth(workspaceId, request = {}) {
3997
+ return await this.requestJson(
3998
+ "POST",
3999
+ `/v1/workspaces/${workspaceId}/connections/fiken/oauth/start`,
4000
+ request
4001
+ );
4002
+ }
2718
4003
  /** Start the public Slack installation flow for the workspace-shared OpenGeni bot. */
2719
4004
  async startOpenGeniSlackBotInstall(workspaceId, request = {}) {
2720
4005
  return await this.requestJson(
@@ -2804,8 +4089,13 @@ var OpenGeniClient = class {
2804
4089
  }
2805
4090
  // --- GitHub ----------------------------------------------------------------------------------
2806
4091
  /** GitHub App server configuration plus truthful workspace binding status. */
2807
- async getGitHubApp(workspaceId) {
2808
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/github/app`);
4092
+ async getGitHubApp(workspaceId, options = {}) {
4093
+ return await this.requestJson(
4094
+ "GET",
4095
+ `/v1/workspaces/${workspaceId}/github/app`,
4096
+ void 0,
4097
+ options.returnPath ? { returnPath: options.returnPath } : void 0
4098
+ );
2809
4099
  }
2810
4100
  /** Build the GitHub owner-consent entry URL for fresh workspace-bound state. */
2811
4101
  githubConnectUrl(workspaceId, state) {
@@ -3035,6 +4325,65 @@ var OpenGeniClient = class {
3035
4325
  { target }
3036
4326
  );
3037
4327
  }
4328
+ // --- SuperGrok/xAI connected subscriptions ------------------------------------------------------
4329
+ async supergrokStatus(workspaceId) {
4330
+ return await this.requestJson(
4331
+ "GET",
4332
+ `/v1/workspaces/${workspaceId}/supergrok/status`
4333
+ );
4334
+ }
4335
+ async supergrokConnectStart(workspaceId, scope = "workspace") {
4336
+ return await this.requestJson(
4337
+ "POST",
4338
+ `/v1/workspaces/${workspaceId}/supergrok/connect/start`,
4339
+ { scope }
4340
+ );
4341
+ }
4342
+ async supergrokConnectPoll(workspaceId, state) {
4343
+ return await this.requestJson(
4344
+ "POST",
4345
+ `/v1/workspaces/${workspaceId}/supergrok/connect/poll`,
4346
+ { state }
4347
+ );
4348
+ }
4349
+ async listSuperGrokAccounts(workspaceId) {
4350
+ return await this.requestJson(
4351
+ "GET",
4352
+ `/v1/workspaces/${workspaceId}/supergrok/accounts`
4353
+ );
4354
+ }
4355
+ async activateSuperGrokAccount(workspaceId, accountId) {
4356
+ return await this.requestJson(
4357
+ "POST",
4358
+ `/v1/workspaces/${workspaceId}/supergrok/accounts/${accountId}/activate`,
4359
+ {}
4360
+ );
4361
+ }
4362
+ async setSuperGrokRotationSettings(workspaceId, patch) {
4363
+ return await this.requestJson(
4364
+ "PATCH",
4365
+ `/v1/workspaces/${workspaceId}/supergrok/settings`,
4366
+ patch
4367
+ );
4368
+ }
4369
+ async setSuperGrokAccountAllocator(workspaceId, accountId, input) {
4370
+ return await this.requestJson(
4371
+ "PATCH",
4372
+ `/v1/workspaces/${workspaceId}/supergrok/accounts/${accountId}/allocator`,
4373
+ input
4374
+ );
4375
+ }
4376
+ async renameSuperGrokAccount(workspaceId, accountId, label) {
4377
+ return await this.requestJson(
4378
+ "PATCH",
4379
+ `/v1/workspaces/${workspaceId}/supergrok/accounts/${accountId}`,
4380
+ { label }
4381
+ );
4382
+ }
4383
+ async disconnectSuperGrokAccount(workspaceId, accountId) {
4384
+ return await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/supergrok/accounts/${accountId}`, {});
4385
+ }
4386
+ /** Contract-checked JSON transport shared by opt-in typed SDK clients. */
3038
4387
  async requestJson(method, path, body, query = {}, options = {}) {
3039
4388
  const correlationId = crypto.randomUUID();
3040
4389
  let response;
@@ -3069,6 +4418,29 @@ var OpenGeniClient = class {
3069
4418
  throw error;
3070
4419
  }
3071
4420
  }
4421
+ /** Authenticated, contract-checked response for bounded streaming downloads. */
4422
+ async requestResponse(method, path, query = {}, options = {}) {
4423
+ const correlationId = crypto.randomUUID();
4424
+ let response;
4425
+ try {
4426
+ response = await this.fetchImpl(this.url(path, query), {
4427
+ method,
4428
+ headers: {
4429
+ ...this.headers(correlationId),
4430
+ Accept: "application/octet-stream"
4431
+ },
4432
+ ...options.signal ? { signal: options.signal } : {}
4433
+ });
4434
+ } catch (error) {
4435
+ if (isMutationMethod(method)) throw mutationTransportError(correlationId);
4436
+ throw error;
4437
+ }
4438
+ assertApiContractResponse(response);
4439
+ if (!response.ok) {
4440
+ throw await apiErrorFromResponse(response, { method, correlationId });
4441
+ }
4442
+ return response;
4443
+ }
3072
4444
  /** Like `requestJson` for endpoints that respond with no body (204). */
3073
4445
  async requestVoid(method, path, body) {
3074
4446
  const correlationId = crypto.randomUUID();
@@ -3224,6 +4596,31 @@ async function sha256Hex(bytes) {
3224
4596
  async function cancelResponseBody(response, reason) {
3225
4597
  await response.body?.cancel(reason).catch(() => void 0);
3226
4598
  }
4599
+ function assertRetainedGeneratedImageReceipt(workspaceId, artifact) {
4600
+ if (!parseRetainedGeneratedImageReference(artifact, workspaceId)) {
4601
+ throw new OpenGeniApiError(502, "retained generated image receipt is invalid");
4602
+ }
4603
+ }
4604
+ function assertSafeArtifactDownloadUrl(value) {
4605
+ if (!value || typeof value.url !== "string" || typeof value.expiresAt !== "string" || !Number.isFinite(Date.parse(value.expiresAt))) {
4606
+ throw new OpenGeniApiError(502, "retained artifact download URL is invalid");
4607
+ }
4608
+ let parsed;
4609
+ try {
4610
+ parsed = new URL(value.url);
4611
+ } catch {
4612
+ throw new OpenGeniApiError(502, "retained artifact download URL is invalid");
4613
+ }
4614
+ if (!["http:", "https:"].includes(parsed.protocol) || parsed.username || parsed.password) {
4615
+ throw new OpenGeniApiError(502, "retained artifact download URL is unsafe");
4616
+ }
4617
+ }
4618
+ function assertSafeVideoArtifactPlaybackSource(value, expectedArtifactId) {
4619
+ if (!value || value.schemaVersion !== 1 || value.artifactId !== expectedArtifactId || value.contentType !== "video/mp4" || value.acceptRanges !== "bytes" || !Number.isSafeInteger(value.sizeBytes) || value.sizeBytes <= 0 || value.sizeBytes > GENERATED_VIDEO_MAX_BYTES || !/^[0-9a-f]{64}$/.test(value.sha256)) {
4620
+ throw new OpenGeniApiError(502, "generated-video playback source is invalid");
4621
+ }
4622
+ assertSafeArtifactDownloadUrl({ url: value.url, expiresAt: value.expiresAt });
4623
+ }
3227
4624
  function parseBoundedContentLength(value) {
3228
4625
  if (value === null) return null;
3229
4626
  if (!/^\d+$/.test(value)) {
@@ -3271,246 +4668,19 @@ async function readBoundedResponseBytes(response, maxBytes, expectedBytes) {
3271
4668
  return bytes;
3272
4669
  }
3273
4670
 
3274
- // src/transcription.ts
3275
- var DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY = {
3276
- enabled: false,
3277
- acceptanceId: null,
3278
- primary: null,
3279
- language: null,
3280
- autoDetectLanguage: false,
3281
- diarization: { enabled: false, maxSpeakers: null },
3282
- retention: { mode: "none", maxDays: null },
3283
- privacy: { allowProviderLogging: false, allowProviderTraining: false },
3284
- fallback: { mode: "disabled", targets: [] },
3285
- cost: { currency: "USD", maxPerHour: null, maxPerMonth: null }
3286
- };
3287
- function resolveWorkspaceVoiceInputEnabled(settings) {
3288
- if (!isRecord(settings)) return null;
3289
- const voiceInput = settings.voiceInput;
3290
- if (isRecord(voiceInput) && typeof voiceInput.enabled === "boolean") {
3291
- return voiceInput.enabled;
3292
- }
3293
- const legacy = settings.transcription;
3294
- return isRecord(legacy) && typeof legacy.enabled === "boolean" ? legacy.enabled : null;
3295
- }
3296
- function resolveWorkspaceTranscriptionPolicy(settings) {
3297
- if (!isRecord(settings)) return cloneDefaultPolicy();
3298
- const candidate = settings.transcription;
3299
- if (!isWorkspaceTranscriptionPolicy(candidate)) return cloneDefaultPolicy();
3300
- return {
3301
- ...candidate,
3302
- primary: candidate.primary ? normalizeTarget(candidate.primary) : null,
3303
- language: candidate.language?.trim() ?? null,
3304
- diarization: { ...candidate.diarization },
3305
- retention: { ...candidate.retention },
3306
- privacy: { ...candidate.privacy },
3307
- fallback: {
3308
- mode: candidate.fallback.mode,
3309
- targets: candidate.fallback.targets.map(normalizeTarget)
3310
- },
3311
- cost: { ...candidate.cost }
3312
- };
3313
- }
3314
- function authorizeTranscriptionAdapter(policy, descriptor, selection = { kind: "primary" }) {
3315
- if (!isWorkspaceTranscriptionPolicy(policy)) {
3316
- return { authorized: false, reason: "unaccepted" };
3317
- }
3318
- if (!policy.enabled) return { authorized: false, reason: "disabled" };
3319
- if (!policy.acceptanceId) return { authorized: false, reason: "unaccepted" };
3320
- let target;
3321
- if (selection.kind === "primary") {
3322
- target = policy.primary;
3323
- } else {
3324
- if (policy.fallback.mode !== "explicit") {
3325
- return { authorized: false, reason: "fallback_disabled" };
3326
- }
3327
- target = policy.fallback.targets[selection.index];
3328
- if (!target) return { authorized: false, reason: "fallback_unaccepted" };
3329
- }
3330
- if (!target) return { authorized: false, reason: "target_missing" };
3331
- const acceptedTarget = normalizeTarget(target);
3332
- if (acceptedTarget.provider !== descriptor.provider) {
3333
- return { authorized: false, reason: "provider_mismatch" };
3334
- }
3335
- if (acceptedTarget.model !== descriptor.model) {
3336
- return { authorized: false, reason: "model_mismatch" };
3337
- }
3338
- if (acceptedTarget.credentialMode !== descriptor.credentialMode) {
3339
- return { authorized: false, reason: "credential_mode_mismatch" };
3340
- }
3341
- if (acceptedTarget.region !== descriptor.region) {
3342
- return { authorized: false, reason: "region_mismatch" };
3343
- }
3344
- return {
3345
- authorized: true,
3346
- acceptanceId: policy.acceptanceId,
3347
- target: acceptedTarget,
3348
- selection
3349
- };
3350
- }
3351
- function createTranscriptionSessionRequest(input) {
3352
- const sequenceFloor = input.sequenceFloor ?? 0;
3353
- if (!Number.isSafeInteger(sequenceFloor) || sequenceFloor < 0) return null;
3354
- const authorization = authorizeTranscriptionAdapter(
3355
- input.policy,
3356
- input.adapter.descriptor,
3357
- input.selection
3358
- );
3359
- if (!authorization.authorized) return null;
3360
- return {
3361
- localSessionId: input.localSessionId,
3362
- policyAcceptanceId: authorization.acceptanceId,
3363
- selection: authorization.selection,
3364
- target: { ...authorization.target },
3365
- language: input.policy.language?.trim() ?? null,
3366
- autoDetectLanguage: input.policy.autoDetectLanguage,
3367
- diarization: { ...input.policy.diarization },
3368
- retention: { ...input.policy.retention },
3369
- privacy: { ...input.policy.privacy },
3370
- cost: { ...input.policy.cost },
3371
- sequenceFloor
3372
- };
3373
- }
3374
- function cloneDefaultPolicy() {
3375
- return {
3376
- ...DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY,
3377
- diarization: { ...DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY.diarization },
3378
- retention: { ...DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY.retention },
3379
- privacy: { ...DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY.privacy },
3380
- fallback: { mode: "disabled", targets: [] },
3381
- cost: { ...DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY.cost }
3382
- };
3383
- }
3384
- function isWorkspaceTranscriptionPolicy(value) {
3385
- if (!isRecord(value) || typeof value.enabled !== "boolean") return false;
3386
- if (!hasOnlyKeys(value, [
3387
- "enabled",
3388
- "acceptanceId",
3389
- "primary",
3390
- "language",
3391
- "autoDetectLanguage",
3392
- "diarization",
3393
- "retention",
3394
- "privacy",
3395
- "fallback",
3396
- "cost"
3397
- ])) {
3398
- return false;
3399
- }
3400
- if (!(value.acceptanceId === null || isUuid(value.acceptanceId))) return false;
3401
- if (!(value.primary === null || isTarget(value.primary))) return false;
3402
- if (!(value.language === null || isBoundedString(value.language, 64))) return false;
3403
- if (typeof value.autoDetectLanguage !== "boolean") return false;
3404
- if (!isRecord(value.diarization) || !hasOnlyKeys(value.diarization, ["enabled", "maxSpeakers"]) || typeof value.diarization.enabled !== "boolean" || !(value.diarization.maxSpeakers === null || isBoundedInteger(value.diarization.maxSpeakers, 100) && value.diarization.maxSpeakers >= 2)) {
3405
- return false;
3406
- }
3407
- if (!value.diarization.enabled && value.diarization.maxSpeakers !== null) return false;
3408
- if (!isRecord(value.retention) || !hasOnlyKeys(value.retention, ["mode", "maxDays"])) {
3409
- return false;
3410
- }
3411
- if (value.retention.mode !== "none" && value.retention.mode !== "provider-policy") return false;
3412
- if (!(value.retention.maxDays === null || isBoundedInteger(value.retention.maxDays, 3650))) {
3413
- return false;
3414
- }
3415
- if (!isRecord(value.privacy) || !hasOnlyKeys(value.privacy, ["allowProviderLogging", "allowProviderTraining"]) || typeof value.privacy.allowProviderLogging !== "boolean" || typeof value.privacy.allowProviderTraining !== "boolean") {
3416
- return false;
3417
- }
3418
- if (!isRecord(value.fallback) || !hasOnlyKeys(value.fallback, ["mode", "targets"])) {
3419
- return false;
3420
- }
3421
- if (value.fallback.mode !== "disabled" && value.fallback.mode !== "explicit") return false;
3422
- if (!Array.isArray(value.fallback.targets) || value.fallback.targets.length > 8 || !value.fallback.targets.every(isTarget)) {
3423
- return false;
3424
- }
3425
- if (value.fallback.mode === "disabled" && value.fallback.targets.length !== 0) return false;
3426
- if (value.fallback.mode === "explicit" && value.fallback.targets.length === 0) return false;
3427
- if (!isRecord(value.cost) || !hasOnlyKeys(value.cost, ["currency", "maxPerHour", "maxPerMonth"]) || value.cost.currency !== "USD") {
3428
- return false;
3429
- }
3430
- if (!isNullableBoundedNumber(value.cost.maxPerHour, 1e4)) return false;
3431
- if (!isNullableBoundedNumber(value.cost.maxPerMonth, 1e6)) return false;
3432
- if (value.enabled && (!value.acceptanceId || !value.primary)) return false;
3433
- if (value.enabled && !value.autoDetectLanguage && value.language === null) return false;
3434
- if (value.autoDetectLanguage && value.language !== null) return false;
3435
- const targets = [value.primary, ...value.fallback.targets].filter(
3436
- (target) => target !== null
3437
- );
3438
- if (new Set(targets.map(targetKey)).size !== targets.length) return false;
3439
- return true;
3440
- }
3441
- function targetKey(target) {
3442
- return [
3443
- target.provider.trim(),
3444
- target.model?.trim() ?? "",
3445
- target.credentialMode,
3446
- target.credentialConnectionId ?? "",
3447
- target.region?.trim() ?? ""
3448
- ].join("\0");
3449
- }
3450
- function isTarget(value) {
3451
- if (!isRecord(value)) return false;
3452
- if (!hasOnlyKeys(value, ["provider", "model", "credentialMode", "credentialConnectionId", "region"])) {
3453
- return false;
3454
- }
3455
- if (!isBoundedString(value.provider, 128)) return false;
3456
- if (!(value.model === null || isBoundedString(value.model, 256))) return false;
3457
- if (value.credentialMode !== "managed" && value.credentialMode !== "byok") return false;
3458
- if (value.provider.trim() === "azure-speech" && value.credentialMode !== "byok") return false;
3459
- if (!(value.credentialConnectionId === null || isUuid(value.credentialConnectionId))) {
3460
- return false;
3461
- }
3462
- if (!(value.region === null || isBoundedString(value.region, 128))) return false;
3463
- if (value.credentialMode === "byok" && value.credentialConnectionId === null) return false;
3464
- if (value.credentialMode === "managed" && value.credentialConnectionId !== null) return false;
3465
- return true;
3466
- }
3467
- function normalizeTarget(target) {
3468
- return {
3469
- provider: target.provider.trim(),
3470
- model: target.model?.trim() ?? null,
3471
- credentialMode: target.credentialMode,
3472
- credentialConnectionId: target.credentialConnectionId,
3473
- region: target.region?.trim() ?? null
3474
- };
3475
- }
3476
- function isRecord(value) {
3477
- return typeof value === "object" && value !== null;
3478
- }
3479
- function hasOnlyKeys(value, keys) {
3480
- const accepted = new Set(keys);
3481
- return Object.keys(value).every((key) => accepted.has(key));
3482
- }
3483
- function isBoundedString(value, maximum) {
3484
- return typeof value === "string" && value.trim().length > 0 && value.length <= maximum;
3485
- }
3486
- function isUuid(value) {
3487
- return typeof value === "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(value);
3488
- }
3489
- function isBoundedInteger(value, maximum) {
3490
- return Number.isInteger(value) && value >= 0 && value <= maximum;
3491
- }
3492
- function isNullableBoundedNumber(value, maximum) {
3493
- return value === null || typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= maximum;
3494
- }
3495
-
3496
4671
  export {
3497
4672
  parseSseStream,
3498
4673
  streamSessionEvents,
3499
4674
  streamWorkspaceControlEvents,
3500
- DEFAULT_FILE_RESOURCE_MOUNT_ROOT,
3501
- SESSION_EVENT_TYPES,
3502
- KNOWN_PERMISSIONS,
3503
- OPENGENI_API_CONTRACT_REVISION,
3504
- OPENGENI_API_CONTRACT_HEADER,
3505
- OPENGENI_CORRELATION_HEADER,
3506
- RETAINED_OUTPUT_DEFAULT_PAGE_BYTES,
3507
- RETAINED_OUTPUT_MAX_PAGE_BYTES,
3508
- KNOWN_USAGE_EVENT_TYPES,
3509
- OpenGeniClient,
3510
- DEFAULT_WORKSPACE_TRANSCRIPTION_POLICY,
3511
- resolveWorkspaceVoiceInputEnabled,
3512
- resolveWorkspaceTranscriptionPolicy,
3513
- authorizeTranscriptionAdapter,
3514
- createTranscriptionSessionRequest
4675
+ streamWorkspaceInteractionRevisions,
4676
+ streamWorkspaceLiveEvents,
4677
+ parseWorkspaceLiveEvent,
4678
+ parseRetainedGeneratedImageReference,
4679
+ generatedImageSandboxPathMatches,
4680
+ parseGeneratedImageReceipt,
4681
+ parseRetainedGeneratedVideoReference,
4682
+ parseGeneratedVideoReceipt,
4683
+ parseMediaGenerationResult,
4684
+ OpenGeniClient
3515
4685
  };
3516
- //# sourceMappingURL=chunk-MBGBLVUV.js.map
4686
+ //# sourceMappingURL=chunk-PKQ377ED.js.map