@nylorun/core 0.5.0-beta → 0.7.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 +62 -0
- package/README.md +1 -1
- package/dist/compatibility.d.ts +20 -3
- package/dist/compatibility.js +30 -13
- package/dist/contracts.d.ts +283 -18
- package/dist/contracts.js +273 -7
- package/dist/definition/sandbox-tools.js +1 -1
- package/dist/utils/hash.js +3 -3
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,67 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.7.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a322696: **Derived principals** (optional Host feature `derived-principals`): a client that holds the admin key no longer needs to store an application key.
|
|
8
|
+
|
|
9
|
+
- `admin.createTenant({ name, principals: ["babai"] })` registers each named principal by the hash of its derived key, and `admin.deriveTenantKey(tenantId, principalId)` (or `deriveTenantKey(adminKey, tenantId, principalId)`) recomputes the key when needed.
|
|
10
|
+
- `POST /v1/admin/tenants` accepts `derivedPrincipals: [{ id, credentialHash }]`. Ids match `^[a-z][a-z0-9-]{0,31}$` and `studio` is reserved; duplicate ids or credentials answer `400`. A retried create must name the same principals.
|
|
11
|
+
- `createTenant` with `principals` throws `incompatible_host` before sending anything to a Host without the feature.
|
|
12
|
+
|
|
13
|
+
- 844bff3: **Act for a person: `Nylorun-Subject` and `Nylorun-Scopes`.** An app server that holds the Tenant key can name the person each request is for, and the Runtime enforces it (optional Host feature `subject-headers`).
|
|
14
|
+
|
|
15
|
+
- `client.as(subject, { scopes })` in `@nylorun/agents` sends both headers on every call, event streams included. Scopes: `agents:read`, `agents:write`, `sessions:own`, `vaults:own`, `tenant:settings`; default `["sessions:own"]`.
|
|
16
|
+
- The Runtime limits a subject to the routes its scopes allow (`403 scope_required`) and to its own sessions and vaults: another owner's session, vault or sandbox is the same `404` as a missing one, including `PUT` on its session id (was `409`). Reset, config seed, executors, actions and the sandbox tool routes are open to no subject. Only application keys may send the headers.
|
|
17
|
+
- The AG-UI handler calls the Runtime as each person and requires `subject-headers`; new optional `scopes` option. The host's `session()` parameters can no longer replace a session's id, agent or owner.
|
|
18
|
+
- Core exports `SUBJECT_HEADER`, `SCOPES_HEADER`, `SUBJECT_SCOPES` and `parseSubjectHeaders`. Postgres Tenant schemas migrate to version 2 (an indexed session owner column).
|
|
19
|
+
|
|
20
|
+
Requests without `Nylorun-Subject` are unchanged.
|
|
21
|
+
|
|
22
|
+
- a322696: **The session log now carries what a chat UI shows** (optional Host feature `transcript-events`).
|
|
23
|
+
|
|
24
|
+
- `message.assistant` for each completed model step: `{ invocationId, text, toolCalls: [{ callId, name, input }], agent? }`.
|
|
25
|
+
- `tool.completed` for an MCP or sandbox tool: `{ invocationId, callId, capabilityId, toolName, output }`, or `error: { code, message }` for a tool error.
|
|
26
|
+
- Tool `action.pending` and `action.completed` events, and `delegation.started` / `delegation.completed`, carry the model's `callId` (and `invocationId` on actions).
|
|
27
|
+
- Events are written in the transaction that completes the effect, so a replay writes none.
|
|
28
|
+
- `@nylorun/core/contracts` adds payload schemas and `parseTranscriptEvent(event)`; `LiveEvent.payload` stays `unknown`.
|
|
29
|
+
|
|
30
|
+
Fix: a tool with both `approval` and an `output` schema now pauses for approval. The Runtime validated its `interaction-required` result against the output schema and failed the tool with `tool.invalid-output`; `denied`, `interaction-required` and `deferred` results are no longer validated.
|
|
31
|
+
|
|
32
|
+
## 0.6.0-beta
|
|
33
|
+
|
|
34
|
+
### Minor Changes
|
|
35
|
+
|
|
36
|
+
- bf1c2da: **`nylorun dev --ephemeral` runs on the Docker stack, with a Tenant-level fixture model (breaking beta).**
|
|
37
|
+
|
|
38
|
+
- `nylorun dev --ephemeral` creates a temporary Tenant through `@nylorun/admin` (no Project link written), seeds it from `.env` with the fixture model, opens Studio on it and runs the watcher; the Tenant is deleted with its active work cancelled when the watcher ends, Ctrl-C included. It needs a Runtime that advertises `tenant-fixture-model`.
|
|
39
|
+
- `PUT /v1/tenant/config/seed` accepts `fixtureModel: true`, stored as Tenant setting `model.fixture`: that Tenant's model calls use the Runtime's fixture model while other Tenants on the Host keep theirs. `HOST_PROTOCOL` advertises the new optional feature `tenant-fixture-model` (`OPTIONAL_HOST_FEATURES` in `@nylorun/core/compatibility`); clients do not require it.
|
|
40
|
+
- `startEphemeralRuntime()` keeps its signature but its Tenants live in memory instead of SQLite under the Host root; nothing survives `close()`.
|
|
41
|
+
- Closing a Tenant waits for running advances at most the advance grace period (30 s by default) and then abandons them; their lease lapses and the next advance takes over.
|
|
42
|
+
- A Worker stop, Tenant close or ended Restate attempt no longer fails or cancels the turn it interrupts: outcomes already returned are recorded, nothing is settled, and the next advance resumes the turn from its checkpoint. Only a user cancel settles `cancelled`; an advance deadline fails the turn with the deadline's message.
|
|
43
|
+
|
|
44
|
+
- bf1c2da: **The microsandbox backend is removed; the Runtime runs sandbox tools on the virtual backend only.** The optional `microsandbox` dependency is gone. `sandbox.backend` and `NYLORUN_SANDBOX` accept `auto` or `virtual`, and `auto` selects `virtual`. A Tenant that stored `microsandbox` reads it as `auto`. `nylorun doctor sandbox` and the `nylorun dev` banner report only the virtual shell.
|
|
45
|
+
- bf1c2da: **Tenants are Postgres schemas only; SQLite and the `nylorun-runtime` launcher are removed (breaking beta).**
|
|
46
|
+
|
|
47
|
+
- The Runtime runs on Postgres (the Session Store, one schema per Tenant), Restate (Durable Session Execution: one advance per session, fenced by an ownership epoch, and a per-Tenant sweep) and S2 (Durable Streams: every event is written to a Postgres outbox and relayed to the session's stream, which history and SSE read). `--role api|worker|all` selects the process role; `/ready` covers Postgres, Restate and S2.
|
|
48
|
+
- SQLite Tenants are not migrated. On first start the Runtime moves every `tenants/<id>/` directory that holds a `tenant.sqlite` to `trash/<id>-sqlite-<time>/` and logs `sqlite_tenant_moved_to_trash`; recreate those Tenants.
|
|
49
|
+
- `@nylorun/runtime` has no bin: the `nylorun-runtime` launcher and `host-state.json` are gone. The Runtime runs as the `ghcr.io/nylorun/runtime` image (`nylorun start`); its Host entry requires `NYLORUN_DATABASE_URL`.
|
|
50
|
+
- `openTenantRuntime(config, hooks)` requires the Tenant's opened `store` and `envelope`; `OpenTenantRuntime` receives them from the Tenant store. `HostStateFile` is no longer exported.
|
|
51
|
+
- `@nylorun/core`: `LAUNCHER_PROTOCOL` and the launcher error codes are removed; `QuarantineSchema` drops `locked`, `lockPath` and `lockPid`; `TenantStatusSchema.checks.sqlite` is now `checks.store`. `TenantStatusSchema` gains optional `execution` (stuck invocations) and `streams` (basin, outbox depth, relay lag); `HostAggregateSchema` gains optional `outboxDepth` and `relayLagMs`.
|
|
52
|
+
|
|
53
|
+
- bf1c2da: **Tenants can register a Studio principal.** `CreateTenantRequest` gains optional `studioCredentialHash` behind the new protocol feature `studio-principal`; the Runtime stores it as application principal `studio`, and idempotent create compares it too. `@nylorun/admin` exports `deriveStudioToken(adminKey, tenantId)` (HMAC-SHA256 over `nylorun/studio/v1`, NUL, Tenant id) and `createTenant` sends the hash of that key, so Studio can reach any Tenant's API with a key derived from the admin key. Clients require the new feature, so upgrade the Runtime with them.
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
- ba1b239: **`nylorun` sets up the local stack; `@nylorun/cli` becomes the Runtime client `nylo` (breaking beta).**
|
|
58
|
+
|
|
59
|
+
- New unscoped package **`nylorun`**: `npx nylorun up` sets up the Docker stack on the first run and starts it after that, from any directory; `npx nylorun down` stops it (volumes are kept). `up` and `down` are aliases of `start` and `stop`. It also owns `status`, `logs`, `studio`, `reset` and `doctor`, pins the Runtime and Studio images (`package.json` `nylorun.runtime` / `nylorun.studio`), depends on `@nylorun/core` only, and never creates Tenants.
|
|
60
|
+
- **`@nylorun/cli`** is the Runtime client with the command **`nylo`**: `nylo tenant create [name]` (creates the Tenant; in a project, writes the Project link and seeds the model provider and sandbox from `.env`), `nylo tenant current|list|use|status|reset|delete`, `nylo configure`, `nylo env` (was `nylorun status --env`) and `nylo doctor sandbox`. It no longer provides the `nylorun` command or the stack commands.
|
|
61
|
+
- **Removed:** `nylorun dev` and `nylorun dev --ephemeral`. Link once with `nylo tenant create`, then run the project's own `npm run dev`. Moved commands exit 2 and name their replacement.
|
|
62
|
+
- **Starter:** the generated project depends on `@nylorun/agents` only (no Nylorun devDependency); `dev` is `tsx watch --env-file-if-exists=.env src/main.ts`. `npm create @nylorun/agent` installs the project and prints the next steps (`npx nylorun up`, `npx @nylorun/cli tenant create`, `npm run dev`) instead of starting development; `--no-open` is accepted and ignored.
|
|
63
|
+
- `connectAgents` names those steps when it finds no Runtime connection. Runtime repair hints, model errors and core's sandbox message name `nylo` and `nylorun up`.
|
|
64
|
+
|
|
3
65
|
## 0.5.0-beta
|
|
4
66
|
|
|
5
67
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ HTTP client, Node host or SDK dependencies.
|
|
|
9
9
|
- Root: shared contracts and types; no authoring or execution entry points.
|
|
10
10
|
|
|
11
11
|
Applications normally import `@nylorun/agents`. Hosts and the execution engine
|
|
12
|
-
consume core directly.
|
|
12
|
+
consume core directly.
|
|
13
13
|
|
|
14
14
|
A built agent's non-enumerable `getBinding()` retains local functions, tool
|
|
15
15
|
snapshots, ordered declarations and live output schemas. Only its manifest is
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
2
|
export declare const PROTOCOL_VERSION = 2;
|
|
3
|
-
export declare const PROTOCOL_FEATURES: readonly ["runtime-tenants", "admin-status"];
|
|
3
|
+
export declare const PROTOCOL_FEATURES: readonly ["runtime-tenants", "admin-status", "studio-principal"];
|
|
4
4
|
export type ProtocolFeature = (typeof PROTOCOL_FEATURES)[number];
|
|
5
|
+
/**
|
|
6
|
+
* Host features no client requires: a client that uses one checks the Host's `/health`
|
|
7
|
+
* for it first. `tenant-fixture-model`: `PUT /v1/tenant/config/seed` accepts
|
|
8
|
+
* `fixtureModel: true` (the Tenant's model calls use the Runtime's fixture model).
|
|
9
|
+
* `transcript-events`: the log carries `message.assistant` and `tool.completed`, and
|
|
10
|
+
* tool `action.*` events carry `callId` and `invocationId`. `derived-principals`:
|
|
11
|
+
* `POST /v1/admin/tenants` accepts `derivedPrincipals`. `subject-headers`: an application
|
|
12
|
+
* principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
|
|
13
|
+
* enforces the scopes and the subject's ownership of sessions and vaults.
|
|
14
|
+
*/
|
|
15
|
+
export declare const OPTIONAL_HOST_FEATURES: readonly ["tenant-fixture-model", "transcript-events", "derived-principals", "subject-headers"];
|
|
16
|
+
export type OptionalHostFeature = (typeof OPTIONAL_HOST_FEATURES)[number];
|
|
5
17
|
export interface ProtocolRange {
|
|
6
18
|
min: number;
|
|
7
19
|
max: number;
|
|
@@ -9,13 +21,18 @@ export interface ProtocolRange {
|
|
|
9
21
|
}
|
|
10
22
|
export declare const HOST_PROTOCOL: ProtocolRange;
|
|
11
23
|
export declare const DEFINITION_SCHEMA_VERSION = 2;
|
|
12
|
-
export declare const LAUNCHER_PROTOCOL = 1;
|
|
13
24
|
export declare const TENANT_HEADER = "Nylorun-Tenant";
|
|
14
25
|
export declare const PROTOCOL_HEADER = "Nylorun-Protocol";
|
|
15
|
-
|
|
26
|
+
/** The subject an application principal acts for (Host feature `subject-headers`). */
|
|
27
|
+
export declare const SUBJECT_HEADER = "Nylorun-Subject";
|
|
28
|
+
/** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
|
|
29
|
+
export declare const SCOPES_HEADER = "Nylorun-Scopes";
|
|
30
|
+
export declare const ERROR_CODES: readonly ["not_found", "protocol_unsupported", "host_rejected", "origin_rejected", "unsupported_media_type", "tenant_conflict", "active_work", "connection_missing", "incompatible_host", "subject_invalid", "scope_required"];
|
|
16
31
|
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
17
32
|
export declare const TENANT_ID_PATTERN: RegExp;
|
|
18
33
|
export declare const PRINCIPAL_ID_PATTERN: RegExp;
|
|
34
|
+
/** A derived principal's id names its client, e.g. `babai`; `studio` is reserved. */
|
|
35
|
+
export declare const DERIVED_PRINCIPAL_ID_PATTERN: RegExp;
|
|
19
36
|
export declare function isTenantId(value: unknown): value is string;
|
|
20
37
|
export declare function isPrincipalId(value: unknown): value is string;
|
|
21
38
|
/**
|
package/dist/compatibility.js
CHANGED
|
@@ -1,15 +1,38 @@
|
|
|
1
1
|
export { hashManifest } from "./utils/hash.js";
|
|
2
2
|
export const PROTOCOL_VERSION = 2;
|
|
3
|
-
export const PROTOCOL_FEATURES = [
|
|
3
|
+
export const PROTOCOL_FEATURES = [
|
|
4
|
+
"runtime-tenants",
|
|
5
|
+
"admin-status",
|
|
6
|
+
"studio-principal",
|
|
7
|
+
];
|
|
8
|
+
/**
|
|
9
|
+
* Host features no client requires: a client that uses one checks the Host's `/health`
|
|
10
|
+
* for it first. `tenant-fixture-model`: `PUT /v1/tenant/config/seed` accepts
|
|
11
|
+
* `fixtureModel: true` (the Tenant's model calls use the Runtime's fixture model).
|
|
12
|
+
* `transcript-events`: the log carries `message.assistant` and `tool.completed`, and
|
|
13
|
+
* tool `action.*` events carry `callId` and `invocationId`. `derived-principals`:
|
|
14
|
+
* `POST /v1/admin/tenants` accepts `derivedPrincipals`. `subject-headers`: an application
|
|
15
|
+
* principal may act for a subject with `Nylorun-Subject` and `Nylorun-Scopes`, and the Runtime
|
|
16
|
+
* enforces the scopes and the subject's ownership of sessions and vaults.
|
|
17
|
+
*/
|
|
18
|
+
export const OPTIONAL_HOST_FEATURES = [
|
|
19
|
+
"tenant-fixture-model",
|
|
20
|
+
"transcript-events",
|
|
21
|
+
"derived-principals",
|
|
22
|
+
"subject-headers",
|
|
23
|
+
];
|
|
4
24
|
export const HOST_PROTOCOL = {
|
|
5
25
|
min: 2,
|
|
6
26
|
max: 2,
|
|
7
|
-
features: PROTOCOL_FEATURES,
|
|
27
|
+
features: [...PROTOCOL_FEATURES, ...OPTIONAL_HOST_FEATURES],
|
|
8
28
|
};
|
|
9
29
|
export const DEFINITION_SCHEMA_VERSION = 2;
|
|
10
|
-
export const LAUNCHER_PROTOCOL = 1;
|
|
11
30
|
export const TENANT_HEADER = "Nylorun-Tenant";
|
|
12
31
|
export const PROTOCOL_HEADER = "Nylorun-Protocol";
|
|
32
|
+
/** The subject an application principal acts for (Host feature `subject-headers`). */
|
|
33
|
+
export const SUBJECT_HEADER = "Nylorun-Subject";
|
|
34
|
+
/** The space-separated scopes of that subject; required with `Nylorun-Subject`. */
|
|
35
|
+
export const SCOPES_HEADER = "Nylorun-Scopes";
|
|
13
36
|
export const ERROR_CODES = [
|
|
14
37
|
"not_found",
|
|
15
38
|
"protocol_unsupported",
|
|
@@ -20,21 +43,15 @@ export const ERROR_CODES = [
|
|
|
20
43
|
"active_work",
|
|
21
44
|
"connection_missing",
|
|
22
45
|
"incompatible_host",
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"lock_timeout",
|
|
26
|
-
"foreign_port",
|
|
27
|
-
"host_unresponsive",
|
|
28
|
-
"host_start_failed",
|
|
29
|
-
"host_schema_newer",
|
|
30
|
-
"host_format_newer",
|
|
31
|
-
"downgrade_refused",
|
|
32
|
-
"upgrade_failed",
|
|
46
|
+
"subject_invalid",
|
|
47
|
+
"scope_required",
|
|
33
48
|
];
|
|
34
49
|
/** Crockford Base32 alphabet (lowercase); excludes i, l, o, u. */
|
|
35
50
|
const CROCKFORD = "0123456789abcdefghjkmnpqrstvwxyz";
|
|
36
51
|
export const TENANT_ID_PATTERN = /^tn_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
37
52
|
export const PRINCIPAL_ID_PATTERN = /^pr_[0-9a-hjkmnp-tv-z]{26}$/;
|
|
53
|
+
/** A derived principal's id names its client, e.g. `babai`; `studio` is reserved. */
|
|
54
|
+
export const DERIVED_PRINCIPAL_ID_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
38
55
|
export function isTenantId(value) {
|
|
39
56
|
return typeof value === "string" && TENANT_ID_PATTERN.test(value);
|
|
40
57
|
}
|
package/dist/contracts.d.ts
CHANGED
|
@@ -309,23 +309,15 @@ export declare const RejectedResponseSchema: z.ZodObject<{
|
|
|
309
309
|
code: z.ZodEnum<{
|
|
310
310
|
active_work: "active_work";
|
|
311
311
|
connection_missing: "connection_missing";
|
|
312
|
-
downgrade_refused: "downgrade_refused";
|
|
313
|
-
foreign_port: "foreign_port";
|
|
314
|
-
host_format_newer: "host_format_newer";
|
|
315
312
|
host_rejected: "host_rejected";
|
|
316
|
-
host_schema_newer: "host_schema_newer";
|
|
317
|
-
host_start_failed: "host_start_failed";
|
|
318
|
-
host_unresponsive: "host_unresponsive";
|
|
319
313
|
incompatible_host: "incompatible_host";
|
|
320
|
-
launcher_failed: "launcher_failed";
|
|
321
|
-
lock_timeout: "lock_timeout";
|
|
322
314
|
not_found: "not_found";
|
|
323
315
|
origin_rejected: "origin_rejected";
|
|
324
|
-
platform_unsupported: "platform_unsupported";
|
|
325
316
|
protocol_unsupported: "protocol_unsupported";
|
|
317
|
+
scope_required: "scope_required";
|
|
318
|
+
subject_invalid: "subject_invalid";
|
|
326
319
|
tenant_conflict: "tenant_conflict";
|
|
327
320
|
unsupported_media_type: "unsupported_media_type";
|
|
328
|
-
upgrade_failed: "upgrade_failed";
|
|
329
321
|
}>;
|
|
330
322
|
message: z.ZodString;
|
|
331
323
|
details: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -502,6 +494,228 @@ export declare const ActionSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
502
494
|
key: z.ZodString;
|
|
503
495
|
}, z.core.$strict>]>;
|
|
504
496
|
export type Action = z.infer<typeof ActionSchema>;
|
|
497
|
+
/** `message.assistant`: one completed model step. `invocationId` is the model call's. */
|
|
498
|
+
export declare const AssistantMessagePayloadSchema: z.ZodObject<{
|
|
499
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
500
|
+
id: z.ZodString;
|
|
501
|
+
path: z.ZodString;
|
|
502
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
503
|
+
}, z.core.$loose>>;
|
|
504
|
+
invocationId: z.ZodString;
|
|
505
|
+
text: z.ZodString;
|
|
506
|
+
toolCalls: z.ZodArray<z.ZodObject<{
|
|
507
|
+
callId: z.ZodString;
|
|
508
|
+
name: z.ZodString;
|
|
509
|
+
input: z.ZodUnknown;
|
|
510
|
+
}, z.core.$loose>>;
|
|
511
|
+
}, z.core.$loose>;
|
|
512
|
+
/** `tool.completed`: an MCP or sandbox tool the Runtime ran. `error` for a tool error. */
|
|
513
|
+
export declare const ToolCompletedPayloadSchema: z.ZodObject<{
|
|
514
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
515
|
+
id: z.ZodString;
|
|
516
|
+
path: z.ZodString;
|
|
517
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
518
|
+
}, z.core.$loose>>;
|
|
519
|
+
callId: z.ZodString;
|
|
520
|
+
invocationId: z.ZodString;
|
|
521
|
+
capabilityId: z.ZodString;
|
|
522
|
+
toolName: z.ZodString;
|
|
523
|
+
output: z.ZodOptional<z.ZodUnknown>;
|
|
524
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
525
|
+
code: z.ZodString;
|
|
526
|
+
message: z.ZodString;
|
|
527
|
+
}, z.core.$loose>>;
|
|
528
|
+
}, z.core.$loose>;
|
|
529
|
+
export declare const ActionPendingPayloadSchema: z.ZodObject<{
|
|
530
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
531
|
+
id: z.ZodString;
|
|
532
|
+
path: z.ZodString;
|
|
533
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
534
|
+
}, z.core.$loose>>;
|
|
535
|
+
actionId: z.ZodString;
|
|
536
|
+
kind: z.ZodString;
|
|
537
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
538
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
539
|
+
invocationId: z.ZodOptional<z.ZodString>;
|
|
540
|
+
input: z.ZodUnknown;
|
|
541
|
+
}, z.core.$loose>;
|
|
542
|
+
export declare const ActionCompletedPayloadSchema: z.ZodObject<{
|
|
543
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
544
|
+
id: z.ZodString;
|
|
545
|
+
path: z.ZodString;
|
|
546
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
547
|
+
}, z.core.$loose>>;
|
|
548
|
+
actionId: z.ZodString;
|
|
549
|
+
kind: z.ZodString;
|
|
550
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
551
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
552
|
+
invocationId: z.ZodOptional<z.ZodString>;
|
|
553
|
+
result: z.ZodUnknown;
|
|
554
|
+
}, z.core.$loose>;
|
|
555
|
+
export declare const ActionUncertainPayloadSchema: z.ZodObject<{
|
|
556
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
557
|
+
id: z.ZodString;
|
|
558
|
+
path: z.ZodString;
|
|
559
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
560
|
+
}, z.core.$loose>>;
|
|
561
|
+
actionId: z.ZodString;
|
|
562
|
+
}, z.core.$loose>;
|
|
563
|
+
export declare const EffectUncertainPayloadSchema: z.ZodObject<{
|
|
564
|
+
effectId: z.ZodString;
|
|
565
|
+
message: z.ZodOptional<z.ZodString>;
|
|
566
|
+
}, z.core.$loose>;
|
|
567
|
+
export declare const TurnCompletedPayloadSchema: z.ZodObject<{
|
|
568
|
+
output: z.ZodUnknown;
|
|
569
|
+
}, z.core.$loose>;
|
|
570
|
+
export declare const TurnPausedPayloadSchema: z.ZodObject<{
|
|
571
|
+
interactions: z.ZodArray<z.ZodObject<{
|
|
572
|
+
invocationId: z.ZodString;
|
|
573
|
+
interaction: z.ZodObject<{
|
|
574
|
+
id: z.ZodString;
|
|
575
|
+
kind: z.ZodString;
|
|
576
|
+
}, z.core.$loose>;
|
|
577
|
+
status: z.ZodOptional<z.ZodString>;
|
|
578
|
+
}, z.core.$loose>>;
|
|
579
|
+
}, z.core.$loose>;
|
|
580
|
+
/** Either `{ error: { code, message } }` or, when a segment threw, `{ message }`. */
|
|
581
|
+
export declare const TurnFailedPayloadSchema: z.ZodObject<{
|
|
582
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
583
|
+
code: z.ZodOptional<z.ZodString>;
|
|
584
|
+
message: z.ZodOptional<z.ZodString>;
|
|
585
|
+
}, z.core.$loose>>;
|
|
586
|
+
message: z.ZodOptional<z.ZodString>;
|
|
587
|
+
}, z.core.$loose>;
|
|
588
|
+
export declare const TurnCancelledPayloadSchema: z.ZodObject<{
|
|
589
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
590
|
+
}, z.core.$loose>;
|
|
591
|
+
/** Lifecycle of an agent used as a tool. `agent.delegationId` is the parent call's invocation. */
|
|
592
|
+
export declare const DelegationPayloadSchema: z.ZodObject<{
|
|
593
|
+
agent: z.ZodObject<{
|
|
594
|
+
id: z.ZodString;
|
|
595
|
+
path: z.ZodString;
|
|
596
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
597
|
+
}, z.core.$loose>;
|
|
598
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
599
|
+
}, z.core.$loose>;
|
|
600
|
+
declare const TRANSCRIPT_PAYLOADS: {
|
|
601
|
+
readonly "message.assistant": z.ZodObject<{
|
|
602
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
603
|
+
id: z.ZodString;
|
|
604
|
+
path: z.ZodString;
|
|
605
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
606
|
+
}, z.core.$loose>>;
|
|
607
|
+
invocationId: z.ZodString;
|
|
608
|
+
text: z.ZodString;
|
|
609
|
+
toolCalls: z.ZodArray<z.ZodObject<{
|
|
610
|
+
callId: z.ZodString;
|
|
611
|
+
name: z.ZodString;
|
|
612
|
+
input: z.ZodUnknown;
|
|
613
|
+
}, z.core.$loose>>;
|
|
614
|
+
}, z.core.$loose>;
|
|
615
|
+
readonly "tool.completed": z.ZodObject<{
|
|
616
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
617
|
+
id: z.ZodString;
|
|
618
|
+
path: z.ZodString;
|
|
619
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
620
|
+
}, z.core.$loose>>;
|
|
621
|
+
callId: z.ZodString;
|
|
622
|
+
invocationId: z.ZodString;
|
|
623
|
+
capabilityId: z.ZodString;
|
|
624
|
+
toolName: z.ZodString;
|
|
625
|
+
output: z.ZodOptional<z.ZodUnknown>;
|
|
626
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
627
|
+
code: z.ZodString;
|
|
628
|
+
message: z.ZodString;
|
|
629
|
+
}, z.core.$loose>>;
|
|
630
|
+
}, z.core.$loose>;
|
|
631
|
+
readonly "action.pending": z.ZodObject<{
|
|
632
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
633
|
+
id: z.ZodString;
|
|
634
|
+
path: z.ZodString;
|
|
635
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
636
|
+
}, z.core.$loose>>;
|
|
637
|
+
actionId: z.ZodString;
|
|
638
|
+
kind: z.ZodString;
|
|
639
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
640
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
641
|
+
invocationId: z.ZodOptional<z.ZodString>;
|
|
642
|
+
input: z.ZodUnknown;
|
|
643
|
+
}, z.core.$loose>;
|
|
644
|
+
readonly "action.completed": z.ZodObject<{
|
|
645
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
646
|
+
id: z.ZodString;
|
|
647
|
+
path: z.ZodString;
|
|
648
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
649
|
+
}, z.core.$loose>>;
|
|
650
|
+
actionId: z.ZodString;
|
|
651
|
+
kind: z.ZodString;
|
|
652
|
+
toolName: z.ZodOptional<z.ZodString>;
|
|
653
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
654
|
+
invocationId: z.ZodOptional<z.ZodString>;
|
|
655
|
+
result: z.ZodUnknown;
|
|
656
|
+
}, z.core.$loose>;
|
|
657
|
+
readonly "action.uncertain": z.ZodObject<{
|
|
658
|
+
agent: z.ZodOptional<z.ZodObject<{
|
|
659
|
+
id: z.ZodString;
|
|
660
|
+
path: z.ZodString;
|
|
661
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
662
|
+
}, z.core.$loose>>;
|
|
663
|
+
actionId: z.ZodString;
|
|
664
|
+
}, z.core.$loose>;
|
|
665
|
+
readonly "effect.uncertain": z.ZodObject<{
|
|
666
|
+
effectId: z.ZodString;
|
|
667
|
+
message: z.ZodOptional<z.ZodString>;
|
|
668
|
+
}, z.core.$loose>;
|
|
669
|
+
readonly "turn.completed": z.ZodObject<{
|
|
670
|
+
output: z.ZodUnknown;
|
|
671
|
+
}, z.core.$loose>;
|
|
672
|
+
readonly "turn.paused": z.ZodObject<{
|
|
673
|
+
interactions: z.ZodArray<z.ZodObject<{
|
|
674
|
+
invocationId: z.ZodString;
|
|
675
|
+
interaction: z.ZodObject<{
|
|
676
|
+
id: z.ZodString;
|
|
677
|
+
kind: z.ZodString;
|
|
678
|
+
}, z.core.$loose>;
|
|
679
|
+
status: z.ZodOptional<z.ZodString>;
|
|
680
|
+
}, z.core.$loose>>;
|
|
681
|
+
}, z.core.$loose>;
|
|
682
|
+
readonly "turn.failed": z.ZodObject<{
|
|
683
|
+
error: z.ZodOptional<z.ZodObject<{
|
|
684
|
+
code: z.ZodOptional<z.ZodString>;
|
|
685
|
+
message: z.ZodOptional<z.ZodString>;
|
|
686
|
+
}, z.core.$loose>>;
|
|
687
|
+
message: z.ZodOptional<z.ZodString>;
|
|
688
|
+
}, z.core.$loose>;
|
|
689
|
+
readonly "turn.cancelled": z.ZodObject<{
|
|
690
|
+
reason: z.ZodOptional<z.ZodString>;
|
|
691
|
+
}, z.core.$loose>;
|
|
692
|
+
readonly "delegation.started": z.ZodObject<{
|
|
693
|
+
agent: z.ZodObject<{
|
|
694
|
+
id: z.ZodString;
|
|
695
|
+
path: z.ZodString;
|
|
696
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
697
|
+
}, z.core.$loose>;
|
|
698
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
699
|
+
}, z.core.$loose>;
|
|
700
|
+
readonly "delegation.completed": z.ZodObject<{
|
|
701
|
+
agent: z.ZodObject<{
|
|
702
|
+
id: z.ZodString;
|
|
703
|
+
path: z.ZodString;
|
|
704
|
+
delegationId: z.ZodOptional<z.ZodString>;
|
|
705
|
+
}, z.core.$loose>;
|
|
706
|
+
callId: z.ZodOptional<z.ZodString>;
|
|
707
|
+
}, z.core.$loose>;
|
|
708
|
+
};
|
|
709
|
+
export type TranscriptEventType = keyof typeof TRANSCRIPT_PAYLOADS;
|
|
710
|
+
export declare const TRANSCRIPT_EVENT_TYPES: readonly TranscriptEventType[];
|
|
711
|
+
export type TranscriptEvent = {
|
|
712
|
+
[K in TranscriptEventType]: Omit<LiveEvent, "type" | "payload"> & {
|
|
713
|
+
type: K;
|
|
714
|
+
payload: z.infer<(typeof TRANSCRIPT_PAYLOADS)[K]>;
|
|
715
|
+
};
|
|
716
|
+
}[TranscriptEventType];
|
|
717
|
+
/** Types a transcript event's payload; `undefined` for other types or a malformed payload. */
|
|
718
|
+
export declare function parseTranscriptEvent(event: LiveEvent): TranscriptEvent | undefined;
|
|
505
719
|
export declare const ActionClaimRequestSchema: z.ZodObject<{
|
|
506
720
|
requestId: z.ZodString;
|
|
507
721
|
implementationVersion: z.ZodString;
|
|
@@ -767,6 +981,11 @@ export declare const CreateTenantRequestSchema: z.ZodObject<{
|
|
|
767
981
|
principalId: z.ZodString;
|
|
768
982
|
credentialHash: z.ZodString;
|
|
769
983
|
idempotencyKey: z.ZodString;
|
|
984
|
+
studioCredentialHash: z.ZodOptional<z.ZodString>;
|
|
985
|
+
derivedPrincipals: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
986
|
+
id: z.ZodString;
|
|
987
|
+
credentialHash: z.ZodString;
|
|
988
|
+
}, z.core.$strict>>>;
|
|
770
989
|
}, z.core.$strict>;
|
|
771
990
|
export type CreateTenantRequest = z.infer<typeof CreateTenantRequestSchema>;
|
|
772
991
|
export declare const AdminTenantSchema: z.ZodObject<{
|
|
@@ -790,7 +1009,6 @@ export declare const QuarantineSchema: z.ZodObject<{
|
|
|
790
1009
|
corrupt: "corrupt";
|
|
791
1010
|
"envelope-invalid": "envelope-invalid";
|
|
792
1011
|
"kek-missing": "kek-missing";
|
|
793
|
-
locked: "locked";
|
|
794
1012
|
"migration-failed": "migration-failed";
|
|
795
1013
|
"open-failed": "open-failed";
|
|
796
1014
|
"open-timeout": "open-timeout";
|
|
@@ -798,8 +1016,6 @@ export declare const QuarantineSchema: z.ZodObject<{
|
|
|
798
1016
|
}>;
|
|
799
1017
|
message: z.ZodString;
|
|
800
1018
|
repair: z.ZodString;
|
|
801
|
-
lockPath: z.ZodOptional<z.ZodString>;
|
|
802
|
-
lockPid: z.ZodOptional<z.ZodNumber>;
|
|
803
1019
|
}, z.core.$strict>;
|
|
804
1020
|
export type QuarantineInfo = z.infer<typeof QuarantineSchema>;
|
|
805
1021
|
export declare const AdminTenantStatusSchema: z.ZodObject<{
|
|
@@ -821,7 +1037,6 @@ export declare const AdminTenantStatusSchema: z.ZodObject<{
|
|
|
821
1037
|
corrupt: "corrupt";
|
|
822
1038
|
"envelope-invalid": "envelope-invalid";
|
|
823
1039
|
"kek-missing": "kek-missing";
|
|
824
|
-
locked: "locked";
|
|
825
1040
|
"migration-failed": "migration-failed";
|
|
826
1041
|
"open-failed": "open-failed";
|
|
827
1042
|
"open-timeout": "open-timeout";
|
|
@@ -829,8 +1044,6 @@ export declare const AdminTenantStatusSchema: z.ZodObject<{
|
|
|
829
1044
|
}>;
|
|
830
1045
|
message: z.ZodString;
|
|
831
1046
|
repair: z.ZodString;
|
|
832
|
-
lockPath: z.ZodOptional<z.ZodString>;
|
|
833
|
-
lockPid: z.ZodOptional<z.ZodNumber>;
|
|
834
1047
|
}, z.core.$strict>>;
|
|
835
1048
|
}, z.core.$strict>;
|
|
836
1049
|
export type AdminTenantStatus = z.infer<typeof AdminTenantStatusSchema>;
|
|
@@ -839,6 +1052,8 @@ export declare const HostAggregateSchema: z.ZodObject<{
|
|
|
839
1052
|
connectedExecutors: z.ZodNumber;
|
|
840
1053
|
pendingActions: z.ZodNumber;
|
|
841
1054
|
uncertainEffects: z.ZodNumber;
|
|
1055
|
+
outboxDepth: z.ZodOptional<z.ZodNumber>;
|
|
1056
|
+
relayLagMs: z.ZodOptional<z.ZodNumber>;
|
|
842
1057
|
}, z.core.$strict>;
|
|
843
1058
|
export type HostAggregate = z.infer<typeof HostAggregateSchema>;
|
|
844
1059
|
export declare const AdminHostStatusSchema: z.ZodObject<{
|
|
@@ -871,6 +1086,8 @@ export declare const AdminHostStatusSchema: z.ZodObject<{
|
|
|
871
1086
|
connectedExecutors: z.ZodNumber;
|
|
872
1087
|
pendingActions: z.ZodNumber;
|
|
873
1088
|
uncertainEffects: z.ZodNumber;
|
|
1089
|
+
outboxDepth: z.ZodOptional<z.ZodNumber>;
|
|
1090
|
+
relayLagMs: z.ZodOptional<z.ZodNumber>;
|
|
874
1091
|
}, z.core.$strict>;
|
|
875
1092
|
}, z.core.$strict>;
|
|
876
1093
|
export type AdminHostStatus = z.infer<typeof AdminHostStatusSchema>;
|
|
@@ -903,6 +1120,8 @@ export declare const AdminStatusSchema: z.ZodObject<{
|
|
|
903
1120
|
connectedExecutors: z.ZodNumber;
|
|
904
1121
|
pendingActions: z.ZodNumber;
|
|
905
1122
|
uncertainEffects: z.ZodNumber;
|
|
1123
|
+
outboxDepth: z.ZodOptional<z.ZodNumber>;
|
|
1124
|
+
relayLagMs: z.ZodOptional<z.ZodNumber>;
|
|
906
1125
|
}, z.core.$strict>;
|
|
907
1126
|
host: z.ZodOptional<z.ZodObject<{
|
|
908
1127
|
hostId: z.ZodString;
|
|
@@ -946,7 +1165,7 @@ export declare const TenantStatusSchema: z.ZodObject<{
|
|
|
946
1165
|
}, z.core.$strict>;
|
|
947
1166
|
path: z.ZodString;
|
|
948
1167
|
checks: z.ZodObject<{
|
|
949
|
-
|
|
1168
|
+
store: z.ZodBoolean;
|
|
950
1169
|
scheduler: z.ZodBoolean;
|
|
951
1170
|
model: z.ZodBoolean;
|
|
952
1171
|
executors: z.ZodBoolean;
|
|
@@ -979,6 +1198,33 @@ export declare const TenantStatusSchema: z.ZodObject<{
|
|
|
979
1198
|
backend: z.ZodNullable<z.ZodString>;
|
|
980
1199
|
retained: z.ZodNumber;
|
|
981
1200
|
}, z.core.$strict>;
|
|
1201
|
+
execution: z.ZodOptional<z.ZodObject<{
|
|
1202
|
+
stuckInvocations: z.ZodArray<z.ZodObject<{
|
|
1203
|
+
id: z.ZodString;
|
|
1204
|
+
status: z.ZodString;
|
|
1205
|
+
service: z.ZodString;
|
|
1206
|
+
handler: z.ZodString;
|
|
1207
|
+
key: z.ZodString;
|
|
1208
|
+
retryCount: z.ZodNumber;
|
|
1209
|
+
lastFailure: z.ZodOptional<z.ZodString>;
|
|
1210
|
+
modifiedAt: z.ZodOptional<z.ZodString>;
|
|
1211
|
+
}, z.core.$strict>>;
|
|
1212
|
+
error: z.ZodOptional<z.ZodString>;
|
|
1213
|
+
}, z.core.$strict>>;
|
|
1214
|
+
streams: z.ZodOptional<z.ZodObject<{
|
|
1215
|
+
reachable: z.ZodBoolean;
|
|
1216
|
+
basin: z.ZodObject<{
|
|
1217
|
+
ready: z.ZodBoolean;
|
|
1218
|
+
failures: z.ZodNumber;
|
|
1219
|
+
lastError: z.ZodNullable<z.ZodString>;
|
|
1220
|
+
}, z.core.$strict>;
|
|
1221
|
+
outbox: z.ZodObject<{
|
|
1222
|
+
depth: z.ZodNumber;
|
|
1223
|
+
oldestAgeMs: z.ZodNullable<z.ZodNumber>;
|
|
1224
|
+
}, z.core.$strict>;
|
|
1225
|
+
relayLagMs: z.ZodNumber;
|
|
1226
|
+
collectionPending: z.ZodBoolean;
|
|
1227
|
+
}, z.core.$strict>>;
|
|
982
1228
|
}, z.core.$strict>;
|
|
983
1229
|
export type TenantStatus = z.infer<typeof TenantStatusSchema>;
|
|
984
1230
|
export declare const SeedTenantConfigRequestSchema: z.ZodObject<{
|
|
@@ -986,7 +1232,6 @@ export declare const SeedTenantConfigRequestSchema: z.ZodObject<{
|
|
|
986
1232
|
sandbox: z.ZodOptional<z.ZodObject<{
|
|
987
1233
|
backend: z.ZodEnum<{
|
|
988
1234
|
auto: "auto";
|
|
989
|
-
microsandbox: "microsandbox";
|
|
990
1235
|
virtual: "virtual";
|
|
991
1236
|
}>;
|
|
992
1237
|
}, z.core.$strict>>;
|
|
@@ -1005,6 +1250,7 @@ export declare const SeedTenantConfigRequestSchema: z.ZodObject<{
|
|
|
1005
1250
|
expires: z.ZodNumber;
|
|
1006
1251
|
}, z.core.$loose>], "type">;
|
|
1007
1252
|
}, z.core.$strict>>;
|
|
1253
|
+
fixtureModel: z.ZodOptional<z.ZodLiteral<true>>;
|
|
1008
1254
|
}, z.core.$strict>;
|
|
1009
1255
|
export type SeedTenantConfigRequest = z.infer<typeof SeedTenantConfigRequestSchema>;
|
|
1010
1256
|
export declare const SeedTenantConfigResponseSchema: z.ZodObject<{
|
|
@@ -1025,3 +1271,22 @@ export declare const ResetTenantRequestSchema: z.ZodObject<{
|
|
|
1025
1271
|
}>;
|
|
1026
1272
|
}, z.core.$strict>;
|
|
1027
1273
|
export type ResetTenantRequest = z.infer<typeof ResetTenantRequestSchema>;
|
|
1274
|
+
/**
|
|
1275
|
+
* Acting for a subject (Host feature `subject-headers`): what an application principal may
|
|
1276
|
+
* narrow a request to. `sessions:own` and `vaults:own` reach only the subject's own sessions
|
|
1277
|
+
* and vaults; the others reach Tenant-wide resources.
|
|
1278
|
+
*/
|
|
1279
|
+
export declare const SUBJECT_SCOPES: readonly ["agents:read", "agents:write", "sessions:own", "vaults:own", "tenant:settings"];
|
|
1280
|
+
export type SubjectScope = (typeof SUBJECT_SCOPES)[number];
|
|
1281
|
+
/**
|
|
1282
|
+
* Validates `Nylorun-Subject` and `Nylorun-Scopes`. Returns the subject and its scopes, or a
|
|
1283
|
+
* message naming what is wrong. Scopes are required: the Runtime never grants a default.
|
|
1284
|
+
*/
|
|
1285
|
+
export declare function parseSubjectHeaders(subject: string, scopes: string | undefined): {
|
|
1286
|
+
ok: true;
|
|
1287
|
+
subject: string;
|
|
1288
|
+
scopes: ReadonlySet<SubjectScope>;
|
|
1289
|
+
} | {
|
|
1290
|
+
ok: false;
|
|
1291
|
+
message: string;
|
|
1292
|
+
};
|
package/dist/contracts.js
CHANGED
|
@@ -5,6 +5,7 @@ import { hookListIssue } from "./definition/hooks.js";
|
|
|
5
5
|
import { DELEGATE_INPUT_SCHEMA } from "./definition/delegate.js";
|
|
6
6
|
import { canonical } from "./utils/canonical.js";
|
|
7
7
|
export { PROTOCOL_VERSION, ERROR_CODES } from "./compatibility.js";
|
|
8
|
+
import { DERIVED_PRINCIPAL_ID_PATTERN } from "./compatibility.js";
|
|
8
9
|
import { ERROR_CODES } from "./compatibility.js";
|
|
9
10
|
export const RequestIdSchema = z.string().min(1);
|
|
10
11
|
export const IdempotencyKeySchema = z.string().min(1).max(256);
|
|
@@ -667,6 +668,126 @@ export const ActionSchema = z.union([
|
|
|
667
668
|
fnActionSchema,
|
|
668
669
|
verifyActionSchema,
|
|
669
670
|
]);
|
|
671
|
+
/**
|
|
672
|
+
* Transcript events (Host feature `transcript-events`): the log entries a chat UI
|
|
673
|
+
* renders. `LiveEvent.payload` stays `unknown` on the wire; `parseTranscriptEvent`
|
|
674
|
+
* types the ones a client reads. Objects pass unknown fields through, so a newer
|
|
675
|
+
* Host can add fields without breaking older clients.
|
|
676
|
+
*/
|
|
677
|
+
const eventAgent = { agent: AgentRefSchema.passthrough().optional() };
|
|
678
|
+
const toolIds = {
|
|
679
|
+
/** The model's tool call id. */
|
|
680
|
+
callId: z.string().min(1),
|
|
681
|
+
/** The harness invocation of the call; interactions refer to it. */
|
|
682
|
+
invocationId: z.string().min(1),
|
|
683
|
+
};
|
|
684
|
+
/** `message.assistant`: one completed model step. `invocationId` is the model call's. */
|
|
685
|
+
export const AssistantMessagePayloadSchema = z
|
|
686
|
+
.object({
|
|
687
|
+
invocationId: z.string().min(1),
|
|
688
|
+
text: z.string(),
|
|
689
|
+
toolCalls: z.array(z
|
|
690
|
+
.object({
|
|
691
|
+
callId: z.string().min(1),
|
|
692
|
+
name: z.string().min(1),
|
|
693
|
+
input: z.unknown(),
|
|
694
|
+
})
|
|
695
|
+
.passthrough()),
|
|
696
|
+
...eventAgent,
|
|
697
|
+
})
|
|
698
|
+
.passthrough();
|
|
699
|
+
/** `tool.completed`: an MCP or sandbox tool the Runtime ran. `error` for a tool error. */
|
|
700
|
+
export const ToolCompletedPayloadSchema = z
|
|
701
|
+
.object({
|
|
702
|
+
...toolIds,
|
|
703
|
+
capabilityId: z.string().min(1),
|
|
704
|
+
toolName: z.string().min(1),
|
|
705
|
+
output: z.unknown().optional(),
|
|
706
|
+
error: z.object({ code: z.string(), message: z.string() }).passthrough().optional(),
|
|
707
|
+
...eventAgent,
|
|
708
|
+
})
|
|
709
|
+
.passthrough();
|
|
710
|
+
/** `action.pending` and `action.completed`; tool actions carry `callId` and `invocationId`. */
|
|
711
|
+
const actionEventBase = {
|
|
712
|
+
actionId: z.string().min(1),
|
|
713
|
+
kind: z.string(),
|
|
714
|
+
toolName: z.string().optional(),
|
|
715
|
+
callId: z.string().optional(),
|
|
716
|
+
invocationId: z.string().optional(),
|
|
717
|
+
...eventAgent,
|
|
718
|
+
};
|
|
719
|
+
export const ActionPendingPayloadSchema = z
|
|
720
|
+
.object({ ...actionEventBase, input: z.unknown() })
|
|
721
|
+
.passthrough();
|
|
722
|
+
export const ActionCompletedPayloadSchema = z
|
|
723
|
+
.object({ ...actionEventBase, result: z.unknown() })
|
|
724
|
+
.passthrough();
|
|
725
|
+
export const ActionUncertainPayloadSchema = z
|
|
726
|
+
.object({ actionId: z.string().min(1), ...eventAgent })
|
|
727
|
+
.passthrough();
|
|
728
|
+
export const EffectUncertainPayloadSchema = z
|
|
729
|
+
.object({ effectId: z.string().min(1), message: z.string().optional() })
|
|
730
|
+
.passthrough();
|
|
731
|
+
export const TurnCompletedPayloadSchema = z
|
|
732
|
+
.object({ output: z.unknown() })
|
|
733
|
+
.passthrough();
|
|
734
|
+
export const TurnPausedPayloadSchema = z
|
|
735
|
+
.object({
|
|
736
|
+
interactions: z.array(z
|
|
737
|
+
.object({
|
|
738
|
+
invocationId: z.string().min(1),
|
|
739
|
+
interaction: z
|
|
740
|
+
.object({ id: z.string().min(1), kind: z.string() })
|
|
741
|
+
.passthrough(),
|
|
742
|
+
status: z.string().optional(),
|
|
743
|
+
})
|
|
744
|
+
.passthrough()),
|
|
745
|
+
})
|
|
746
|
+
.passthrough();
|
|
747
|
+
/** Either `{ error: { code, message } }` or, when a segment threw, `{ message }`. */
|
|
748
|
+
export const TurnFailedPayloadSchema = z
|
|
749
|
+
.object({
|
|
750
|
+
error: z
|
|
751
|
+
.object({ code: z.string().optional(), message: z.string().optional() })
|
|
752
|
+
.passthrough()
|
|
753
|
+
.optional(),
|
|
754
|
+
message: z.string().optional(),
|
|
755
|
+
})
|
|
756
|
+
.passthrough();
|
|
757
|
+
export const TurnCancelledPayloadSchema = z
|
|
758
|
+
.object({ reason: z.string().optional() })
|
|
759
|
+
.passthrough();
|
|
760
|
+
/** Lifecycle of an agent used as a tool. `agent.delegationId` is the parent call's invocation. */
|
|
761
|
+
export const DelegationPayloadSchema = z
|
|
762
|
+
.object({
|
|
763
|
+
agent: AgentRefSchema.passthrough(),
|
|
764
|
+
callId: z.string().optional(),
|
|
765
|
+
})
|
|
766
|
+
.passthrough();
|
|
767
|
+
const TRANSCRIPT_PAYLOADS = {
|
|
768
|
+
"message.assistant": AssistantMessagePayloadSchema,
|
|
769
|
+
"tool.completed": ToolCompletedPayloadSchema,
|
|
770
|
+
"action.pending": ActionPendingPayloadSchema,
|
|
771
|
+
"action.completed": ActionCompletedPayloadSchema,
|
|
772
|
+
"action.uncertain": ActionUncertainPayloadSchema,
|
|
773
|
+
"effect.uncertain": EffectUncertainPayloadSchema,
|
|
774
|
+
"turn.completed": TurnCompletedPayloadSchema,
|
|
775
|
+
"turn.paused": TurnPausedPayloadSchema,
|
|
776
|
+
"turn.failed": TurnFailedPayloadSchema,
|
|
777
|
+
"turn.cancelled": TurnCancelledPayloadSchema,
|
|
778
|
+
"delegation.started": DelegationPayloadSchema,
|
|
779
|
+
"delegation.completed": DelegationPayloadSchema,
|
|
780
|
+
};
|
|
781
|
+
export const TRANSCRIPT_EVENT_TYPES = Object.keys(TRANSCRIPT_PAYLOADS);
|
|
782
|
+
/** Types a transcript event's payload; `undefined` for other types or a malformed payload. */
|
|
783
|
+
export function parseTranscriptEvent(event) {
|
|
784
|
+
if (!Object.hasOwn(TRANSCRIPT_PAYLOADS, event.type))
|
|
785
|
+
return undefined;
|
|
786
|
+
const parsed = TRANSCRIPT_PAYLOADS[event.type].safeParse(event.payload);
|
|
787
|
+
return parsed.success
|
|
788
|
+
? { ...event, payload: parsed.data }
|
|
789
|
+
: undefined;
|
|
790
|
+
}
|
|
670
791
|
export const ActionClaimRequestSchema = z
|
|
671
792
|
.object({
|
|
672
793
|
requestId: RequestIdSchema,
|
|
@@ -763,11 +884,58 @@ export const CreateTenantRequestSchema = z
|
|
|
763
884
|
.object({
|
|
764
885
|
tenantId: z.string().min(1),
|
|
765
886
|
name: z.string().min(1),
|
|
766
|
-
|
|
887
|
+
/** `studio` is reserved for the derived Studio principal. */
|
|
888
|
+
principalId: z
|
|
889
|
+
.string()
|
|
890
|
+
.min(1)
|
|
891
|
+
.refine((id) => id !== "studio", "principalId `studio` is reserved"),
|
|
767
892
|
credentialHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
768
893
|
idempotencyKey: IdempotencyKeySchema,
|
|
894
|
+
/** SHA-256 of the derived Studio key; registers principal `studio` (feature `studio-principal`). */
|
|
895
|
+
studioCredentialHash: z
|
|
896
|
+
.string()
|
|
897
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
898
|
+
.optional(),
|
|
899
|
+
/**
|
|
900
|
+
* SHA-256 of each derived principal's key (feature `derived-principals`): application
|
|
901
|
+
* principals whose keys the admin key derives, so their clients store no key.
|
|
902
|
+
*/
|
|
903
|
+
derivedPrincipals: z
|
|
904
|
+
.array(z
|
|
905
|
+
.object({
|
|
906
|
+
id: z
|
|
907
|
+
.string()
|
|
908
|
+
.regex(DERIVED_PRINCIPAL_ID_PATTERN)
|
|
909
|
+
.refine((id) => id !== "studio", "principal id `studio` is reserved"),
|
|
910
|
+
credentialHash: z.string().regex(/^[0-9a-f]{64}$/),
|
|
911
|
+
})
|
|
912
|
+
.strict())
|
|
913
|
+
.max(16)
|
|
914
|
+
.optional(),
|
|
769
915
|
})
|
|
770
|
-
.strict()
|
|
916
|
+
.strict()
|
|
917
|
+
.superRefine((body, ctx) => {
|
|
918
|
+
const ids = new Set([body.principalId]);
|
|
919
|
+
const hashes = new Set([body.credentialHash]);
|
|
920
|
+
if (body.studioCredentialHash)
|
|
921
|
+
hashes.add(body.studioCredentialHash);
|
|
922
|
+
for (const [index, principal] of (body.derivedPrincipals ?? []).entries()) {
|
|
923
|
+
if (ids.has(principal.id))
|
|
924
|
+
ctx.addIssue({
|
|
925
|
+
code: "custom",
|
|
926
|
+
path: ["derivedPrincipals", index, "id"],
|
|
927
|
+
message: `Principal id ${principal.id} is used twice`,
|
|
928
|
+
});
|
|
929
|
+
if (hashes.has(principal.credentialHash))
|
|
930
|
+
ctx.addIssue({
|
|
931
|
+
code: "custom",
|
|
932
|
+
path: ["derivedPrincipals", index, "credentialHash"],
|
|
933
|
+
message: "Every principal needs its own credential",
|
|
934
|
+
});
|
|
935
|
+
ids.add(principal.id);
|
|
936
|
+
hashes.add(principal.credentialHash);
|
|
937
|
+
}
|
|
938
|
+
});
|
|
771
939
|
export const AdminTenantSchema = z
|
|
772
940
|
.object({
|
|
773
941
|
id: z.string().min(1),
|
|
@@ -779,7 +947,6 @@ export const AdminTenantSchema = z
|
|
|
779
947
|
export const QuarantineSchema = z
|
|
780
948
|
.object({
|
|
781
949
|
code: z.enum([
|
|
782
|
-
"locked",
|
|
783
950
|
"kek-missing",
|
|
784
951
|
"corrupt",
|
|
785
952
|
"schema-too-new",
|
|
@@ -790,8 +957,6 @@ export const QuarantineSchema = z
|
|
|
790
957
|
]),
|
|
791
958
|
message: z.string(),
|
|
792
959
|
repair: z.string(),
|
|
793
|
-
lockPath: z.string().optional(),
|
|
794
|
-
lockPid: z.number().int().optional(),
|
|
795
960
|
})
|
|
796
961
|
.strict();
|
|
797
962
|
export const AdminTenantStatusSchema = AdminTenantSchema.extend({
|
|
@@ -803,6 +968,10 @@ export const HostAggregateSchema = z
|
|
|
803
968
|
connectedExecutors: z.number().int().nonnegative(),
|
|
804
969
|
pendingActions: z.number().int().nonnegative(),
|
|
805
970
|
uncertainEffects: z.number().int().nonnegative(),
|
|
971
|
+
/** Events committed but not yet relayed to Durable Streams, over the open Tenants. */
|
|
972
|
+
outboxDepth: z.number().int().nonnegative().optional(),
|
|
973
|
+
/** The largest relay lag of an open Tenant: its oldest unrelayed event's age. */
|
|
974
|
+
relayLagMs: z.number().nonnegative().optional(),
|
|
806
975
|
})
|
|
807
976
|
.strict();
|
|
808
977
|
export const AdminHostStatusSchema = z
|
|
@@ -867,7 +1036,7 @@ export const TenantStatusSchema = z
|
|
|
867
1036
|
path: z.string().min(1),
|
|
868
1037
|
checks: z
|
|
869
1038
|
.object({
|
|
870
|
-
|
|
1039
|
+
store: z.boolean(),
|
|
871
1040
|
scheduler: z.boolean(),
|
|
872
1041
|
model: z.boolean(),
|
|
873
1042
|
executors: z.boolean(),
|
|
@@ -896,6 +1065,54 @@ export const TenantStatusSchema = z
|
|
|
896
1065
|
retained: z.number().int().nonnegative(),
|
|
897
1066
|
})
|
|
898
1067
|
.strict(),
|
|
1068
|
+
/**
|
|
1069
|
+
* Durable Session Execution invocations of this Tenant that need an operator: paused
|
|
1070
|
+
* after exhausting retries, or backing off after failures. Absent when the execution
|
|
1071
|
+
* cannot report them; `error` when it could not be asked.
|
|
1072
|
+
*/
|
|
1073
|
+
execution: z
|
|
1074
|
+
.object({
|
|
1075
|
+
stuckInvocations: z.array(z
|
|
1076
|
+
.object({
|
|
1077
|
+
id: z.string(),
|
|
1078
|
+
status: z.string(),
|
|
1079
|
+
service: z.string(),
|
|
1080
|
+
handler: z.string(),
|
|
1081
|
+
key: z.string(),
|
|
1082
|
+
retryCount: z.number().int().nonnegative(),
|
|
1083
|
+
lastFailure: z.string().optional(),
|
|
1084
|
+
modifiedAt: z.string().optional(),
|
|
1085
|
+
})
|
|
1086
|
+
.strict()),
|
|
1087
|
+
error: z.string().optional(),
|
|
1088
|
+
})
|
|
1089
|
+
.strict()
|
|
1090
|
+
.optional(),
|
|
1091
|
+
/**
|
|
1092
|
+
* This Tenant's Durable Streams: whether the service answers, its basin, the events
|
|
1093
|
+
* committed but not yet relayed, and how far the relay is behind.
|
|
1094
|
+
*/
|
|
1095
|
+
streams: z
|
|
1096
|
+
.object({
|
|
1097
|
+
reachable: z.boolean(),
|
|
1098
|
+
basin: z
|
|
1099
|
+
.object({
|
|
1100
|
+
ready: z.boolean(),
|
|
1101
|
+
failures: z.number().int().nonnegative(),
|
|
1102
|
+
lastError: z.string().nullable(),
|
|
1103
|
+
})
|
|
1104
|
+
.strict(),
|
|
1105
|
+
outbox: z
|
|
1106
|
+
.object({
|
|
1107
|
+
depth: z.number().int().nonnegative(),
|
|
1108
|
+
oldestAgeMs: z.number().nonnegative().nullable(),
|
|
1109
|
+
})
|
|
1110
|
+
.strict(),
|
|
1111
|
+
relayLagMs: z.number().nonnegative(),
|
|
1112
|
+
collectionPending: z.boolean(),
|
|
1113
|
+
})
|
|
1114
|
+
.strict()
|
|
1115
|
+
.optional(),
|
|
899
1116
|
})
|
|
900
1117
|
.strict();
|
|
901
1118
|
const seedModelSchema = PutHostModelRequestSchema.omit({
|
|
@@ -907,11 +1124,17 @@ export const SeedTenantConfigRequestSchema = z
|
|
|
907
1124
|
requestId: RequestIdSchema,
|
|
908
1125
|
sandbox: z
|
|
909
1126
|
.object({
|
|
910
|
-
backend: z.enum(["auto", "
|
|
1127
|
+
backend: z.enum(["auto", "virtual"]),
|
|
911
1128
|
})
|
|
912
1129
|
.strict()
|
|
913
1130
|
.optional(),
|
|
914
1131
|
model: seedModelSchema.optional(),
|
|
1132
|
+
/**
|
|
1133
|
+
* The Tenant's model calls use the Runtime's deterministic fixture model instead of its
|
|
1134
|
+
* host model, e.g. for a temporary test Tenant (scripts/lib/temporary-tenant.mjs). Stored
|
|
1135
|
+
* as Tenant setting `model.fixture`. Host feature `tenant-fixture-model`.
|
|
1136
|
+
*/
|
|
1137
|
+
fixtureModel: z.literal(true).optional(),
|
|
915
1138
|
})
|
|
916
1139
|
.strict();
|
|
917
1140
|
export const SeedTenantConfigResponseSchema = z
|
|
@@ -927,3 +1150,46 @@ export const ResetTenantRequestSchema = z
|
|
|
927
1150
|
activeWork: z.enum(["drain", "cancel"]),
|
|
928
1151
|
})
|
|
929
1152
|
.strict();
|
|
1153
|
+
/**
|
|
1154
|
+
* Acting for a subject (Host feature `subject-headers`): what an application principal may
|
|
1155
|
+
* narrow a request to. `sessions:own` and `vaults:own` reach only the subject's own sessions
|
|
1156
|
+
* and vaults; the others reach Tenant-wide resources.
|
|
1157
|
+
*/
|
|
1158
|
+
export const SUBJECT_SCOPES = [
|
|
1159
|
+
"agents:read",
|
|
1160
|
+
"agents:write",
|
|
1161
|
+
"sessions:own",
|
|
1162
|
+
"vaults:own",
|
|
1163
|
+
"tenant:settings",
|
|
1164
|
+
];
|
|
1165
|
+
/** 1–200 visible ASCII characters; spaces only inside. */
|
|
1166
|
+
const SUBJECT_PATTERN = /^[\x21-\x7e](?:[\x20-\x7e]{0,198}[\x21-\x7e])?$/;
|
|
1167
|
+
/** Owner ids the Runtime uses itself: the host model's vault is owned by `host`. */
|
|
1168
|
+
const RESERVED_SUBJECTS = new Set(["host"]);
|
|
1169
|
+
/**
|
|
1170
|
+
* Validates `Nylorun-Subject` and `Nylorun-Scopes`. Returns the subject and its scopes, or a
|
|
1171
|
+
* message naming what is wrong. Scopes are required: the Runtime never grants a default.
|
|
1172
|
+
*/
|
|
1173
|
+
export function parseSubjectHeaders(subject, scopes) {
|
|
1174
|
+
if (!SUBJECT_PATTERN.test(subject))
|
|
1175
|
+
return {
|
|
1176
|
+
ok: false,
|
|
1177
|
+
message: "Nylorun-Subject must be 1-200 visible ASCII characters",
|
|
1178
|
+
};
|
|
1179
|
+
if (RESERVED_SUBJECTS.has(subject))
|
|
1180
|
+
return { ok: false, message: `Subject ${subject} is reserved` };
|
|
1181
|
+
const names = (scopes ?? "").split(" ").filter(Boolean);
|
|
1182
|
+
if (names.length === 0)
|
|
1183
|
+
return {
|
|
1184
|
+
ok: false,
|
|
1185
|
+
message: "Nylorun-Scopes is required with Nylorun-Subject",
|
|
1186
|
+
};
|
|
1187
|
+
const unknown = names.filter((name) => !SUBJECT_SCOPES.includes(name));
|
|
1188
|
+
if (unknown.length > 0)
|
|
1189
|
+
return { ok: false, message: `Unknown scope ${unknown.join(", ")}` };
|
|
1190
|
+
return {
|
|
1191
|
+
ok: true,
|
|
1192
|
+
subject,
|
|
1193
|
+
scopes: new Set(names),
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
@@ -12,7 +12,7 @@ export const SANDBOX_INSTRUCTIONS = `You have an isolated Linux sandbox with a p
|
|
|
12
12
|
* reaching this means the agent ran without a Nylorun Runtime.
|
|
13
13
|
*/
|
|
14
14
|
async function runtimeOnly() {
|
|
15
|
-
throw new ToolError("sandbox.runtime-only", "Sandbox tools run in the Nylorun Runtime.
|
|
15
|
+
throw new ToolError("sandbox.runtime-only", "Sandbox tools run in the Nylorun Runtime. Connect the agent to a Runtime (npx nylorun up, then npm run dev) to use them.");
|
|
16
16
|
}
|
|
17
17
|
/** The six built-in sandbox tools. Schemas are part of the hashed manifest; change them deliberately. */
|
|
18
18
|
export function createSandboxTools() {
|
package/dist/utils/hash.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { sha256 } from "@noble/hashes/
|
|
2
|
-
import { bytesToHex } from "@noble/hashes/utils";
|
|
1
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2
|
+
import { bytesToHex, utf8ToBytes } from "@noble/hashes/utils.js";
|
|
3
3
|
import { canonical } from "./canonical.js";
|
|
4
4
|
/** Canonical SHA-256 hex digest of an agent or workflow definition document. */
|
|
5
5
|
export function hashManifest(manifest) {
|
|
6
|
-
return bytesToHex(sha256(canonical(manifest)));
|
|
6
|
+
return bytesToHex(sha256(utf8ToBytes(canonical(manifest))));
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0-beta",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"description": "Shared agent definitions and wire contracts",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/nylorun/
|
|
9
|
+
"url": "git+https://github.com/nylorun/agents.git",
|
|
10
10
|
"directory": "core"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"prepack": "npm run build"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@noble/hashes": "^
|
|
33
|
+
"@noble/hashes": "^2.4.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "^26.5.0",
|