@opengeni/sdk 0.13.0 → 0.20.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/README.md CHANGED
@@ -44,12 +44,39 @@ contiguous `sequence` number:
44
44
  - Ends gracefully when the provided `AbortSignal` aborts; throws on
45
45
  non-retryable failures (e.g. 401/403/404).
46
46
 
47
- Use `client.listEvents(workspaceId, sessionId, { before, after, limit })` for
48
- durable replay pages. `before` is an exclusive sequence cursor that returns the
49
- newest matching page, still ordered ascending in the response. Pass
50
- `compact: true` for history windows that do not need individual delta fragments;
51
- delta runs may be coalesced and expose `payload.coalescedUntil` as the true last
52
- sequence for stream resume cursors.
47
+ Use `client.listEventPage(...)` when monitoring another session. A call without
48
+ a cursor is safe by default: it returns a newest-first-selected (but
49
+ ascending-in-response) semantic tail, uses bounded `summary` payloads, and omits
50
+ raw message/reasoning/command/PTY deltas. The page returns exact
51
+ `coveredSequence`, `nextBefore`/`nextAfter`, byte, truncation, and projection
52
+ metadata. Filters can select canonical event types or the `control`, `terminal`,
53
+ `failure`, `checkpoint`, `tool_receipt`, and `provider_account` semantic classes;
54
+ `latest` is an exclusive typed lookup that returns the newest event in exactly
55
+ the requested class. It cannot be combined with any type or class include/exclude
56
+ filter, so an unrelated newer event cannot displace the requested result and an
57
+ exclusion cannot remove it.
58
+
59
+ ```ts
60
+ const terminal = await client.listEventPage(workspaceId, sessionId, {
61
+ latest: "terminal",
62
+ payloadMode: "summary",
63
+ });
64
+
65
+ const older = await client.listEventPage(workspaceId, sessionId, {
66
+ before: terminal.nextBefore ?? undefined,
67
+ includeClasses: ["failure", "checkpoint"],
68
+ payloadMode: "none",
69
+ });
70
+ ```
71
+
72
+ Use explicit `mode: "forensic", payloadMode: "full"` with `after`/`before` for
73
+ exact retained audit replay. “Full” means the exact durable audit projection;
74
+ it cannot restore source bytes that the audit boundary never retained. REST/SDK
75
+ pages remain count- and byte-bounded, so continue with the returned cursor. The
76
+ convenience `client.listEvents(...)` returns only the page's event array. Pass
77
+ `compact: true` for forensic history windows that do not need individual delta
78
+ fragments; delta runs may be coalesced and expose `payload.coalescedUntil` as
79
+ the true last sequence for stream resume cursors.
53
80
 
54
81
  ```ts
55
82
  const controller = new AbortController();
@@ -70,19 +97,41 @@ the explicit alternative: deliver now by interrupting the running turn.
70
97
 
71
98
  ```ts
72
99
  // Queue (default): stacks behind the running turn.
73
- await client.sendMessage(workspaceId, sessionId, "Also check the nginx config");
100
+ await client.sendMessage(workspaceId, sessionId, {
101
+ text: "Also check the nginx config",
102
+ clientEventId: crypto.randomUUID(),
103
+ });
74
104
 
75
105
  // Steer: send + promote to the queue front + interrupt the running turn.
76
- await client.steerMessage(workspaceId, sessionId, "Stop — prod is paging, look at that first");
106
+ await client.steerMessage(workspaceId, sessionId, {
107
+ text: "Stop — prod is paging, look at that first",
108
+ clientEventId: crypto.randomUUID(),
109
+ });
77
110
 
78
- // Manage the queue while it waits.
79
- const turns = await client.listTurns(workspaceId, sessionId);
80
- await client.updateQueuedTurn(workspaceId, sessionId, turnId, { prompt: "rewritten" });
81
- await client.reorderQueuedTurns(workspaceId, sessionId, [turnB, turnA]);
82
- await client.deleteQueuedTurn(workspaceId, sessionId, turnId);
111
+ // Manage the server-authoritative queue while it waits.
112
+ const queue = await client.getQueue(workspaceId, sessionId);
113
+ const waiting = queue.items.at(-1)!;
114
+ await client.moveQueueItem(workspaceId, sessionId, waiting.id, {
115
+ expectedQueueVersion: queue.version,
116
+ beforeTurnId: queue.items[0]?.id ?? null,
117
+ clientEventId: crypto.randomUUID(),
118
+ });
119
+ await client.editQueueItem(workspaceId, sessionId, waiting.id, {
120
+ expectedTurnVersion: waiting.version,
121
+ expectedDraftRevision: 0,
122
+ replaceDraft: false,
123
+ clientEventId: crypto.randomUUID(),
124
+ });
83
125
 
84
- // Control events.
85
- await client.interrupt(workspaceId, sessionId, { reason: "stop and report" });
126
+ // Pause/Resume is recursive workstream control; it creates no queue row.
127
+ await client.pauseSession(workspaceId, sessionId, {
128
+ reason: "hold this workstream",
129
+ expectedControlEtag: queue.effectiveControl.controlEtag,
130
+ });
131
+ const paused = await client.getQueue(workspaceId, sessionId);
132
+ await client.resumeSession(workspaceId, sessionId, {
133
+ expectedControlEtag: paused.effectiveControl.controlEtag,
134
+ });
86
135
  await client.sendApprovalDecision(workspaceId, sessionId, { approvalId, decision: "approve" });
87
136
  ```
88
137
 
@@ -149,9 +198,9 @@ Every public endpoint group has typed methods:
149
198
  | Group | Methods |
150
199
  | --- | --- |
151
200
  | Access + workspaces | `getAccessContext`, `listWorkspaces`, `createWorkspace`, `getWorkspace`, `updateWorkspace` |
152
- | Sessions + events | `createSession`, `listSessions`, `getSession`, `updateSession`, `listEvents`, `sendEvent`, `sendMessage`, `steerMessage`, `interrupt`, `sendApprovalDecision`, `streamEvents`, `openEventStream` |
201
+ | Sessions + events | `createSession`, `listSessions`, `getSession`, `updateSession`, `listEvents`, `sendEvent`, `sendMessage`, `steerMessage`, `pauseSession`, `resumeSession`, `sendApprovalDecision`, `streamEvents`, `openEventStream` |
153
202
  | Machines (bring-your-own-compute) | `listMachines`, `machineMetricsSeries`, `swapActiveSandbox`, `mintEnrollToken`, `lookupDeviceEnrollment`, `approveDeviceEnrollment`, `denyDeviceEnrollment` |
154
- | Turn queue | `listTurns`, `updateQueuedTurn`, `reorderQueuedTurns`, `deleteQueuedTurn` |
203
+ | Turn queue | `getQueue`, `moveQueueItem`, `editQueueItem`, `steerQueueItem`, `deleteQueueItem` |
155
204
  | Goal | `getGoal`, `updateGoal`, `pauseGoal`, `resumeGoal` |
156
205
  | Scheduled tasks | `createScheduledTask`, `listScheduledTasks`, `getScheduledTask`, `updateScheduledTask`, `pauseScheduledTask`, `resumeScheduledTask`, `triggerScheduledTask`, `deleteScheduledTask`, `listScheduledTaskRuns` |
157
206
  | Variable sets | `listVariable sets`, `createVariable set`, `getVariable set`, `updateVariable set`, `deleteVariable set`, `setVariable setVariable`, `deleteVariable setVariable` (values are write-only) |