@nylorun/harness 0.25.1-beta → 0.27.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +144 -0
  2. package/HOST_CONTRACT.md +21 -18
  3. package/README.md +12 -13
  4. package/dist/api/executors.d.ts +18 -4
  5. package/dist/api/harness.d.ts +1 -1
  6. package/dist/api/harness.js +4 -4
  7. package/dist/api/host.d.ts +4 -0
  8. package/dist/api/host.js +62 -24
  9. package/dist/api/index.d.ts +1 -1
  10. package/dist/api/run.js +9 -0
  11. package/dist/definition/agent-definition.d.ts +2 -2
  12. package/dist/definition/agent-definition.js +2 -2
  13. package/dist/definition/registry.d.ts +3 -3
  14. package/dist/definition/registry.js +12 -15
  15. package/dist/loop/compaction/index.d.ts +4 -2
  16. package/dist/loop/compaction/index.js +78 -8
  17. package/dist/loop/dispatch.js +1 -1
  18. package/dist/loop/model/project.d.ts +6 -0
  19. package/dist/loop/model/project.js +59 -18
  20. package/dist/loop/run.js +2 -2
  21. package/dist/loop/state.js +0 -1
  22. package/dist/loop/step/canonicalize.d.ts +1 -3
  23. package/dist/loop/step/canonicalize.js +0 -15
  24. package/dist/loop/step/model-configuration.d.ts +4 -13
  25. package/dist/loop/step/model-configuration.js +12 -70
  26. package/dist/loop/step/resolve.js +0 -1
  27. package/dist/loop/step/run.js +33 -12
  28. package/dist/loop/step/runtime.d.ts +2 -2
  29. package/dist/loop/step/seal.js +0 -17
  30. package/dist/loop/step/slot-assembly.d.ts +5 -5
  31. package/dist/loop/step/slot-assembly.js +5 -5
  32. package/dist/loop/step/step-context.d.ts +5 -19
  33. package/dist/loop/step/step-context.js +9 -195
  34. package/dist/loop/transcript.js +7 -1
  35. package/dist/run/durable.d.ts +2 -6
  36. package/dist/run/durable.js +30 -40
  37. package/dist/types/execution.d.ts +0 -1
  38. package/package.json +6 -6
  39. package/dist/loop/step/compose.d.ts +0 -5
  40. package/dist/loop/step/compose.js +0 -109
  41. package/dist/loop/step/context-draft.d.ts +0 -8
  42. package/dist/loop/step/context-draft.js +0 -48
package/CHANGELOG.md CHANGED
@@ -1,5 +1,149 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.27.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - c96b9a8: **An agent manifest is flat: manifest v7, a `runtime` block the Runtime writes, and tools known by name (protocol 13, Harness API 3).** A manifest listed capabilities, each with its own instructions, tools, skills and servers, and the Runtime added its own as more capabilities. Now the agent's parts sit at the top level, a plugin's skills and servers say which plugin brought them, and what the Runtime adds to a session's agent is one `runtime` block. A fresh start: the Runtime speaks protocol 13 only, so save your agents again; sessions from protocol 12 do not carry over. See MIGRATION.md.
8
+
9
+ - **Manifest v7.** `{ manifestSchemaVersion: 7, id, name?, description?, metadata?, outputSchema?, instructions?, tools?, skills?, mcpServers?, runtime? }`. Versions 3 to 6 and a `capabilities` field are refused with a message to rebuild. `SkillManifest.plugin` and `McpServerManifest.plugin` are `{ name, version? }`, set by `.plugin(dir)` from `plugin.json`.
10
+ - **The `runtime` block.** `{ sandbox?, tools?, instructions? }`, written only by the Runtime when a session pins the agent: the sandbox spec and tools, `save_artifact`, `read_artifact`, `load_skill` and `read_skill_resource`, the skill catalog and the notes that go with them. A definition or a turn variant that sets it is refused. `runtimeManifestFor` in `@nylorun/core/define` replaces `sandboxCapabilityManifest`, `artifactsCapabilityManifest` and `toolsCapabilityManifest`. `.skills()` and `.plugin()` no longer add the skill tools or the catalog.
11
+ - **Names.** An agent's tool may not take a Runtime tool's name (`RUNTIME_TOOL_NAMES`) or contain `__`, and names are unique across tools, skills and servers.
12
+ - **Turn variants** may remove tools, tighten MCP servers and change instructions, name, description and metadata. Skills are fixed, and a variant never sets `runtime` or changes `outputSchema`.
13
+ - **Tools by name.** `capabilityId` is gone from `tool.completed`, `mcp.discovered`, tool call rows, `EffectIntent`, gate requests, checkpoints and `SessionToolRef`. An HTTP tool's `server` is its URL's host. `Implementations` is `{ tools }`, keyed by tool name (`Agent.from(json, { tools })`), `AgentBinding.declarations` is `parts`, and observe events say `partId`.
14
+ - **Harness API 3.** `hello.capabilities` is `features`, and the `harness` pseudo-capability is gone: a native tool is known by its name, and one whose name is taken fails the turn at its start. `createHarness({ features })` in `@nylorun/harness`. `examples/harness-minimal` speaks it.
15
+ - **Studio.** The Agent tab shows instructions, tools (HTTP and agent badges), skills and MCP servers, each skill and server with its plugin's badge and a filter by plugin, and a session's Runtime section: its sandbox, tools and instructions.
16
+ - `@nylorun/core`: `PROTOCOL_VERSION` 13, `HOST_PROTOCOL` `{ min: 13, max: 13 }`, required feature `flat-manifest`, `HARNESS_API_VERSION` 3; `PluginLabel`, `RuntimeManifest`, `RUNTIME_TOOL_NAMES`, `isRuntimeToolName`, `runtimeToolOf`, `isSkillTool`, `SKILLS_USAGE` and `formatSkillCatalog` in `/define`.
17
+ - `@nylorun/agents`, `@nylorun/admin`, `@nylorun/studio` and `nylorun` send protocol 13.
18
+
19
+ - 94bf329: **Each model says what it reads, a file it does not read is refused before a turn starts, and a file is an artifact the model reads again after its turn (protocol 12).** A message could name any file, and a model that could not read it failed the turn at its model call; every later turn sent the file's bytes again. Now the Runtime knows what the Tenant's model reads, checks a message's files when it is accepted, and sends a file's bytes only in the turn that brought it. Protocol 12 only adds to 11: the Runtime serves both.
20
+
21
+ - **Model inputs.** A model reads `text`, and `image`, `pdf`, `office`, `audio` or `video` when its catalog says so or the operator adds it where its API carries it natively (images everywhere; PDFs on the Anthropic, OpenAI, Azure and Google APIs; Office documents on the OpenAI Responses APIs; audio and video on Google's APIs and OpenAI-compatible completions). `GET /v1/tenant/models` gives each model `inputs` and `addableInputs`, `GET /v1/tenant/providers` each provider's `inputs`, and **`PUT /v1/tenant/models/inputs`** (the Management API; `admin.models.setInputs({ provider, model, inputs })`) sets the added ones, kept in the Tenant setting `model.inputs`. The Model Gate gives the provider adapter a model with an added image, so it is sent.
22
+ - **A custom endpoint reads text only by default.** It used to be sent images. Set `settings.inputs` on `PUT /v1/tenant/model` (`image`, `pdf`, `audio`, `video`) for what yours reads; `office` is refused there. See MIGRATION.md.
23
+ - **The accept check.** A message naming a file of a type the Tenant's model does not read is `422 attachment_unsupported`, with `details.parts` (`artifactId`, `name`, `mediaType`, `reason`), and no turn starts. Only the type is checked, never the size. Without a model in the vault nothing is refused.
24
+ - **Files as artifacts.** After its turn a file is a reference line, `[Uploaded artifact "name" · <artifactId> v<n> · read_artifact to view]` (a tool's: `[Tool <name> returned artifact …]`). Our harness sends the turn's own files once more, as media, in one user message after the conversation, so a message reads the same in every later call. At the gate, an image the model reads is an image, a text file a `<file>` block, and any other file, or one that cannot be read, a note: no file fails a call. PDFs, Office documents, audio and video are notes until the gate sends them natively.
25
+ - **`read_artifact` for every agent.** Every agent's session has it (an agent that declares its own keeps it), so every agent session pins its definition with it added. It takes a `version`, reads the Tenant-wide artifacts the session's messages named, and shows any file the Tenant's model reads; one it does not read fails `artifact.unsupported`.
26
+ - **Compaction** keeps the summarized part's reference lines (`files` on the compaction entry), and counts the turn's files by type and size in its token estimate.
27
+ - `@nylorun/core`: `PROTOCOL_VERSION` 12, required feature `model-inputs`, `HOST_PROTOCOL` `{ min: 11, max: 12 }`, error code `attachment_unsupported`; `MODEL_INPUTS`, `ModelInputSchema`, `PutModelInputsRequestSchema`, `ModelInputsViewSchema`, `CustomModelSettings.inputs`; `mediaReferenceLine` and `mediaReferenceOf` in `/define`; `TranscriptCompactionEntry.files`.
28
+ - `@nylorun/agents`, `@nylorun/studio` and `nylorun` send protocol 12.
29
+
30
+ - b5ea2b5: **An agent is its manifest: step middleware and capability bundles are removed from authoring.** The Runtime already refused middleware; now the local engine runs none either, and an agent is built only from the builder's own methods. No protocol change. See MIGRATION.md.
31
+
32
+ - **Removed:** `.use()`, `.capability()`, `capability()`, `CapabilityBuilder`, `middleware()`, `model()`, `StepMiddleware`, `StepRequest`, `StepResponse`, and `Implementations[id].middleware`. To reuse tools and instructions, write a function that adds them; a bundle you publish is an Agent Plugin.
33
+ - **`@nylorun/agents`:** the standalone `skills()`, `plugin()` and `mcp()` factories are removed; use `.skills(dir)`, `.plugin(dir)` and `.mcp(servers)`. `.skills()` takes no options: the part takes the folder's name.
34
+ - **`@nylorun/harness`:** each step offers the definition's tools and instructions in order. The `middleware.entered`, `middleware.completed` and `middleware.lease-violation` observe events are gone, and a model request carries no `model` directive or runtime context items.
35
+
36
+ ### Patch Changes
37
+
38
+ - Pin core to the tested release.
39
+ - Updated dependencies [3a32a57]
40
+ - Updated dependencies [af90d1e]
41
+ - Updated dependencies [104f24f]
42
+ - Updated dependencies [c96b9a8]
43
+ - Updated dependencies [94bf329]
44
+ - Updated dependencies [b5ea2b5]
45
+ - Updated dependencies [aff9bb8]
46
+ - Updated dependencies [f44c018]
47
+ - Updated dependencies [c8e640b]
48
+ - @nylorun/core@0.21.0-beta
49
+
50
+ ## 0.26.0-beta
51
+
52
+ ### Minor Changes
53
+
54
+ - e917bd6: **Bring your own harness: harness ids, harness-owned state, and who wrote each event (R4.1, R4.2, R4.4, R4.9).**
55
+
56
+ - **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`.
57
+ - **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`.
58
+ - **Routing.** Only a connection whose `hello.name` is that id takes the session's runs.
59
+ - **Our harness's name.** It now says `nylorun` in `hello`. A harness that says `@nylorun/harness` is refused with a message naming the new id, so an older harness image needs this Runtime's.
60
+ - **Placement.** It is keyed by the real harness id, and `"*": {hosts: []}` refuses any harness the map does not name.
61
+ - **Drift.** A turn on an Environment that now runs another harness is `409 harness_mismatch`; open a new session. For a pod Environment, a changed `harness` applies at the pod's next wake, like its image.
62
+ - **Per-harness tokens.** `nylorun-operate harness token put <id>` makes a custom harness container's own Harness API credential, bound to its id; `list` and `rm` manage them. `NYLORUN_HARNESS_TOKEN` stays ours, bound to `nylorun`.
63
+ - **A custom harness as a pod's image.** A pod Environment whose harness is not ours runs its `image` as the harness: the image's own entrypoint (`entrypoint: "image"` to the sandboxes service), with nothing copied in. It needs `image`.
64
+ - **Harness-owned state.** Core stores a harness's turn state as sent and never reads it. Our engine now aligns its state with the turn's manifest itself.
65
+ - **Limits for a custom harness.** Its state is at most 256 KiB, or its turn fails. It cannot pause for approvals in Harness API 2.
66
+ - **Native tools.** It may declare the tools it runs itself in `hello` (`capabilities.tools`). Their calls (capability `harness`) are journaled like built-ins, and the log records a real `tool.completed` instead of `tool.unavailable`.
67
+ - **Who wrote each event.** The writer sets an event's `source` and `evidence`; the event's type no longer decides them. Events written before this release still say `loop` or `api`.
68
+ - **`client`**: a command, with a new `principal` taken from its credential.
69
+ - **`harness`**: what a harness reported, with its harness id and `runId`. Evidence `claimed`.
70
+ - **`core`**: core's own logic. Evidence `observed`.
71
+ - **`effectId` on model calls.** `GET /v1/sessions/{id}/calls/model` returns each call's `effectId`, so a metered call joins the effect journal.
72
+ - **The published contract grows.** It adds `HarnessCheckpointSchema` (the checkpoint fields a harness reads), `NativeToolSchema`, the harness id helpers, `HARNESS_TOOLS_CAPABILITY`, `MAX_HARNESS_STATE_BYTES`, and the gate error codes `key_required` and `effect_not_journaled`. It also documents the effect context keys, the model request hash rule and how a turn's status maps to its output method.
73
+
74
+ - 35e29b7: **Environments replace sandboxes and vaults (protocol 11). This is a fresh start: upgrading deletes your sandboxes, their disks and every vault except the model's, and closes every open session (its history stays readable).** List what you have before upgrading; see "Environments replace sandboxes and vaults" in MIGRATION.md.
75
+
76
+ An Environment is where sessions run: one sandbox (kind `virtual`, `pod` or `none`) with a recipe that can change, and one vault of secrets for its shell, MCP servers and HTTP tools. The app decides who uses which Environment; the Runtime keeps it by id and holds its lifecycle.
77
+
78
+ - `@nylorun/core`: protocol 11 (the Host accepts 11 only; older clients get `426`), required feature `environments`. `PutEnvironmentRequestSchema`, `EnvironmentViewSchema` (`recipe`, `version`, `appliedVersion`, `ownerUserId`, `lastUsedAt`), `PutEnvironmentSecretRequestSchema`, `EnvironmentSecretViewSchema`, `ENVIRONMENT_EVENT_TYPES`, `TenantEnvironmentsConfigSchema`, `environmentGranted`. `PutSessionRequest.environment` replaces `sandbox`, `vaultIds` and `credentialSelections`; `SessionView.environment` replaces the session's sandbox and vault fields. Error codes `environment_busy`, `environment_unavailable`, `environment_lost`, `environment_not_granted`, `environment_owner_mismatch` and `session_closed` (the `sandbox_*` codes and `sandbox_expired` are gone); session events `environment.state`, `environment.exec` and `environment.attached`; scope `environments:write`. Credential coverage takes `environmentId` and answers `covered` or `missing`; the MCP preview takes `environmentId`. The vault Management schemas are removed.
79
+ - `@nylorun/runtime`: `/v1/environments/{id}` replaces `/v1/sandboxes/{id}`: `PUT` creates, finds or changes one (`kind` and `storage` fixed; a recipe change bumps `version`; a pod gets a new image or resources at its next start from stopped, a new allowlist within seconds), with list by label, events (`nylorun.environment-event/1`), stop, reset and delete. Each Environment owns one vault: `PUT|GET|DELETE /v1/environments/{id}/secrets/{name}` on the Runtime API, write-only, with a second credential for a host or URL refused at the write (`409 credential_conflict`). An optional owner guard (`ownerUserId`) is checked when a session opens and at every turn start. `lifecycle.deleteAfter` deletes an Environment unused that long; TTL and `onExpiry` are gone. Kind `none` holds secrets for MCP-only agents. `/v1/tenant/vaults`, user and installation vaults, the Tenant's default sandbox, inline sandboxes and `{ session }` sharing are removed. The Tenant setting is `environments.config` (`limits.environments`). Identity files grant `environments:` (an old `sandboxes:` key, or `sandboxes:write`, stops the Runtime with a message naming the new key). Migration `0020_environments`.
80
+ - `@nylorun/harness`: the Harness API claims `environment.state` and `environment.exec`, and its workspace fields name `environmentId`.
81
+ - `@nylorun/agents`: `client.environments` (`put`, `get`, `list`, `page`, `stop`, `reset`, `delete`, `events`, `secrets.put|list|get|delete`, `forSession`) replaces `client.sandboxes`; `createSession({ environment })`; `sessions.page({ environmentId })` filters by Environment. The AG-UI handler's session options take `environment`.
82
+ - `@nylorun/admin`: `admin.coverage({ agentId, environmentId })` replaces `admin.vaults`; `admin.mcp.preview({ url, environmentId })`.
83
+ - `@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.
84
+ - `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.
85
+
86
+ - 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.
87
+
88
+ - **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.
89
+ - **`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`.
90
+ - **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.
91
+ - **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.
92
+ - **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.
93
+ - **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.
94
+ - `@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.
95
+ - **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).
96
+
97
+ - 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.
98
+
99
+ - **`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.
100
+ - **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.
101
+ - **`approval` leaves the manifest.** `PUT /v1/agents/:id` and `saveAgent()` refuse a definition that sets `approval` on an HTTP tool, an MCP server or an MCP tool's settings; `http({ approval })` and `.mcp({ … approval })` throw; a turn manifest can no longer add one. The engine never asks for an HTTP or MCP tool's approval itself. A session pinned to a manifest saved with `approval: "always"` keeps it, as an ask.
102
+ - `@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**.
103
+ - Migration: move each `approval: "always"` to an `ask` rule (see MIGRATION.md).
104
+
105
+ - 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.
106
+
107
+ - **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.
108
+ - **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.
109
+ - **References by default.** Spans point at log events (`nylorun.event.cursor`) and carry no content unless you opt in per kind with `NYLORUN_TRACE_CONTENT` (`user`, `outputs`, `tool-results`, `errors`), or all of them with `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT=true`, each cut at 8 KiB. A span never carries a credential value, a prompt, a person's id, an identity header or an idempotency key.
110
+ - **`GET /v1/sessions/{id}/turns/{turnId}/trace`** answers a turn's spans as OTLP JSON, the same spans the exporter posts: look at a turn without a collector, or post it to one to backfill. Application keys, as the `/calls` reads. Host feature `traces`; `@nylorun/agents` adds `session.trace(turnId)`, and `@nylorun/core/contracts` `TurnTraceSchema`.
111
+ - **Trace context in and out.** A `traceparent` (and `tracestate`) on `POST /v1/sessions/{id}/commands`, an AG-UI run or an A2A message puts the turn in the caller's trace; `command.message` records it as `trace`. The turn hands its context on: to the harness in `TurnStart.trace`, to HTTP tools as `traceparent` beside `Idempotency-Key`, to MCP servers as `traceparent` on the call's requests, and to sandbox commands as `TRACEPARENT`.
112
+ - **Harness API** (additive): the `effect.intent` answer `execute` may carry the tool call's `traceparent`. `@nylorun/harness`: `HarnessExecutors.tool` takes it as a fourth argument (`ToolCallContext`).
113
+
114
+ ### Patch Changes
115
+
116
+ - 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:
117
+ - the transport and the pod join (`HARNESS_API_PATH`, `HARNESS_API_HEADER`, `HOST_JOIN_PATH`, `HostJoinRequestSchema`, `HostJoinAnswerSchema`);
118
+ - the Model and Tool Gate bodies (`ModelCallBodySchema`, `ToolCallBodySchema`, `HttpCallBodySchema`, the MCP bodies, `GATE_ERROR_CODES`);
119
+ - the MCP snapshot (`McpSnapshotSchema`);
120
+ - transcript entries (`TranscriptEntrySchema`);
121
+ - the effect id rule (`effectIdOf`, `isEffectIdOf`).
122
+
123
+ The build also writes them as one JSON Schema document, `@nylorun/core/harness-api/schema.json`, for harnesses written in other languages.
124
+
125
+ Other changes:
126
+ - `TurnStart` gains an optional `trace` (W3C `traceparent`) for the turn's trace context. Nothing fills it yet.
127
+ - Core refuses a `hello` whose `api` is not `2`.
128
+ - **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.
129
+ - The fixture model also answers scripted markers: `fixture:text`, `fixture:tool <name> <json>`, `fixture:budget` and `fixture:slow <seconds>`.
130
+ - **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.
131
+
132
+ - Pin core to the tested release.
133
+ - Updated dependencies [17a97e9]
134
+ - Updated dependencies [b6214d9]
135
+ - Updated dependencies [e917bd6]
136
+ - Updated dependencies [5165451]
137
+ - Updated dependencies [35e29b7]
138
+ - Updated dependencies [e917bd6]
139
+ - Updated dependencies [a0cbca1]
140
+ - Updated dependencies [3013501]
141
+ - Updated dependencies [6061a3a]
142
+ - Updated dependencies [7d496e4]
143
+ - Updated dependencies [81c783e]
144
+ - Updated dependencies [7800358]
145
+ - @nylorun/core@0.20.0-beta
146
+
3
147
  ## 0.25.1-beta
4
148
 
5
149
  ### Patch Changes
package/HOST_CONTRACT.md CHANGED
@@ -4,9 +4,9 @@ Artifact: `@nylorun/harness@0.14.0-beta.3`. Package version is separate from pro
4
4
 
5
5
  ## HTTP (both hosts)
6
6
 
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 vaultIds, optional credentialSelections, optional `sandbox` — `false`, `{ session }` to share another session's sandbox (same owner), or an inline `{ image?, network?: { allow }, resources? }` checked against the Tenant's limits; omitted means the Tenant default; 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). Bearer management keys (the Management API, protocol 8; an application key there is `403 key_role_mismatch`): vault administration `POST/GET/DELETE /v1/tenant/vaults` and `/v1/tenant/vaults/:vaultId/credentials`, and the `/v1/tenant/*` model routes below. 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. Vault creates and credential rotations use `idempotencyKey`; requestId is excluded from comparison; the same key and body replay the stored metadata response; a changed body is 409. Credential responses omit secret values. `GET /v1/tenant/vaults?ownerUserId=` also lists that user's vaults. A session attaches only vaults with the same ownerUserId. User vaults cannot see or attach the host vault. `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. A later session PUT may replace vaultIds and credentialSelections; agentId, ownerUserId, and info stay the creation identity. GET session returns id, agentId, ownerUserId, status, activeTurnId, vaultIds, credentialSelections, 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 and contains no secrets. History returns `{items: LiveEvent[], cursor: string|null}`; empty history cursor is null.
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 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 is not a built-in, 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, 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`).
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
@@ -14,17 +14,18 @@ route requires `Nylorun-Protocol` (client protocol integer). Missing or
14
14
  unsupported protocol → `426` with
15
15
  `{ status: "rejected", code: "protocol_unsupported", protocol }` before
16
16
  authentication, except that a request with neither `Nylorun-Protocol` nor
17
- `Authorization` gets the route's `401` challenge (protocol 9). For one release
18
- the Host also serves protocol 4 clients, which send `Nylorun-Tenant`: a header
19
- naming the Host's Tenant is accepted, one naming another Tenant (or a malformed
20
- one) is the opaque `404`. A Tenant id in the query string or body is ignored. A
17
+ `Authorization` gets the route's `401` challenge (protocol 9). The Host serves
18
+ protocol 13 only (protocol 13 changed the agent manifest to v7, the flat manifest, so a protocol 11 or 12
19
+ client is answered `426`; protocol 12 added model inputs and refuses a message naming a
20
+ file the Tenant's model does not read with `422 attachment_unsupported`). A `Nylorun-Tenant` header naming the Host's Tenant is
21
+ accepted, one naming another Tenant (or a malformed one) is the opaque `404`. A Tenant id in the query string or body is ignored. A
21
22
  Tenant that could not be opened and an unknown Tenant share the opaque `404`
22
23
  body. A missing or rejected credential is `401` (`credential_required`,
23
24
  `credential_invalid`) with `WWW-Authenticate: Bearer` (protocol 9); on the
24
25
  Runtime API the challenge names `/.well-known/oauth-protected-resource` when
25
26
  the Host has trusted issuers. The Admin API is gone (protocol 8): `/v1/admin/*`
26
27
  is no route, and the admin key is no request's credential. Vocabulary:
27
- [runtime/src/CONTEXT.md](../runtime/src/CONTEXT.md).
28
+ [runtime/server/src/CONTEXT.md](../server/src/CONTEXT.md).
28
29
 
29
30
  Unauthenticated `GET /health` returns status, `service: "nylorun-runtime"`,
30
31
  version, `hostId`, pid, and `protocol: { min, max, features }` (plus diagnostic
@@ -34,42 +35,44 @@ Tenant is open; a Tenant that cannot be opened fails it with its cause
34
35
  (`schema-too-new`, `kek-missing`, `database-layout-old`, …), also reported in
35
36
  `nylorun-operate status` inside the runtime container (`nylorun status` on a local Tenant).
36
37
 
37
- 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). Lost tool work is uncertain, not automatically run again. Results after cancellation cannot resume a turn. No hardcoded production credentials.
38
+ 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 core-served 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.
38
39
 
39
40
  ## Engine host
40
41
 
41
- `createDurableCheckpoint({manifest,sessionId,turnId,input,state?,info?,segment?})`, `runDurable({manifest,checkpoint,host,signal?,sessionTools?})` from `/run`. `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, for a call that summarizes history, `compaction: {trigger, tokensBefore, keptTokens}` (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; hosts publish `context.compacted` for such a call instead of `message.assistant`. 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 capabilityId, toolName, serialized input and context. Tool result value is a ToolOutcome or a plain tool output; 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.
42
+ `createDurableCheckpoint({manifest,sessionId,turnId,input,state?,info?,segment?})`, `runDurable({manifest,checkpoint,host,signal?,sessionTools?})` from `/run`. `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, for a call that summarizes history, `compaction: {trigger, tokensBefore, keptTokens}` (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; hosts publish `context.compacted` for such a call instead of `message.assistant`. 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 (a tool is known by its name alone: the agent's `tools`, the pinned `runtime.tools` and the session tools never share one), serialized input and context. Tool result value is a ToolOutcome or a plain tool output; 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.
42
43
 
43
- 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.
44
+ 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.
44
45
 
45
46
  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.
46
47
 
47
48
  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.
48
49
 
49
- 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, identical sandbox specs across the tree — in a session opened with a sandbox the Runtime adds the same `nylorun.sandbox` capability to the root and each inlined child) 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, sandbox and MCP routing, and include `agent` in `tool.completed` payloads. 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.
50
+ 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, identical sandbox specs across the tree — in a session opened with a sandbox the Runtime pins the same `runtime` block's sandbox on the root and each inlined child) 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, sandbox and MCP routing, and include `agent` in `tool.completed` payloads. 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.
50
51
 
51
- **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 `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 `capabilityId` + `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 becomes `uncertain` and is never re-run automatically. Parallelism comes from pending effects returned together; the Runtime caps concurrency with `RuntimeOptions.flow` / env (`maxConcurrency`, `maxMapItems`, `maxLoopIterations`).
52
+ **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`).
52
53
 
53
- **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 fixed; tools/skills/delegates may only shrink; MCP and sandbox must not change), 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.
54
+ **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 never sets `runtime`, and the turn runs with the pin's), 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.
54
55
 
55
- **Shared sandbox.** Definitions declare no sandbox; a session is opened with one (`PutSessionRequest.sandbox`), resolved against the Tenant's limits and pinned on the session. An agent session's pinned manifest is its definition plus capability `nylorun.sandbox` (the six built-ins, the sandbox instructions and the resolved spec), so its hash differs from the definition's; a workflow session's manifest is unchanged and its sandbox is stored beside it. A tree has one sandbox, keyed by the owning session id. `sandbox: { session }` attaches another session's sandbox (same `ownerUserId`, same Tenant); a session whose definition declares none inherits the owner's spec and tools. Linked agent sessions created for agent nodes attach with `sandbox: { session: workflowSessionId }` and inherit the same way. Application principals call `POST /v1/sessions/:id/sandbox/:tool` (`bash` | `read` | `write` | `edit` | `grep` | `glob`); refused while that session has an active agent turn. `session.sandbox` on the application client mirrors the session endpoint. Registration refuses a definition that declares a sandbox; definitions stored before Sandboxes v3 keep theirs.
56
+ **Shared sandbox.** Definitions declare no sandbox; a session is opened with one (`PutSessionRequest.sandbox`), resolved against the Tenant's limits and pinned on the session. An agent session's pinned manifest is its definition plus the `runtime` block (`runtimeManifestFor` in `/define`: the resolved spec, the six built-ins and the sandbox instructions, `save_artifact` and `read_artifact`, and `load_skill` and `read_skill_resource` with the skill catalog when the agent has skills), so its hash differs from the definition's; a definition or a turn variant that sets `runtime` is refused; a workflow session's manifest is unchanged and its sandbox is stored beside it. A tree has one sandbox, keyed by the owning session id. `sandbox: { session }` attaches another session's sandbox (same `ownerUserId`, same Tenant); a session whose definition declares none inherits the owner's spec and tools. Linked agent sessions created for agent nodes attach with `sandbox: { session: workflowSessionId }` and inherit the same way. Application principals call `POST /v1/sessions/:id/sandbox/:tool` (`bash` | `read` | `write` | `edit` | `grep` | `glob`); refused while that session has an active agent turn. `session.sandbox` on the application client mirrors the session endpoint. Registration refuses a definition that declares a sandbox; definitions stored before Sandboxes v3 keep theirs.
56
57
 
57
- ## Harness API v1
58
+ ## Harness API 3
58
59
 
59
- The Runtime runs every segment through the Harness API (blueprint D37–D42): core keeps scheduling, the record, settle and takeover; a harness runs the engine. Protocol types, schemas, the request hash, transcript edits and the RPC channel are `@nylorun/core/harness-api` (`HARNESS_API_VERSION = 2`: v2 removed held runs, `TurnStart.options.holdMs` and `effect.resolved`, with track R2); the harness client is `@nylorun/harness/api` (`createHarness({channel, executors})`). 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.
60
+ The Runtime runs every segment through the Harness API (blueprint D37–D42): 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 = 3`; core refuses a `hello` naming another `api`; 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 the tools it declares in `hello` (`features.tools`, known by name; a name the agent or the Runtime already uses fails the turn at its start) are journaled like built-ins. 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?})`). 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.
60
61
 
61
62
  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`, …).
62
63
 
63
64
  - **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`).
64
65
  - **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, `sessionTools`, the segment's completed `outcomes` (`{effectId, requestHash, outcome}`), `transcript.cursor`, `options` (`yieldAfter`, `flowLimits`, `fixtureModel`) and `routing` (root manifest, plugin roots, MCP snapshot, sandbox owner). Core aborts a run with `cancel{runId, reason, message}`, `reason` one of `cancel`, `shutdown`, `deadline`, `ownership.lost`.
65
- - **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); after a `shutdown` a recoverable call reports nothing and stays `invoking`. Core runs flow work, linked sessions, delegation journaling and its built-in tools, and fails a tool that would run the developer's code (`tool.unavailable`). Rows written before carry their full request and are hashed on read.
66
+ - **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`); 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 (`400 key_required`, `409 effect_not_journaled`). Core applies the Tenant's tool policy to an MCP or HTTP tool intent (R5 step 2): 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, delegation journaling and its built-in tools, and fails a tool that would run the developer's code (`tool.unavailable`). Rows written before carry their full request and are hashed on read.
66
67
  - **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.
67
68
  - **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.
68
69
 
69
70
  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.
70
71
 
72
+ **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.
73
+
71
74
  ## Definitions, validation, compatibility
72
75
 
73
- `/define` is execution-free and browser-bundleable; Agent has no `.run()`. Explicit local execution uses `/run` run + bindingFromAgent(agent.build()). `/contracts` never imports checkpoint internals. Tools are supported remotely. Arbitrary legacy middleware closures are rejected for durable definitions because they cannot be reconstructed from manifests. JSON schemas are reconstructed through Zod's JSON Schema importer; unsupported schemas fail closed. The original manifest document must survive reconstruction. Runtime is the only hasher: it hashes the accepted manifest and pins that digest on the session. Agents do not hash. Model configuration is host-owned. The Runtime refuses a definition whose tools would run the developer's code. It checks an HTTP tool's answer against the tool's output schema and records a mismatch as the failed outcome `tool.invalid-output`.
76
+ `/define` is execution-free and browser-bundleable; Agent has no `.run()`. Explicit local execution uses `/run` run + bindingFromAgent(agent.build()). `/contracts` never imports checkpoint internals. Tools are supported remotely. JSON schemas are reconstructed through Zod's JSON Schema importer; unsupported schemas fail closed. The original manifest document must survive reconstruction. Runtime is the only hasher: it hashes the accepted manifest and pins that digest on the session. Agents do not hash. Model configuration is host-owned. The Runtime refuses a definition whose tools would run the developer's code. It checks an HTTP tool's answer against the tool's output schema and records a mismatch as the failed outcome `tool.invalid-output`.
74
77
 
75
78
  No session migration, arbitrary checkpoint migration, broad model-support, or conformance claims follow from compiling this interface. Studio and conformance tooling remain outside production harness.
package/README.md CHANGED
@@ -19,7 +19,7 @@ provider call.
19
19
  ## Compose an agent
20
20
 
21
21
  ```ts
22
- import { Agent, tool, ToolError, capability } from "@nylorun/agents/define";
22
+ import { Agent, tool, ToolError } from "@nylorun/agents/define";
23
23
  import { z } from "zod";
24
24
 
25
25
  const lookup = tool({
@@ -33,21 +33,20 @@ const lookup = tool({
33
33
  },
34
34
  });
35
35
 
36
- export const supportAgent = Agent({
37
- id: "support",
38
- name: "Support",
39
- instructions: "You help customers with orders. Be brief.",
40
- tools: [lookup],
41
- }).capability(capability({ id: "policy" }).instructions("Never promise a refund."));
36
+ export const supportAgent = Agent({ id: "support", name: "Support" })
37
+ .instructions("You help customers with orders. Be brief.", "Never promise a refund.")
38
+ .tools(lookup);
42
39
 
43
40
  // Optional: .build() is a no-op facade
44
41
  const agent = supportAgent.build();
45
42
 
46
- JSON.stringify(supportAgent); // manifest
47
- Agent.from(supportAgent.toJSON(), implementations);
43
+ JSON.stringify(supportAgent); // manifest v7: { manifestSchemaVersion: 7, id, name, instructions, tools }
44
+ Agent.from(supportAgent.toJSON(), { tools: { lookup_order: lookup } });
48
45
  ```
49
46
 
50
- `.use()` returns a **new** agent. Top-level `tools` / `instructions` are first-class. Do **not** put `model` on `Agent({})` — Runtime resolves and calls the model.
47
+ The manifest is flat: the agent's `instructions`, `tools`, `skills` and `mcpServers` are top-level, and a skill or server from an Agent Plugin carries its `plugin` label. A tool is known by its name alone, so an agent's tool may not take a name the Runtime serves (the sandbox, artifact and skill tools, `tool_search`, `tool_call`) or contain `__`. When a session pins the agent, the Runtime adds its `runtime` block (`runtimeManifestFor`): the sandbox and its tools, the artifact tools and the skill tools with the skill catalog.
48
+
49
+ Each builder call (`.instructions()`, `.tools()`, `.subagents()`, `.mcp()`, `.output()`) returns a **new** agent; the engine offers the agent's instructions and tools to the model on every step. Do **not** put `model` on `Agent({})` — Runtime resolves and calls the model.
51
50
 
52
51
  ## Run the loop
53
52
 
@@ -78,8 +77,8 @@ Prefer `input` / `output` / `run`. Legacy `inputSchema` / `execute` and tagged `
78
77
 
79
78
  Definitions must not import `@nylorun/runtime`.
80
79
 
81
- Local explicit engine execution retains middleware. Durable manifests reject middleware
82
- closures: a hosted agent is its manifest, and the Runtime never calls your code during a session.
80
+ There is no step middleware: a hosted agent is its manifest, and the Runtime runs it from
81
+ that alone.
83
82
 
84
83
  ## Checkpoint / durability
85
84
 
@@ -87,4 +86,4 @@ closures: a hosted agent is its manifest, and the Runtime never calls your code
87
86
 
88
87
  ## Client types
89
88
 
90
- The authoritative session/action wire schemas live in `/contracts` and do not import durable checkpoint types. Use `@nylorun/agents` for the session client and to save agents (`saveAgent`); the Runtime runs no code of yours during a session, so a tool there is an `http()` tool or a remote MCP server's. Historical root client types remain for deferred local tooling; they are not the new wire contract.
89
+ The authoritative session/action wire schemas live in `/contracts` and do not import durable checkpoint types. Use `@nylorun/agents` for the session client and to save agents (`saveAgent`); the Runtime runs agents from their manifests alone, so a tool there is an `http()` tool or a remote MCP server's. Historical root client types remain for deferred local tooling; they are not the new wire contract.
@@ -1,4 +1,4 @@
1
- import type { ParamsOf, ResultOf, RunGrant, TurnStart } from "@nylorun/core/harness-api";
1
+ import type { McpSnapshot, ParamsOf, ResultOf, RunGrant, TurnStart } from "@nylorun/core/harness-api";
2
2
  import type { DurableSessionTool, HostEffect } from "../run/durable.js";
3
3
  /** A run as the harness holds it: the lease, what it started from, and its signal. */
4
4
  export interface HarnessRun {
@@ -15,8 +15,12 @@ export interface HarnessRun {
15
15
  export interface HarnessExecutors {
16
16
  /** A model call. A provider failure is a failure outcome; only an abort throws. */
17
17
  model(effect: HostEffect, signal: AbortSignal, run: HarnessRun): Promise<unknown>;
18
- /** An MCP, HTTP or sandbox tool call, routed by `run.start.routing`. */
19
- tool(effect: HostEffect, signal: AbortSignal, run: HarnessRun): Promise<unknown>;
18
+ /**
19
+ * An MCP, HTTP or sandbox tool call, routed by `run.start.routing`. `call.traceparent` is the
20
+ * call's span context from core's `execute` answer (R7.4): a sandbox command gets it as
21
+ * `TRACEPARENT`.
22
+ */
23
+ tool(effect: HostEffect, signal: AbortSignal, run: HarnessRun, call?: ToolCallContext): Promise<unknown>;
20
24
  /**
21
25
  * Calls that outlive this process at their gate: a shutdown leaves them running there, and
22
26
  * the next run re-sends them (`rejoin`) instead of marking them uncertain.
@@ -28,6 +32,12 @@ export interface HarnessExecutors {
28
32
  };
29
33
  /** Stops a recoverable tool call at its gate after a user cancel. Never rejects. */
30
34
  cancelAtGate?(effect: HostEffect, run: HarnessRun): Promise<void>;
35
+ /**
36
+ * True when `error` says the hop to the tool call's gate lost its answer (R5.3): sending the
37
+ * call again with the same key joins it, collects its answer, or runs it again. The harness
38
+ * then asks core first (`effect.intent`), which counts the send and stops at its cap.
39
+ */
40
+ resends?(effect: HostEffect, error: unknown, run: HarnessRun): boolean;
31
41
  /**
32
42
  * Readies the session's MCP servers before an agent's segment runs (F6.2): discovers their
33
43
  * tools the first time, reconnects them after. `record` keeps what it found in the session
@@ -36,10 +46,14 @@ export interface HarnessExecutors {
36
46
  */
37
47
  prepare?(run: HarnessRun, record: McpRecorder): Promise<PreparedRun | undefined>;
38
48
  }
49
+ /** What core's `execute` answer says of a tool call beside running it (R7.4). */
50
+ export interface ToolCallContext {
51
+ readonly traceparent?: string;
52
+ }
39
53
  /** Records a session's MCP discovery in core (`session.mcp`). */
40
54
  export type McpRecorder = (params: Omit<ParamsOf<"session.mcp">, "runId">) => Promise<ResultOf<"session.mcp">>;
41
55
  /** The session's MCP snapshot and tools after `prepare`. */
42
56
  export interface PreparedRun {
43
57
  readonly sessionTools: readonly DurableSessionTool[];
44
- readonly mcpSnapshot?: unknown;
58
+ readonly mcpSnapshot?: McpSnapshot;
45
59
  }
@@ -21,7 +21,7 @@ export interface HarnessOptions {
21
21
  readonly name?: string;
22
22
  readonly version?: string;
23
23
  /** What `hello` declares: `workspace` when this harness serves the Tenant's workspaces. */
24
- readonly capabilities?: {
24
+ readonly features?: {
25
25
  readonly workspace?: unknown;
26
26
  };
27
27
  /** Sees core's answer to `hello` (the Tenant, the sandbox backend preference). */
@@ -5,7 +5,7 @@
5
5
  * with `ownership.lost`, and `stop()` with `shutdown`. While a run is live it renews its lease
6
6
  * every `renewEveryMs`; renewing stops once the run is aborted.
7
7
  */
8
- import { HARNESS_API_VERSION, } from "@nylorun/core/harness-api";
8
+ import { DEFAULT_HARNESS, HARNESS_API_VERSION, } from "@nylorun/core/harness-api";
9
9
  import { ABORT_MESSAGES, RunAbort } from "./abort.js";
10
10
  import { runTurn } from "./run.js";
11
11
  import { TranscriptCache } from "./transcript-cache.js";
@@ -111,11 +111,11 @@ export function createHarness(options) {
111
111
  async start() {
112
112
  const hello = await channel.request("hello", {
113
113
  api: HARNESS_API_VERSION,
114
- name: options.name ?? "@nylorun/harness",
114
+ name: options.name ?? DEFAULT_HARNESS,
115
115
  version: options.version ?? "0",
116
- capabilities: options.capabilities?.workspace === undefined
116
+ features: options.features?.workspace === undefined
117
117
  ? {}
118
- : { workspace: options.capabilities.workspace },
118
+ : { workspace: options.features.workspace },
119
119
  });
120
120
  renewEveryMs = hello.renewEveryMs;
121
121
  options.onHello?.(hello);
@@ -3,6 +3,10 @@
3
3
  * (same id, same request hash) resolves here; any other becomes an `effect.intent`. A model
4
4
  * intent carries no prompt: core stores its hash. When core answers `execute`, the harness runs
5
5
  * the call and reports its outcome.
6
+ *
7
+ * A tool call whose gate hop lost its answer (`executors.resends`) is sent again with the same
8
+ * key (R5.3): the harness waits a moment and asks core again with the same intent, and core
9
+ * counts the send, answering `execute` again or the call's outcome once it reached its cap.
6
10
  */
7
11
  import { type HarnessChannel } from "@nylorun/core/harness-api";
8
12
  import type { DurableHost } from "../run/durable.js";