@nylorun/runtime 0.20.0-beta → 0.21.1-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/CHANGELOG.md +86 -0
  2. package/README.md +19 -12
  3. package/dist/adapters/execution/restate.js +26 -1
  4. package/dist/api/components.d.ts +155 -36
  5. package/dist/api/components.js +3 -3
  6. package/dist/api/http/app.js +2 -0
  7. package/dist/api/http/routes/mcp.d.ts +9 -0
  8. package/dist/api/http/routes/mcp.js +32 -0
  9. package/dist/api/http/routes/vaults.d.ts +1 -9
  10. package/dist/api/http/routes/vaults.js +3 -103
  11. package/dist/api/openapi.js +6 -3
  12. package/dist/artifacts/media-types.d.ts +2 -0
  13. package/dist/artifacts/media-types.js +5 -0
  14. package/dist/core/flow-host.d.ts +2 -3
  15. package/dist/core/flow-host.js +10 -7
  16. package/dist/execution/types.d.ts +13 -5
  17. package/dist/execution/types.js +13 -5
  18. package/dist/gates/http-tool.d.ts +7 -0
  19. package/dist/gates/http-tool.js +34 -3
  20. package/dist/gates/mcp-handler.d.ts +4 -1
  21. package/dist/gates/mcp-handler.js +64 -8
  22. package/dist/gates/tenant-vaults.d.ts +9 -15
  23. package/dist/gates/tenant-vaults.js +9 -17
  24. package/dist/gates/tool-client.js +36 -17
  25. package/dist/gates/tool-contract.d.ts +19 -3
  26. package/dist/gates/tool-contract.js +9 -3
  27. package/dist/gates/tool-gate.d.ts +2 -2
  28. package/dist/harness/calls.d.ts +2 -0
  29. package/dist/harness/calls.js +13 -3
  30. package/dist/harness-api/record.d.ts +7 -6
  31. package/dist/harness-api/record.js +99 -17
  32. package/dist/harness-api/server.js +35 -27
  33. package/dist/harness-api/start.js +2 -1
  34. package/dist/host/config-for.d.ts +0 -2
  35. package/dist/host/config-for.js +0 -1
  36. package/dist/host/create-host.d.ts +1 -1
  37. package/dist/host/create-host.js +2 -1
  38. package/dist/host/gates.js +0 -1
  39. package/dist/host/http.d.ts +0 -1
  40. package/dist/host/http.js +0 -6
  41. package/dist/host/main.js +13 -3
  42. package/dist/host/stack-config.d.ts +7 -8
  43. package/dist/host/stack-config.js +50 -92
  44. package/dist/index.d.ts +0 -1
  45. package/dist/keys/client.js +1 -9
  46. package/dist/keys/keys.d.ts +11 -13
  47. package/dist/keys/keys.js +5 -7
  48. package/dist/management-openapi.json +315 -345
  49. package/dist/mcp/connect.d.ts +159 -13
  50. package/dist/mcp/connect.js +538 -55
  51. package/dist/mcp/pool.d.ts +11 -2
  52. package/dist/mcp/pool.js +74 -27
  53. package/dist/mcp/preview.d.ts +35 -0
  54. package/dist/mcp/preview.js +215 -0
  55. package/dist/mcp/snapshot.d.ts +79 -5
  56. package/dist/mcp/snapshot.js +145 -27
  57. package/dist/model/catalog.d.ts +14 -0
  58. package/dist/model/catalog.js +14 -1
  59. package/dist/model/pi-model.js +36 -2
  60. package/dist/openapi.json +362 -123
  61. package/dist/redact.d.ts +19 -1
  62. package/dist/redact.js +42 -13
  63. package/dist/sandbox/session-sandbox.d.ts +7 -0
  64. package/dist/sandbox/session-sandbox.js +89 -28
  65. package/dist/store/postgres/drizzle/0016_mcp_oauth_removed.sql +5 -0
  66. package/dist/store/postgres/drizzle/0017_wake_outbox.sql +9 -0
  67. package/dist/store/postgres/drizzle/meta/_journal.json +14 -0
  68. package/dist/store/postgres/schema.d.ts +105 -261
  69. package/dist/store/postgres/schema.js +18 -36
  70. package/dist/store/postgres/store.js +54 -21
  71. package/dist/store/postgres/tenant.d.ts +14 -0
  72. package/dist/store/postgres/tenant.js +22 -2
  73. package/dist/store/types.d.ts +48 -13
  74. package/dist/tenant/advance.js +1 -4
  75. package/dist/tenant/artifact-tool.d.ts +9 -1
  76. package/dist/tenant/artifact-tool.js +113 -9
  77. package/dist/tenant/commands.js +5 -5
  78. package/dist/tenant/context.d.ts +15 -13
  79. package/dist/tenant/effects.d.ts +2 -2
  80. package/dist/tenant/effects.js +20 -5
  81. package/dist/tenant/ephemeral.d.ts +0 -6
  82. package/dist/tenant/ephemeral.js +0 -1
  83. package/dist/tenant/outbound.d.ts +14 -5
  84. package/dist/tenant/outbound.js +21 -9
  85. package/dist/tenant/runtime.js +11 -15
  86. package/dist/tenant/sessions.js +20 -3
  87. package/dist/tenant/store-pg.js +9 -0
  88. package/dist/tenant/sweep.d.ts +14 -0
  89. package/dist/tenant/sweep.js +69 -10
  90. package/dist/tenant/tool-results.d.ts +57 -0
  91. package/dist/tenant/tool-results.js +298 -0
  92. package/dist/tenant/tool-search.d.ts +43 -0
  93. package/dist/tenant/tool-search.js +100 -0
  94. package/dist/tenant/transcript.d.ts +108 -0
  95. package/dist/tenant/transcript.js +13 -0
  96. package/dist/tenant/types.d.ts +0 -14
  97. package/dist/vault/crypto.d.ts +0 -7
  98. package/dist/vault/crypto.js +0 -16
  99. package/dist/vault/headers.d.ts +17 -0
  100. package/dist/vault/headers.js +61 -0
  101. package/dist/vault/service.d.ts +11 -68
  102. package/dist/vault/service.js +83 -438
  103. package/dist/vault/sources.d.ts +20 -48
  104. package/dist/vault/sources.js +25 -189
  105. package/dist/version.d.ts +1 -1
  106. package/dist/version.js +1 -1
  107. package/package.json +3 -3
  108. package/dist/vault/oauth.d.ts +0 -55
  109. package/dist/vault/oauth.js +0 -186
package/CHANGELOG.md CHANGED
@@ -1,5 +1,91 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.21.1-beta
4
+
5
+ ### Patch Changes
6
+
7
+ - 070674d: **One source of truth for the manifest and Harness API schemas.**
8
+
9
+ - `@nylorun/core`: `Agent.from` (`agentFrom`) checks a manifest with `AgentManifestSchema`, the Runtime's own check, instead of a validator of its own, and refuses with `agent.build-failed` and the schema's messages (each prefixed with its path, such as `capabilities.0.tools.0.name: …`). It now refuses what the Runtime refuses at registration and it let through, such as unknown fields (it dropped them) or a tool or MCP server name that not every model provider accepts. The schema names a top-level `model` or `schemaVersion` and a capability's `model` as before, and the skill whose `files` are wrong (`Skill 'triage' files must include SKILL.md`). The rebuilt manifest is a frozen copy; the object passed in is no longer frozen. `AgentManifestSchema` and `WorkflowManifestSchema` are no longer force-cast to their types: the build checks that each accepts exactly `AgentManifest` and `WorkflowManifest`. `@nylorun/core/contracts` exports `McpServerManifestSchema`, `HEADER_NAME_PATTERN` and `LOOPBACK_HOSTS`. The Harness API's types (`@nylorun/core/harness-api`) are inferred from the schemas that validate its frames, so they match them: `TurnStart.manifest`, `TurnStart.checkpoint` and `RunRouting.rootManifest` are `object`, `WorkspaceCall.tool` is a sandbox tool name, `ABORT_REASONS` is a tuple, and properties are no longer `readonly` (arrays that were stay so).
10
+ - `@nylorun/harness`: `runDurable` checks the manifest once, when it rebuilds the agent, instead of twice. The unpublished, stale `schemas/manifest.schema.json` (manifest `schemaVersion` 2) is gone; `z.toJSONSchema(AgentManifestSchema)` is the manifest's JSON Schema.
11
+ - `@nylorun/agents`: a plugin's MCP servers are checked with core's `McpServerManifestSchema`, header-name pattern and loopback hosts. A server whose key is not a name every model provider accepts is skipped with a `plugin.mcp-server-skipped` warning, since the Runtime would refuse the manifest declaring it.
12
+ - `@nylorun/runtime`: the stack configuration reads its four listeners (`NYLORUN_LISTEN_*`, `NYLORUN_GATES_LISTEN_*`, `NYLORUN_HARNESS_LISTEN_*`, `NYLORUN_EGRESS_LISTEN_*`) with one parser; the variables and their errors are unchanged.
13
+
14
+ - 34d1a81: A commit can no longer lose its wake. A transaction that asks for an advance writes the wake to the Session Store's wake outbox (`Tx.wake`, migration `0017_wake_outbox` adds `nylorun.wakes`) and sends it to Durable Session Execution after commit, with an idempotency key (the wake's dedupe key, or one made from its row), deleting the row once Restate accepted it. A send that fails, or that a crash between the commit and the send cut off, is sent again by the Tenant sweep under the same key: on a process's first pass for any row, then for rows older than 2 s. Restate deduplicates the repeat, so a wake whose answer was lost runs one advance. The sweep's orphan scan no longer delivers lost wakes: it runs on a process's first pass and then once a minute, as the backstop for what the execution itself lost (Restate state wiped, an invocation killed, an in-process execution's queue). Restate owns when a session runs (wakes, one advance per session, retries, timers); the Session Store owns what happened (checkpoint, effect journal, events, the lease's epoch and the outbox), as `src/CONTEXT.md` and `adapters/execution/restate.ts` now describe. A Runtime of the previous beta refuses the migrated database (`schema-too-new`); while processes of both run, the old ones send wakes as before.
15
+ - Pin core to the tested release.
16
+ - Pin harness to the tested release.
17
+ - Updated dependencies [417f336]
18
+ - Updated dependencies [6fecd4c]
19
+ - Updated dependencies [7780b2f]
20
+ - Updated dependencies [070674d]
21
+ - Updated dependencies
22
+ - @nylorun/core@0.18.0-beta
23
+ - @nylorun/harness@0.25.0-beta
24
+
25
+ ## 0.21.0-beta
26
+
27
+ ### Major Changes
28
+
29
+ - 50e2f7e: **Protocol 10: MCP credentials come from a session's vaults only.** Nylorun no longer signs the installation in to MCP servers with OAuth and no longer asks a credential resolver. Upgrade every package together; MIGRATION.md has the details.
30
+
31
+ - **Breaking (`@nylorun/runtime`): the MCP OAuth connect is gone.** `POST /v1/tenant/vaults/{vaultId}/oauth/start` and `GET /v1/oauth/callback` answer `404`. The vault credential type `oauth` and its refresh are gone: a credential is a `bearer` token or a `headers` map bound to a URL. Migration `0016_mcp_oauth_removed` drops the table of pending connects and deletes every `oauth` credential, writing one audit row each (actor `migration`); the Runtime logs `oauth_credential_removed` once for each, naming its vault, id and URL.
32
+ - **Breaking (`@nylorun/runtime`): the credential resolver is gone.** The gateway no longer asks the operator's resolver for a person's credential when the session's vaults hold none. A process that still sets a `NYLORUN_RESOLVER_*` variable logs `resolver_removed` and ignores it. Keep a person's own keys in their user vault and attach it to their sessions (`vaultIds`). `TenantConfig.resolver`, `TenantConfig.publicUrl`, `TenantConfig.vaultFetch`, `startEphemeralRuntime({ resolver })`, the `ResolverConfig` export and `VaultService`'s `fetch` option are removed; `NYLORUN_PUBLIC_URL` still sets the protected resource metadata's `resource`.
33
+ - **Breaking (`@nylorun/core`):** `PROTOCOL_VERSION` is 10 and `HOST_PROTOCOL` 4–10. `StartOAuthRequest`, `StartOAuthResponse`, the `oauth` variants of `CreateCredentialRequest` and `RotateCredentialRequest`, `oauth` in `CredentialInfo.type` and `CredentialInfo.expiresAt` are removed, and `ERROR_CODES` drops `oauth_client_required`, `oauth_state_invalid` and `oauth_failed`. `@nylorun/agents` and `@nylorun/cli` send protocol 10.
34
+ - **Breaking (`@nylorun/admin`):** `admin.vaults` loses its OAuth start method.
35
+ - **Breaking (`nylorun`):** the `connect` subcommand of `nylorun mcp` is removed (`nylorun mcp inspect` lists a server's tools instead), and the gateway's Compose service no longer passes the `NYLORUN_RESOLVER_*` variables.
36
+ - `@nylorun/studio`: the Credentials page loses the OAuth type, the Expires column and the OAuth connect hint.
37
+
38
+ ### Minor Changes
39
+
40
+ - e0e39ff: **Header map, gateway and identity header credentials; `credential_rejected` on a `401`** (R2b C1, C2). For remote MCP servers and HTTP tools alike, in installation and user vaults. MIGRATION.md (protocol 10, "Header and gateway credentials" and "Tool errors the model sees") has the details.
41
+
42
+ - `@nylorun/core`: `CreateCredentialRequest` and `RotateCredentialRequest` gain `type: "headers"` with a `headers` map, and optional `via` (where requests go, such as a gateway: `https`, or `http` to a loopback host, with no userinfo, query string or fragment) and `identity: { header }` on both kinds; a rotation may change them, and `null` removes one. `CredentialInfo` gains `headers` in its type, `headerNames`, `via` and `identity`, never a value. `ERROR_CODES` gains `credential_rejected`, and `tool.completed`'s `error` documents `server` and `vault`. The admin client's vault methods take the new bodies through these types.
43
+ - `@nylorun/runtime`: a `headers` credential is sealed like a token and sends every header in its map; the transport's headers, `Idempotency-Key` and `Nylorun-*` are refused (`400`), and a credential header replaces a manifest header of the same name. A credential with `via` sends the server's requests there, while the manifest's URL still picks the credential and names the tools. An identity header carries the session owner's subject from the session record, and is left out for a session owned by `installation`. A `401` from an MCP server or HTTP tool is a failed tool call with code `credential_rejected` that the model sees, never retried and never `uncertain`. `via`, `identity` and the header names are stored unsealed in the credential's binding: no migration.
44
+ - `@nylorun/studio`: the Credentials page adds Bearer or Headers credentials (name and value rows), with an optional gateway URL and identity header, and shows them without values.
45
+
46
+ - 18f9a2f: **Model-safe MCP tool names, coded MCP tool errors and credential scrubbing** (R2b C6, C7, C8). MIGRATION.md (protocol 10, "Tool and MCP server names" and "Tool errors the model sees") has the details.
47
+
48
+ - `@nylorun/core`: a declared tool's name and an MCP server's name must match `^[A-Za-z0-9_-]{1,64}$` (`AgentManifestSchema`, so `PUT /v1/agents/{id}` refuses others). `mcp.discovered`'s server outcomes gain `renamed: [{ serverToolName, name }]`; `tool.completed` gains `redacted` and its `error` gains `retryable`. A failed `ToolOutcome` and `ToolResult` may carry `retryable`.
49
+ - `@nylorun/harness`: a failed tool result keeps the outcome's `retryable`, and the model sees it beside `code` and `message`.
50
+ - `@nylorun/runtime`: the model knows an MCP tool by `server__tool` with characters outside `[A-Za-z0-9_-]` replaced by `_`, shortened to 64 with an 8-hex SHA-256 suffix (also given to a renamed tool that collides); the server is still called by its own name. A failed MCP tool call is a failed tool result the model sees, with code `mcp.unreachable` (never sent; retryable), `credential_rejected` (`401`), `mcp.forbidden` (`403`), `mcp.error` (a JSON-RPC error) or `mcp.status` (another HTTP status); a call whose answer was lost after it was sent is `mcp.lost` for a `readOnlyHint` or `idempotentHint` tool and stays `uncertain` otherwise, as does a call lost with a gateway restart. A pooled connection whose server ended its session (`404` to its `Mcp-Session-Id`) or whose credential's `via` moved is dropped, opened again, and the call sent once more, since the tool never saw it. The credential values sent on a call (at least 8 characters, and a `Bearer` value's token) are replaced with `[redacted]` in MCP and HTTP tool results and errors before the gate records or returns them; no other field is touched.
51
+
52
+ - da93711: **Preview an MCP server's tools** (R2b C12). MIGRATION.md (protocol 10, "Previewing a server's tools") has the details.
53
+
54
+ - `@nylorun/core`: `McpPreviewRequestSchema` and `McpPreviewSchema` (`McpPreviewTool`), and the error code `mcp_preview_failed`.
55
+ - `@nylorun/runtime`: `POST /v1/tenant/mcp/preview` (the Management API) connects to a remote MCP server with the installation vault's credential for its URL (headers and `via`, no identity header), under the Host's address policy and within 15 s, and answers its server info, instructions, tools (model names, annotations, schema sizes) and renames; a `401` is `authRequired`, with the server's RFC 9728 protected-resource metadata. It runs in the keys service (`Keys.previewMcp`), which holds the plaintext, and calls no tool. Both OpenAPI documents list it.
56
+ - `@nylorun/admin`: `admin.mcp.preview({ url, type?, name?, vaultId? })`.
57
+ - `nylorun`: `nylorun mcp inspect <url> [--server <name>] [--vault <id>] [--sse] [--json]` prints the running Tenant's preview: a table of tools, the renames, or that the server needs a person's sign-in. Its `connect` subcommand still says it was removed, and now points to `inspect`.
58
+ - `@nylorun/studio`: **Preview tools** on each credential of the Credentials page lists the tools behind its URL.
59
+
60
+ - 90a817d: **MCP and HTTP tool results that fit** (R2b C11). MIGRATION.md (protocol 10, "Tool results that fit") has the details.
61
+
62
+ - `@nylorun/core`: a completed `ToolOutcome` may carry `files` (`ToolResultFile`: a media type and the host's reference) and `truncated`; a completed `ToolResult` carries the `files`. `artifactsCapabilityManifest({ save, read })` adds the built-in `read_artifact` (`READ_ARTIFACT_TOOL`, `READ_ARTIFACT_MAX_BYTES`), and `codeToolsOf` leaves it alone. `SessionView` gains `definitionHash`, the definition the session was opened from. Transcript edits are split at 48 KiB, down from 256 KiB, so each `transcript.updated` event stays under 64 KiB when no entry is larger.
63
+ - `@nylorun/harness`: a tool result's files go to the model after its output, as media parts; an outcome marked `truncated` is not checked against the tool's output schema.
64
+ - `@nylorun/runtime`: an agent's remote MCP or HTTP tool result past 32 KiB is stored as a file artifact of the session, and the model gets `{ truncated: true, artifactId, size, preview }` (the first 4 KiB and the last 1 KiB). Image, audio and blob resource parts become artifacts too, an image also shown to a model that reads images (a note for one that does not); each part of a mixed result is shaped alone, and a `resource_link` stays a link. One step's results share a 256 KiB budget, so many parallel results never make an event near S2's 1 MiB record: past it, a result is a stub naming its artifact. When an artifact cannot be stored, the preview stays and `dropped` says why. An MCP answer past 8 MiB is `mcp.too-large`. `read_artifact { artifactId, offset?, length? }` reads 32 KiB of the session's own artifact a call, with or without a sandbox: a session gets it for each agent with an MCP server or an HTTP tool. The session view names its `definitionHash`.
65
+ - `@nylorun/studio`: a session is shown as running an older manifest only when the definition it was opened from is not the registered one, not because the Runtime pinned its own tools (a sandbox's, `save_artifact`, `read_artifact`) beside it.
66
+
67
+ - b8d10cb: **Per-tool MCP settings (manifest v6) and deferred tools** (R2b C9, C10). MIGRATION.md (protocol 10, "Per-tool settings and manifest v6" and "Deferred tools") has the details.
68
+
69
+ - `@nylorun/core`: an MCP server takes `tools` (`McpToolSettings` by the server's own tool name, `"*"` for the rest: `enabled`, `approval`, `deferred`) and `deferred`, in manifest v6. `mcp()` and `Agent.mcp()` accept them, and the builder writes v6 only for a manifest that uses them, so other manifests keep their hashes; `AgentManifestSchema` accepts v5 unchanged and refuses the fields in v5. `mcpToolSettings` resolves a tool's settings, `manifestVersionFor` says which version a definition needs. `isVariantOf` lets a turn variant disable an MCP tool or require its approval, and nothing else. `TOOLS_CAPABILITY_ID`, `TOOL_SEARCH_TOOL`, `TOOL_CALL_TOOL`, `deferredToolsTools` and `deferredToolsInstructions` describe `tool_search` and `tool_call`. A session tool may carry instructions, read with its capability's. `mcp.discovered` gains `deferred`, `disabled` and `unknownTools` per server.
70
+ - `@nylorun/harness`: a session tool marked `deferred` stays out of the model's tool list; `tool_call` runs it as its own call, after checking the arguments against its `inputSchema`, and asks for approval when it needs it.
71
+ - `@nylorun/runtime`: discovery leaves out the tools a server's settings disable and names keys that match no tool. A session of an agent with a remote MCP server pins an empty `nylorun.tools` capability; when the agent's MCP tools pass a tenth of the model's context window (or settings say so), they are deferred for the session's life, and the model gets `tool_search` (BM25 over the deferred tools' names and descriptions, served by core) and `tool_call`, with a note naming each server and its instructions. Approval resolves per tool, and a turn variant's tightening applies to its turn. The gate's `mcp/connect` answers the server's instructions.
72
+
73
+ ### Patch Changes
74
+
75
+ - fed5e58: **Docs: reaching a person's accounts** (R2b C5). The READMEs describe MCP credentials as protocol 10 has them (a `bearer` token or a `headers` map per URL, with `via` and an identity header for an MCP gateway), and point to "MCP servers and HTTP tools" in DEPLOYMENT.md: the operator's flow from credential to preview, tool settings, deferral, stored results and the error codes a model sees, with gateway recipes for Arcade, ToolHive, Obot and Nylorun Cloud and the proxy pattern for gateways that mint per person. `HttpToolTarget.credential`'s doc (`@nylorun/core`) no longer names the removed credential resolver.
76
+ - Pin core to the tested release.
77
+ - Pin harness to the tested release.
78
+ - Updated dependencies [50e2f7e]
79
+ - Updated dependencies [e0e39ff]
80
+ - Updated dependencies [fed5e58]
81
+ - Updated dependencies [18f9a2f]
82
+ - Updated dependencies [da93711]
83
+ - Updated dependencies [90a817d]
84
+ - Updated dependencies [b8d10cb]
85
+ - Updated dependencies
86
+ - @nylorun/core@0.17.0-beta
87
+ - @nylorun/harness@0.24.0-beta
88
+
3
89
  ## 0.20.0-beta
4
90
 
5
91
  ### Major Changes
package/README.md CHANGED
@@ -42,8 +42,10 @@ whose key the admin key derives (the only derived key). Management keys come fro
42
42
  rotates and deletes the Tenant's application keys (`PUT /v1/tenant/keys/{keyId}`); a rotated
43
43
  or deleted key stops authenticating at once. A database written by a Runtime that kept several Tenants in one
44
44
  database (`tenant_<id>` schemas), or by a pre-release build of one Tenant per database
45
- (`schema_version` tables), is refused: this release starts fresh on a new database. Restate runs one advance of a session at a time and holds the Tenant's sweep
46
- timer (Durable Session Execution); every session's events are relayed from the record to
45
+ (`schema_version` tables), is refused: this release starts fresh on a new database. Restate runs one advance of a session at a time, delivers its wakes and holds
46
+ its timers and the Tenant's sweep (Durable Session Execution), and journals no effect:
47
+ checkpoints, effects, events and the wake outbox are the Session Store's, and a wake is
48
+ written to the outbox in the transaction that causes it, so a commit never loses it; every session's events are relayed from the record to
47
49
  its own S2 stream, which history and SSE read (Durable Streams). One image runs every **service**,
48
50
  and `--service` picks what a process runs: `core` serves the Runtime API, the
49
51
  Management API and SSE and runs the stream relay, `loop` runs advances (the Worker), and
@@ -86,11 +88,13 @@ is refused with `409 run_stale`. A `gates` process needs only
86
88
  `NYLORUN_DATABASE_URL`, `NYLORUN_GATES_TOKEN`, its listener
87
89
  (`NYLORUN_GATES_LISTEN_HOST`, `NYLORUN_GATES_LISTEN_PORT`, default 4100, and
88
90
  `NYLORUN_GATES_ALLOWED_HOSTS`) and the Host's `tenant/` directory, which it
89
- never writes; it serves the database's one Tenant. `NYLORUN_RESOLVER_URL` and
90
- `NYLORUN_RESOLVER_TOKEN` (both or neither, gates only) name the operator's
91
- credential resolver, which the gate asks for a person's MCP credential when the
92
- session's vaults hold none ([DEPLOYMENT.md](../DEPLOYMENT.md#credentials)); an
93
- embedding or `startEphemeralRuntime` takes `resolver: { url, token }` instead. With `egress`
91
+ never writes; it serves the database's one Tenant. A session's MCP servers and
92
+ HTTP tools get their credentials from its attached vaults only: a `bearer` token
93
+ or a `headers` map per URL, sent to an MCP gateway instead when it has `via`,
94
+ with the session owner in its identity header
95
+ ([DEPLOYMENT.md](../DEPLOYMENT.md#mcp-servers-and-http-tools)); the credential resolver is gone
96
+ (protocol 10), and a process that still sets a `NYLORUN_RESOLVER_*` variable logs
97
+ `resolver_removed` and ignores it. With `egress`
94
98
  (`--service gates,keys,egress`, for pod sandboxes) the same process runs
95
99
  egress-gate on `NYLORUN_EGRESS_LISTEN_HOST`:`NYLORUN_EGRESS_LISTEN_PORT`
96
100
  (default `0.0.0.0:4200`): a CONNECT proxy that admits a pod's egress token and
@@ -142,8 +146,6 @@ The Host root is `NYLORUN_HOME` or `~/.nylorun` (for a local Tenant,
142
146
  | `/v1/*` Runtime API routes (all but `/v1/tenant/*`) | application key or trusted issuer's token | Require `Nylorun-Protocol`; nothing names the Tenant. A management key is `403 key_role_mismatch`, except on `/v1/me` and the public `GET /v1/access/jwks` |
143
147
  | `/v1/tenant/*` Management API routes | management key | Require `Nylorun-Protocol`. An application key, alone or acting for a subject, is `403 key_role_mismatch`; a management key with `Nylorun-Subject` or `Nylorun-Scopes` is `403 subject_invalid` |
144
148
  | `PUT /v1/tenant/keys/{keyId}` | management key | Creates application key `keyId` or rotates it, and returns it once; `GET /v1/tenant/keys` lists every key (id, role, when issued, never the keys) and `DELETE` deletes one. `studio`, `bootstrap` and management keys are refused |
145
- | `POST /v1/tenant/vaults/{vaultId}/oauth/start` | management key | MCP OAuth connect into an installation vault (F9 C2): `{url, server, clientId?}` → `{authorizeUrl, expiresAt}`; the gateway's keys module does discovery, registration and the exchange. `oauth_client_required` without DCR or a `clientId` |
146
- | `GET /v1/oauth/callback` | the `state` itself | Where the authorization server sends the browser back: no credential, no `Nylorun-Protocol`; finishes the connect once (`oauth_state_invalid` after) and answers a small HTML page. Its base is `NYLORUN_PUBLIC_URL`, else the start request's origin |
147
149
  | `GET /v1/artifact-links/{token}` | the link itself | A capability link to one artifact version (protocol 6): no credential, no `Nylorun-Protocol`, Range supported; a folder's link opens its zip, or one of its files |
148
150
 
149
151
  Every route checks `Host` first (`421 host_rejected`) and rejects non-JSON bodies
@@ -155,8 +157,10 @@ are refused from browsers before they are looked up. The Runtime sends no CORS h
155
157
  `OPTIONS` with `204` and `Allow` only: the operator's reverse proxy answers preflights
156
158
  ([DEPLOYMENT.md](../DEPLOYMENT.md#calling-the-runtime-from-browsers-and-apps)). Missing or
157
159
  unsupported protocol → `426` before authentication, unless the request sends neither
158
- `Nylorun-Protocol` nor `Authorization` (the Host serves protocols 4 to 9; protocol 9 makes the
159
- Runtime API an OAuth 2.1 resource server: a missing or rejected credential is `401
160
+ `Nylorun-Protocol` nor `Authorization` (the Host serves protocols 4 to 10; protocol 10 removes
161
+ the MCP OAuth connect, the vault's `oauth` credentials and the credential resolver, and adds
162
+ `headers` credentials, `via` and the identity header, manifest v6 and
163
+ `POST /v1/tenant/mcp/preview`; protocol 9 makes the Runtime API an OAuth 2.1 resource server: a missing or rejected credential is `401
160
164
  credential_required` or `credential_invalid` with a `WWW-Authenticate: Bearer` challenge, a
161
165
  token without a route's scope gets `error="insufficient_scope"`, and
162
166
  `/.well-known/oauth-protected-resource` lists the trusted issuers (RFC 9728); protocol 8 gives keys roles, moves vaults and signing keys under `/v1/tenant` and removes
@@ -239,7 +243,10 @@ Save agents with `PUT /v1/agents/{agentId}` using the application principal (`sa
239
243
  in `@nylorun/agents`). The Runtime runs the agent from its manifest and never calls your
240
244
  code during a session: a definition with a tool that would (`tool({ run })`, a flow's tool
241
245
  stage) is refused. Your services are reached as tools: HTTP tools, POSTed from the Runtime,
242
- so their URLs must be reachable from it, and remote MCP servers. Model gateway
246
+ so their URLs must be reachable from it, and remote MCP servers. The operator gives
247
+ each URL a vault credential, previews an MCP server's tools (`nylorun mcp inspect`),
248
+ and the manifest says which tools are enabled, need approval or are deferred
249
+ ([DEPLOYMENT.md](../DEPLOYMENT.md#mcp-servers-and-http-tools)). Model gateway
243
250
  and sandbox backend are Tenant configuration (vault / seed), not Host process
244
251
  env.
245
252
 
@@ -25,7 +25,32 @@
25
25
  * What a run answers arms its timers and its retry.
26
26
  *
27
27
  * Wakes, sandbox reconciles, timers and sweep arming go through the ingress as one-way
28
- * sends, so an API node can call them without ever calling `start`.
28
+ * sends, so an API node can call them without ever calling `start`. A wake a commit asked for
29
+ * comes from the Session Store's wake outbox (`Tx.wake`) with an idempotency key, so a send
30
+ * repeated after its answer was lost causes no second advance.
31
+ *
32
+ * ## What Restate owns, and what the Session Store owns
33
+ *
34
+ * Restate owns when a session runs: it delivers each wake at least once, deduped by its
35
+ * key for `dedupeRetentionMs`; runs at most one invocation per key at a time; retries an
36
+ * invocation whose attempt failed, so an advance whose Worker died runs again and takes the
37
+ * session over (§11.4); and keeps every timer: the busy re-wake, `NylorunTimer`,
38
+ * `NylorunSandbox` and the `NylorunTenant` sweep chain. The Session Store (Postgres) owns
39
+ * what happened: the checkpoint, the effect journal (`harness-api/record.ts`), the events
40
+ * (the Record), and the wake outbox that hands each committed wake to Restate. Restate
41
+ * journals no effect: an effect's intent and outcome commit with the session's events in
42
+ * one transaction, under the advance's lease, and remote harnesses and pod engines write
43
+ * them too, over the Harness API.
44
+ *
45
+ * Two Session Store mechanisms overlap Restate on purpose:
46
+ *
47
+ * - **The lease and its epoch** (§10.6). Restate's one invocation per key holds for an
48
+ * attempt, not for the code it started: an attempt that ends (abort timeout, a dropped
49
+ * connection) is retried while the previous attempt's handler may still run on its Worker,
50
+ * and a remote harness or pod engine may still hold the run. The epoch fences their writes,
51
+ * and `busy` answers the overlap.
52
+ * - **The advance deadline** (`tenant/worker.ts`). Restate's abort timeout does not stop a
53
+ * running handler, so the Worker bounds each advance itself, below `timeouts`.
29
54
  */
30
55
  import { createServer } from "node:http2";
31
56
  import * as restate from "@restatedev/restate-sdk";
@@ -11,6 +11,7 @@ export declare const Rejected: z.ZodObject<{
11
11
  code: z.ZodEnum<{
12
12
  connection_missing: "connection_missing";
13
13
  credential_invalid: "credential_invalid";
14
+ credential_rejected: "credential_rejected";
14
15
  credential_required: "credential_required";
15
16
  definition_files_missing: "definition_files_missing";
16
17
  host_rejected: "host_rejected";
@@ -20,10 +21,8 @@ export declare const Rejected: z.ZodObject<{
20
21
  issuer_unavailable: "issuer_unavailable";
21
22
  key_role_mismatch: "key_role_mismatch";
22
23
  limit_exceeded: "limit_exceeded";
24
+ mcp_preview_failed: "mcp_preview_failed";
23
25
  not_found: "not_found";
24
- oauth_client_required: "oauth_client_required";
25
- oauth_failed: "oauth_failed";
26
- oauth_state_invalid: "oauth_state_invalid";
27
26
  origin_rejected: "origin_rejected";
28
27
  placement_refused: "placement_refused";
29
28
  protocol_unsupported: "protocol_unsupported";
@@ -522,6 +521,7 @@ export declare const SessionView: z.ZodObject<{
522
521
  agentId: z.ZodString;
523
522
  ownerUserId: z.ZodString;
524
523
  manifestHash: z.ZodString;
524
+ definitionHash: z.ZodOptional<z.ZodString>;
525
525
  implementationVersion: z.ZodString;
526
526
  status: z.ZodEnum<{
527
527
  cancelled: "cancelled";
@@ -1594,7 +1594,14 @@ export declare const SessionEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
1594
1594
  }>;
1595
1595
  message: z.ZodString;
1596
1596
  tools: z.ZodNumber;
1597
+ deferred: z.ZodOptional<z.ZodNumber>;
1598
+ disabled: z.ZodOptional<z.ZodNumber>;
1599
+ unknownTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
1597
1600
  credentialIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
1601
+ renamed: z.ZodOptional<z.ZodArray<z.ZodObject<{
1602
+ serverToolName: z.ZodString;
1603
+ name: z.ZodString;
1604
+ }, z.core.$loose>>>;
1598
1605
  }, z.core.$loose>>;
1599
1606
  }, z.core.$loose>;
1600
1607
  }, z.core.$strip> | z.ZodObject<{
@@ -2119,7 +2126,14 @@ export declare const SessionEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
2119
2126
  error: z.ZodOptional<z.ZodObject<{
2120
2127
  code: z.ZodString;
2121
2128
  message: z.ZodString;
2129
+ server: z.ZodOptional<z.ZodString>;
2130
+ vault: z.ZodOptional<z.ZodEnum<{
2131
+ installation: "installation";
2132
+ user: "user";
2133
+ }>>;
2134
+ retryable: z.ZodOptional<z.ZodBoolean>;
2122
2135
  }, z.core.$loose>>;
2136
+ redacted: z.ZodOptional<z.ZodNumber>;
2123
2137
  }, z.core.$loose>;
2124
2138
  }, z.core.$strip> | z.ZodObject<{
2125
2139
  schema: z.ZodLiteral<"nylorun.event/2">;
@@ -3400,7 +3414,14 @@ export declare const SessionEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
3400
3414
  }>;
3401
3415
  message: z.ZodString;
3402
3416
  tools: z.ZodNumber;
3417
+ deferred: z.ZodOptional<z.ZodNumber>;
3418
+ disabled: z.ZodOptional<z.ZodNumber>;
3419
+ unknownTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
3403
3420
  credentialIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
3421
+ renamed: z.ZodOptional<z.ZodArray<z.ZodObject<{
3422
+ serverToolName: z.ZodString;
3423
+ name: z.ZodString;
3424
+ }, z.core.$loose>>>;
3404
3425
  }, z.core.$loose>>;
3405
3426
  }, z.core.$loose>;
3406
3427
  }, z.core.$strip> | z.ZodObject<{
@@ -3925,7 +3946,14 @@ export declare const SessionEvent: z.ZodDiscriminatedUnion<[z.ZodObject<{
3925
3946
  error: z.ZodOptional<z.ZodObject<{
3926
3947
  code: z.ZodString;
3927
3948
  message: z.ZodString;
3949
+ server: z.ZodOptional<z.ZodString>;
3950
+ vault: z.ZodOptional<z.ZodEnum<{
3951
+ installation: "installation";
3952
+ user: "user";
3953
+ }>>;
3954
+ retryable: z.ZodOptional<z.ZodBoolean>;
3928
3955
  }, z.core.$loose>>;
3956
+ redacted: z.ZodOptional<z.ZodNumber>;
3929
3957
  }, z.core.$loose>;
3930
3958
  }, z.core.$strip> | z.ZodObject<{
3931
3959
  schema: z.ZodLiteral<"nylorun.event/2">;
@@ -5209,7 +5237,14 @@ export declare const SessionItemsResponse: z.ZodObject<{
5209
5237
  }>;
5210
5238
  message: z.ZodString;
5211
5239
  tools: z.ZodNumber;
5240
+ deferred: z.ZodOptional<z.ZodNumber>;
5241
+ disabled: z.ZodOptional<z.ZodNumber>;
5242
+ unknownTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
5212
5243
  credentialIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
5244
+ renamed: z.ZodOptional<z.ZodArray<z.ZodObject<{
5245
+ serverToolName: z.ZodString;
5246
+ name: z.ZodString;
5247
+ }, z.core.$loose>>>;
5213
5248
  }, z.core.$loose>>;
5214
5249
  }, z.core.$loose>;
5215
5250
  }, z.core.$strip> | z.ZodObject<{
@@ -5734,7 +5769,14 @@ export declare const SessionItemsResponse: z.ZodObject<{
5734
5769
  error: z.ZodOptional<z.ZodObject<{
5735
5770
  code: z.ZodString;
5736
5771
  message: z.ZodString;
5772
+ server: z.ZodOptional<z.ZodString>;
5773
+ vault: z.ZodOptional<z.ZodEnum<{
5774
+ installation: "installation";
5775
+ user: "user";
5776
+ }>>;
5777
+ retryable: z.ZodOptional<z.ZodBoolean>;
5737
5778
  }, z.core.$loose>>;
5779
+ redacted: z.ZodOptional<z.ZodNumber>;
5738
5780
  }, z.core.$loose>;
5739
5781
  }, z.core.$strip> | z.ZodObject<{
5740
5782
  schema: z.ZodLiteral<"nylorun.event/2">;
@@ -7015,7 +7057,14 @@ export declare const SessionItemsResponse: z.ZodObject<{
7015
7057
  }>;
7016
7058
  message: z.ZodString;
7017
7059
  tools: z.ZodNumber;
7060
+ deferred: z.ZodOptional<z.ZodNumber>;
7061
+ disabled: z.ZodOptional<z.ZodNumber>;
7062
+ unknownTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
7018
7063
  credentialIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
7064
+ renamed: z.ZodOptional<z.ZodArray<z.ZodObject<{
7065
+ serverToolName: z.ZodString;
7066
+ name: z.ZodString;
7067
+ }, z.core.$loose>>>;
7019
7068
  }, z.core.$loose>>;
7020
7069
  }, z.core.$loose>;
7021
7070
  }, z.core.$strip> | z.ZodObject<{
@@ -7540,7 +7589,14 @@ export declare const SessionItemsResponse: z.ZodObject<{
7540
7589
  error: z.ZodOptional<z.ZodObject<{
7541
7590
  code: z.ZodString;
7542
7591
  message: z.ZodString;
7592
+ server: z.ZodOptional<z.ZodString>;
7593
+ vault: z.ZodOptional<z.ZodEnum<{
7594
+ installation: "installation";
7595
+ user: "user";
7596
+ }>>;
7597
+ retryable: z.ZodOptional<z.ZodBoolean>;
7543
7598
  }, z.core.$loose>>;
7599
+ redacted: z.ZodOptional<z.ZodNumber>;
7544
7600
  }, z.core.$loose>;
7545
7601
  }, z.core.$strip> | z.ZodObject<{
7546
7602
  schema: z.ZodLiteral<"nylorun.event/2">;
@@ -8305,28 +8361,21 @@ export declare const CreateCredentialRequest: z.ZodObject<{
8305
8361
  idempotencyKey: z.ZodString;
8306
8362
  name: z.ZodString;
8307
8363
  auth: z.ZodDiscriminatedUnion<[z.ZodObject<{
8364
+ via: z.ZodOptional<z.ZodString>;
8365
+ identity: z.ZodOptional<z.ZodObject<{
8366
+ header: z.ZodString;
8367
+ }, z.core.$strict>>;
8308
8368
  type: z.ZodLiteral<"bearer">;
8309
8369
  url: z.ZodString;
8310
8370
  token: z.ZodString;
8311
8371
  }, z.core.$strict>, z.ZodObject<{
8312
- type: z.ZodLiteral<"oauth">;
8313
- url: z.ZodString;
8314
- accessToken: z.ZodString;
8315
- expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8316
- refresh: z.ZodOptional<z.ZodObject<{
8317
- tokenEndpoint: z.ZodString;
8318
- clientId: z.ZodString;
8319
- refreshToken: z.ZodString;
8320
- tokenEndpointAuth: z.ZodDiscriminatedUnion<[z.ZodObject<{
8321
- type: z.ZodLiteral<"none">;
8322
- }, z.core.$strict>, z.ZodObject<{
8323
- type: z.ZodLiteral<"client_secret_basic">;
8324
- clientSecret: z.ZodString;
8325
- }, z.core.$strict>, z.ZodObject<{
8326
- type: z.ZodLiteral<"client_secret_post">;
8327
- clientSecret: z.ZodString;
8328
- }, z.core.$strict>], "type">;
8372
+ via: z.ZodOptional<z.ZodString>;
8373
+ identity: z.ZodOptional<z.ZodObject<{
8374
+ header: z.ZodString;
8329
8375
  }, z.core.$strict>>;
8376
+ type: z.ZodLiteral<"headers">;
8377
+ url: z.ZodString;
8378
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
8330
8379
  }, z.core.$strict>], "type">;
8331
8380
  }, z.core.$strict>;
8332
8381
  export declare const CredentialInfo: z.ZodObject<{
@@ -8335,12 +8384,16 @@ export declare const CredentialInfo: z.ZodObject<{
8335
8384
  name: z.ZodString;
8336
8385
  type: z.ZodEnum<{
8337
8386
  bearer: "bearer";
8338
- oauth: "oauth";
8387
+ headers: "headers";
8339
8388
  }>;
8340
8389
  binding: z.ZodObject<{
8341
8390
  url: z.ZodString;
8342
8391
  }, z.core.$strict>;
8343
- expiresAt: z.ZodOptional<z.ZodString>;
8392
+ headerNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
8393
+ via: z.ZodOptional<z.ZodString>;
8394
+ identity: z.ZodOptional<z.ZodObject<{
8395
+ header: z.ZodString;
8396
+ }, z.core.$strict>>;
8344
8397
  createdAt: z.ZodString;
8345
8398
  rotatedAt: z.ZodOptional<z.ZodString>;
8346
8399
  }, z.core.$strict>;
@@ -8351,12 +8404,16 @@ export declare const ListCredentialsResponse: z.ZodObject<{
8351
8404
  name: z.ZodString;
8352
8405
  type: z.ZodEnum<{
8353
8406
  bearer: "bearer";
8354
- oauth: "oauth";
8407
+ headers: "headers";
8355
8408
  }>;
8356
8409
  binding: z.ZodObject<{
8357
8410
  url: z.ZodString;
8358
8411
  }, z.core.$strict>;
8359
- expiresAt: z.ZodOptional<z.ZodString>;
8412
+ headerNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
8413
+ via: z.ZodOptional<z.ZodString>;
8414
+ identity: z.ZodOptional<z.ZodObject<{
8415
+ header: z.ZodString;
8416
+ }, z.core.$strict>>;
8360
8417
  createdAt: z.ZodString;
8361
8418
  rotatedAt: z.ZodOptional<z.ZodString>;
8362
8419
  }, z.core.$strict>>;
@@ -8365,26 +8422,60 @@ export declare const RotateCredentialRequest: z.ZodObject<{
8365
8422
  requestId: z.ZodString;
8366
8423
  idempotencyKey: z.ZodString;
8367
8424
  auth: z.ZodDiscriminatedUnion<[z.ZodObject<{
8425
+ via: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8426
+ identity: z.ZodOptional<z.ZodNullable<z.ZodObject<{
8427
+ header: z.ZodString;
8428
+ }, z.core.$strict>>>;
8368
8429
  type: z.ZodLiteral<"bearer">;
8369
8430
  token: z.ZodString;
8370
8431
  }, z.core.$strict>, z.ZodObject<{
8371
- type: z.ZodLiteral<"oauth">;
8372
- accessToken: z.ZodString;
8373
- expiresAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8432
+ via: z.ZodOptional<z.ZodNullable<z.ZodString>>;
8433
+ identity: z.ZodOptional<z.ZodNullable<z.ZodObject<{
8434
+ header: z.ZodString;
8435
+ }, z.core.$strict>>>;
8436
+ type: z.ZodLiteral<"headers">;
8437
+ headers: z.ZodRecord<z.ZodString, z.ZodString>;
8374
8438
  }, z.core.$strict>], "type">;
8375
8439
  }, z.core.$strict>;
8376
- export declare const StartOAuthRequest: z.ZodObject<{
8377
- url: z.ZodString;
8378
- server: z.ZodString;
8379
- clientId: z.ZodOptional<z.ZodString>;
8380
- }, z.core.$strict>;
8381
- export declare const StartOAuthResponse: z.ZodObject<{
8382
- authorizeUrl: z.ZodString;
8383
- expiresAt: z.ZodString;
8384
- }, z.core.$strict>;
8385
8440
  export declare const DeletedResponse: z.ZodObject<{
8386
8441
  id: z.ZodString;
8387
8442
  }, z.core.$strict>;
8443
+ export declare const McpPreviewRequest: z.ZodObject<{
8444
+ requestId: z.ZodOptional<z.ZodString>;
8445
+ url: z.ZodString;
8446
+ type: z.ZodOptional<z.ZodEnum<{
8447
+ sse: "sse";
8448
+ "streamable-http": "streamable-http";
8449
+ }>>;
8450
+ name: z.ZodOptional<z.ZodString>;
8451
+ vaultId: z.ZodOptional<z.ZodString>;
8452
+ }, z.core.$strict>;
8453
+ export declare const McpPreview: z.ZodObject<{
8454
+ name: z.ZodString;
8455
+ url: z.ZodString;
8456
+ type: z.ZodEnum<{
8457
+ sse: "sse";
8458
+ "streamable-http": "streamable-http";
8459
+ }>;
8460
+ credentialSent: z.ZodBoolean;
8461
+ serverInfo: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
8462
+ instructions: z.ZodOptional<z.ZodString>;
8463
+ tools: z.ZodArray<z.ZodObject<{
8464
+ serverToolName: z.ZodString;
8465
+ modelName: z.ZodOptional<z.ZodString>;
8466
+ description: z.ZodOptional<z.ZodString>;
8467
+ annotations: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
8468
+ schemaBytes: z.ZodNumber;
8469
+ }, z.core.$strict>>;
8470
+ renamed: z.ZodArray<z.ZodObject<{
8471
+ serverToolName: z.ZodString;
8472
+ name: z.ZodString;
8473
+ }, z.core.$strict>>;
8474
+ authRequired: z.ZodOptional<z.ZodObject<{
8475
+ resourceMetadataUrl: z.ZodOptional<z.ZodString>;
8476
+ resourceMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
8477
+ }, z.core.$strict>>;
8478
+ }, z.core.$strict>;
8388
8479
  export declare const Jwks: z.ZodObject<{
8389
8480
  keys: z.ZodArray<z.ZodObject<{
8390
8481
  kty: z.ZodLiteral<"EC">;
@@ -9506,7 +9597,14 @@ export declare const HistoryPage: z.ZodObject<{
9506
9597
  }>;
9507
9598
  message: z.ZodString;
9508
9599
  tools: z.ZodNumber;
9600
+ deferred: z.ZodOptional<z.ZodNumber>;
9601
+ disabled: z.ZodOptional<z.ZodNumber>;
9602
+ unknownTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
9509
9603
  credentialIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
9604
+ renamed: z.ZodOptional<z.ZodArray<z.ZodObject<{
9605
+ serverToolName: z.ZodString;
9606
+ name: z.ZodString;
9607
+ }, z.core.$loose>>>;
9510
9608
  }, z.core.$loose>>;
9511
9609
  }, z.core.$loose>;
9512
9610
  }, z.core.$strip> | z.ZodObject<{
@@ -10031,7 +10129,14 @@ export declare const HistoryPage: z.ZodObject<{
10031
10129
  error: z.ZodOptional<z.ZodObject<{
10032
10130
  code: z.ZodString;
10033
10131
  message: z.ZodString;
10132
+ server: z.ZodOptional<z.ZodString>;
10133
+ vault: z.ZodOptional<z.ZodEnum<{
10134
+ installation: "installation";
10135
+ user: "user";
10136
+ }>>;
10137
+ retryable: z.ZodOptional<z.ZodBoolean>;
10034
10138
  }, z.core.$loose>>;
10139
+ redacted: z.ZodOptional<z.ZodNumber>;
10035
10140
  }, z.core.$loose>;
10036
10141
  }, z.core.$strip> | z.ZodObject<{
10037
10142
  schema: z.ZodLiteral<"nylorun.event/2">;
@@ -11312,7 +11417,14 @@ export declare const HistoryPage: z.ZodObject<{
11312
11417
  }>;
11313
11418
  message: z.ZodString;
11314
11419
  tools: z.ZodNumber;
11420
+ deferred: z.ZodOptional<z.ZodNumber>;
11421
+ disabled: z.ZodOptional<z.ZodNumber>;
11422
+ unknownTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
11315
11423
  credentialIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
11424
+ renamed: z.ZodOptional<z.ZodArray<z.ZodObject<{
11425
+ serverToolName: z.ZodString;
11426
+ name: z.ZodString;
11427
+ }, z.core.$loose>>>;
11316
11428
  }, z.core.$loose>>;
11317
11429
  }, z.core.$loose>;
11318
11430
  }, z.core.$strip> | z.ZodObject<{
@@ -11837,7 +11949,14 @@ export declare const HistoryPage: z.ZodObject<{
11837
11949
  error: z.ZodOptional<z.ZodObject<{
11838
11950
  code: z.ZodString;
11839
11951
  message: z.ZodString;
11952
+ server: z.ZodOptional<z.ZodString>;
11953
+ vault: z.ZodOptional<z.ZodEnum<{
11954
+ installation: "installation";
11955
+ user: "user";
11956
+ }>>;
11957
+ retryable: z.ZodOptional<z.ZodBoolean>;
11840
11958
  }, z.core.$loose>>;
11959
+ redacted: z.ZodOptional<z.ZodNumber>;
11841
11960
  }, z.core.$loose>;
11842
11961
  }, z.core.$strip> | z.ZodObject<{
11843
11962
  schema: z.ZodLiteral<"nylorun.event/2">;
@@ -5,7 +5,7 @@
5
5
  * global registry.
6
6
  */
7
7
  import { z } from "zod";
8
- import { SessionListItemSchema, ModelCallSchema, SessionPageSchema, SessionManifestViewSchema, HistoryPageSchema, SessionUsageTotalsSchema, ModelCallsPageSchema, ModelCallExportPageSchema, SandboxPageSchema, JwksSchema, SigningKeyListSchema, SigningKeyViewSchema, RotateSigningKeysRequestSchema, RevokeSigningKeyRequestSchema, MeResponseSchema, TenantStatusSchema, ResetTenantRequestSchema, ResetTenantResponseSchema, SeedTenantConfigRequestSchema, SeedTenantConfigResponseSchema, HostModelCatalogSchema, TenantSandboxViewSchema, ModelUsageTotalsSchema, ModelBudgetsSchema, PutModelBudgetsRequestSchema, PutTenantSandboxRequestSchema, ListProvidersResponseSchema, HostModelViewSchema, PutHostModelRequestSchema, SelectHostModelRequestSchema, CreateVaultRequestSchema, VaultInfoSchema, ListVaultsResponseSchema, CreateCredentialRequestSchema, CredentialInfoSchema, ListCredentialsResponseSchema, RotateCredentialRequestSchema, StartOAuthRequestSchema, StartOAuthResponseSchema, DeletedResponseSchema, ListAgentsResponseSchema, ListPublicAgentsResponseSchema, ListSessionsResponseSchema, LiveEventSchema, PutAgentRequestSchema, PutAgentResponseSchema, PutSessionRequestSchema, SessionItemsResponseSchema, SessionViewSchema, StreamClosedFrameSchema, AcceptedResponseSchema, SandboxToolOutcomeSchema, PutSandboxRequestSchema, SandboxViewSchema, ListSandboxesResponseSchema, DeleteSandboxResponseSchema, ListSandboxEventsResponseSchema, ArtifactViewSchema, ArtifactVersionViewSchema, ListArtifactsResponseSchema, UploadArtifactResponseSchema, DefinitionFileViewSchema, DeleteArtifactResponseSchema, CreateArtifactLinkRequestSchema, ArtifactLinkSchema, PutTenantArtifactsRequestSchema, TenantArtifactsViewSchema, ArtifactTreeSchema, ArtifactDiffSchema, SessionCommandSchema, ListOperatorKeysResponseSchema, PutOperatorKeyResponseSchema, DeleteOperatorKeyResponseSchema, OperatorKeySchema, ProtocolRejectedResponseSchema, RejectedResponseSchema, EVENT_SCHEMAS, EVENT_TYPES, } from "@nylorun/core/contracts";
8
+ import { SessionListItemSchema, ModelCallSchema, SessionPageSchema, SessionManifestViewSchema, HistoryPageSchema, SessionUsageTotalsSchema, ModelCallsPageSchema, ModelCallExportPageSchema, SandboxPageSchema, JwksSchema, SigningKeyListSchema, SigningKeyViewSchema, RotateSigningKeysRequestSchema, RevokeSigningKeyRequestSchema, MeResponseSchema, TenantStatusSchema, ResetTenantRequestSchema, ResetTenantResponseSchema, SeedTenantConfigRequestSchema, SeedTenantConfigResponseSchema, HostModelCatalogSchema, TenantSandboxViewSchema, ModelUsageTotalsSchema, ModelBudgetsSchema, PutModelBudgetsRequestSchema, PutTenantSandboxRequestSchema, ListProvidersResponseSchema, HostModelViewSchema, PutHostModelRequestSchema, SelectHostModelRequestSchema, CreateVaultRequestSchema, VaultInfoSchema, ListVaultsResponseSchema, CreateCredentialRequestSchema, CredentialInfoSchema, ListCredentialsResponseSchema, RotateCredentialRequestSchema, McpPreviewRequestSchema, McpPreviewSchema, DeletedResponseSchema, ListAgentsResponseSchema, ListPublicAgentsResponseSchema, ListSessionsResponseSchema, LiveEventSchema, PutAgentRequestSchema, PutAgentResponseSchema, PutSessionRequestSchema, SessionItemsResponseSchema, SessionViewSchema, StreamClosedFrameSchema, AcceptedResponseSchema, SandboxToolOutcomeSchema, PutSandboxRequestSchema, SandboxViewSchema, ListSandboxesResponseSchema, DeleteSandboxResponseSchema, ListSandboxEventsResponseSchema, ArtifactViewSchema, ArtifactVersionViewSchema, ListArtifactsResponseSchema, UploadArtifactResponseSchema, DefinitionFileViewSchema, DeleteArtifactResponseSchema, CreateArtifactLinkRequestSchema, ArtifactLinkSchema, PutTenantArtifactsRequestSchema, TenantArtifactsViewSchema, ArtifactTreeSchema, ArtifactDiffSchema, SessionCommandSchema, ListOperatorKeysResponseSchema, PutOperatorKeyResponseSchema, DeleteOperatorKeyResponseSchema, OperatorKeySchema, ProtocolRejectedResponseSchema, RejectedResponseSchema, EVENT_SCHEMAS, EVENT_TYPES, } from "@nylorun/core/contracts";
9
9
  function named(id, schema) {
10
10
  return schema.meta({ id });
11
11
  }
@@ -76,9 +76,9 @@ export const CreateCredentialRequest = named("CreateCredentialRequest", CreateCr
76
76
  export const CredentialInfo = named("CredentialInfo", CredentialInfoSchema);
77
77
  export const ListCredentialsResponse = named("ListCredentialsResponse", ListCredentialsResponseSchema);
78
78
  export const RotateCredentialRequest = named("RotateCredentialRequest", RotateCredentialRequestSchema);
79
- export const StartOAuthRequest = named("StartOAuthRequest", StartOAuthRequestSchema);
80
- export const StartOAuthResponse = named("StartOAuthResponse", StartOAuthResponseSchema);
81
79
  export const DeletedResponse = named("DeletedResponse", DeletedResponseSchema);
80
+ export const McpPreviewRequest = named("McpPreviewRequest", McpPreviewRequestSchema);
81
+ export const McpPreview = named("McpPreview", McpPreviewSchema);
82
82
  export const Jwks = named("Jwks", JwksSchema);
83
83
  export const SigningKeyList = named("SigningKeyList", SigningKeyListSchema);
84
84
  export const SigningKeyView = named("SigningKeyView", SigningKeyViewSchema);
@@ -20,6 +20,7 @@ import { fileRoutes } from "./routes/files.js";
20
20
  import { keyRoutes } from "./routes/keys.js";
21
21
  import { tenantRoutes } from "./routes/tenant.js";
22
22
  import { vaultRoutes } from "./routes/vaults.js";
23
+ import { mcpRoutes } from "./routes/mcp.js";
23
24
  let app;
24
25
  /** The Tenant API, built on first use. */
25
26
  export function tenantApi() {
@@ -48,6 +49,7 @@ function build() {
48
49
  tenantRoutes(api);
49
50
  keyRoutes(api);
50
51
  vaultRoutes(api);
52
+ mcpRoutes(api);
51
53
  accessRoutes(api);
52
54
  meRoutes(api);
53
55
  agUiRoutes(api);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * A remote MCP server's tools before an agent names it (`POST /v1/tenant/mcp/preview`, R2b C12,
3
+ * the Management API): a management key (or Studio's key, acting as itself), as the vault routes
4
+ * take. The keys service runs it (`Keys.previewMcp`), since it sends an installation vault's
5
+ * credential; this process never reads the plaintext.
6
+ */
7
+ import type { OpenAPIHono } from "@hono/zod-openapi";
8
+ import type { TenantEnv } from "../app.js";
9
+ export declare function mcpRoutes(api: OpenAPIHono<TenantEnv>): void;