@b3os/sdk 0.2.2 → 0.2.3

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 (80) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/core/util.d.ts +1 -1
  3. package/dist/cjs/core/util.js +1 -1
  4. package/dist/cjs/generated/client.d.ts +5 -0
  5. package/dist/cjs/generated/client.js +9 -0
  6. package/dist/cjs/generated/client.js.map +1 -1
  7. package/dist/cjs/generated/errors.d.ts +1 -1
  8. package/dist/cjs/generated/errors.js +45 -0
  9. package/dist/cjs/generated/errors.js.map +1 -1
  10. package/dist/cjs/generated/ids.d.ts +28 -0
  11. package/dist/cjs/generated/ids.js +7 -0
  12. package/dist/cjs/generated/ids.js.map +1 -1
  13. package/dist/cjs/generated/ns/agents.d.ts +438 -11
  14. package/dist/cjs/generated/ns/agents.js +598 -11
  15. package/dist/cjs/generated/ns/agents.js.map +1 -1
  16. package/dist/cjs/generated/ns/images.d.ts +84 -3
  17. package/dist/cjs/generated/ns/images.js +126 -2
  18. package/dist/cjs/generated/ns/images.js.map +1 -1
  19. package/dist/cjs/generated/ns/listeners.d.ts +6 -2
  20. package/dist/cjs/generated/ns/listeners.js +6 -2
  21. package/dist/cjs/generated/ns/listeners.js.map +1 -1
  22. package/dist/cjs/generated/ns/routines.d.ts +11 -0
  23. package/dist/cjs/generated/ns/routines.js +11 -0
  24. package/dist/cjs/generated/ns/routines.js.map +1 -1
  25. package/dist/cjs/generated/ns/sandboxes.d.ts +140 -1
  26. package/dist/cjs/generated/ns/sandboxes.js +190 -1
  27. package/dist/cjs/generated/ns/sandboxes.js.map +1 -1
  28. package/dist/cjs/generated/ns/vision.d.ts +55 -1
  29. package/dist/cjs/generated/ns/vision.js +94 -1
  30. package/dist/cjs/generated/ns/vision.js.map +1 -1
  31. package/dist/cjs/generated/ns/workspaces.d.ts +225 -0
  32. package/dist/cjs/generated/ns/workspaces.js +410 -0
  33. package/dist/cjs/generated/ns/workspaces.js.map +1 -0
  34. package/dist/cjs/generated/types.d.ts +2230 -72
  35. package/dist/esm/core/util.d.ts +1 -1
  36. package/dist/esm/core/util.js +1 -1
  37. package/dist/esm/generated/client.d.ts +5 -0
  38. package/dist/esm/generated/client.js +9 -0
  39. package/dist/esm/generated/client.js.map +1 -1
  40. package/dist/esm/generated/errors.d.ts +1 -1
  41. package/dist/esm/generated/errors.js +45 -0
  42. package/dist/esm/generated/errors.js.map +1 -1
  43. package/dist/esm/generated/ids.d.ts +28 -0
  44. package/dist/esm/generated/ids.js +7 -0
  45. package/dist/esm/generated/ids.js.map +1 -1
  46. package/dist/esm/generated/ns/agents.d.ts +438 -11
  47. package/dist/esm/generated/ns/agents.js +598 -11
  48. package/dist/esm/generated/ns/agents.js.map +1 -1
  49. package/dist/esm/generated/ns/images.d.ts +84 -3
  50. package/dist/esm/generated/ns/images.js +126 -2
  51. package/dist/esm/generated/ns/images.js.map +1 -1
  52. package/dist/esm/generated/ns/listeners.d.ts +6 -2
  53. package/dist/esm/generated/ns/listeners.js +6 -2
  54. package/dist/esm/generated/ns/listeners.js.map +1 -1
  55. package/dist/esm/generated/ns/routines.d.ts +11 -0
  56. package/dist/esm/generated/ns/routines.js +11 -0
  57. package/dist/esm/generated/ns/routines.js.map +1 -1
  58. package/dist/esm/generated/ns/sandboxes.d.ts +140 -1
  59. package/dist/esm/generated/ns/sandboxes.js +190 -1
  60. package/dist/esm/generated/ns/sandboxes.js.map +1 -1
  61. package/dist/esm/generated/ns/vision.d.ts +55 -1
  62. package/dist/esm/generated/ns/vision.js +94 -1
  63. package/dist/esm/generated/ns/vision.js.map +1 -1
  64. package/dist/esm/generated/ns/workspaces.d.ts +225 -0
  65. package/dist/esm/generated/ns/workspaces.js +406 -0
  66. package/dist/esm/generated/ns/workspaces.js.map +1 -0
  67. package/dist/esm/generated/types.d.ts +2230 -72
  68. package/package.json +1 -1
  69. package/src/core/util.ts +1 -1
  70. package/src/generated/client.ts +10 -0
  71. package/src/generated/errors.ts +90 -0
  72. package/src/generated/ids.ts +7 -0
  73. package/src/generated/ns/agents.ts +652 -11
  74. package/src/generated/ns/images.ts +131 -3
  75. package/src/generated/ns/listeners.ts +6 -2
  76. package/src/generated/ns/routines.ts +11 -0
  77. package/src/generated/ns/sandboxes.ts +203 -1
  78. package/src/generated/ns/vision.ts +101 -1
  79. package/src/generated/ns/workspaces.ts +448 -0
  80. package/src/generated/types.ts +2416 -48
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.AgentsAPI = exports.agentsOps = void 0;
5
5
  const jobs_ts_1 = require("../../core/jobs.js");
6
6
  const namespace_ts_1 = require("../../core/namespace.js");
7
+ const ws_ts_1 = require("../../core/ws.js");
7
8
  const listAgentsOp = {
8
9
  id: "agentsListAgents",
9
10
  method: "GET",
@@ -20,6 +21,32 @@ const createAgentOp = {
20
21
  timeoutMs: 10000,
21
22
  scope: "agents:write",
22
23
  };
24
+ const listHarnessesOp = {
25
+ id: "agentsListHarnesses",
26
+ method: "GET",
27
+ path: "/v1/agents/harnesses",
28
+ timeoutMs: 10000,
29
+ stretch: true,
30
+ scope: "agents:read",
31
+ };
32
+ const requestSelfDecisionOp = {
33
+ id: "agentsRequestSelfDecision",
34
+ method: "POST",
35
+ path: "/v1/agents/self/decide",
36
+ body: "json",
37
+ timeoutMs: 12000,
38
+ stretch: true,
39
+ scope: "authenticated",
40
+ };
41
+ const recordSelfEventsOp = {
42
+ id: "agentsRecordSelfEvents",
43
+ method: "POST",
44
+ path: "/v1/agents/self/events",
45
+ body: "json",
46
+ timeoutMs: 10000,
47
+ stretch: true,
48
+ scope: "authenticated",
49
+ };
23
50
  const getSessionOp = {
24
51
  id: "agentsGetSession",
25
52
  method: "GET",
@@ -36,6 +63,16 @@ const cancelSessionOp = {
36
63
  timeoutMs: 10000,
37
64
  scope: "agents:run",
38
65
  };
66
+ const sendDecisionOp = {
67
+ id: "agentsSendDecision",
68
+ method: "POST",
69
+ path: "/v1/agents/sessions/{session_id}/decisions",
70
+ params: ["session_id"],
71
+ body: "json",
72
+ timeoutMs: 10000,
73
+ stretch: true,
74
+ scope: "agents:run",
75
+ };
39
76
  const streamSessionOp = {
40
77
  id: "agentsStreamSession",
41
78
  method: "GET",
@@ -45,6 +82,16 @@ const streamSessionOp = {
45
82
  timeoutMs: 3600000,
46
83
  scope: "agents:read",
47
84
  };
85
+ const steerSessionOp = {
86
+ id: "agentsSteerSession",
87
+ method: "POST",
88
+ path: "/v1/agents/sessions/{session_id}/steer",
89
+ params: ["session_id"],
90
+ body: "json",
91
+ timeoutMs: 10000,
92
+ stretch: true,
93
+ scope: "agents:run",
94
+ };
48
95
  const deleteAgentOp = {
49
96
  id: "agentsDeleteAgent",
50
97
  method: "DELETE",
@@ -103,6 +150,16 @@ const putInstanceOp = {
103
150
  timeoutMs: 65000,
104
151
  scope: "agents:run",
105
152
  };
153
+ const sendInstanceDecisionOp = {
154
+ id: "agentsSendInstanceDecision",
155
+ method: "POST",
156
+ path: "/v1/agents/{agent}/instances/{key}/decisions",
157
+ params: ["agent", "key"],
158
+ body: "json",
159
+ timeoutMs: 10000,
160
+ stretch: true,
161
+ scope: "agents:run",
162
+ };
106
163
  const listInstanceEventsOp = {
107
164
  id: "agentsListInstanceEvents",
108
165
  method: "GET",
@@ -111,6 +168,34 @@ const listInstanceEventsOp = {
111
168
  timeoutMs: 10000,
112
169
  scope: "agents:read",
113
170
  };
171
+ const listGrantsOp = {
172
+ id: "agentsListGrants",
173
+ method: "GET",
174
+ path: "/v1/agents/{agent}/instances/{key}/grants",
175
+ params: ["agent", "key"],
176
+ timeoutMs: 10000,
177
+ stretch: true,
178
+ scope: "agents:read",
179
+ };
180
+ const createGrantOp = {
181
+ id: "agentsCreateGrant",
182
+ method: "POST",
183
+ path: "/v1/agents/{agent}/instances/{key}/grants",
184
+ params: ["agent", "key"],
185
+ body: "json",
186
+ timeoutMs: 10000,
187
+ stretch: true,
188
+ scope: "agents:write",
189
+ };
190
+ const deleteGrantOp = {
191
+ id: "agentsDeleteGrant",
192
+ method: "DELETE",
193
+ path: "/v1/agents/{agent}/instances/{key}/grants/{grant_id}",
194
+ params: ["agent", "key", "grant_id"],
195
+ timeoutMs: 10000,
196
+ stretch: true,
197
+ scope: "agents:write",
198
+ };
114
199
  const sleepInstanceOp = {
115
200
  id: "agentsSleepInstance",
116
201
  method: "POST",
@@ -120,6 +205,53 @@ const sleepInstanceOp = {
120
205
  timeoutMs: 30000,
121
206
  scope: "agents:run",
122
207
  };
208
+ const streamInstanceOp = {
209
+ id: "agentsStreamInstance",
210
+ method: "GET",
211
+ path: "/v1/agents/{agent}/instances/{key}/stream",
212
+ params: ["agent", "key"],
213
+ stream: "sse",
214
+ timeoutMs: 3600000,
215
+ stretch: true,
216
+ scope: "agents:read",
217
+ };
218
+ const openTerminalOp = {
219
+ id: "agentsOpenTerminal",
220
+ method: "GET",
221
+ path: "/v1/agents/{agent}/instances/{key}/terminal",
222
+ params: ["agent", "key"],
223
+ stream: "ws",
224
+ timeoutMs: 3600000,
225
+ stretch: true,
226
+ scope: "agents:read",
227
+ };
228
+ const listRecordingsOp = {
229
+ id: "agentsListRecordings",
230
+ method: "GET",
231
+ path: "/v1/agents/{agent}/instances/{key}/terminal/recordings",
232
+ params: ["agent", "key"],
233
+ timeoutMs: 30000,
234
+ stretch: true,
235
+ scope: "agents:read",
236
+ };
237
+ const getRecordingOp = {
238
+ id: "agentsGetRecording",
239
+ method: "GET",
240
+ path: "/v1/agents/{agent}/instances/{key}/terminal/recordings/{recording_id}",
241
+ params: ["agent", "key", "recording_id"],
242
+ timeoutMs: 65000,
243
+ stretch: true,
244
+ scope: "agents:read",
245
+ };
246
+ const createTicketOp = {
247
+ id: "agentsCreateTicket",
248
+ method: "POST",
249
+ path: "/v1/agents/{agent}/instances/{key}/ticket",
250
+ params: ["agent", "key"],
251
+ timeoutMs: 5000,
252
+ stretch: true,
253
+ scope: "agents:read",
254
+ };
123
255
  const listSessionsOp = {
124
256
  id: "agentsListSessions",
125
257
  method: "GET",
@@ -144,9 +276,14 @@ const sendMessageOp = {
144
276
  exports.agentsOps = {
145
277
  listAgents: listAgentsOp,
146
278
  createAgent: createAgentOp,
279
+ listHarnesses: listHarnessesOp,
280
+ requestSelfDecision: requestSelfDecisionOp,
281
+ recordSelfEvents: recordSelfEventsOp,
147
282
  getSession: getSessionOp,
148
283
  cancelSession: cancelSessionOp,
284
+ sendDecision: sendDecisionOp,
149
285
  streamSession: streamSessionOp,
286
+ steerSession: steerSessionOp,
150
287
  deleteAgent: deleteAgentOp,
151
288
  getAgent: getAgentOp,
152
289
  updateAgent: updateAgentOp,
@@ -154,9 +291,18 @@ exports.agentsOps = {
154
291
  deleteInstance: deleteInstanceOp,
155
292
  getInstance: getInstanceOp,
156
293
  putInstance: putInstanceOp,
294
+ sendInstanceDecision: sendInstanceDecisionOp,
157
295
  listInstanceEvents: listInstanceEventsOp,
296
+ listGrants: listGrantsOp,
297
+ createGrant: createGrantOp,
298
+ deleteGrant: deleteGrantOp,
158
299
  sendMessage: sendMessageOp,
159
300
  sleepInstance: sleepInstanceOp,
301
+ streamInstance: streamInstanceOp,
302
+ openTerminal: openTerminalOp,
303
+ listRecordings: listRecordingsOp,
304
+ getRecording: getRecordingOp,
305
+ createTicket: createTicketOp,
160
306
  listSessions: listSessionsOp,
161
307
  };
162
308
  /**
@@ -187,18 +333,125 @@ class AgentsAPI extends namespace_ts_1.Namespace {
187
333
  * disk, never its definition. Instances belong to the project: revoking the key that created the agent does
188
334
  * not stop them.
189
335
  *
336
+ * Set `harness` instead of `entry` to run a coding agent people already use (opencode, the default; Codex; pi;
337
+ * Claude Code), unmodified (`AgentHarness`; planned, not served on the beta node yet). The node checks the
338
+ * block against the kind's entry in `GET /v1/agents/harnesses`, then fills `entry`, `source.template`, each
339
+ * `key` profile's credentials in `secrets` (as `B3OS_PROFILE_<NAME>__<VAR>`), and `api`, `egress` and
340
+ * `turns.timeout_s` where you leave them out. A request with both `entry` and `harness`, or neither, is `400
341
+ * invalid_request`. Until they are served on this node, `repo`, `context` and `acp` are refused even when
342
+ * empty, and so is every vault connection outside a credential profile (`repo.connection`, a remote `mcp`
343
+ * server's `connection`, a stdio server's `{connection}` values): `422 harness_capability_unsupported`.
344
+ *
345
+ * An agent with a `signin` profile in `harness.auth` is personal: its `owner` is the person who creates it,
346
+ * from their own dashboard session or CLI token (an API key, a sandbox or an instance gets `403
347
+ * harness_personal_agent`), and it never changes. A ChatGPT plan's sign-in (`provider: openai`) needs no flag.
348
+ * A Claude plan's (`provider: anthropic`) needs the `agents.claude_plan_signin` flag (`403
349
+ * harness_claude_plan_signin_disabled` without it). The node knows no person yet, so until the prerequisites
350
+ * `AgentHarnessAuthSignin` names land, every `signin` profile is `403 harness_personal_agent`.
351
+ *
190
352
  * `POST /v1/agents` · scope `agents:write` · served by the node
191
353
  */
192
354
  createAgent(body, options) {
193
355
  return this._client._call(createAgentOp, { body }, options);
194
356
  }
357
+ /**
358
+ * List the harnesses this node runs
359
+ *
360
+ * The harnesses a `harness` block may name (`kind`), the open-source ones first (opencode, the default `kind`,
361
+ * then Codex and pi; Claude Code last), each with the versions this node runs, newest first, and the one a
362
+ * definition without `version` gets. A version is pinned in the node's `harness` template; a new
363
+ * upstream release becomes a new template revision and a new entry here, and a definition moves to it only when
364
+ * a `PATCH` changes its `version`.
365
+ *
366
+ * This answer is the catalog the harness's shim prints (`b3os-harness catalog --json`), stored with the
367
+ * `harness` template's build and served as it was printed, nothing added or left out: the shim's drivers are
368
+ * the source of truth for what each kind takes, and the node checks definitions against this answer. Each entry
369
+ * in `data` is what the kind's driver declares about itself: `driver` (`native`, built into the shim, or `acp`,
370
+ * the generic Agent Client Protocol adapter), `capabilities`, the credential profiles the kind takes (`auth`:
371
+ * the `key` providers with the variables each sets, the `signin` providers, and whether a model the node serves
372
+ * works), the lists of the block it takes (`setup`), and the `settings` keys the shim owns
373
+ * (`settings_refused`). `plan_env` names the variables no harness agent may set (`AgentHarnessPlanEnv`).
374
+ * `checks` is what the node and the shim refuse beyond each entry (`AgentHarnessCatalogChecks`), among them the
375
+ * default `mcp` and `skills` entries every definition's maps merge over (`checks.defaults`), so a client can
376
+ * check a recipe, and show its merged lists, before it deploys it. A feature not yet checked against a kind's
377
+ * pinned version is left out, and a definition that uses it is refused (`422 harness_capability_unsupported`).
378
+ * A definition that moves to a new version builds that revision's prepared snapshot again, at most
379
+ * `agents.prepare_concurrent` builds of an organization at once (planned, with prepared snapshots).
380
+ * Planned: not served on the beta node yet.
381
+ *
382
+ * `GET /v1/agents/harnesses` · scope `agents:read` · served by the node
383
+ *
384
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
385
+ */
386
+ listHarnesses(options) {
387
+ return this._client._call(listHarnessesOp, {}, options);
388
+ }
389
+ /**
390
+ * Ask the decide webhook from inside an instance
391
+ *
392
+ * How the harness's shim asks the definition's `hooks.decide` webhook a question while the turn waits, from
393
+ * inside the instance at `http://127.0.0.1:7700`. The node makes the call (`agentsDecideHarnessEvent`): it sets
394
+ * `harness`, `instance` and, when `session` is the session the instance runs now, `session_id` and `subject`
395
+ * from that session (any other `session` is dropped); it signs the call with `B3OS-Signature` and the URL's
396
+ * secret, sends it through the egress guard (private and loopback addresses refused), and answers with the
397
+ * decision. So the secret never enters the instance, and the decide host need not be in the instance's
398
+ * `egress`.
399
+ *
400
+ * The node applies the fail-closed rule itself and answers within `timeout_ms` (at most 10 seconds) plus its
401
+ * own overhead: no answer in time, a status other than 2xx, or a body without a `decision` answers
402
+ * `hooks.decide.on_timeout` (`deny` unless the definition sets `allow`) with `fallback: true`. The shim treats
403
+ * any answer other than `200`, and no answer, as `deny`. A question the definition does not send to the
404
+ * webhook is `400 invalid_request`: an agent without `hooks.decide`, a `type` its `events` does not select, and
405
+ * any question in `permissions: plan`, where the webhook is never called.
406
+ *
407
+ * Bound to the caller's own credential as `POST /v1/agents/self/events` is: the instance is the one whose
408
+ * token calls, and any other caller, an API key included, gets `403 forbidden` with `reason: instance_only`.
409
+ * An instance asks at most `agents.self_decide_rate` questions a minute; past it the answer is `429
410
+ * rate_limited`, which the shim takes as `deny`, as it takes any answer but `200`. Planned: not served on the
411
+ * beta node yet.
412
+ *
413
+ * `POST /v1/agents/self/decide` · scope `authenticated` · served by the node
414
+ *
415
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
416
+ */
417
+ requestSelfDecision(body, options) {
418
+ return this._client._call(requestSelfDecisionOp, { body }, options);
419
+ }
420
+ /**
421
+ * Record harness events from inside an instance
422
+ *
423
+ * How the harness's shim records `harness.*` events that happened outside a delivered turn (a turn typed in the
424
+ * terminal or started inside the instance), from inside the instance at `http://127.0.0.1:7700`. The node writes them to the
425
+ * calling instance's event stream (`GET /v1/agents/{agent}/instances/{key}/stream`) and sends the ones the
426
+ * definition's `hooks.webhook` selects. Events of a delivered turn reach the session's stream as
427
+ * `session.output` instead and are not sent here.
428
+ *
429
+ * The route is bound to the caller's own credential: the node takes the instance from the token of the VM that
430
+ * calls. Each event is an `AgentSelfEvent`, which has none of the members the node owns: the node sets
431
+ * `instance`, `org` and `project` itself and assigns the log's own `seq`. An event with `seq`, `instance`,
432
+ * `org`, `project`, `session_id` or `subject` is `400 invalid_request`, and so is one whose `harness` is not the
433
+ * definition's kind; the whole request is refused and nothing in it is written. A self event never belongs to a
434
+ * session: the node never takes one as a session's result or as the answer to a question. No instance can write
435
+ * another's events. Any other caller, an API key included, gets `403 forbidden` with `reason: instance_only`.
436
+ * An event whose `id` the instance already recorded is counted in `duplicates` and not written again. An
437
+ * instance records at most `agents.self_events_rate` events a minute; past it the request is `429
438
+ * rate_limited` with `Retry-After` and nothing in it is written. Planned: not served on the beta node yet.
439
+ *
440
+ * `POST /v1/agents/self/events` · scope `authenticated` · served by the node
441
+ *
442
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
443
+ */
444
+ recordSelfEvents(body, options) {
445
+ return this._client._call(recordSelfEventsOp, { body }, options);
446
+ }
195
447
  /**
196
448
  * Get an agent session
197
449
  *
198
450
  * One turn: its status and phase, who sent it (`initiator`), its conversation, how its instance woke
199
451
  * (`woke_from`), its trace and its timing. The message and the harness's answer are kept only for a session that
200
452
  * was answered `202` (so you can read the result here, for 24 hours) or when the project's
201
- * `platform.capture_content` setting is on. Sessions are kept 30 days after they end.
453
+ * `platform.capture_content` setting is on. Sessions are kept 30 days after they end. A session of a personal
454
+ * agent (`Agent.owner`, planned) is read only by the agent's owner (`403 harness_personal_agent`).
202
455
  *
203
456
  * `GET /v1/agents/sessions/{session_id}` · scope `agents:read` · served by the node
204
457
  */
@@ -209,13 +462,50 @@ class AgentsAPI extends namespace_ts_1.Namespace {
209
462
  * Cancel an agent session
210
463
  *
211
464
  * Cancels a turn. A queued session leaves the queue and is never delivered. A delivered one has its request into
212
- * the harness closed; what the harness already did stands. Cancelling an ended session returns it unchanged.
465
+ * the harness closed; what the harness already did stands. Cancelling an ended session returns it unchanged. For
466
+ * an agent with a `harness` block (planned), the node first asks the harness to interrupt the turn (opencode's
467
+ * session interrupt, Codex's `turn/interrupt`, pi's `abort`, Claude Code's `interrupt`), so the turn ends
468
+ * `harness.turn.interrupted` with its usage so far, and the harness session stays open for the next turn. The
469
+ * harness's shim also stops the turn when the node closes the delivery, so a cancel that arrives before the
470
+ * harness has started the turn still stops it. On a personal agent only the owner cancels (`403
471
+ * harness_personal_agent`).
213
472
  *
214
473
  * `POST /v1/agents/sessions/{session_id}/cancel` · scope `agents:run` · served by the node
215
474
  */
216
475
  cancelSession(sessionId, options) {
217
476
  return this._client._call(cancelSessionOp, { path: [sessionId] }, options);
218
477
  }
478
+ /**
479
+ * Answer a harness's permission request
480
+ *
481
+ * Answers a question the turn waits on: a `harness.permission.requested` event (the harness asked a person,
482
+ * with `permissions: ask`, or `hooks.decide` answered `ask`). `request` is that event's `request`. `allow` lets
483
+ * the tool run; `deny` refuses it, and the harness carries on with the refusal and `reason`. The answer is
484
+ * recorded as `harness.permission.resolved` with `by: person`. A question nobody answers is denied when the turn
485
+ * reaches its timeout (`by: timeout`), and one still open when its turn ends is withdrawn (`by: withdrawn`). This
486
+ * answer is for this one call, and B3OS never picks a harness's own "always allow": an answer that should cover
487
+ * the rest of a conversation is a rule B3OS keeps for that conversation (planned), never the harness's own.
488
+ *
489
+ * A question of a turn that is not a session (typed in the terminal or started inside the instance) has no
490
+ * session to answer it through: its event has no `session_id`. Answer those, or any question of the instance, with
491
+ * `POST /v1/agents/{agent}/instances/{key}/decisions`, which the live view uses for every question.
492
+ *
493
+ * Claude Code in `terminal` mode asks its own permission prompts in its TUI (with `permissions: ask`), and they
494
+ * are answered there, by whoever controls the terminal: such a `harness.permission.requested` carries no
495
+ * `request`, and no `…/decisions` route can answer it. `hooks.decide` still answers before the TUI asks.
496
+ *
497
+ * A question already answered (by you, another caller, the turn's end or its timeout), or one this session
498
+ * never asked, answers `404 decision_not_found`; an ended session answers `409 no_turn_running`. On a personal
499
+ * agent only the owner answers (`403 harness_personal_agent`). Only for an agent with a `harness` block (`409
500
+ * harness_required`). Planned: not served on the beta node yet.
501
+ *
502
+ * `POST /v1/agents/sessions/{session_id}/decisions` · scope `agents:run` · served by the node
503
+ *
504
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
505
+ */
506
+ sendDecision(sessionId, body, options) {
507
+ return this._client._call(sendDecisionOp, { path: [sessionId], body }, options);
508
+ }
219
509
  /**
220
510
  * Stream an agent session's events
221
511
  *
@@ -223,7 +513,9 @@ class AgentsAPI extends namespace_ts_1.Namespace {
223
513
  * to wake (with `woke_from`), `session.delivered` when the harness received it, `session.output` for each event
224
514
  * the harness streamed back (when it answered with `text/event-stream`), and the terminal `job.succeeded`,
225
515
  * `job.failed` or `job.canceled`, which carries the final session and ends the stream. Reconnect with
226
- * `Last-Event-ID` to resume while the session runs; a session that ended sends its terminal event alone.
516
+ * `Last-Event-ID` to resume while the session runs; a session that ended sends its terminal event alone. A
517
+ * session of a personal agent (`Agent.owner`, planned) is streamed only by the agent's owner, since its
518
+ * `session.output` carries the turn's `harness.*` events (`403 harness_personal_agent`).
227
519
  *
228
520
  * `GET /v1/agents/sessions/{session_id}/events` · scope `agents:read` · served by the node
229
521
  */
@@ -233,11 +525,33 @@ class AgentsAPI extends namespace_ts_1.Namespace {
233
525
  reconnectOnEnd: true,
234
526
  });
235
527
  }
528
+ /**
529
+ * Steer a running harness turn
530
+ *
531
+ * Adds `text` to the turn while it runs, past the instance's queue: the harness reads it at its next step
532
+ * (opencode as a `steer` prompt, Codex with `turn/steer`, pi with `steer`, Claude Code as a user message on its
533
+ * input). The session's stream shows it as `harness.turn.started` with `source: steer`. Only for an agent
534
+ * with a `harness` block (`409 harness_required` otherwise), and only while the session is delivered and
535
+ * running: a queued or ended session answers `409 no_turn_running`. A steer that arrives after delivery but
536
+ * before the harness has started the turn is held by the harness's shim and given to the turn as it starts. To
537
+ * start a new turn, send a message. A harness that refuses the text answers `502 harness_error`, and a kind
538
+ * whose driver cannot steer (`capabilities.steer: false` in `GET /v1/agents/harnesses`) answers `422
539
+ * harness_capability_unsupported`. On a personal agent only the owner steers (`403 harness_personal_agent`).
540
+ * Planned: not served on the beta node yet.
541
+ *
542
+ * `POST /v1/agents/sessions/{session_id}/steer` · scope `agents:run` · served by the node
543
+ *
544
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
545
+ */
546
+ steerSession(sessionId, body, options) {
547
+ return this._client._call(steerSessionOp, { path: [sessionId], body }, options);
548
+ }
236
549
  /**
237
550
  * Delete an agent
238
551
  *
239
- * Deletes the agent and every instance of it: their microVMs, memory snapshots and disks. Their sessions stay
240
- * readable until they expire.
552
+ * Deletes the agent and every instance of it: their microVMs, memory snapshots and disks, with any sign-in
553
+ * made in them. Their sessions stay readable until they expire. A personal agent is deleted by its owner or an
554
+ * organization admin (`403 harness_personal_agent` for anyone else).
241
555
  *
242
556
  * `DELETE /v1/agents/{agent}` · scope `agents:write` · served by the node
243
557
  */
@@ -247,7 +561,11 @@ class AgentsAPI extends namespace_ts_1.Namespace {
247
561
  /**
248
562
  * Get an agent
249
563
  *
250
- * The agent, by name or `agt_` ID, with its current revision and how many instances it has.
564
+ * The agent, by name or `agt_` ID, with its current revision and how many instances it has. A harness agent
565
+ * (planned) also has its `harness` block as the node stored it (shorthands expanded, `mcp` and `skills` as
566
+ * written, so it can be sent back as it is; the merged lists are those maps over `checks.defaults` in `GET
567
+ * /v1/agents/harnesses`), its `owner`, the state of its revision's prepared snapshot (`harness_prepared`), and
568
+ * its `entry`, `source`, `api`, `egress` and `turns` show what the node filled in from it.
251
569
  *
252
570
  * `GET /v1/agents/{agent}` · scope `agents:read` · served by the node
253
571
  */
@@ -263,6 +581,18 @@ class AgentsAPI extends namespace_ts_1.Namespace {
263
581
  * earlier revision again from this one at its next wake, which ends its memory and disk. `name` cannot change.
264
582
  * The grant is checked again against your own scopes.
265
583
  *
584
+ * `harness` (planned) replaces the whole block, as `entry` does; a harness is pinned to the revision, so a new
585
+ * `version` reaches an instance only through `upgrade: on_wake`, and only once the new revision's prepared
586
+ * snapshot is ready. `on_wake` remakes the instance, so its sign-ins and its harness sessions end with its disk.
587
+ * A change to start-time members only (`instructions`, `settings`, `mcp` entries, `files`, `auth`, `model`,
588
+ * `permissions` and the like) keeps the revision's prepare key, so nothing is built again. An agent made with
589
+ * `entry` cannot take a `harness`, and a harness agent cannot take an `entry` (`400 invalid_request`): make
590
+ * another agent.
591
+ *
592
+ * Only the owner changes a personal agent (`403 harness_personal_agent`). Adding a `signin` profile to an agent
593
+ * that is not personal is `409 harness_signin_not_personal`: make a personal agent from the same block
594
+ * instead.
595
+ *
266
596
  * `PATCH /v1/agents/{agent}` · scope `agents:write` · served by the node
267
597
  */
268
598
  updateAgent(agent, body, options) {
@@ -283,7 +613,9 @@ class AgentsAPI extends namespace_ts_1.Namespace {
283
613
  *
284
614
  * Deletes the instance: its microVM, its memory snapshot and its disk. Queued messages end `canceled` and are
285
615
  * never delivered. This and deleting the agent are the only ways an instance ends; idleness never does. The
286
- * next message to the key makes a new instance unless it sends `create: false`.
616
+ * next message to the key makes a new instance unless it sends `create: false`. An instance of a personal agent
617
+ * (`Agent.owner`, planned), with any sign-in made in it, is deleted by the agent's owner or an organization
618
+ * admin (`403 harness_personal_agent` for anyone else).
287
619
  *
288
620
  * `DELETE /v1/agents/{agent}/instances/{key}` · scope `agents:write` · served by the node
289
621
  */
@@ -311,13 +643,41 @@ class AgentsAPI extends namespace_ts_1.Namespace {
311
643
  * agent's current revision. Two requests for a new key at once make one instance.
312
644
  *
313
645
  * Each instance is its own microVM: instances of different keys never share one. The key is stored and shown as
314
- * written, so never use a credential or a personal detail as a key.
646
+ * written, so never use a credential or a personal detail as a key. Only the owner makes or wakes an instance
647
+ * of a personal agent (`403 harness_personal_agent`).
315
648
  *
316
649
  * `PUT /v1/agents/{agent}/instances/{key}` · scope `agents:run` · served by the node
317
650
  */
318
651
  putInstance(agent, key, body, options) {
319
652
  return this._client._call(putInstanceOp, { path: [agent, key], body }, options);
320
653
  }
654
+ /**
655
+ * Answer any permission request of an instance
656
+ *
657
+ * Answers a question the instance's harness waits on, whichever way its turn came: a message (a session), or a
658
+ * turn typed in the terminal or started inside the instance. The body, the answer and the errors are those of
659
+ * `POST /v1/agents/sessions/{session_id}/decisions`; `request` is unique per instance, so this route answers
660
+ * any question of the instance, a session's included. The live view answers every question here, since an event
661
+ * without `session_id` has no session to answer through. The answer is recorded as
662
+ * `harness.permission.resolved` with `by: person`.
663
+ *
664
+ * Claude Code's own permission prompts in `terminal` mode are answered in its TUI, not here (their
665
+ * `harness.permission.requested` carries no `request`).
666
+ *
667
+ * A question of a session is denied when its turn reaches its timeout; one of a turn without a session is denied
668
+ * after an hour (the most a turn may take). A question still open when its turn ends is withdrawn
669
+ * (`harness.permission.resolved` with `by: withdrawn`). A question already answered, or one the instance never
670
+ * asked, answers `404 decision_not_found`. On a personal agent only the owner answers (`403
671
+ * harness_personal_agent`). Only for an agent with a `harness` block (`409 harness_required`). Planned: not
672
+ * served on the beta node yet.
673
+ *
674
+ * `POST /v1/agents/{agent}/instances/{key}/decisions` · scope `agents:run` · served by the node
675
+ *
676
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
677
+ */
678
+ sendInstanceDecision(agent, key, body, options) {
679
+ return this._client._call(sendInstanceDecisionOp, { path: [agent, key], body }, options);
680
+ }
321
681
  /**
322
682
  * List an instance's lifecycle events
323
683
  *
@@ -332,6 +692,60 @@ class AgentsAPI extends namespace_ts_1.Namespace {
332
692
  listInstanceEvents(agent, key, params, options) {
333
693
  return this._client._list(listInstanceEventsOp, { path: [agent, key], query: params }, options);
334
694
  }
695
+ /**
696
+ * List an instance's grants
697
+ *
698
+ * The instance's grants that have not ended, newest first, without their tokens (`token` and `url` are
699
+ * `null`). A personal agent's grants are listed by its owner or an organization admin (`403
700
+ * harness_personal_agent` for anyone else). Planned: not served on the beta node yet.
701
+ *
702
+ * `GET /v1/agents/{agent}/instances/{key}/grants` · scope `agents:read` · served by the node
703
+ *
704
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
705
+ */
706
+ listGrants(agent, key, params, options) {
707
+ return this._client._list(listGrantsOp, { path: [agent, key], query: params }, options);
708
+ }
709
+ /**
710
+ * Share an instance's terminal by link
711
+ *
712
+ * Mints a grant: a link that opens this instance's live view and terminal for whoever holds it, without a B3OS
713
+ * account. `watch` shows the event stream and the terminal, view-only; `control` also types into the terminal
714
+ * when nobody else holds control, and never takes it over. The link carries its token in the URL fragment
715
+ * (`#token=`), which browsers never send to a server, so it stays out of every log on the way; the share page
716
+ * redeems it (`agentsRedeemGrant`). `token` and `url` are in this answer only: B3OS keeps a hash of the token.
717
+ *
718
+ * A grant ends at `expires_at` (`ttl_s`, 900 seconds by default, at most 3,600), after `uses` redemptions when
719
+ * set, when it is revoked (`DELETE …/grants/{grant_id}`), or when the instance is deleted; revoking it closes
720
+ * the sockets opened with it. The share page redeems the link again each time it reconnects, and each
721
+ * redemption counts one of `uses`: leave `uses` out, or set it to cover the reconnects you expect. An instance
722
+ * has at most `agents.grants_max` grants that have not ended; one more is `422 limit_exceeded`. On a personal
723
+ * agent only the owner mints grants, and only `watch` ones (`403 harness_personal_agent`): a `watch` grant never
724
+ * shows the sign-in window. Only for an agent with a `harness` block (`409 harness_required`). Planned: not
725
+ * served on the beta node yet.
726
+ *
727
+ * `POST /v1/agents/{agent}/instances/{key}/grants` · scope `agents:write` · served by the node
728
+ *
729
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
730
+ */
731
+ createGrant(agent, key, body, options) {
732
+ return this._client._call(createGrantOp, { path: [agent, key], body }, options);
733
+ }
734
+ /**
735
+ * Revoke a grant
736
+ *
737
+ * Ends the grant: its link stops working, and the terminal and event-stream sockets opened with it close.
738
+ * Revoking a grant that already ended answers `404 grant_not_found`. A personal agent's grants are revoked by its
739
+ * owner or an organization admin (`403 harness_personal_agent` for anyone else). Planned: not served on the beta
740
+ * node yet.
741
+ *
742
+ * `DELETE /v1/agents/{agent}/instances/{key}/grants/{grant_id}` · scope `agents:write` · served by the node
743
+ *
744
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
745
+ */
746
+ deleteGrant(agent, key, grantId, options) {
747
+ return this._client._call(deleteGrantOp, { path: [agent, key, grantId] }, options);
748
+ }
335
749
  /**
336
750
  * Send a message to an instance
337
751
  *
@@ -366,6 +780,28 @@ class AgentsAPI extends namespace_ts_1.Namespace {
366
780
  * `Server-Timing` and the session's `timing` split the turn into `queue`, `wake` (`desc` names the tier),
367
781
  * `deliver` and `harness`.
368
782
  *
783
+ * For an agent with a `harness` block (planned), `text` is the prompt and `context` (optional) is added before
784
+ * the model sees it, quoted as information rather than an instruction. `conversation` names the harness's own
785
+ * session (an opencode session, a Codex thread, a pi session file, a Claude Code session): the first message of
786
+ * a new `conversation` starts a new harness session, and later ones continue it. `profile` picks one of the
787
+ * definition's credential profiles for this turn and the conversation's next ones (`harness.auth`); a name the
788
+ * definition does not have is `400 harness_profile_unknown`. A harness agent's message is closed: a member
789
+ * other than the reserved ones, `text`, `context`, `profile` and a listener's `event` is `400
790
+ * invalid_request`, so a field the harness would not read is refused rather than dropped. `text` is required,
791
+ * but in a listener's message (`type: listener.event`), which carries `event` instead and which the harness is
792
+ * to see quoted whole as information; until the harness's shim quotes it, a `listener.event` message to a
793
+ * harness agent is `422 harness_capability_unsupported`, and `event` in any other message is `400
794
+ * invalid_request`. Each
795
+ * `session.output` carries one `AgentHarnessEvent`, as the node wrote it to the instance's event log, and the
796
+ * turn's `result` is `harness.turn.completed`'s `result`. The session ends `succeeded` at
797
+ * `harness.turn.completed`, `canceled` at `harness.turn.interrupted`, and `failed` with `harness_error` at
798
+ * `harness.turn.failed` or when the harness's stream ends without one of the three, or with
799
+ * `harness_prepare_failed` when the revision's prepared snapshot could not be built.
800
+ *
801
+ * A personal agent (`Agent.owner`) takes messages only from its owner's own principals (their dashboard
802
+ * session, their CLI token, and routines they made); anyone else, and every listener, gets `403
803
+ * harness_personal_agent`.
804
+ *
369
805
  * `POST /v1/agents/{agent}/instances/{key}/messages` · scope `agents:run` · served by the node
370
806
  */
371
807
  sendMessage(agent, key, body, options) {
@@ -376,21 +812,172 @@ class AgentsAPI extends namespace_ts_1.Namespace {
376
812
  *
377
813
  * Sends the instance to a sleep tier now instead of waiting for its timers: `ram` pauses it, `snapshot` writes
378
814
  * its memory snapshot and frees its memory (an instance with a volume answers `409 volume_attached` and stays as
379
- * it was). A harness may call this on its own instance when it knows it is done
815
+ * it was). The snapshot's write takes longer the more memory the instance has (seconds to minutes for 4 GiB on
816
+ * a slow drive), and the call does not wait for all of it: it answers `200` with the instance `hibernated` when
817
+ * the write is done within about 2 seconds, else `202` with the instance `paused` and the write going on. It
818
+ * reads `hibernated` once the write is committed; a write that fails leaves it `paused`, and its timers try the
819
+ * snapshot again later. A harness may call this on its own instance when it knows it is done
380
820
  * (from inside, at `http://127.0.0.1:7700`); the pause then happens once its current turn ends. An instance with
381
821
  * a turn running or messages queued goes to sleep after them. Asleep already in that tier or a deeper one:
382
- * returned unchanged.
822
+ * returned unchanged. An instance of a personal agent (`Agent.owner`, planned) is put to sleep by the agent's
823
+ * owner or by itself, from inside (`403 harness_personal_agent` for anyone else).
383
824
  *
384
825
  * `POST /v1/agents/{agent}/instances/{key}/sleep` · scope `agents:run` · served by the node
385
826
  */
386
827
  sleepInstance(agent, key, body, options) {
387
828
  return this._client._call(sleepInstanceOp, { path: [agent, key], body }, options);
388
829
  }
830
+ /**
831
+ * Stream an instance's harness events
832
+ *
833
+ * Server-sent events: every `harness.*` event of the instance, whichever way its turn came (a message, a turn
834
+ * typed in the terminal or started inside the instance, a steer), as `AgentHarnessEvent`s. This is what the live view reads.
835
+ * Each event's SSE `id` is its `seq`, which the node assigns as it writes the event to the instance's log, so it
836
+ * keeps growing when the harness's shim restarts; reconnect with `Last-Event-ID` to resume after it. Events are
837
+ * kept 7 days for replay, as every product event is, and at most `agents.harness_event_log_mib` per instance,
838
+ * past which the oldest go first; a stream that resumes past what is kept starts from the oldest kept event.
839
+ * `harness.message` events with `delta: true` get a `seq` too, but are streamed and never kept. The node
840
+ * serves the stream from its own copy of the events, so opening it neither wakes the instance nor keeps it
841
+ * awake.
842
+ *
843
+ * Authenticate with the `Authorization` header, the dashboard session, or a ticket (`POST …/ticket`, or a
844
+ * grant's from `agentsRedeemGrant`). On a personal agent, only the owner and the owner's `watch` grants read
845
+ * it (`403 harness_personal_agent`). Only for an agent with a `harness` block (`409 harness_required`).
846
+ * Planned: not served on the beta node yet.
847
+ *
848
+ * `GET /v1/agents/{agent}/instances/{key}/stream` · scope `agents:read` · served by the node
849
+ *
850
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
851
+ */
852
+ streamInstance(agent, key, options) {
853
+ return this._client._stream(streamInstanceOp, { path: [agent, key] }, options, {});
854
+ }
855
+ /**
856
+ * Open a harness's terminal
857
+ *
858
+ * Opens the harness's terminal over a WebSocket: the harness's own TUI in `terminal` mode, a shell in the
859
+ * workspace in `api` mode (the live view shows the events beside it). tmux in the instance holds the terminal,
860
+ * so it outlives every socket and a restart of the harness's shim. The node reaches it through the instance's
861
+ * port proxy: opening it wakes a sleeping instance, and an open socket keeps the instance awake. When the last
862
+ * socket closes and the harness is idle, the instance sleeps on its timers with the terminal paused in memory.
863
+ *
864
+ * The wire is the sandbox terminal's (`sandboxesOpenPty`) with a cursor added. Binary frames carry terminal
865
+ * bytes both ways; input counts only from the controller. Text frames carry JSON. The server's first frame is
866
+ * `{"type": "session", "id": "pts_…", "resumed": true, "cursor": 1048576, "role": "view", "cols": 120, "rows":
867
+ * 40}`, then one binary frame with what the socket missed, then live output. The client sends `{"type":
868
+ * "resize", "cols", "rows"}` (controller only), `{"type": "control"}` to ask for control, `{"type": "release"}`,
869
+ * and `{"type": "end"}` (controller only: ends the terminal, and the TUI with it). The server sends `{"type":
870
+ * "role", "role", "reason"}` when this socket's role changes, `{"type": "error", "code": "controller_active"}`
871
+ * when another socket holds control, and `{"type": "exit", "code"}` before it closes.
872
+ *
873
+ * One controller, any number of viewers. `role=control` takes control when nobody holds it, and needs
874
+ * `agents:run` besides this operation's `agents:read`; when another socket holds it, this one opens as `view`
875
+ * (its first frame says so). Only the agent's owners take control from the holder, with `{"type": "control",
876
+ * "takeover": true}`: a credential that holds `agents:write`, never a grant. The holder stays as a viewer and
877
+ * gets `{"type": "role", "role": "view", "reason": "taken over"}`.
878
+ *
879
+ * Reconnect where you left off: the terminal's output is kept in a 1 MiB ring indexed by byte offset. Send the
880
+ * `session` and the `cursor` (the session frame's `cursor` plus the bytes received since), and the socket
881
+ * replays the bytes it missed. Past the ring, or when the terminal was started again (another `session`), it
882
+ * draws the current screen and goes on live. A socket lasts at most an hour; reconnect with the cursor.
883
+ *
884
+ * Every attach and detach is a `harness.terminal.attached` or `harness.terminal.detached` event. With
885
+ * `harness.terminal.record`, the terminal is also written as a recording (`…/terminal/recordings`).
886
+ * Authenticate with the `Authorization` header, the dashboard session, or a ticket (`POST …/ticket`, or a
887
+ * grant's from `agentsRedeemGrant`) as `?ticket=` or the `b3os.ticket.<ticket>` subprotocol. Only for an agent
888
+ * with a `harness` block (`409 harness_required`). Planned: not served on the beta node yet.
889
+ *
890
+ * The sign-in window (`window=signin:<profile>`) is where a personal agent's owner signs in to their own plan
891
+ * for a `signin` profile: the harness's own login runs there (`codex login --device-auth`, `claude auth login`;
892
+ * a kind signs in only to the plans its `auth.signin` in `GET /v1/agents/harnesses` lists), under that profile's
893
+ * directory, and writes the harness's own credential file in the instance. B3OS never reads that file, and the
894
+ * shim reports only that it exists (`harness.auth.ready`, with what the harness says about its plan). The
895
+ * sign-out window (`window=signout:<profile>`) runs the harness's own logout for the profile the same way, and
896
+ * `harness.auth.removed` (`reason: signed_out`) says when the file is gone. Either window opens only for the
897
+ * owner, on a `signin` profile of the definition (`403 harness_personal_agent` or `400 harness_profile_unknown`
898
+ * otherwise), and a sign-in to a Claude plan's profile (`provider: anthropic`) only with
899
+ * `agents.claude_plan_signin` on (`403 harness_claude_plan_signin_disabled`); a sign-out needs no flag. It is
900
+ * never sent to a viewer or a grant's socket, it is never recorded, and what it showed is dropped when it
901
+ * closes. On a personal agent the main window too is the owner's: others see it only through a `watch` grant,
902
+ * and `control` grants are refused. Until personal agents are served (`AgentHarnessAuthSignin` names what they
903
+ * wait on), no agent has a `signin` profile, so neither window opens.
904
+ *
905
+ * The node opens the shim's terminal with the shim's token in place of your credential, and says what it
906
+ * checked in headers only it may set (`x-b3os-window`, `x-b3os-takeover`), which it removes from every request
907
+ * it forwards (packages/spec/sidecars/harness.md).
908
+ *
909
+ * `GET /v1/agents/{agent}/instances/{key}/terminal` · scope `agents:read` · served by the node
910
+ *
911
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
912
+ */
913
+ async openTerminal(agent, key, params, options = {}) {
914
+ const { url, protocols } = await (0, ws_ts_1.ticketedUrl)(this._client, openTerminalOp, createTicketOp, { path: [agent, key], query: params }, options, false);
915
+ return new ws_ts_1.PtySession(await (0, ws_ts_1.openSocket)(url, protocols, options.signal));
916
+ }
917
+ /**
918
+ * List an instance's terminal recordings
919
+ *
920
+ * The instance's terminal recordings, newest first. A terminal is recorded only when the definition sets
921
+ * `harness.terminal.record: true`; it is off by default, because a recording keeps whatever the terminal showed,
922
+ * codes and keys printed in it included. Each start of a conversation's terminal begins a new recording, an
923
+ * asciicast v3 file on the instance's own disk with one header, with a marker (`m`) at each `harness.*` event
924
+ * but `harness.message`, so a player can jump to a turn. One that reaches 64 MiB while it is written is closed
925
+ * and the next one begins; a conversation keeps its current recording and the one before it. Deleting the
926
+ * instance deletes them. The node reads them from the harness's shim through the instance's port, so reading
927
+ * the list wakes the instance as a port request does. The sign-in window is never recorded. On a personal agent
928
+ * only the owner reads them (`403 harness_personal_agent`). Only for an agent with a `harness` block (`409
929
+ * harness_required`). Planned: not served on the beta node yet.
930
+ *
931
+ * `GET /v1/agents/{agent}/instances/{key}/terminal/recordings` · scope `agents:read` · served by the node
932
+ *
933
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
934
+ */
935
+ listRecordings(agent, key, params, options) {
936
+ return this._client._list(listRecordingsOp, { path: [agent, key], query: params }, options);
937
+ }
938
+ /**
939
+ * Download a terminal recording
940
+ *
941
+ * The recording as an asciicast v3 file (`application/x-asciicast`, one JSON value per line): a header, then
942
+ * `[seconds since the previous event, code, data]` with codes `o` (output), `r` (resize, `"COLSxROWS"`), `m`
943
+ * (a marker, the `harness.*` event's type) and `x` (exit status). Input is never recorded. asciinema 3 plays
944
+ * it. Planned: not served on the beta node yet.
945
+ *
946
+ * `GET /v1/agents/{agent}/instances/{key}/terminal/recordings/{recording_id}` · scope `agents:read` · served by the node
947
+ *
948
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
949
+ */
950
+ getRecording(agent, key, recordingId, options) {
951
+ return this._client._call(getRecordingOp, { path: [agent, key, recordingId] }, options, "*/*", "bytes");
952
+ }
953
+ /**
954
+ * Create a stream ticket for an instance
955
+ *
956
+ * Returns a single-use ticket, valid for 30 seconds, that opens one stream of this instance without a bearer
957
+ * header: its terminal (`GET …/terminal`) or its event stream (`GET …/stream`). Pass it as `?ticket=` or in
958
+ * `Sec-WebSocket-Protocol: b3os.v1, b3os.ticket.<ticket>`. The stream runs with this caller's scopes, so a
959
+ * terminal opened with it takes control only when the caller holds `agents:run`.
960
+ *
961
+ * The ticket's `resource` is this request's own path without `/ticket`, exactly as it was sent: the agent as you
962
+ * named it (its name or its `agt_` ID) and the key percent-encoded as in the request. A ticket is matched
963
+ * against the stream's path as sent, so open the stream with the same form: a ticket minted under the agent's
964
+ * name does not open its stream under its ID. On a personal agent only the owner mints tickets (`403
965
+ * harness_personal_agent`): others watch through a `watch` grant the owner shares. Only for an agent with a
966
+ * `harness` block (`409 harness_required`). Planned: not served on the beta node yet.
967
+ *
968
+ * `POST /v1/agents/{agent}/instances/{key}/ticket` · scope `agents:read` · served by the node
969
+ *
970
+ * Stretch: in the contract, but may answer `501 not_implemented` on this deployment.
971
+ */
972
+ createTicket(agent, key, options) {
973
+ return this._client._call(createTicketOp, { path: [agent, key] }, options);
974
+ }
389
975
  /**
390
976
  * List an agent's sessions
391
977
  *
392
978
  * Lists the agent's sessions, newest first. Filter by instance `key`, by `conversation` (the ID you sent with the
393
- * message, or the `b3os.conversation` baggage of `b3.traces.turn`) or by `status`.
979
+ * message, or the `b3os.conversation` baggage of `b3.traces.turn`) or by `status`. A personal agent's sessions
980
+ * (`Agent.owner`, planned) are listed only for its owner (`403 harness_personal_agent`).
394
981
  *
395
982
  * `GET /v1/agents/{agent}/sessions` · scope `agents:read` · served by the node
396
983
  */