@nylorun/harness 0.37.4-beta → 0.38.1-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.
Files changed (55) hide show
  1. package/CHANGELOG.md +67 -41
  2. package/HOST_CONTRACT.md +9 -10
  3. package/dist/api/executors.d.ts +4 -4
  4. package/dist/api/harness.d.ts +3 -3
  5. package/dist/api/harness.js +1 -1
  6. package/dist/api/host.d.ts +0 -18
  7. package/dist/api/host.js +8 -4
  8. package/dist/api/run.d.ts +1 -9
  9. package/dist/api/run.js +17 -14
  10. package/dist/flow/engine.d.ts +1 -1
  11. package/dist/flow/engine.js +1 -1
  12. package/dist/flow/limits.d.ts +1 -1
  13. package/dist/flow/limits.js +1 -1
  14. package/dist/flow/paths.d.ts +2 -2
  15. package/dist/flow/paths.js +2 -2
  16. package/dist/loop/compaction/config.d.ts +2 -2
  17. package/dist/loop/compaction/config.js +1 -1
  18. package/dist/loop/compaction/index.d.ts +2 -2
  19. package/dist/loop/compaction/index.js +2 -2
  20. package/dist/loop/delegation.d.ts +3 -3
  21. package/dist/loop/delegation.js +1 -1
  22. package/dist/loop/model/files.d.ts +3 -3
  23. package/dist/loop/model/files.js +4 -4
  24. package/dist/loop/model/project.d.ts +1 -1
  25. package/dist/loop/model/project.js +2 -2
  26. package/dist/loop/options.js +1 -1
  27. package/dist/loop/run.js +4 -4
  28. package/dist/loop/step/canonicalize.d.ts +2 -2
  29. package/dist/loop/step/canonicalize.js +2 -2
  30. package/dist/loop/step/step-context.d.ts +1 -1
  31. package/dist/loop/step/step-context.js +1 -1
  32. package/dist/loop/tool-result.js +2 -2
  33. package/dist/loop/transcript.js +1 -1
  34. package/dist/run/durable.d.ts +4 -4
  35. package/dist/run/durable.js +6 -6
  36. package/dist/tools/ask.d.ts +6 -6
  37. package/dist/tools/ask.js +1 -1
  38. package/dist/tools/engine-tools.d.ts +5 -5
  39. package/dist/tools/mcp.d.ts +1 -1
  40. package/dist/tools/mcp.js +1 -1
  41. package/dist/tools/memory.d.ts +3 -3
  42. package/dist/tools/outputs.js +1 -1
  43. package/dist/tools/person-started.d.ts +12 -0
  44. package/dist/tools/person-started.js +31 -0
  45. package/dist/tools/read-media.js +1 -1
  46. package/dist/tools/results.d.ts +1 -1
  47. package/dist/tools/results.js +3 -3
  48. package/dist/tools/sandbox.d.ts +1 -1
  49. package/dist/tools/sandbox.js +1 -1
  50. package/dist/tools/skills.d.ts +9 -4
  51. package/dist/tools/skills.js +32 -6
  52. package/dist/tools/tool-search.js +1 -1
  53. package/dist/tools/wake.js +1 -1
  54. package/dist/types/execution.d.ts +4 -4
  55. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.38.1-beta
4
+
5
+ ### Patch Changes
6
+
7
+ - Pin core to the tested release.
8
+ - Updated dependencies [f2ce855]
9
+ - @nylorun/core@0.55.0-beta
10
+
11
+ ## 0.38.0-beta
12
+
13
+ ### Minor Changes
14
+
15
+ - 807b302: Skills only a person starts. A `SKILL.md` may set `disable-model-invocation: true`, as Claude Code's skills do; the compiler and the SDK carry it as the skill's `disableModelInvocation: true`. Such a skill is left out of the model's catalog and `load_skill` unless the turn's message names it: a message command's new `skill` (the SDK's `MessageOptions.skill`, an A2A message's `metadata.skill`). The named skill is offered for that turn only, and the model is told the person started it; an agent used as a tool never gets it. A name the session's agent doesn't hold is `400 unknown_skill`, and a message naming a skill waits for its own turn rather than steering one. Host feature `person-started-skills`; agent manifest `v8.7` and harness file `v1.7` take the field. Also fixes the SDK sending a message's `context` twice with parts.
16
+ - f872ddd: An Agent Plugin's own files reach the sandbox. A vendored plugin holding files beyond its `plugin.json`, servers, skills and subagent files (a plugin's `resources/`, its persona files, its docs) carries all of them, but secret-shaped ones, by hash on its `harness.plugins` entry and on the loop manifest's new `plugins`, in the folder compiler and in the SDK's `.plugin()` and `harness.manifest.json` plugins. They are definition files: uploaded with the skills' files, named at save (`definition_files_missing`), bounded together as a skill's are, and served to the run. Before a sandbox call the harness mounts each such plugin read-only at `/plugins/<name>@<hash>/`, for the root and its subagents, and `load_skill` answers a plugin skill's `pluginPath`. A plugin holding only its parts carries no files, so its manifest doesn't change. Agent manifest schema `v8.7`, harness file `v1.7`, Host feature `plugin-files`; `nylorun check` says how many of a plugin's files are mounted.
17
+
18
+ ### Patch Changes
19
+
20
+ - 8b3df7c: Help text, error messages, API descriptions and doc comments say what the behaviour is without naming internal plan or decision identifiers. No behaviour changes.
21
+ - Pin core to the tested release.
22
+ - Updated dependencies [807b302]
23
+ - Updated dependencies [8b3df7c]
24
+ - Updated dependencies [f872ddd]
25
+ - Updated dependencies [0ebf870]
26
+ - Updated dependencies [8390f9b]
27
+ - @nylorun/core@0.54.0-beta
28
+
3
29
  ## 0.37.4-beta
4
30
 
5
31
  ### Patch Changes
@@ -12,7 +38,7 @@
12
38
 
13
39
  ### Patch Changes
14
40
 
15
- - b9b0965: A subagent used as a tool receives `{ task }` as a string, so one that declares an `inputSchema` that can't take a string is now refused when it is built or saved (ADR-162): `delegation.input` in the builder and the manifest contract, `delegation_input` in a manifest's files. Before, the manifest saved and the flow's first stage got a string it didn't declare. Messages and Studio now use ADR-162's words: an agent manifest is driven by a model loop or by a flow, and a flow's stages can be subagents; "flow agent" is no longer a kind. Studio's Agent manifests list filters by **Driven by** (Model loop or Flow), a flow's section is **Stages**, and a subagent used as a tool shows as "Subagent". No code, diagnostic code or wire format changes.
41
+ - b9b0965: A subagent used as a tool receives `{ task }` as a string, so one that declares an `inputSchema` that can't take a string is now refused when it is built or saved: `delegation.input` in the builder and the manifest contract, `delegation_input` in a manifest's files. Before, the manifest saved and the flow's first stage got a string it didn't declare. Messages and Studio now use the same words: an agent manifest is driven by a model loop or by a flow, and a flow's stages can be subagents; "flow agent" is no longer a kind. Studio's Agent manifests list filters by **Driven by** (Model loop or Flow), a flow's section is **Stages**, and a subagent used as a tool shows as "Subagent". No code, diagnostic code or wire format changes.
16
42
  - Pin core to the tested release.
17
43
  - Updated dependencies [b9b0965]
18
44
  - @nylorun/core@0.52.0-beta
@@ -38,11 +64,11 @@
38
64
 
39
65
  ### Minor Changes
40
66
 
41
- - d688ce5: An Agent sets when its sessions compact (ADR-157): `harness.loop.compaction` (`loop.compaction` in `AGENT.md`) takes `threshold` and `keepTokens`, positive whole numbers of tokens, and `roles.<role>` over them for sessions opened with that role. Our harness compacts before a model call whose estimate passes the lower of `threshold` and the model's window minus the reply reserve, and keeps `keepTokens` word for word; unset, sessions compact as before. A value that is not a positive integer is ignored with an `engine.diagnostic` (`compaction_setting_ignored`), and the folder compiler refuses it. `turn.start` names the session's role (`role`) to our harness.
67
+ - d688ce5: An Agent sets when its sessions compact: `harness.loop.compaction` (`loop.compaction` in `AGENT.md`) takes `threshold` and `keepTokens`, positive whole numbers of tokens, and `roles.<role>` over them for sessions opened with that role. Our harness compacts before a model call whose estimate passes the lower of `threshold` and the model's window minus the reply reserve, and keeps `keepTokens` word for word; unset, sessions compact as before. A value that is not a positive integer is ignored with an `engine.diagnostic` (`compaction_setting_ignored`), and the folder compiler refuses it. `turn.start` names the session's role (`role`) to our harness.
42
68
 
43
69
  An `agent-folder/3` folder may now set `loop` for the harness's own settings, such as `compaction`; only `loop.plan`, `loop.connections` and `loop.ask`, which its plugins declare, are refused. `nylorun migrate folder --to 3` keeps those settings.
44
70
 
45
- - d688ce5: A message's context (ADR-157, Host feature `message-context`): a message takes `context`, up to 16 items `{ type?, value }` and 16 KiB in all, facts for its own turn only. The Runtime keeps them on `command.message` and passes them to the turn as its input's `metadata.context`; our harness renders the turn's latest ones in the `<runtime-context>` block after the history on every model call of that turn, and later turns leave them out. A workflow session refuses them. `session.input(value, { context })` and `session.inputParts(parts, { context })` send them, and refuse before sending when the Runtime lacks the feature.
71
+ - d688ce5: A message's context (Host feature `message-context`): a message takes `context`, up to 16 items `{ type?, value }` and 16 KiB in all, facts for its own turn only. The Runtime keeps them on `command.message` and passes them to the turn as its input's `metadata.context`; our harness renders the turn's latest ones in the `<runtime-context>` block after the history on every model call of that turn, and later turns leave them out. A workflow session refuses them. `session.input(value, { context })` and `session.inputParts(parts, { context })` send them, and refuse before sending when the Runtime lacks the feature.
46
72
 
47
73
  ### Patch Changes
48
74
 
@@ -122,7 +148,7 @@
122
148
 
123
149
  ### Minor Changes
124
150
 
125
- - b6a7c1d: An agent sees the images and PDFs it makes in its sandbox (ADR-139). `read` of a file the turn's model reads as media, known by its extension (an image, a PDF, an Office document, audio or video), comes back as the file itself, shown to the model in the turn's files, instead of numbered lines of decoded bytes. Our engine runs it in the harness: it reads the bytes, checks they start as the type says, and stores them as an artifact for the model only. A model that can't read the kind is told so before anything is read or stored (`sandbox.unreadable`), and a file that isn't what its name says fails `sandbox.binary_file`.
151
+ - b6a7c1d: An agent sees the images and PDFs it makes in its sandbox. `read` of a file the turn's model reads as media, known by its extension (an image, a PDF, an Office document, audio or video), comes back as the file itself, shown to the model in the turn's files, instead of numbered lines of decoded bytes. Our engine runs it in the harness: it reads the bytes, checks they start as the type says, and stores them as an artifact for the model only. A model that can't read the kind is told so before anything is read or stored (`sandbox.unreadable`), and a file that isn't what its name says fails `sandbox.binary_file`.
126
152
 
127
153
  - **Model-only artifacts.** `artifact.write` `begin` takes `audience: "model"` (Harness API 5, schema revision 5, `harness-api/v5.5.json`; only our own engine sends it). Such an artifact is readable by id and carries `audience: "model"` in its view and its `artifact.created` event, but is never listed (`GET /v1/artifacts`, a session's artifacts, pages) and is no A2A task file. Runtime store migration 0046 (`artifacts.audience`, nullable) runs at start.
128
154
  - **Binary files.** The sandbox's `read` of any other binary file fails `sandbox.binary_file`, in words, instead of answering decoded bytes as text.
@@ -161,14 +187,14 @@
161
187
 
162
188
  ### Minor Changes
163
189
 
164
- - c649f33: A message can steer a running turn (D85). `delivery: "steer"` on a `message` command, behind the
190
+ - c649f33: A message can steer a running turn. `delivery: "steer"` on a `message` command, behind the
165
191
  optional Host feature `steer`: to a busy agent session it waits in the session queue marked
166
192
  `steer`, and our engine takes it into the running turn before its next step, after the tool
167
193
  results, through a new effect kind, `inputs`, which core answers in the transaction that journals
168
194
  it (Harness API 5, `harness-api/v5.4.json`). Each taken message's `command.message` is written
169
195
  under the running turn, then `queue.taken` with the `step`. The queued answer and
170
196
  `message.queued` say which delivery applied; a workflow session queues. A steer the turn doesn't
171
- take starts the next turn like any queued message, and D76's defaults never choose steer.
197
+ take starts the next turn like any queued message, and the queue's defaults never choose steer.
172
198
 
173
199
  ### Patch Changes
174
200
 
@@ -180,7 +206,7 @@
180
206
 
181
207
  ### Minor Changes
182
208
 
183
- - 2afa44d: The Runtime's primitives as its own Agent Plugins (ADR-106, D84). An `agent-folder/3` folder lists them under `plugins:` (`nylorun-memory`, `nylorun-triggers`, `nylorun-plan`, `nylorun-interactions`, `nylorun-artifacts`, `nylorun-sandbox`, which needs a computer), with no versions, and turns one of their tools off with `mcpServers.nylorun.tools.<tool>.enabled: false`. The compiler reads them as the `agent-folder/2` declarations they stand for (`memory`, `loop`, `engine.sandbox`, `engine.artifacts`, `engine.triggers`, which v3 refuses) and records them in `harness.engine.plugins`, each with its tools and the hash of its files. The engine presents their tools as the reserved server `nylorun`: the model reads `nylorun__memory` and the declared plugins' words as one text, with their skills (`memory`, `triggers`) in the catalog, served from the bundle; every effect keeps its target and `toolName`, so the record, tool policy (`kind: "runtime"` rules) and dispatch are unchanged. New: `ask` (`nylorun-interactions`, `harness.loop.ask`), a question that pauses the turn as an A2A `question`; `removeTools` takes `nylorun__<tool>`; `triggers` answers carry `now`; under `nylorun-triggers`, an agent-made trigger's run starts with a `[trigger <id> · <title> · nobody is watching]` line, and a turn a trigger started may set a one-off follow-up (`in` or `at`, `session: "this"`); the sandbox's instructions name the hosts `runtime.json` allows. `nylorun migrate folder <dir> --to 3` writes the plugins that keep an agent's tools and features, and `nylorun check --explain` names the plugin behind each. The JSON Schemas are republished as `agent-manifest/v8.4`, `harness-manifest/v1.4` and `agent-folder/v1/agent-md.4`.
209
+ - 2afa44d: The Runtime's primitives as its own Agent Plugins. An `agent-folder/3` folder lists them under `plugins:` (`nylorun-memory`, `nylorun-triggers`, `nylorun-plan`, `nylorun-interactions`, `nylorun-artifacts`, `nylorun-sandbox`, which needs a computer), with no versions, and turns one of their tools off with `mcpServers.nylorun.tools.<tool>.enabled: false`. The compiler reads them as the `agent-folder/2` declarations they stand for (`memory`, `loop`, `engine.sandbox`, `engine.artifacts`, `engine.triggers`, which v3 refuses) and records them in `harness.engine.plugins`, each with its tools and the hash of its files. The engine presents their tools as the reserved server `nylorun`: the model reads `nylorun__memory` and the declared plugins' words as one text, with their skills (`memory`, `triggers`) in the catalog, served from the bundle; every effect keeps its target and `toolName`, so the record, tool policy (`kind: "runtime"` rules) and dispatch are unchanged. New: `ask` (`nylorun-interactions`, `harness.loop.ask`), a question that pauses the turn as an A2A `question`; `removeTools` takes `nylorun__<tool>`; `triggers` answers carry `now`; under `nylorun-triggers`, an agent-made trigger's run starts with a `[trigger <id> · <title> · nobody is watching]` line, and a turn a trigger started may set a one-off follow-up (`in` or `at`, `session: "this"`); the sandbox's instructions name the hosts `runtime.json` allows. `nylorun migrate folder <dir> --to 3` writes the plugins that keep an agent's tools and features, and `nylorun check --explain` names the plugin behind each. The JSON Schemas are republished as `agent-manifest/v8.4`, `harness-manifest/v1.4` and `agent-folder/v1/agent-md.4`.
184
210
 
185
211
  ### Patch Changes
186
212
 
@@ -204,7 +230,7 @@
204
230
 
205
231
  ### Minor Changes
206
232
 
207
- - 67ed2ea: An agent that declares its engine features (`engine`, `agent-folder/2`, ADR-100) gets only those:
233
+ - 67ed2ea: An agent that declares its engine features (`engine`, `agent-folder/2`) gets only those:
208
234
  no shell or file tools and no sandbox note without `engine.sandbox` (or only the tools it names),
209
235
  no `read_artifact` or `save_artifact` or their text unless declared, and `/workspace/outputs` is
210
236
  saved when a turn ends only with `engine.outputs`. Without `artifacts.read`, a tool result past
@@ -246,7 +272,7 @@
246
272
 
247
273
  ### Minor Changes
248
274
 
249
- - d48b6ef: An agent keeps a durable plan (A2A profile v2, `progress/v1`; A2A-E10).
275
+ - d48b6ef: An agent keeps a durable plan (A2A profile v2, `progress/v1`).
250
276
 
251
277
  - **`plan.updated`**, a new durable session event: `{ steps: [{ label, state, note? }] }`, the agent's whole plan each time, never a diff. `state` is `pending`, `active`, `done`, `blocked` or `skipped`; at most 20 steps, labels of at most 120 and notes of at most 280 characters (`PLAN_LIMITS`, `PLAN_STEP_STATES`, `PlanUpdatedPayloadSchema` in `@nylorun/core/contracts`). The Runtime records and serves it like any public event, with the harness as its writer (evidence `claimed`), and the OpenAPI document lists it.
252
278
  - **`update_plan`**, a built-in tool of our engine, off by default. A version opts in with `harness.loop.plan: true` (in an agent folder, `loop: { plan: true }` in `AGENT.md`'s frontmatter); the session's root agent then gets the tool, unless it declares its own tool of that name. A call takes `{ steps: [...] }`, cuts long labels and notes (ending in `…`) and steps past 20 rather than refusing them, claims one `plan.updated` and answers `Plan updated`. A malformed plan is a failed result the model sees.
@@ -343,19 +369,19 @@
343
369
 
344
370
  ### Minor Changes
345
371
 
346
- - 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.
372
+ - 22c61ce: Protocol 16, Agents from one manifest, 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.
347
373
 
348
- 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.
374
+ 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. 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.
349
375
 
350
376
  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.
351
377
 
352
- - 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.
353
- - 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`.
354
- - 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.
378
+ - bf942ed: Our engine offers the `memory` tool. 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.
379
+ - ffeb3bb: `schedule_wake`. 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`.
380
+ - 9e60e40: Protocol 17, a queue per session. 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.
355
381
 
356
382
  ### Patch Changes
357
383
 
358
- - 3a575d7: Track T3, versions per turn: a turn's first segment takes the manifest version its session's Agent runs then, so a session moves with its Agent between turns and keeps one version through every segment, approval and rollover of a turn. A turn whose message named a variant, and a flow's sessions, keep the version they pinned; a changed loop manifest drops the session's MCP snapshot. The turn span names the version (`nylorun.manifest.version`). Our engine takes a new version's output schema at the next turn.
384
+ - 3a575d7: Versions per turn: a turn's first segment takes the manifest version its session's Agent runs then, so a session moves with its Agent between turns and keeps one version through every segment, approval and rollover of a turn. A turn whose message named a variant, and a flow's sessions, keep the version they pinned; a changed loop manifest drops the session's MCP snapshot. The turn span names the version (`nylorun.manifest.version`). Our engine takes a new version's output schema at the next turn.
359
385
  - Pin core to the tested release.
360
386
  - Updated dependencies [218b078]
361
387
  - Updated dependencies [22c61ce]
@@ -416,18 +442,18 @@
416
442
  - cf425c6: **The harness mounts skills and saves outputs; the in-process harness uses the gates; compaction is a transcript edit (protocol 15).** The fifth step of the harness boundary, still protocol 15 and Harness API 4. See MIGRATION.md.
417
443
 
418
444
  - **Skill folders are our engine's.** Before each sandbox call our engine mounts each skill version of the turn's tree at `/skills/<name>@<hash>/` with `executors.files.mount`, reading the bytes over `definition.file`; the SandboxManager only writes them (`mountFolder`), once per open sandbox (`present` after). `SandboxManager.mountSkills`, its `definitionFile` port and `SandboxSessionRef.manifest` are gone, and the operator sandbox route mounts nothing.
419
- - **The outputs folder is our engine's (Q5).** At a completed turn's end in a sandbox our engine saves `/workspace/outputs` as the session's `outputs` folder before `turn.completed`, over the new folder mode of `artifact.write` (`kind: "folder"`, `file`, chunks named by hash, `unchanged`, `refused`). Core takes every byte, checks each file's hash before content is stored under it, dedupes, and keeps the content epoch and quotas. Versions say `source: "engine"`; `artifact.export.skipped` and `artifact.export.failed` are harness claims. Core's export (`artifacts/export.ts`, the `WorkspaceReader`, `workspace.read` listing and bytes calls) is removed.
445
+ - **The outputs folder is our engine's.** At a completed turn's end in a sandbox our engine saves `/workspace/outputs` as the session's `outputs` folder before `turn.completed`, over the new folder mode of `artifact.write` (`kind: "folder"`, `file`, chunks named by hash, `unchanged`, `refused`). Core takes every byte, checks each file's hash before content is stored under it, dedupes, and keeps the content epoch and quotas. Versions say `source: "engine"`; `artifact.export.skipped` and `artifact.export.failed` are harness claims. Core's export (`artifacts/export.ts`, the `WorkspaceReader`, `workspace.read` listing and bytes calls) is removed.
420
446
  - **No limit literals.** The new Runtime limit `folderEntries` (10,000; a count, its ceiling from the manifest's one string) replaces `EXPORT_MAX_FILES`, and `createHarness({ outputs: { dir, maxBytes } })` (`/workspace/outputs`, 1 GiB) replaces `EXPORT_MAX_BYTES`. `RUNTIME_LIMIT_CEILINGS` entries are `{value, unit, why}`.
421
447
  - **In-process parity.** Every model call goes through the Model Gate: a scripted model is served by `providerModelGate`, metered like any. The MCP pool opens every server through the Tool Gate (`openRemote` is required; the in-process gate's `openMcp` finds the server in the session's pinned manifest and authorizes it with the vault). `ModelRoute` is `{tenantId, modelGate}`; `TenantContext.modelProvider`, `useVaultModel` and `workspaces` are gone.
422
- - **Compaction is a transcript edit (Q4).** Summary calls say `purpose: "summary"` (no `message.assistant`), and the segment's edit that replaced the history says `kind: "compaction"` with its facts and summary calls (`CompactionFactsSchema`, `transcriptUpdates(..., compaction)`). Core checks the calls and writes one `context.compacted`, which loses `partial`.
448
+ - **Compaction is a transcript edit.** Summary calls say `purpose: "summary"` (no `message.assistant`), and the segment's edit that replaced the history says `kind: "compaction"` with its facts and summary calls (`CompactionFactsSchema`, `transcriptUpdates(..., compaction)`). Core checks the calls and writes one `context.compacted`, which loses `partial`.
423
449
 
424
- - dc75e58: **Host timings, retries and engine settings are configuration with defaults (B15).** Still protocol 15 and Harness API 4. See MIGRATION.md and DEPLOYMENT.md ("Host tuning").
450
+ - dc75e58: **Host timings, retries and engine settings are configuration with defaults.** Still protocol 15 and Harness API 4. See MIGRATION.md and DEPLOYMENT.md ("Host tuning").
425
451
 
426
452
  - **Host tuning.** The Runtime processes' timeouts, retries, poll intervals and internal sizes are one typed schema with a default each (`HostTuningSchema`, `runtime/server/src/tuning.ts`): keys, the Harness API, the API's streams, the Host, the Object store, the Tenant, its sweep, Durable Session Execution, Restate, Postgres, Durable Streams and the relay, the gates, egress-gate, sandbox pods, harnesses and traces. An operator sets any part in `NYLORUN_TUNING` (JSON), parsed with the stack configuration and read once at start; every default is the value before. An unknown key or a value past its ceiling (Node's longest timer, S3's part sizes, S2's batch, the sandboxes service's wait) stops the process naming the key. Core hands a sandbox pod's engine the `harness` and `engine` groups the operator set. `nylorun start` passes `NYLORUN_TUNING` to the runtime, gateway and harness containers.
427
453
  - **Our engine's loop is configuration.** `createHarness` takes `compaction` (`CompactionConfig`, `DEFAULT_COMPACTION_CONFIG`: the kept tail, the reply's reserve, the estimate), `partialOutputChars` (a failed agent-as-tool's output its parent sees), `resendDelaysMs` and `leaseRetryMs`; `runDurable` takes `loop` (`LoopConfig`), which an invocation hands its agents used as tools. `EngineToolConfig` is `EngineConfig`. The Runtime's harness host passes the tuning's `engine` group to `createHarness`.
428
454
  - **Kept as constants**, each justified where it is defined: Node's longest timer, S3's part sizes and object key, S2's batch, the sandboxes service's longest wait and pod variable, the `environment.egress` event's 16 running turns, W3C's 512-character `tracestate`, and the 24-hour floor of a wake's dedupe key.
429
455
 
430
- - 23774c4: **The last hard-coded limits are configuration (harness boundary B15c).** Still protocol 15 and Harness API 4. Every default is the value before. See MIGRATION.md, and DEPLOYMENT.md's Runtime limits and Host tuning.
456
+ - 23774c4: **The last hard-coded limits are configuration.** Still protocol 15 and Harness API 4. Every default is the value before. See MIGRATION.md, and DEPLOYMENT.md's Runtime limits and Host tuning.
431
457
 
432
458
  - **21 more Runtime limits** (`GET`/`PUT /v1/tenant/limits`): a message's parts (`messageParts`), page sizes (`pageItems`, `exportPageItems`, `environmentEventItems`; a page asked larger holds that many), labels (`artifactLabels`, `labelKeyChars`, `labelValueChars`), a manifest's setup command, descriptions and secret hosts (`setupCommandChars`, `manifestDescriptionChars`, `secretDescriptionChars`, `secretHosts`), a failed pod's reason (`setupReasonChars`, `setupCommandExcerptChars`), secret values (`secretValueChars`), the tool policy and budgets (`toolRules`, `toolRuleFieldChars`, `toolRuleTextChars`, `modelBudgets`) and flows (`flowConcurrency`, `flowMapItems`, `flowLoopIterations`, replacing the `NYLORUN_FLOW_*` variables no Host read). Request schemas lose these maxima; the Runtime checks the Tenant's.
433
459
  - **More Host tuning** (`NYLORUN_TUNING`): token lifetimes and clock tolerance (`keys.*`), the advance deadline and grace (`execution.*`), `nylorun-operate`'s waits, the credential store's lock, sweep arming, Postgres batches and the replication pool, a basin repair's log cadence, egress sockets, the engine poll and sandbox memory floor, MCP listing pages and diagnostics, sandbox helper commands, the scrub threshold, exec event and local stream sizes; and in the engine, `flowValueChars` and `toolResults.minPreviewBytes`.
@@ -446,7 +472,7 @@
446
472
  - **`turn.start` carries `limits`** (`RuntimeLimitsSchema`), the limits in force when the segment started. Harness API 3 and protocol 14 are unchanged, but `TurnStartSchema` is strict: a harness built against an older `@nylorun/core` refuses a `turn.start` with `limits`, so upgrade a custom harness with the Runtime. Our harness asks for skill files `limits.chunkBytes` at a time, and holds MCP answers on its own connections to `limits.toolAnswerBytes`. `createHarness` takes `onStart(grant, start)`.
447
473
  - **Removed exports:** `MAX_MODEL_CALL_BYTES`, `MAX_TOOL_BODY_BYTES`, `MAX_HARNESS_STATE_BYTES` and `DEFINITION_FILE_CHUNK_BYTES` from `@nylorun/core`. Added: `RuntimeLimitsSchema`, `RUNTIME_LIMIT_DEFAULTS`, `RUNTIME_LIMIT_CEILINGS`, `runtimeLimitsOf`, `runtimeLimitIssues`, `limitExceededMessage`, `S2_RECORD_MAX_BYTES`, `RECORD_ENVELOPE_RESERVE_BYTES`, `JS_STRING_MAX_LENGTH` and the `TenantLimits*` schemas.
448
474
 
449
- - 6772612: **The remaining request, upload, token and sandbox limits are Tenant settings (harness boundary B15).** Still protocol 15 and Harness API 4. See MIGRATION.md and DEPLOYMENT.md's Runtime limits.
475
+ - 6772612: **The remaining request, upload, token and sandbox limits are Tenant settings.** Still protocol 15 and Harness API 4. See MIGRATION.md and DEPLOYMENT.md's Runtime limits.
450
476
 
451
477
  - **27 more Runtime limits** in `GET`/`PUT /v1/tenant/limits`, each with today's value as its default and a ceiling from a dependency (a JavaScript string or timer, a request read as one string, a Harness API frame, a JavaScript number): request bodies and inline files (`requestBodyBytes`, `inlineFileBytes`), `a2aWaitMs`, `errorExcerptChars`, `traceContentBytes`, an Environment's labels, setup and input files (`environmentLabels`, `environmentSetupCommands`, `environmentFiles`, `environmentFilesPerEntry`, `environmentSecretSlots`, `setupCommandMs`, `setupOutputChars`), disk versions (`diskVersionEntries`, `diskVersionBytes`, `diskLeaseMs`, `diskPodWaitMs`; an Environment's manifest may lower the first two with `limits.disk`), model calls (`modelRequestMs`, `modelIdleMs`, `modelAttempts`, `modelRetryDelayMs`, `modelProviderRetries`, `modelRetryDelayMaxMs`, read by the gates for each call) and tools (`toolAttempts`, `httpToolTimeoutMs`, `mcpPreviewMs`, `mcpMetadataBytes`, and the new `mcpSnapshotBytes`: what a session pins of its MCP servers' tools and instructions, past which a server is left out with a diagnostic).
452
478
  - **Schema maxima are checked against the Tenant's limits**: an Environment's labels, setup commands, input files, files per entry, secret slots and setup timeout, and an HTTP tool's `timeoutMs` (at deploy and at each call). `limits.environments` and `lifecycle.stopGrace` lose their arbitrary caps; an identity file's issuer takes any number of grants and `jwksFetch` settings.
@@ -530,7 +556,7 @@
530
556
 
531
557
  ### Minor Changes
532
558
 
533
- - e917bd6: **Bring your own harness: harness ids, harness-owned state, and who wrote each event (R4.1, R4.2, R4.4, R4.9).**
559
+ - e917bd6: **Bring your own harness: harness ids, harness-owned state, and who wrote each event.**
534
560
 
535
561
  - **Harness ids and routing.** An Environment's `harness` takes any harness id (`^[a-z][a-z0-9-]{1,62}$`). It is no longer only `nylorun`.
536
562
  - **The pin.** A session pins its harness when it opens: its Environment's harness, else `nylorun`. A flow always runs `nylorun`. `GET /v1/sessions/{id}` returns the pin as `harness`.
@@ -562,18 +588,18 @@
562
588
  - `@nylorun/studio`: Environments replace Sandboxes, with a create form, stop, reset, delete and their secrets; the Credentials forms write an Environment's secrets; New session picks an Environment and shows its coverage.
563
589
  - `nylorun`: `nylorun sandbox ls|rm` list and delete Environments; `nylorun mcp inspect --environment <id>` replaces `--vault`; `nylo reset --environments` replaces `--sandboxes`; `nylo doctor sandbox` reports the Environment limits.
564
590
 
565
- - 3013501: **Tool calls are delivered at least once, and every one is on the record (R5 step 1).** A gateway restart used to park the sessions it interrupted as `uncertain` until someone cancelled them, a harness could call tools with no record, and nothing listed a session's tool calls. Now every tool call ends in the log with its outcome, a crash sends it again with the same key, and the gateway runs only calls the effect journal recorded.
591
+ - 3013501: **Tool calls are delivered at least once, and every one is on the record.** A gateway restart used to park the sessions it interrupted as `uncertain` until someone cancelled them, a harness could call tools with no record, and nothing listed a session's tool calls. Now every tool call ends in the log with its outcome, a crash sends it again with the same key, and the gateway runs only calls the effect journal recorded.
566
592
 
567
593
  - **Every outcome in the log.** Each tool call ends in one `tool.completed` with `status` (`completed`: the tool answered; `failed`: the Runtime ended it, `tool.disabled`, `tool.unavailable` or `tool.interrupted`; `cancelled`), `kind` (`mcp`, `http`, `sandbox`, `platform`), `server`, `attempts` and `durationMs`. Refused and cancelled calls are in the log for the first time.
568
594
  - **`GET /v1/sessions/{id}/calls/tool`** pages a session's tool calls from the effect journal, in the order they were first sent: tool, input, status, sends, error and timing. Same credentials and paging as `/calls/model`; `@nylorun/agents` adds `session.toolCalls()`. Host feature `tool-calls`.
569
595
  - **At least once, with the same key.** An MCP or HTTP tool call that a crash, a shutdown or a lost gateway hop interrupted is sent again with its effect id as the key, up to 3 sends; then it fails to the model as `tool.interrupted` ("may have run") and the session continues. A gateway that restarts mid call runs the call again under its key instead of answering `uncertain`. HTTP tools get the key as `Idempotency-Key`, as before; MCP servers now get it in `_meta["nylorun/idempotency-key"]` on `tools/call`. A tool that honors the key acts once; `attempts` above 1 marks where one may have acted twice.
570
596
  - **Sandbox commands are never run twice.** A sandbox or core-served call a crash interrupted has no key to dedupe on, so it fails to the model as `tool.interrupted` at once, and the model decides whether to run it again.
571
- - **No tool call parks a session.** The `uncertain` state for tool calls, its cancel-only exit and R2b's read-only/idempotent `mcp.lost` exception are gone: a lost MCP answer is `mcp.lost` to the model for every tool. Model calls keep their own rules.
597
+ - **No tool call parks a session.** The `uncertain` state for tool calls, its cancel-only exit and the earlier read-only/idempotent `mcp.lost` exception are gone: a lost MCP answer is `mcp.lost` to the model for every tool. Model calls keep their own rules.
572
598
  - **The gateway runs only journaled calls.** Under a run token, `/nylorun/v1/tool-calls` and `/nylorun/v1/http-calls` need the call's effect id as `Idempotency-Key` (`400 key_required`), and the effect journal must hold it running, for the run's turn, the same tool and the same input (`409 effect_not_journaled`). A harness that skips the journal gets nothing run.
573
599
  - `@nylorun/harness`: `HarnessExecutors.resends(effect, error, run)` says a gate hop lost a call's answer; the harness then asks core again with the same intent and sends the call again.
574
- - **Approval** stays in the manifest and our harness still asks for it. Only the Runtime's own harness asks: one built from the Harness API can skip it until tool policy moves to the gateway (R5 step 2).
600
+ - **Approval** stays in the manifest and our harness still asks for it. Only the Runtime's own harness asks: one built from the Harness API can skip it until tool policy moves to the gateway.
575
601
 
576
- - 6061a3a: **Tool approvals are the Tenant's tool policy (R5 step 2).** An agent's manifest used to say which tool calls wait for a person, and only the Runtime's own harness asked; a harness built from the Harness API could skip it. Now the operator sets one tool policy for every agent and every harness, and the Runtime enforces it before anything is sent.
602
+ - 6061a3a: **Tool approvals are the Tenant's tool policy.** An agent's manifest used to say which tool calls wait for a person, and only the Runtime's own harness asked; a harness built from the Harness API could skip it. Now the operator sets one tool policy for every agent and every harness, and the Runtime enforces it before anything is sent.
577
603
 
578
604
  - **`GET`/`PUT /v1/tenant/tool-policy`** (the Management API; `admin.toolPolicy.get()`/`.put({ rules })`): rules `{ effect: "allow" | "ask" | "deny", tool?, server?, kind?, agent?, when?, reason? }`. A rule matches a call when every selector it sets matches (`tool` and `server` take `*` globs; `when` tests input fields by dotted path with `equals`, `in`, `gt`, `gte`, `lt`, `lte` or `matches`). The strictest matching rule decides; a call no rule matches runs.
579
605
  - **Enforced for every harness.** Core decides an MCP or HTTP tool call as it journals it. `deny` fails it to the model as `tool.denied`, unsent. `ask` holds the call (`held` at `/calls/tool`) and pauses the turn with one `approval` interaction per held call (`turn.paused`, with the tool, its input and the reason). `approve` sends that exact call, or fails it as `tool.denied`. The Tool Gate runs only calls the journal holds running, so a held or refused call cannot run. Nothing holds a process while it waits: an approval survives a restart. A flow's HTTP stages are decided the same way.
@@ -581,7 +607,7 @@
581
607
  - `@nylorun/studio`: a paused session shows an approval card for each held call, with its tool, why it is held and its input, and **Approve** / **Deny**.
582
608
  - Migration: move each `approval: "always"` to an `ask` rule (see MIGRATION.md).
583
609
 
584
- - 7800358: **Each turn is one OpenTelemetry trace, projected from the session log (R7).** An operator could not see what a turn did or where its time went without grepping container logs. Now every turn is a trace with a span for each model call, tool call and egress tunnel, exported over OTLP to any collector, readable per turn from the Runtime, and joined to the trace of the app that started it. No protocol change.
610
+ - 7800358: **Each turn is one OpenTelemetry trace, projected from the session log.** An operator could not see what a turn did or where its time went without grepping container logs. Now every turn is a trace with a span for each model call, tool call and egress tunnel, exported over OTLP to any collector, readable per turn from the Runtime, and joined to the trace of the app that started it. No protocol change.
585
611
 
586
612
  - **Traces from the log.** A turn's end is its root span, `invoke_agent <agent>`; each model call is a `chat <model>` span, each tool call and flow HTTP stage an `execute_tool <tool>` span, each egress-gate tunnel a `CONNECT <host>` span, and each pause and answer a marker. A model or gate tool span is the gate's own start and end; usage and cost are the gate's (`nylorun.usage.mismatch` when the harness reported other numbers). Attribute names follow the OTel GenAI conventions at one pinned commit, recorded as `nylorun.semconv.genai` on the resource. Ids are derived from the log under a key the Tenant keeps (setting `trace.key`), so every export and read of a turn gives the same ids.
587
613
  - **OTLP export, off until you set an endpoint.** With `OTEL_EXPORTER_OTLP_ENDPOINT` (or `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`) the Runtime posts OTLP/HTTP JSON from a replication slot of its own, `nylorun_trace_export`, in batches of up to 512 spans or every 2 s; `OTEL_EXPORTER_OTLP_HEADERS`, `OTEL_SERVICE_NAME` and `OTEL_RESOURCE_ATTRIBUTES` work as usual. No turn waits for it. A collector that is down costs only its spans: after three retries a batch is dropped and logged as `trace_export_dropped`, and the slot moves on, so Postgres keeps no WAL for it. `nylorun start` passes these variables to the runtime container.
@@ -592,7 +618,7 @@
592
618
 
593
619
  ### Patch Changes
594
620
 
595
- - e917bd6: **The Harness API is a published contract (R4.5).** Everything a harness sends or reads now has a schema in `@nylorun/core/harness-api`, and the Runtime validates with those same schemas:
621
+ - e917bd6: **The Harness API is a published contract.** Everything a harness sends or reads now has a schema in `@nylorun/core/harness-api`, and the Runtime validates with those same schemas:
596
622
  - the transport and the pod join (`HARNESS_API_PATH`, `HARNESS_API_HEADER`, `HOST_JOIN_PATH`, `HostJoinRequestSchema`, `HostJoinAnswerSchema`);
597
623
  - the Model and Tool Gate bodies (`ModelCallBodySchema`, `ToolCallBodySchema`, `HttpCallBodySchema`, the MCP bodies, `GATE_ERROR_CODES`);
598
624
  - the MCP snapshot (`McpSnapshotSchema`);
@@ -604,9 +630,9 @@
604
630
  Other changes:
605
631
  - `TurnStart` gains an optional `trace` (W3C `traceparent`) for the turn's trace context. Nothing fills it yet.
606
632
  - Core refuses a `hello` whose `api` is not `2`.
607
- - **The fixture model answers at the Model Gate (R4.3).** With a Tenant's `fixtureModel` seeded, the gate answers model calls itself and meters each one, like any model: a `model_usage` row with provider `fixture` and cost 0, readable at `GET /v1/sessions/{id}/calls/model`. Our harness no longer answers it locally.
633
+ - **The fixture model answers at the Model Gate.** With a Tenant's `fixtureModel` seeded, the gate answers model calls itself and meters each one, like any model: a `model_usage` row with provider `fixture` and cost 0, readable at `GET /v1/sessions/{id}/calls/model`. Our harness no longer answers it locally.
608
634
  - The fixture model also answers scripted markers: `fixture:text`, `fixture:tool <name> <json>`, `fixture:budget` and `fixture:slow <seconds>`.
609
- - **The sandboxes service can run a harness image (R4.4, Go).** `PUT /v1/pods/{name}` accepts `entrypoint: "image"`: the workload image's own `ENTRYPOINT` and `CMD` run, with no engine copied in and no `harnessImage`. The default, `entrypoint: "engine"`, is unchanged. The Runtime starts sending it with the harness pin in a later change.
635
+ - **The sandboxes service can run a harness image (Go).** `PUT /v1/pods/{name}` accepts `entrypoint: "image"`: the workload image's own `ENTRYPOINT` and `CMD` run, with no engine copied in and no `harnessImage`. The default, `entrypoint: "engine"`, is unchanged. The Runtime starts sending it with the harness pin in a later change.
610
636
 
611
637
  - Pin core to the tested release.
612
638
  - Updated dependencies [17a97e9]
@@ -658,20 +684,20 @@
658
684
 
659
685
  ### Minor Changes
660
686
 
661
- - 18f9a2f: **Model-safe MCP tool names, coded MCP tool errors and credential scrubbing** (R2b C6, C7, C8). MIGRATION.md (protocol 10, "Tool and MCP server names" and "Tool errors the model sees") has the details.
687
+ - 18f9a2f: **Model-safe MCP tool names, coded MCP tool errors and credential scrubbing**. MIGRATION.md (protocol 10, "Tool and MCP server names" and "Tool errors the model sees") has the details.
662
688
 
663
689
  - `@nylorun/core`: a declared tool's name and an MCP server's name must match `^[A-Za-z0-9_-]{1,64}$` (`AgentManifestSchema`, so `PUT /v1/agents/{id}` refuses others). `mcp.discovered`'s server outcomes gain `renamed: [{ serverToolName, name }]`; `tool.completed` gains `redacted` and its `error` gains `retryable`. A failed `ToolOutcome` and `ToolResult` may carry `retryable`.
664
690
  - `@nylorun/harness`: a failed tool result keeps the outcome's `retryable`, and the model sees it beside `code` and `message`.
665
691
  - `@nylorun/runtime`: the model knows an MCP tool by `server__tool` with characters outside `[A-Za-z0-9_-]` replaced by `_`, shortened to 64 with an 8-hex SHA-256 suffix (also given to a renamed tool that collides); the server is still called by its own name. A failed MCP tool call is a failed tool result the model sees, with code `mcp.unreachable` (never sent; retryable), `credential_rejected` (`401`), `mcp.forbidden` (`403`), `mcp.error` (a JSON-RPC error) or `mcp.status` (another HTTP status); a call whose answer was lost after it was sent is `mcp.lost` for a `readOnlyHint` or `idempotentHint` tool and stays `uncertain` otherwise, as does a call lost with a gateway restart. A pooled connection whose server ended its session (`404` to its `Mcp-Session-Id`) or whose credential's `via` moved is dropped, opened again, and the call sent once more, since the tool never saw it. The credential values sent on a call (at least 8 characters, and a `Bearer` value's token) are replaced with `[redacted]` in MCP and HTTP tool results and errors before the gate records or returns them; no other field is touched.
666
692
 
667
- - 90a817d: **MCP and HTTP tool results that fit** (R2b C11). MIGRATION.md (protocol 10, "Tool results that fit") has the details.
693
+ - 90a817d: **MCP and HTTP tool results that fit**. MIGRATION.md (protocol 10, "Tool results that fit") has the details.
668
694
 
669
695
  - `@nylorun/core`: a completed `ToolOutcome` may carry `files` (`ToolResultFile`: a media type and the host's reference) and `truncated`; a completed `ToolResult` carries the `files`. `artifactsCapabilityManifest({ save, read })` adds the built-in `read_artifact` (`READ_ARTIFACT_TOOL`, `READ_ARTIFACT_MAX_BYTES`), and `codeToolsOf` leaves it alone. `SessionView` gains `definitionHash`, the definition the session was opened from. Transcript edits are split at 48 KiB, down from 256 KiB, so each `transcript.updated` event stays under 64 KiB when no entry is larger.
670
696
  - `@nylorun/harness`: a tool result's files go to the model after its output, as media parts; an outcome marked `truncated` is not checked against the tool's output schema.
671
697
  - `@nylorun/runtime`: an agent's remote MCP or HTTP tool result past 32 KiB is stored as a file artifact of the session, and the model gets `{ truncated: true, artifactId, size, preview }` (the first 4 KiB and the last 1 KiB). Image, audio and blob resource parts become artifacts too, an image also shown to a model that reads images (a note for one that does not); each part of a mixed result is shaped alone, and a `resource_link` stays a link. One step's results share a 256 KiB budget, so many parallel results never make an event near S2's 1 MiB record: past it, a result is a stub naming its artifact. When an artifact cannot be stored, the preview stays and `dropped` says why. An MCP answer past 8 MiB is `mcp.too-large`. `read_artifact { artifactId, offset?, length? }` reads 32 KiB of the session's own artifact a call, with or without a sandbox: a session gets it for each agent with an MCP server or an HTTP tool. The session view names its `definitionHash`.
672
698
  - `@nylorun/studio`: a session is shown as running an older manifest only when the definition it was opened from is not the registered one, not because the Runtime pinned its own tools (a sandbox's, `save_artifact`, `read_artifact`) beside it.
673
699
 
674
- - b8d10cb: **Per-tool MCP settings (manifest v6) and deferred tools** (R2b C9, C10). MIGRATION.md (protocol 10, "Per-tool settings and manifest v6" and "Deferred tools") has the details.
700
+ - b8d10cb: **Per-tool MCP settings (manifest v6) and deferred tools**. MIGRATION.md (protocol 10, "Per-tool settings and manifest v6" and "Deferred tools") has the details.
675
701
 
676
702
  - `@nylorun/core`: an MCP server takes `tools` (`McpToolSettings` by the server's own tool name, `"*"` for the rest: `enabled`, `approval`, `deferred`) and `deferred`, in manifest v6. `mcp()` and `Agent.mcp()` accept them, and the builder writes v6 only for a manifest that uses them, so other manifests keep their hashes; `AgentManifestSchema` accepts v5 unchanged and refuses the fields in v5. `mcpToolSettings` resolves a tool's settings, `manifestVersionFor` says which version a definition needs. `isVariantOf` lets a turn variant disable an MCP tool or require its approval, and nothing else. `TOOLS_CAPABILITY_ID`, `TOOL_SEARCH_TOOL`, `TOOL_CALL_TOOL`, `deferredToolsTools` and `deferredToolsInstructions` describe `tool_search` and `tool_call`. A session tool may carry instructions, read with its capability's. `mcp.discovered` gains `deferred`, `disabled` and `unknownTools` per server.
677
703
  - `@nylorun/harness`: a session tool marked `deferred` stays out of the model's tool list; `tool_call` runs it as its own call, after checking the arguments against its `inputSchema`, and asks for approval when it needs it.
@@ -702,7 +728,7 @@
702
728
 
703
729
  ### Major Changes
704
730
 
705
- - 4bd2a0b: **Flows run no code: workflow manifest v3 (manifest-only agents, step M2).** A flow agent is data: each stage gets the previous stage's output, a switch reads it, a map runs over it and a loop asks a verifier agent. See MIGRATION.md for what replaces each function.
731
+ - 4bd2a0b: **Flows run no code: workflow manifest v3 (manifest-only agents).** A flow agent is data: each stage gets the previous stage's output, a switch reads it, a map runs over it and a loop asks a verifier agent. See MIGRATION.md for what replaces each function.
706
732
 
707
733
  - **Breaking (`@nylorun/core`, `@nylorun/agents`):** stage `input` functions, `switch` `on`, loop `verify` functions and `decide` are removed; a builder option that names one is refused with what replaces it. `.loop()` takes a verifier agent and a required `max`. New `.pipe(...children)` adds one stage per child; `.step()` is a deprecated alias (`NYLORUN_DEP_STEP`). `Chain`, `Switch`, `Parallel`, `Map`, `Loop`, `withInstructions`, `withoutTools`, `isSlot`, `functionKey` and the `StageArgs`, `LoopVerifyFn`, `LoopDecideArgs`, `LoopChoice` and v1 workflow types are removed. `Agent.from` for a flow takes tool nodes only.
708
734
  - **Breaking (`@nylorun/core`):** workflow manifests are `workflowSchemaVersion: 3`; no node carries `input`, a switch has no `on`, a loop's `verify` is an agent and `max` is required. A v1 or v2 manifest is refused with a message naming the change. The `fn` and `verify` Actions and effect kinds, and the `loop.decided` event, are removed. `WorkflowManifestV2` / `WorkflowNodeV2` / `isWorkflowManifestV2` are now `WorkflowManifest` / `WorkflowNode` / `isWorkflowManifest`.
@@ -710,7 +736,7 @@
710
736
  - **Breaking (`@nylorun/runtime`):** no `fn` or `verify` Actions are offered or delivered. An agent stage's message shows the flow's input as the original request before its own input, and each verifier verdict is recorded as `loop.verified`.
711
737
  - `@nylorun/studio`: the workflow tree draws v3 manifests (a loop shows its verifier agent and `max`); the loop timeline drops decide outcomes, and `loop.verified` shows the feedback.
712
738
 
713
- - 40b7648: **HTTP tools and static approval (manifest-only agents, M3).** A tool can be one HTTP request the Runtime makes through its Tool Gate, with no Action endpoint; code tools keep working.
739
+ - 40b7648: **HTTP tools and static approval (manifest-only agents).** A tool can be one HTTP request the Runtime makes through its Tool Gate, with no Action endpoint; code tools keep working.
714
740
 
715
741
  - `@nylorun/core`: `ToolManifest` gains `http` (`url`, `method` `POST`/`PUT`/`PATCH`, `credential`, `timeoutMs` up to 300000) and `approval` (`never`/`always`, HTTP tools only); a tool is never both an agent and an HTTP request, and `fn` and `command` are refused ("Functions are not available yet"). Remote MCP servers take `approval`. `http()` builds an HTTP tool, `httpToolOf()` reads one; `SESSION_ID_HEADER`, `TURN_ID_HEADER` and `AGENT_ID_HEADER` name the headers it sends. `Agent.from` rebuilds HTTP tools without an implementation; an HTTP tool is refused as a flow stage.
716
742
  - `@nylorun/harness`: hosted HTTP tools keep their target, and `approval: "always"` (an HTTP tool's, or `DurableSessionTool.approval` for a remote MCP server's tools) pauses each call for approval. **Breaking:** `HarnessExecutors.recovers.remoteMcp` is renamed `recovers.tool`.
@@ -718,7 +744,7 @@
718
744
  - `@nylorun/runtime`: the Tool Gate runs HTTP tool calls (`POST /nylorun/v1/http-calls` at the gates service, or in process): the input as JSON under the Host's address policy, the session's vault credential bound to the URL, `Nylorun-Session-Id`/`-Turn-Id`/`-Agent-Id` and the effect id as `Idempotency-Key`. A keyed call runs once (`tool_crossings`), so a re-send after a takeover joins it and one lost with the gateway is `uncertain`. Non-2xx answers, timeouts, refused addresses, missing credentials and output mismatches are tool errors the model sees. The credential resolver is asked with `target.kind: "http"` and the tool's `credential` name.
719
745
  - `@nylorun/studio`: the Agent Manifest tab lists HTTP tools with their method and URL, and marks tools and MCP servers that wait for approval.
720
746
 
721
- - c135267: **Action endpoints are removed (manifest-only agents, M6).** The Runtime runs no code of yours during a session: an agent's tools are HTTP tools, remote MCP servers, agents used as tools and the Runtime's built-ins. Protocol stays 8; the `action-endpoints` feature is gone, so a client that requires it is refused. See MIGRATION.md, "Action endpoints are removed".
747
+ - c135267: **Action endpoints are removed (manifest-only agents).** The Runtime runs no code of yours during a session: an agent's tools are HTTP tools, remote MCP servers, agents used as tools and the Runtime's built-ins. Protocol stays 8; the `action-endpoints` feature is gone, so a client that requires it is refused. See MIGRATION.md, "Action endpoints are removed".
722
748
 
723
749
  - **Breaking (`@nylorun/core`):** the `Action`, endpoint (`PutEndpointsRequest`, `Endpoint`, `EndpointHealth`, …) and delivery schemas, `SIGNATURE_HEADER`, `OUTCOME_HEADER`, `DELIVERY_TOKEN_TYPE` and the `action.*` events (`action.pending`, `.delivered`, `.delivery_failed`, `.completed`, `.uncertain`) are removed, and `ToolDefinition.background` with them. `ActionOutcome` is renamed `EffectOutcome`. Tenant status loses `checks.endpoints`, `agents[].registered` and `agents[].endpoint`, and `counts.pendingActions`; the session view loses `actions`. A `turn.paused` interaction carries the tool call's `callId`. New `codeToolsOf` and `codeToolRefusal` name a definition's tools that would run your code. The Harness API is v2 (`HARNESS_API_VERSION = 2`): `TurnStart.options.holdMs` and `effect.resolved` are removed.
724
750
  - **Breaking (`@nylorun/harness`):** held runs are gone: `createHarness` loses `holdMs`, and `apiHost` its `hold` option.
@@ -729,7 +755,7 @@
729
755
  - `nylorun`: the local stack's comments speak of MCP servers and HTTP tools on this machine, not Action endpoints.
730
756
  - `@nylorun/studio`: the `action.*` event views and delivery status are removed; the chat shows `tool.completed`, and the Agent Manifest tab lists tools without a target as code tools.
731
757
 
732
- - d36f0d9: **Hooks are removed; manifests are v5 (manifest-only agents, step M1).** The Runtime no longer calls the developer's code before or after a turn or a model call. See MIGRATION.md for what replaces each use.
758
+ - d36f0d9: **Hooks are removed; manifests are v5 (manifest-only agents).** The Runtime no longer calls the developer's code before or after a turn or a model call. See MIGRATION.md for what replaces each use.
733
759
 
734
760
  - **Breaking (`@nylorun/core`, `@nylorun/agents`):** `.beforeTurn()`, `.beforeModel()`, `.afterModel()`, `.afterTurn()`, the deprecated `.before()` / `.after()`, a capability's `before` / `after`, and the `Patch`, `Decision`, `TurnDecision`, `BeforeHook`, `AfterHook`, `HookScope` types and `runHookPoint` / `hooksFrom` helpers are removed. A capability that still passes `before` or `after` is refused with `hooks were removed: …`.
735
761
  - **Breaking (`@nylorun/core`):** `manifestSchemaVersion` is 5. `capabilities[].hooks` is gone; a manifest that names it, or a v3/v4 manifest, is refused with a message naming the change. The `hook` Action and the `hook` effect kind of the Harness API are removed.
@@ -739,7 +765,7 @@
739
765
 
740
766
  ### Minor Changes
741
767
 
742
- - a64aaca: **HTTP in flows (manifest-only agents, after M2 and M3).** An `http()` tool is a flow stage, and `http({ url })` is a Loop's HTTP verifier; the Runtime makes both requests through its Tool Gate, with no Action endpoint.
768
+ - a64aaca: **HTTP in flows (manifest-only agents).** An `http()` tool is a flow stage, and `http({ url })` is a Loop's HTTP verifier; the Runtime makes both requests through its Tool Gate, with no Action endpoint.
743
769
 
744
770
  - `@nylorun/core`: an HTTP tool may be a stage in `.pipe()`, a switch case, a Map item or a Loop body; its tool node carries its `http` target and binds nothing. The build refuses an HTTP stage whose input is known to be the wrong type (`flow.input-mismatch`, e.g. after an agent with no `.output()`) and `approval: "always"` on one (`flow.approval-unsupported`). `http()` without a name and an input returns an `HttpTarget`, an HTTP verifier: `.loop(body, { verify: http({ url, method?, credential?, timeoutMs? }), max })`, in the manifest `loop.verify: { http }`. `fn` and `command` verify targets are refused ("Functions are not available yet"). New `flowHttpTarget()` finds an HTTP stage or verifier by stage key; `isHttpTarget()`, `WorkflowHttpVerify` and `WorkflowLoopVerify` are exported.
745
771
  - `@nylorun/harness`: the flow engine checks an HTTP stage's input against its schema (`tool.invalid-input`), runs it as a `tool` effect and fails the stage on a failed outcome (`http.status`, `http.timeout`, `tool.invalid-output`, …). An HTTP verifier is a `tool` effect with `{ input, output, iteration }` and `context.role: "verify-http"`; a non-verdict or a failed request is `loop.verify-failed`. A Loop body that starts with an HTTP stage is retried with the Loop's input.
@@ -749,7 +775,7 @@
749
775
 
750
776
  ### Patch Changes
751
777
 
752
- - 107b07d: **Skills are files the Runtime holds and serves itself (track R2 M4).** Breaking: a skill's manifest names every file of its folder, and the skill tools no longer run in the developer's process. The protocol stays at 8 until the track ships.
778
+ - 107b07d: **Skills are files the Runtime holds and serves itself.** Breaking: a skill's manifest names every file of its folder, and the skill tools no longer run in the developer's process. The protocol stays at 8 until the track ships.
753
779
 
754
780
  - `@nylorun/core`: `SkillManifest` gains `files`, each path of the skill's folder (`SKILL.md` required, `/`-separated, no `..`, at most 500 files) mapped to `sha256:<hex>`, so the manifest hash pins them. `skillRecords` and `SkillRecord` are gone; a declaration's `skillFiles` holds the bytes to upload (`SkillFileSource`). `load_skill` and `read_skill_resource` keep their names and input schemas but fail with `skills.runtime-only` outside a Runtime. New `DefinitionFileViewSchema`, error code `definition_files_missing`, Harness API request `definition.file`, and `definitionFilesOf`, `isSkillTool` and the definition-file limits. A top-level `functions` key is reserved and refused ("Functions are not available yet").
755
781
  - `@nylorun/runtime`: `PUT /v1/files/sha256:<hex>` stores a definition file (application key; at most 10 MiB; a body of another hash is `400`; `201` stored, `200` held already) in the Object store at `definitions/sha256/<hex>`, and `HEAD` says whether the Tenant holds one. New tables `definition_files` and `definition_file_uses` (migration `0013_definition_files`). `PUT /v1/agents/{id}` refuses a definition, nested agents and flow agents included, that names a file the Tenant lacks (`400 definition_files_missing`). Core serves `load_skill` (the `SKILL.md` body, the other files' paths, and `sandboxPath` with a sandbox) and `read_skill_resource` (text files only) from those files, with no Action. A session's sandbox gets each skill's files read-only under `/skills/<name>/` before the first call that opens it, and the sandbox's instructions name them; pod sandboxes mount an `emptyDir` at `/skills`. Unused files are not deleted yet.
@@ -798,13 +824,13 @@
798
824
 
799
825
  ### Minor Changes
800
826
 
801
- - b6bf1f5: **Harness API v1, in process (F6.1).** Every segment now runs in a harness: the advance takes the session's lease and offers the segment as a run, and the Tenant's own harness, in the same process, runs the engine and reports how it ended. Core settles it exactly as before. Nothing changes on the wire: protocol 5, durable checkpoint 1, engine `hosted-3` and the Action endpoint wire are the same.
827
+ - b6bf1f5: **Harness API v1, in process.** Every segment now runs in a harness: the advance takes the session's lease and offers the segment as a run, and the Tenant's own harness, in the same process, runs the engine and reports how it ended. Core settles it exactly as before. Nothing changes on the wire: protocol 5, durable checkpoint 1, engine `hosted-3` and the Action endpoint wire are the same.
802
828
 
803
829
  - `@nylorun/core/harness-api`: the protocol (messages, Zod schemas, the effect request hash, transcript edits, an RPC channel with an in-process memory transport).
804
830
  - `@nylorun/harness/api`: `createHarness({ channel, executors })`, a harness that leases runs, renews their leases, replays a run's recorded outcomes without asking, keeps transcripts by record cursor, and runs model, MCP and sandbox calls through the executors it is given.
805
- - `@nylorun/runtime`: the Harness API server per Tenant (`TenantHandle.attachHarness`), the in-process harness, and the journal as the Record seam. A model call's journal row now stores the request's hash without its prompt, so a replay never sends a prompt twice. `NYLORUN_HARNESS_API=0` runs the engine in the advance as before, until F6.2 removes it. A Runtime older than this one may fail a turn that was in flight across a downgrade with drift.
831
+ - `@nylorun/runtime`: the Harness API server per Tenant (`TenantHandle.attachHarness`), the in-process harness, and the journal as the Record seam. A model call's journal row now stores the request's hash without its prompt, so a replay never sends a prompt twice. `NYLORUN_HARNESS_API=0` runs the engine in the advance as before, until a later release removes it. A Runtime older than this one may fail a turn that was in flight across a downgrade with drift.
806
832
 
807
- - 8ed4ea6: **Harness service over WebSocket, with the workspace capability (F6.2).** A Runtime started with `NYLORUN_HARNESS=remote` runs no harness of its own: it opens the Harness API listener (`NYLORUN_HARNESS_LISTEN_HOST`/`_PORT`, default port 4200, `NYLORUN_HARNESS_ALLOWED_HOSTS`), which accepts only the harness credential (`NYLORUN_HARNESS_TOKEN`) on `/nylorun/harness/v1`. The runtime image's `--service harness` connects to it (`NYLORUN_HARNESS_URL`, `NYLORUN_HARNESS_TOKEN`, `NYLORUN_GATES_URL`, `NYLORUN_HARNESS_ROOT`) and runs the Tenant's segments, MCP servers and sandboxes with no store; it refuses to start with a database, the gates' or keys' credential, or Restate settings, and presents only run tokens at the gates. The in-process harness stays the default.
833
+ - 8ed4ea6: **Harness service over WebSocket, with the workspace capability.** A Runtime started with `NYLORUN_HARNESS=remote` runs no harness of its own: it opens the Harness API listener (`NYLORUN_HARNESS_LISTEN_HOST`/`_PORT`, default port 4200, `NYLORUN_HARNESS_ALLOWED_HOSTS`), which accepts only the harness credential (`NYLORUN_HARNESS_TOKEN`) on `/nylorun/harness/v1`. The runtime image's `--service harness` connects to it (`NYLORUN_HARNESS_URL`, `NYLORUN_HARNESS_TOKEN`, `NYLORUN_GATES_URL`, `NYLORUN_HARNESS_ROOT`) and runs the Tenant's segments, MCP servers and sandboxes with no store; it refuses to start with a database, the gates' or keys' credential, or Restate settings, and presents only run tokens at the gates. The in-process harness stays the default.
808
834
 
809
835
  - `@nylorun/core/harness-api`: the `workspace.*` requests core sends to a harness that serves workspaces, `tenantId` in the `hello` answer, a workspace record on `sandbox.state` claims, and `TurnStart.options.holdMs`. Tenant and admin status report the Tenant's harnesses (`harness`).
810
836
  - `@nylorun/harness/api`: `createHarness` declares capabilities, reports grants (`onGrant`) and the `hello` answer, readies MCP through `executors.prepare` (`session.mcp`), and holds a run while its Action is pending until core sends the outcome (`effect.resolved`).
package/HOST_CONTRACT.md CHANGED
@@ -6,7 +6,7 @@ Artifact: `@nylorun/harness@0.14.0-beta.3`. Package version is separate from pro
6
6
 
7
7
  Bearer application credentials: `PUT /v1/agents/:agentId` (`PutAgentRequest`: requestId, complete manifest, implementationVersion); `PUT /v1/sessions/:sessionId` (`PutSessionRequest`: requestId, agentId, trusted ownerUserId, optional info, optional `environment` — the id of an Environment (protocol 11): its sandbox (kinds `virtual` and `pod`) and its vault are the session's, with the recipe it applies pinned at open; omitted means no sandbox and no credentials; fixed for the session's life); `GET /v1/sessions/:sessionId`; `POST /v1/sessions/:sessionId/commands`; `GET /v1/sessions/:sessionId/items?cursor=...`; `GET /v1/sessions/:sessionId/events?cursor=...` (SSE, Last-Event-ID also accepted). Environments (`PUT/GET/DELETE /v1/environments/:environmentId`, `/stop`, `/reset`, `/events`, disk versions) and their secrets (`PUT/GET/DELETE /v1/environments/:environmentId/secrets/:name` and `GET .../secrets`: names, types and bindings, never a value) are Runtime API routes. Bearer management keys (the Management API, protocol 8; an application key there is `403 key_role_mismatch`): the `/v1/tenant/*` model routes below, the tool policy (`/v1/tenant/tool-policy`) and the Tenant's settings. Commands use `SessionCommandSchema`. A `message` command is exactly one of `{ content: string }` or `{ data: JsonValue }`, plus optional `manifest` (turn-only agent variant; see Turn manifests below). Application principals may call `POST /v1/sessions/:id/sandbox/:tool` for session-scoped sandbox built-ins when the session has a sandbox and no active agent turn. An Environment whose owner guard (`ownerUserId`) names another owner cannot be named by the session (the opaque `404`). `GET /v1/tenant/model` returns `{configured:false}` or the active provider, model, authType, and optional baseUrl, never the secret. `PUT /v1/tenant/model` upserts a host-scope provider credential and makes it active (idempotencyKey, requestId excluded from comparison). `PUT /v1/tenant/model/selection` switches the active provider/model among configured credentials without a new secret. `GET /v1/tenant/providers` lists configured providers with name, model, authType, lastUpdated, and active. `GET /v1/tenant/models` returns the public provider catalog, each model with the inputs it reads (`inputs`) and those the operator may add (`addableInputs`); `PUT /v1/tenant/models/inputs` sets the added ones (protocol 12), and `GET /v1/tenant/providers` gives each provider's `inputs`. agentId, ownerUserId, info and environment stay the creation identity. GET session returns id, agentId, ownerUserId, status, activeTurnId, `environment: { id, version } | null`, the pinned `harness`, `closedReason` on a closed session, mcpSnapshot, mcpDiagnostics, plus inspectable waits/uncertainty as available. mcpSnapshot is null until the first turn discovers MCP tools; it is then pinned for the session (v2, protocol 15: what the servers listed, by their own tool names, disabled tools included) and contains no secrets. History returns `{items: LiveEvent[], cursor: string|null}`; empty history cursor is null.
8
8
 
9
- **Manifest-only agents (protocol 8, track R2).** The Runtime runs the whole agent from its manifest and its definition files, and never calls the developer's code during a session: Action endpoints, delivery tokens, background tools and held runs are gone (`/v1/endpoints` and `/v1/actions/*` answer `404`). An agent's tools are HTTP tools (`http`), remote MCP servers, agents used as tools and the Runtime's built-ins. `PUT /v1/agents/:agentId` refuses (`400`) a definition with a tool that has no `http` and no `agent`, and a flow agent with a `tool` stage (`codeToolRefusal` in `/define`); a tool effect the Runtime cannot run fails with `tool.unavailable`. `tool({ run })` runs only in the local engine (`/run`).
9
+ **Manifest-only agents (protocol 8).** The Runtime runs the whole agent from its manifest and its definition files, and never calls the developer's code during a session: Action endpoints, delivery tokens, background tools and held runs are gone (`/v1/endpoints` and `/v1/actions/*` answer `404`). An agent's tools are HTTP tools (`http`), remote MCP servers, agents used as tools and the Runtime's built-ins. `PUT /v1/agents/:agentId` refuses (`400`) a definition with a tool that has no `http` and no `agent`, and a flow agent with a `tool` stage (`codeToolRefusal` in `/define`); a tool effect the Runtime cannot run fails with `tool.unavailable`. `tool({ run })` runs only in the local engine (`/run`).
10
10
 
11
11
  **Tenant and protocol headers.** A Host serves the one Tenant of its
12
12
  installation, and nothing in a request selects it (protocol 5). Every Tenant
@@ -26,8 +26,7 @@ body. A missing or rejected credential is `401` (`credential_required`,
26
26
  `credential_invalid`) with `WWW-Authenticate: Bearer` (protocol 9); on the
27
27
  Runtime API the challenge names `/.well-known/oauth-protected-resource` when
28
28
  the Host has trusted issuers. The Admin API is gone (protocol 8): `/v1/admin/*`
29
- is no route, and the admin key is no request's credential. Vocabulary:
30
- [runtime/server/src/CONTEXT.md](../server/src/CONTEXT.md).
29
+ is no route, and the admin key is no request's credential.
31
30
 
32
31
  Unauthenticated `GET /health` returns status, `service: "nylorun-runtime"`,
33
32
  version, `hostId`, pid, and `protocol: { min, max, features }` (plus diagnostic
@@ -37,21 +36,21 @@ Tenant is open; a Tenant that cannot be opened fails it with its cause
37
36
  (`schema-too-new`, `kek-missing`, `database-layout-old`, …), also reported in
38
37
  `nylorun-operate status` inside the runtime container (`nylorun status` on a local Tenant).
39
38
 
40
- All command idempotency keys bind to canonical request content within a session; requestId is transport metadata and is excluded from content comparison; exact semantic duplicates return the stored original response; changed content conflicts (409). Tool calls are delivered at least once (R5): an MCP or HTTP call a crash, a shutdown or a lost gate hop interrupted is sent again with the same key, its effect id (`Idempotency-Key`, or `_meta["nylorun/idempotency-key"]` for MCP), up to 3 sends; then, and for a sandbox or harness call at once, it fails to the model as `tool.interrupted` and is not run again. No tool call leaves its session `uncertain`. Results after cancellation cannot resume a turn. No hardcoded production credentials.
39
+ All command idempotency keys bind to canonical request content within a session; requestId is transport metadata and is excluded from content comparison; exact semantic duplicates return the stored original response; changed content conflicts (409). Tool calls are delivered at least once: an MCP or HTTP call a crash, a shutdown or a lost gate hop interrupted is sent again with the same key, its effect id (`Idempotency-Key`, or `_meta["nylorun/idempotency-key"]` for MCP), up to 3 sends; then, and for a sandbox or harness call at once, it fails to the model as `tool.interrupted` and is not run again. No tool call leaves its session `uncertain`. Results after cancellation cannot resume a turn. No hardcoded production credentials.
41
40
 
42
41
  ## Engine host
43
42
 
44
- `createDurableCheckpoint({manifest,sessionId,turnId,input,state?,info?,segment?})`, `runDurable({manifest,checkpoint,host,signal?,mcp?,engineTools?})` from `/run` (`engineTools(agent)`: what our engine adds to each agent of the tree, `{tools, instructions}` from `engineToolsFor(agent, turn.start.environment, options)`: the sandbox, skill and artifact tools and their text, offered after the agent's own tools and before the MCP tools, not hashed; `mcp`: the session's MCP tools as our engine offers them, `mcpToolSet(turn.start.mcp, manifest, {config, model?, layout?, taken?})`, in place of `sessionTools` (protocol 15): named for the model, deferred tools behind `tool_search` and `tool_call`, each call targeting the tool's identity, with the layout the segment's state keeps as `mcpLayout`, not hashed). `DurableHost.resolveEffect(HostEffect)` atomically creates or reads an individually identified effect and returns `{status:'completed',outcome:{value,statePatch?}}` or `{status:'pending'|'uncertain'}`. Model effect `input` is the complete ModelCall (instructions/history/tools/output schema); context contains invocationId, and a call that summarizes history says `purpose: "summary"` (its invocationId starts with `compaction-`). When history no longer fits the model's window, the engine replaces the older transcript entries with one `compaction` entry and keeps the rest; `runDurable` answers the root agent's summary calls of the segment (`summaryEffectIds`), and the API host marks the segment's transcript edit `kind: "compaction"` with them and the entry's facts (Q4, protocol 15). Hosts record no `message.assistant` for a summary call, and publish one `context.compacted` per compaction edit. Its completed value is a ModelCandidate, a string, or a failure outcome `{kind:'failed', code, message, retryable, retryAfterMs?}` for a provider failure the Runtime classified (codes in `MODEL_FAILURE_CODES`); the engine fails the step with `model.<code>`. A classified failure is a known outcome, not a lost one, so it is never `uncertain`. Runtime provider code owns credentials and invocation. Tool effects have toolName (the name the model called, for display), `target` (what runs the call, by identity, protocol 15: `{kind: "mcp", server, tool}` with the server's own tool name, `{kind: "http", tool}` with the declared name, `{kind: "sandbox"}` or `{kind: "harness"}`; the host routes by it, never by name, and it is in the request hash; an author's code tool has none, and the host fails it), optional `skill`, serialized input and context. The agent's `tools`, our engine's and the MCP tools never share a name: a clash fails the turn (`agent.build-failed`); an MCP tool whose name is taken is left out. Tool result value is a ToolOutcome or a plain tool output, shaped by the API host before it is recorded (`shapeToolOutcome`, `StepBudget`: one record entry at most, the rest stored as artifacts keyed by `spillKey`); statePatch contains changed session keys. Tool context includes invocationId, resume, state, info and stable idempotencyKey. Customer implementationVersion is pinned by the runtime outside durable checkpoints.
43
+ `createDurableCheckpoint({manifest,sessionId,turnId,input,state?,info?,segment?})`, `runDurable({manifest,checkpoint,host,signal?,mcp?,engineTools?})` from `/run` (`engineTools(agent)`: what our engine adds to each agent of the tree, `{tools, instructions}` from `engineToolsFor(agent, turn.start.environment, options)`: the sandbox, skill and artifact tools and their text, offered after the agent's own tools and before the MCP tools, not hashed; `mcp`: the session's MCP tools as our engine offers them, `mcpToolSet(turn.start.mcp, manifest, {config, model?, layout?, taken?})`, in place of `sessionTools` (protocol 15): named for the model, deferred tools behind `tool_search` and `tool_call`, each call targeting the tool's identity, with the layout the segment's state keeps as `mcpLayout`, not hashed). `DurableHost.resolveEffect(HostEffect)` atomically creates or reads an individually identified effect and returns `{status:'completed',outcome:{value,statePatch?}}` or `{status:'pending'|'uncertain'}`. Model effect `input` is the complete ModelCall (instructions/history/tools/output schema); context contains invocationId, and a call that summarizes history says `purpose: "summary"` (its invocationId starts with `compaction-`). When history no longer fits the model's window, the engine replaces the older transcript entries with one `compaction` entry and keeps the rest; `runDurable` answers the root agent's summary calls of the segment (`summaryEffectIds`), and the API host marks the segment's transcript edit `kind: "compaction"` with them and the entry's facts (protocol 15). Hosts record no `message.assistant` for a summary call, and publish one `context.compacted` per compaction edit. Its completed value is a ModelCandidate, a string, or a failure outcome `{kind:'failed', code, message, retryable, retryAfterMs?}` for a provider failure the Runtime classified (codes in `MODEL_FAILURE_CODES`); the engine fails the step with `model.<code>`. A classified failure is a known outcome, not a lost one, so it is never `uncertain`. Runtime provider code owns credentials and invocation. Tool effects have toolName (the name the model called, for display), `target` (what runs the call, by identity, protocol 15: `{kind: "mcp", server, tool}` with the server's own tool name, `{kind: "http", tool}` with the declared name, `{kind: "sandbox"}` or `{kind: "harness"}`; the host routes by it, never by name, and it is in the request hash; an author's code tool has none, and the host fails it), optional `skill`, serialized input and context. The agent's `tools`, our engine's and the MCP tools never share a name: a clash fails the turn (`agent.build-failed`); an MCP tool whose name is taken is left out. Tool result value is a ToolOutcome or a plain tool output, shaped by the API host before it is recorded (`shapeToolOutcome`, `StepBudget`: one record entry at most, the rest stored as artifacts keyed by `spillKey`); statePatch contains changed session keys. Tool context includes invocationId, resume, state, info and stable idempotencyKey. Customer implementationVersion is pinned by the runtime outside durable checkpoints.
45
44
 
46
45
  Persist checkpoint BEFORE scheduling, effect intent BEFORE provider invocation or notification, and outcome BEFORE resumption. Journaling an entire runDurable call as one replayable operation is forbidden. The durable path deterministically reconstructs a segment from its immutable starting checkpoint and individually cached effect outcomes. A waiting result returns that starting checkpoint: do not replace it with an intermediate preview. The journal is required continuation data and must be retained with the checkpoint. Stable IDs include turn/segment and deterministic invocation identity. There is no live continuation or request-held promise while waiting. Runtimes serialize work per session, check cancellation before effects and before settlement, and fence ownership. Lost provider acknowledgement becomes uncertain; do not repeat it merely because a worker restarts. Tool calls are the exception: they are re-sent with their key, as above.
47
46
 
48
- A terminal/paused result includes `result.state`. Save it. A new message uses a new turnId with prior completed state. Approval/response resumes paused state via a new checkpoint, same turnId, `segment + 1`, with `{kind:'approve',interactionId,approved}` or `{kind:'respond',interactionId,value}`. An action result simply reruns the SAME suspended checkpoint/segment after recording the outcome. `runDurable({yieldAfter: {steps, ms}})` lets a long turn end a segment at a step boundary with status `yielded` (Model Calls §10): the result state is mid-turn (status `active`, `turn` kept); save it, write a new checkpoint for the same turnId at `segment + 1` with input `{kind:'continue'}`, and schedule it. A yielded segment emits no `turn.*` event, and its effects are never read again. Paused plan records pending interactions/deferred calls; waiting on remote action is distinct from a human wait. Cancellation is host-owned and must fence both running and pending work. Runtime supplies canonical events; execution observations are not wire events and reconstruction must not republish duplicate history.
47
+ A terminal/paused result includes `result.state`. Save it. A new message uses a new turnId with prior completed state. Approval/response resumes paused state via a new checkpoint, same turnId, `segment + 1`, with `{kind:'approve',interactionId,approved}` or `{kind:'respond',interactionId,value}`. An action result simply reruns the SAME suspended checkpoint/segment after recording the outcome. `runDurable({yieldAfter: {steps, ms}})` lets a long turn end a segment at a step boundary with status `yielded`: the result state is mid-turn (status `active`, `turn` kept); save it, write a new checkpoint for the same turnId at `segment + 1` with input `{kind:'continue'}`, and schedule it. A yielded segment emits no `turn.*` event, and its effects are never read again. Paused plan records pending interactions/deferred calls; waiting on remote action is distinct from a human wait. Cancellation is host-owned and must fence both running and pending work. Runtime supplies canonical events; execution observations are not wire events and reconstruction must not republish duplicate history.
49
48
 
50
49
  Host resolveEffect must bind the effect ID to the original request and reject drift. Intent/outcome, checkpoint settlement and canonical event/outbox writes must use runtime transactions. The Runtime journals individual effect boundaries, not the loop, in the Session Store under the advance's lease; Durable Session Execution (Restate) only runs one advance per session at a time and delivers wakes and timers, and journals no effects. Scheduling, storage, publication, delivery policy and reconciliation remain runtime-owned.
51
50
 
52
51
  Agents used as tools: a manifest tool with an `agent` body (the child manifest inlined; name equals the child id, description equals the child description, input is the standard `{task}` schema, no outputSchema, no nested agent tools; the tree shares the session's one sandbox, whose spec the session keeps) is run by the engine inside the parent's `runDurable`. Its model and tool effects carry `agent: {id, path, delegationId}` (`delegationId` is the parent tool call's invocationId), keep the root `agentId` and `manifestHash`, and use identity `<delegationId>/<inner identity>`; tool context `idempotencyKey` is prefixed the same way. Hosts resolve child effects against the child manifest (`delegateManifest`) for pinned tool schemas and MCP routing, and include `agent` in `tool.completed` payloads; our engine gives each child its own skill tools and the session's sandbox tools. A `delegation` effect (identity `<delegationId>:started` or `<delegationId>:settled`, input `{task}` or `{status, outcome}`) must be recorded completed immediately with value null and publish `delegation.started` / `delegation.completed` exactly once; the journal makes replays silent. `DurableSessionTool.agentId` attaches discovered MCP tools to a child; MCP snapshot records and diagnostics carry `agentId`. Children share the session sandbox. `GET /v1/sessions/:id/items?agent=` filters history by `payload.agent.delegationId` or `payload.agent.path`. Existing checkpoints are unaffected; engine version stays `hosted-2`. A tool whose `agent` body is a flow agent (workflow manifest v3) is not run in-process: the engine issues one `agent` effect (identity `<delegationId>:flow`, input `{agentId, input: task, path}`, context `{role: "delegate", delegationId}`, `agent` ref set) between the `delegation` start and settle points. The host starts a linked flow session from the pinned parent manifest's inlined flow (session id `derive(parentSessionId, path, "delegate", delegationId)`), sends the task as its message, and completes the effect with the flow's output, or `{kind: "failed", code, message}`, when its turn ends. Cancelling the parent cascades to linked sessions.
53
52
 
54
- **Workflows (flow engine).** Definitions with `kind: "workflow"` (workflow manifest v3) run through `createFlowCheckpoint` / `runFlowDurable` from `/run` (same `DurableResult` shape as `runDurable`) on engine `flow-3`; checkpoints pin it, and v1/v2 manifests are refused. The turn loop in `runtime/harness/src/loop/` is unchanged. A flow runs no developer code: its effects are `agent` (a leaf agent's turn) and `tool` (a workflow tool node). Each carries `path` (the leaf path: the leaf's id, `[i]` per Map item, nested flow agent ids in front), `key` (the path without Map indices) and `iterations` (enclosing Loop vector as a dotted string, or `"-"` outside Loops). Effect ids are `${turnId}:${segment}:flow:${path}:${kind}:${iterations}`. The first stage gets the flow's input and each later stage the previous output; a Switch reads it (a string, or its `route` field), a Map runs over it (an array, or its `items`), and a Loop asks a verifier (an agent, or an HTTP verifier) for a verdict (`{ pass, feedback? }`) and retries the body with the feedback, up to `max`. `agent` effect input is `{ agentId, input, path, flow?, flowInput? }`: `flow` names the nested flow agents, outermost first; `flowInput` is the flow agent's input, sent when the stage's input differs, and the host puts it in the linked message as the original request before the stage's input. Effect `context` carries `loopPath` and `n` for a Loop's turns, and `role: "verify-agent"` for its verifier, which gets a fresh session per attempt and whose verdict the host records as `loop.verified`. The host resolves the leaf from the workflow manifest's embedded `agents` (`embeddedAgent`) and gives the linked session the leaf's manifest and its hash, only through the public session contract (create linked session, message with derived idempotency key, settle on linked `turn.completed` / failed / cancelled). A `tool` effect carries `path` + `key` instead of `toolName`. A code tool node (no `http`) runs only in the local engine: the Runtime refuses a flow with one at save and fails such an effect with `tool.unavailable`. The `tool` effects of an HTTP stage (a tool node with `http`, input checked against its schema first) and of an HTTP verifier (`loop.verify: { http }`, input `{ input, output, iteration }`, `context.role: "verify-http"`, at the verify position's key) are requests the host makes through its Tool Gate as for an agent's HTTP tool, the effect id as `Idempotency-Key`, the HTTP outcome (`{ kind: "completed", output }` or `{ kind: "failed", code, message }`) as the value, and an HTTP verifier's verdict recorded as `loop.verified`; a Loop body that starts with an HTTP stage is retried with the Loop's input. A lost HTTP stage is sent again with the same key, as an agent's HTTP tool call is (R5). Parallelism comes from pending effects returned together; the Runtime caps concurrency with `RuntimeOptions.flow` / env (`maxConcurrency`, `maxMapItems`, `maxLoopIterations`).
53
+ **Workflows (flow engine).** Definitions with `kind: "workflow"` (workflow manifest v3) run through `createFlowCheckpoint` / `runFlowDurable` from `/run` (same `DurableResult` shape as `runDurable`) on engine `flow-3`; checkpoints pin it, and v1/v2 manifests are refused. The turn loop in `runtime/harness/src/loop/` is unchanged. A flow runs no developer code: its effects are `agent` (a leaf agent's turn) and `tool` (a workflow tool node). Each carries `path` (the leaf path: the leaf's id, `[i]` per Map item, nested flow agent ids in front), `key` (the path without Map indices) and `iterations` (enclosing Loop vector as a dotted string, or `"-"` outside Loops). Effect ids are `${turnId}:${segment}:flow:${path}:${kind}:${iterations}`. The first stage gets the flow's input and each later stage the previous output; a Switch reads it (a string, or its `route` field), a Map runs over it (an array, or its `items`), and a Loop asks a verifier (an agent, or an HTTP verifier) for a verdict (`{ pass, feedback? }`) and retries the body with the feedback, up to `max`. `agent` effect input is `{ agentId, input, path, flow?, flowInput? }`: `flow` names the nested flow agents, outermost first; `flowInput` is the flow agent's input, sent when the stage's input differs, and the host puts it in the linked message as the original request before the stage's input. Effect `context` carries `loopPath` and `n` for a Loop's turns, and `role: "verify-agent"` for its verifier, which gets a fresh session per attempt and whose verdict the host records as `loop.verified`. The host resolves the leaf from the workflow manifest's embedded `agents` (`embeddedAgent`) and gives the linked session the leaf's manifest and its hash, only through the public session contract (create linked session, message with derived idempotency key, settle on linked `turn.completed` / failed / cancelled). A `tool` effect carries `path` + `key` instead of `toolName`. A code tool node (no `http`) runs only in the local engine: the Runtime refuses a flow with one at save and fails such an effect with `tool.unavailable`. The `tool` effects of an HTTP stage (a tool node with `http`, input checked against its schema first) and of an HTTP verifier (`loop.verify: { http }`, input `{ input, output, iteration }`, `context.role: "verify-http"`, at the verify position's key) are requests the host makes through its Tool Gate as for an agent's HTTP tool, the effect id as `Idempotency-Key`, the HTTP outcome (`{ kind: "completed", output }` or `{ kind: "failed", code, message }`) as the value, and an HTTP verifier's verdict recorded as `loop.verified`; a Loop body that starts with an HTTP stage is retried with the Loop's input. A lost HTTP stage is sent again with the same key, as an agent's HTTP tool call is. Parallelism comes from pending effects returned together; the Runtime caps concurrency with `RuntimeOptions.flow` / env (`maxConcurrency`, `maxMapItems`, `maxLoopIterations`).
55
54
 
56
55
  **Turn manifests.** A `message` command may include optional `manifest`. Any app may use it (not only Loops). When present, the Runtime parses it with `AgentManifestSchema`, requires it to be a **variant** of the session's pinned manifest (id, `outputSchema` and skills fixed, plugin labels included; tools and delegates may only be removed; MCP servers may only be tightened; it has no `runtime` field), hashes and stores it by hash for that turn only (it does not latch — a later message without `manifest` uses the pin), and rebases `state.manifestHash` at turn start when the prior state hash and the turn hash are both the pin or validated variants of it. Invalid variants fail closed.
57
56
 
@@ -59,17 +58,17 @@ Agents used as tools: a manifest tool with an `agent` body (the child manifest i
59
58
 
60
59
  ## Harness API 5
61
60
 
62
- The Runtime runs every segment through the Harness API: core keeps scheduling, the record, settle and takeover; a harness runs the engine. Three version numbers apply: the transport (path `/nylorun/harness/v1`, header `Nylorun-Harness-Api: 1`), the messages (`HARNESS_API_VERSION = 5`; core refuses a `hello` naming another `api`; 5 (protocol 16) replaced `turn.start.environment` with `turn.start.agent` (`{id, kind, sandbox?}`, the Agent the session runs on) and added `turn.start.definition` (`{name, version}`, the agent manifest version the session pinned) and `turn.start.loop` (the harness section's `loop`); 4 added the artifact seam, `artifact.read` and `artifact.write`, over which a harness reads and writes its run's session's artifacts, the error code `not_found`, `turn.start.model`, `turn.start.environment` and `turn.start.mcp` (the session's MCP discovery as raw facts), and each tool effect's `target` (an MCP or HTTP tool's identity), the folder mode of `artifact.write` (`kind: "folder"`, `file`, `refused`), `purpose: "summary"` on model intents, compaction edits (`kind: "compaction"` with `CompactionFactsSchema`) and the claims `artifact.export.skipped` and `artifact.export.failed`, and removed `hello.features.tools`, `turn.start.sessionTools`, `routing.mcpSnapshot`, the `platform` target and the `workspace.read` listing and bytes calls (core exports no outputs); 3 renamed `hello.capabilities` to `features` and dropped `capabilityId` from effect intents, MCP server refs, HTTP call bodies and MCP records) and the Runtime protocol, which only the Runtime and Management APIs carry. The whole contract is `@nylorun/core/harness-api` (R4.5): frames and messages, the transport and the pod join (`HostJoinRequestSchema`, `HostJoinAnswerSchema`), the Model and Tool Gate bodies (`ModelCallBodySchema`, `ToolCallBodySchema`, `HttpCallBodySchema`, MCP bodies, `GATE_ERROR_CODES`), the MCP snapshot (`McpSnapshotSchema`), transcript entries (`TranscriptEntrySchema`) and the effect id rule (`effectIdOf`: `<turnId>:<segment>:<kind>:<identity>`; a run gets back only its segment's outcomes), the request hash, transcript edits and the RPC channel; the Runtime validates with the same schemas, and the build writes them as one JSON Schema document (`@nylorun/core/harness-api/schema.json`). `TurnStart.trace` (optional W3C `traceparent`) is the turn's trace context when the Runtime traces. With the Tenant's fixture model on (`TurnStart.options.fixtureModel`, informational), the Model Gate answers model calls itself, metered like any model (provider `fixture`, cost 0), so a harness calls the gate as usual. Harness ids (R4.1): `hello.name` is the harness's id (ours says `nylorun`; `@nylorun/harness` is refused); a session pins its Environment's harness, else `nylorun`, and only a connection of that id takes its runs; a credential binds its id (the harness token is ours, a custom harness has its own from `nylorun-operate harness token put <id>`, a pod's host is its Environment's harness). A harness's state is its own (R4.2): core stores it unread; a custom harness's is at most 256 KiB, it cannot pause for approvals, and a tool it runs itself is a `harness` effect, journaled like ours. Events carry who wrote them (R4.9): `harness` with its id, `runId` and evidence `claimed` for what a harness reported. v2 removed held runs, `TurnStart.options.holdMs` and `effect.resolved`, with track R2; the harness client is `@nylorun/harness/api` (`createHarness({channel, executors, features?, mcpTools?, toolResults?, outputs?})`: `mcpTools` how our engine defers MCP tools and `tool_search`'s limits, `toolResults` how it shapes tool results, `outputs` its outputs folder's directory and byte bound, each partial over its defaults). Its executors' `files` (`read`, `write`, `list`, `mount`) are the sandbox files our engine decides about: before each `sandbox` call it mounts each skill version of the turn's tree at `/skills/<name>@<hash>/` (the host only writes, `present` when the sandbox holds it), and at a completed turn's end in a sandbox it saves `/workspace/outputs` as the session's `outputs` folder over the artifact seam before `turn.completed`. Placement changes none of it (protocol 15): the in-process harness calls models through the Model Gate (a scripted model's gate in tests), opens MCP servers through the Tool Gate, and reads skill bytes over `definition.file`. A Tenant runs one harness in its own process over a memory channel, or (F6.2, `NYLORUN_HARNESS=remote`) harnesses connect to core's Harness API listener over WebSocket (`/nylorun/harness/v1`, the harness credential): `--service harness` runs one with its own MCP pool and sandboxes and no store, and serves the Tenant's workspaces (`workspace.*`). Durable checkpoint 1 is unchanged.
61
+ The Runtime runs every segment through the Harness API: core keeps scheduling, the record, settle and takeover; a harness runs the engine. Three version numbers apply: the transport (path `/nylorun/harness/v1`, header `Nylorun-Harness-Api: 1`), the messages (`HARNESS_API_VERSION = 5`; core refuses a `hello` naming another `api`; 5 (protocol 16) replaced `turn.start.environment` with `turn.start.agent` (`{id, kind, sandbox?}`, the Agent the session runs on) and added `turn.start.definition` (`{name, version}`, the agent manifest version the session pinned) and `turn.start.loop` (the harness section's `loop`); 4 added the artifact seam, `artifact.read` and `artifact.write`, over which a harness reads and writes its run's session's artifacts, the error code `not_found`, `turn.start.model`, `turn.start.environment` and `turn.start.mcp` (the session's MCP discovery as raw facts), and each tool effect's `target` (an MCP or HTTP tool's identity), the folder mode of `artifact.write` (`kind: "folder"`, `file`, `refused`), `purpose: "summary"` on model intents, compaction edits (`kind: "compaction"` with `CompactionFactsSchema`) and the claims `artifact.export.skipped` and `artifact.export.failed`, and removed `hello.features.tools`, `turn.start.sessionTools`, `routing.mcpSnapshot`, the `platform` target and the `workspace.read` listing and bytes calls (core exports no outputs); 3 renamed `hello.capabilities` to `features` and dropped `capabilityId` from effect intents, MCP server refs, HTTP call bodies and MCP records) and the Runtime protocol, which only the Runtime and Management APIs carry. The whole contract is `@nylorun/core/harness-api`: frames and messages, the transport and the pod join (`HostJoinRequestSchema`, `HostJoinAnswerSchema`), the Model and Tool Gate bodies (`ModelCallBodySchema`, `ToolCallBodySchema`, `HttpCallBodySchema`, MCP bodies, `GATE_ERROR_CODES`), the MCP snapshot (`McpSnapshotSchema`), transcript entries (`TranscriptEntrySchema`) and the effect id rule (`effectIdOf`: `<turnId>:<segment>:<kind>:<identity>`; a run gets back only its segment's outcomes), the request hash, transcript edits and the RPC channel; the Runtime validates with the same schemas, and the build writes them as one JSON Schema document (`@nylorun/core/harness-api/schema.json`). `TurnStart.trace` (optional W3C `traceparent`) is the turn's trace context when the Runtime traces. With the Tenant's fixture model on (`TurnStart.options.fixtureModel`, informational), the Model Gate answers model calls itself, metered like any model (provider `fixture`, cost 0), so a harness calls the gate as usual. Harness ids: `hello.name` is the harness's id (ours says `nylorun`; `@nylorun/harness` is refused); a session pins its Environment's harness, else `nylorun`, and only a connection of that id takes its runs; a credential binds its id (the harness token is ours, a custom harness has its own from `nylorun-operate harness token put <id>`, a pod's host is its Environment's harness). A harness's state is its own: core stores it unread; a custom harness's is at most 256 KiB, it cannot pause for approvals, and a tool it runs itself is a `harness` effect, journaled like ours. Events carry who wrote them: `harness` with its id, `runId` and evidence `claimed` for what a harness reported. v2 removed held runs, `TurnStart.options.holdMs` and `effect.resolved`; the harness client is `@nylorun/harness/api` (`createHarness({channel, executors, features?, mcpTools?, toolResults?, outputs?})`: `mcpTools` how our engine defers MCP tools and `tool_search`'s limits, `toolResults` how it shapes tool results, `outputs` its outputs folder's directory and byte bound, each partial over its defaults). Its executors' `files` (`read`, `write`, `list`, `mount`) are the sandbox files our engine decides about: before each `sandbox` call it mounts each skill version of the turn's tree at `/skills/<name>@<hash>/` (the host only writes, `present` when the sandbox holds it), and at a completed turn's end in a sandbox it saves `/workspace/outputs` as the session's `outputs` folder over the artifact seam before `turn.completed`. Placement changes none of it (protocol 15): the in-process harness calls models through the Model Gate (a scripted model's gate in tests), opens MCP servers through the Tool Gate, and reads skill bytes over `definition.file`. A Tenant runs one harness in its own process over a memory channel, or (`NYLORUN_HARNESS=remote`) harnesses connect to core's Harness API listener over WebSocket (`/nylorun/harness/v1`, the harness credential): `--service harness` runs one with its own MCP pool and sandboxes and no store, and serves the Tenant's workspaces (`workspace.*`). Durable checkpoint 1 is unchanged.
63
62
 
64
63
  Frames: `{t:"req",id,m,p}`, `{t:"res",id,ok,r|e:{code,message}}`, `{t:"msg",m,p}`, `{t:"abort",id}`, `{t:"ping"}`. Error codes: `run_not_held`, `turn_cancelled`, `ownership_lost`, `effect_drift`, `invalid`, `unavailable`, `internal`; the message is today's (`Turn cancelled`, `Effect identity request drift`, …).
65
64
 
66
65
  - **Work.** `hello` → `{api, sandbox:{backend}, renewEveryMs}`. A harness keeps one `lease` waiting; an advance that took a session's lease offers its segment, and the answer is `{run: {runId, sessionId, turnId, epoch, token?, tokenExpiresAt?}, input: TurnStart}`. A run is bound to the connection that leased it. `lease.renew` every `renewEveryMs` renews the session's ownership lease (`{ok:false}`: lost, abort with `ownership.lost`); `lease.release{reason}` gives the run back (`shutdown`, `ownership.lost`; a lost connection counts as `connection.lost`).
67
66
  - **Input.** `TurnStart` (`type` `turn.start`, or `approval.answer` for approve/respond): `engine` (`agent` | `flow`), the turn's `manifest`, the segment's `checkpoint` with an empty transcript, `mcp` (the session's MCP facts once discovered: each server's tools, raw, with `enabled` and a `deferred` hint; `session.mcp` records a snapshot and answers them), the segment's completed `outcomes` (`{effectId, requestHash, outcome}`), `transcript.cursor`, `options` (`yieldAfter`, `flowLimits`, `fixtureModel`) and `routing` (root manifest, plugin roots, sandbox owner). Core aborts a run with `cancel{runId, reason, message}`, `reason` one of `cancel`, `shutdown`, `deadline`, `ownership.lost`.
68
- - **Record.** `requestHash = sha256(canonical(requestIdentity(effect)))` (canonical JSON: keys by code unit, `undefined` dropped; a delegation's identity leaves out `context`). An effect in `outcomes` with the same hash resolves in the harness; another hash is drift. Any other effect is an `effect.intent{effect, requestHash}`: a model intent carries no `input`, so a prompt never crosses twice. Core journals the row with `requestHash` (a model row without `input`) and answers `completed`, `pending`, `uncertain`, or `execute` (`rejoin` for a call its gate recovers, P1.2/F4.1). The harness runs model, MCP, HTTP and sandbox calls through the executors it is given (a model call reaches its provider through the Runtime's Model Gate, never from the harness) and reports `effect.outcome{value}` or `{error}` (uncertain for a model call; a tool call's error fails it to the model as `tool.interrupted`; a value past `limits.recordEntryBytes` is `limit_exceeded`, since the harness shapes tool results, not core); after a `shutdown` a recoverable call reports nothing and stays `invoking`. An intent for a tool row still `invoking` is a re-send (R5): core counts it and answers `execute` for an MCP or HTTP call under 3 sends, else the call's `tool.interrupted` outcome. A harness whose gate hop lost a call's answer asks again with the same intent. The Tool Gate runs a run's tool call only when its `Idempotency-Key` names an `invoking` row of the run's turn for the same tool and input, an MCP call's row targeting the same agent, server and raw tool name (`400 key_required`, `409 effect_not_journaled`). Core applies the Tenant's tool policy to an MCP or HTTP tool intent (R5 step 2), by the target's identity, never the model's name: one it refuses is answered `completed` with a `tool.denied` failure, and one it holds for a person is answered `pending` (the segment ends waiting; the turn pauses with an `approval` interaction whose id is the effect id, and the call is `execute`d once approved). Core runs flow work, linked sessions and delegation journaling, no tool of its own, and fails a tool that would run the developer's code (`tool.unavailable`), an MCP tool the session did not discover (`tool.unknown`) and one the turn disables (`tool.disabled`). Rows written before carry their full request and are hashed on read.
67
+ - **Record.** `requestHash = sha256(canonical(requestIdentity(effect)))` (canonical JSON: keys by code unit, `undefined` dropped; a delegation's identity leaves out `context`). An effect in `outcomes` with the same hash resolves in the harness; another hash is drift. Any other effect is an `effect.intent{effect, requestHash}`: a model intent carries no `input`, so a prompt never crosses twice. Core journals the row with `requestHash` (a model row without `input`) and answers `completed`, `pending`, `uncertain`, or `execute` (`rejoin` for a call its gate recovers). The harness runs model, MCP, HTTP and sandbox calls through the executors it is given (a model call reaches its provider through the Runtime's Model Gate, never from the harness) and reports `effect.outcome{value}` or `{error}` (uncertain for a model call; a tool call's error fails it to the model as `tool.interrupted`; a value past `limits.recordEntryBytes` is `limit_exceeded`, since the harness shapes tool results, not core); after a `shutdown` a recoverable call reports nothing and stays `invoking`. An intent for a tool row still `invoking` is a re-send: core counts it and answers `execute` for an MCP or HTTP call under 3 sends, else the call's `tool.interrupted` outcome. A harness whose gate hop lost a call's answer asks again with the same intent. The Tool Gate runs a run's tool call only when its `Idempotency-Key` names an `invoking` row of the run's turn for the same tool and input, an MCP call's row targeting the same agent, server and raw tool name (`400 key_required`, `409 effect_not_journaled`). Core applies the Tenant's tool policy to an MCP or HTTP tool intent, by the target's identity, never the model's name: one it refuses is answered `completed` with a `tool.denied` failure, and one it holds for a person is answered `pending` (the segment ends waiting; the turn pauses with an `approval` interaction whose id is the effect id, and the call is `execute`d once approved). Core runs flow work, linked sessions and delegation journaling, no tool of its own, and fails a tool that would run the developer's code (`tool.unavailable`), an MCP tool the session did not discover (`tool.unknown`) and one the turn disables (`tool.disabled`). Rows written before carry their full request and are hashed on read.
69
68
  - **Transcript.** The cursor is the record seq of the last `transcript.updated`, `turn.cancelled` or `turn.failed`. A harness resumes from its cached transcript at that cursor, else reads it once (`transcript.read`). Outputs carry the agent's state without its transcript plus the `TranscriptUpdate[]` from the transcript the segment started with; core records them and answers with the new cursor.
70
69
  - **Output.** `turn.completed`, `turn.paused`, `turn.waiting{status, effectIds}`, `turn.failed{status, error}` or `{thrown}`, and `checkpoint` for a yielded segment; answered `{cursor?}` once core settled it, idempotent per run and type. Core settles them exactly as the engine's own results, classifying aborts from its own signal.
71
70
 
72
- A Runtime below F6.1 compares journal rows by their full request: downgrading one with a turn in flight can fail that turn with drift.
71
+ An older Runtime compares journal rows by their full request: downgrading one with a turn in flight can fail that turn with drift.
73
72
 
74
73
  **Build your own harness.** A harness is any program that speaks this contract; it does not need `@nylorun/harness`. [`examples/harness-minimal`](../../examples/harness-minimal/) is one, written only against `@nylorun/core/harness-api`: it runs beside the Runtime with its own token (`nylorun-operate harness token put <id>`) and takes the sessions of Environments whose `harness` is its id, or runs as a pod Environment's `image`. `runtime/server/test/harness-api/conformance.test.ts` runs it against ours and the example.
75
74
 
@@ -81,7 +81,7 @@ export interface HarnessExecutors {
81
81
  * call names its server and the server's own tool name, an HTTP call the declared tool, and a
82
82
  * `sandbox` call runs in the sandbox `routing.sandbox.spec` names. What it answers is the
83
83
  * tool's whole result: our engine shapes it before it is recorded. `call.traceparent` is the
84
- * call's span context from core's `execute` answer (R7.4): a sandbox command gets it as
84
+ * call's span context from core's `execute` answer: a sandbox command gets it as
85
85
  * `TRACEPARENT`.
86
86
  */
87
87
  tool(effect: HostEffect, signal: AbortSignal, run: HarnessRun, call?: ToolCallContext): Promise<unknown>;
@@ -97,13 +97,13 @@ export interface HarnessExecutors {
97
97
  /** Stops a recoverable tool call at its gate after a user cancel. Never rejects. */
98
98
  cancelAtGate?(effect: HostEffect, run: HarnessRun): Promise<void>;
99
99
  /**
100
- * True when `error` says the hop to the tool call's gate lost its answer (R5.3): sending the
100
+ * True when `error` says the hop to the tool call's gate lost its answer: sending the
101
101
  * call again with the same key joins it, collects its answer, or runs it again. The harness
102
102
  * then asks core first (`effect.intent`), which counts the send and stops at its cap.
103
103
  */
104
104
  resends?(effect: HostEffect, error: unknown, run: HarnessRun): boolean;
105
105
  /**
106
- * Readies the session's MCP servers before an agent's segment runs (F6.2): discovers their
106
+ * Readies the session's MCP servers before an agent's segment runs: discovers their
107
107
  * tools when the run has no MCP facts yet (`turn.start.mcp`), reconnects them after. `record`
108
108
  * keeps what it found in the session (`session.mcp`; the first snapshot recorded wins) and
109
109
  * answers the facts the segment runs with. Undefined: nothing to change.
@@ -115,7 +115,7 @@ export interface HarnessExecutors {
115
115
  */
116
116
  readonly files?: HarnessFiles;
117
117
  }
118
- /** What core's `execute` answer says of a tool call beside running it (R7.4). */
118
+ /** What core's `execute` answer says of a tool call beside running it. */
119
119
  export interface ToolCallContext {
120
120
  readonly traceparent?: string;
121
121
  }