@nylorun/core 0.11.0-beta → 0.13.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 +92 -0
- package/dist/compatibility.d.ts +71 -34
- package/dist/compatibility.js +76 -46
- package/dist/contracts.d.ts +1078 -215
- package/dist/contracts.js +742 -181
- package/dist/define.d.ts +1 -1
- package/dist/define.js +1 -1
- package/dist/definition/sandbox-capability.d.ts +13 -0
- package/dist/definition/sandbox-capability.js +59 -0
- package/dist/harness-api/errors.d.ts +7 -0
- package/dist/harness-api/errors.js +9 -0
- package/dist/harness-api/hash.d.ts +12 -0
- package/dist/harness-api/hash.js +34 -0
- package/dist/harness-api/index.d.ts +10 -0
- package/dist/harness-api/index.js +10 -0
- package/dist/harness-api/messages.d.ts +394 -0
- package/dist/harness-api/messages.js +21 -0
- package/dist/harness-api/rpc.d.ts +78 -0
- package/dist/harness-api/rpc.js +240 -0
- package/dist/harness-api/schema.d.ts +155 -0
- package/dist/harness-api/schema.js +271 -0
- package/dist/harness-api/transcript.d.ts +29 -0
- package/dist/harness-api/transcript.js +74 -0
- package/package.json +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,97 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.13.0-beta
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- bd478ee: **Subject tokens, browser keys and derived principals leave open source (F9 I3, protocol 7).** Upgrade these with the Runtime: they speak protocol 7, which this Runtime serves beside 4, 5 and 6; protocol 6 clients keep working on every route that remains. Browsers and apps present a trusted issuer's token (F9 I2), servers an operator key (F9 I1), and a person's own credentials come from the operator's credential resolver (F9 C1). See MIGRATION.md.
|
|
8
|
+
|
|
9
|
+
- **Breaking (`@nylorun/runtime`, `@nylorun/core`): subject tokens are gone.** `POST /v1/tokens`, `POST /v1/access/revocations`, subject-token verification, revocation epochs and the `subject.revoked` stream signal are removed; the routes answer `404`, and a JWT no trusted issuer signed is the opaque `404`. A stream opened with a token now ends only at its expiry (`event: nylorun.closed`, reason `token_expired`; `StreamClosedFrame` loses `revoked`). Migration `0010_oss_auth_removals` drops the `subject_epochs`, `subject_usage` and `publishable_keys` tables. The `token` caller is a trusted issuer's token only: it loses `role`, `limits` and `epoch`, and `issuer` is always set; `GET /v1/me` no longer reports `via: token`. Core drops `SUBJECT_TOKEN_TYPE`, `SUBJECT_TOKEN_AUDIENCE`, `subjectTokenIssuer` (the Runtime's own tokens use `tenantTokenIssuer`, same value), `CreateTokenRequest`/`Response`, `RevokeSubject*`, `SubjectTokenClaims`, `TOKEN_TTL_MIN_SECONDS` and `TOKEN_TTL_DEFAULT_SECONDS`; `TOKEN_SCOPES` is `agents:read`, `sessions:own`, `sandboxes:write`.
|
|
10
|
+
- **Breaking (`@nylorun/runtime`, `@nylorun/core`): the access policy and role limits are gone.** `GET`/`PUT /v1/access/policy` answer `404`, a turn is never refused with `429 limit_exceeded` for a role (limit requests at your proxy), and an existing `access.policy` setting is ignored. Core drops `AccessPolicy*`, `AccessRole*`, `RoleLimits*`, `DEFAULT_ACCESS_POLICY`, `PutAccessPolicyRequest` and `ROLE_NAME_PATTERN`.
|
|
11
|
+
- **Breaking (`@nylorun/runtime`, `@nylorun/core`): publishable keys and the Runtime's CORS are gone.** `/v1/access/publishable-keys*` answer `404`, `Nylorun-Key` is ignored, `NYLORUN_BROWSER_ACCESS` and `browserAccess` (host.json, `createHost`, `startEphemeralRuntime`) are removed, and the Runtime sends no CORS headers. A request with `Origin` reaches the Tenant routes of the public listener with no toggle: a trusted issuer's token is served, an application key or delivery token is `403 origin_rejected`; admin routes, `/health`, `/ready` and the operator listener still refuse `Origin`. Any `OPTIONS` request is `204` with `Allow` and no CORS header: the operator's proxy answers preflights. Route declarations lose `browser` (`x-nylorun-browser` leaves the OpenAPI document) and the `publishable` credential; the token security scheme is `issuerToken`. Core drops `PUBLISHABLE_KEY_HEADER`, `PUBLISHABLE_KEY_PATTERN`, `PUBLISHABLE_KEY_ID_PATTERN`, `tenantOfPublishableKey`, `newPublishableKey`, `newPublishableKeyId`, `PublishableKey*`, `OriginEntrySchema`, `originAllowed` and `LOOPBACK_ORIGIN_WILDCARDS`.
|
|
12
|
+
- **Breaking (`@nylorun/runtime`, `@nylorun/core`, `@nylorun/agents`): vault routes are application-only, and `vaults:own` is retired.** Every `/v1/vaults` route takes an application key acting for no one (operator keys, Studio); a request acting for a subject or a trusted issuer's token gets `403 scope_required`. `vaults:own` leaves `SUBJECT_SCOPES`, `TOKEN_SCOPES` and the issuer scopes; `Nylorun-Scopes` may still name it and it grants nothing. Existing user vaults stay attachable to their own owner's sessions. `client.createVault` takes `{ scope: "installation" }` or `ownerUserId`, and `client.listVaults()` takes an optional owner.
|
|
13
|
+
- **Breaking (`@nylorun/runtime`, `@nylorun/core`, `@nylorun/admin`, `nylorun`): derived principals are gone.** Only Studio's key is derived from the admin key. `NYLORUN_DERIVED_PRINCIPALS` is ignored and no longer written, `hostPrincipals` takes no `derived`, `startEphemeralRuntime` no `derivedPrincipals`, and `@nylorun/admin` drops `deriveTenantKey`, `PROJECT_PRINCIPAL_ID` and `admin.deriveTenantKey`. Keys an earlier Host derived stay in the database and keep working as ordinary keys; replace them with operator keys. Core renames `DERIVED_PRINCIPAL_ID_PATTERN` to `APPLICATION_KEY_ID_PATTERN`.
|
|
14
|
+
- **Breaking (`@nylorun/agents`):** `createTokenEndpoint`, `createBrowserClient` and the `@nylorun/agents/browser` entry, `client.tokens`, `TokensClient`, `PublishableKeysClient`, `client.access.getPolicy`/`putPolicy`/`revokeSubject`/`publishableKeys` and `Destination.publishableKey` are removed. `client.access.signingKeys` and `client.access.jwks()` stay, and `Destination.token` takes a trusted issuer's tokens.
|
|
15
|
+
- **Breaking (`@nylorun/cli`):** `nylo access policy|keys|revoke|token` are removed and name what replaces them; `nylo access signing-keys list|rotate|revoke` stays.
|
|
16
|
+
- **Breaking (`@nylorun/core`, `@nylorun/agents`, `@nylorun/studio`): the Studio embed message `open.babai` is now `open.session`** (`{ sessionId }`): it asks the embedding app to open that session in its own UI. Studio sends no such message itself.
|
|
17
|
+
- **Breaking (`nylorun`): Studio embedding is opt-in.** No origin may frame Studio by default; list your app's origins with `nylorun start --studio-embed-origin <origin>`. A Tenant's `.env` from an earlier nylorun keeps the origins it had until `--studio-embed-origin-reset`.
|
|
18
|
+
- `PROTOCOL_VERSION` is 7 and `HOST_PROTOCOL` 4–7; the Host features `subject-tokens`, `browser-access` and `derived-principals` are removed. `@nylorun/studio` and `@nylorun/create-agent` speak protocol 7.
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- 8773586: **Installation vaults and a credential resolver (F9 C1).** A session's MCP credential now comes from its attached vaults, then from the operator's own credential resolver; nothing changes for existing vaults, and the protocol stays at 6.
|
|
23
|
+
|
|
24
|
+
- Installation vaults: `POST /v1/vaults` takes `scope: "installation"` (no `ownerUserId`) from an application key acting for no one; a request acting for a subject gets `403`. The vault is owned by `installation`, now a reserved subject like `host`. Any session may attach one and select its credentials. `GET /v1/vaults` from an application key lists them after the named person's vaults, and lists only them without `ownerUserId`; a request acting for a subject never sees one (the opaque `404`). The host model vault stays hidden and unattachable. Migration 0008 adds the scope.
|
|
25
|
+
- The credential resolver: `NYLORUN_RESOLVER_URL` and `NYLORUN_RESOLVER_TOKEN` on the gateway (`TenantConfig.resolver` and `startEphemeralRuntime({ resolver })` in process). When the session's vaults hold nothing for a remote MCP server's URL, the Runtime POSTs `{ owner, session, turn, target: { kind: "mcp", server, agent, url } }` with the resolver's bearer: `200 { headers, expiresAt? }` is used, `404` goes without a credential, and anything else or no answer within 5 s refuses the server with `credential_unavailable`. Owner and turn come from the session row. Answers are cached per owner and URL until `expiresAt`, at most 5 minutes (60 s without one), and concurrent misses share one request. See DEPLOYMENT.md, Credentials.
|
|
26
|
+
- `nylorun`: the gateway's Compose service passes `NYLORUN_RESOLVER_URL` and `NYLORUN_RESOLVER_TOKEN` from the shell that runs `nylorun start` (unset by default).
|
|
27
|
+
- Studio: the Vault page is now **Connections**, and creates installation vaults.
|
|
28
|
+
|
|
29
|
+
- e1bfb4b: **MCP OAuth connect for installation vaults (F9 C2).** The installation can sign in once to a remote MCP server that uses OAuth, and every session that attaches the vault uses the credential. Additive; the protocol stays at 6.
|
|
30
|
+
|
|
31
|
+
- `POST /v1/vaults/{vaultId}/oauth/start` (application keys acting for no one, installation vaults only) takes `{ url, server, clientId? }` and answers `{ authorizeUrl, expiresAt }`. The Runtime discovers the server's authorization server (RFC 9728, then RFC 8414), registers itself (RFC 7591) unless `clientId` names a registered client, and starts an S256 PKCE sign-in whose `state` works once, for ten minutes. A server without registration and no `clientId` is `400 oauth_client_required`.
|
|
32
|
+
- `GET /v1/oauth/callback` takes the browser back: anonymous and unversioned like an artifact link, it exchanges the code and stores an `oauth` credential bound to the URL, named after `server` (connecting again rotates it), and answers a small HTML page. An unknown, used or expired `state` is `oauth_state_invalid`; the authorization server's refusal is `oauth_failed`. The callback's base is `NYLORUN_PUBLIC_URL` (`TenantConfig.publicUrl`), else the start request's origin.
|
|
33
|
+
- Every OAuth step runs in the gateway's keys module (F9-D14): the runtime container never sees a token, the PKCE verifier or a client secret, and makes no outbound call. Migration 0009 adds `oauth_pending`, with the verifier and secret sealed under the vault key. `Keys` gains `startOAuth` and `finishOAuth`.
|
|
34
|
+
- OAuth requests, including refresh of every OAuth vault credential, now go through `guardedFetch` (`tenant/outbound.ts`): the `NYLORUN_ENDPOINT_*` address policy checked on the address connected to, no redirects, a bounded answer. With `NYLORUN_ENDPOINT_PRIVATE=refuse` a token endpoint on a private address is refused, where refresh used to call it.
|
|
35
|
+
- `@nylorun/core`: `ERROR_CODES` adds `oauth_client_required`, `oauth_state_invalid` and `oauth_failed`; `StartOAuthRequestSchema` and `StartOAuthResponseSchema`.
|
|
36
|
+
- `nylorun mcp connect <url> --server <name> [--vault <id>] [--client-id <id>]`: creates the installation vault `mcp` if needed, opens the sign-in page and waits up to 10 minutes for the credential. See DEPLOYMENT.md, "Connecting a remote MCP server with OAuth".
|
|
37
|
+
|
|
38
|
+
- 5cfaed9: **Operator keys, and project links on them (F9 I1).** The Admin API manages the Tenant's application keys by name: `PUT /v1/admin/keys/{id}` creates a key or rotates it and returns it once, `GET /v1/admin/keys` lists every key's id, role and issue time (never the keys), and `DELETE /v1/admin/keys/{id}` removes one. A rotated or deleted key stops authenticating on its next request. Ids follow `^[a-z][a-z0-9-]{0,31}$`; `studio` (derived from the admin key) is refused. Keys keep today's format (64 hex) and only their SHA-256 is stored, in the existing principals table (no migration). Host feature `operator-keys` (additive, protocol unchanged); core adds the `OperatorKey`, `ListOperatorKeysResponse`, `PutOperatorKeyResponse` and `DeleteOperatorKeyResponse` schemas.
|
|
39
|
+
|
|
40
|
+
- `@nylorun/admin`: `admin.keys.put(id)`, `admin.keys.list()` and `admin.keys.delete(id)`; they refuse with `incompatible_host` when the Host lacks `operator-keys`.
|
|
41
|
+
- `nylorun key put|list|rm <id>` manages a running local Tenant's keys; `put` prints the key once on stdout.
|
|
42
|
+
- `nylorun start` no longer derives the project's key. It keeps `.nylorun/credentials.json` while its key still reaches the Tenant (one authenticated read); otherwise it gives the project the operator key `project`, which the Host root keeps in `project-credentials.json` (0600) so every checkout linked to the Tenant shares it. An existing derived project key keeps working and is adopted.
|
|
43
|
+
- `nylorun sandbox` uses the linked project's key, or the operator key `cli` it puts once and keeps in `<Host root>/cli-credentials.json` (0600).
|
|
44
|
+
- The ephemeral Runtime (`startEphemeralRuntime`) no longer registers the derived `project` principal; pass `derivedPrincipals: ["project"]` to keep it. Derived principals (`NYLORUN_DERIVED_PRINCIPALS`, `deriveTenantKey`) still work on a Host.
|
|
45
|
+
|
|
46
|
+
- c0b604e: **Trusted issuers (F9 I2).** The Tenant API accepts JWTs from the operator's own identity provider as bearers, configured in an identity file: `NYLORUN_IDENTITY_FILE` names a YAML file listing each issuer's `name`, `issuer`, `audience`, `jwks` URL or static PEM `keys`, a `subject` template over scalar claims (`u:{sub}`), `scopes` from a claim or a fixed list, `allowedScopes`, an optional `agents` allowlist, optional `sandboxes` grant templates (`{org_id}/*`) and `maxLifetime`. A malformed file stops the boot, naming the issuer and the field; a subject template without a claim is malformed. A bearer whose unverified `iss` names an issuer is verified with RS256, ES256 or EdDSA only, up to 16 KiB, `aud` matching, `exp` and `iat` required and `exp − iat` within `maxLifetime`, and becomes a token caller (`role: issuer:<name>`) with the issuer's scopes, agents and rendered sandbox grants; subject revocation does not reach it. JWKS keys are fetched only from the configured URL (no redirects), cached by `kid`, refetched at most once a minute for an unknown `kid`; while a JWKS is unreachable cached keys keep working and a new `kid` is `401 issuer_unavailable` (new error code). A browser request with an issuer token needs no publishable key (CORS comes from the operator's proxy). New: `GET /v1/me` reports the subject, scopes, agents, sandbox grants and `via` (`application:<id>`, `subject`, `token` or `issuer:<name>`) of any credential; the issuer-only scope `studio`; `ISSUER_SCOPES`, `CALLER_SCOPES` and `MeResponseSchema` in `@nylorun/core/contracts`; `parseIdentityFile` and `createTrustedIssuers` in `@nylorun/runtime`, and an `issuers` option on `startEphemeralRuntime`; Host feature `trusted-issuers` (additive, protocol unchanged). `nylorun start` sets `NYLORUN_IDENTITY_FILE=/nylorun/identity.yaml` on the runtime container when `<Host root>/identity.yaml` exists.
|
|
47
|
+
|
|
48
|
+
## 0.12.0-beta
|
|
49
|
+
|
|
50
|
+
### Major Changes
|
|
51
|
+
|
|
52
|
+
- b352feb: **File artifacts, message parts and capability links (protocol 6).** Upgrade these with the Runtime: they speak protocol 6, which this Runtime serves beside 4 and 5. See MIGRATION.md.
|
|
53
|
+
|
|
54
|
+
- **`@nylorun/runtime`: file artifacts.** A file is an artifact: an `af_` id, a name and numbered immutable versions, with rows in the new `artifacts` and `artifact_versions` tables (migration `0004_artifacts`) and bytes in the Object store (`BlobStore`). `POST /v1/artifacts?name=&sessionId=` uploads a file in one streamed request and `POST /v1/artifacts/{id}/versions` adds a version, within the Tenant's limits (`GET`/`PUT /v1/tenant/artifacts`: 100 MiB per file and 10 GiB in all by default); a body past either is `413 limit_exceeded`, refused mid-stream with nothing stored. `GET /v1/artifacts` lists them (by session), `GET /v1/artifacts/{id}` reads one with its versions, `GET /v1/artifacts/{id}/versions/{n|latest}/content` downloads through the Runtime with HTTP Range (`206`, `Content-Range`, `416`), and `DELETE /v1/artifacts/{id}` deletes it with its bytes. A session's artifacts go with it on a sessions reset, and appear in its history as `artifact.created`, `artifact.version.created` and `artifact.deleted` (new in the event catalog). A subject reaches only the artifacts of their own sessions.
|
|
55
|
+
- **`@nylorun/runtime`: capability links.** `POST /v1/artifacts/{id}/links` mints a short-lived path, `/v1/artifact-links/<token>`, that downloads one version (with Range) with no credential and no `Nylorun-Protocol`: an ES256 JWT (`typ: nylorun-artifact+jwt`) signed with the Tenant's signing key, at most 15 minutes, and dead once the artifact is deleted. The Host logs its path without the token.
|
|
56
|
+
- **Breaking (`@nylorun/core`, `@nylorun/runtime`): message `parts`.** A user message may carry `parts`: `text`, and `file` by `artifactId` (and `version`, else the latest, pinned when the message is accepted). Model-gate reads the file from the Object store: an image goes to the model as image input, a text file as text, and any other file fails the call (`invalid_request`). The record and the transcript hold only the reference. The gateway builds its `BlobStore` from `NYLORUN_OBJECT_STORE_*` (the Tenant's `fs` store without it). `PROTOCOL_VERSION` is 6; `HOST_PROTOCOL` is 4–6 and protocol 6 clients require the feature `artifacts`.
|
|
57
|
+
- **`@nylorun/runtime`: `save_artifact`.** A session with a sandbox gets the `nylorun.artifacts` capability, whose `save_artifact` tool saves a sandbox file (`path`) or text (`content`) as an artifact of the session, carrying the turn and tool call on its event.
|
|
58
|
+
- **Breaking (`@nylorun/runtime`): `MediaStore` is removed.** `MediaStore` and `localMedia` leave `@nylorun/runtime/node`, and `piModel` takes `files` (a resolver from an artifact reference to its bytes) instead of `media`; images are file artifacts. The image checks (`decodeImageBase64`, `validateImageBytes`, `IMAGE_MEDIA_TYPES`, `MAX_IMAGE_BYTES`) stay.
|
|
59
|
+
- **`@nylorun/agents`:** `client.artifacts` (`upload`, `uploadVersion`, `list`, `get`, `download` with a range, `link`, `delete`), also on `BrowserClient`, and `session.inputParts(parts)`. A request with a body of its own type keeps it.
|
|
60
|
+
- `@nylorun/admin`, `@nylorun/cli`, `nylorun`, `@nylorun/studio`: speak protocol 6.
|
|
61
|
+
|
|
62
|
+
### Minor Changes
|
|
63
|
+
|
|
64
|
+
- 6077272: **Folder artifacts and the turn-end outputs export (F8.2).** Part of protocol 6, with file artifacts.
|
|
65
|
+
|
|
66
|
+
- **`@nylorun/runtime`: the turn-end export.** When an agent's turn completes, the Runtime reads `/workspace/outputs` of the session's sandbox and keeps it as a version of the session's folder artifact `outputs`: the first export creates it, and each later turn whose outputs changed adds a version (`artifact.created` / `artifact.version.created` with `kind: "folder"`, `source: "export"`, `fileCount` and `claimed: true`, since the listing and bytes are what the sandbox supplied). Nothing is exported without a sandbox or without outputs. An export past 10,000 files, 1 GiB, the per-file limit or the Tenant total stores nothing and records `artifact.export.skipped` with its reason; a failure records `artifact.export.failed`. Neither fails the turn. Core reads the workspace through one seam, `WorkspaceReader`, which the Harness API and pod sandboxes will implement later.
|
|
67
|
+
- **`@nylorun/runtime`: folder artifacts.** A folder version is a manifest of paths to content-addressed files: each file's bytes are stored once at `blobs/sha256/<hex>`, so an unchanged file is never stored again, and the Tenant total (`GET /v1/tenant/artifacts` `usedBytes`) counts it once. New routes: `GET /v1/artifacts/{id}/versions/{n|latest}/tree` (the manifest), `…/files/{path}` (one file by its percent-encoded path, with Range), `…/diff?from=n` (files added, removed and changed) and `…/zip` (a streamed zip). `POST /v1/artifacts/{id}/links` takes `file` to link one file of a folder; a folder's link without it opens the zip. A folder's `/content`, a new version uploaded to a folder, and a message part naming a folder are `400`. Deleting a folder removes the files no other version names. Migration `0006_folder_artifacts` allows the `folder` kind and adds the `artifact_content` table.
|
|
68
|
+
- **`@nylorun/core`:** `ArtifactKindSchema` (`file`, `folder`), the `export` source, `FolderEntrySchema`, `FolderManifestSchema`, `ArtifactTreeSchema`, `ArtifactDiffSchema`, the `artifact.export.skipped` and `artifact.export.failed` events, and `fileCount` and `claimed` on `artifact.created` / `artifact.version.created`.
|
|
69
|
+
- **`@nylorun/agents`:** `client.artifacts.tree()`, `file()`, `diff()` and `zip()`, and `link(id, { file })`.
|
|
70
|
+
|
|
71
|
+
- b6bf1f5: **Harness API v1, in process (F6.1).** Every segment now runs in a harness: the advance takes the session's lease and offers the segment as a run, and the Tenant's own harness, in the same process, runs the engine and reports how it ended. Core settles it exactly as before. Nothing changes on the wire: protocol 5, durable checkpoint 1, engine `hosted-3` and the Action endpoint wire are the same.
|
|
72
|
+
|
|
73
|
+
- `@nylorun/core/harness-api`: the protocol (messages, Zod schemas, the effect request hash, transcript edits, an RPC channel with an in-process memory transport).
|
|
74
|
+
- `@nylorun/harness/api`: `createHarness({ channel, executors })`, a harness that leases runs, renews their leases, replays a run's recorded outcomes without asking, keeps transcripts by record cursor, and runs model, MCP and sandbox calls through the executors it is given.
|
|
75
|
+
- `@nylorun/runtime`: the Harness API server per Tenant (`TenantHandle.attachHarness`), the in-process harness, and the journal as the Record seam. A model call's journal row now stores the request's hash without its prompt, so a replay never sends a prompt twice. `NYLORUN_HARNESS_API=0` runs the engine in the advance as before, until F6.2 removes it. A Runtime older than this one may fail a turn that was in flight across a downgrade with drift.
|
|
76
|
+
|
|
77
|
+
- 8ed4ea6: **Harness service over WebSocket, with the workspace capability (F6.2).** A Runtime started with `NYLORUN_HARNESS=remote` runs no harness of its own: it opens the Harness API listener (`NYLORUN_HARNESS_LISTEN_HOST`/`_PORT`, default port 4200, `NYLORUN_HARNESS_ALLOWED_HOSTS`), which accepts only the harness credential (`NYLORUN_HARNESS_TOKEN`) on `/nylorun/harness/v1`. The runtime image's `--service harness` connects to it (`NYLORUN_HARNESS_URL`, `NYLORUN_HARNESS_TOKEN`, `NYLORUN_GATES_URL`, `NYLORUN_HARNESS_ROOT`) and runs the Tenant's segments, MCP servers and sandboxes with no store; it refuses to start with a database, the gates' or keys' credential, or Restate settings, and presents only run tokens at the gates. The in-process harness stays the default.
|
|
78
|
+
|
|
79
|
+
- `@nylorun/core/harness-api`: the `workspace.*` requests core sends to a harness that serves workspaces, `tenantId` in the `hello` answer, a workspace record on `sandbox.state` claims, and `TurnStart.options.holdMs`. Tenant and admin status report the Tenant's harnesses (`harness`).
|
|
80
|
+
- `@nylorun/harness/api`: `createHarness` declares capabilities, reports grants (`onGrant`) and the `hello` answer, readies MCP through `executors.prepare` (`session.mcp`), and holds a run while its Action is pending until core sends the outcome (`effect.resolved`).
|
|
81
|
+
- `@nylorun/runtime`: the WebSocket listener and client, `--service harness`, the workspace capability (`ctx.sandbox` is a `WorkspacePort`; sandbox tool routes, `save_artifact`, sweep and reset reach the harness's workspaces), the SandboxManager's records port, and held runs (`actionHoldMs`, default 5 minutes). `save_artifact` runs in core. `NYLORUN_HARNESS_API` and the engine run in the advance are removed; tests run with `NYLORUN_TEST_HARNESS=memory|json|ws`.
|
|
82
|
+
|
|
83
|
+
- 678e085: **Pod sandboxes (F7.2, second part).** With `nylorun sandbox enable`, a sandbox resource of kind `pod` (`PUT /v1/sandboxes/{id}` with `kind: "pod"`, an `image`, `*.suffix` hosts, `storage` and `lifecycle.ttl`) is an agent-sandbox pod on the Tenant's cluster, created at once. The turns of the sessions attached to it run in the pod: the engine is copied from the Runtime image into the pod (the Runtime image now carries tini for it), waits until the pod's NetworkPolicy is in force, exchanges its join token for a host token at the Harness API listener (`POST /nylorun/harness/v1/host/join`, published for pods on the Docker host's address, with the gates), and serves its sandbox alone. New: `POST /v1/sandboxes/{id}/stop` and `/reset`; the Tenant's `limits.ttl`, `lifecycle.onExpiry`, `lifecycle.stopGrace` and `placement`; idle stop; lifecycle events `sandbox.running`, `.suspended`, `.expired`, `.relaunched`, `.lost`, `.reset` and `.failed`; error codes `placement_refused`, `sandbox_lost` and `sandbox_expired`; `cluster` in `GET /v1/tenant/sandbox`; Host feature `sandbox-pods` (additive, protocol unchanged). Without a cluster, kind `pod` is `409 sandbox_unavailable` (it was 400). Migration `0007_sandbox_pods` adds the pod lifecycle columns to `sandbox_resources`.
|
|
84
|
+
- 926711b: **Sandboxes are a resource (F7.1, blueprint D39; Host feature `sandboxes`).** A sandbox has its own id, a kind, a spec and labels, and outlives the sessions attached to it. Additive: protocol 5 is unchanged.
|
|
85
|
+
|
|
86
|
+
- `PUT /v1/sandboxes/{id}` creates a sandbox or finds the one with that id (get-or-create in one call); `GET /v1/sandboxes/{id}`, `GET /v1/sandboxes?label=key=value` (repeatable), `GET /v1/sandboxes/{id}/events` and `DELETE /v1/sandboxes/{id}`. Ids are `/`-separated segments (`team-a/proj-42`), sent percent-encoded as one path segment. Only kind `virtual` runs; `pod` is refused with `sandbox_unavailable`. The spec is resolved against the Tenant's limits and fixed once the sandbox exists; labels can change.
|
|
87
|
+
- A session attaches with `sandbox: { id }` and shares the sandbox's `/workspace` with every other session attached to it. Turns are serial per sandbox: a second session's turn is refused with `409 sandbox_busy` while another runs. Deleting a session (a sessions reset) only detaches it. Deleting a sandbox is refused while a turn runs in it; afterwards an attached session's next turn is refused with `sandbox_unavailable` until a sandbox with that id exists again.
|
|
88
|
+
- Subject tokens carry an `sbx` claim: `POST /v1/tokens` takes `sandboxes`, exact ids or prefixes ending in `/*` (at most 16). A token reaches only the sandboxes they match, checked when a session attaches and at every turn start (`403 sandbox_not_granted`); any other sandbox is the 404 of a missing one. The new scope `sandboxes:write` lets a role create and delete the sandboxes its grants reach. Application keys reach every sandbox.
|
|
89
|
+
- The Tenant holds at most `limits.sandboxes` sandboxes (`PUT /v1/tenant/sandbox`, default 100); one more is `409 limit_exceeded`.
|
|
90
|
+
- Lifecycle events (`sandbox.created`, `sandbox.attached`, `sandbox.detached`, `sandbox.deleted`) go to the sandbox's own stream in the record, through the record module; the session's log records `sandbox.attached`. The sandbox stream is not relayed to S2.
|
|
91
|
+
- New error codes `sandbox_not_granted`, `sandbox_busy` and `sandbox_unavailable`; the session view gains `sandboxId` and `sandboxSource: "sandbox"`. Migration `0004_sandbox_resources` adds `sandbox_resources`, `nylorun_streams.sandbox_events` and the sessions' `sandbox_id` column.
|
|
92
|
+
- `@nylorun/agents`: `client.sandboxes` with `ensure(id, spec)`, `get`, `list({ labels })`, `delete`, `events`, and `forSession({ session, spec })`, which creates a sandbox for one session, opens the session on it, and deletes it with `release()`. It replaces sharing through another session (`sandbox: { session }` and the view's `sandboxOwnerId`, now deprecated). `client.tokens.create` takes `sandboxes`.
|
|
93
|
+
- `nylorun sandbox ls [--label key=value]... [--json]` and `nylorun sandbox rm <id>` list and delete the running local Tenant's sandboxes.
|
|
94
|
+
|
|
3
95
|
## 0.11.0-beta
|
|
4
96
|
|
|
5
97
|
### Minor Changes
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
2
|
/**
|
|
3
|
-
* Protocol
|
|
4
|
-
* `Nylorun-
|
|
3
|
+
* Protocol 7: open-source auth (F9 I3). Subject tokens (`POST /v1/tokens`), the access policy,
|
|
4
|
+
* revocations, browser keys (`Nylorun-Key`), the Runtime's own CORS and derived principals are gone; their
|
|
5
|
+
* routes answer 404. Browsers and apps present a trusted issuer's token, servers an operator key.
|
|
6
|
+
* Protocol 6: file artifacts (`/v1/artifacts/**`, Runtime-signed capability links) and user
|
|
7
|
+
* messages with `parts`. Protocol 5: a Host serves one Tenant, and nothing in a request selects
|
|
8
|
+
* it. The Host still accepts protocol 4 (and `Nylorun-Tenant`), 5 and 6 clients on every route
|
|
9
|
+
* that remains.
|
|
5
10
|
*/
|
|
6
|
-
export declare const PROTOCOL_VERSION =
|
|
11
|
+
export declare const PROTOCOL_VERSION = 7;
|
|
7
12
|
/** What a client of this protocol requires of a Host. */
|
|
8
|
-
export declare const PROTOCOL_FEATURES: readonly ["admin-status", "studio-principal", "action-endpoints"];
|
|
13
|
+
export declare const PROTOCOL_FEATURES: readonly ["admin-status", "studio-principal", "action-endpoints", "artifacts"];
|
|
9
14
|
export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
|
|
10
15
|
/**
|
|
11
16
|
* Host features no client requires: a client that uses one checks the Host's `/health`
|
|
12
17
|
* for it first. `tenant-fixture-model`: `PUT /v1/tenant/config/seed` accepts
|
|
13
18
|
* `fixtureModel: true` (the Tenant's model calls use the Runtime's fixture model).
|
|
14
19
|
* `transcript-events`: the log carries `message.assistant` and `tool.completed`, and
|
|
15
|
-
* tool `action.*` events carry `callId` and `invocationId`. `
|
|
16
|
-
* registers the derived principals it is configured with (`NYLORUN_DERIVED_PRINCIPALS`,
|
|
17
|
-
* default `project`) on its Tenant, whose keys the admin key derives. `subject-headers`: an application
|
|
20
|
+
* tool `action.*` events carry `callId` and `invocationId`. `subject-headers`: an application
|
|
18
21
|
* principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
|
|
19
|
-
* enforces the scopes and the subject's ownership of sessions
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* policy, signing keys and revocations). `browser-access`: publishable keys
|
|
23
|
-
* (`Nylorun-Key`, `/v1/access/publishable-keys`) name the Tenant and an origin allowlist, and
|
|
24
|
-
* browser requests from listed origins reach the Tenant routes with CORS. `ag-ui-endpoint`:
|
|
25
|
-
* the Runtime serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a subject token
|
|
26
|
-
* or by subject headers. `a2a-endpoint`:
|
|
22
|
+
* enforces the scopes and the subject's ownership of sessions. `ag-ui-endpoint`: the Runtime
|
|
23
|
+
* serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a trusted issuer's token or
|
|
24
|
+
* by subject headers. `a2a-endpoint`:
|
|
27
25
|
* `POST /v1/a2a/agents/:agent` answers A2A 1.0 JSON-RPC for a subject, and
|
|
28
26
|
* `GET /v1/a2a/agents/:agent/card` returns the agent's card without its interfaces.
|
|
29
27
|
* `action-endpoints`: `PUT`/`GET`/`DELETE /v1/endpoints` register the URL that runs each agent's
|
|
30
28
|
* Actions, and the Runtime delivers them there, signed with a delivery token
|
|
31
|
-
* (`Nylorun-Signature`), instead of offering them to executors.
|
|
29
|
+
* (`Nylorun-Signature`), instead of offering them to executors. `sandboxes`: sandboxes are a
|
|
30
|
+
* resource (`PUT`/`GET`/`DELETE /v1/sandboxes/{id}`, kind `virtual`), a session attaches to one
|
|
31
|
+
* with `sandbox: { id }`, a token caller (a trusted issuer's token) carries sandbox grants
|
|
32
|
+
* checked at every turn start, and `sandboxes:write` lets a subject create and delete the
|
|
33
|
+
* sandboxes it is granted.
|
|
34
|
+
* `sandbox-pods`: kind `pod` runs as an agent-sandbox pod on the Tenant's cluster (`nylorun
|
|
35
|
+
* sandbox enable`), with `POST /v1/sandboxes/{id}/stop` and `/reset`, a TTL
|
|
36
|
+
* (`lifecycle.ttl`), lifecycle events (`sandbox.running`, `.suspended`, `.expired`,
|
|
37
|
+
* `.relaunched`, `.lost`, `.reset`, `.failed`) and the Tenant's `placement`.
|
|
38
|
+
* `trusted-issuers`: the Tenant API accepts JWTs from the issuers of the Host's identity file
|
|
39
|
+
* (`NYLORUN_IDENTITY_FILE`) as bearers, from servers and from browsers alike, with the
|
|
40
|
+
* issuer's subject, scopes (and the issuer-only `studio`), agents and sandbox grants; `GET
|
|
41
|
+
* /v1/me` reports who any credential is.
|
|
42
|
+
* `operator-keys`: the Admin API creates, rotates, lists and deletes the Tenant's application
|
|
43
|
+
* keys by name (`PUT`/`GET`/`DELETE /v1/admin/keys`); a deleted or rotated key stops
|
|
44
|
+
* authenticating at once. `studio` is not managed there.
|
|
32
45
|
*/
|
|
33
|
-
export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "transcript-events", "
|
|
46
|
+
export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "transcript-events", "subject-headers", "ag-ui-endpoint", "a2a-endpoint", "action-endpoints", "sandboxes", "sandbox-pods", "trusted-issuers", "operator-keys"];
|
|
34
47
|
export type OptionalHostFeature = (typeof OPTIONAL_HOST_FEATURES)[number];
|
|
35
48
|
export interface ProtocolRange {
|
|
36
49
|
min: number;
|
|
@@ -39,7 +52,9 @@ export interface ProtocolRange {
|
|
|
39
52
|
}
|
|
40
53
|
/**
|
|
41
54
|
* What this Host serves. `runtime-tenants` (protocol 4 clients require it) is still advertised
|
|
42
|
-
* for the compatibility window; protocol 5 clients no longer require it.
|
|
55
|
+
* for the compatibility window; protocol 5 and later clients no longer require it. `artifacts`
|
|
56
|
+
* (protocol 6 and 7, required by their clients): file artifacts, capability links and message
|
|
57
|
+
* `parts`.
|
|
43
58
|
*/
|
|
44
59
|
export declare const HOST_PROTOCOL: ProtocolRange;
|
|
45
60
|
export declare const DEFINITION_SCHEMA_VERSION = 2;
|
|
@@ -53,8 +68,6 @@ export declare const PROTOCOL_HEADER = "Nylorun-Protocol";
|
|
|
53
68
|
export declare const SUBJECT_HEADER = "Nylorun-Subject";
|
|
54
69
|
/** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
|
|
55
70
|
export declare const SCOPES_HEADER = "Nylorun-Scopes";
|
|
56
|
-
/** A publishable key: names the client app, and its Tenant (Host feature `browser-access`). */
|
|
57
|
-
export declare const PUBLISHABLE_KEY_HEADER = "Nylorun-Key";
|
|
58
71
|
/** The delivery token on a request the Runtime sends to an Action endpoint. */
|
|
59
72
|
export declare const SIGNATURE_HEADER = "Nylorun-Signature";
|
|
60
73
|
/** Set to `1` on an Action endpoint's response whose body is a tagged `ActionOutcome`. */
|
|
@@ -65,20 +78,45 @@ export declare const ERROR_CODES: readonly ["not_found", "protocol_unsupported",
|
|
|
65
78
|
/** A request the Host could not read: headers, body or query. */
|
|
66
79
|
"invalid_request",
|
|
67
80
|
/** A route that acts for a person was called without one (`Nylorun-Subject`). */
|
|
68
|
-
"subject_required",
|
|
81
|
+
"subject_required",
|
|
82
|
+
/** A token caller's sandbox grants do not reach the sandbox (Host feature `sandboxes`). */
|
|
83
|
+
"sandbox_not_granted",
|
|
84
|
+
/** Another session's turn holds the sandbox: turns are serial per sandbox. */
|
|
85
|
+
"sandbox_busy",
|
|
86
|
+
/** The sandbox is gone, or its kind cannot run on this Runtime. */
|
|
87
|
+
"sandbox_unavailable",
|
|
88
|
+
/** The Tenant's placement keeps this session's harness off the host its sandbox needs. */
|
|
89
|
+
"placement_refused",
|
|
90
|
+
/** A pod sandbox's volume or node is gone: only `POST /v1/sandboxes/{id}/reset` brings it back. */
|
|
91
|
+
"sandbox_lost",
|
|
92
|
+
/** A pod sandbox passed its TTL: a `PUT` with a longer `lifecycle.ttl` revives it. */
|
|
93
|
+
"sandbox_expired",
|
|
94
|
+
/**
|
|
95
|
+
* A trusted issuer's token names a key the Runtime has not seen, and the issuer's JWKS cannot
|
|
96
|
+
* be fetched now (Host feature `trusted-issuers`): retry later. Keys already fetched keep working.
|
|
97
|
+
*/
|
|
98
|
+
"issuer_unavailable",
|
|
99
|
+
/**
|
|
100
|
+
* An MCP OAuth connect found no way to identify this installation to the authorization server:
|
|
101
|
+
* it offers no dynamic client registration and no client id was given (F9 C2).
|
|
102
|
+
*/
|
|
103
|
+
"oauth_client_required",
|
|
104
|
+
/** An OAuth callback's `state` is unknown, already used or expired: start the connect again. */
|
|
105
|
+
"oauth_state_invalid",
|
|
106
|
+
/** The authorization server (or its discovery) failed or refused an MCP OAuth connect step. */
|
|
107
|
+
"oauth_failed", "internal_error"];
|
|
69
108
|
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
70
109
|
export declare const TENANT_ID_PATTERN: RegExp;
|
|
71
110
|
export declare const PRINCIPAL_ID_PATTERN: RegExp;
|
|
72
|
-
/** A Tenant signing key's id, the `kid` of the
|
|
111
|
+
/** A Tenant signing key's id, the `kid` of the tokens it signs (delivery tokens, capability links). */
|
|
73
112
|
export declare const SIGNING_KEY_ID_PATTERN: RegExp;
|
|
74
|
-
/** A
|
|
75
|
-
export declare const
|
|
76
|
-
/**
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
export declare const DERIVED_PRINCIPAL_ID_PATTERN: RegExp;
|
|
113
|
+
/** A file artifact's id (protocol 6). */
|
|
114
|
+
export declare const ARTIFACT_ID_PATTERN: RegExp;
|
|
115
|
+
/**
|
|
116
|
+
* An application key's id: an operator key's name, which names its client (e.g. `backend`).
|
|
117
|
+
* `studio` is reserved for the key Studio derives from the admin key.
|
|
118
|
+
*/
|
|
119
|
+
export declare const APPLICATION_KEY_ID_PATTERN: RegExp;
|
|
82
120
|
export declare function isTenantId(value: unknown): value is string;
|
|
83
121
|
export declare function isPrincipalId(value: unknown): value is string;
|
|
84
122
|
/**
|
|
@@ -91,10 +129,9 @@ export declare function newTenantId(now?: number): string;
|
|
|
91
129
|
export declare function newPrincipalId(now?: number): string;
|
|
92
130
|
/** Signing key id: `sk_` + lowercase Crockford ULID (same generator as tenants). */
|
|
93
131
|
export declare function newSigningKeyId(now?: number): string;
|
|
94
|
-
/**
|
|
95
|
-
export declare function
|
|
96
|
-
|
|
97
|
-
export declare function newPublishableKey(tenantId: string): string;
|
|
132
|
+
/** Artifact id: `af_` + lowercase Crockford ULID. */
|
|
133
|
+
export declare function newArtifactId(now?: number): string;
|
|
134
|
+
export declare function isArtifactId(value: unknown): value is string;
|
|
98
135
|
/**
|
|
99
136
|
* SemVer 2.0 precedence, including prereleases. Build metadata is ignored.
|
|
100
137
|
* Returns -1 when a < b, 0 when equal, 1 when a > b.
|
package/dist/compatibility.js
CHANGED
|
@@ -1,56 +1,73 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
2
|
/**
|
|
3
|
-
* Protocol
|
|
4
|
-
* `Nylorun-
|
|
3
|
+
* Protocol 7: open-source auth (F9 I3). Subject tokens (`POST /v1/tokens`), the access policy,
|
|
4
|
+
* revocations, browser keys (`Nylorun-Key`), the Runtime's own CORS and derived principals are gone; their
|
|
5
|
+
* routes answer 404. Browsers and apps present a trusted issuer's token, servers an operator key.
|
|
6
|
+
* Protocol 6: file artifacts (`/v1/artifacts/**`, Runtime-signed capability links) and user
|
|
7
|
+
* messages with `parts`. Protocol 5: a Host serves one Tenant, and nothing in a request selects
|
|
8
|
+
* it. The Host still accepts protocol 4 (and `Nylorun-Tenant`), 5 and 6 clients on every route
|
|
9
|
+
* that remains.
|
|
5
10
|
*/
|
|
6
|
-
export const PROTOCOL_VERSION =
|
|
11
|
+
export const PROTOCOL_VERSION = 7;
|
|
7
12
|
/** What a client of this protocol requires of a Host. */
|
|
8
13
|
export const PROTOCOL_FEATURES = [
|
|
9
14
|
"admin-status",
|
|
10
15
|
"studio-principal",
|
|
11
16
|
"action-endpoints",
|
|
17
|
+
"artifacts",
|
|
12
18
|
];
|
|
13
19
|
/**
|
|
14
20
|
* Host features no client requires: a client that uses one checks the Host's `/health`
|
|
15
21
|
* for it first. `tenant-fixture-model`: `PUT /v1/tenant/config/seed` accepts
|
|
16
22
|
* `fixtureModel: true` (the Tenant's model calls use the Runtime's fixture model).
|
|
17
23
|
* `transcript-events`: the log carries `message.assistant` and `tool.completed`, and
|
|
18
|
-
* tool `action.*` events carry `callId` and `invocationId`. `
|
|
19
|
-
* registers the derived principals it is configured with (`NYLORUN_DERIVED_PRINCIPALS`,
|
|
20
|
-
* default `project`) on its Tenant, whose keys the admin key derives. `subject-headers`: an application
|
|
24
|
+
* tool `action.*` events carry `callId` and `invocationId`. `subject-headers`: an application
|
|
21
25
|
* principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
|
|
22
|
-
* enforces the scopes and the subject's ownership of sessions
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* policy, signing keys and revocations). `browser-access`: publishable keys
|
|
26
|
-
* (`Nylorun-Key`, `/v1/access/publishable-keys`) name the Tenant and an origin allowlist, and
|
|
27
|
-
* browser requests from listed origins reach the Tenant routes with CORS. `ag-ui-endpoint`:
|
|
28
|
-
* the Runtime serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a subject token
|
|
29
|
-
* or by subject headers. `a2a-endpoint`:
|
|
26
|
+
* enforces the scopes and the subject's ownership of sessions. `ag-ui-endpoint`: the Runtime
|
|
27
|
+
* serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a trusted issuer's token or
|
|
28
|
+
* by subject headers. `a2a-endpoint`:
|
|
30
29
|
* `POST /v1/a2a/agents/:agent` answers A2A 1.0 JSON-RPC for a subject, and
|
|
31
30
|
* `GET /v1/a2a/agents/:agent/card` returns the agent's card without its interfaces.
|
|
32
31
|
* `action-endpoints`: `PUT`/`GET`/`DELETE /v1/endpoints` register the URL that runs each agent's
|
|
33
32
|
* Actions, and the Runtime delivers them there, signed with a delivery token
|
|
34
|
-
* (`Nylorun-Signature`), instead of offering them to executors.
|
|
33
|
+
* (`Nylorun-Signature`), instead of offering them to executors. `sandboxes`: sandboxes are a
|
|
34
|
+
* resource (`PUT`/`GET`/`DELETE /v1/sandboxes/{id}`, kind `virtual`), a session attaches to one
|
|
35
|
+
* with `sandbox: { id }`, a token caller (a trusted issuer's token) carries sandbox grants
|
|
36
|
+
* checked at every turn start, and `sandboxes:write` lets a subject create and delete the
|
|
37
|
+
* sandboxes it is granted.
|
|
38
|
+
* `sandbox-pods`: kind `pod` runs as an agent-sandbox pod on the Tenant's cluster (`nylorun
|
|
39
|
+
* sandbox enable`), with `POST /v1/sandboxes/{id}/stop` and `/reset`, a TTL
|
|
40
|
+
* (`lifecycle.ttl`), lifecycle events (`sandbox.running`, `.suspended`, `.expired`,
|
|
41
|
+
* `.relaunched`, `.lost`, `.reset`, `.failed`) and the Tenant's `placement`.
|
|
42
|
+
* `trusted-issuers`: the Tenant API accepts JWTs from the issuers of the Host's identity file
|
|
43
|
+
* (`NYLORUN_IDENTITY_FILE`) as bearers, from servers and from browsers alike, with the
|
|
44
|
+
* issuer's subject, scopes (and the issuer-only `studio`), agents and sandbox grants; `GET
|
|
45
|
+
* /v1/me` reports who any credential is.
|
|
46
|
+
* `operator-keys`: the Admin API creates, rotates, lists and deletes the Tenant's application
|
|
47
|
+
* keys by name (`PUT`/`GET`/`DELETE /v1/admin/keys`); a deleted or rotated key stops
|
|
48
|
+
* authenticating at once. `studio` is not managed there.
|
|
35
49
|
*/
|
|
36
50
|
export const OPTIONAL_HOST_FEATURES = [
|
|
37
51
|
"tenant-fixture-model",
|
|
38
52
|
"transcript-events",
|
|
39
|
-
"derived-principals",
|
|
40
53
|
"subject-headers",
|
|
41
|
-
"subject-tokens",
|
|
42
|
-
"browser-access",
|
|
43
54
|
"ag-ui-endpoint",
|
|
44
55
|
"a2a-endpoint",
|
|
45
56
|
"action-endpoints",
|
|
57
|
+
"sandboxes",
|
|
58
|
+
"sandbox-pods",
|
|
59
|
+
"trusted-issuers",
|
|
60
|
+
"operator-keys",
|
|
46
61
|
];
|
|
47
62
|
/**
|
|
48
63
|
* What this Host serves. `runtime-tenants` (protocol 4 clients require it) is still advertised
|
|
49
|
-
* for the compatibility window; protocol 5 clients no longer require it.
|
|
64
|
+
* for the compatibility window; protocol 5 and later clients no longer require it. `artifacts`
|
|
65
|
+
* (protocol 6 and 7, required by their clients): file artifacts, capability links and message
|
|
66
|
+
* `parts`.
|
|
50
67
|
*/
|
|
51
68
|
export const HOST_PROTOCOL = {
|
|
52
69
|
min: 4,
|
|
53
|
-
max:
|
|
70
|
+
max: 7,
|
|
54
71
|
features: ["runtime-tenants", ...PROTOCOL_FEATURES, ...OPTIONAL_HOST_FEATURES],
|
|
55
72
|
};
|
|
56
73
|
export const DEFINITION_SCHEMA_VERSION = 2;
|
|
@@ -64,8 +81,6 @@ export const PROTOCOL_HEADER = "Nylorun-Protocol";
|
|
|
64
81
|
export const SUBJECT_HEADER = "Nylorun-Subject";
|
|
65
82
|
/** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
|
|
66
83
|
export const SCOPES_HEADER = "Nylorun-Scopes";
|
|
67
|
-
/** A publishable key: names the client app, and its Tenant (Host feature `browser-access`). */
|
|
68
|
-
export const PUBLISHABLE_KEY_HEADER = "Nylorun-Key";
|
|
69
84
|
/** The delivery token on a request the Runtime sends to an Action endpoint. */
|
|
70
85
|
export const SIGNATURE_HEADER = "Nylorun-Signature";
|
|
71
86
|
/** Set to `1` on an Action endpoint's response whose body is a tagged `ActionOutcome`. */
|
|
@@ -88,26 +103,47 @@ export const ERROR_CODES = [
|
|
|
88
103
|
"invalid_request",
|
|
89
104
|
/** A route that acts for a person was called without one (`Nylorun-Subject`). */
|
|
90
105
|
"subject_required",
|
|
106
|
+
/** A token caller's sandbox grants do not reach the sandbox (Host feature `sandboxes`). */
|
|
107
|
+
"sandbox_not_granted",
|
|
108
|
+
/** Another session's turn holds the sandbox: turns are serial per sandbox. */
|
|
109
|
+
"sandbox_busy",
|
|
110
|
+
/** The sandbox is gone, or its kind cannot run on this Runtime. */
|
|
111
|
+
"sandbox_unavailable",
|
|
112
|
+
/** The Tenant's placement keeps this session's harness off the host its sandbox needs. */
|
|
113
|
+
"placement_refused",
|
|
114
|
+
/** A pod sandbox's volume or node is gone: only `POST /v1/sandboxes/{id}/reset` brings it back. */
|
|
115
|
+
"sandbox_lost",
|
|
116
|
+
/** A pod sandbox passed its TTL: a `PUT` with a longer `lifecycle.ttl` revives it. */
|
|
117
|
+
"sandbox_expired",
|
|
118
|
+
/**
|
|
119
|
+
* A trusted issuer's token names a key the Runtime has not seen, and the issuer's JWKS cannot
|
|
120
|
+
* be fetched now (Host feature `trusted-issuers`): retry later. Keys already fetched keep working.
|
|
121
|
+
*/
|
|
122
|
+
"issuer_unavailable",
|
|
123
|
+
/**
|
|
124
|
+
* An MCP OAuth connect found no way to identify this installation to the authorization server:
|
|
125
|
+
* it offers no dynamic client registration and no client id was given (F9 C2).
|
|
126
|
+
*/
|
|
127
|
+
"oauth_client_required",
|
|
128
|
+
/** An OAuth callback's `state` is unknown, already used or expired: start the connect again. */
|
|
129
|
+
"oauth_state_invalid",
|
|
130
|
+
/** The authorization server (or its discovery) failed or refused an MCP OAuth connect step. */
|
|
131
|
+
"oauth_failed",
|
|
91
132
|
"internal_error",
|
|
92
133
|
];
|
|
93
134
|
/** Crockford Base32 alphabet (lowercase); excludes i, l, o, u. */
|
|
94
135
|
const CROCKFORD = "0123456789abcdefghjkmnpqrstvwxyz";
|
|
95
136
|
export const TENANT_ID_PATTERN = /^tn_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
96
137
|
export const PRINCIPAL_ID_PATTERN = /^pr_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
97
|
-
/** A Tenant signing key's id, the `kid` of the
|
|
138
|
+
/** A Tenant signing key's id, the `kid` of the tokens it signs (delivery tokens, capability links). */
|
|
98
139
|
export const SIGNING_KEY_ID_PATTERN = /^sk_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
99
|
-
/** A
|
|
100
|
-
export const
|
|
101
|
-
/**
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return undefined;
|
|
107
|
-
return PUBLISHABLE_KEY_PATTERN.exec(value)?.[1];
|
|
108
|
-
}
|
|
109
|
-
/** A derived principal's id names its client, e.g. `babai`; `studio` is reserved. */
|
|
110
|
-
export const DERIVED_PRINCIPAL_ID_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
140
|
+
/** A file artifact's id (protocol 6). */
|
|
141
|
+
export const ARTIFACT_ID_PATTERN = /^af_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
142
|
+
/**
|
|
143
|
+
* An application key's id: an operator key's name, which names its client (e.g. `backend`).
|
|
144
|
+
* `studio` is reserved for the key Studio derives from the admin key.
|
|
145
|
+
*/
|
|
146
|
+
export const APPLICATION_KEY_ID_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
111
147
|
export function isTenantId(value) {
|
|
112
148
|
return typeof value === "string" && TENANT_ID_PATTERN.test(value);
|
|
113
149
|
}
|
|
@@ -173,18 +209,12 @@ export function newPrincipalId(now) {
|
|
|
173
209
|
export function newSigningKeyId(now) {
|
|
174
210
|
return newPrefixedId("sk_", now);
|
|
175
211
|
}
|
|
176
|
-
/**
|
|
177
|
-
export function
|
|
178
|
-
return newPrefixedId("
|
|
212
|
+
/** Artifact id: `af_` + lowercase Crockford ULID. */
|
|
213
|
+
export function newArtifactId(now) {
|
|
214
|
+
return newPrefixedId("af_", now);
|
|
179
215
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
if (!isTenantId(tenantId))
|
|
183
|
-
throw new Error(`Invalid Tenant id ${tenantId}`);
|
|
184
|
-
let random = "";
|
|
185
|
-
while (random.length < 32)
|
|
186
|
-
random += encodeRandom();
|
|
187
|
-
return `nr_pub_${tenantId}_${random.slice(0, 32)}`;
|
|
216
|
+
export function isArtifactId(value) {
|
|
217
|
+
return typeof value === "string" && ARTIFACT_ID_PATTERN.test(value);
|
|
188
218
|
}
|
|
189
219
|
function parseSemVer(version) {
|
|
190
220
|
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);
|