@nylorun/core 0.11.0-beta → 0.12.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 +47 -0
- package/dist/compatibility.d.ts +35 -8
- package/dist/compatibility.js +40 -6
- package/dist/contracts.d.ts +967 -8
- package/dist/contracts.js +612 -8
- 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,52 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.12.0-beta
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 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.
|
|
8
|
+
|
|
9
|
+
- **`@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.
|
|
10
|
+
- **`@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.
|
|
11
|
+
- **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`.
|
|
12
|
+
- **`@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.
|
|
13
|
+
- **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.
|
|
14
|
+
- **`@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.
|
|
15
|
+
- `@nylorun/admin`, `@nylorun/cli`, `nylorun`, `@nylorun/studio`: speak protocol 6.
|
|
16
|
+
|
|
17
|
+
### Minor Changes
|
|
18
|
+
|
|
19
|
+
- 6077272: **Folder artifacts and the turn-end outputs export (F8.2).** Part of protocol 6, with file artifacts.
|
|
20
|
+
|
|
21
|
+
- **`@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.
|
|
22
|
+
- **`@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.
|
|
23
|
+
- **`@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`.
|
|
24
|
+
- **`@nylorun/agents`:** `client.artifacts.tree()`, `file()`, `diff()` and `zip()`, and `link(id, { file })`.
|
|
25
|
+
|
|
26
|
+
- 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.
|
|
27
|
+
|
|
28
|
+
- `@nylorun/core/harness-api`: the protocol (messages, Zod schemas, the effect request hash, transcript edits, an RPC channel with an in-process memory transport).
|
|
29
|
+
- `@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.
|
|
30
|
+
- `@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.
|
|
31
|
+
|
|
32
|
+
- 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.
|
|
33
|
+
|
|
34
|
+
- `@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`).
|
|
35
|
+
- `@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`).
|
|
36
|
+
- `@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`.
|
|
37
|
+
|
|
38
|
+
- 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`.
|
|
39
|
+
- 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.
|
|
40
|
+
|
|
41
|
+
- `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.
|
|
42
|
+
- 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.
|
|
43
|
+
- 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.
|
|
44
|
+
- The Tenant holds at most `limits.sandboxes` sandboxes (`PUT /v1/tenant/sandbox`, default 100); one more is `409 limit_exceeded`.
|
|
45
|
+
- 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.
|
|
46
|
+
- 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.
|
|
47
|
+
- `@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`.
|
|
48
|
+
- `nylorun sandbox ls [--label key=value]... [--json]` and `nylorun sandbox rm <id>` list and delete the running local Tenant's sandboxes.
|
|
49
|
+
|
|
3
50
|
## 0.11.0-beta
|
|
4
51
|
|
|
5
52
|
### Minor Changes
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
2
|
/**
|
|
3
|
-
* Protocol
|
|
4
|
-
* `
|
|
3
|
+
* Protocol 6: file artifacts (`/v1/artifacts/**`, Runtime-signed capability links) and user
|
|
4
|
+
* messages with `parts`, whose file parts name an artifact the model reads. Protocol 5: a Host
|
|
5
|
+
* serves one Tenant, and nothing in a request selects it. Clients send no `Nylorun-Tenant`; the
|
|
6
|
+
* Host still accepts protocol 4 (and the header) and protocol 5 clients.
|
|
5
7
|
*/
|
|
6
|
-
export declare const PROTOCOL_VERSION =
|
|
8
|
+
export declare const PROTOCOL_VERSION = 6;
|
|
7
9
|
/** What a client of this protocol requires of a Host. */
|
|
8
|
-
export declare const PROTOCOL_FEATURES: readonly ["admin-status", "studio-principal", "action-endpoints"];
|
|
10
|
+
export declare const PROTOCOL_FEATURES: readonly ["admin-status", "studio-principal", "action-endpoints", "artifacts"];
|
|
9
11
|
export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
|
|
10
12
|
/**
|
|
11
13
|
* Host features no client requires: a client that uses one checks the Host's `/health`
|
|
@@ -28,9 +30,16 @@ export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
|
|
|
28
30
|
* `GET /v1/a2a/agents/:agent/card` returns the agent's card without its interfaces.
|
|
29
31
|
* `action-endpoints`: `PUT`/`GET`/`DELETE /v1/endpoints` register the URL that runs each agent's
|
|
30
32
|
* Actions, and the Runtime delivers them there, signed with a delivery token
|
|
31
|
-
* (`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 }`, subject tokens carry `sbx` grants checked at every turn start, and
|
|
36
|
+
* `sandboxes:write` lets a subject create and delete the sandboxes it is granted.
|
|
37
|
+
* `sandbox-pods`: kind `pod` runs as an agent-sandbox pod on the Tenant's cluster (`nylorun
|
|
38
|
+
* sandbox enable`), with `POST /v1/sandboxes/{id}/stop` and `/reset`, a TTL
|
|
39
|
+
* (`lifecycle.ttl`), lifecycle events (`sandbox.running`, `.suspended`, `.expired`,
|
|
40
|
+
* `.relaunched`, `.lost`, `.reset`, `.failed`) and the Tenant's `placement`.
|
|
32
41
|
*/
|
|
33
|
-
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"];
|
|
42
|
+
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", "sandboxes", "sandbox-pods"];
|
|
34
43
|
export type OptionalHostFeature = (typeof OPTIONAL_HOST_FEATURES)[number];
|
|
35
44
|
export interface ProtocolRange {
|
|
36
45
|
min: number;
|
|
@@ -39,7 +48,8 @@ export interface ProtocolRange {
|
|
|
39
48
|
}
|
|
40
49
|
/**
|
|
41
50
|
* 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.
|
|
51
|
+
* for the compatibility window; protocol 5 and 6 clients no longer require it. `artifacts`
|
|
52
|
+
* (protocol 6, required by its clients): file artifacts, capability links and message `parts`.
|
|
43
53
|
*/
|
|
44
54
|
export declare const HOST_PROTOCOL: ProtocolRange;
|
|
45
55
|
export declare const DEFINITION_SCHEMA_VERSION = 2;
|
|
@@ -65,7 +75,19 @@ export declare const ERROR_CODES: readonly ["not_found", "protocol_unsupported",
|
|
|
65
75
|
/** A request the Host could not read: headers, body or query. */
|
|
66
76
|
"invalid_request",
|
|
67
77
|
/** A route that acts for a person was called without one (`Nylorun-Subject`). */
|
|
68
|
-
"subject_required",
|
|
78
|
+
"subject_required",
|
|
79
|
+
/** A subject token's `sbx` grants do not reach the sandbox (Host feature `sandboxes`). */
|
|
80
|
+
"sandbox_not_granted",
|
|
81
|
+
/** Another session's turn holds the sandbox: turns are serial per sandbox. */
|
|
82
|
+
"sandbox_busy",
|
|
83
|
+
/** The sandbox is gone, or its kind cannot run on this Runtime. */
|
|
84
|
+
"sandbox_unavailable",
|
|
85
|
+
/** The Tenant's placement keeps this session's harness off the host its sandbox needs. */
|
|
86
|
+
"placement_refused",
|
|
87
|
+
/** A pod sandbox's volume or node is gone: only `POST /v1/sandboxes/{id}/reset` brings it back. */
|
|
88
|
+
"sandbox_lost",
|
|
89
|
+
/** A pod sandbox passed its TTL: a `PUT` with a longer `lifecycle.ttl` revives it. */
|
|
90
|
+
"sandbox_expired", "internal_error"];
|
|
69
91
|
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
70
92
|
export declare const TENANT_ID_PATTERN: RegExp;
|
|
71
93
|
export declare const PRINCIPAL_ID_PATTERN: RegExp;
|
|
@@ -73,6 +95,8 @@ export declare const PRINCIPAL_ID_PATTERN: RegExp;
|
|
|
73
95
|
export declare const SIGNING_KEY_ID_PATTERN: RegExp;
|
|
74
96
|
/** A publishable key's id (not the key). */
|
|
75
97
|
export declare const PUBLISHABLE_KEY_ID_PATTERN: RegExp;
|
|
98
|
+
/** A file artifact's id (protocol 6). */
|
|
99
|
+
export declare const ARTIFACT_ID_PATTERN: RegExp;
|
|
76
100
|
/** A publishable key: `nr_pub_<tenantId>_<32 Crockford characters>`. */
|
|
77
101
|
export declare const PUBLISHABLE_KEY_PATTERN: RegExp;
|
|
78
102
|
/** The Tenant a publishable key names, or undefined when it is not one. */
|
|
@@ -93,6 +117,9 @@ export declare function newPrincipalId(now?: number): string;
|
|
|
93
117
|
export declare function newSigningKeyId(now?: number): string;
|
|
94
118
|
/** Publishable key id: `pk_` + lowercase Crockford ULID. */
|
|
95
119
|
export declare function newPublishableKeyId(now?: number): string;
|
|
120
|
+
/** Artifact id: `af_` + lowercase Crockford ULID. */
|
|
121
|
+
export declare function newArtifactId(now?: number): string;
|
|
122
|
+
export declare function isArtifactId(value: unknown): value is string;
|
|
96
123
|
/** A new publishable key for `tenantId`: 160 random bits after the Tenant id. */
|
|
97
124
|
export declare function newPublishableKey(tenantId: string): string;
|
|
98
125
|
/**
|
package/dist/compatibility.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
2
|
/**
|
|
3
|
-
* Protocol
|
|
4
|
-
* `
|
|
3
|
+
* Protocol 6: file artifacts (`/v1/artifacts/**`, Runtime-signed capability links) and user
|
|
4
|
+
* messages with `parts`, whose file parts name an artifact the model reads. Protocol 5: a Host
|
|
5
|
+
* serves one Tenant, and nothing in a request selects it. Clients send no `Nylorun-Tenant`; the
|
|
6
|
+
* Host still accepts protocol 4 (and the header) and protocol 5 clients.
|
|
5
7
|
*/
|
|
6
|
-
export const PROTOCOL_VERSION =
|
|
8
|
+
export const PROTOCOL_VERSION = 6;
|
|
7
9
|
/** What a client of this protocol requires of a Host. */
|
|
8
10
|
export const PROTOCOL_FEATURES = [
|
|
9
11
|
"admin-status",
|
|
10
12
|
"studio-principal",
|
|
11
13
|
"action-endpoints",
|
|
14
|
+
"artifacts",
|
|
12
15
|
];
|
|
13
16
|
/**
|
|
14
17
|
* Host features no client requires: a client that uses one checks the Host's `/health`
|
|
@@ -31,7 +34,14 @@ export const PROTOCOL_FEATURES = [
|
|
|
31
34
|
* `GET /v1/a2a/agents/:agent/card` returns the agent's card without its interfaces.
|
|
32
35
|
* `action-endpoints`: `PUT`/`GET`/`DELETE /v1/endpoints` register the URL that runs each agent's
|
|
33
36
|
* Actions, and the Runtime delivers them there, signed with a delivery token
|
|
34
|
-
* (`Nylorun-Signature`), instead of offering them to executors.
|
|
37
|
+
* (`Nylorun-Signature`), instead of offering them to executors. `sandboxes`: sandboxes are a
|
|
38
|
+
* resource (`PUT`/`GET`/`DELETE /v1/sandboxes/{id}`, kind `virtual`), a session attaches to one
|
|
39
|
+
* with `sandbox: { id }`, subject tokens carry `sbx` grants checked at every turn start, and
|
|
40
|
+
* `sandboxes:write` lets a subject create and delete the sandboxes it is granted.
|
|
41
|
+
* `sandbox-pods`: kind `pod` runs as an agent-sandbox pod on the Tenant's cluster (`nylorun
|
|
42
|
+
* sandbox enable`), with `POST /v1/sandboxes/{id}/stop` and `/reset`, a TTL
|
|
43
|
+
* (`lifecycle.ttl`), lifecycle events (`sandbox.running`, `.suspended`, `.expired`,
|
|
44
|
+
* `.relaunched`, `.lost`, `.reset`, `.failed`) and the Tenant's `placement`.
|
|
35
45
|
*/
|
|
36
46
|
export const OPTIONAL_HOST_FEATURES = [
|
|
37
47
|
"tenant-fixture-model",
|
|
@@ -43,14 +53,17 @@ export const OPTIONAL_HOST_FEATURES = [
|
|
|
43
53
|
"ag-ui-endpoint",
|
|
44
54
|
"a2a-endpoint",
|
|
45
55
|
"action-endpoints",
|
|
56
|
+
"sandboxes",
|
|
57
|
+
"sandbox-pods",
|
|
46
58
|
];
|
|
47
59
|
/**
|
|
48
60
|
* 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.
|
|
61
|
+
* for the compatibility window; protocol 5 and 6 clients no longer require it. `artifacts`
|
|
62
|
+
* (protocol 6, required by its clients): file artifacts, capability links and message `parts`.
|
|
50
63
|
*/
|
|
51
64
|
export const HOST_PROTOCOL = {
|
|
52
65
|
min: 4,
|
|
53
|
-
max:
|
|
66
|
+
max: 6,
|
|
54
67
|
features: ["runtime-tenants", ...PROTOCOL_FEATURES, ...OPTIONAL_HOST_FEATURES],
|
|
55
68
|
};
|
|
56
69
|
export const DEFINITION_SCHEMA_VERSION = 2;
|
|
@@ -88,6 +101,18 @@ export const ERROR_CODES = [
|
|
|
88
101
|
"invalid_request",
|
|
89
102
|
/** A route that acts for a person was called without one (`Nylorun-Subject`). */
|
|
90
103
|
"subject_required",
|
|
104
|
+
/** A subject token's `sbx` grants do not reach the sandbox (Host feature `sandboxes`). */
|
|
105
|
+
"sandbox_not_granted",
|
|
106
|
+
/** Another session's turn holds the sandbox: turns are serial per sandbox. */
|
|
107
|
+
"sandbox_busy",
|
|
108
|
+
/** The sandbox is gone, or its kind cannot run on this Runtime. */
|
|
109
|
+
"sandbox_unavailable",
|
|
110
|
+
/** The Tenant's placement keeps this session's harness off the host its sandbox needs. */
|
|
111
|
+
"placement_refused",
|
|
112
|
+
/** A pod sandbox's volume or node is gone: only `POST /v1/sandboxes/{id}/reset` brings it back. */
|
|
113
|
+
"sandbox_lost",
|
|
114
|
+
/** A pod sandbox passed its TTL: a `PUT` with a longer `lifecycle.ttl` revives it. */
|
|
115
|
+
"sandbox_expired",
|
|
91
116
|
"internal_error",
|
|
92
117
|
];
|
|
93
118
|
/** Crockford Base32 alphabet (lowercase); excludes i, l, o, u. */
|
|
@@ -98,6 +123,8 @@ export const PRINCIPAL_ID_PATTERN = /^pr_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
|
98
123
|
export const SIGNING_KEY_ID_PATTERN = /^sk_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
99
124
|
/** A publishable key's id (not the key). */
|
|
100
125
|
export const PUBLISHABLE_KEY_ID_PATTERN = /^pk_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
126
|
+
/** A file artifact's id (protocol 6). */
|
|
127
|
+
export const ARTIFACT_ID_PATTERN = /^af_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
101
128
|
/** A publishable key: `nr_pub_<tenantId>_<32 Crockford characters>`. */
|
|
102
129
|
export const PUBLISHABLE_KEY_PATTERN = /^nr_pub_(tn_[0-9a-hjkmnp-tv-z]{26})_([0-9a-hjkmnp-tv-z]{32})$/;
|
|
103
130
|
/** The Tenant a publishable key names, or undefined when it is not one. */
|
|
@@ -177,6 +204,13 @@ export function newSigningKeyId(now) {
|
|
|
177
204
|
export function newPublishableKeyId(now) {
|
|
178
205
|
return newPrefixedId("pk_", now);
|
|
179
206
|
}
|
|
207
|
+
/** Artifact id: `af_` + lowercase Crockford ULID. */
|
|
208
|
+
export function newArtifactId(now) {
|
|
209
|
+
return newPrefixedId("af_", now);
|
|
210
|
+
}
|
|
211
|
+
export function isArtifactId(value) {
|
|
212
|
+
return typeof value === "string" && ARTIFACT_ID_PATTERN.test(value);
|
|
213
|
+
}
|
|
180
214
|
/** A new publishable key for `tenantId`: 160 random bits after the Tenant id. */
|
|
181
215
|
export function newPublishableKey(tenantId) {
|
|
182
216
|
if (!isTenantId(tenantId))
|