@nylorun/core 0.23.0-beta → 0.24.0-beta

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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @nylorun/core
2
2
 
3
+ ## 0.24.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - 218b078: Agent manifest v8, the schema of protocol 16 (track T2), ahead of the Runtime that saves it: `AgentManifestV8Schema`, with a `harness` section (what runs inside the loop: the harness id, instructions, tools, skills with the secret slots they read, MCP servers with the slot they authenticate with, plugins, `loop`) or a flow's, and a `runtime` section (environment manifest v1's fields; `kind` required, `harness` moved to `harness.id`, `triggers` reserved). The authoring files `nylorun apply` will read have their own schemas: `AgentManifestFileSchema`, `HarnessManifestFileSchema` and `RuntimeManifestFileSchema`, published as `@nylorun/core/schemas/agent-manifest-v8.json`, `harness-manifest.json` and `runtime-manifest.json`.
8
+
9
+ `sectionGaps(manifest)` (from `@nylorun/core/define`) checks the two sections against each other, as the Runtime will when a manifest is saved: a custom harness needs a pod with an image; every credential the harness names is a declared slot of the right type (an MCP server's or HTTP tool's a `bearer` or `headers` slot bound to its URL, a skill's `secrets` an `environment_secret` or `environment_variable` slot); and the runtime's kind gives the loop the sandbox it needs (`sandboxNeedOf`). `loopManifestOf` and `harnessSectionOf` convert between a version's harness section and the loop manifest the engine runs. Nothing calls them yet.
10
+
11
+ - 22c61ce: Protocol 16, Agents from one manifest (track T2), a fresh start. An agent manifest (v8) is one versioned document at `/v1/agent-manifests/{name}` with a `harness` section (what runs inside the loop, including the harness's id) and a `runtime` section (what an environment manifest said). The Runtime checks the two against each other when it is saved (`422 manifest_inconsistent` with `details.gaps`), in place of `requires` at session open. Agent definitions and environment manifests are gone.
12
+
13
+ Environments are Agents: `/v1/agents/{id}` and its sub-routes, made from a saved manifest only (`manifest: "name"` tracks it, `"name@n"` pins a version; either resolves once, into `resolvedVersion`), with a derived `state` (`working`, `sleeping`, `input_required`, `failing`, `paused`) and `attention`. Every session runs on one Agent (`PUT /v1/sessions/{id} { agent, ownerUserId }`) and pins its manifest version. No session is special (D71). Error codes, events (`agent.*`), scopes (`agents:write`, `agent-manifests:write`) and identity-file grants (`agents`) say Agent; model budget scope `agent` is `manifest`. Harness API 5: `turn.start.agent` replaces `turn.start.environment`, with `definition` and `loop`. Migration 0032 closes older sessions (`protocol_16`) and drops Environments with their disks and vaults.
14
+
15
+ The SDK has `client.agentManifests`, `client.agents` and `composeManifest(dir)` for three-file authoring; the CLI has `nylorun apply`, `nylorun agent-manifests`, `nylorun agents` and `nylorun migrate v8`; Studio has an Agents screen, an Agent page and an Agent manifests screen. See MIGRATION.md.
16
+
17
+ - 1ded443: Track T3, Agents that evolve: an Agent moves between versions of its manifest in place, with its id, disk, vault and sessions. `PUT /v1/agents/{id}` with another version moves it (`?dryRun=true` answers the plan, `AgentMovePlan`), and saving a manifest moves every Agent that tracks it. A harness-only change applies at once; a runtime change a pod applies only when it starts (image, resources, network, setup, files) leaves the Agent outdated (`targetVersion`, `waitingFor: "start"`) until its pod's next start, on the same volume; a version that adds a required secret waits for its value (`waitingFor: "secrets"`, state `input_required`). Its manifest's name, kind, harness and storage are fixed: `409 agent_fixed_field` replaces `409 agent_upgrade_unavailable`. Only secrets that fill a slot of the running version are used; others stay in the vault, dormant. New events `agent.outdated` and `agent.version_changed`, `GET /v1/agents?outdated=true`, and the save plan's `moves` and `agents_move` warning. Migration 0033 adds the Agent's target and failed versions and its start check.
18
+ - 76dcd11: Track T3, the next start and its check: a pod Agent's start on a new version is checked until the new pod's harness joins (`startCheck` on the Agent). A failed setup, a failed pod, or a start slower than the Host's `tenant.upgradeStartMs` (10 minutes) takes the Agent back to the version it ran, its definition and not its disk, records `agent.start_failed`, and names the version `failedVersion` (state `failing`), which a tracking Agent does not move to again. A new version's setup runs on the same volume when its commands or files changed (`setupHash` in the setup plan and the volume's marker). While a pod waits to start on a new version it idles at most `tenant.upgradeIdleMs` (1 minute). `POST /v1/agents/{id}/restart` applies a pending version now; `retry: true` tries the failed version again.
19
+ - bf942ed: Our engine offers the `memory` tool (track T5, D72). An agent whose version sets `harness.memory` gets one `memory` tool with Anthropic's memory tool schema (`view`, `create`, `str_replace`, `insert`, `delete`, `rename`; `view` only for a `read_only` agent and an agent used as a tool), our memory rules followed by the agent's `instructions`, and its memory index pinned after the instructions as user-role context: kept for the session so the prompt prefix stays cacheable (`ExecutionState.pinned`), and re-pinned after a compaction. Each command's parameters are checked before a call is sent (`checkMemoryCall` in `@nylorun/core/contracts`, which the Runtime also uses), and a call named `memory.<command>` or `memory/<command>` runs as `memory` with that command (`memoryAliasOf`). `ModelRequest.pinned` carries the pinned text; `memoryTool` and `memoryIndexBlock` are exported for your own harness.
20
+ - 4fa160d: Agent memory, storage and API (track T5, D72). An agent manifest's `harness.memory` (`access`: `read_write` or `read_only`; `instructions`, at most 4,096 characters) turns on the Agent's memory: Markdown files under `/memories` it keeps across sessions, wakes and upgrades. The Runtime keeps them in Postgres (`memories`, `memory_versions`, migration 0036) with a version per change and who made it. `GET /v1/agents/{id}/memories` lists them (`pathPrefix`), `GET`, `PUT` (whole content, with an optional `contentSha256` precondition: `409 memory_conflict`) and `DELETE /v1/agents/{id}/memories/{path}` read, write and delete one (or a folder), and `GET /v1/agents/{id}/memory_versions` and `.../memory_versions/{versionId}` page the versions. A fork copies the memories (the fork plan adds `memories`); a delete removes them. `@nylorun/core` adds `memoryPathOf`, `memoryDescriptionOf` and the memory contracts; new Runtime limits `memoryBytes` (100 KB) and `memoriesPerAgent` (10,000); new error code `memory_conflict`. The SDK adds `client.agents.memories`; the CLI adds `nylorun agents memories ls|cat|put|rm|versions`. The model's `memory` tool arrives in the next steps of T5.
21
+ - 9fed948: The `memory` tool's calls (track T5, D72). A new effect target, `{kind: "runtime", operation: "memory"}` (additive on Harness API 5), carries Anthropic's memory tool input (`command`: `view`, `create`, `str_replace`, `insert`, `delete`, `rename`, and its parameters); core serves it in the intent's own transaction, so a replayed turn applies a write once. A malformed call fails with text for the model and changes nothing; a write from a `read_only` agent or a sub-agent is `memory.forbidden`. Each write is a memory version naming the turn's manifest version, session, turn and the trigger run that started the turn, with a new session event `memory.updated` and Agent event `agent.memory_updated`. `turn.start.memory` (`TurnMemorySchema`) carries the Agent's memory access, instructions and the index a harness pins, newest first, within the new Runtime limits `memoryIndexLines` (200) and `memoryIndexBytes` (25 KiB).
22
+ - ffeb3bb: `schedule_wake` (track T4, D77). An agent manifest's `runtime.selfWake: true` offers the agent `schedule_wake`: `{in | at, note}` books its session's next turn, replacing the booking before, and `{cancel: true}` removes it. The Runtime serves the call in its own transaction (a new effect target, `{kind: "runtime", operation: "schedule_wake"}`, additive on Harness API 5; `turn.start.agent.selfWake` tells a harness to offer it), so a replayed turn books once. The booking fires as a trigger run of kind `wake`, its note the turn's message with `cause.kind: "self"`. New session events `wake.booked` and `wake.cancelled`, tool call kind `runtime`, and Runtime limits `wakeMaxAheadMs` and `wakeNoteChars`.
23
+ - 9e60e40: Protocol 17, a queue per session (track T4, D76). A message sent while the session's turn runs or waits is queued (`{status: "queued", queuedMessageId, position}`, `message.queued`) and starts the next turn when this one ends, with every queued message, each its own user message (`queue.taken`); a cancel ends the turn, not the queue. `delivery: "reject"` keeps the refusal, now `409 session_busy`, and a protocol 16 client's messages default to it, so the Host serves protocol 16 and 17. The queue holds at most the Runtime limit `sessionQueuedMessages` (`429 queue_full`), and session reads count `queuedMessages`. Our engine takes `{kind: "messages", messages}` as a turn's input. The SDK's `input` and `inputParts` take `delivery`, and the CLI's `sessions send` takes `--reject-if-busy`. See MIGRATION.md.
24
+ - f85483d: Triggers (track T4, D74). An agent manifest's `runtime.triggers` declares `schedule` (cron with an IANA `timezone`) and `at` triggers, each with the session its runs go to (a session id, opened on the first run, or `new` for a session per run) and its prompt. They start active with a new Agent, fire on a durable timer per trigger with Postgres as the truth (one late fire after downtime, never a backfill, a fixed jitter per trigger), and each fire is a run (`started`, `queued`, `skipped` or `failed`, with a reason) at `GET /v1/agents/{id}/runs`. A schedule adds at most one queued message to a busy session. `GET /v1/agents/{id}/triggers` and `POST .../triggers/{triggerId}/pause`, `/resume` and `/run` (with an `Idempotency-Key`); Agent reads add `nextWakeAt`, and the Agent's stream adds `agent.run`, `agent.trigger_paused` and `agent.trigger_resumed`. New Runtime limits: `triggersPerAgent`, `triggerMinIntervalMs` and `triggerRunRetentionMs` (with floors), `triggerRunsPerHour`, `triggerJitterPercent`, `triggerJitterMaxMs`, `triggerPromptChars`; Host tuning `triggers.lateGraceMs` and `triggers.intervalCheckFires`. The SDK's `client.agents` adds `triggers`, `pauseTrigger`, `resumeTrigger`, `runTrigger` and `runs`; the CLI adds `nylorun agents triggers` and `nylorun agents runs`.
25
+ - ae54de7: Webhook triggers (track T4, D75). A `webhook: "standard-webhooks"` trigger has an endpoint, `POST /v1/webhooks/{endpointId}`, an anonymous, unversioned route that takes any body up to the new Runtime limit `webhookBodyBytes` and verifies Standard Webhooks (`webhook-id`, `webhook-timestamp` within the Host's `triggers.webhookToleranceMs`, `webhook-signature`) in the keys service, which alone opens the trigger's sealed secret; anything else is `401` and writes nothing. A delivery runs the trigger once per `webhook-id` (`202 {runId, status}`); a paused trigger answers a signed one `409 trigger_paused`. `POST /v1/agents/{id}/triggers/{triggerId}/secret` makes or replaces the `whsec_` secret, shown once (`agent.trigger_secret_rotated`); trigger reads show `webhookUrl` and `secretSet`. The payload reaches the model under the trigger's prompt in a labelled `<trigger-payload>` block. The SDK adds `agents.rotateWebhookSecret`, and the CLI `nylorun agents triggers new-secret`.
26
+
3
27
  ## 0.23.0-beta
4
28
 
5
29
  ### Minor Changes
@@ -1,5 +1,36 @@
1
1
  export { hashManifest } from "./utils/hash.js";
2
2
  /**
3
+ * Protocol 17: a queue per session (track T4, D76). A message sent while the session's turn runs,
4
+ * or while it waits on an approval, an answer or an uncertain call, is queued
5
+ * (`{status: "queued", queuedMessageId, position}`, `message.queued`) instead of refused, unless
6
+ * it asks `delivery: "reject"`; the refusal now has a code, `409 session_busy`. When the turn ends
7
+ * (completed, failed or cancelled), every queued message starts one turn, in order, each its own
8
+ * user message (`queue.taken`); our engine's turn input for more than one is
9
+ * `{kind: "messages", messages}` (Harness API 5, additive). Past the Runtime limit
10
+ * `sessionQueuedMessages` a message is `429 queue_full`. Session reads count `queuedMessages`. The
11
+ * Host serves protocol 16 and 17: a message from a protocol 16 client is `reject` unless it says
12
+ * otherwise, so its sessions answer `409` as before.
13
+ * Protocol 16: Agents from one manifest (track T2), a fresh start. An agent manifest (v8) is one
14
+ * versioned document at `/v1/agent-manifests/{name}` with a `harness` section (what runs inside
15
+ * the loop, including the harness's id) and a `runtime` section (what an environment manifest
16
+ * said); the Runtime checks the two against each other when it is saved
17
+ * (`422 manifest_inconsistent`), so `requires` and `409 environment_unsuitable` are gone, and so
18
+ * are agent definitions (`PUT /v1/agents/:id` with a v7 manifest) and environment manifests.
19
+ * Environments are Agents: `/v1/agents/{id}` (with `.../events`, `stop`, `reset`, `snapshot`,
20
+ * `restore`, `versions`, `fork` and `secrets`) is made from a saved manifest only, records it as
21
+ * tracking (`name`) or pinned (`name@n`) into `resolvedVersion`, the version it runs. An Agent
22
+ * evolves (track T3, D73): a `PUT` naming another version of its manifest moves it (`dryRun`
23
+ * answers the plan), a save moves every Agent that tracks the manifest, and each turn takes the
24
+ * version its Agent runs when it starts; a runtime change waits for a pod's next start, and its
25
+ * kind, harness and storage are fixed (`409 agent_fixed_field`). Reads add `state`
26
+ * (`working`, `sleeping`, `input_required`, `failing`, `paused`) and `attention`, and the
27
+ * compute's state moves to `compute.state`. Every session belongs to one Agent:
28
+ * `PUT /v1/sessions/{id}` takes `{ agent, ownerUserId, info }` and pins the manifest version its
29
+ * Agent runs; no session is special (D71). Error codes, event types (`agent.*`), the scopes
30
+ * (`agents:write`, `agent-manifests:write`) and identity-file grants (`agents`) say Agent. Model
31
+ * budget scope `agent` is `manifest`. Harness API 5: `turn.start.agent` replaces
32
+ * `turn.start.environment`. Sessions opened before protocol 16 are closed (`protocol_16`) and
33
+ * stay readable; Environments, their disks and vaults are gone. The Host serves protocol 16 only.
3
34
  * Protocol 15: the harness boundary, a fresh start. Model-facing work belongs to the harness. Our
4
35
  * engine's `read_artifact` and `save_artifact` run in our harness, over the Harness API's new
5
36
  * artifact seam (`artifact.read`, `artifact.write`; Harness API 4), so a session's pinned
@@ -71,7 +102,7 @@ export { hashManifest } from "./utils/hash.js";
71
102
  * it. The Host still accepts protocol 4 (and `Nylorun-Tenant`), 5 and 6 clients on every route
72
103
  * that remains; a client that requires `action-endpoints` is refused by the feature check.
73
104
  */
74
- export declare const PROTOCOL_VERSION = 15;
105
+ export declare const PROTOCOL_VERSION = 17;
75
106
  /** What a client of this protocol requires of a Host. */
76
107
  export declare const PROTOCOL_FEATURES: readonly ["studio-principal", "artifacts",
77
108
  /**
@@ -86,13 +117,6 @@ export declare const PROTOCOL_FEATURES: readonly ["studio-principal", "artifacts
86
117
  * metadata at `/.well-known/oauth-protected-resource` when it has trusted issuers.
87
118
  */
88
119
  "resource-server",
89
- /**
90
- * Protocol 11: Environments (`/v1/environments/{id}`, kinds `virtual`, `pod` and `none`), each
91
- * with one vault written on the Runtime API; sessions name an `environment`; token callers
92
- * carry Environment grants checked at every turn start, and `environments:write` lets a
93
- * subject create, change and delete the Environments it is granted.
94
- */
95
- "environments",
96
120
  /** Protocol 12: the model catalog and provider list say which inputs each model reads. */
97
121
  "model-inputs",
98
122
  /**
@@ -101,19 +125,27 @@ export declare const PROTOCOL_FEATURES: readonly ["studio-principal", "artifacts
101
125
  * block, and tool calls, MCP servers and HTTP calls are named without capability ids.
102
126
  */
103
127
  "flat-manifest",
104
- /**
105
- * Protocol 14: environment manifests (`/v1/environment-manifests/{name}`), Environments made
106
- * from one version and never changed after creation, secret slots, and an agent manifest's
107
- * `requires`, checked when a session opens.
108
- */
109
- "environment-manifests",
110
128
  /**
111
129
  * Protocol 15: the harness boundary. `read_artifact` and `save_artifact` are our harness's
112
130
  * tools, not the Runtime's: a session's pinned `runtime` block no longer carries them, and an
113
131
  * author tool may take their names. MCP tools are named by the harness and identified by
114
132
  * `{server, tool}`: tool policy rules and approvals name them so.
115
133
  */
116
- "harness-boundary"];
134
+ "harness-boundary",
135
+ /**
136
+ * Protocol 16: agent manifests (`/v1/agent-manifests/{name}`, v8, with a harness and a runtime
137
+ * section checked against each other at save) and Agents (`/v1/agents/{id}`, kinds `virtual`,
138
+ * `pod` and `none`, each with one vault), made from one manifest version, with a derived
139
+ * `state`; every session runs on an Agent; token callers carry Agent grants checked at every
140
+ * turn start, and `agents:write` lets a subject create, change and delete the Agents it is
141
+ * granted.
142
+ */
143
+ "agents",
144
+ /**
145
+ * Protocol 17: a queue per session (D76). A message to a busy session is queued unless it asks
146
+ * `delivery: "reject"`, and the busy refusal is `409 session_busy`.
147
+ */
148
+ "session-queue"];
117
149
  export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
118
150
  /**
119
151
  * Host features no client requires: a client that uses one checks the Host's `/health`
@@ -163,9 +195,10 @@ export interface ProtocolRange {
163
195
  features: readonly string[];
164
196
  }
165
197
  /**
166
- * What this Host serves: protocol 15. Protocol 15 changed what a session's pinned manifest
167
- * carries and which tool names are reserved, so an older client is answered `426` naming the
168
- * protocol it needs rather than a turn it cannot read.
198
+ * What this Host serves: protocol 16 and 17. Protocol 16 replaced agent definitions and
199
+ * Environments with agent manifests and Agents, so an older client is answered `426` naming the
200
+ * protocol it needs rather than routes it cannot use. Protocol 17 is additive: a protocol 16
201
+ * client's messages default to `delivery: "reject"`.
169
202
  */
170
203
  export declare const HOST_PROTOCOL: ProtocolRange;
171
204
  export declare const DEFINITION_SCHEMA_VERSION = 2;
@@ -203,21 +236,44 @@ export declare const ERROR_CODES: readonly ["not_found",
203
236
  "invalid_request",
204
237
  /** A route that acts for a person was called without one (`Nylorun-Subject`). */
205
238
  "subject_required",
206
- /** A token caller's Environment grants do not reach the Environment. */
207
- "environment_not_granted",
239
+ /** A token caller's Agent grants do not reach the Agent. */
240
+ "agent_not_granted",
241
+ /**
242
+ * A message to a session whose turn runs, or that waits on an approval, an answer or an
243
+ * uncertain call, sent with `delivery: "reject"` (protocol 17): `409`. Without it the message is
244
+ * queued.
245
+ */
246
+ "session_busy",
247
+ /**
248
+ * The session already holds the Runtime limit `sessionQueuedMessages` queued messages
249
+ * (protocol 17): `429`. They start a turn when the running one ends.
250
+ */
251
+ "queue_full",
252
+ /**
253
+ * `POST /v1/agents/{id}/triggers/{triggerId}/resume` on an `at` trigger whose time has passed
254
+ * (track T4): `409`. Save a manifest version with a new time.
255
+ */
256
+ "trigger_expired",
257
+ /** A signed delivery to a paused webhook trigger (D75): `409`; nothing runs. */
258
+ "trigger_paused",
259
+ /**
260
+ * A memory write whose `content_sha256` precondition no longer holds, or a path a folder or
261
+ * another memory already holds (track T5, D72): `409`. Read the memory again and write on top.
262
+ */
263
+ "memory_conflict",
208
264
  /** Disk work (snapshot, restore, stop, reset) while a turn runs, or a turn while a disk copy runs. */
209
- "environment_busy",
210
- /** The Environment is gone, or its kind cannot run on this Runtime. */
211
- "environment_unavailable",
212
- /** The Tenant's placement keeps this session's harness off the host its Environment needs. */
265
+ "agent_busy",
266
+ /** The Agent is gone, or its kind cannot run on this Runtime. */
267
+ "agent_unavailable",
268
+ /** The Tenant's placement keeps this session's harness off the host its Agent needs. */
213
269
  "placement_refused",
214
- /** A pod Environment's volume or node is gone: only `POST /v1/environments/{id}/reset` brings it back. */
215
- "environment_lost",
270
+ /** A pod Agent's volume or node is gone: only `POST /v1/agents/{id}/reset` brings it back. */
271
+ "agent_lost",
216
272
  /**
217
- * The Environment names an owner (`ownerUserId`) other than the session's owner: `403` to an
273
+ * The Agent names an owner (`owner`) other than the session's owner: `403` to an
218
274
  * application key; a caller acting for a person gets the opaque `404`.
219
275
  */
220
- "environment_owner_mismatch",
276
+ "agent_owner_mismatch",
221
277
  /**
222
278
  * The session's Environment runs another harness than the one the session pinned when it
223
279
  * opened (track R4): its id was deleted and made again with another harness, or an
@@ -258,24 +314,25 @@ export declare const ERROR_CODES: readonly ["not_found",
258
314
  */
259
315
  "credential_conflict",
260
316
  /**
261
- * A `PUT /v1/environments/{id}` asked an existing Environment to run something else
262
- * (protocol 14, D63): only its labels and owner guard may change. Fork it into a new
263
- * Environment (`POST /v1/environments/{id}/fork`). `details.fields` names what differed.
317
+ * A move of an existing Agent (`PUT /v1/agents/{id}`, track T3) would change what is fixed for
318
+ * its life: its manifest's name, its kind, its harness or its storage (D73). `409`, with each in
319
+ * `details.fields`. Fork it into a new Agent (`POST /v1/agents/{id}/fork`) instead.
264
320
  */
265
- "environment_immutable",
321
+ "agent_fixed_field",
266
322
  /**
267
- * A secret write named a secret the Environment's manifest does not declare (D64): `409`.
268
- * Add the slot to the manifest and make or fork an Environment from the new version.
323
+ * A secret write named a secret the Agent's manifest does not declare (D64): `409`. Add the
324
+ * slot to the manifest's runtime section and move the Agent to the new version.
269
325
  */
270
326
  "secret_not_in_manifest",
271
327
  /**
272
- * A session's agent requires what its Environment lacks (D65): `409` when the session opens.
273
- * `details.missing` lists each gap (`sandbox`, `pod`, or `secret:<name>`).
328
+ * An agent manifest whose harness and runtime sections do not fit each other (protocol 16):
329
+ * `422` when it is saved. `details.gaps` names each gap: a custom harness off a pod, a
330
+ * credential that is no declared slot of the right type, a sandbox the runtime does not give.
274
331
  */
275
- "environment_unsuitable",
276
- /** No environment manifest has this name, or no version with this number. */
332
+ "manifest_inconsistent",
333
+ /** No agent manifest has this name, or no version with this number. */
277
334
  "manifest_not_found",
278
- /** An environment manifest some Environment was made from cannot be deleted: `409`. */
335
+ /** An agent manifest some Agent was made from cannot be deleted: `409`. */
279
336
  "manifest_in_use",
280
337
  /**
281
338
  * `If-Match` named a version that is no longer the latest (D63): `412`. Read the manifest
@@ -1,5 +1,36 @@
1
1
  export { hashManifest } from "./utils/hash.js";
2
2
  /**
3
+ * Protocol 17: a queue per session (track T4, D76). A message sent while the session's turn runs,
4
+ * or while it waits on an approval, an answer or an uncertain call, is queued
5
+ * (`{status: "queued", queuedMessageId, position}`, `message.queued`) instead of refused, unless
6
+ * it asks `delivery: "reject"`; the refusal now has a code, `409 session_busy`. When the turn ends
7
+ * (completed, failed or cancelled), every queued message starts one turn, in order, each its own
8
+ * user message (`queue.taken`); our engine's turn input for more than one is
9
+ * `{kind: "messages", messages}` (Harness API 5, additive). Past the Runtime limit
10
+ * `sessionQueuedMessages` a message is `429 queue_full`. Session reads count `queuedMessages`. The
11
+ * Host serves protocol 16 and 17: a message from a protocol 16 client is `reject` unless it says
12
+ * otherwise, so its sessions answer `409` as before.
13
+ * Protocol 16: Agents from one manifest (track T2), a fresh start. An agent manifest (v8) is one
14
+ * versioned document at `/v1/agent-manifests/{name}` with a `harness` section (what runs inside
15
+ * the loop, including the harness's id) and a `runtime` section (what an environment manifest
16
+ * said); the Runtime checks the two against each other when it is saved
17
+ * (`422 manifest_inconsistent`), so `requires` and `409 environment_unsuitable` are gone, and so
18
+ * are agent definitions (`PUT /v1/agents/:id` with a v7 manifest) and environment manifests.
19
+ * Environments are Agents: `/v1/agents/{id}` (with `.../events`, `stop`, `reset`, `snapshot`,
20
+ * `restore`, `versions`, `fork` and `secrets`) is made from a saved manifest only, records it as
21
+ * tracking (`name`) or pinned (`name@n`) into `resolvedVersion`, the version it runs. An Agent
22
+ * evolves (track T3, D73): a `PUT` naming another version of its manifest moves it (`dryRun`
23
+ * answers the plan), a save moves every Agent that tracks the manifest, and each turn takes the
24
+ * version its Agent runs when it starts; a runtime change waits for a pod's next start, and its
25
+ * kind, harness and storage are fixed (`409 agent_fixed_field`). Reads add `state`
26
+ * (`working`, `sleeping`, `input_required`, `failing`, `paused`) and `attention`, and the
27
+ * compute's state moves to `compute.state`. Every session belongs to one Agent:
28
+ * `PUT /v1/sessions/{id}` takes `{ agent, ownerUserId, info }` and pins the manifest version its
29
+ * Agent runs; no session is special (D71). Error codes, event types (`agent.*`), the scopes
30
+ * (`agents:write`, `agent-manifests:write`) and identity-file grants (`agents`) say Agent. Model
31
+ * budget scope `agent` is `manifest`. Harness API 5: `turn.start.agent` replaces
32
+ * `turn.start.environment`. Sessions opened before protocol 16 are closed (`protocol_16`) and
33
+ * stay readable; Environments, their disks and vaults are gone. The Host serves protocol 16 only.
3
34
  * Protocol 15: the harness boundary, a fresh start. Model-facing work belongs to the harness. Our
4
35
  * engine's `read_artifact` and `save_artifact` run in our harness, over the Harness API's new
5
36
  * artifact seam (`artifact.read`, `artifact.write`; Harness API 4), so a session's pinned
@@ -71,7 +102,7 @@ export { hashManifest } from "./utils/hash.js";
71
102
  * it. The Host still accepts protocol 4 (and `Nylorun-Tenant`), 5 and 6 clients on every route
72
103
  * that remains; a client that requires `action-endpoints` is refused by the feature check.
73
104
  */
74
- export const PROTOCOL_VERSION = 15;
105
+ export const PROTOCOL_VERSION = 17;
75
106
  /** What a client of this protocol requires of a Host. */
76
107
  export const PROTOCOL_FEATURES = [
77
108
  "studio-principal",
@@ -88,13 +119,6 @@ export const PROTOCOL_FEATURES = [
88
119
  * metadata at `/.well-known/oauth-protected-resource` when it has trusted issuers.
89
120
  */
90
121
  "resource-server",
91
- /**
92
- * Protocol 11: Environments (`/v1/environments/{id}`, kinds `virtual`, `pod` and `none`), each
93
- * with one vault written on the Runtime API; sessions name an `environment`; token callers
94
- * carry Environment grants checked at every turn start, and `environments:write` lets a
95
- * subject create, change and delete the Environments it is granted.
96
- */
97
- "environments",
98
122
  /** Protocol 12: the model catalog and provider list say which inputs each model reads. */
99
123
  "model-inputs",
100
124
  /**
@@ -103,12 +127,6 @@ export const PROTOCOL_FEATURES = [
103
127
  * block, and tool calls, MCP servers and HTTP calls are named without capability ids.
104
128
  */
105
129
  "flat-manifest",
106
- /**
107
- * Protocol 14: environment manifests (`/v1/environment-manifests/{name}`), Environments made
108
- * from one version and never changed after creation, secret slots, and an agent manifest's
109
- * `requires`, checked when a session opens.
110
- */
111
- "environment-manifests",
112
130
  /**
113
131
  * Protocol 15: the harness boundary. `read_artifact` and `save_artifact` are our harness's
114
132
  * tools, not the Runtime's: a session's pinned `runtime` block no longer carries them, and an
@@ -116,6 +134,20 @@ export const PROTOCOL_FEATURES = [
116
134
  * `{server, tool}`: tool policy rules and approvals name them so.
117
135
  */
118
136
  "harness-boundary",
137
+ /**
138
+ * Protocol 16: agent manifests (`/v1/agent-manifests/{name}`, v8, with a harness and a runtime
139
+ * section checked against each other at save) and Agents (`/v1/agents/{id}`, kinds `virtual`,
140
+ * `pod` and `none`, each with one vault), made from one manifest version, with a derived
141
+ * `state`; every session runs on an Agent; token callers carry Agent grants checked at every
142
+ * turn start, and `agents:write` lets a subject create, change and delete the Agents it is
143
+ * granted.
144
+ */
145
+ "agents",
146
+ /**
147
+ * Protocol 17: a queue per session (D76). A message to a busy session is queued unless it asks
148
+ * `delivery: "reject"`, and the busy refusal is `409 session_busy`.
149
+ */
150
+ "session-queue",
119
151
  ];
120
152
  /**
121
153
  * Host features no client requires: a client that uses one checks the Host's `/health`
@@ -175,13 +207,14 @@ export const OPTIONAL_HOST_FEATURES = [
175
207
  "artifact-reads",
176
208
  ];
177
209
  /**
178
- * What this Host serves: protocol 15. Protocol 15 changed what a session's pinned manifest
179
- * carries and which tool names are reserved, so an older client is answered `426` naming the
180
- * protocol it needs rather than a turn it cannot read.
210
+ * What this Host serves: protocol 16 and 17. Protocol 16 replaced agent definitions and
211
+ * Environments with agent manifests and Agents, so an older client is answered `426` naming the
212
+ * protocol it needs rather than routes it cannot use. Protocol 17 is additive: a protocol 16
213
+ * client's messages default to `delivery: "reject"`.
181
214
  */
182
215
  export const HOST_PROTOCOL = {
183
- min: 15,
184
- max: 15,
216
+ min: 16,
217
+ max: 17,
185
218
  features: [...PROTOCOL_FEATURES, ...OPTIONAL_HOST_FEATURES],
186
219
  };
187
220
  export const DEFINITION_SCHEMA_VERSION = 2;
@@ -230,21 +263,44 @@ export const ERROR_CODES = [
230
263
  "invalid_request",
231
264
  /** A route that acts for a person was called without one (`Nylorun-Subject`). */
232
265
  "subject_required",
233
- /** A token caller's Environment grants do not reach the Environment. */
234
- "environment_not_granted",
266
+ /** A token caller's Agent grants do not reach the Agent. */
267
+ "agent_not_granted",
268
+ /**
269
+ * A message to a session whose turn runs, or that waits on an approval, an answer or an
270
+ * uncertain call, sent with `delivery: "reject"` (protocol 17): `409`. Without it the message is
271
+ * queued.
272
+ */
273
+ "session_busy",
274
+ /**
275
+ * The session already holds the Runtime limit `sessionQueuedMessages` queued messages
276
+ * (protocol 17): `429`. They start a turn when the running one ends.
277
+ */
278
+ "queue_full",
279
+ /**
280
+ * `POST /v1/agents/{id}/triggers/{triggerId}/resume` on an `at` trigger whose time has passed
281
+ * (track T4): `409`. Save a manifest version with a new time.
282
+ */
283
+ "trigger_expired",
284
+ /** A signed delivery to a paused webhook trigger (D75): `409`; nothing runs. */
285
+ "trigger_paused",
286
+ /**
287
+ * A memory write whose `content_sha256` precondition no longer holds, or a path a folder or
288
+ * another memory already holds (track T5, D72): `409`. Read the memory again and write on top.
289
+ */
290
+ "memory_conflict",
235
291
  /** Disk work (snapshot, restore, stop, reset) while a turn runs, or a turn while a disk copy runs. */
236
- "environment_busy",
237
- /** The Environment is gone, or its kind cannot run on this Runtime. */
238
- "environment_unavailable",
239
- /** The Tenant's placement keeps this session's harness off the host its Environment needs. */
292
+ "agent_busy",
293
+ /** The Agent is gone, or its kind cannot run on this Runtime. */
294
+ "agent_unavailable",
295
+ /** The Tenant's placement keeps this session's harness off the host its Agent needs. */
240
296
  "placement_refused",
241
- /** A pod Environment's volume or node is gone: only `POST /v1/environments/{id}/reset` brings it back. */
242
- "environment_lost",
297
+ /** A pod Agent's volume or node is gone: only `POST /v1/agents/{id}/reset` brings it back. */
298
+ "agent_lost",
243
299
  /**
244
- * The Environment names an owner (`ownerUserId`) other than the session's owner: `403` to an
300
+ * The Agent names an owner (`owner`) other than the session's owner: `403` to an
245
301
  * application key; a caller acting for a person gets the opaque `404`.
246
302
  */
247
- "environment_owner_mismatch",
303
+ "agent_owner_mismatch",
248
304
  /**
249
305
  * The session's Environment runs another harness than the one the session pinned when it
250
306
  * opened (track R4): its id was deleted and made again with another harness, or an
@@ -285,24 +341,25 @@ export const ERROR_CODES = [
285
341
  */
286
342
  "credential_conflict",
287
343
  /**
288
- * A `PUT /v1/environments/{id}` asked an existing Environment to run something else
289
- * (protocol 14, D63): only its labels and owner guard may change. Fork it into a new
290
- * Environment (`POST /v1/environments/{id}/fork`). `details.fields` names what differed.
344
+ * A move of an existing Agent (`PUT /v1/agents/{id}`, track T3) would change what is fixed for
345
+ * its life: its manifest's name, its kind, its harness or its storage (D73). `409`, with each in
346
+ * `details.fields`. Fork it into a new Agent (`POST /v1/agents/{id}/fork`) instead.
291
347
  */
292
- "environment_immutable",
348
+ "agent_fixed_field",
293
349
  /**
294
- * A secret write named a secret the Environment's manifest does not declare (D64): `409`.
295
- * Add the slot to the manifest and make or fork an Environment from the new version.
350
+ * A secret write named a secret the Agent's manifest does not declare (D64): `409`. Add the
351
+ * slot to the manifest's runtime section and move the Agent to the new version.
296
352
  */
297
353
  "secret_not_in_manifest",
298
354
  /**
299
- * A session's agent requires what its Environment lacks (D65): `409` when the session opens.
300
- * `details.missing` lists each gap (`sandbox`, `pod`, or `secret:<name>`).
355
+ * An agent manifest whose harness and runtime sections do not fit each other (protocol 16):
356
+ * `422` when it is saved. `details.gaps` names each gap: a custom harness off a pod, a
357
+ * credential that is no declared slot of the right type, a sandbox the runtime does not give.
301
358
  */
302
- "environment_unsuitable",
303
- /** No environment manifest has this name, or no version with this number. */
359
+ "manifest_inconsistent",
360
+ /** No agent manifest has this name, or no version with this number. */
304
361
  "manifest_not_found",
305
- /** An environment manifest some Environment was made from cannot be deleted: `409`. */
362
+ /** An agent manifest some Agent was made from cannot be deleted: `409`. */
306
363
  "manifest_in_use",
307
364
  /**
308
365
  * `If-Match` named a version that is no longer the latest (D63): `412`. Read the manifest