@nylorun/core 0.7.0-beta → 0.9.0-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +249 -0
- package/dist/compatibility.d.ts +42 -4
- package/dist/compatibility.js +65 -3
- package/dist/contracts.d.ts +2165 -328
- package/dist/contracts.js +1246 -100
- package/dist/define.d.ts +13 -5
- package/dist/define.js +7 -2
- package/dist/definition/assemble.js +16 -14
- package/dist/definition/bind-tool.js +1 -0
- package/dist/definition/bound.d.ts +2 -0
- package/dist/definition/builder.d.ts +116 -16
- package/dist/definition/builder.js +330 -53
- package/dist/definition/capability.d.ts +55 -0
- package/dist/definition/capability.js +104 -0
- package/dist/definition/declaration.js +6 -2
- package/dist/definition/delegate.d.ts +25 -4
- package/dist/definition/delegate.js +34 -6
- package/dist/definition/flow/compile.d.ts +23 -0
- package/dist/definition/flow/compile.js +274 -0
- package/dist/definition/flow/from.d.ts +11 -0
- package/dist/definition/flow/from.js +78 -0
- package/dist/definition/flow/index.d.ts +11 -0
- package/dist/definition/flow/index.js +11 -0
- package/dist/definition/flow/paths.d.ts +60 -0
- package/dist/definition/flow/paths.js +90 -0
- package/dist/definition/flow/spec.d.ts +66 -0
- package/dist/definition/flow/spec.js +130 -0
- package/dist/definition/flow/types.d.ts +157 -0
- package/dist/definition/flow/types.js +1 -0
- package/dist/definition/from.js +5 -1
- package/dist/definition/helpers.d.ts +1 -16
- package/dist/definition/helpers.js +1 -30
- package/dist/definition/mcp.d.ts +37 -0
- package/dist/definition/mcp.js +81 -0
- package/dist/definition/model-failure.d.ts +4 -0
- package/dist/definition/model-failure.js +22 -0
- package/dist/definition/sandbox-capability.d.ts +12 -0
- package/dist/definition/sandbox-capability.js +33 -0
- package/dist/definition/schema.js +3 -0
- package/dist/definition/workflow/build.d.ts +3 -13
- package/dist/definition/workflow/build.js +3 -25
- package/dist/definition/workflow/chain.js +0 -1
- package/dist/definition/workflow/loop.js +2 -4
- package/dist/definition/workflow/map.js +0 -1
- package/dist/definition/workflow/parallel.js +0 -1
- package/dist/definition/workflow/runnable.d.ts +13 -5
- package/dist/definition/workflow/runnable.js +11 -41
- package/dist/definition/workflow/switch.js +0 -2
- package/dist/errors.d.ts +3 -1
- package/dist/types/manifest.d.ts +4 -2
- package/dist/types/middleware.d.ts +1 -3
- package/dist/types/model.d.ts +32 -1
- package/dist/types/observe.d.ts +7 -1
- package/dist/types/tool.d.ts +6 -0
- package/dist/types/transcript.d.ts +14 -1
- package/dist/types/workflow.d.ts +72 -3
- package/dist/utils/deprecate.d.ts +3 -0
- package/dist/utils/deprecate.js +25 -0
- package/dist/utils/sandbox.d.ts +0 -4
- package/dist/utils/sandbox.js +0 -16
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,254 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.9.0-beta
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- c121144: **Definitions no longer declare a sandbox.** `.sandbox()` on ReAct and flow agents, and the `sandbox`, `SandboxError`, `SandboxOptions` and `SandboxCapability` exports, are removed. Open the session with one instead, `createSession({ sandbox: { … } })`, or set the Tenant's default; see `MIGRATION.md`.
|
|
8
|
+
|
|
9
|
+
- **Build and registration.** A capability that still carries `sandbox` fails the build (`sandbox.in-definition`), and `PUT /v1/agents/:id` refuses such a definition with a `400` that names it. Definitions stored before this release keep their sandbox.
|
|
10
|
+
- **Trees.** `sandbox.mismatch` and `workflow.sandbox-mismatch` are gone, with the workflow manifest's derived `sandbox`: a tree shares the sandbox its session was opened with.
|
|
11
|
+
- **Executors.** The action claim reports whether the session has a sandbox (`ActionClaim.sandbox`), and `ctx.sandbox` follows it.
|
|
12
|
+
|
|
13
|
+
- 9546ac7: **Postgres is the record of every session event; S2 delivers it.** Durable Streams v1.
|
|
14
|
+
|
|
15
|
+
- **The record.** Each event is written to `nylorun_streams.session_events` in the transaction that causes it, with the session's log head. The per-Tenant outbox, its relay, its drain in the Tenant sweep and `StreamGapError` are gone: losing S2's data, the relay or its replication slot now costs delay, never events.
|
|
16
|
+
- **The stream relay.** With S2, every `api` or `all` Runtime process runs the relay; its Postgres replication slot (`nylorun_stream_relay`) lets exactly one be active. It appends with `matchSeq`, acknowledges the slot only after S2 has the events, refills gaps from the record, and reconciles the record with S2 after a new or lost slot. Without S2 (a local development Host), each Tenant relays its own commits.
|
|
17
|
+
- **Postgres needs logical replication.** The Runtime refuses to start an `api` or `all` process with S2 unless `wal_level = logical` and its role may replicate; the error names the setting. The local stack is configured for it. See `DEPLOYMENT.md`.
|
|
18
|
+
- **No incarnations.** A session's stream is `sessions/<id>`. A sessions reset moves the Tenant to a new **basin generation**: the old basin gets a `sessions.reset` signal, every process moves its readers, and the old basin is deleted after a grace period. Tenant deletion deletes every generation's basin and the Tenant's record rows.
|
|
19
|
+
- **Status.** Tenant status `streams` reports `generation` and the Tenant's `relay` instead of the outbox; the Host aggregate reports the process's `relay` (with its slot lag in bytes) instead of `outboxDepth` and `relayLagMs`.
|
|
20
|
+
- **Session history does not survive the upgrade.** Installs are in beta, so Tenant schema migration 8 is a fresh start for session data: a Tenant with sessions loses them, with their commands, checkpoints, effects, Actions and links, as a sessions reset does, and moves to basin generation 1; its settings, agents, Action endpoints, keys, policy and vaults stay. Clients holding cursors start again.
|
|
21
|
+
|
|
22
|
+
- 9546ac7: **Protocol 4: every session event is typed, on the `nylorun.event/2` envelope.**
|
|
23
|
+
|
|
24
|
+
- **The catalog.** `EVENT_CATALOG` in `@nylorun/core/contracts` lists every event type the Runtime writes, with its payload schema, its schema version and its source. `SessionEventSchema` is their union, discriminated on `type`; `parseSessionEvent` types a known event and returns an unknown one as the bare envelope.
|
|
25
|
+
- **The envelope.** Events carry `schema`, `seq`, `epoch`, `runId`, `incarnation`, `schemaVersion`, `source`, `evidence`, `visibility`, `retention` and an optional `trace`. `createdAt` is renamed `time`. The envelope is no longer strict, so later fields never break a client.
|
|
26
|
+
- **Validated writes.** `Tx.event` is typed by the catalog, and both Session Stores check each event against it before it commits (`InvalidEventError`). Workflow `action.pending` payloads may carry `path` and `key`.
|
|
27
|
+
- **OpenAPI.** Each event type is a component (`MessageAssistantEvent`, …), `SessionEvent` is their union, and the session SSE and history responses refer to them.
|
|
28
|
+
- **Clients.** `@nylorun/agents` reads events with `parseSessionEvent`, so a newer Runtime's event types reach your code instead of failing the stream. Studio reads `time`.
|
|
29
|
+
|
|
30
|
+
See `MIGRATION.md`.
|
|
31
|
+
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- c7614a4: **A2A: serve agents to other agents (v1, gateway mode).** The Runtime answers [A2A](https://a2a-protocol.org) 1.0 over JSON-RPC for the Tenant's agents (optional Host feature `a2a-endpoint`), and the app server publishes them with `createA2aHandler`.
|
|
35
|
+
|
|
36
|
+
- **Runtime.** `POST /v1/a2a/agents/:agent` acts for a subject with `sessions:own`. It serves `SendMessage` (blocking up to 5 minutes, or `returnImmediately`), `GetTask` and `CancelTask`. A context is one session per subject, agent and `contextId`, and a task is one turn. A question pauses the task as `TASK_STATE_INPUT_REQUIRED` until the caller replies on the same task. The `messageId` is the idempotency key. `ListTasks`, streaming, push notifications and the extended card answer with their A2A errors, and approvals cannot be answered over A2A yet. `GET /v1/a2a/agents/:agent/card` returns the card built from the manifest, without interfaces. `observeSession` lets in-process readers join a session's shared event feed.
|
|
37
|
+
- **Agents SDK.** `@nylorun/agents/a2a`: `createA2aHandler({ agents, subject, publicUrl, card })` forwards each partner's JSON-RPC request to the Runtime as that partner's subject, and serves the Agent Card with its own URL, provider and security schemes. It loads no A2A package. `Transport.forward` returns the Runtime's raw response.
|
|
38
|
+
|
|
39
|
+
- 679c488: **Action endpoints: the Runtime delivers Actions (Host feature `action-endpoints`).** For an agent with a registered endpoint, each tool call, hook and workflow `fn`, `verify` or tool node is POSTed to the endpoint and the answer settles it. Agents without one keep their executors.
|
|
40
|
+
|
|
41
|
+
- **The request.** `{ type: "action", action, sandbox }`, with a delivery token in `Nylorun-Signature` (for this Tenant, URL, Action, generation and body) and the Action id as `Idempotency-Key`. Deliveries of one Action never overlap, and at most `maxConcurrent` are in flight per endpoint.
|
|
42
|
+
- **The answer.**
|
|
43
|
+
- `200` with `Nylorun-Outcome: 1` is the outcome. A plain `200` is a tool's output, or what an `fn` or `verify` returned; the tool's output schema still applies.
|
|
44
|
+
- `202` means the result comes later.
|
|
45
|
+
- `429` and `503` (honouring `Retry-After`), a version mismatch (`409`) and anything that never reached the endpoint are retried, backing off from 250 ms to 30 s. The failure is reported as `action.delivery_failed` at most every 10 s.
|
|
46
|
+
- Any other `4xx`, or a `3xx` (redirects are not followed), fails the Action with `endpoint.rejected`.
|
|
47
|
+
- No answer after sending (timeout, reset, `5xx`) loses it: a tool becomes `uncertain`; a hook, `fn` or `verify` is delivered again. A delivery whose deadline passes (a Worker died) is lost the same way, by the Tenant sweep.
|
|
48
|
+
- **Cancel.** A cancelled turn aborts the request at once. The code may have run, so the Action becomes `uncertain`, as a claimed one does.
|
|
49
|
+
- **Events and health.** `action.delivered` and `action.delivery_failed` are new events. Endpoint health records successes and failures.
|
|
50
|
+
- **Ping.** `POST /v1/endpoints/:agentId/ping` sends a signed ping and records what the endpoint serves. It answers `502` when the endpoint doesn't answer.
|
|
51
|
+
- **Host settings.**
|
|
52
|
+
- `NYLORUN_ENDPOINT_LOOPBACK=docker-host`: in the local stack, `localhost` means the Docker host.
|
|
53
|
+
- `NYLORUN_ENDPOINT_PRIVATE` (`allow`/`refuse`): checked on the address actually connected to.
|
|
54
|
+
- `NYLORUN_ENDPOINT_HTTP` (`allow`/`refuse`).
|
|
55
|
+
- **Executors unchanged.** Executor results and deliveries record outcomes through one function, so the two paths behave the same.
|
|
56
|
+
|
|
57
|
+
- c85cd9e: **Action endpoints: register them (nothing is delivered yet).** An application registers, for each agent, the URL that will run its Actions. The Runtime stores the registration and its health; deliveries follow in a later release.
|
|
58
|
+
|
|
59
|
+
- **Routes (application key only).**
|
|
60
|
+
- `PUT /v1/endpoints` registers or updates up to 64 endpoints: `agentId`, `url` (http or https, no credentials or fragment), `implementationVersion`, optional `manifestHash`, `timeoutMs` (default 60 000, at most 840 000) and `maxConcurrent` (default 16).
|
|
61
|
+
- `GET /v1/endpoints` lists them with their health: last delivery, last success, last error, consecutive failures, and what the last ping reported.
|
|
62
|
+
- `DELETE /v1/endpoints/:agentId` removes one.
|
|
63
|
+
- Subjects, subject tokens and executors are refused.
|
|
64
|
+
- **One path per agent.** Registering an endpoint removes the agent's executor and ends its streams. `PUT /v1/executors` for an agent with an endpoint is `409`, naming the endpoint to remove first.
|
|
65
|
+
- **Health.** Registering the same URL again keeps an endpoint's health; a new URL starts with none.
|
|
66
|
+
- **Store.** Postgres migration 5 adds the `endpoints` table and a `deadline_at` column on Actions.
|
|
67
|
+
- **Core.** Adds `DeleteEndpointResponseSchema`. The endpoint response schemas are strict.
|
|
68
|
+
|
|
69
|
+
- 4282d5f: **Breaking: executors are removed; protocol 3.** The Runtime delivers every Action (tool, hook, `fn`, `verify`) to the Action endpoint an agent registers. It no longer offers Actions for executors to claim. See `MIGRATION.md`, "Action endpoints replace executors".
|
|
70
|
+
|
|
71
|
+
- **Core.** `PROTOCOL_VERSION` is 3 and a Host serves only protocol 3. `action-endpoints` is a protocol feature instead of an optional Host feature. Removed:
|
|
72
|
+
|
|
73
|
+
- the executor, claim and Action-list schemas;
|
|
74
|
+
- `action_result` from `SessionCommandSchema`;
|
|
75
|
+
- the `claimed` Action status, `claimId` and `leaseExpiresAt`.
|
|
76
|
+
|
|
77
|
+
New: `ActionResultReceiptSchema`, the receipt of `POST /v1/actions/:id/result`, which is `AcceptedResponse` without `requestId`.
|
|
78
|
+
|
|
79
|
+
- **Runtime.** Removed:
|
|
80
|
+
|
|
81
|
+
- `PUT`/`GET /v1/executors`, `DELETE /v1/executors/:agentId`, `GET /v1/executors/connect`;
|
|
82
|
+
- `GET /v1/actions`, `POST /v1/actions/:id/claim`, and the executor form of `POST /v1/actions/:id/heartbeat`;
|
|
83
|
+
- the `tenant/work` stream;
|
|
84
|
+
- claim expiry;
|
|
85
|
+
- executor credentials.
|
|
86
|
+
|
|
87
|
+
`POST /v1/actions/:id/sandbox/:tool` takes the delivery token only. Tenant summaries report `inFlightDeliveries` instead of `connectedExecutors`. Tenant status lists each agent's endpoint and has an `endpoints` check instead of `executors`.
|
|
88
|
+
|
|
89
|
+
Postgres migration 6 drops the `executors` table. Actions an executor had claimed are handled like lost deliveries: a tool becomes `uncertain`, and a hook, `fn` or `verify` is delivered again.
|
|
90
|
+
|
|
91
|
+
- **Agents.** Removed: `connectAgents`, the `@nylorun/agents/executor` subpath, derived executor keys and `NYLORUN_EXECUTOR_KEY`. Serve agents with `createActionHandler` and call `register({ url })`.
|
|
92
|
+
- **CLI.** Executor keys are gone from Project credentials. `nylo tenant endpoints` shows each endpoint and its health.
|
|
93
|
+
|
|
94
|
+
- 82d95ef: **Action endpoints: background tools, CLI and Studio.**
|
|
95
|
+
|
|
96
|
+
- **Background tools (core, agents).** `tool({ …, background: true })` marks a tool that runs longer than an endpoint's timeout. The option is code-only and never serialized into the manifest. `createActionHandler` answers its delivery at once with `202`, runs the tool, heartbeats on the deadline the Runtime returns (each time with the newest delivery token), and posts the outcome. A heartbeat answered `409` (cancelled, lost or sent again) aborts the tool's `ctx.signal`, and nothing is posted. The new `waitUntil` option hands the background work to platforms that end a request's work with its response.
|
|
97
|
+
- **CLI.** `nylo tenant endpoints [--json]` lists each agent's Action endpoint and how it is doing, and `nylo tenant endpoints ping <agent>` pings one through the Runtime.
|
|
98
|
+
- **Studio.** Shows `action.delivered` ("Action delivered") and `action.delivery_failed` ("Delivery failed", with the endpoint's error and when it retries).
|
|
99
|
+
|
|
100
|
+
- f48f12f: **Action endpoints: contracts (groundwork, not served yet).** `@nylorun/core` adds the wire shapes for Actions the Runtime will deliver over HTTP to a URL the application registers, in place of executors. No Runtime serves them yet, and the Host does not advertise a feature for them.
|
|
101
|
+
|
|
102
|
+
- **Contracts.** `EndpointRegistrationSchema`, `PutEndpointsRequestSchema`, `EndpointSchema` with `EndpointHealthSchema`, `ListEndpointsResponseSchema`, `ActionDeliverySchema` (an Action or a ping), `EndpointPingResponseSchema`, `DeliveryHeartbeatResponseSchema`, and the `action.delivered` and `action.delivery_failed` payload schemas. `Action.status` gains `delivering`, and Actions gain an optional `deadlineAt`.
|
|
103
|
+
- **Constants.** `DELIVERY_TOKEN_TYPE` (`nylorun-delivery+jwt`), `DELIVERY_TOKEN_MAX_TTL_SECONDS` (900, the subject-token maximum), `ENDPOINT_TIMEOUT_DEFAULT_MS` (60 000), `ENDPOINT_TIMEOUT_MAX_MS` (840 000), `ENDPOINT_MAX_CONCURRENT_DEFAULT` (16), and in `@nylorun/core/compatibility` the headers `SIGNATURE_HEADER` (`Nylorun-Signature`) and `OUTCOME_HEADER` (`Nylorun-Outcome`).
|
|
104
|
+
|
|
105
|
+
- 50d0fb5: **AG-UI in the Runtime.** The Runtime serves AG-UI itself at `/v1/ag-ui/agents/:agent` (optional Host feature `ag-ui-endpoint`), and pages reach it directly with a subject token. `@nylorun/agents` no longer contains or depends on any AG-UI package.
|
|
106
|
+
|
|
107
|
+
- **Runtime.** `POST /v1/ag-ui/agents/:agent` runs (a `RunAgentInput` in, server-sent AG-UI events out); `GET …/threads/:thread/messages`, `GET …/threads/:thread/events` (reattach) and `POST …/threads/:thread/cancel`. For a person named by a subject token (limited to the role's agents) or by subject headers; an application key alone is `400`. A thread's session (`sessionIdFor`, unchanged, so existing threads keep their sessions) is created on its first run with `forwardedProps.nylorun.session` (`vaultIds`, `credentialSelections`, and `info` from app servers only) and never changed afterwards. Limits and a busy session are streamed as `RUN_ERROR`. A stream opened with a token ends at the token's expiry or revocation with `CUSTOM nylorun.stream_closed`. The translation moves here from `@nylorun/agents`, and `@ag-ui/core` becomes a Runtime dependency.
|
|
108
|
+
- **Agents SDK.** `createAgUiHandler` keeps its options and routes and forwards each request to the Runtime acting for the signed-in person; it now needs a Runtime with `ag-ui-endpoint` (`502 runtime_feature_missing` otherwise). `session()` options apply when a thread's session is created; whatever the browser sends in `forwardedProps.nylorun` is replaced. `@ag-ui/core` is no longer a dependency. `@nylorun/agents/browser` adds `agUi(agentId)`, a `{ url, fetch }` for `HttpAgent` that adds the key and a current token and reattaches a run the Runtime ended at token expiry, so the agent sees one run, and `agUiHistory()`. The transport gains `forward()`, which returns the Runtime's response as it is.
|
|
109
|
+
|
|
110
|
+
- 50d0fb5: **Browser access: web pages and apps call the Runtime with a publishable key.** A page ships a publishable key and gets subject tokens from its app server; the Runtime answers it directly, with CORS (optional Host feature `browser-access`).
|
|
111
|
+
|
|
112
|
+
- **Publishable keys.** `nr_pub_<tenantId>_…`, sent in `Nylorun-Key`, name the Tenant and one app, with an origin allowlist (exact origins, or `http://localhost:*` and `http://127.0.0.1:*` for development; none for native apps). `GET`/`POST /v1/access/publishable-keys`, `PUT`/`DELETE …/:id`. A key alone grants the policy's `anon` role, at most the public agent list, and reaches no session or vault. Postgres migration 4.
|
|
113
|
+
- **Host.** With browser access on, requests with an `Origin` reach Tenant routes; `/health`, `/ready` and admin routes still refuse them. Preflights for browser routes (agents, sessions, vaults, AG-UI, JWKS) are answered from the route alone and grant no credentials; the actual request must carry a publishable key whose allowlist names the origin, and only then do responses (JSON, errors, `401`, `429`, event streams) carry CORS headers. A disallowed origin or unknown key gets the opaque `404`. Tenant and executor keys sent with an `Origin` are refused before they are looked up. `Nylorun-Tenant` may be left out when `Nylorun-Key` names the Tenant; both must agree when both are sent. Browser access is on in the stack (`NYLORUN_BROWSER_ACCESS=off` turns it off) and off for a Host started from `host.json` unless `browserAccess` is true.
|
|
114
|
+
- **JWKS.** `GET /v1/access/jwks` is readable by any caller that reaches the Tenant.
|
|
115
|
+
- **Agents SDK.** `@nylorun/agents/browser`: `createBrowserClient({ url, publishableKey, token })` keeps subject tokens in memory, refreshes them a minute before expiry or after `401 token_expired`, one fetch at a time, and creates sessions and vaults owned by the token's subject; it loads no Node module. `createTokenEndpoint()` is the app server's token route. `client.access.publishableKeys` manages keys. The transport accepts a `token` source and a `publishableKey`, and event streams the Runtime ends at token expiry reconnect at once. The Tenant API client classes move to a module with no Node imports; `@nylorun/agents` and `/client` export the same names.
|
|
116
|
+
- **CLI.** `nylo access keys list|create|set-origins|revoke`.
|
|
117
|
+
|
|
118
|
+
- 6ab4c59: **Long sessions on any model: compaction.** A session whose history outgrows the model's context window keeps going, on a 16k local model as on a 1M hosted one.
|
|
119
|
+
|
|
120
|
+
- **Compaction.**
|
|
121
|
+
- **When.** Before each model call the engine estimates the prompt: the last reported usage, plus about four characters per token for what came after. If the estimate would not leave room for the reply, the engine first compacts: it asks the model to summarize the older history, then keeps about the newest 20,000 tokens (at most 30% of the window) verbatim.
|
|
122
|
+
- **What it keeps.** The cut never separates a tool call from its result. The current turn's request is always kept. A later compaction merges with the earlier summary.
|
|
123
|
+
- **Overflow.** If a provider still reports a context overflow, the engine compacts once and asks again.
|
|
124
|
+
- **Storage.** The summary is a `compaction` transcript entry that replaces the older entries in the session state; the event log keeps the full history. The summary call is a journaled model effect, so replays are deterministic.
|
|
125
|
+
- **New event.** `context.compacted` (`trigger`, `tokensBefore`, `tokensAfter`).
|
|
126
|
+
- **Custom endpoints.**
|
|
127
|
+
- **Settings.** Model Settings take `settings: { contextWindow, maxTokens, reasoning, compat }` for a custom OpenAI-compatible provider (vLLM, SGLang, llama.cpp, Ollama, LM Studio). `compat` is passed to pi-ai: `thinkingFormat`, `thinkingTokenBudgetField`, `chatTemplateKwargs` and the rest.
|
|
128
|
+
- **Defaults.** Without settings, a custom endpoint is assumed to have a 32k window and an 8k output limit. They used to be 128k and 16k.
|
|
129
|
+
- **Where to set them.** `nylo configure` asks for the window and output limit. Studio's Model Settings shows all four fields.
|
|
130
|
+
- **Storage.**
|
|
131
|
+
- Model effects no longer journal the model request next to the call, so each call's prompt is stored once.
|
|
132
|
+
- When a turn ends, its model effects are slimmed to their identity and status; the transcript holds the answers.
|
|
133
|
+
- Session storage now grows with the window, not with the square of the session's length.
|
|
134
|
+
- **Core.**
|
|
135
|
+
- `TranscriptEntry` adds `compaction` (`TranscriptCompactionEntry`).
|
|
136
|
+
- `ModelAdapterContext.compaction` marks a summary call.
|
|
137
|
+
- `CustomModelSettings` / `CustomModelSettingsSchema` describe the custom endpoint settings.
|
|
138
|
+
|
|
139
|
+
- 6ab4c59: **Model calls don't strand sessions.** A model provider failure is now a known outcome, not a lost call. The Runtime retries what can be retried, and otherwise fails the turn with `model.<code>`, so the session accepts the next message instead of sitting `uncertain` until it is cancelled.
|
|
140
|
+
|
|
141
|
+
- **Runtime.**
|
|
142
|
+
|
|
143
|
+
- **Upgrade.** The model adapter moves to pi-ai 0.99.1 and always streams.
|
|
144
|
+
- **Per-call settings.**
|
|
145
|
+
- Every call carries the session id, so OpenAI and other providers reuse the prompt cache and route to the same backend.
|
|
146
|
+
- Provider auth no longer reads the process environment.
|
|
147
|
+
- Rate limits, overloads, timeouts and transient errors are retried: 3 attempts with backoff, honouring `Retry-After`.
|
|
148
|
+
- A stream that produces nothing for 300 s is aborted and retried. `TenantConfig.modelCall` sets attempts, backoff, the idle timeout and the request timeout.
|
|
149
|
+
- **Failures.** Anything else fails the turn with one of these codes:
|
|
150
|
+
|
|
151
|
+
- `model.context_overflow`, `model.rate_limited`, `model.overloaded`, `model.timeout`, `model.transient`
|
|
152
|
+
- `model.content_policy`, `model.auth` (whose message says where to fix the credential)
|
|
153
|
+
- `model.invalid_request`, `model.invalid_output`
|
|
154
|
+
|
|
155
|
+
Only a call whose outcome was lost, such as a Worker dying mid-call, is still `uncertain`.
|
|
156
|
+
|
|
157
|
+
- **Structured output.** A structured final answer is repaired (control characters, a Markdown code fence) before it is parsed.
|
|
158
|
+
- **Model history.** Replayed history keeps the model that produced each message, so a model switch no longer sends one model's signatures or tool-call ids to another. Reasoning from OpenAI-compatible servers (`reasoning_content`, `reasoning`) is sent back only within the turn that produced it.
|
|
159
|
+
|
|
160
|
+
- **Events.**
|
|
161
|
+
- `message.assistant` adds `model` (`provider`, `model`), `finishReason` and `usage`.
|
|
162
|
+
- A new `model.failed` transcript event (`code`, `message`, `retryable`) is written instead of `message.assistant` when a call fails.
|
|
163
|
+
- **Core and harness.**
|
|
164
|
+
- New types and helpers: `ModelFailureOutcome`, `ModelFailureCode`, `MODEL_FAILURE_CODES`, `isModelFailureOutcome`, `ModelProducer`.
|
|
165
|
+
- `PromptItem` assistant messages may carry `producer`.
|
|
166
|
+
- `ModelUsage` adds `cacheWriteTokens`.
|
|
167
|
+
- A model adapter may return a failure outcome.
|
|
168
|
+
- The durable engine version is `hosted-3`: a turn that is running when the Runtime is upgraded fails once with `execution.incompatible`, and the next message works.
|
|
169
|
+
- **CLI.**
|
|
170
|
+
- `nylo configure` passes a stable installation id to OAuth logins that need one (OpenAI "Sign in with ChatGPT"), stored as `cli-installation-id` in the Host root.
|
|
171
|
+
- A custom OpenAI-compatible provider now prompts for its API key instead of failing.
|
|
172
|
+
|
|
173
|
+
- 2ab8ed1: **Schemas for every Runtime answer.** `@nylorun/core/contracts` now has a Zod schema for each successful response of the Tenant and Admin APIs that lacked one, so clients can validate what they receive and the Runtime's OpenAPI document can be generated from them.
|
|
174
|
+
|
|
175
|
+
- **Agents:** `ListAgentsResponseSchema` (`AgentDefinitionViewSchema`), `ListPublicAgentsResponseSchema` (`PublicAgentSchema`) and `PutAgentResponseSchema`.
|
|
176
|
+
- **Sessions:** `ListSessionsResponseSchema` (`SessionSummarySchema`, `SESSION_STATUSES`) and `SessionViewSchema`.
|
|
177
|
+
- **Executors and actions:** `ListActionsResponseSchema`, `ActionHeartbeatResponseSchema`, `DeleteExecutorResponseSchema` and `SandboxToolOutcomeSchema`.
|
|
178
|
+
- **Tenant settings:** `ResetTenantResponseSchema`, `HostModelCatalogSchema`, `ListProvidersResponseSchema` (`HostModelProviderInfoSchema`), and `TenantSandboxViewSchema` with `EffectiveSandboxConfigSchema` (the configuration with defaults applied, sizes in MiB).
|
|
179
|
+
- **Vaults:** `VaultInfoSchema`, `CredentialInfoSchema`, `ListVaultsResponseSchema`, `ListCredentialsResponseSchema` and `DeletedResponseSchema`. `VaultInfo`, `CredentialInfo` and `HostModelProviderInfo` are now inferred from their schemas; their fields are no longer `readonly`.
|
|
180
|
+
- **Access:** `AccessPolicyResponseSchema` and `ListPublishableKeysResponseSchema`.
|
|
181
|
+
- **Admin:** `AdminTenantListSchema` and `HostShutdownResponseSchema`.
|
|
182
|
+
- **Streams:** `StreamClosedFrameSchema` (the `nylorun.closed` frame) and `AgUiRunErrorCodeSchema` (codes of an AG-UI `RUN_ERROR`, which add `session_busy` and `runtime_error`).
|
|
183
|
+
|
|
184
|
+
`ERROR_CODES` gains `request_rejected`, `invalid_request`, `subject_required` and `internal_error`, codes the Runtime already sends. `RejectedResponseSchema` now accepts every rejection the Runtime makes. An exhaustive `switch` over `ErrorCode` needs the new cases.
|
|
185
|
+
|
|
186
|
+
- c121144: **Choose a session's sandbox when you open it.** `createSession({ sandbox })` (`PutSessionRequest.sandbox`) now takes `false`, `{ session }` to share, or an inline sandbox: `image`, `network.allow` and `resources`. Omit it for the Tenant's default. The agent definition needs no `.sandbox()`: the Runtime resolves the request against the Tenant's limits, pins it on the session and adds the six sandbox tools to that session only (capability `nylorun.sandbox`). The registered definition is unchanged.
|
|
187
|
+
|
|
188
|
+
- **Tenant configuration.** `GET /v1/tenant/sandbox` adds `config`; `PUT /v1/tenant/sandbox` sets `default` (`none`, `virtual` or an inline sandbox) and `limits` (`network` ceiling, `resources` maximum, `defaultResources`, `idle`). Unset, a Tenant's default is `none` and its ceiling is the package registries and code hosts of today's `dev` preset. `SeedTenantConfigRequest.sandbox.config` seeds it.
|
|
189
|
+
- **Checks at open.** A request outside the limits is a `400` that lists every problem. An inline sandbox from a caller acting for a subject is a `403`; such callers get the Tenant default or `false`. An `image` is refused: the virtual sandbox has no images. The sandbox is fixed for the session's life: a different one on a later `PUT` is a `409`.
|
|
190
|
+
- **Trees inherit.** The agent sessions of a flow agent, the agents a session uses as tools, and sessions attached with `{ session }` use the sandbox the session was opened with, and get its tools.
|
|
191
|
+
- **Compatible.** An agent that declares `.sandbox()` keeps working as before; opening its session with a `sandbox` value is a `400` that says to remove `.sandbox()` from the agent.
|
|
192
|
+
|
|
193
|
+
- 9d52189: **Studio embedding contract.** `@nylorun/core/contracts` defines the contract between Studio and an app that embeds it in an iframe, and `@nylorun/agents/studio-embed` re-exports it for Studio's web app and embedders such as Babai Desktop.
|
|
194
|
+
|
|
195
|
+
- `StudioEmbedMessageSchema`: every `postMessage` between the two, on the envelope `{ type: "nylorun.studio", protocol, kind }`. Kinds: `ready`, `init`, `token.refresh`, `theme.changed`, `navigate`, `session`, `token.expiring`, `route.changed`, `open.external`, `open.babai`, `error`. `STUDIO_EMBED_PROTOCOLS` is `[1]`.
|
|
196
|
+
- `StudioLoginTokenRequestSchema` and `StudioLoginTokenResponseSchema` for `POST /_studio/login-tokens` (now with optional `tenant` and `subject`), and `StudioSessionRequestSchema` and `StudioSessionResponseSchema` for `POST /_studio/sessions`.
|
|
197
|
+
- `parseFrameAncestors` and `isFrameAncestor` validate `NYLORUN_STUDIO_FRAME_ANCESTORS`: exact origins only, no wildcards, keywords, scheme-only entries or paths.
|
|
198
|
+
|
|
199
|
+
- 50d0fb5: **Subject tokens: a person's own credential for the Runtime.** An app server mints a short-lived token for one signed-in person, and their app calls the Runtime directly (optional Host feature `subject-tokens`). Requests with application keys and subject headers are unchanged.
|
|
200
|
+
|
|
201
|
+
- **Runtime.** `POST /v1/tokens` (application key only) mints an ES256 JWT for a subject and a role, valid 60–900 seconds. The Tenant API accepts it as a bearer and resolves its scopes and agents from the role on every request. Forged, foreign or malformed tokens get the opaque `404`; an expired token, a revoked subject, a revoked key or a removed role gets `401 token_expired` with `WWW-Authenticate`. Tokens carry only `agents:read`, `sessions:own` and `vaults:own`; they may not set session `info`, send `message.manifest` or store OAuth refresh credentials, and `GET /v1/agents` shows them `{ agentId, name, description }` of their role's agents only.
|
|
202
|
+
- **Access policy.** `GET`/`PUT /v1/access/policy`: roles with token scopes, an agent allowlist and limits (`turnsPerHour`, `concurrentTurns`, answered with `429 limit_exceeded` and `Retry-After`). Without roles nothing is minted.
|
|
203
|
+
- **Signing keys.** Per Tenant, the private key sealed with the vault KEK: `GET /v1/access/signing-keys`, `POST …/rotate` (refused while the previous key may still verify live tokens; `force` for incidents), `POST …/:kid/revoke`, `GET /v1/access/jwks`. A Tenant with signing keys and no KEK is quarantined `kek-missing`.
|
|
204
|
+
- **Revocation.** `POST /v1/access/revocations` ends a subject's tokens; their open event streams end with `event: nylorun.closed` on every process. A stream opened with a token also ends when the token expires.
|
|
205
|
+
- Postgres migration 3 adds `signing_keys`, `subject_epochs`, `subject_usage` and an index on the session owner and status. New error codes `token_expired` and `limit_exceeded`.
|
|
206
|
+
- **Agents SDK.** `client.tokens.create()`, `client.access.getPolicy()`/`putPolicy()`/`revokeSubject()`/`jwks()` and `client.access.signingKeys.list()`/`rotate()`/`revoke()`, each checking the Host feature first.
|
|
207
|
+
- **CLI.** `nylo access policy get|set|init`, `nylo access signing-keys list|rotate|revoke`, `nylo access revoke <subject>` and `nylo access token` for trying the API.
|
|
208
|
+
|
|
209
|
+
### Patch Changes
|
|
210
|
+
|
|
211
|
+
- 18468d9: **Tenant routes start moving to Hono.** The executor and Action routes and session commands (`/v1/executors/connect`, `/v1/actions/**`, `/v1/executors`, `/v1/executors/:agentId` and `POST /v1/sessions/:id/commands`) are declared as Hono routes (`api/http/routes/executors.ts`). Each says who may call it: its credentials, subject scopes and browser access. The Runtime's OpenAPI document shows this, and the executor routes are marked deprecated there, since Action endpoints replace them. Answers are unchanged. A path the new routes don't match exactly still goes to the router they replace, so its answer is unchanged too.
|
|
212
|
+
|
|
213
|
+
**Core:** the recursive contract schemas (JSON values, workflow nodes and manifests, and an agent used as a tool) carry a Zod `id`, so documents generated from them refer back to the named schema instead of recursing. Parsing is unchanged.
|
|
214
|
+
|
|
215
|
+
## 0.8.0-beta
|
|
216
|
+
|
|
217
|
+
### Minor Changes
|
|
218
|
+
|
|
219
|
+
- e537a82: **One `Agent` builder: named methods and flow agents.** Every capability has its own method, and deterministic workflows are written on the same builder. ReAct agent manifests are unchanged: the new syntax compiles to exactly what the old syntax produced.
|
|
220
|
+
|
|
221
|
+
- ReAct agents: `.instructions()`, `.tools()`, `.subagents()`, `.mcp()` (a server's `name` defaults to its key; calls merge), `.skills()`, `.plugin()`, `.capability()`, `.sandbox()`, `.beforeTurn()`, `.beforeModel()`, `.afterModel()`, `.afterTurn()`, `.output()`. `capability({ id })` returns a builder with the same methods.
|
|
222
|
+
- Flow agents: `.step()`, `.switch({ ...cases, default }, { on })`, `.parallel()`, `.map()` (runs over its input), `.loop(body, { verify, max | decide })`, plus `.input()`, `.output()`, `.sandbox()`, `flow()` for nested sequences and `.withId()`. Functions receive `{ input, results, flowInput }`, typed from each step's output schema. A flow agent compiles to a workflow manifest (v2, see the flow-manifest-v2 changeset).
|
|
223
|
+
- Build diagnostics: `agent.mixed-body`, `flow.no-model`, `agent.single-value`, `flow.empty`, `loop.max-required`, `loop.invalid-max`, `mcp.duplicate-server`, `delegation.flow-unsupported`.
|
|
224
|
+
- `sandbox()` and `mcp()` move to `@nylorun/core/define` (still exported from `@nylorun/agents`).
|
|
225
|
+
- Deprecated, warning once each: options-form `instructions`/`tools`/`outputSchema` (`NYLORUN_DEP_AGENT_OPTIONS`), `.use(capability)` (`NYLORUN_DEP_USE`), `.before()`/`.after()` (`NYLORUN_DEP_HOOKS`), and `capability({ tools, instructions, … })` (`NYLORUN_DEP_CAPABILITY_OPTIONS`). See MIGRATION.md.
|
|
226
|
+
|
|
227
|
+
- 5278b4e: **Flow agents on workflow manifest v2.** A flow agent compiles to `workflowSchemaVersion: 2` and runs on the new `flow-2` engine; v1 workflows (`Chain`, `Switch`, `Parallel`, `Map`, `Loop`) keep running on `flow-1`, so in-flight runs finish as they began.
|
|
228
|
+
|
|
229
|
+
- **Manifest (core).** Any node may carry `id` and `input`; there are no slots. `chain` and `parallel` are bare collections, a Map is `{ map: { each } }` over its input, and a Loop has `max?` and `decide?`. The header adds `name`, `description`, `metadata`, `inputSchema` and `outputSchema`, and `agents` embeds every agent the flow runs, so one manifest hash covers the whole flow. `Agent.from(json, { nodes, agents })` rebuilds a flow agent. Path and key helpers (`leafPath`, `stageKey`, `forEachFlowNode`, `embeddedAgent`, …) are exported from `@nylorun/core/define`.
|
|
230
|
+
- **Paths (harness).** Linked agent sessions are named by the agent: its id, `[i]` per Map item, and a nested flow agent's id in front. Control stages add nothing, so wrapping a step in a Loop keeps its session. Functions are bound under stage keys (`route:on`, `@1.default.1:input`) and all receive `{ input, results, flowInput }`; `flowInput` works inside nested `flow()`. A Loop without `decide` retries with the verifier's feedback up to `max` and then fails with `loop.exhausted`. Nested flow agents run inline.
|
|
231
|
+
- **Runtime.** Leaves of a v2 workflow resolve from its embedded `agents` (with the workflow's plugin roots, keyed `<agent>/<capability>`) instead of the registry. `loop.iteration` is emitted only for a Loop's own agent turns.
|
|
232
|
+
- **Agents SDK.** `saveAgent(flowAgent)` PUTs one document; application mode registers the flow's executor with its manifest hash. An executor leaves `fn`, `verify` and tool actions of a v2 flow unclaimed when they belong to another manifest hash, because stage keys can shift between deploys; it reports each skipped action once through `onError`.
|
|
233
|
+
- **Studio.** Draws v2 manifests: agents and tools at their session paths, control stages at their stage keys, nested flow agents inline, and lights a Map's agent from its item sessions.
|
|
234
|
+
- Build diagnostics: `flow.duplicate-leaf`, `flow.duplicate-id`, `flow.agent-conflict`, `flow.v1-workflow`, `loop.invalid-verify`, `workflow.flow-agent-child`. Also fixes v1 flows passing an agent step's output to the next step still wrapped in the runtime's turn marker.
|
|
235
|
+
|
|
236
|
+
- 426fd27: **Flow agents as subagents.** `.subagents(flowAgent)` lets a ReAct agent delegate to a flow agent. The flow's workflow manifest v2 is inlined in the delegating tool (`ToolManifest.agent` may be a workflow manifest), so it is saved with the parent and served by the parent's executor, plugin roots included (`<flow>/<agent>/<capability>`).
|
|
237
|
+
|
|
238
|
+
- **Engine (harness).** A call to a flow subagent is one durable `agent` effect (`role: "delegate"`) between the delegation's start and settle points; the flow's output is the tool result, and a failed flow is a failed tool result. Local `run()` refuses flow subagents, which need the Runtime.
|
|
239
|
+
- **Runtime.** The effect starts a linked flow session from the parent's pinned manifest, fresh per call, and settles when the flow's turn ends. Cancelling any session now cascades to the linked sessions it started, not only a workflow's.
|
|
240
|
+
- **Core.** `delegation.flow-unsupported` now only reports a workflow built with `Chain`, `Switch`, `Parallel`, `Map` or `Loop`. New helpers: `flowDelegatesOf`, `flowDelegateManifest`, `isFlowDelegate`; `delegatesOf` lists only the ReAct agents run in-process.
|
|
241
|
+
|
|
242
|
+
### Patch Changes
|
|
243
|
+
|
|
244
|
+
- 8cda500: **Workflow functions and tool steps reach the executor.** Several workflow nodes asked the executor for a key that core never registered, so the executor never found the function and the turn waited forever.
|
|
245
|
+
|
|
246
|
+
- A Map's `over` and a slot's `input` now use the keys core registers (`<path>/over`, `<path>/input`), as Switch's `on` already did.
|
|
247
|
+
- A slot `input` that wraps a Map or Switch gets its own effect id, so it no longer collides with the `over` or `on` effect on the same path.
|
|
248
|
+
- A slot `id` that renames a nested workflow now renames the keys inside it too.
|
|
249
|
+
- A verifier slot's `input` is keyed under the verifier's path (`<loop>/<part>/input`).
|
|
250
|
+
- A tool step passes its output to the next step, not the `{ kind: "completed", output }` outcome around it. A denied tool call fails the flow with `tool.denied`.
|
|
251
|
+
|
|
3
252
|
## 0.7.0-beta
|
|
4
253
|
|
|
5
254
|
### Minor Changes
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
|
-
export declare const PROTOCOL_VERSION =
|
|
3
|
-
export declare const PROTOCOL_FEATURES: readonly ["runtime-tenants", "admin-status", "studio-principal"];
|
|
2
|
+
export declare const PROTOCOL_VERSION = 4;
|
|
3
|
+
export declare const PROTOCOL_FEATURES: readonly ["runtime-tenants", "admin-status", "studio-principal", "action-endpoints"];
|
|
4
4
|
export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
|
|
5
5
|
/**
|
|
6
6
|
* Host features no client requires: a client that uses one checks the Host's `/health`
|
|
@@ -11,8 +11,20 @@ export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
|
|
|
11
11
|
* `POST /v1/admin/tenants` accepts `derivedPrincipals`. `subject-headers`: an application
|
|
12
12
|
* principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
|
|
13
13
|
* enforces the scopes and the subject's ownership of sessions and vaults.
|
|
14
|
+
* `subject-tokens`: `POST /v1/tokens` mints ES256 subject tokens for the roles of the Tenant's
|
|
15
|
+
* access policy, and the Tenant API accepts them as bearers (`/v1/access/**` manages the
|
|
16
|
+
* policy, signing keys and revocations). `browser-access`: publishable keys
|
|
17
|
+
* (`Nylorun-Key`, `/v1/access/publishable-keys`) name the Tenant and an origin allowlist, and
|
|
18
|
+
* browser requests from listed origins reach the Tenant routes with CORS. `ag-ui-endpoint`:
|
|
19
|
+
* the Runtime serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a subject token
|
|
20
|
+
* or by subject headers. `a2a-endpoint`:
|
|
21
|
+
* `POST /v1/a2a/agents/:agent` answers A2A 1.0 JSON-RPC for a subject, and
|
|
22
|
+
* `GET /v1/a2a/agents/:agent/card` returns the agent's card without its interfaces.
|
|
23
|
+
* `action-endpoints`: `PUT`/`GET`/`DELETE /v1/endpoints` register the URL that runs each agent's
|
|
24
|
+
* Actions, and the Runtime delivers them there, signed with a delivery token
|
|
25
|
+
* (`Nylorun-Signature`), instead of offering them to executors.
|
|
14
26
|
*/
|
|
15
|
-
export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "transcript-events", "derived-principals", "subject-headers"];
|
|
27
|
+
export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "transcript-events", "derived-principals", "subject-headers", "subject-tokens", "browser-access", "ag-ui-endpoint", "a2a-endpoint", "action-endpoints"];
|
|
16
28
|
export type OptionalHostFeature = (typeof OPTIONAL_HOST_FEATURES)[number];
|
|
17
29
|
export interface ProtocolRange {
|
|
18
30
|
min: number;
|
|
@@ -27,10 +39,30 @@ export declare const PROTOCOL_HEADER = "Nylorun-Protocol";
|
|
|
27
39
|
export declare const SUBJECT_HEADER = "Nylorun-Subject";
|
|
28
40
|
/** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
|
|
29
41
|
export declare const SCOPES_HEADER = "Nylorun-Scopes";
|
|
30
|
-
|
|
42
|
+
/** A publishable key: names the Tenant and the client app (Host feature `browser-access`). */
|
|
43
|
+
export declare const PUBLISHABLE_KEY_HEADER = "Nylorun-Key";
|
|
44
|
+
/** The delivery token on a request the Runtime sends to an Action endpoint. */
|
|
45
|
+
export declare const SIGNATURE_HEADER = "Nylorun-Signature";
|
|
46
|
+
/** Set to `1` on an Action endpoint's response whose body is a tagged `ActionOutcome`. */
|
|
47
|
+
export declare const OUTCOME_HEADER = "Nylorun-Outcome";
|
|
48
|
+
export declare const ERROR_CODES: readonly ["not_found", "protocol_unsupported", "host_rejected", "origin_rejected", "unsupported_media_type", "tenant_conflict", "active_work", "connection_missing", "incompatible_host", "subject_invalid", "scope_required", "token_expired", "limit_exceeded",
|
|
49
|
+
/** A request the Runtime refuses for a reason the message gives. */
|
|
50
|
+
"request_rejected",
|
|
51
|
+
/** A request the Host could not read: headers, body or query. */
|
|
52
|
+
"invalid_request",
|
|
53
|
+
/** A route that acts for a person was called without one (`Nylorun-Subject`). */
|
|
54
|
+
"subject_required", "internal_error"];
|
|
31
55
|
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
32
56
|
export declare const TENANT_ID_PATTERN: RegExp;
|
|
33
57
|
export declare const PRINCIPAL_ID_PATTERN: RegExp;
|
|
58
|
+
/** A Tenant signing key's id, the `kid` of the subject tokens it signs. */
|
|
59
|
+
export declare const SIGNING_KEY_ID_PATTERN: RegExp;
|
|
60
|
+
/** A publishable key's id (not the key). */
|
|
61
|
+
export declare const PUBLISHABLE_KEY_ID_PATTERN: RegExp;
|
|
62
|
+
/** A publishable key: `nr_pub_<tenantId>_<32 Crockford characters>`. */
|
|
63
|
+
export declare const PUBLISHABLE_KEY_PATTERN: RegExp;
|
|
64
|
+
/** The Tenant a publishable key names, or undefined when it is not one. */
|
|
65
|
+
export declare function tenantOfPublishableKey(value: unknown): string | undefined;
|
|
34
66
|
/** A derived principal's id names its client, e.g. `babai`; `studio` is reserved. */
|
|
35
67
|
export declare const DERIVED_PRINCIPAL_ID_PATTERN: RegExp;
|
|
36
68
|
export declare function isTenantId(value: unknown): value is string;
|
|
@@ -43,6 +75,12 @@ export declare function isPrincipalId(value: unknown): value is string;
|
|
|
43
75
|
export declare function newTenantId(now?: number): string;
|
|
44
76
|
/** Principal id: `pr_` + lowercase Crockford ULID (same generator as tenants). */
|
|
45
77
|
export declare function newPrincipalId(now?: number): string;
|
|
78
|
+
/** Signing key id: `sk_` + lowercase Crockford ULID (same generator as tenants). */
|
|
79
|
+
export declare function newSigningKeyId(now?: number): string;
|
|
80
|
+
/** Publishable key id: `pk_` + lowercase Crockford ULID. */
|
|
81
|
+
export declare function newPublishableKeyId(now?: number): string;
|
|
82
|
+
/** A new publishable key for `tenantId`: 160 random bits after the Tenant id. */
|
|
83
|
+
export declare function newPublishableKey(tenantId: string): string;
|
|
46
84
|
/**
|
|
47
85
|
* SemVer 2.0 precedence, including prereleases. Build metadata is ignored.
|
|
48
86
|
* Returns -1 when a < b, 0 when equal, 1 when a > b.
|
package/dist/compatibility.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
|
-
export const PROTOCOL_VERSION =
|
|
2
|
+
export const PROTOCOL_VERSION = 4;
|
|
3
3
|
export const PROTOCOL_FEATURES = [
|
|
4
4
|
"runtime-tenants",
|
|
5
5
|
"admin-status",
|
|
6
6
|
"studio-principal",
|
|
7
|
+
"action-endpoints",
|
|
7
8
|
];
|
|
8
9
|
/**
|
|
9
10
|
* Host features no client requires: a client that uses one checks the Host's `/health`
|
|
@@ -14,16 +15,33 @@ export const PROTOCOL_FEATURES = [
|
|
|
14
15
|
* `POST /v1/admin/tenants` accepts `derivedPrincipals`. `subject-headers`: an application
|
|
15
16
|
* principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
|
|
16
17
|
* enforces the scopes and the subject's ownership of sessions and vaults.
|
|
18
|
+
* `subject-tokens`: `POST /v1/tokens` mints ES256 subject tokens for the roles of the Tenant's
|
|
19
|
+
* access policy, and the Tenant API accepts them as bearers (`/v1/access/**` manages the
|
|
20
|
+
* policy, signing keys and revocations). `browser-access`: publishable keys
|
|
21
|
+
* (`Nylorun-Key`, `/v1/access/publishable-keys`) name the Tenant and an origin allowlist, and
|
|
22
|
+
* browser requests from listed origins reach the Tenant routes with CORS. `ag-ui-endpoint`:
|
|
23
|
+
* the Runtime serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a subject token
|
|
24
|
+
* or by subject headers. `a2a-endpoint`:
|
|
25
|
+
* `POST /v1/a2a/agents/:agent` answers A2A 1.0 JSON-RPC for a subject, and
|
|
26
|
+
* `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.
|
|
17
30
|
*/
|
|
18
31
|
export const OPTIONAL_HOST_FEATURES = [
|
|
19
32
|
"tenant-fixture-model",
|
|
20
33
|
"transcript-events",
|
|
21
34
|
"derived-principals",
|
|
22
35
|
"subject-headers",
|
|
36
|
+
"subject-tokens",
|
|
37
|
+
"browser-access",
|
|
38
|
+
"ag-ui-endpoint",
|
|
39
|
+
"a2a-endpoint",
|
|
40
|
+
"action-endpoints",
|
|
23
41
|
];
|
|
24
42
|
export const HOST_PROTOCOL = {
|
|
25
|
-
min:
|
|
26
|
-
max:
|
|
43
|
+
min: 4,
|
|
44
|
+
max: 4,
|
|
27
45
|
features: [...PROTOCOL_FEATURES, ...OPTIONAL_HOST_FEATURES],
|
|
28
46
|
};
|
|
29
47
|
export const DEFINITION_SCHEMA_VERSION = 2;
|
|
@@ -33,6 +51,12 @@ export const PROTOCOL_HEADER = "Nylorun-Protocol";
|
|
|
33
51
|
export const SUBJECT_HEADER = "Nylorun-Subject";
|
|
34
52
|
/** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
|
|
35
53
|
export const SCOPES_HEADER = "Nylorun-Scopes";
|
|
54
|
+
/** A publishable key: names the Tenant and the client app (Host feature `browser-access`). */
|
|
55
|
+
export const PUBLISHABLE_KEY_HEADER = "Nylorun-Key";
|
|
56
|
+
/** The delivery token on a request the Runtime sends to an Action endpoint. */
|
|
57
|
+
export const SIGNATURE_HEADER = "Nylorun-Signature";
|
|
58
|
+
/** Set to `1` on an Action endpoint's response whose body is a tagged `ActionOutcome`. */
|
|
59
|
+
export const OUTCOME_HEADER = "Nylorun-Outcome";
|
|
36
60
|
export const ERROR_CODES = [
|
|
37
61
|
"not_found",
|
|
38
62
|
"protocol_unsupported",
|
|
@@ -45,11 +69,32 @@ export const ERROR_CODES = [
|
|
|
45
69
|
"incompatible_host",
|
|
46
70
|
"subject_invalid",
|
|
47
71
|
"scope_required",
|
|
72
|
+
"token_expired",
|
|
73
|
+
"limit_exceeded",
|
|
74
|
+
/** A request the Runtime refuses for a reason the message gives. */
|
|
75
|
+
"request_rejected",
|
|
76
|
+
/** A request the Host could not read: headers, body or query. */
|
|
77
|
+
"invalid_request",
|
|
78
|
+
/** A route that acts for a person was called without one (`Nylorun-Subject`). */
|
|
79
|
+
"subject_required",
|
|
80
|
+
"internal_error",
|
|
48
81
|
];
|
|
49
82
|
/** Crockford Base32 alphabet (lowercase); excludes i, l, o, u. */
|
|
50
83
|
const CROCKFORD = "0123456789abcdefghjkmnpqrstvwxyz";
|
|
51
84
|
export const TENANT_ID_PATTERN = /^tn_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
52
85
|
export const PRINCIPAL_ID_PATTERN = /^pr_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
86
|
+
/** A Tenant signing key's id, the `kid` of the subject tokens it signs. */
|
|
87
|
+
export const SIGNING_KEY_ID_PATTERN = /^sk_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
88
|
+
/** A publishable key's id (not the key). */
|
|
89
|
+
export const PUBLISHABLE_KEY_ID_PATTERN = /^pk_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
90
|
+
/** A publishable key: `nr_pub_<tenantId>_<32 Crockford characters>`. */
|
|
91
|
+
export const PUBLISHABLE_KEY_PATTERN = /^nr_pub_(tn_[0-9a-hjkmnp-tv-z]{26})_([0-9a-hjkmnp-tv-z]{32})$/;
|
|
92
|
+
/** The Tenant a publishable key names, or undefined when it is not one. */
|
|
93
|
+
export function tenantOfPublishableKey(value) {
|
|
94
|
+
if (typeof value !== "string")
|
|
95
|
+
return undefined;
|
|
96
|
+
return PUBLISHABLE_KEY_PATTERN.exec(value)?.[1];
|
|
97
|
+
}
|
|
53
98
|
/** A derived principal's id names its client, e.g. `babai`; `studio` is reserved. */
|
|
54
99
|
export const DERIVED_PRINCIPAL_ID_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
55
100
|
export function isTenantId(value) {
|
|
@@ -113,6 +158,23 @@ export function newTenantId(now) {
|
|
|
113
158
|
export function newPrincipalId(now) {
|
|
114
159
|
return newPrefixedId("pr_", now);
|
|
115
160
|
}
|
|
161
|
+
/** Signing key id: `sk_` + lowercase Crockford ULID (same generator as tenants). */
|
|
162
|
+
export function newSigningKeyId(now) {
|
|
163
|
+
return newPrefixedId("sk_", now);
|
|
164
|
+
}
|
|
165
|
+
/** Publishable key id: `pk_` + lowercase Crockford ULID. */
|
|
166
|
+
export function newPublishableKeyId(now) {
|
|
167
|
+
return newPrefixedId("pk_", now);
|
|
168
|
+
}
|
|
169
|
+
/** A new publishable key for `tenantId`: 160 random bits after the Tenant id. */
|
|
170
|
+
export function newPublishableKey(tenantId) {
|
|
171
|
+
if (!isTenantId(tenantId))
|
|
172
|
+
throw new Error(`Invalid Tenant id ${tenantId}`);
|
|
173
|
+
let random = "";
|
|
174
|
+
while (random.length < 32)
|
|
175
|
+
random += encodeRandom();
|
|
176
|
+
return `nr_pub_${tenantId}_${random.slice(0, 32)}`;
|
|
177
|
+
}
|
|
116
178
|
function parseSemVer(version) {
|
|
117
179
|
const match = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/.exec(version);
|
|
118
180
|
if (!match)
|