@nylorun/core 0.13.0-beta → 0.15.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 (90) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/dist/compatibility.d.ts +49 -25
  3. package/dist/compatibility.js +48 -27
  4. package/dist/contracts.d.ts +318 -956
  5. package/dist/contracts.js +280 -515
  6. package/dist/define.d.ts +13 -10
  7. package/dist/define.js +7 -4
  8. package/dist/definition/assemble.d.ts +0 -3
  9. package/dist/definition/assemble.js +13 -19
  10. package/dist/definition/bind-agent.js +0 -2
  11. package/dist/definition/bind-tool.js +0 -1
  12. package/dist/definition/bound.d.ts +3 -10
  13. package/dist/definition/builder.d.ts +19 -55
  14. package/dist/definition/builder.js +19 -130
  15. package/dist/definition/capability.d.ts +3 -15
  16. package/dist/definition/capability.js +3 -25
  17. package/dist/definition/code-tools.d.ts +22 -0
  18. package/dist/definition/code-tools.js +46 -0
  19. package/dist/definition/declaration.d.ts +0 -3
  20. package/dist/definition/declaration.js +8 -11
  21. package/dist/definition/delegate.d.ts +7 -7
  22. package/dist/definition/flow/compile.d.ts +4 -5
  23. package/dist/definition/flow/compile.js +120 -72
  24. package/dist/definition/flow/from.d.ts +2 -2
  25. package/dist/definition/flow/from.js +14 -33
  26. package/dist/definition/flow/index.d.ts +2 -2
  27. package/dist/definition/flow/index.js +2 -2
  28. package/dist/definition/flow/paths.d.ts +32 -17
  29. package/dist/definition/flow/paths.js +35 -14
  30. package/dist/definition/flow/spec.d.ts +6 -9
  31. package/dist/definition/flow/spec.js +49 -31
  32. package/dist/definition/flow/types.d.ts +40 -116
  33. package/dist/definition/from.js +36 -41
  34. package/dist/definition/helpers.d.ts +1 -1
  35. package/dist/definition/helpers.js +1 -1
  36. package/dist/definition/http-tool.d.ts +66 -0
  37. package/dist/definition/http-tool.js +131 -0
  38. package/dist/definition/implementations.d.ts +0 -3
  39. package/dist/definition/manifest.js +5 -4
  40. package/dist/definition/mcp.d.ts +4 -2
  41. package/dist/definition/mcp.js +14 -18
  42. package/dist/definition/removed.d.ts +10 -0
  43. package/dist/definition/removed.js +26 -0
  44. package/dist/definition/sandbox-capability.d.ts +2 -0
  45. package/dist/definition/sandbox-capability.js +11 -1
  46. package/dist/definition/schema.js +0 -3
  47. package/dist/definition/skill-tools.d.ts +16 -2
  48. package/dist/definition/skill-tools.js +38 -31
  49. package/dist/definition/variant.d.ts +1 -1
  50. package/dist/definition/variant.js +3 -14
  51. package/dist/definition/workflow/diagnostics.d.ts +1 -7
  52. package/dist/definition/workflow/diagnostics.js +1 -24
  53. package/dist/definition/workflow/index.d.ts +3 -17
  54. package/dist/definition/workflow/index.js +2 -9
  55. package/dist/definition/workflow/runnable.d.ts +2 -34
  56. package/dist/definition/workflow/runnable.js +8 -142
  57. package/dist/definition/workflow/types.d.ts +1 -10
  58. package/dist/harness-api/messages.d.ts +24 -27
  59. package/dist/harness-api/messages.js +1 -1
  60. package/dist/harness-api/schema.d.ts +0 -16
  61. package/dist/harness-api/schema.js +5 -12
  62. package/dist/index.d.ts +1 -1
  63. package/dist/types/manifest.d.ts +41 -14
  64. package/dist/types/middleware.d.ts +11 -16
  65. package/dist/types/observe.d.ts +0 -6
  66. package/dist/types/tool.d.ts +0 -6
  67. package/dist/types/workflow.d.ts +54 -110
  68. package/dist/utils/definition-files.d.ts +31 -0
  69. package/dist/utils/definition-files.js +84 -0
  70. package/package.json +1 -1
  71. package/dist/definition/hooks.d.ts +0 -19
  72. package/dist/definition/hooks.js +0 -67
  73. package/dist/definition/workflow/build.d.ts +0 -28
  74. package/dist/definition/workflow/build.js +0 -40
  75. package/dist/definition/workflow/chain.d.ts +0 -49
  76. package/dist/definition/workflow/chain.js +0 -40
  77. package/dist/definition/workflow/loop.d.ts +0 -54
  78. package/dist/definition/workflow/loop.js +0 -100
  79. package/dist/definition/workflow/map.d.ts +0 -17
  80. package/dist/definition/workflow/map.js +0 -45
  81. package/dist/definition/workflow/parallel.d.ts +0 -19
  82. package/dist/definition/workflow/parallel.js +0 -36
  83. package/dist/definition/workflow/patch.d.ts +0 -11
  84. package/dist/definition/workflow/patch.js +0 -45
  85. package/dist/definition/workflow/slot.d.ts +0 -23
  86. package/dist/definition/workflow/slot.js +0 -16
  87. package/dist/definition/workflow/switch.d.ts +0 -26
  88. package/dist/definition/workflow/switch.js +0 -64
  89. package/dist/types/dynamics.d.ts +0 -101
  90. package/dist/types/dynamics.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,119 @@
1
1
  # @nylorun/core
2
2
 
3
+ ## 0.15.0-beta
4
+
5
+ ### Major Changes
6
+
7
+ - 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.
8
+
9
+ - **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.
10
+ - **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`.
11
+ - **Breaking (`@nylorun/harness`):** the flow engine is `flow-3` and runs only v3 manifests; v1 and v2 engines, `agentTurnValue` and the `fn` / `verify` effect kinds are removed. A switch picks the case named by the previous output or its `route` field, a map runs over an array or an `items` array, and a loop retries with its verifier's feedback until `max`. An `agent` effect carries the flow's input as `flowInput` when the stage's input differs.
12
+ - **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`.
13
+ - `@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.
14
+
15
+ - 713e676: **Remote MCP servers only (blueprint D47).** Nylorun accepts `streamable-http` and `sse` MCP servers, declared by URL and reached through the gates; stdio servers and plugin roots are gone. See MIGRATION.md.
16
+
17
+ - **Breaking (`@nylorun/core`):** `McpServerManifest` and the manifest schema keep only `streamable-http` and `sse`. A `stdio` server is refused by `.mcp({...})` (`McpError`, code `mcp.stdio`), by `Agent.from` and by the wire schema, all with one message (`stdioMcpRefusal`): "MCP server 'x' uses stdio; Nylorun accepts remote MCP servers only (streamable-http or sse). Run the server behind an HTTP transport and declare its URL." `PutAgentRequest` loses `pluginRoots`, `CapabilityDeclaration` loses `pluginRoot`, and the Harness API's `RunRouting` loses `pluginRoots`.
18
+ - **Breaking (`@nylorun/agents`):** `.plugin()` and `plugin()` throw `PluginError` (code `plugin.mcp-stdio`) for a stdio server in a plugin's `mcp.json`; its remote servers and skills load as before. `saveAgent` no longer sends plugin roots. `prepareStdioLaunch`, `expandPluginPlaceholders` and `StdioLaunch` are removed.
19
+ - **Breaking (`@nylorun/runtime`):** no stdio MCP launcher: `PUT /v1/agents/:id` refuses a stdio server (`400`) and `pluginRoots`. `TenantConfig.childEnv`, `TenantPaths.pluginData` and `tmp`, `tenantChildEnvironment`, `startEphemeralRuntime({ baseline })` and `configForFactory`'s `baseline` and `hostConfig` are removed; the harness service no longer takes `childEnv` or `paths.pluginData`.
20
+ - `nylorun`: the local stack no longer mounts the Host root's `plugins/` into the runtime and harness containers, nor the Tenant's `plugin-data/`, `home/` and `tmp/` into the harness, which now mounts only `sandboxes/`.
21
+
22
+ - 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".
23
+
24
+ - **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.
25
+ - **Breaking (`@nylorun/harness`):** held runs are gone: `createHarness` loses `holdMs`, and `apiHost` its `hold` option.
26
+ - **Breaking (`@nylorun/agents`):** `createActionHandler`, `executeAction`, `createActionSandbox`, `definitionDeclaresSandbox`, `isActionSandboxTool` and the `Action`, `ActionOutcome`, `ActionHandler`, `ActionHandlerOptions`, `RegisterOptions`, `ExecuteActionOptions` and `ExecutableDefinition` types are removed. `saveAgent` refuses a code tool (`tool({ run })`) or a flow tool stage before sending; its `implementationVersion` is optional (`NYLORUN_IMPLEMENTATION_VERSION`, else `dev`).
27
+ - **Breaking (`@nylorun/runtime`):** `/v1/endpoints` and `/v1/actions/*` answer `404`; delivery tokens, the deliverer, background tools, held runs (`TenantConfig.actionHoldMs`), `DurableExecution.deliver`, the Restate `NylorunAction` object, the `action_result` wake and the gates service's `/nylorun/v1/deliveries` are removed, and a migration drops the `actions` and `endpoints` tables. `PUT /v1/agents/:id` refuses a definition with a code tool or a flow tool stage (`400`); a tool the Runtime cannot run fails with `tool.unavailable`. The fixture model answers in text when the agent offers no `lookup_order` tool.
28
+ - **Breaking (`@nylorun/cli`):** `nylo endpoints` is removed (a usage error that says why); `nylo status` shows uncertain effects instead of pending Actions.
29
+ - **Breaking (`@nylorun/create-agent`):** the starter saves its agent with `saveAgent` and runs no server: no Action endpoint, `PORT` or `NYLORUN_ACTIONS_URL`. Its assistant has no tools, with a commented `http()` tool to start from.
30
+ - `nylorun`: the local stack's comments speak of MCP servers and HTTP tools on this machine, not Action endpoints.
31
+ - `@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.
32
+
33
+ - 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.
34
+
35
+ - **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: …`.
36
+ - **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.
37
+ - **Breaking (`@nylorun/harness`):** the turn loop runs no hooks; the turn state a checkpoint carries is `{ turnId }`, and the engine version is `hosted-4`, so checkpoints of earlier engines are refused.
38
+ - `@nylorun/runtime`: no `hook` Actions are offered or delivered.
39
+ - `@nylorun/studio`: the Agent Manifest tab drops the Hooks count and the turn lifecycle.
40
+
41
+ - 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.
42
+
43
+ - `@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").
44
+ - `@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.
45
+ - `@nylorun/agents`: `.skills()`, `skills()` and `.plugin()` read every file of a skill's folder, binary included (not `.git/`, `node_modules/`, OS files or `.env` files), and hash it; a file over 10 MiB or more than 500 files fail the build. `saveAgent` uploads the files the Runtime lacks before the definition; `client.files` (`has`, `upload`, `ensure`) does it by hand.
46
+ - `@nylorun/harness`: tests only.
47
+ - `@nylorun/studio`: the agent's manifest lists each skill's files.
48
+
49
+ ### Minor Changes
50
+
51
+ - 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.
52
+
53
+ - `@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.
54
+ - `@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.
55
+ - `@nylorun/agents`: `http()` builds HTTP verifiers too.
56
+ - `@nylorun/runtime`: a flow's HTTP stages and verifiers are executed like an agent's HTTP tool: address policy, the flow session's vault credential, `Nylorun-Session-Id`/`-Turn-Id`/`-Agent-Id` (the flow agent's id) and the flow effect id as `Idempotency-Key`, run once at the gates service (`POST /nylorun/v1/http-calls` takes `tool: { sessionId?, stage }`) and `uncertain` when the answer is lost. An HTTP verifier's verdict is recorded as `loop.verified`.
57
+ - `@nylorun/studio`: the workflow tree shows HTTP stages and HTTP verifiers with their method and URL.
58
+
59
+ - 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.
60
+
61
+ - `@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.
62
+ - `@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`.
63
+ - `@nylorun/agents`: exports `http` and the identity header constants.
64
+ - `@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.
65
+ - `@nylorun/studio`: the Agent Manifest tab lists HTTP tools with their method and URL, and marks tools and MCP servers that wait for approval.
66
+
67
+ ## 0.14.0-beta
68
+
69
+ ### Major Changes
70
+
71
+ - 7f763c3: **The Admin API and the operator listener are gone (Runtime and Management APIs, step A5).** Host work moves to the machine: `nylorun` runs `nylorun-operate` inside the runtime container, and every remote client uses the Runtime API or the Management API.
72
+
73
+ - **Breaking (`@nylorun/runtime`):** `/v1/admin/*` (status, host, shutdown, keys, openapi.json) is removed; it answers like any unknown route. The operator listener, `NYLORUN_ADMIN_LISTEN_PORT`, `NYLORUN_ADMIN_LISTEN_HOST`, `NYLORUN_ADMIN_ALLOWED_HOSTS` and `host.json`'s `adminPort` are gone, and so is the `admin-openapi.json` package file. Stop the Host with SIGTERM. `nylorun-operate status [--json]` reports the version, protocol and the Tenant's id, name, state and cause, exiting 2 when the Tenant is not open. `/ready` adds `harness: { mode, connected }` while the Tenant is open. `startEphemeralRuntime` loses `operatorListener` and `adminUrl`. The admin key stays: it derives Studio's key.
74
+ - **Breaking (`@nylorun/admin`):** `createAdmin()` is the Management API client (`tenant`, `keys`, `models`, `vaults`, `signingKeys`, `settings`) with a management key: explicit `{ url, key }`, else `NYLORUN_RUNTIME_URL` + `NYLORUN_MANAGEMENT_KEY`, else the Project link's or the local Host root's management key. `status()`, `adminUrl`, the Admin API keys, `NYLORUN_ADMIN_URL`/`NYLORUN_ADMIN_KEY` and `OPERATOR_KEYS_FEATURE` are removed; `deriveStudioToken` and `mintStudioLoginToken` stay.
75
+ - **Breaking (`@nylorun/core`):** `admin-status` leaves `PROTOCOL_FEATURES` (the Host still advertises it for protocol 5–7 clients) and `operator-keys` is removed; `AdminStatusSchema`, `AdminHostStatusSchema`, `HostAggregateSchema` and `HostShutdownResponseSchema` are removed.
76
+ - **Breaking (`nylorun`):** no admin port: `NYLORUN_ADMIN_PORT` is no longer written or published (an existing one is ignored). `nylorun start` waits for `/ready`, and `nylorun status` reads readiness from `/ready` and the Tenant from `nylorun-operate status`.
77
+ - `@nylorun/cli`: `nylo status` no longer falls back to the Admin API; when the Tenant does not answer it points to `npx nylorun status`.
78
+
79
+ - 98b0d37: **Protocol 8: the Runtime API and the Management API take separate keys (Runtime and Management APIs, step A4).** Upgrade every package together; `nylorun`, `@nylorun/cli` and Studio already use management keys (A3).
80
+
81
+ - **Breaking (`@nylorun/runtime`): `/v1/tenant/*` takes only a management key.** An application key there, alone or acting for a subject, is `403 key_role_mismatch`; a management key acting for a subject is `403 subject_invalid`. This covers the Tenant's status, seed and reset, models, providers, usage and budgets, sandbox and artifact settings, application keys, vaults and signing keys. A management key on any other route but `/v1/me` and the public `/v1/access/jwks` is `403 key_role_mismatch`.
82
+ - **Breaking (`@nylorun/runtime`): vaults and signing keys moved.** They are at `/v1/tenant/vaults…` (including `…/oauth/start`) and `/v1/tenant/signing-keys…`; `/v1/vaults…` and `/v1/access/signing-keys…` are gone, with no alias. Opening a session with `vaultIds` is unchanged, as are `GET /v1/oauth/callback` and `GET /v1/access/jwks`.
83
+ - **Breaking (`@nylorun/core`, `@nylorun/runtime`): `tenant:settings` is retired.** It leaves `SUBJECT_SCOPES`; `Nylorun-Scopes` may still name it and it grants nothing. `/v1/tenant/models` and `/v1/tenant/providers` no longer admit `agents:write` subjects: apps don't read the model catalog.
84
+ - **Breaking (`@nylorun/agents`):** the vault methods (`createVault`, `listVaults`, `getVault`, `deleteVault`, `createCredential`, `listCredentials`, `getCredential`, `rotateCredential`, `deleteCredential`) and `client.access.signingKeys` / `SigningKeysClient` are removed; use `admin.vaults` and `admin.signingKeys` from `@nylorun/admin`'s `createManagementClient`. `client.access.jwks()` stays.
85
+ - `@nylorun/core`: `PROTOCOL_VERSION` is 8 and `HOST_PROTOCOL` 4–8, with the required feature `management-api`. Runtime API routes keep their request and response shapes.
86
+ - `@nylorun/runtime`: `startEphemeralRuntime` registers a management key (`managementKey`, the key `bootstrap`).
87
+
88
+ ### Minor Changes
89
+
90
+ - 3b3bdc6: **The clients use management keys (Runtime and Management APIs, step A3).** The protocol stays at 7; every client keeps working against a protocol 7 Runtime's routes.
91
+
92
+ - `nylorun`: `nylorun start` keeps an application key (`project`) and a management key (`project-management`) for a Project, in `<Host root>/project-credentials.json` and the Project's `.nylorun/credentials.json` (still format 1, with new `managementKey` and `managementPrincipalId` fields). A credentials file holding only an application key gains a management key at the next start. Commands outside a project keep `cli` and `cli-management`. Keys are issued through `nylorun-operate` in the runtime container instead of the Admin API, and `nylorun key put <id> --management` puts a management key. Seeding the Tenant and `nylorun mcp connect` use the management key (`/v1/tenant/vaults`). Studio reaches the Runtime's public listener.
93
+ - `@nylorun/cli`: `status`, `reset`, `configure`, `doctor` and `access signing-keys` use the Management API through `@nylorun/admin` with the Project's management key, or `NYLORUN_MANAGEMENT_KEY`.
94
+ - `@nylorun/studio`: local Studio needs no login. A request on the published loopback address (`localhost` or `127.0.0.1` at Studio's port) acts as signed in; hosts behind a sign-in proxy and embedding keep their login, and state-changing requests still need Studio's own `Origin`. Studio learns its Tenant from `GET /v1/tenant` with its key instead of the Admin API, and its Connections page manages vaults through `@nylorun/admin/client` at `/v1/tenant/vaults`.
95
+ - **Breaking (`@nylorun/admin`, `@nylorun/runtime`): Studio's key is derived from the admin key alone.** `deriveStudioToken(adminKey)` takes no Tenant id (HMAC-SHA256 over `nylorun/studio/v2`). The Host registers the new key's hash at its next start, replacing the old one; an app that embeds Studio and derives its key must update.
96
+ - `@nylorun/core`: `ProjectCredentialsFileSchema` gains optional `managementKey` and `managementPrincipalId`.
97
+
98
+ - 6576e12: **Key roles and management keys (Runtime and Management APIs, step A1).** Additive; the protocol stays at 7. Application keys keep reaching every route they reach today.
99
+
100
+ - `@nylorun/runtime`: a key now has a role. `application` keys are unchanged. A new **management key** (role `management`) reaches the Management API (`/v1/tenant/*`) and `/v1/me` only, as itself: `Nylorun-Subject` or `Nylorun-Scopes` with it is `403 subject_invalid`, an `Origin` is `403 origin_rejected`, and any other route is `403 key_role_mismatch`. `/v1/me` reports it as `via: management:<id>` with no scopes and no agents. Studio's derived key has role `studio`, which reaches both. Migration `0011_key_roles` gives the existing `studio` principal its role.
101
+ - `@nylorun/runtime`: management keys are issued only on the Tenant's machine, with the new `nylorun-operate` command in the runtime image (`nylorun-operate keys list | put <id> [--role application|management] | rm <id>`), or from `NYLORUN_MANAGEMENT_KEY_FILE` (64 hex characters), which the Host registers as the key `bootstrap` at every start and replaces when the file changes. `bootstrap` is reserved like `studio`. Rotating a key keeps its role; putting an id that holds the other role is refused.
102
+ - `@nylorun/core`: `KEY_ROLES`, `KeyRole`, `BOOTSTRAP_KEY_ID` and the error code `key_role_mismatch`.
103
+
104
+ - b28bdd7: **Local MCP servers work on a local Tenant, and a server that does not connect shows.** Additive; the protocol stays at 7.
105
+
106
+ - `@nylorun/runtime`: remote MCP servers (`streamable-http`, `sse`) are reached under the Host's address policy, as Action endpoints are (`NYLORUN_ENDPOINT_*`, `tenant/outbound.ts`). In the local Docker stack `localhost`, `127.0.0.1` and `[::1]` now mean the machine that runs Docker (`host.docker.internal`), so `.mcp({ x: { type: "streamable-http", url: "http://localhost:3002/x" } })` connects where it used to fail with `fetch failed`. With `NYLORUN_ENDPOINT_PRIVATE=refuse` a server on a private address is refused; with `NYLORUN_ENDPOINT_HTTP=refuse` an `http` server is refused. Redirects are still not followed. A connection failure now names its cause (`connect ECONNREFUSED …`) instead of `fetch failed`. This applies in the gateway, a harness process and an in-process Tenant. `guardedFetch` takes `stream: true`: the answer streams, unbounded, with no timeout but the caller's signal.
107
+ - `@nylorun/core`: new session event `mcp.discovered`, recorded once on the session's first turn with the MCP snapshot: one entry per declared server with `outcome` (`connected`, `refused`, `failed`), `message` and the number of `tools` it added (`McpDiscoveredPayloadSchema`, `McpServerOutcomeSchema`). A server that does not connect adds no tools for the session's life; this is where that shows in the event log, beside `mcpDiagnostics`.
108
+ - `@nylorun/agents`: `.plugin()` and `plugin()` emit a process warning (`NylorunPluginWarning`, the diagnostic's code) for each part of the package they skip, so building or registering the agent says when a plugin's MCP server was dropped. The `plugin.mcp-server-skipped` message now says why: for example, plain `http` is accepted only for `localhost`, `127.0.0.1` or `[::1]`.
109
+ - `@nylorun/studio`: the event list labels `mcp.discovered` and summarizes each server's outcome.
110
+
111
+ - c66d8ed: Add optional session reads and a resumable model-ledger export: pinned manifests, usage totals, model calls, and opt-in session/history/sandbox pages (Host feature `session-reads`), and `GET /v1/tenant/calls/model` on the Management API (Host feature `calls-export`). Usage and model calls take an application key acting as itself; the export takes a management key. Runtime reads use a separate bounded, read-only Drizzle pool. The additive migration `0012_session_reads` preserves unknown legacy creation times and usage quality; the export uses safe transaction order without skipping committed rows. `@nylorun/agents` adds `client.sessions.page()`, `session.manifest()`, `session.usage()`, `session.modelCalls()`, `session.history({ limit })` and `client.sandboxes.page()`; `@nylorun/admin` adds `models.exportCalls()`. Legacy unpaged responses are unchanged.
112
+
113
+ ### Patch Changes
114
+
115
+ - cc107b1: **Named agents work as flow children.** An Agent with a `name` (for example `Agent({ id: "a", name: "Named A" })`) used in `.step()`, `.switch()`, `.parallel()`, `.map()`, `.loop()` or in `Chain`/`Switch`/`Parallel`/`Map`/`Loop` was mistaken for a tool, because a builder has a string `name` and an `.input()` method, and the build threw `tool.invalid: Tool 'Named A' must provide run() or execute()`. Agents, agent builders and flows are no longer classified as tools.
116
+
3
117
  ## 0.13.0-beta
4
118
 
5
119
  ### Major Changes
@@ -1,33 +1,40 @@
1
1
  export { hashManifest } from "./utils/hash.js";
2
2
  /**
3
+ * Protocol 8: the Runtime and Management APIs (`key_role_mismatch`), and manifest-only agents
4
+ * (track R2): manifest v5 and workflow manifest v3, no hooks or flow functions, remote MCP
5
+ * only, and no Action endpoints (`/v1/endpoints` and `/v1/actions/*` answer 404, delivery
6
+ * tokens are gone): an agent's tools are HTTP tools, remote MCP servers, agents and the
7
+ * Runtime's built-ins.
3
8
  * Protocol 7: open-source auth (F9 I3). Subject tokens (`POST /v1/tokens`), the access policy,
4
9
  * revocations, browser keys (`Nylorun-Key`), the Runtime's own CORS and derived principals are gone; their
5
10
  * routes answer 404. Browsers and apps present a trusted issuer's token, servers an operator key.
6
11
  * Protocol 6: file artifacts (`/v1/artifacts/**`, Runtime-signed capability links) and user
7
12
  * messages with `parts`. Protocol 5: a Host serves one Tenant, and nothing in a request selects
8
13
  * it. The Host still accepts protocol 4 (and `Nylorun-Tenant`), 5 and 6 clients on every route
9
- * that remains.
14
+ * that remains; a client that requires `action-endpoints` is refused by the feature check.
10
15
  */
11
- export declare const PROTOCOL_VERSION = 7;
16
+ export declare const PROTOCOL_VERSION = 8;
12
17
  /** What a client of this protocol requires of a Host. */
13
- export declare const PROTOCOL_FEATURES: readonly ["admin-status", "studio-principal", "action-endpoints", "artifacts"];
18
+ export declare const PROTOCOL_FEATURES: readonly ["studio-principal", "artifacts",
19
+ /**
20
+ * Protocol 8: the Management API (`/v1/tenant/*`) takes management keys only, and the
21
+ * Runtime API application keys only (`key_role_mismatch`); vaults and signing keys are under
22
+ * `/v1/tenant`.
23
+ */
24
+ "management-api"];
14
25
  export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
15
26
  /**
16
27
  * Host features no client requires: a client that uses one checks the Host's `/health`
17
28
  * for it first. `tenant-fixture-model`: `PUT /v1/tenant/config/seed` accepts
18
29
  * `fixtureModel: true` (the Tenant's model calls use the Runtime's fixture model).
19
- * `transcript-events`: the log carries `message.assistant` and `tool.completed`, and
20
- * tool `action.*` events carry `callId` and `invocationId`. `subject-headers`: an application
21
- * principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
30
+ * `transcript-events`: the log carries `message.assistant` and `tool.completed`.
31
+ * `subject-headers`: an application principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
22
32
  * enforces the scopes and the subject's ownership of sessions. `ag-ui-endpoint`: the Runtime
23
33
  * serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a trusted issuer's token or
24
34
  * by subject headers. `a2a-endpoint`:
25
35
  * `POST /v1/a2a/agents/:agent` answers A2A 1.0 JSON-RPC for a subject, and
26
36
  * `GET /v1/a2a/agents/:agent/card` returns the agent's card without its interfaces.
27
- * `action-endpoints`: `PUT`/`GET`/`DELETE /v1/endpoints` register the URL that runs each agent's
28
- * Actions, and the Runtime delivers them there, signed with a delivery token
29
- * (`Nylorun-Signature`), instead of offering them to executors. `sandboxes`: sandboxes are a
30
- * resource (`PUT`/`GET`/`DELETE /v1/sandboxes/{id}`, kind `virtual`), a session attaches to one
37
+ * `sandboxes`: sandboxes are a resource (`PUT`/`GET`/`DELETE /v1/sandboxes/{id}`, kind `virtual`), a session attaches to one
31
38
  * with `sandbox: { id }`, a token caller (a trusted issuer's token) carries sandbox grants
32
39
  * checked at every turn start, and `sandboxes:write` lets a subject create and delete the
33
40
  * sandboxes it is granted.
@@ -39,11 +46,8 @@ export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
39
46
  * (`NYLORUN_IDENTITY_FILE`) as bearers, from servers and from browsers alike, with the
40
47
  * issuer's subject, scopes (and the issuer-only `studio`), agents and sandbox grants; `GET
41
48
  * /v1/me` reports who any credential is.
42
- * `operator-keys`: the Admin API creates, rotates, lists and deletes the Tenant's application
43
- * keys by name (`PUT`/`GET`/`DELETE /v1/admin/keys`); a deleted or rotated key stops
44
- * authenticating at once. `studio` is not managed there.
45
49
  */
46
- export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "transcript-events", "subject-headers", "ag-ui-endpoint", "a2a-endpoint", "action-endpoints", "sandboxes", "sandbox-pods", "trusted-issuers", "operator-keys"];
50
+ export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "transcript-events", "subject-headers", "ag-ui-endpoint", "a2a-endpoint", "sandboxes", "sandbox-pods", "trusted-issuers", "session-reads", "calls-export"];
47
51
  export type OptionalHostFeature = (typeof OPTIONAL_HOST_FEATURES)[number];
48
52
  export interface ProtocolRange {
49
53
  min: number;
@@ -51,10 +55,11 @@ export interface ProtocolRange {
51
55
  features: readonly string[];
52
56
  }
53
57
  /**
54
- * What this Host serves. `runtime-tenants` (protocol 4 clients require it) is still advertised
55
- * for the compatibility window; protocol 5 and later clients no longer require it. `artifacts`
56
- * (protocol 6 and 7, required by their clients): file artifacts, capability links and message
57
- * `parts`.
58
+ * What this Host serves. `runtime-tenants` (protocol 4 clients require it) and `admin-status`
59
+ * (protocol 5 to 7 clients require it) are still advertised for the compatibility window, so
60
+ * those clients keep reaching the Runtime API; protocol 8 clients require neither. The Admin
61
+ * API itself is gone (protocol 8): `/v1/admin/*` is the opaque 404. `artifacts` (protocol 6 and
62
+ * 7, required by their clients): file artifacts, capability links and message `parts`.
58
63
  */
59
64
  export declare const HOST_PROTOCOL: ProtocolRange;
60
65
  export declare const DEFINITION_SCHEMA_VERSION = 2;
@@ -68,11 +73,16 @@ export declare const PROTOCOL_HEADER = "Nylorun-Protocol";
68
73
  export declare const SUBJECT_HEADER = "Nylorun-Subject";
69
74
  /** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
70
75
  export declare const SCOPES_HEADER = "Nylorun-Scopes";
71
- /** The delivery token on a request the Runtime sends to an Action endpoint. */
72
- export declare const SIGNATURE_HEADER = "Nylorun-Signature";
73
- /** Set to `1` on an Action endpoint's response whose body is a tagged `ActionOutcome`. */
74
- export declare const OUTCOME_HEADER = "Nylorun-Outcome";
75
- export declare const ERROR_CODES: readonly ["not_found", "protocol_unsupported", "host_rejected", "origin_rejected", "unsupported_media_type", "connection_missing", "incompatible_host", "subject_invalid", "scope_required", "token_expired", "limit_exceeded",
76
+ /** The session, turn and agent of a call the Runtime makes to an HTTP tool's URL. */
77
+ export declare const SESSION_ID_HEADER = "Nylorun-Session-Id";
78
+ export declare const TURN_ID_HEADER = "Nylorun-Turn-Id";
79
+ export declare const AGENT_ID_HEADER = "Nylorun-Agent-Id";
80
+ export declare const ERROR_CODES: readonly ["not_found", "protocol_unsupported", "host_rejected", "origin_rejected", "unsupported_media_type", "connection_missing", "incompatible_host", "subject_invalid", "scope_required",
81
+ /**
82
+ * A known key on the other API (protocol 8): an application key on the Management API
83
+ * (`/v1/tenant/*`), or a management key on the Runtime API. The message names the key's API.
84
+ */
85
+ "key_role_mismatch", "token_expired", "limit_exceeded",
76
86
  /** A request the Runtime refuses for a reason the message gives. */
77
87
  "request_rejected",
78
88
  /** A request the Host could not read: headers, body or query. */
@@ -104,11 +114,16 @@ export declare const ERROR_CODES: readonly ["not_found", "protocol_unsupported",
104
114
  /** An OAuth callback's `state` is unknown, already used or expired: start the connect again. */
105
115
  "oauth_state_invalid",
106
116
  /** The authorization server (or its discovery) failed or refused an MCP OAuth connect step. */
107
- "oauth_failed", "internal_error"];
117
+ "oauth_failed",
118
+ /**
119
+ * A definition names definition files the Runtime does not hold (track R2 M4): upload each
120
+ * with `PUT /v1/files/sha256:<hex>` first. `details.missing` lists their hashes.
121
+ */
122
+ "definition_files_missing", "internal_error"];
108
123
  export type ErrorCode = (typeof ERROR_CODES)[number];
109
124
  export declare const TENANT_ID_PATTERN: RegExp;
110
125
  export declare const PRINCIPAL_ID_PATTERN: RegExp;
111
- /** A Tenant signing key's id, the `kid` of the tokens it signs (delivery tokens, capability links). */
126
+ /** A Tenant signing key's id, the `kid` of the tokens it signs (capability links, run tokens). */
112
127
  export declare const SIGNING_KEY_ID_PATTERN: RegExp;
113
128
  /** A file artifact's id (protocol 6). */
114
129
  export declare const ARTIFACT_ID_PATTERN: RegExp;
@@ -117,6 +132,15 @@ export declare const ARTIFACT_ID_PATTERN: RegExp;
117
132
  * `studio` is reserved for the key Studio derives from the admin key.
118
133
  */
119
134
  export declare const APPLICATION_KEY_ID_PATTERN: RegExp;
135
+ /**
136
+ * What a key reaches (protocol 8). `application`: the Runtime API, for the whole Tenant or for
137
+ * one subject. `management`: the Management API (`/v1/tenant/*`), as itself only. `studio`: the
138
+ * key Studio derives from the admin key, which reaches both.
139
+ */
140
+ export declare const KEY_ROLES: readonly ["application", "management", "studio"];
141
+ export type KeyRole = (typeof KEY_ROLES)[number];
142
+ /** The management key a Host registers from `NYLORUN_MANAGEMENT_KEY_FILE` at start. */
143
+ export declare const BOOTSTRAP_KEY_ID = "bootstrap";
120
144
  export declare function isTenantId(value: unknown): value is string;
121
145
  export declare function isPrincipalId(value: unknown): value is string;
122
146
  /**
@@ -1,37 +1,42 @@
1
1
  export { hashManifest } from "./utils/hash.js";
2
2
  /**
3
+ * Protocol 8: the Runtime and Management APIs (`key_role_mismatch`), and manifest-only agents
4
+ * (track R2): manifest v5 and workflow manifest v3, no hooks or flow functions, remote MCP
5
+ * only, and no Action endpoints (`/v1/endpoints` and `/v1/actions/*` answer 404, delivery
6
+ * tokens are gone): an agent's tools are HTTP tools, remote MCP servers, agents and the
7
+ * Runtime's built-ins.
3
8
  * Protocol 7: open-source auth (F9 I3). Subject tokens (`POST /v1/tokens`), the access policy,
4
9
  * revocations, browser keys (`Nylorun-Key`), the Runtime's own CORS and derived principals are gone; their
5
10
  * routes answer 404. Browsers and apps present a trusted issuer's token, servers an operator key.
6
11
  * Protocol 6: file artifacts (`/v1/artifacts/**`, Runtime-signed capability links) and user
7
12
  * messages with `parts`. Protocol 5: a Host serves one Tenant, and nothing in a request selects
8
13
  * it. The Host still accepts protocol 4 (and `Nylorun-Tenant`), 5 and 6 clients on every route
9
- * that remains.
14
+ * that remains; a client that requires `action-endpoints` is refused by the feature check.
10
15
  */
11
- export const PROTOCOL_VERSION = 7;
16
+ export const PROTOCOL_VERSION = 8;
12
17
  /** What a client of this protocol requires of a Host. */
13
18
  export const PROTOCOL_FEATURES = [
14
- "admin-status",
15
19
  "studio-principal",
16
- "action-endpoints",
17
20
  "artifacts",
21
+ /**
22
+ * Protocol 8: the Management API (`/v1/tenant/*`) takes management keys only, and the
23
+ * Runtime API application keys only (`key_role_mismatch`); vaults and signing keys are under
24
+ * `/v1/tenant`.
25
+ */
26
+ "management-api",
18
27
  ];
19
28
  /**
20
29
  * Host features no client requires: a client that uses one checks the Host's `/health`
21
30
  * for it first. `tenant-fixture-model`: `PUT /v1/tenant/config/seed` accepts
22
31
  * `fixtureModel: true` (the Tenant's model calls use the Runtime's fixture model).
23
- * `transcript-events`: the log carries `message.assistant` and `tool.completed`, and
24
- * tool `action.*` events carry `callId` and `invocationId`. `subject-headers`: an application
25
- * principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
32
+ * `transcript-events`: the log carries `message.assistant` and `tool.completed`.
33
+ * `subject-headers`: an application principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
26
34
  * enforces the scopes and the subject's ownership of sessions. `ag-ui-endpoint`: the Runtime
27
35
  * serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a trusted issuer's token or
28
36
  * by subject headers. `a2a-endpoint`:
29
37
  * `POST /v1/a2a/agents/:agent` answers A2A 1.0 JSON-RPC for a subject, and
30
38
  * `GET /v1/a2a/agents/:agent/card` returns the agent's card without its interfaces.
31
- * `action-endpoints`: `PUT`/`GET`/`DELETE /v1/endpoints` register the URL that runs each agent's
32
- * Actions, and the Runtime delivers them there, signed with a delivery token
33
- * (`Nylorun-Signature`), instead of offering them to executors. `sandboxes`: sandboxes are a
34
- * resource (`PUT`/`GET`/`DELETE /v1/sandboxes/{id}`, kind `virtual`), a session attaches to one
39
+ * `sandboxes`: sandboxes are a resource (`PUT`/`GET`/`DELETE /v1/sandboxes/{id}`, kind `virtual`), a session attaches to one
35
40
  * with `sandbox: { id }`, a token caller (a trusted issuer's token) carries sandbox grants
36
41
  * checked at every turn start, and `sandboxes:write` lets a subject create and delete the
37
42
  * sandboxes it is granted.
@@ -43,9 +48,6 @@ export const PROTOCOL_FEATURES = [
43
48
  * (`NYLORUN_IDENTITY_FILE`) as bearers, from servers and from browsers alike, with the
44
49
  * issuer's subject, scopes (and the issuer-only `studio`), agents and sandbox grants; `GET
45
50
  * /v1/me` reports who any credential is.
46
- * `operator-keys`: the Admin API creates, rotates, lists and deletes the Tenant's application
47
- * keys by name (`PUT`/`GET`/`DELETE /v1/admin/keys`); a deleted or rotated key stops
48
- * authenticating at once. `studio` is not managed there.
49
51
  */
50
52
  export const OPTIONAL_HOST_FEATURES = [
51
53
  "tenant-fixture-model",
@@ -53,22 +55,23 @@ export const OPTIONAL_HOST_FEATURES = [
53
55
  "subject-headers",
54
56
  "ag-ui-endpoint",
55
57
  "a2a-endpoint",
56
- "action-endpoints",
57
58
  "sandboxes",
58
59
  "sandbox-pods",
59
60
  "trusted-issuers",
60
- "operator-keys",
61
+ "session-reads",
62
+ "calls-export",
61
63
  ];
62
64
  /**
63
- * What this Host serves. `runtime-tenants` (protocol 4 clients require it) is still advertised
64
- * for the compatibility window; protocol 5 and later clients no longer require it. `artifacts`
65
- * (protocol 6 and 7, required by their clients): file artifacts, capability links and message
66
- * `parts`.
65
+ * What this Host serves. `runtime-tenants` (protocol 4 clients require it) and `admin-status`
66
+ * (protocol 5 to 7 clients require it) are still advertised for the compatibility window, so
67
+ * those clients keep reaching the Runtime API; protocol 8 clients require neither. The Admin
68
+ * API itself is gone (protocol 8): `/v1/admin/*` is the opaque 404. `artifacts` (protocol 6 and
69
+ * 7, required by their clients): file artifacts, capability links and message `parts`.
67
70
  */
68
71
  export const HOST_PROTOCOL = {
69
72
  min: 4,
70
- max: 7,
71
- features: ["runtime-tenants", ...PROTOCOL_FEATURES, ...OPTIONAL_HOST_FEATURES],
73
+ max: 8,
74
+ features: ["runtime-tenants", "admin-status", ...PROTOCOL_FEATURES, ...OPTIONAL_HOST_FEATURES],
72
75
  };
73
76
  export const DEFINITION_SCHEMA_VERSION = 2;
74
77
  /**
@@ -81,10 +84,10 @@ export const PROTOCOL_HEADER = "Nylorun-Protocol";
81
84
  export const SUBJECT_HEADER = "Nylorun-Subject";
82
85
  /** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
83
86
  export const SCOPES_HEADER = "Nylorun-Scopes";
84
- /** The delivery token on a request the Runtime sends to an Action endpoint. */
85
- export const SIGNATURE_HEADER = "Nylorun-Signature";
86
- /** Set to `1` on an Action endpoint's response whose body is a tagged `ActionOutcome`. */
87
- export const OUTCOME_HEADER = "Nylorun-Outcome";
87
+ /** The session, turn and agent of a call the Runtime makes to an HTTP tool's URL. */
88
+ export const SESSION_ID_HEADER = "Nylorun-Session-Id";
89
+ export const TURN_ID_HEADER = "Nylorun-Turn-Id";
90
+ export const AGENT_ID_HEADER = "Nylorun-Agent-Id";
88
91
  export const ERROR_CODES = [
89
92
  "not_found",
90
93
  "protocol_unsupported",
@@ -95,6 +98,11 @@ export const ERROR_CODES = [
95
98
  "incompatible_host",
96
99
  "subject_invalid",
97
100
  "scope_required",
101
+ /**
102
+ * A known key on the other API (protocol 8): an application key on the Management API
103
+ * (`/v1/tenant/*`), or a management key on the Runtime API. The message names the key's API.
104
+ */
105
+ "key_role_mismatch",
98
106
  "token_expired",
99
107
  "limit_exceeded",
100
108
  /** A request the Runtime refuses for a reason the message gives. */
@@ -129,13 +137,18 @@ export const ERROR_CODES = [
129
137
  "oauth_state_invalid",
130
138
  /** The authorization server (or its discovery) failed or refused an MCP OAuth connect step. */
131
139
  "oauth_failed",
140
+ /**
141
+ * A definition names definition files the Runtime does not hold (track R2 M4): upload each
142
+ * with `PUT /v1/files/sha256:<hex>` first. `details.missing` lists their hashes.
143
+ */
144
+ "definition_files_missing",
132
145
  "internal_error",
133
146
  ];
134
147
  /** Crockford Base32 alphabet (lowercase); excludes i, l, o, u. */
135
148
  const CROCKFORD = "0123456789abcdefghjkmnpqrstvwxyz";
136
149
  export const TENANT_ID_PATTERN = /^tn_[0-9a-hjkmnp-tv-z]{26}$/;
137
150
  export const PRINCIPAL_ID_PATTERN = /^pr_[0-9a-hjkmnp-tv-z]{26}$/;
138
- /** A Tenant signing key's id, the `kid` of the tokens it signs (delivery tokens, capability links). */
151
+ /** A Tenant signing key's id, the `kid` of the tokens it signs (capability links, run tokens). */
139
152
  export const SIGNING_KEY_ID_PATTERN = /^sk_[0-9a-hjkmnp-tv-z]{26}$/;
140
153
  /** A file artifact's id (protocol 6). */
141
154
  export const ARTIFACT_ID_PATTERN = /^af_[0-9a-hjkmnp-tv-z]{26}$/;
@@ -144,6 +157,14 @@ export const ARTIFACT_ID_PATTERN = /^af_[0-9a-hjkmnp-tv-z]{26}$/;
144
157
  * `studio` is reserved for the key Studio derives from the admin key.
145
158
  */
146
159
  export const APPLICATION_KEY_ID_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
160
+ /**
161
+ * What a key reaches (protocol 8). `application`: the Runtime API, for the whole Tenant or for
162
+ * one subject. `management`: the Management API (`/v1/tenant/*`), as itself only. `studio`: the
163
+ * key Studio derives from the admin key, which reaches both.
164
+ */
165
+ export const KEY_ROLES = ["application", "management", "studio"];
166
+ /** The management key a Host registers from `NYLORUN_MANAGEMENT_KEY_FILE` at start. */
167
+ export const BOOTSTRAP_KEY_ID = "bootstrap";
147
168
  export function isTenantId(value) {
148
169
  return typeof value === "string" && TENANT_ID_PATTERN.test(value);
149
170
  }