@nylorun/core 0.12.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 +45 -0
- package/dist/compatibility.d.ts +47 -37
- package/dist/compatibility.js +48 -52
- package/dist/contracts.d.ts +132 -228
- package/dist/contracts.js +147 -190
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,50 @@
|
|
|
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
|
+
|
|
3
48
|
## 0.12.0-beta
|
|
4
49
|
|
|
5
50
|
### Major Changes
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
2
|
/**
|
|
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.
|
|
3
6
|
* Protocol 6: file artifacts (`/v1/artifacts/**`, Runtime-signed capability links) and user
|
|
4
|
-
* messages with `parts
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
7
10
|
*/
|
|
8
|
-
export declare const PROTOCOL_VERSION =
|
|
11
|
+
export declare const PROTOCOL_VERSION = 7;
|
|
9
12
|
/** What a client of this protocol requires of a Host. */
|
|
10
13
|
export declare const PROTOCOL_FEATURES: readonly ["admin-status", "studio-principal", "action-endpoints", "artifacts"];
|
|
11
14
|
export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
|
|
@@ -14,32 +17,33 @@ export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
|
|
|
14
17
|
* for it first. `tenant-fixture-model`: `PUT /v1/tenant/config/seed` accepts
|
|
15
18
|
* `fixtureModel: true` (the Tenant's model calls use the Runtime's fixture model).
|
|
16
19
|
* `transcript-events`: the log carries `message.assistant` and `tool.completed`, and
|
|
17
|
-
* tool `action.*` events carry `callId` and `invocationId`. `
|
|
18
|
-
* registers the derived principals it is configured with (`NYLORUN_DERIVED_PRINCIPALS`,
|
|
19
|
-
* 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
|
|
20
21
|
* principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
|
|
21
|
-
* enforces the scopes and the subject's ownership of sessions
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* policy, signing keys and revocations). `browser-access`: publishable keys
|
|
25
|
-
* (`Nylorun-Key`, `/v1/access/publishable-keys`) name the Tenant and an origin allowlist, and
|
|
26
|
-
* browser requests from listed origins reach the Tenant routes with CORS. `ag-ui-endpoint`:
|
|
27
|
-
* the Runtime serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a subject token
|
|
28
|
-
* 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`:
|
|
29
25
|
* `POST /v1/a2a/agents/:agent` answers A2A 1.0 JSON-RPC for a subject, and
|
|
30
26
|
* `GET /v1/a2a/agents/:agent/card` returns the agent's card without its interfaces.
|
|
31
27
|
* `action-endpoints`: `PUT`/`GET`/`DELETE /v1/endpoints` register the URL that runs each agent's
|
|
32
28
|
* Actions, and the Runtime delivers them there, signed with a delivery token
|
|
33
29
|
* (`Nylorun-Signature`), instead of offering them to executors. `sandboxes`: sandboxes are a
|
|
34
30
|
* resource (`PUT`/`GET`/`DELETE /v1/sandboxes/{id}`, kind `virtual`), a session attaches to one
|
|
35
|
-
* with `sandbox: { id }`,
|
|
36
|
-
* `sandboxes:write` lets a subject create and delete the
|
|
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.
|
|
37
34
|
* `sandbox-pods`: kind `pod` runs as an agent-sandbox pod on the Tenant's cluster (`nylorun
|
|
38
35
|
* sandbox enable`), with `POST /v1/sandboxes/{id}/stop` and `/reset`, a TTL
|
|
39
36
|
* (`lifecycle.ttl`), lifecycle events (`sandbox.running`, `.suspended`, `.expired`,
|
|
40
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.
|
|
41
45
|
*/
|
|
42
|
-
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"];
|
|
43
47
|
export type OptionalHostFeature = (typeof OPTIONAL_HOST_FEATURES)[number];
|
|
44
48
|
export interface ProtocolRange {
|
|
45
49
|
min: number;
|
|
@@ -48,8 +52,9 @@ export interface ProtocolRange {
|
|
|
48
52
|
}
|
|
49
53
|
/**
|
|
50
54
|
* What this Host serves. `runtime-tenants` (protocol 4 clients require it) is still advertised
|
|
51
|
-
* for the compatibility window; protocol 5 and
|
|
52
|
-
* (protocol 6, required by
|
|
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`.
|
|
53
58
|
*/
|
|
54
59
|
export declare const HOST_PROTOCOL: ProtocolRange;
|
|
55
60
|
export declare const DEFINITION_SCHEMA_VERSION = 2;
|
|
@@ -63,8 +68,6 @@ export declare const PROTOCOL_HEADER = "Nylorun-Protocol";
|
|
|
63
68
|
export declare const SUBJECT_HEADER = "Nylorun-Subject";
|
|
64
69
|
/** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
|
|
65
70
|
export declare const SCOPES_HEADER = "Nylorun-Scopes";
|
|
66
|
-
/** A publishable key: names the client app, and its Tenant (Host feature `browser-access`). */
|
|
67
|
-
export declare const PUBLISHABLE_KEY_HEADER = "Nylorun-Key";
|
|
68
71
|
/** The delivery token on a request the Runtime sends to an Action endpoint. */
|
|
69
72
|
export declare const SIGNATURE_HEADER = "Nylorun-Signature";
|
|
70
73
|
/** Set to `1` on an Action endpoint's response whose body is a tagged `ActionOutcome`. */
|
|
@@ -76,7 +79,7 @@ export declare const ERROR_CODES: readonly ["not_found", "protocol_unsupported",
|
|
|
76
79
|
"invalid_request",
|
|
77
80
|
/** A route that acts for a person was called without one (`Nylorun-Subject`). */
|
|
78
81
|
"subject_required",
|
|
79
|
-
/** A
|
|
82
|
+
/** A token caller's sandbox grants do not reach the sandbox (Host feature `sandboxes`). */
|
|
80
83
|
"sandbox_not_granted",
|
|
81
84
|
/** Another session's turn holds the sandbox: turns are serial per sandbox. */
|
|
82
85
|
"sandbox_busy",
|
|
@@ -87,22 +90,33 @@ export declare const ERROR_CODES: readonly ["not_found", "protocol_unsupported",
|
|
|
87
90
|
/** A pod sandbox's volume or node is gone: only `POST /v1/sandboxes/{id}/reset` brings it back. */
|
|
88
91
|
"sandbox_lost",
|
|
89
92
|
/** A pod sandbox passed its TTL: a `PUT` with a longer `lifecycle.ttl` revives it. */
|
|
90
|
-
"sandbox_expired",
|
|
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"];
|
|
91
108
|
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
92
109
|
export declare const TENANT_ID_PATTERN: RegExp;
|
|
93
110
|
export declare const PRINCIPAL_ID_PATTERN: RegExp;
|
|
94
|
-
/** 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). */
|
|
95
112
|
export declare const SIGNING_KEY_ID_PATTERN: RegExp;
|
|
96
|
-
/** A publishable key's id (not the key). */
|
|
97
|
-
export declare const PUBLISHABLE_KEY_ID_PATTERN: RegExp;
|
|
98
113
|
/** A file artifact's id (protocol 6). */
|
|
99
114
|
export declare const ARTIFACT_ID_PATTERN: RegExp;
|
|
100
|
-
/**
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
export declare const DERIVED_PRINCIPAL_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;
|
|
106
120
|
export declare function isTenantId(value: unknown): value is string;
|
|
107
121
|
export declare function isPrincipalId(value: unknown): value is string;
|
|
108
122
|
/**
|
|
@@ -115,13 +129,9 @@ export declare function newTenantId(now?: number): string;
|
|
|
115
129
|
export declare function newPrincipalId(now?: number): string;
|
|
116
130
|
/** Signing key id: `sk_` + lowercase Crockford ULID (same generator as tenants). */
|
|
117
131
|
export declare function newSigningKeyId(now?: number): string;
|
|
118
|
-
/** Publishable key id: `pk_` + lowercase Crockford ULID. */
|
|
119
|
-
export declare function newPublishableKeyId(now?: number): string;
|
|
120
132
|
/** Artifact id: `af_` + lowercase Crockford ULID. */
|
|
121
133
|
export declare function newArtifactId(now?: number): string;
|
|
122
134
|
export declare function isArtifactId(value: unknown): value is string;
|
|
123
|
-
/** A new publishable key for `tenantId`: 160 random bits after the Tenant id. */
|
|
124
|
-
export declare function newPublishableKey(tenantId: string): string;
|
|
125
135
|
/**
|
|
126
136
|
* SemVer 2.0 precedence, including prereleases. Build metadata is ignored.
|
|
127
137
|
* Returns -1 when a < b, 0 when equal, 1 when a > b.
|
package/dist/compatibility.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
2
|
/**
|
|
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.
|
|
3
6
|
* Protocol 6: file artifacts (`/v1/artifacts/**`, Runtime-signed capability links) and user
|
|
4
|
-
* messages with `parts
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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.
|
|
7
10
|
*/
|
|
8
|
-
export const PROTOCOL_VERSION =
|
|
11
|
+
export const PROTOCOL_VERSION = 7;
|
|
9
12
|
/** What a client of this protocol requires of a Host. */
|
|
10
13
|
export const PROTOCOL_FEATURES = [
|
|
11
14
|
"admin-status",
|
|
@@ -18,52 +21,53 @@ export const PROTOCOL_FEATURES = [
|
|
|
18
21
|
* for it first. `tenant-fixture-model`: `PUT /v1/tenant/config/seed` accepts
|
|
19
22
|
* `fixtureModel: true` (the Tenant's model calls use the Runtime's fixture model).
|
|
20
23
|
* `transcript-events`: the log carries `message.assistant` and `tool.completed`, and
|
|
21
|
-
* tool `action.*` events carry `callId` and `invocationId`. `
|
|
22
|
-
* registers the derived principals it is configured with (`NYLORUN_DERIVED_PRINCIPALS`,
|
|
23
|
-
* 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
|
|
24
25
|
* principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
|
|
25
|
-
* enforces the scopes and the subject's ownership of sessions
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* policy, signing keys and revocations). `browser-access`: publishable keys
|
|
29
|
-
* (`Nylorun-Key`, `/v1/access/publishable-keys`) name the Tenant and an origin allowlist, and
|
|
30
|
-
* browser requests from listed origins reach the Tenant routes with CORS. `ag-ui-endpoint`:
|
|
31
|
-
* the Runtime serves AG-UI at `/v1/ag-ui/agents/:agent` for a person named by a subject token
|
|
32
|
-
* 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`:
|
|
33
29
|
* `POST /v1/a2a/agents/:agent` answers A2A 1.0 JSON-RPC for a subject, and
|
|
34
30
|
* `GET /v1/a2a/agents/:agent/card` returns the agent's card without its interfaces.
|
|
35
31
|
* `action-endpoints`: `PUT`/`GET`/`DELETE /v1/endpoints` register the URL that runs each agent's
|
|
36
32
|
* Actions, and the Runtime delivers them there, signed with a delivery token
|
|
37
33
|
* (`Nylorun-Signature`), instead of offering them to executors. `sandboxes`: sandboxes are a
|
|
38
34
|
* resource (`PUT`/`GET`/`DELETE /v1/sandboxes/{id}`, kind `virtual`), a session attaches to one
|
|
39
|
-
* with `sandbox: { id }`,
|
|
40
|
-
* `sandboxes:write` lets a subject create and delete the
|
|
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.
|
|
41
38
|
* `sandbox-pods`: kind `pod` runs as an agent-sandbox pod on the Tenant's cluster (`nylorun
|
|
42
39
|
* sandbox enable`), with `POST /v1/sandboxes/{id}/stop` and `/reset`, a TTL
|
|
43
40
|
* (`lifecycle.ttl`), lifecycle events (`sandbox.running`, `.suspended`, `.expired`,
|
|
44
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.
|
|
45
49
|
*/
|
|
46
50
|
export const OPTIONAL_HOST_FEATURES = [
|
|
47
51
|
"tenant-fixture-model",
|
|
48
52
|
"transcript-events",
|
|
49
|
-
"derived-principals",
|
|
50
53
|
"subject-headers",
|
|
51
|
-
"subject-tokens",
|
|
52
|
-
"browser-access",
|
|
53
54
|
"ag-ui-endpoint",
|
|
54
55
|
"a2a-endpoint",
|
|
55
56
|
"action-endpoints",
|
|
56
57
|
"sandboxes",
|
|
57
58
|
"sandbox-pods",
|
|
59
|
+
"trusted-issuers",
|
|
60
|
+
"operator-keys",
|
|
58
61
|
];
|
|
59
62
|
/**
|
|
60
63
|
* What this Host serves. `runtime-tenants` (protocol 4 clients require it) is still advertised
|
|
61
|
-
* for the compatibility window; protocol 5 and
|
|
62
|
-
* (protocol 6, required by
|
|
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`.
|
|
63
67
|
*/
|
|
64
68
|
export const HOST_PROTOCOL = {
|
|
65
69
|
min: 4,
|
|
66
|
-
max:
|
|
70
|
+
max: 7,
|
|
67
71
|
features: ["runtime-tenants", ...PROTOCOL_FEATURES, ...OPTIONAL_HOST_FEATURES],
|
|
68
72
|
};
|
|
69
73
|
export const DEFINITION_SCHEMA_VERSION = 2;
|
|
@@ -77,8 +81,6 @@ export const PROTOCOL_HEADER = "Nylorun-Protocol";
|
|
|
77
81
|
export const SUBJECT_HEADER = "Nylorun-Subject";
|
|
78
82
|
/** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
|
|
79
83
|
export const SCOPES_HEADER = "Nylorun-Scopes";
|
|
80
|
-
/** A publishable key: names the client app, and its Tenant (Host feature `browser-access`). */
|
|
81
|
-
export const PUBLISHABLE_KEY_HEADER = "Nylorun-Key";
|
|
82
84
|
/** The delivery token on a request the Runtime sends to an Action endpoint. */
|
|
83
85
|
export const SIGNATURE_HEADER = "Nylorun-Signature";
|
|
84
86
|
/** Set to `1` on an Action endpoint's response whose body is a tagged `ActionOutcome`. */
|
|
@@ -101,7 +103,7 @@ export const ERROR_CODES = [
|
|
|
101
103
|
"invalid_request",
|
|
102
104
|
/** A route that acts for a person was called without one (`Nylorun-Subject`). */
|
|
103
105
|
"subject_required",
|
|
104
|
-
/** A
|
|
106
|
+
/** A token caller's sandbox grants do not reach the sandbox (Host feature `sandboxes`). */
|
|
105
107
|
"sandbox_not_granted",
|
|
106
108
|
/** Another session's turn holds the sandbox: turns are serial per sandbox. */
|
|
107
109
|
"sandbox_busy",
|
|
@@ -113,28 +115,35 @@ export const ERROR_CODES = [
|
|
|
113
115
|
"sandbox_lost",
|
|
114
116
|
/** A pod sandbox passed its TTL: a `PUT` with a longer `lifecycle.ttl` revives it. */
|
|
115
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",
|
|
116
132
|
"internal_error",
|
|
117
133
|
];
|
|
118
134
|
/** Crockford Base32 alphabet (lowercase); excludes i, l, o, u. */
|
|
119
135
|
const CROCKFORD = "0123456789abcdefghjkmnpqrstvwxyz";
|
|
120
136
|
export const TENANT_ID_PATTERN = /^tn_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
121
137
|
export const PRINCIPAL_ID_PATTERN = /^pr_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
122
|
-
/** 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). */
|
|
123
139
|
export const SIGNING_KEY_ID_PATTERN = /^sk_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
124
|
-
/** A publishable key's id (not the key). */
|
|
125
|
-
export const PUBLISHABLE_KEY_ID_PATTERN = /^pk_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
126
140
|
/** A file artifact's id (protocol 6). */
|
|
127
141
|
export const ARTIFACT_ID_PATTERN = /^af_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
128
|
-
/**
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return undefined;
|
|
134
|
-
return PUBLISHABLE_KEY_PATTERN.exec(value)?.[1];
|
|
135
|
-
}
|
|
136
|
-
/** A derived principal's id names its client, e.g. `babai`; `studio` is reserved. */
|
|
137
|
-
export const DERIVED_PRINCIPAL_ID_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
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}$/;
|
|
138
147
|
export function isTenantId(value) {
|
|
139
148
|
return typeof value === "string" && TENANT_ID_PATTERN.test(value);
|
|
140
149
|
}
|
|
@@ -200,10 +209,6 @@ export function newPrincipalId(now) {
|
|
|
200
209
|
export function newSigningKeyId(now) {
|
|
201
210
|
return newPrefixedId("sk_", now);
|
|
202
211
|
}
|
|
203
|
-
/** Publishable key id: `pk_` + lowercase Crockford ULID. */
|
|
204
|
-
export function newPublishableKeyId(now) {
|
|
205
|
-
return newPrefixedId("pk_", now);
|
|
206
|
-
}
|
|
207
212
|
/** Artifact id: `af_` + lowercase Crockford ULID. */
|
|
208
213
|
export function newArtifactId(now) {
|
|
209
214
|
return newPrefixedId("af_", now);
|
|
@@ -211,15 +216,6 @@ export function newArtifactId(now) {
|
|
|
211
216
|
export function isArtifactId(value) {
|
|
212
217
|
return typeof value === "string" && ARTIFACT_ID_PATTERN.test(value);
|
|
213
218
|
}
|
|
214
|
-
/** A new publishable key for `tenantId`: 160 random bits after the Tenant id. */
|
|
215
|
-
export function newPublishableKey(tenantId) {
|
|
216
|
-
if (!isTenantId(tenantId))
|
|
217
|
-
throw new Error(`Invalid Tenant id ${tenantId}`);
|
|
218
|
-
let random = "";
|
|
219
|
-
while (random.length < 32)
|
|
220
|
-
random += encodeRandom();
|
|
221
|
-
return `nr_pub_${tenantId}_${random.slice(0, 32)}`;
|
|
222
|
-
}
|
|
223
219
|
function parseSemVer(version) {
|
|
224
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);
|
|
225
221
|
if (!match)
|