@opengeni/sdk 0.11.0 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -105,7 +105,8 @@ async function* streamSessionEvents(transport, options = {}) {
105
105
  let failedAttempts = 0;
106
106
  let delayMs = baseDelayMs;
107
107
  let everConnected = false;
108
- while (!signal?.aborted) {
108
+ while (true) {
109
+ if (signal?.aborted) break;
109
110
  options.onStateChange?.(everConnected || failedAttempts > 0 ? "reconnecting" : "connecting");
110
111
  const cursorAtOpen = cursor;
111
112
  try {
@@ -219,23 +220,89 @@ var OpenGeniClient = class {
219
220
  }
220
221
  // --- Session lifecycle ---------------------------------------------------
221
222
  async createSession(workspaceId, request) {
222
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions`, request);
223
+ return await this.requestJson(
224
+ "POST",
225
+ `/v1/workspaces/${workspaceId}/sessions`,
226
+ request
227
+ );
223
228
  }
224
229
  async getSession(workspaceId, sessionId) {
225
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/sessions/${sessionId}`);
230
+ return await this.requestJson(
231
+ "GET",
232
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}`
233
+ );
226
234
  }
227
235
  async updateSession(workspaceId, sessionId, request) {
228
- return await this.requestJson("PATCH", `/v1/workspaces/${workspaceId}/sessions/${sessionId}`, request);
236
+ return await this.requestJson(
237
+ "PATCH",
238
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}`,
239
+ request
240
+ );
229
241
  }
230
242
  async listSessions(workspaceId, options = {}) {
231
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/sessions`, void 0, {
232
- ...options.limit !== void 0 ? { limit: String(options.limit) } : {}
233
- });
243
+ return await this.requestJson(
244
+ "GET",
245
+ `/v1/workspaces/${workspaceId}/sessions`,
246
+ void 0,
247
+ {
248
+ ...options.limit !== void 0 ? { limit: String(options.limit) } : {},
249
+ ...options.search?.trim() ? { search: options.search.trim() } : {},
250
+ ...Object.prototype.hasOwnProperty.call(options, "parentSessionId") && options.parentSessionId !== void 0 ? {
251
+ parentSessionId: options.parentSessionId === null ? "null" : String(options.parentSessionId)
252
+ } : {}
253
+ }
254
+ );
255
+ }
256
+ /** Pin-aware ordinary-session page with a stable keyset cursor. */
257
+ async listSessionPage(workspaceId, options = {}) {
258
+ const response = await this.requestJson(
259
+ "GET",
260
+ `/v1/workspaces/${workspaceId}/sessions`,
261
+ void 0,
262
+ {
263
+ view: "page",
264
+ ...options.limit !== void 0 ? { limit: String(options.limit) } : {},
265
+ ...options.cursor !== void 0 ? { cursor: options.cursor } : {},
266
+ ...options.search?.trim() ? { search: options.search.trim() } : {},
267
+ ...Object.prototype.hasOwnProperty.call(options, "parentSessionId") && options.parentSessionId !== void 0 ? {
268
+ parentSessionId: options.parentSessionId === null ? "null" : String(options.parentSessionId)
269
+ } : {}
270
+ }
271
+ );
272
+ if (Array.isArray(response)) {
273
+ if (options.cursor) {
274
+ throw new Error("The connected OpenGeni API does not support stable session-page cursors");
275
+ }
276
+ if (options.search?.trim()) {
277
+ throw new Error("The connected OpenGeni API does not support session search");
278
+ }
279
+ return { pinned: [], sessions: response, nextCursor: null };
280
+ }
281
+ return response;
282
+ }
283
+ /** Set this authenticated member's personal workspace pin for a session. */
284
+ async updateSessionPin(workspaceId, sessionId, request) {
285
+ return await this.requestJson(
286
+ "PUT",
287
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/pin`,
288
+ request
289
+ );
290
+ }
291
+ async getSessionLineage(workspaceId, sessionId) {
292
+ return await this.requestJson(
293
+ "GET",
294
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/lineage`
295
+ );
234
296
  }
235
297
  async listTurns(workspaceId, sessionId, options = {}) {
236
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/turns`, void 0, {
237
- ...options.limit !== void 0 ? { limit: String(options.limit) } : {}
238
- });
298
+ return await this.requestJson(
299
+ "GET",
300
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/turns`,
301
+ void 0,
302
+ {
303
+ ...options.limit !== void 0 ? { limit: String(options.limit) } : {}
304
+ }
305
+ );
239
306
  }
240
307
  // --- Bring-your-own-compute: Machines dashboard + metrics (M10) ------------
241
308
  /**
@@ -245,9 +312,14 @@ var OpenGeniClient = class {
245
312
  * session's synthetic Modal group box + the active-sandbox pointer.
246
313
  */
247
314
  async listMachines(workspaceId, options = {}) {
248
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/machines`, void 0, {
249
- ...options.sessionId !== void 0 ? { sessionId: options.sessionId } : {}
250
- });
315
+ return await this.requestJson(
316
+ "GET",
317
+ `/v1/workspaces/${workspaceId}/machines`,
318
+ void 0,
319
+ {
320
+ ...options.sessionId !== void 0 ? { sessionId: options.sessionId } : {}
321
+ }
322
+ );
251
323
  }
252
324
  /**
253
325
  * Read the downsampled (~1/min) metrics series for ONE machine over a time
@@ -273,7 +345,11 @@ var OpenGeniClient = class {
273
345
  * the request.
274
346
  */
275
347
  async lookupDeviceEnrollment(userCode) {
276
- return await this.requestJson("POST", "/v1/enrollments/device/lookup", { userCode });
348
+ return await this.requestJson(
349
+ "POST",
350
+ "/v1/enrollments/device/lookup",
351
+ { userCode }
352
+ );
277
353
  }
278
354
  /**
279
355
  * Approve a pending device-enrollment flow (the LOUD consent step). `allowScreenControl`
@@ -325,12 +401,20 @@ var OpenGeniClient = class {
325
401
  }
326
402
  // --- Scheduled tasks -------------------------------------------------------
327
403
  async listScheduledTasks(workspaceId, options = {}) {
328
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/scheduled-tasks`, void 0, {
329
- ...options.limit !== void 0 ? { limit: String(options.limit) } : {}
330
- });
404
+ return await this.requestJson(
405
+ "GET",
406
+ `/v1/workspaces/${workspaceId}/scheduled-tasks`,
407
+ void 0,
408
+ {
409
+ ...options.limit !== void 0 ? { limit: String(options.limit) } : {}
410
+ }
411
+ );
331
412
  }
332
413
  async getScheduledTask(workspaceId, taskId) {
333
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}`);
414
+ return await this.requestJson(
415
+ "GET",
416
+ `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}`
417
+ );
334
418
  }
335
419
  // --- Events: replay, send, stream ----------------------------------------
336
420
  /**
@@ -340,16 +424,25 @@ var OpenGeniClient = class {
340
424
  * for resume cursors.
341
425
  */
342
426
  async listEvents(workspaceId, sessionId, options = {}) {
343
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/events`, void 0, {
344
- ...options.after !== void 0 ? { after: String(options.after) } : {},
345
- ...options.before !== void 0 ? { before: String(options.before) } : {},
346
- ...options.limit !== void 0 ? { limit: String(options.limit) } : {},
347
- ...options.compact ? { compact: "1" } : {}
348
- });
427
+ return await this.requestJson(
428
+ "GET",
429
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/events`,
430
+ void 0,
431
+ {
432
+ ...options.after !== void 0 ? { after: String(options.after) } : {},
433
+ ...options.before !== void 0 ? { before: String(options.before) } : {},
434
+ ...options.limit !== void 0 ? { limit: String(options.limit) } : {},
435
+ ...options.compact ? { compact: "1" } : {}
436
+ }
437
+ );
349
438
  }
350
439
  /** POST a user/control event to the session. Returns the accepted event. */
351
440
  async sendEvent(workspaceId, sessionId, event) {
352
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/events`, event);
441
+ return await this.requestJson(
442
+ "POST",
443
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/events`,
444
+ event
445
+ );
353
446
  }
354
447
  async sendMessage(workspaceId, sessionId, message) {
355
448
  const input = typeof message === "string" ? { text: message } : message;
@@ -360,12 +453,11 @@ var OpenGeniClient = class {
360
453
  payload
361
454
  });
362
455
  }
363
- async interrupt(workspaceId, sessionId, options = {}) {
364
- return await this.sendEvent(workspaceId, sessionId, {
365
- type: "user.interrupt",
366
- ...options.clientEventId !== void 0 ? { clientEventId: options.clientEventId } : {},
367
- payload: options.reason !== void 0 ? { reason: options.reason } : {}
368
- });
456
+ async pauseSession(workspaceId, sessionId, options = {}) {
457
+ return (await this.controlSession(workspaceId, sessionId, {
458
+ mode: "pause",
459
+ ...options
460
+ })).event;
369
461
  }
370
462
  async sendApprovalDecision(workspaceId, sessionId, decision) {
371
463
  const { clientEventId, ...payload } = decision;
@@ -386,7 +478,10 @@ var OpenGeniClient = class {
386
478
  /** The transport `streamEvents` runs on; useful for custom streaming layers. */
387
479
  eventStreamTransport(workspaceId, sessionId) {
388
480
  return {
389
- openStream: async (after, signal) => await this.openEventStream(workspaceId, sessionId, { after, ...signal ? { signal } : {} }),
481
+ openStream: async (after, signal) => await this.openEventStream(workspaceId, sessionId, {
482
+ after,
483
+ ...signal ? { signal } : {}
484
+ }),
390
485
  listEvents: async (after, limit) => await this.listEvents(workspaceId, sessionId, { after, limit })
391
486
  };
392
487
  }
@@ -409,23 +504,34 @@ var OpenGeniClient = class {
409
504
  return response.body;
410
505
  }
411
506
  // --- Turn queue ------------------------------------------------------------
412
- /** Edit a still-queued turn (prompt, model, resources, tools, ...). */
413
- async updateQueuedTurn(workspaceId, sessionId, turnId, update) {
507
+ async getQueue(workspaceId, sessionId) {
414
508
  return await this.requestJson(
415
- "PATCH",
416
- `/v1/workspaces/${workspaceId}/sessions/${sessionId}/turns/${turnId}`,
417
- update
509
+ "GET",
510
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/queue`
418
511
  );
419
512
  }
420
- /**
421
- * Reorder the queued turns. `turnIds` must all reference queued turns; the
422
- * server assigns positions in the given order and returns the queue.
423
- */
424
- async reorderQueuedTurns(workspaceId, sessionId, turnIds) {
513
+ async cancelQueueItem(workspaceId, sessionId, turnId, request) {
514
+ return await this.requestJson(
515
+ "POST",
516
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/queue/${turnId}/cancel`,
517
+ request
518
+ );
519
+ }
520
+ async controlSession(workspaceId, sessionId, request) {
521
+ return await this.requestJson(
522
+ "POST",
523
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/control`,
524
+ request
525
+ );
526
+ }
527
+ async resumeSession(workspaceId, sessionId, options = {}) {
528
+ return await this.controlSession(workspaceId, sessionId, { mode: "resume", ...options });
529
+ }
530
+ async setWorkspaceInferenceState(workspaceId, request) {
425
531
  return await this.requestJson(
426
532
  "POST",
427
- `/v1/workspaces/${workspaceId}/sessions/${sessionId}/turns/reorder`,
428
- { turnIds }
533
+ `/v1/workspaces/${workspaceId}/inference-control`,
534
+ request
429
535
  );
430
536
  }
431
537
  /** Cancel a queued turn before it is claimed. Returns the cancelled turn. */
@@ -436,60 +542,34 @@ var OpenGeniClient = class {
436
542
  );
437
543
  }
438
544
  /**
439
- * Steer: deliver a message *now* instead of behind the queue. Sends the
440
- * message, promotes its queued turn to the front, and interrupts the
441
- * running turn so the session picks the steer turn up next. On a session
442
- * that is not running this degrades gracefully to a plain queued message.
443
- *
444
- * The steer turn is located by `triggerEventId` across ALL turns (retried
445
- * briefly in case the server is still materializing it) — not just the
446
- * queued ones, because the worker can claim the steer turn before it is
447
- * ever observed queued, and a claimed steer turn means the message is
448
- * already being delivered: interrupting then would cancel the very message
449
- * being steered. If the turn cannot be found while other turns are queued,
450
- * the interrupt is also skipped — stopping the running turn would otherwise
451
- * promote someone else's queued work over this message — and the call
452
- * degrades to a plain queued send (`interrupted: false`).
545
+ * Steer: atomically put this prompt at the head and supersede the current
546
+ * inference. The client performs one request and renders server order.
453
547
  */
454
548
  async steerMessage(workspaceId, sessionId, message) {
455
- const accepted = await this.sendMessage(workspaceId, sessionId, message);
456
- let steerTurn = null;
457
- let queued = [];
458
- for (let attempt = 0; attempt < 4; attempt += 1) {
459
- if (attempt > 0) {
460
- await delay(150 * attempt);
461
- }
462
- const turns = await this.listTurns(workspaceId, sessionId);
463
- queued = turns.filter((turn) => turn.status === "queued").sort((a, b) => a.position - b.position || a.createdAt.localeCompare(b.createdAt));
464
- steerTurn = turns.find((turn) => turn.triggerEventId === accepted.id) ?? null;
465
- if (steerTurn) {
466
- break;
467
- }
468
- }
469
- const steerTurnQueued = steerTurn?.status === "queued";
470
- if (steerTurn && steerTurnQueued && queued.length > 1) {
471
- const front = steerTurn;
472
- await this.reorderQueuedTurns(workspaceId, sessionId, [
473
- front.id,
474
- ...queued.filter((turn) => turn.id !== front.id).map((turn) => turn.id)
475
- ]);
476
- }
477
- const canDeliverNext = steerTurnQueued || steerTurn === null && queued.length === 0;
478
- const session = await this.getSession(workspaceId, sessionId);
479
- const steerTurnAlreadyActive = steerTurn !== null && session.activeTurnId === steerTurn.id;
480
- const interrupted = canDeliverNext && !steerTurnAlreadyActive && (session.status === "running" || session.status === "requires_action");
481
- if (interrupted) {
482
- await this.interrupt(workspaceId, sessionId, { reason: "steer" });
483
- }
484
- return { accepted, turn: steerTurn, interrupted };
549
+ const input = typeof message === "string" ? { text: message } : message;
550
+ return await this.requestJson(
551
+ "POST",
552
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/steer`,
553
+ input
554
+ );
485
555
  }
486
556
  // --- Goals -------------------------------------------------------------------
487
557
  /** The session's goal. 404s when the session never had one. */
488
558
  async getGoal(workspaceId, sessionId) {
489
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/goal`);
559
+ return await this.requestJson(
560
+ "GET",
561
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/goal`
562
+ );
490
563
  }
491
564
  async updateGoal(workspaceId, sessionId, request) {
492
- return await this.requestJson("PATCH", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/goal`, request);
565
+ return await this.requestJson(
566
+ "PATCH",
567
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/goal`,
568
+ request
569
+ );
570
+ }
571
+ async deleteGoal(workspaceId, sessionId) {
572
+ await this.requestVoid("DELETE", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/goal`);
493
573
  }
494
574
  /** Pause the goal loop: the session stops self-continuing until resumed. */
495
575
  async pauseGoal(workspaceId, sessionId, options = {}) {
@@ -511,16 +591,19 @@ var OpenGeniClient = class {
511
591
  * context — the destructive intent is explicit on the wire.
512
592
  */
513
593
  async clearSessionContext(workspaceId, sessionId) {
514
- await this.requestVoid("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/context/clear`, { confirm: true });
594
+ await this.requestVoid(
595
+ "POST",
596
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/context/clear`,
597
+ { confirm: true }
598
+ );
515
599
  }
516
- /**
517
- * Trigger conversation compaction now. On the client-managed (Azure) path this
518
- * queues a forced compaction the worker honors before the next turn
519
- * (`status:"queued"`); on a server-managed provider or when compaction is off
520
- * it is a no-op (`status:"noop"`) with an explanatory message.
521
- */
600
+ /** Request one durable portable compaction at the next safe model boundary. */
522
601
  async compactSessionContext(workspaceId, sessionId) {
523
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/context/compact`, {});
602
+ return await this.requestJson(
603
+ "POST",
604
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/context/compact`,
605
+ {}
606
+ );
524
607
  }
525
608
  // --- Channel-A structured services (P4.4) ------------------------------------
526
609
  // FileSystem (Pierre tree), Git (Pierre diff), Terminal (exec + PTY). Each is a
@@ -528,64 +611,147 @@ var OpenGeniClient = class {
528
611
  // notifications + the PTY output stream arrive on the existing event SSE.
529
612
  /** FileSystem: list a directory tree (feeds the Pierre file tree). */
530
613
  async fsList(workspaceId, sessionId, request = {}) {
531
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/list`, request);
614
+ return await this.requestJson(
615
+ "POST",
616
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/list`,
617
+ request
618
+ );
532
619
  }
533
620
  /** FileSystem: read a file (text or base64; binary-safe, size-capped). */
534
621
  async fsRead(workspaceId, sessionId, request) {
535
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/read`, request);
622
+ return await this.requestJson(
623
+ "POST",
624
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/read`,
625
+ request
626
+ );
536
627
  }
537
628
  /** FileSystem: write a file (last-writer-wins; emits fs.changed). */
538
629
  async fsWrite(workspaceId, sessionId, request) {
539
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/write`, request);
630
+ return await this.requestJson(
631
+ "POST",
632
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/write`,
633
+ request
634
+ );
540
635
  }
541
636
  /** FileSystem: delete a path (emits fs.changed). */
542
637
  async fsDelete(workspaceId, sessionId, request) {
543
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/delete`, request);
638
+ return await this.requestJson(
639
+ "POST",
640
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/delete`,
641
+ request
642
+ );
544
643
  }
545
644
  /** FileSystem: move/rename a path (emits fs.changed; 409 if destination exists and overwrite is false). */
546
645
  async fsMove(workspaceId, sessionId, request) {
547
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/move`, request);
646
+ return await this.requestJson(
647
+ "POST",
648
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/move`,
649
+ request
650
+ );
548
651
  }
549
652
  /** FileSystem: create a directory (emits fs.changed; recursive defaults to true). */
550
653
  async fsMkdir(workspaceId, sessionId, request) {
551
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/mkdir`, request);
654
+ return await this.requestJson(
655
+ "POST",
656
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/fs/mkdir`,
657
+ request
658
+ );
552
659
  }
553
660
  /** Git: working-tree/index status (the Pierre file-status feed). */
554
661
  async gitStatus(workspaceId, sessionId, request = {}) {
555
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/git/status`, request);
662
+ return await this.requestJson(
663
+ "POST",
664
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/git/status`,
665
+ request
666
+ );
556
667
  }
557
668
  /** Git: structured diff hunks (the Pierre diff feed). */
558
669
  async gitDiff(workspaceId, sessionId, request = {}) {
559
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/git/diff`, request);
670
+ return await this.requestJson(
671
+ "POST",
672
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/git/diff`,
673
+ request
674
+ );
560
675
  }
561
676
  /** Git: commit log. */
562
677
  async gitLog(workspaceId, sessionId, request = {}) {
563
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/git/log`, request);
678
+ return await this.requestJson(
679
+ "POST",
680
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/git/log`,
681
+ request
682
+ );
564
683
  }
565
684
  /** Git: show a commit (diff vs first parent) or fetch a raw blob at a ref. */
566
685
  async gitShow(workspaceId, sessionId, request) {
567
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/git/show`, request);
686
+ return await this.requestJson(
687
+ "POST",
688
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/git/show`,
689
+ request
690
+ );
691
+ }
692
+ /** Workspace capture: the latest turn-end snapshot of the session's workspace
693
+ * (tree + per-repo diff + file after-image refs), served from durable storage
694
+ * WITHOUT warming a machine — the workbench cold-paint source. Returns
695
+ * `{available:false}` when no capture exists yet (fall back to the live path). */
696
+ async getWorkspaceCapture(workspaceId, sessionId) {
697
+ return await this.requestJson(
698
+ "GET",
699
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/workspace/capture`
700
+ );
701
+ }
702
+ /** Workspace capture: a single file's after-image from the capture (revision
703
+ * pins a specific one; omitted → latest). Content is inline for small files,
704
+ * else a short-TTL signed URL; a tooLarge file returns metadata only. */
705
+ async getWorkspaceCaptureFile(workspaceId, sessionId, path, revision) {
706
+ const query = { path };
707
+ if (revision !== void 0) query.revision = String(revision);
708
+ return await this.requestJson(
709
+ "GET",
710
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/workspace/capture/file`,
711
+ void 0,
712
+ query
713
+ );
568
714
  }
569
715
  /** Terminal: run a bounded command, returning buffered stdout/stderr inline. */
570
716
  async terminalExec(workspaceId, sessionId, request) {
571
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/exec`, request);
717
+ return await this.requestJson(
718
+ "POST",
719
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/exec`,
720
+ request
721
+ );
572
722
  }
573
723
  /** Terminal: open an interactive PTY. Output streams on the event SSE as
574
724
  * terminal.pty.output.delta; drive it with terminalPtyWrite. */
575
725
  async terminalPtyOpen(workspaceId, sessionId, request = {}) {
576
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/pty`, request);
726
+ return await this.requestJson(
727
+ "POST",
728
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/pty`,
729
+ request
730
+ );
577
731
  }
578
732
  /** Terminal: send stdin to an open PTY (output rides A1). */
579
733
  async terminalPtyWrite(workspaceId, sessionId, request) {
580
- await this.requestVoid("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/pty/write`, request);
734
+ await this.requestVoid(
735
+ "POST",
736
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/pty/write`,
737
+ request
738
+ );
581
739
  }
582
740
  /** Terminal: resize an open PTY. */
583
741
  async terminalPtyResize(workspaceId, sessionId, request) {
584
- await this.requestVoid("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/pty/resize`, request);
742
+ await this.requestVoid(
743
+ "POST",
744
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/pty/resize`,
745
+ request
746
+ );
585
747
  }
586
748
  /** Terminal: close an open PTY (idempotent). */
587
749
  async terminalPtyClose(workspaceId, sessionId, request) {
588
- await this.requestVoid("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/pty/close`, request);
750
+ await this.requestVoid(
751
+ "POST",
752
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/terminal/pty/close`,
753
+ request
754
+ );
589
755
  }
590
756
  // --- Stream surfacing: capability negotiation + viewer lifecycle (Phase 5) ---
591
757
  // The capability doc is the single source of UI truth (degradation is always a
@@ -641,7 +807,10 @@ var OpenGeniClient = class {
641
807
  }
642
808
  /** Detach a viewer (delete this holder; idempotent delete-my-row). */
643
809
  async detachViewer(workspaceId, sessionId, viewerId) {
644
- await this.requestVoid("DELETE", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/viewers/${viewerId}`);
810
+ await this.requestVoid(
811
+ "DELETE",
812
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/viewers/${viewerId}`
813
+ );
645
814
  }
646
815
  // --- Access + workspaces -----------------------------------------------------
647
816
  /**
@@ -680,7 +849,10 @@ var OpenGeniClient = class {
680
849
  // --- Members ("People with access") -------------------------------------------
681
850
  /** The workspace's members (user + api_key subjects). */
682
851
  async listWorkspaceMembers(workspaceId) {
683
- const response = await this.requestJson("GET", `/v1/workspaces/${workspaceId}/members`);
852
+ const response = await this.requestJson(
853
+ "GET",
854
+ `/v1/workspaces/${workspaceId}/members`
855
+ );
684
856
  return response.members;
685
857
  }
686
858
  /**
@@ -688,7 +860,11 @@ var OpenGeniClient = class {
688
860
  * exists (email invites for unknown users are deferred).
689
861
  */
690
862
  async addWorkspaceMember(workspaceId, request) {
691
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/members`, request);
863
+ return await this.requestJson(
864
+ "POST",
865
+ `/v1/workspaces/${workspaceId}/members`,
866
+ request
867
+ );
692
868
  }
693
869
  async updateWorkspaceMember(workspaceId, subjectId, request) {
694
870
  return await this.requestJson(
@@ -702,20 +878,37 @@ var OpenGeniClient = class {
702
878
  * member who can still manage the workspace.
703
879
  */
704
880
  async removeWorkspaceMember(workspaceId, subjectId) {
705
- await this.requestVoid("DELETE", `/v1/workspaces/${workspaceId}/members/${encodeURIComponent(subjectId)}`);
881
+ await this.requestVoid(
882
+ "DELETE",
883
+ `/v1/workspaces/${workspaceId}/members/${encodeURIComponent(subjectId)}`
884
+ );
706
885
  }
707
886
  // --- Scheduled tasks (write + runs) -------------------------------------------
708
887
  async createScheduledTask(workspaceId, request) {
709
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/scheduled-tasks`, request);
888
+ return await this.requestJson(
889
+ "POST",
890
+ `/v1/workspaces/${workspaceId}/scheduled-tasks`,
891
+ request
892
+ );
710
893
  }
711
894
  async updateScheduledTask(workspaceId, taskId, request) {
712
- return await this.requestJson("PATCH", `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}`, request);
895
+ return await this.requestJson(
896
+ "PATCH",
897
+ `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}`,
898
+ request
899
+ );
713
900
  }
714
901
  async pauseScheduledTask(workspaceId, taskId) {
715
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}/pause`);
902
+ return await this.requestJson(
903
+ "POST",
904
+ `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}/pause`
905
+ );
716
906
  }
717
907
  async resumeScheduledTask(workspaceId, taskId) {
718
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}/resume`);
908
+ return await this.requestJson(
909
+ "POST",
910
+ `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}/resume`
911
+ );
719
912
  }
720
913
  /**
721
914
  * Fire the task immediately (manual trigger), independent of its schedule.
@@ -730,7 +923,10 @@ var OpenGeniClient = class {
730
923
  );
731
924
  }
732
925
  async deleteScheduledTask(workspaceId, taskId) {
733
- await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}`);
926
+ await this.requestJson(
927
+ "DELETE",
928
+ `/v1/workspaces/${workspaceId}/scheduled-tasks/${taskId}`
929
+ );
734
930
  }
735
931
  async listScheduledTaskRuns(workspaceId, taskId, options = {}) {
736
932
  return await this.requestJson(
@@ -740,45 +936,178 @@ var OpenGeniClient = class {
740
936
  { ...options.limit !== void 0 ? { limit: String(options.limit) } : {} }
741
937
  );
742
938
  }
743
- // --- Environments --------------------------------------------------------------
939
+ // --- VariableSets --------------------------------------------------------------
744
940
  // Variable values are write-only: reads return name/version metadata only.
745
- async listEnvironments(workspaceId) {
746
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/environments`);
941
+ async listVariableSets(workspaceId) {
942
+ return await this.requestJson(
943
+ "GET",
944
+ `/v1/workspaces/${workspaceId}/variable-sets`
945
+ );
747
946
  }
748
- async createEnvironment(workspaceId, request) {
749
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/environments`, request);
947
+ async createVariableSet(workspaceId, request) {
948
+ return await this.requestJson(
949
+ "POST",
950
+ `/v1/workspaces/${workspaceId}/variable-sets`,
951
+ request
952
+ );
750
953
  }
751
- async getEnvironment(workspaceId, environmentId) {
752
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/environments/${environmentId}`);
954
+ async getVariableSet(workspaceId, variableSetId) {
955
+ return await this.requestJson(
956
+ "GET",
957
+ `/v1/workspaces/${workspaceId}/variable-sets/${variableSetId}`
958
+ );
753
959
  }
754
- async updateEnvironment(workspaceId, environmentId, request) {
960
+ async updateVariableSet(workspaceId, variableSetId, request) {
755
961
  return await this.requestJson(
756
962
  "PATCH",
757
- `/v1/workspaces/${workspaceId}/environments/${environmentId}`,
963
+ `/v1/workspaces/${workspaceId}/variable-sets/${variableSetId}`,
758
964
  request
759
965
  );
760
966
  }
761
- async deleteEnvironment(workspaceId, environmentId) {
762
- await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/environments/${environmentId}`);
967
+ async deleteVariableSet(workspaceId, variableSetId) {
968
+ await this.requestJson(
969
+ "DELETE",
970
+ `/v1/workspaces/${workspaceId}/variable-sets/${variableSetId}`
971
+ );
763
972
  }
764
973
  /** Create or rotate a variable. The value never comes back on any read. */
765
- async setEnvironmentVariable(workspaceId, environmentId, name, value) {
974
+ async setVariableSetVariable(workspaceId, variableSetId, name, value) {
766
975
  return await this.requestJson(
767
976
  "PUT",
768
- `/v1/workspaces/${workspaceId}/environments/${environmentId}/variables/${encodeURIComponent(name)}`,
977
+ `/v1/workspaces/${workspaceId}/variable-sets/${variableSetId}/variables/${encodeURIComponent(name)}`,
769
978
  { value }
770
979
  );
771
980
  }
772
- async deleteEnvironmentVariable(workspaceId, environmentId, name) {
981
+ async deleteVariableSetVariable(workspaceId, variableSetId, name) {
773
982
  await this.requestJson(
774
983
  "DELETE",
775
- `/v1/workspaces/${workspaceId}/environments/${environmentId}/variables/${encodeURIComponent(name)}`
984
+ `/v1/workspaces/${workspaceId}/variable-sets/${variableSetId}/variables/${encodeURIComponent(name)}`
985
+ );
986
+ }
987
+ // --- Rigs ------------------------------------------------------------------
988
+ // Workspace-scoped, versioned sandbox machine definitions. rigs:use gates read
989
+ // + proposeRigChange; rigs:manage gates create / update / delete / activate.
990
+ async listRigs(workspaceId) {
991
+ return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/rigs`);
992
+ }
993
+ async createRig(workspaceId, request) {
994
+ return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/rigs`, request);
995
+ }
996
+ async getRig(workspaceId, rigId) {
997
+ return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/rigs/${rigId}`);
998
+ }
999
+ async updateRig(workspaceId, rigId, request) {
1000
+ return await this.requestJson(
1001
+ "PATCH",
1002
+ `/v1/workspaces/${workspaceId}/rigs/${rigId}`,
1003
+ request
1004
+ );
1005
+ }
1006
+ async deleteRig(workspaceId, rigId) {
1007
+ await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/rigs/${rigId}`);
1008
+ }
1009
+ async listRigVersions(workspaceId, rigId) {
1010
+ return await this.requestJson(
1011
+ "GET",
1012
+ `/v1/workspaces/${workspaceId}/rigs/${rigId}/versions`
1013
+ );
1014
+ }
1015
+ /** Roll the active version to an existing one (rollback / promote-activate). */
1016
+ async activateRigVersion(workspaceId, rigId, versionId) {
1017
+ return await this.requestJson(
1018
+ "POST",
1019
+ `/v1/workspaces/${workspaceId}/rigs/${rigId}/versions/${versionId}/activate`
776
1020
  );
777
1021
  }
1022
+ async listRigChanges(workspaceId, rigId) {
1023
+ return await this.requestJson(
1024
+ "GET",
1025
+ `/v1/workspaces/${workspaceId}/rigs/${rigId}/changes`
1026
+ );
1027
+ }
1028
+ /** Propose a change against the rig's active version (rigs:use). */
1029
+ async proposeRigChange(workspaceId, rigId, request) {
1030
+ return await this.requestJson(
1031
+ "POST",
1032
+ `/v1/workspaces/${workspaceId}/rigs/${rigId}/changes`,
1033
+ request
1034
+ );
1035
+ }
1036
+ async getRigChange(workspaceId, rigId, changeId) {
1037
+ return await this.requestJson(
1038
+ "GET",
1039
+ `/v1/workspaces/${workspaceId}/rigs/${rigId}/changes/${changeId}`
1040
+ );
1041
+ }
1042
+ /**
1043
+ * Re-run verification for a change (rigs:use). Verification is asynchronous:
1044
+ * this returns the change immediately with status `verifying`; poll
1045
+ * `getRigChange`/`listRigChanges` for the terminal outcome + logs.
1046
+ */
1047
+ async verifyRigChange(workspaceId, rigId, changeId) {
1048
+ return await this.requestJson(
1049
+ "POST",
1050
+ `/v1/workspaces/${workspaceId}/rigs/${rigId}/changes/${changeId}/verify`
1051
+ );
1052
+ }
1053
+ /**
1054
+ * Promote a verified `definition_edit` change into a new active rig version
1055
+ * (rigs:manage). Only valid once the change's verification passed; returns the
1056
+ * newly minted version.
1057
+ */
1058
+ async promoteRigChange(workspaceId, rigId, changeId) {
1059
+ return await this.requestJson(
1060
+ "POST",
1061
+ `/v1/workspaces/${workspaceId}/rigs/${rigId}/changes/${changeId}/promote`
1062
+ );
1063
+ }
1064
+ /**
1065
+ * Re-run the active version's checks in a clean throwaway sandbox (rigs:use).
1066
+ * Asynchronous — returns the version id being verified; the outcome lands on
1067
+ * the version's audit trail.
1068
+ */
1069
+ async verifyRig(workspaceId, rigId) {
1070
+ return await this.requestJson(
1071
+ "POST",
1072
+ `/v1/workspaces/${workspaceId}/rigs/${rigId}/verify`
1073
+ );
1074
+ }
1075
+ /** @deprecated use listVariableSets */
1076
+ async listEnvironments(workspaceId) {
1077
+ return await this.listVariableSets(workspaceId);
1078
+ }
1079
+ /** @deprecated use createVariableSet */
1080
+ async createEnvironment(workspaceId, request) {
1081
+ return await this.createVariableSet(workspaceId, request);
1082
+ }
1083
+ /** @deprecated use getVariableSet */
1084
+ async getEnvironment(workspaceId, environmentId) {
1085
+ return await this.getVariableSet(workspaceId, environmentId);
1086
+ }
1087
+ /** @deprecated use updateVariableSet */
1088
+ async updateEnvironment(workspaceId, environmentId, request) {
1089
+ return await this.updateVariableSet(workspaceId, environmentId, request);
1090
+ }
1091
+ /** @deprecated use deleteVariableSet */
1092
+ async deleteEnvironment(workspaceId, environmentId) {
1093
+ await this.deleteVariableSet(workspaceId, environmentId);
1094
+ }
1095
+ /** @deprecated use setVariableSetVariable */
1096
+ async setEnvironmentVariable(workspaceId, environmentId, name, value) {
1097
+ return await this.setVariableSetVariable(workspaceId, environmentId, name, value);
1098
+ }
1099
+ /** @deprecated use deleteVariableSetVariable */
1100
+ async deleteEnvironmentVariable(workspaceId, environmentId, name) {
1101
+ await this.deleteVariableSetVariable(workspaceId, environmentId, name);
1102
+ }
778
1103
  // --- Files -----------------------------------------------------------------------
779
1104
  /** Step 1 of the upload flow: returns the pre-signed PUT target. */
780
1105
  async beginFileUpload(workspaceId, request) {
781
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/files/uploads`, request);
1106
+ return await this.requestJson(
1107
+ "POST",
1108
+ `/v1/workspaces/${workspaceId}/files/uploads`,
1109
+ request
1110
+ );
782
1111
  }
783
1112
  /** Step 3 of the upload flow: server verifies the object and marks it ready. */
784
1113
  async completeFileUpload(workspaceId, uploadId) {
@@ -819,28 +1148,51 @@ var OpenGeniClient = class {
819
1148
  return await this.completeFileUpload(workspaceId, upload.uploadId);
820
1149
  }
821
1150
  async getFile(workspaceId, fileId) {
822
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/files/${fileId}`);
1151
+ return await this.requestJson(
1152
+ "GET",
1153
+ `/v1/workspaces/${workspaceId}/files/${fileId}`
1154
+ );
823
1155
  }
824
1156
  /** Mint a short-lived signed download URL for a ready file. */
825
1157
  async createFileDownloadUrl(workspaceId, fileId) {
826
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/files/${fileId}/download-url`);
1158
+ return await this.requestJson(
1159
+ "POST",
1160
+ `/v1/workspaces/${workspaceId}/files/${fileId}/download-url`
1161
+ );
827
1162
  }
828
1163
  // --- Documents ----------------------------------------------------------------------
829
1164
  async createDocumentBase(workspaceId, request) {
830
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/document-bases`, request);
1165
+ return await this.requestJson(
1166
+ "POST",
1167
+ `/v1/workspaces/${workspaceId}/document-bases`,
1168
+ request
1169
+ );
831
1170
  }
832
1171
  async listDocumentBases(workspaceId) {
833
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/document-bases`);
1172
+ return await this.requestJson(
1173
+ "GET",
1174
+ `/v1/workspaces/${workspaceId}/document-bases`
1175
+ );
834
1176
  }
835
1177
  async getDocumentBase(workspaceId, baseId) {
836
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/document-bases/${baseId}`);
1178
+ return await this.requestJson(
1179
+ "GET",
1180
+ `/v1/workspaces/${workspaceId}/document-bases/${baseId}`
1181
+ );
837
1182
  }
838
1183
  /** Index an uploaded file into the base. The file must be `ready`. */
839
1184
  async addDocument(workspaceId, baseId, request) {
840
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/document-bases/${baseId}/documents`, request);
1185
+ return await this.requestJson(
1186
+ "POST",
1187
+ `/v1/workspaces/${workspaceId}/document-bases/${baseId}/documents`,
1188
+ request
1189
+ );
841
1190
  }
842
1191
  async listDocuments(workspaceId, baseId) {
843
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/document-bases/${baseId}/documents`);
1192
+ return await this.requestJson(
1193
+ "GET",
1194
+ `/v1/workspaces/${workspaceId}/document-bases/${baseId}/documents`
1195
+ );
844
1196
  }
845
1197
  /** Retry indexing for a failed document. */
846
1198
  async reindexDocument(workspaceId, baseId, documentId) {
@@ -867,7 +1219,11 @@ var OpenGeniClient = class {
867
1219
  );
868
1220
  }
869
1221
  async searchKnowledge(workspaceId, request) {
870
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/knowledge/search`, request);
1222
+ return await this.requestJson(
1223
+ "POST",
1224
+ `/v1/workspaces/${workspaceId}/knowledge/search`,
1225
+ request
1226
+ );
871
1227
  }
872
1228
  async listKnowledgeMemories(workspaceId, request = {}) {
873
1229
  const params = new URLSearchParams();
@@ -877,16 +1233,53 @@ var OpenGeniClient = class {
877
1233
  if (request.scope) params.set("scope", request.scope);
878
1234
  if (request.limit) params.set("limit", String(request.limit));
879
1235
  const query = params.toString();
880
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/knowledge/memories${query ? `?${query}` : ""}`);
1236
+ return await this.requestJson(
1237
+ "GET",
1238
+ `/v1/workspaces/${workspaceId}/knowledge/memories${query ? `?${query}` : ""}`
1239
+ );
881
1240
  }
882
1241
  async getKnowledgeMemory(workspaceId, memoryId) {
883
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/knowledge/memories/${memoryId}`);
1242
+ return await this.requestJson(
1243
+ "GET",
1244
+ `/v1/workspaces/${workspaceId}/knowledge/memories/${memoryId}`
1245
+ );
884
1246
  }
885
1247
  async createKnowledgeMemory(workspaceId, request) {
886
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/knowledge/memories`, request);
1248
+ return await this.requestJson(
1249
+ "POST",
1250
+ `/v1/workspaces/${workspaceId}/knowledge/memories`,
1251
+ request
1252
+ );
887
1253
  }
888
1254
  async updateKnowledgeMemory(workspaceId, memoryId, request) {
889
- return await this.requestJson("PATCH", `/v1/workspaces/${workspaceId}/knowledge/memories/${memoryId}`, request);
1255
+ return await this.requestJson(
1256
+ "PATCH",
1257
+ `/v1/workspaces/${workspaceId}/knowledge/memories/${memoryId}`,
1258
+ request
1259
+ );
1260
+ }
1261
+ /** Hybrid (semantic + keyword) search over the workspace's agent-visible memory. */
1262
+ async searchWorkspaceMemories(workspaceId, request) {
1263
+ return await this.requestJson(
1264
+ "POST",
1265
+ `/v1/workspaces/${workspaceId}/knowledge/memories/search`,
1266
+ request
1267
+ );
1268
+ }
1269
+ /** Deep-merge a settings patch into the workspace (preserves unknown keys). */
1270
+ async updateWorkspaceSettings(workspaceId, request) {
1271
+ return await this.requestJson(
1272
+ "PATCH",
1273
+ `/v1/workspaces/${workspaceId}/settings`,
1274
+ request
1275
+ );
1276
+ }
1277
+ async setWorkspaceDefaultRig(workspaceId, request) {
1278
+ return await this.requestJson(
1279
+ "PUT",
1280
+ `/v1/workspaces/${workspaceId}/default-rig`,
1281
+ request
1282
+ );
890
1283
  }
891
1284
  // --- Capability packs ------------------------------------------------------------------
892
1285
  /** Built-in + registered packs, with the workspace's installations. */
@@ -895,10 +1288,17 @@ var OpenGeniClient = class {
895
1288
  }
896
1289
  /** Register (or replace) a workspace-scoped pack from a manifest. */
897
1290
  async registerPack(workspaceId, manifest) {
898
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/packs`, manifest);
1291
+ return await this.requestJson(
1292
+ "POST",
1293
+ `/v1/workspaces/${workspaceId}/packs`,
1294
+ manifest
1295
+ );
899
1296
  }
900
1297
  async getPack(workspaceId, packId) {
901
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}`);
1298
+ return await this.requestJson(
1299
+ "GET",
1300
+ `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}`
1301
+ );
902
1302
  }
903
1303
  async enablePack(workspaceId, packId, request = {}) {
904
1304
  return await this.requestJson(
@@ -909,18 +1309,31 @@ var OpenGeniClient = class {
909
1309
  }
910
1310
  /** Unregister a workspace-scoped pack (built-in packs cannot be deleted). */
911
1311
  async deletePack(workspaceId, packId) {
912
- await this.requestVoid("DELETE", `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}`);
1312
+ await this.requestVoid(
1313
+ "DELETE",
1314
+ `/v1/workspaces/${workspaceId}/packs/${encodeURIComponent(packId)}`
1315
+ );
913
1316
  }
914
1317
  async listPackInstallations(workspaceId) {
915
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/packs/installations`);
1318
+ return await this.requestJson(
1319
+ "GET",
1320
+ `/v1/workspaces/${workspaceId}/packs/installations`
1321
+ );
916
1322
  }
917
1323
  // --- Capabilities -------------------------------------------------------------------------
918
1324
  async listCapabilities(workspaceId) {
919
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/capabilities`);
1325
+ return await this.requestJson(
1326
+ "GET",
1327
+ `/v1/workspaces/${workspaceId}/capabilities`
1328
+ );
920
1329
  }
921
1330
  /** Add a manual capability catalog item (e.g. a remote MCP server). */
922
1331
  async createCapability(workspaceId, request) {
923
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/capabilities`, request);
1332
+ return await this.requestJson(
1333
+ "POST",
1334
+ `/v1/workspaces/${workspaceId}/capabilities`,
1335
+ request
1336
+ );
924
1337
  }
925
1338
  async enableCapability(workspaceId, capabilityId, request = {}) {
926
1339
  return await this.requestJson(
@@ -947,6 +1360,49 @@ var OpenGeniClient = class {
947
1360
  }
948
1361
  );
949
1362
  }
1363
+ // --- Connections -------------------------------------------------------------------------------
1364
+ async listConnections(workspaceId) {
1365
+ const response = await this.requestJson(
1366
+ "GET",
1367
+ `/v1/workspaces/${workspaceId}/connections`
1368
+ );
1369
+ return response.connections;
1370
+ }
1371
+ async createConnection(workspaceId, request) {
1372
+ const response = await this.requestJson(
1373
+ "POST",
1374
+ `/v1/workspaces/${workspaceId}/connections`,
1375
+ request
1376
+ );
1377
+ return response.connection;
1378
+ }
1379
+ async updateConnection(workspaceId, connectionId, request) {
1380
+ const response = await this.requestJson(
1381
+ "PATCH",
1382
+ `/v1/workspaces/${workspaceId}/connections/${connectionId}`,
1383
+ request
1384
+ );
1385
+ return response.connection;
1386
+ }
1387
+ async deleteConnection(workspaceId, connectionId) {
1388
+ const response = await this.requestJson(
1389
+ "DELETE",
1390
+ `/v1/workspaces/${workspaceId}/connections/${connectionId}`
1391
+ );
1392
+ return response.connection;
1393
+ }
1394
+ /** Start an OAuth connection flow; redirect the user to the returned `authorizationUrl`. */
1395
+ async startConnectionOAuth(workspaceId, request) {
1396
+ return await this.requestJson(
1397
+ "POST",
1398
+ `/v1/workspaces/${workspaceId}/connections/oauth/start`,
1399
+ request
1400
+ );
1401
+ }
1402
+ /** Public, immutably-cached URL for a catalog item's logo, or null when the item has none. */
1403
+ catalogAssetUrl(logoAssetPath) {
1404
+ return logoAssetPath ? `${this.baseUrl}/v1/${logoAssetPath}` : null;
1405
+ }
950
1406
  // --- GitHub ----------------------------------------------------------------------------------
951
1407
  /** GitHub App configuration status + a signed install URL when configured. */
952
1408
  async getGitHubApp(workspaceId) {
@@ -961,11 +1417,17 @@ var OpenGeniClient = class {
961
1417
  return this.url(`/v1/workspaces/${workspaceId}/github/connect`, { state });
962
1418
  }
963
1419
  async listGitHubRepositories(workspaceId) {
964
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/github/repositories`);
1420
+ return await this.requestJson(
1421
+ "GET",
1422
+ `/v1/workspaces/${workspaceId}/github/repositories`
1423
+ );
965
1424
  }
966
1425
  /** Re-sync the installation's repository list from GitHub. */
967
1426
  async syncGitHubRepositories(workspaceId) {
968
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/github/repositories/sync`);
1427
+ return await this.requestJson(
1428
+ "POST",
1429
+ `/v1/workspaces/${workspaceId}/github/repositories/sync`
1430
+ );
969
1431
  }
970
1432
  /** Build a GitHub App manifest + the GitHub URL to submit it to. */
971
1433
  async createGitHubAppManifest(workspaceId, request = {}) {
@@ -977,16 +1439,26 @@ var OpenGeniClient = class {
977
1439
  }
978
1440
  // --- API keys ----------------------------------------------------------------------------------
979
1441
  async listApiKeys(workspaceId) {
980
- const response = await this.requestJson("GET", `/v1/workspaces/${workspaceId}/api-keys`);
1442
+ const response = await this.requestJson(
1443
+ "GET",
1444
+ `/v1/workspaces/${workspaceId}/api-keys`
1445
+ );
981
1446
  return response.apiKeys;
982
1447
  }
983
1448
  /** The returned `token` is shown once; only its prefix is stored. */
984
1449
  async createApiKey(workspaceId, request) {
985
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/api-keys`, request);
1450
+ return await this.requestJson(
1451
+ "POST",
1452
+ `/v1/workspaces/${workspaceId}/api-keys`,
1453
+ request
1454
+ );
986
1455
  }
987
1456
  /** Revoke an API key. Returns the revoked key. */
988
1457
  async deleteApiKey(workspaceId, apiKeyId) {
989
- return await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/api-keys/${apiKeyId}`);
1458
+ return await this.requestJson(
1459
+ "DELETE",
1460
+ `/v1/workspaces/${workspaceId}/api-keys/${apiKeyId}`
1461
+ );
990
1462
  }
991
1463
  // --- Billing (account-scoped) --------------------------------------------------------------------
992
1464
  async getBilling(options = {}) {
@@ -1001,9 +1473,14 @@ var OpenGeniClient = class {
1001
1473
  });
1002
1474
  }
1003
1475
  async getBillingEntitlements(options = {}) {
1004
- return await this.requestJson("GET", "/v1/billing/entitlements", void 0, {
1005
- ...options.accountId !== void 0 ? { accountId: options.accountId } : {}
1006
- });
1476
+ return await this.requestJson(
1477
+ "GET",
1478
+ "/v1/billing/entitlements",
1479
+ void 0,
1480
+ {
1481
+ ...options.accountId !== void 0 ? { accountId: options.accountId } : {}
1482
+ }
1483
+ );
1007
1484
  }
1008
1485
  /** Start a Stripe checkout for prepaid credits. */
1009
1486
  async createBillingCheckout(request) {
@@ -1024,15 +1501,25 @@ var OpenGeniClient = class {
1024
1501
  // --- Codex (ChatGPT) subscription (workspace-scoped) --------------------------------------------
1025
1502
  /** Connection state + the codex models the workspace may select (empty until connected). */
1026
1503
  async codexStatus(workspaceId) {
1027
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/codex/status`);
1504
+ return await this.requestJson(
1505
+ "GET",
1506
+ `/v1/workspaces/${workspaceId}/codex/status`
1507
+ );
1028
1508
  }
1029
1509
  /** Begin device-code login: show `userCode` at `verificationUri`, then poll with `state`. */
1030
1510
  async codexConnectStart(workspaceId) {
1031
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/codex/connect/start`);
1511
+ return await this.requestJson(
1512
+ "POST",
1513
+ `/v1/workspaces/${workspaceId}/codex/connect/start`
1514
+ );
1032
1515
  }
1033
1516
  /** Poll device-code authorization with the `state` from {@link codexConnectStart}. */
1034
1517
  async codexConnectPoll(workspaceId, state) {
1035
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/codex/connect/poll`, { state });
1518
+ return await this.requestJson(
1519
+ "POST",
1520
+ `/v1/workspaces/${workspaceId}/codex/connect/poll`,
1521
+ { state }
1522
+ );
1036
1523
  }
1037
1524
  /** Remaining usage / limits for the connected (ACTIVE) subscription. Back-compat. */
1038
1525
  async codexUsage(workspaceId) {
@@ -1040,39 +1527,69 @@ var OpenGeniClient = class {
1040
1527
  }
1041
1528
  /** Live per-account usage read (refreshes THIS account's bearer; writes the cache). */
1042
1529
  async codexAccountUsage(workspaceId, accountId) {
1043
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}/usage`);
1530
+ return await this.requestJson(
1531
+ "GET",
1532
+ `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}/usage`
1533
+ );
1044
1534
  }
1045
1535
  /** Batched live refresh across every connected account, keyed by credential id. */
1046
1536
  async refreshCodexUsage(workspaceId) {
1047
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/codex/usage/refresh`);
1537
+ return await this.requestJson(
1538
+ "POST",
1539
+ `/v1/workspaces/${workspaceId}/codex/usage/refresh`
1540
+ );
1048
1541
  }
1049
1542
  /** Disconnect ALL accounts (legacy workspace-wide). Prefer `disconnectCodexAccount`. */
1050
1543
  async codexDisconnect(workspaceId) {
1051
- return await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/codex`);
1544
+ return await this.requestJson(
1545
+ "DELETE",
1546
+ `/v1/workspaces/${workspaceId}/codex`
1547
+ );
1052
1548
  }
1053
1549
  /** List every connected Codex account + the workspace active pointer + settings. */
1054
1550
  async listCodexAccounts(workspaceId) {
1055
- return await this.requestJson("GET", `/v1/workspaces/${workspaceId}/codex/accounts`);
1551
+ return await this.requestJson(
1552
+ "GET",
1553
+ `/v1/workspaces/${workspaceId}/codex/accounts`
1554
+ );
1056
1555
  }
1057
1556
  /** Switch the workspace ACTIVE Codex account (the one unpinned sessions use). */
1058
1557
  async activateCodexAccount(workspaceId, accountId) {
1059
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}/activate`);
1558
+ return await this.requestJson(
1559
+ "POST",
1560
+ `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}/activate`
1561
+ );
1060
1562
  }
1061
1563
  /** P3: enable/disable Codex auto-rotation and/or pick the strategy. Returns the effective settings. */
1062
1564
  async setCodexRotationSettings(workspaceId, patch) {
1063
- return await this.requestJson("PATCH", `/v1/workspaces/${workspaceId}/codex/settings`, patch);
1565
+ return await this.requestJson(
1566
+ "PATCH",
1567
+ `/v1/workspaces/${workspaceId}/codex/settings`,
1568
+ patch
1569
+ );
1064
1570
  }
1065
1571
  /** Disconnect ONE Codex account by id (re-picks active when the removed one was active). */
1066
1572
  async disconnectCodexAccount(workspaceId, accountId) {
1067
- return await this.requestJson("DELETE", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}`);
1573
+ return await this.requestJson(
1574
+ "DELETE",
1575
+ `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}`
1576
+ );
1068
1577
  }
1069
1578
  /** Rename a Codex account (label only in P1). */
1070
1579
  async renameCodexAccount(workspaceId, accountId, label) {
1071
- return await this.requestJson("PATCH", `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}`, { label });
1580
+ return await this.requestJson(
1581
+ "PATCH",
1582
+ `/v1/workspaces/${workspaceId}/codex/accounts/${accountId}`,
1583
+ { label }
1584
+ );
1072
1585
  }
1073
1586
  /** Pin (or unpin via "auto") a session's Codex account. Applies on the next turn. */
1074
1587
  async pinSessionCodexAccount(workspaceId, sessionId, target) {
1075
- return await this.requestJson("POST", `/v1/workspaces/${workspaceId}/sessions/${sessionId}/codex-account`, { target });
1588
+ return await this.requestJson(
1589
+ "POST",
1590
+ `/v1/workspaces/${workspaceId}/sessions/${sessionId}/codex-account`,
1591
+ { target }
1592
+ );
1076
1593
  }
1077
1594
  async requestJson(method, path, body, query = {}) {
1078
1595
  const response = await this.fetchImpl(this.url(path, query), {
@@ -1112,9 +1629,6 @@ async function safeText(response) {
1112
1629
  return "";
1113
1630
  }
1114
1631
  }
1115
- function delay(ms) {
1116
- return new Promise((resolve) => setTimeout(resolve, ms));
1117
- }
1118
1632
 
1119
1633
  // src/proxy.ts
1120
1634
  function formatSseEvent(event) {
@@ -1304,25 +1818,33 @@ var SESSION_EVENT_TYPES = [
1304
1818
  "session.created",
1305
1819
  "session.status.changed",
1306
1820
  "session.requiresAction",
1821
+ "session.context.compaction.requested",
1307
1822
  "session.context.compacted",
1823
+ "session.context.compaction.skipped",
1308
1824
  "session.context.cleared",
1309
1825
  "user.message",
1310
- "user.interrupt",
1826
+ "user.pause",
1311
1827
  "user.approvalDecision",
1312
1828
  "turn.queued",
1313
- "turn.updated",
1314
1829
  "turn.started",
1315
1830
  "turn.completed",
1316
1831
  "turn.failed",
1317
1832
  "turn.cancelled",
1318
- "turn.preempted",
1833
+ "turn.superseded",
1834
+ "turn.recovery.requested",
1835
+ "turn.capacity_waiting",
1319
1836
  "agent.message.delta",
1320
1837
  "agent.message.completed",
1321
1838
  "agent.reasoning.delta",
1322
1839
  "agent.toolCall.created",
1323
1840
  "agent.toolCall.output",
1841
+ "agent.model.usage",
1324
1842
  "tool.auth_needed",
1325
1843
  "agent.updated",
1844
+ "rig.setup.started",
1845
+ "rig.setup.completed",
1846
+ "rig.setup.skipped",
1847
+ "rig.setup.failed",
1326
1848
  "sandbox.operation.started",
1327
1849
  "sandbox.operation.completed",
1328
1850
  "sandbox.operation.failed",
@@ -1333,7 +1855,20 @@ var SESSION_EVENT_TYPES = [
1333
1855
  "goal.completed",
1334
1856
  "goal.paused",
1335
1857
  "goal.resumed",
1858
+ "goal.cleared",
1336
1859
  "goal.continuation",
1860
+ "system.update.pending",
1861
+ "system.update.delivered",
1862
+ "session.control.paused",
1863
+ "session.control.resumed",
1864
+ "session.control.steer_requested",
1865
+ "workspace.inference.paused",
1866
+ "workspace.inference.resumed",
1867
+ "session.queue.prompt.cancelled",
1868
+ "session.queue.history",
1869
+ "turn.event.rejected_late",
1870
+ "memory.saved",
1871
+ "memory.corrected",
1337
1872
  // Channel-B desktop pixel-plane signals (mirror of contracts SessionEventType;
1338
1873
  // the contract-parity test asserts sorted equality).
1339
1874
  "stream.url.rotated",
@@ -1353,7 +1888,37 @@ var SESSION_EVENT_TYPES = [
1353
1888
  "terminal.pty.exited",
1354
1889
  "session.title_set",
1355
1890
  // Multi-account Codex (P1): the session's inference account changed.
1356
- "codex.account.switched"
1891
+ "codex.account.switched",
1892
+ // OPE-21 metadata-only per-turn credential selection audit.
1893
+ "codex.credential.selected",
1894
+ // OPE-21 durable zero-capacity wait lifecycle. These are system/runtime
1895
+ // events, never synthetic user messages.
1896
+ "codex.capacity.waiting",
1897
+ "codex.capacity.resumed",
1898
+ "codex.capacity.superseded",
1899
+ // Sandbox durability observability (mirror of contracts SessionEventType):
1900
+ // box lifecycle + manifest-env drift, attributable from the DB alone.
1901
+ "sandbox.box.created",
1902
+ "sandbox.box.lost",
1903
+ "sandbox.box.terminated",
1904
+ "sandbox.box.snapshot",
1905
+ "sandbox.env.drift",
1906
+ // Active-sandbox pointer reconcile (issue #341; announce-only; mirror of contracts
1907
+ // SessionEventType — the contract-parity test asserts sorted equality).
1908
+ "session.route.reconciled",
1909
+ // Workbench v2 turn-end workspace capture (announce-only; mirror of contracts
1910
+ // SessionEventType — the contract-parity test asserts sorted equality).
1911
+ "workspace.revision.captured",
1912
+ "workspace.revision.degraded",
1913
+ // Connected Machine op-outcome observability (announce-only, quiet; mirror of
1914
+ // contracts SessionEventType — the contract-parity test asserts sorted equality).
1915
+ "machine.op.failed",
1916
+ "machine.op.recovered",
1917
+ // Connected Machine link-plane observability (announce-only, quiet; mirror of
1918
+ // contracts SessionEventType — the contract-parity test asserts sorted equality).
1919
+ "machine.link.lost",
1920
+ "machine.link.restored",
1921
+ "machine.runner.restarted"
1357
1922
  ];
1358
1923
  var KNOWN_PERMISSIONS = [
1359
1924
  "account:read",
@@ -1389,11 +1954,15 @@ var KNOWN_PERMISSIONS = [
1389
1954
  "connections:write",
1390
1955
  "environments:manage",
1391
1956
  "environments:use",
1957
+ "variable-sets:manage",
1958
+ "variable-sets:use",
1392
1959
  "mcp_servers:attach",
1393
1960
  "toolspace:call",
1394
1961
  "goals:manage",
1395
1962
  "enrollments:read",
1396
- "enrollments:manage"
1963
+ "enrollments:manage",
1964
+ "rigs:use",
1965
+ "rigs:manage"
1397
1966
  ];
1398
1967
  var KNOWN_USAGE_EVENT_TYPES = [
1399
1968
  "agent_run.created",