@nylorun/core 0.17.0-beta → 0.19.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 +30 -0
- package/README.md +10 -0
- package/dist/compatibility.d.ts +7 -1
- package/dist/compatibility.js +6 -0
- package/dist/contracts.d.ts +83 -4
- package/dist/contracts.js +161 -33
- package/dist/definition/from.js +22 -188
- package/dist/definition/removed.d.ts +4 -2
- package/dist/definition/removed.js +8 -2
- package/dist/harness-api/messages.d.ts +30 -352
- package/dist/harness-api/messages.js +2 -6
- package/dist/harness-api/schema.d.ts +704 -13
- package/dist/harness-api/schema.js +138 -53
- package/dist/harness-api/transcript.d.ts +3 -5
- package/dist/harness-api/transcript.js +0 -5
- package/dist/project.d.ts +67 -0
- package/dist/project.js +210 -0
- package/dist/transport.d.ts +52 -0
- package/dist/transport.js +73 -0
- package/package.json +9 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.19.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 212364b: **Credentials for skills (R2c).** A skill's CLI in a pod sandbox authenticates with a vault credential whose value never enters the sandbox.
|
|
8
|
+
|
|
9
|
+
- `@nylorun/core`: vault credentials gain `environment_secret` (`secretName`, `secretValue`, `allowedHosts`, optional `inject: { header, format }`) and `environment_variable` (`variableName`, `variableValue`), in create, rotate and `CredentialInfo` (whose `binding.url` is now optional). `ENVIRONMENT_SECRET_SENTINEL` (`nylorun-managed`), `ENVIRONMENT_SECRET_DEFAULT_INJECT`, `isInjectFormat`, `renderInjectFormat`, `EnvironmentNameSchema` and `RESERVED_ENVIRONMENT_NAMES` are exported; `ERROR_CODES` gains `credential_conflict`; the Harness API's `RunRouting.sandbox` gains `environment`.
|
|
10
|
+
- `@nylorun/runtime`: every sandbox command gets each secret's name set to `nylorun-managed` and each variable's value. egress-gate terminates TLS for port 443 of a host an `environment_secret` of the sandbox's sessions is bound to, with a fresh leaf signed by the installation's egress CA (held by keys; its certificate reaches the pod in the join answer, and the engine points `SSL_CERT_FILE`, `NODE_EXTRA_CA_CERTS`, `REQUESTS_CA_BUNDLE`, `CURL_CA_BUNDLE`, `GIT_SSL_CAINFO` and `AWS_CA_BUNDLE` at a bundle with it), and sets the credential's header on every request from the vault, uncached. Every other host stays an opaque tunnel. Session open answers `409 credential_conflict` for two credentials with one variable name or one host, or two owners' secrets on one sandbox. No protocol change.
|
|
11
|
+
- `@nylorun/studio`: the Credentials page lists shell credentials (their variable and hosts) and deletes them; create and rotate them with the Management API.
|
|
12
|
+
|
|
13
|
+
## 0.18.0-beta
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- 7780b2f: **One client and connection layer.** The Project link and credentials are read one way, and every Runtime client shares one `/health` probe.
|
|
18
|
+
|
|
19
|
+
- `@nylorun/core`: `@nylorun/core/project` (Node only, the one Core subpath that imports Node modules) reads the Nylorun home, a local Tenant's Host root (`tenantHostRoot`), the Project root (`findProjectRoot`) and the Project link and credentials (`findLinkedProject`, `readProjectLink`, `readCredentialsFile`), validated with `ProjectLinkFileSchema` and `ProjectCredentialsFileSchema`; a broken or newer file throws `ProjectFileError`. `@nylorun/core/transport` (browser-safe) holds the `/health` compatibility probe (`checkHealth`), `parseProtocolRange` (on `ProtocolRangeSchema`, ignoring fields a newer Host adds), `describeIncompatibility`, `requestHeaders` and `readBody`.
|
|
20
|
+
- `@nylorun/agents`: `resolveConnection` and `createClient()` find the Project as every reader does: the nearest directory with `.nylorun/` from `cwd` upwards, never the home directory or above it (they used to walk to the filesystem root, and past a `.nylorun/` without a link). A link without `credentials.json`, or a link or credentials file that does not validate, is now `connection_missing` naming the file and `npx nylorun start`, instead of a raw file-system or parse error. `@nylorun/agents/client` loads the link reader only when `createClient()` resolves a connection, so it imports no Node module. The root entry re-exports `checkHealth`, `describeIncompatibility` and `parseProtocolRange`.
|
|
21
|
+
- `@nylorun/admin`: `createAdmin` reads the Project link with the same reader. A link that does not validate is now refused like one from an older nylorun (when nothing else names the Host root), and a linked Project's `credentials.json` that does not validate is `connection_missing` instead of being skipped. `@nylorun/admin/project` re-exports `@nylorun/core/project` for tools that depend on this package. The `/health` check and request headers come from `@nylorun/core/transport`.
|
|
22
|
+
- `nylorun`: reads the Project link and credentials with `@nylorun/core/project`; a credentials file whose keys are not 64 hex characters is replaced by `start`, as an unreadable one was. No command changes.
|
|
23
|
+
- `@nylorun/cli`: `nylo` reads the Project root, link and credentials through `@nylorun/admin/project` instead of its own copies, with the same messages. No command changes.
|
|
24
|
+
- `@nylorun/studio`: the server's Runtime compatibility probe is `checkHealth` from `@nylorun/agents`.
|
|
25
|
+
|
|
26
|
+
- 070674d: **One source of truth for the manifest and Harness API schemas.**
|
|
27
|
+
|
|
28
|
+
- `@nylorun/core`: `Agent.from` (`agentFrom`) checks a manifest with `AgentManifestSchema`, the Runtime's own check, instead of a validator of its own, and refuses with `agent.build-failed` and the schema's messages (each prefixed with its path, such as `capabilities.0.tools.0.name: …`). It now refuses what the Runtime refuses at registration and it let through, such as unknown fields (it dropped them) or a tool or MCP server name that not every model provider accepts. The schema names a top-level `model` or `schemaVersion` and a capability's `model` as before, and the skill whose `files` are wrong (`Skill 'triage' files must include SKILL.md`). The rebuilt manifest is a frozen copy; the object passed in is no longer frozen. `AgentManifestSchema` and `WorkflowManifestSchema` are no longer force-cast to their types: the build checks that each accepts exactly `AgentManifest` and `WorkflowManifest`. `@nylorun/core/contracts` exports `McpServerManifestSchema`, `HEADER_NAME_PATTERN` and `LOOPBACK_HOSTS`. The Harness API's types (`@nylorun/core/harness-api`) are inferred from the schemas that validate its frames, so they match them: `TurnStart.manifest`, `TurnStart.checkpoint` and `RunRouting.rootManifest` are `object`, `WorkspaceCall.tool` is a sandbox tool name, `ABORT_REASONS` is a tuple, and properties are no longer `readonly` (arrays that were stay so).
|
|
29
|
+
- `@nylorun/harness`: `runDurable` checks the manifest once, when it rebuilds the agent, instead of twice. The unpublished, stale `schemas/manifest.schema.json` (manifest `schemaVersion` 2) is gone; `z.toJSONSchema(AgentManifestSchema)` is the manifest's JSON Schema.
|
|
30
|
+
- `@nylorun/agents`: a plugin's MCP servers are checked with core's `McpServerManifestSchema`, header-name pattern and loopback hosts. A server whose key is not a name every model provider accepts is skipped with a `plugin.mcp-server-skipped` warning, since the Runtime would refuse the manifest declaring it.
|
|
31
|
+
- `@nylorun/runtime`: the stack configuration reads its four listeners (`NYLORUN_LISTEN_*`, `NYLORUN_GATES_LISTEN_*`, `NYLORUN_HARNESS_LISTEN_*`, `NYLORUN_EGRESS_LISTEN_*`) with one parser; the variables and their errors are unchanged.
|
|
32
|
+
|
|
3
33
|
## 0.17.0-beta
|
|
4
34
|
|
|
5
35
|
### Major Changes
|
package/README.md
CHANGED
|
@@ -6,6 +6,16 @@ HTTP client, Node host or SDK dependencies.
|
|
|
6
6
|
- `/define`: `Agent`, `tool`, capabilities, schemas and explicit local bindings.
|
|
7
7
|
- `/contracts`: runtime request, event, action and response schemas.
|
|
8
8
|
- `/compatibility`: protocol/definition versions and canonical manifest hashing.
|
|
9
|
+
- `/transport`: what every Runtime client does on the wire: the `/health`
|
|
10
|
+
compatibility probe (`checkHealth`), protocol ranges, request headers and
|
|
11
|
+
response bodies. Browser-safe; `@nylorun/agents` and `@nylorun/admin` build on it.
|
|
12
|
+
- `/project` (**Node only**, the one subpath that imports Node modules): the
|
|
13
|
+
Nylorun home, a local Tenant's Host root, the Project root, and the Project
|
|
14
|
+
link and credentials, validated with `ProjectLinkFileSchema` and
|
|
15
|
+
`ProjectCredentialsFileSchema`. Every reader of the link uses it (the SDK,
|
|
16
|
+
`@nylorun/admin`, `nylorun` and `nylo`): the Project is the nearest directory
|
|
17
|
+
with `.nylorun/`, from the working directory upwards, never the home
|
|
18
|
+
directory or above it; a broken file throws `ProjectFileError`.
|
|
9
19
|
- Root: shared contracts and types; no authoring or execution entry points.
|
|
10
20
|
|
|
11
21
|
Applications normally import `@nylorun/agents`. Hosts and the execution engine
|
package/dist/compatibility.d.ts
CHANGED
|
@@ -145,7 +145,13 @@ export declare const ERROR_CODES: readonly ["not_found",
|
|
|
145
145
|
* address the Host refuses, a connection that failed or a server silent past 15 s;
|
|
146
146
|
* `mcp.forbidden`, `mcp.status`, `mcp.error`).
|
|
147
147
|
*/
|
|
148
|
-
"mcp_preview_failed",
|
|
148
|
+
"mcp_preview_failed",
|
|
149
|
+
/**
|
|
150
|
+
* A session's shell credentials would be ambiguous (R2c, D50): `409`. Two attached
|
|
151
|
+
* `environment_secret` or `environment_variable` credentials share a variable name, two
|
|
152
|
+
* secrets are bound to one host, or the sandbox would serve secrets to sessions of two owners.
|
|
153
|
+
*/
|
|
154
|
+
"credential_conflict", "internal_error"];
|
|
149
155
|
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
150
156
|
export declare const TENANT_ID_PATTERN: RegExp;
|
|
151
157
|
export declare const PRINCIPAL_ID_PATTERN: RegExp;
|
package/dist/compatibility.js
CHANGED
|
@@ -168,6 +168,12 @@ export const ERROR_CODES = [
|
|
|
168
168
|
* `mcp.forbidden`, `mcp.status`, `mcp.error`).
|
|
169
169
|
*/
|
|
170
170
|
"mcp_preview_failed",
|
|
171
|
+
/**
|
|
172
|
+
* A session's shell credentials would be ambiguous (R2c, D50): `409`. Two attached
|
|
173
|
+
* `environment_secret` or `environment_variable` credentials share a variable name, two
|
|
174
|
+
* secrets are bound to one host, or the sandbox would serve secrets to sessions of two owners.
|
|
175
|
+
*/
|
|
176
|
+
"credential_conflict",
|
|
171
177
|
"internal_error",
|
|
172
178
|
];
|
|
173
179
|
/** Crockford Base32 alphabet (lowercase); excludes i, l, o, u. */
|
package/dist/contracts.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Public wire contracts only. Never import checkpoint or engine modules here. */
|
|
2
2
|
import { z } from "zod";
|
|
3
|
-
import type { AgentManifest } from "./types/manifest.js";
|
|
3
|
+
import type { AgentManifest, McpServerManifest } from "./types/manifest.js";
|
|
4
4
|
import type { JsonValue } from "./types/shared.js";
|
|
5
5
|
import type { WorkflowManifest } from "./types/workflow.js";
|
|
6
6
|
export type { AgentManifest } from "./types/manifest.js";
|
|
@@ -10,9 +10,15 @@ export { DEFINITION_FILE_MAX_BYTES, SKILL_FILES_MAX, definitionFilesOf, isDefini
|
|
|
10
10
|
export type { ErrorCode } from "./compatibility.js";
|
|
11
11
|
export declare const RequestIdSchema: z.ZodString;
|
|
12
12
|
export declare const IdempotencyKeySchema: z.ZodString;
|
|
13
|
+
/** A remote MCP server as a manifest declares it (`streamable-http` or `sse`). */
|
|
14
|
+
export declare const McpServerManifestSchema: z.ZodType<McpServerManifest>;
|
|
15
|
+
/**
|
|
16
|
+
* An agent's manifest (manifest v5 and v6). Its output is checked against `AgentManifest` here and
|
|
17
|
+
* below (`ManifestDrift`): the hand-written type keeps its read-only fields and its docs.
|
|
18
|
+
*/
|
|
13
19
|
export declare const AgentManifestSchema: z.ZodType<AgentManifest>;
|
|
14
20
|
/** Workflow definition document. `kind: "workflow"`; a missing `kind` is never a workflow. */
|
|
15
|
-
export declare const WorkflowManifestSchema: z.ZodType<WorkflowManifest
|
|
21
|
+
export declare const WorkflowManifestSchema: z.ZodType<WorkflowManifest, unknown, z.core.$ZodTypeInternals<WorkflowManifest, unknown>>;
|
|
16
22
|
/** Registry document: agent (no `kind`, or legacy) or workflow (`kind: "workflow"`). */
|
|
17
23
|
export declare const DefinitionDocumentSchema: z.ZodUnion<readonly [z.ZodType<AgentManifest, unknown, z.core.$ZodTypeInternals<AgentManifest, unknown>>, z.ZodType<WorkflowManifest, unknown, z.core.$ZodTypeInternals<WorkflowManifest, unknown>>]>;
|
|
18
24
|
export type DefinitionDocument = AgentManifest | WorkflowManifest;
|
|
@@ -470,6 +476,10 @@ export declare const CreateVaultRequestSchema: z.ZodObject<{
|
|
|
470
476
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
471
477
|
}, z.core.$strict>;
|
|
472
478
|
export type CreateVaultRequest = z.infer<typeof CreateVaultRequestSchema>;
|
|
479
|
+
/** An RFC 9110 field name. */
|
|
480
|
+
export declare const HEADER_NAME_PATTERN: RegExp;
|
|
481
|
+
/** A loopback host as a URL's `hostname` names it: plain `http` reaches only these. */
|
|
482
|
+
export declare const LOOPBACK_HOSTS: RegExp;
|
|
473
483
|
/**
|
|
474
484
|
* `via` (R2b C2, Q11): where this installation reaches the credential's server, such as a
|
|
475
485
|
* gateway's endpoint for it. An absolute `https` URL (`http` only to a loopback host), with no
|
|
@@ -486,6 +496,34 @@ export declare const CredentialIdentitySchema: z.ZodObject<{
|
|
|
486
496
|
header: z.ZodString;
|
|
487
497
|
}, z.core.$strict>;
|
|
488
498
|
export type CredentialIdentity = z.infer<typeof CredentialIdentitySchema>;
|
|
499
|
+
/**
|
|
500
|
+
* An environment variable name a shell secret or plain variable may take (R2c, D50): a POSIX
|
|
501
|
+
* name. Names the sandbox needs for itself (the proxy, the trust store, `PATH`, `HOME`) and
|
|
502
|
+
* `NYLORUN_*` are reserved.
|
|
503
|
+
*/
|
|
504
|
+
export declare const ENVIRONMENT_NAME_PATTERN: RegExp;
|
|
505
|
+
export declare const RESERVED_ENVIRONMENT_NAMES: ReadonlySet<string>;
|
|
506
|
+
export declare function isReservedEnvironmentName(name: string): boolean;
|
|
507
|
+
/** The value a sandbox sees for every `environment_secret` (R2c, D50): never the secret. */
|
|
508
|
+
export declare const ENVIRONMENT_SECRET_SENTINEL = "nylorun-managed";
|
|
509
|
+
/**
|
|
510
|
+
* How egress-gate writes an `environment_secret` into a request (R2c, D50): one header, set on
|
|
511
|
+
* every request to a bound host. `format` is text with `{value}` once, optionally inside a
|
|
512
|
+
* `{base64:…}` group, for example `Bearer {value}` (the default),
|
|
513
|
+
* `Basic {base64:x-access-token:{value}}` or `{value}`.
|
|
514
|
+
*/
|
|
515
|
+
export declare const ENVIRONMENT_SECRET_DEFAULT_INJECT: {
|
|
516
|
+
readonly header: "Authorization";
|
|
517
|
+
readonly format: "Bearer {value}";
|
|
518
|
+
};
|
|
519
|
+
export declare function isInjectFormat(format: string): boolean;
|
|
520
|
+
/** `format` with `{value}` replaced, and each `{base64:…}` group encoded. */
|
|
521
|
+
export declare function renderInjectFormat(format: string, value: string): string;
|
|
522
|
+
export declare const EnvironmentSecretInjectSchema: z.ZodObject<{
|
|
523
|
+
header: z.ZodString;
|
|
524
|
+
format: z.ZodString;
|
|
525
|
+
}, z.core.$strict>;
|
|
526
|
+
export type EnvironmentSecretInject = z.infer<typeof EnvironmentSecretInjectSchema>;
|
|
489
527
|
/**
|
|
490
528
|
* A credential for the server at `url` (the URL a manifest names): `bearer` sends
|
|
491
529
|
* `Authorization: Bearer <token>`, `headers` its header map (R2b C2). The header names may not be
|
|
@@ -511,6 +549,19 @@ export declare const CreateCredentialRequestSchema: z.ZodObject<{
|
|
|
511
549
|
type: z.ZodLiteral<"headers">;
|
|
512
550
|
url: z.ZodString;
|
|
513
551
|
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
552
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
553
|
+
type: z.ZodLiteral<"environment_secret">;
|
|
554
|
+
secretName: z.ZodString;
|
|
555
|
+
secretValue: z.ZodString;
|
|
556
|
+
allowedHosts: z.ZodArray<z.ZodString>;
|
|
557
|
+
inject: z.ZodOptional<z.ZodObject<{
|
|
558
|
+
header: z.ZodString;
|
|
559
|
+
format: z.ZodString;
|
|
560
|
+
}, z.core.$strict>>;
|
|
561
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
562
|
+
type: z.ZodLiteral<"environment_variable">;
|
|
563
|
+
variableName: z.ZodString;
|
|
564
|
+
variableValue: z.ZodString;
|
|
514
565
|
}, z.core.$strict>], "type">;
|
|
515
566
|
}, z.core.$strict>;
|
|
516
567
|
export type CreateCredentialRequest = z.infer<typeof CreateCredentialRequestSchema>;
|
|
@@ -535,6 +586,12 @@ export declare const RotateCredentialRequestSchema: z.ZodObject<{
|
|
|
535
586
|
}, z.core.$strict>>>;
|
|
536
587
|
type: z.ZodLiteral<"headers">;
|
|
537
588
|
headers: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
589
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
590
|
+
type: z.ZodLiteral<"environment_secret">;
|
|
591
|
+
secretValue: z.ZodString;
|
|
592
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
593
|
+
type: z.ZodLiteral<"environment_variable">;
|
|
594
|
+
variableValue: z.ZodString;
|
|
538
595
|
}, z.core.$strict>], "type">;
|
|
539
596
|
}, z.core.$strict>;
|
|
540
597
|
export type RotateCredentialRequest = z.infer<typeof RotateCredentialRequestSchema>;
|
|
@@ -607,10 +664,20 @@ export declare const CredentialInfoSchema: z.ZodObject<{
|
|
|
607
664
|
name: z.ZodString;
|
|
608
665
|
type: z.ZodEnum<{
|
|
609
666
|
bearer: "bearer";
|
|
667
|
+
environment_secret: "environment_secret";
|
|
668
|
+
environment_variable: "environment_variable";
|
|
610
669
|
headers: "headers";
|
|
611
670
|
}>;
|
|
612
671
|
binding: z.ZodObject<{
|
|
613
|
-
url: z.ZodString
|
|
672
|
+
url: z.ZodOptional<z.ZodString>;
|
|
673
|
+
secretName: z.ZodOptional<z.ZodString>;
|
|
674
|
+
allowedHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
675
|
+
inject: z.ZodOptional<z.ZodObject<{
|
|
676
|
+
header: z.ZodString;
|
|
677
|
+
format: z.ZodString;
|
|
678
|
+
}, z.core.$strict>>;
|
|
679
|
+
variableName: z.ZodOptional<z.ZodString>;
|
|
680
|
+
variableValue: z.ZodOptional<z.ZodString>;
|
|
614
681
|
}, z.core.$strict>;
|
|
615
682
|
headerNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
616
683
|
via: z.ZodOptional<z.ZodString>;
|
|
@@ -989,6 +1056,7 @@ export declare const RejectedResponseSchema: z.ZodObject<{
|
|
|
989
1056
|
status: z.ZodLiteral<"rejected">;
|
|
990
1057
|
code: z.ZodEnum<{
|
|
991
1058
|
connection_missing: "connection_missing";
|
|
1059
|
+
credential_conflict: "credential_conflict";
|
|
992
1060
|
credential_invalid: "credential_invalid";
|
|
993
1061
|
credential_rejected: "credential_rejected";
|
|
994
1062
|
credential_required: "credential_required";
|
|
@@ -2919,10 +2987,20 @@ export declare const ListCredentialsResponseSchema: z.ZodObject<{
|
|
|
2919
2987
|
name: z.ZodString;
|
|
2920
2988
|
type: z.ZodEnum<{
|
|
2921
2989
|
bearer: "bearer";
|
|
2990
|
+
environment_secret: "environment_secret";
|
|
2991
|
+
environment_variable: "environment_variable";
|
|
2922
2992
|
headers: "headers";
|
|
2923
2993
|
}>;
|
|
2924
2994
|
binding: z.ZodObject<{
|
|
2925
|
-
url: z.ZodString
|
|
2995
|
+
url: z.ZodOptional<z.ZodString>;
|
|
2996
|
+
secretName: z.ZodOptional<z.ZodString>;
|
|
2997
|
+
allowedHosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2998
|
+
inject: z.ZodOptional<z.ZodObject<{
|
|
2999
|
+
header: z.ZodString;
|
|
3000
|
+
format: z.ZodString;
|
|
3001
|
+
}, z.core.$strict>>;
|
|
3002
|
+
variableName: z.ZodOptional<z.ZodString>;
|
|
3003
|
+
variableValue: z.ZodOptional<z.ZodString>;
|
|
2926
3004
|
}, z.core.$strict>;
|
|
2927
3005
|
headerNames: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
2928
3006
|
via: z.ZodOptional<z.ZodString>;
|
|
@@ -2955,6 +3033,7 @@ export type StreamClosedFrame = z.infer<typeof StreamClosedFrameSchema>;
|
|
|
2955
3033
|
*/
|
|
2956
3034
|
export declare const AgUiRunErrorCodeSchema: z.ZodEnum<{
|
|
2957
3035
|
connection_missing: "connection_missing";
|
|
3036
|
+
credential_conflict: "credential_conflict";
|
|
2958
3037
|
credential_invalid: "credential_invalid";
|
|
2959
3038
|
credential_rejected: "credential_rejected";
|
|
2960
3039
|
credential_required: "credential_required";
|
package/dist/contracts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** Public wire contracts only. Never import checkpoint or engine modules here. */
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, isSandboxHostPattern, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
|
|
4
|
-
import { REMOVED_CAPABILITY_FIELDS, manifestVersionIssue, workflowVersionIssue, } from "./definition/removed.js";
|
|
4
|
+
import { REMOVED_CAPABILITY_FIELDS, REMOVED_MANIFEST_FIELDS, manifestVersionIssue, workflowVersionIssue, } from "./definition/removed.js";
|
|
5
5
|
import { DELEGATE_INPUT_SCHEMA, DELEGATE_NAME_PATTERN } from "./definition/delegate.js";
|
|
6
6
|
import { mcpToolSettingsVersionIssue, stdioMcpRefusal, usesMcpToolSettings, } from "./definition/mcp.js";
|
|
7
7
|
import { APPROVAL_MODES, HTTP_TOOL_MAX_TIMEOUT_MS, HTTP_TOOL_METHODS, httpUrlIssue, } from "./definition/http-tool.js";
|
|
@@ -13,6 +13,11 @@ import { ERROR_CODES } from "./compatibility.js";
|
|
|
13
13
|
export const RequestIdSchema = z.string().min(1);
|
|
14
14
|
export const IdempotencyKeySchema = z.string().min(1).max(256);
|
|
15
15
|
const jsonObject = z.record(z.string(), z.unknown());
|
|
16
|
+
/**
|
|
17
|
+
* A JSON object in a definition document (a schema, metadata). Documents arrive as JSON, so its
|
|
18
|
+
* values are JSON values: the manifest types say `JsonObject`, and the schema checks no value.
|
|
19
|
+
*/
|
|
20
|
+
const definitionJson = jsonObject;
|
|
16
21
|
// Recursive schemas carry an `id`: a document generated from them (the Runtime's OpenAPI)
|
|
17
22
|
// refers back to the named schema instead of expanding it forever.
|
|
18
23
|
const jsonValue = z
|
|
@@ -68,6 +73,8 @@ const mcpServerSchema = z.discriminatedUnion("type", [
|
|
|
68
73
|
})
|
|
69
74
|
.strict(),
|
|
70
75
|
], { error: (issue) => stdioIssue(issue.input) });
|
|
76
|
+
/** A remote MCP server as a manifest declares it (`streamable-http` or `sse`). */
|
|
77
|
+
export const McpServerManifestSchema = mcpServerSchema;
|
|
71
78
|
/** The refusal of a `stdio` server; other bad declarations keep zod's own message. */
|
|
72
79
|
function stdioIssue(input) {
|
|
73
80
|
if (!input || typeof input !== "object")
|
|
@@ -81,13 +88,14 @@ const skillManifestSchema = z
|
|
|
81
88
|
.object({
|
|
82
89
|
name: z.string().min(1),
|
|
83
90
|
description: z.string().min(1),
|
|
84
|
-
files: z.record(z.string(), z.string())
|
|
85
|
-
const issue = skillFilesIssue(files);
|
|
86
|
-
if (issue)
|
|
87
|
-
ctx.addIssue({ code: "custom", message: `Skill ${issue}` });
|
|
88
|
-
}),
|
|
91
|
+
files: z.record(z.string(), z.string()),
|
|
89
92
|
})
|
|
90
|
-
.strict()
|
|
93
|
+
.strict()
|
|
94
|
+
.superRefine((skill, ctx) => {
|
|
95
|
+
const issue = skillFilesIssue(skill.files);
|
|
96
|
+
if (issue)
|
|
97
|
+
ctx.addIssue({ code: "custom", path: ["files"], message: `Skill '${skill.name}' ${issue}` });
|
|
98
|
+
});
|
|
91
99
|
const sandboxManifestSchema = z
|
|
92
100
|
.object({
|
|
93
101
|
image: z.string().min(1).optional(),
|
|
@@ -146,8 +154,8 @@ const toolManifestSchema = z
|
|
|
146
154
|
.object({
|
|
147
155
|
name: modelFacingName("Tool"),
|
|
148
156
|
description: z.string().optional(),
|
|
149
|
-
inputSchema:
|
|
150
|
-
outputSchema:
|
|
157
|
+
inputSchema: definitionJson,
|
|
158
|
+
outputSchema: definitionJson.optional(),
|
|
151
159
|
agent: z
|
|
152
160
|
.lazy(() => z.union([workflowManifestSchema, AgentManifestSchema]))
|
|
153
161
|
.meta({ id: "ToolAgentManifest" })
|
|
@@ -171,15 +179,15 @@ const toolManifestSchema = z
|
|
|
171
179
|
message: `Tool '${tool.name}' takes approval only as an HTTP tool`,
|
|
172
180
|
});
|
|
173
181
|
});
|
|
174
|
-
/** A capability naming a field
|
|
175
|
-
const removedFieldError = (issue) => {
|
|
182
|
+
/** A manifest or capability naming a removed field is refused with what replaces it. */
|
|
183
|
+
const removedFieldError = (removedFields) => (issue) => {
|
|
176
184
|
if (issue.code !== "unrecognized_keys")
|
|
177
185
|
return undefined;
|
|
178
|
-
const removed = issue.keys?.find((key) =>
|
|
179
|
-
return removed === undefined ? undefined :
|
|
186
|
+
const removed = issue.keys?.find((key) => removedFields[key] !== undefined);
|
|
187
|
+
return removed === undefined ? undefined : removedFields[removed];
|
|
180
188
|
};
|
|
181
|
-
|
|
182
|
-
.
|
|
189
|
+
const agentManifestSchema = z
|
|
190
|
+
.strictObject({
|
|
183
191
|
// 6 adds an MCP server's `tools` and `deferred` (R2b C9); 5 is accepted unchanged.
|
|
184
192
|
manifestSchemaVersion: z.union([z.literal(5), z.literal(6)], {
|
|
185
193
|
error: (issue) => manifestVersionIssue(issue.input),
|
|
@@ -187,26 +195,25 @@ export const AgentManifestSchema = z
|
|
|
187
195
|
id: z.string().min(1),
|
|
188
196
|
name: z.string().min(1).optional(),
|
|
189
197
|
description: z.string().optional(),
|
|
190
|
-
metadata:
|
|
191
|
-
outputSchema:
|
|
198
|
+
metadata: definitionJson.optional(),
|
|
199
|
+
outputSchema: definitionJson.optional(),
|
|
192
200
|
capabilities: z.array(z.strictObject({
|
|
193
201
|
id: z.string().min(1),
|
|
194
202
|
type: z.enum(["agent", "agent-plugin"]),
|
|
195
203
|
name: z.string().min(1).optional(),
|
|
196
204
|
description: z.string().optional(),
|
|
197
|
-
metadata:
|
|
205
|
+
metadata: definitionJson.optional(),
|
|
198
206
|
instructions: z.array(z.string()).optional(),
|
|
199
207
|
skills: z.record(z.string(), skillManifestSchema).optional(),
|
|
200
208
|
tools: z.array(toolManifestSchema).optional(),
|
|
201
209
|
mcpServers: z.record(z.string(), mcpServerSchema).optional(),
|
|
202
210
|
sandbox: sandboxManifestSchema.optional(),
|
|
203
|
-
}, { error: removedFieldError })),
|
|
211
|
+
}, { error: removedFieldError(REMOVED_CAPABILITY_FIELDS) })),
|
|
204
212
|
runtime: z.object({}).strict().optional(),
|
|
205
213
|
// Reserved for Functions, which are deferred: developer code the Runtime will run from
|
|
206
214
|
// uploaded definition files (a `functions/` folder). Any value is refused below.
|
|
207
215
|
functions: z.unknown().optional().meta({ description: "Reserved: Functions are not available yet" }),
|
|
208
|
-
})
|
|
209
|
-
.strict()
|
|
216
|
+
}, { error: removedFieldError(REMOVED_MANIFEST_FIELDS) })
|
|
210
217
|
.superRefine((manifest, ctx) => {
|
|
211
218
|
if (manifest.functions !== undefined)
|
|
212
219
|
ctx.addIssue({ code: "custom", path: ["functions"], message: "Functions are not available yet" });
|
|
@@ -283,6 +290,11 @@ export const AgentManifestSchema = z
|
|
|
283
290
|
}
|
|
284
291
|
}
|
|
285
292
|
});
|
|
293
|
+
/**
|
|
294
|
+
* An agent's manifest (manifest v5 and v6). Its output is checked against `AgentManifest` here and
|
|
295
|
+
* below (`ManifestDrift`): the hand-written type keeps its read-only fields and its docs.
|
|
296
|
+
*/
|
|
297
|
+
export const AgentManifestSchema = agentManifestSchema;
|
|
286
298
|
/** Agents used as tools: one level deep, `{ task }` input, one shared sandbox spec. */
|
|
287
299
|
function delegationIssues(manifest, issue) {
|
|
288
300
|
const sandboxes = new Set();
|
|
@@ -356,8 +368,8 @@ const workflowLoopVerifySchema = z
|
|
|
356
368
|
else if (verify.http !== undefined && verify.id !== undefined)
|
|
357
369
|
ctx.addIssue({ code: "custom", path: ["id"], message: "An HTTP verifier takes no id" });
|
|
358
370
|
})
|
|
359
|
-
.meta({ id: "WorkflowLoopVerify" });
|
|
360
|
-
const
|
|
371
|
+
.meta({ id: "WorkflowLoopVerify" }); // the refinement picks one kind
|
|
372
|
+
const workflowNodeKinds = z.lazy(() => z.union([
|
|
361
373
|
workflowAgentNodeSchema,
|
|
362
374
|
z
|
|
363
375
|
.object({
|
|
@@ -365,8 +377,8 @@ const workflowNodeSchema = z.lazy(() => z.union([
|
|
|
365
377
|
.object({
|
|
366
378
|
name: z.string().min(1),
|
|
367
379
|
description: z.string().optional(),
|
|
368
|
-
inputSchema:
|
|
369
|
-
outputSchema:
|
|
380
|
+
inputSchema: definitionJson.optional(),
|
|
381
|
+
outputSchema: definitionJson.optional(),
|
|
370
382
|
/** An HTTP stage: the Runtime makes the request, as for an agent's HTTP tool. */
|
|
371
383
|
http: httpToolTargetSchema.optional(),
|
|
372
384
|
})
|
|
@@ -415,7 +427,8 @@ const workflowNodeSchema = z.lazy(() => z.union([
|
|
|
415
427
|
})
|
|
416
428
|
.strict(),
|
|
417
429
|
])).meta({ id: "WorkflowNode" });
|
|
418
|
-
const
|
|
430
|
+
const workflowNodeSchema = workflowNodeKinds;
|
|
431
|
+
const workflowManifestObject = z.lazy(() => z
|
|
419
432
|
.object({
|
|
420
433
|
kind: z.literal("workflow"),
|
|
421
434
|
workflowSchemaVersion: z.literal(3, {
|
|
@@ -424,9 +437,9 @@ const workflowManifestSchema = z.lazy(() => z
|
|
|
424
437
|
id: z.string().min(1),
|
|
425
438
|
name: z.string().min(1).optional(),
|
|
426
439
|
description: z.string().optional(),
|
|
427
|
-
metadata:
|
|
428
|
-
inputSchema:
|
|
429
|
-
outputSchema:
|
|
440
|
+
metadata: definitionJson.optional(),
|
|
441
|
+
inputSchema: definitionJson.optional(),
|
|
442
|
+
outputSchema: definitionJson.optional(),
|
|
430
443
|
sandbox: sandboxManifestSchema.optional(),
|
|
431
444
|
root: workflowNodeSchema,
|
|
432
445
|
agents: z.record(z.string().min(1), z.union([workflowManifestSchema, AgentManifestSchema])),
|
|
@@ -450,6 +463,7 @@ const workflowManifestSchema = z.lazy(() => z
|
|
|
450
463
|
});
|
|
451
464
|
}
|
|
452
465
|
})).meta({ id: "WorkflowManifest" });
|
|
466
|
+
const workflowManifestSchema = workflowManifestObject;
|
|
453
467
|
function referencedAgents(node) {
|
|
454
468
|
const out = [];
|
|
455
469
|
const visit = (child) => {
|
|
@@ -851,7 +865,7 @@ export const CreateVaultRequestSchema = z
|
|
|
851
865
|
ctx.addIssue({ code: "custom", path: ["ownerUserId"], message: "An installation vault is owned by installation" });
|
|
852
866
|
});
|
|
853
867
|
/** An RFC 9110 field name. */
|
|
854
|
-
const HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
868
|
+
export const HEADER_NAME_PATTERN = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
855
869
|
const CredentialHeaderNameSchema = z
|
|
856
870
|
.string()
|
|
857
871
|
.regex(HEADER_NAME_PATTERN, "A header name is an RFC 9110 token");
|
|
@@ -865,7 +879,8 @@ const CredentialHeadersSchema = z
|
|
|
865
879
|
.record(CredentialHeaderNameSchema, CredentialHeaderValueSchema)
|
|
866
880
|
.refine((value) => Object.keys(value).length > 0, "At least one header is required")
|
|
867
881
|
.refine((value) => new Set(Object.keys(value).map((name) => name.toLowerCase())).size === Object.keys(value).length, "Header names are case-insensitive: each may appear once");
|
|
868
|
-
|
|
882
|
+
/** A loopback host as a URL's `hostname` names it: plain `http` reaches only these. */
|
|
883
|
+
export const LOOPBACK_HOSTS = /^(?:localhost|127(?:\.\d{1,3}){3}|\[::1\])$/i;
|
|
869
884
|
/**
|
|
870
885
|
* `via` (R2b C2, Q11): where this installation reaches the credential's server, such as a
|
|
871
886
|
* gateway's endpoint for it. An absolute `https` URL (`http` only to a loopback host), with no
|
|
@@ -906,6 +921,87 @@ const credentialRoutingChange = {
|
|
|
906
921
|
via: CredentialViaSchema.nullable().optional(),
|
|
907
922
|
identity: CredentialIdentitySchema.nullable().optional(),
|
|
908
923
|
};
|
|
924
|
+
/**
|
|
925
|
+
* An environment variable name a shell secret or plain variable may take (R2c, D50): a POSIX
|
|
926
|
+
* name. Names the sandbox needs for itself (the proxy, the trust store, `PATH`, `HOME`) and
|
|
927
|
+
* `NYLORUN_*` are reserved.
|
|
928
|
+
*/
|
|
929
|
+
export const ENVIRONMENT_NAME_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,127}$/;
|
|
930
|
+
export const RESERVED_ENVIRONMENT_NAMES = new Set([
|
|
931
|
+
"PATH",
|
|
932
|
+
"HOME",
|
|
933
|
+
"PWD",
|
|
934
|
+
"SHELL",
|
|
935
|
+
"USER",
|
|
936
|
+
"HTTPS_PROXY",
|
|
937
|
+
"HTTP_PROXY",
|
|
938
|
+
"NO_PROXY",
|
|
939
|
+
"ALL_PROXY",
|
|
940
|
+
"SSL_CERT_FILE",
|
|
941
|
+
"SSL_CERT_DIR",
|
|
942
|
+
"NODE_EXTRA_CA_CERTS",
|
|
943
|
+
"REQUESTS_CA_BUNDLE",
|
|
944
|
+
"CURL_CA_BUNDLE",
|
|
945
|
+
"GIT_SSL_CAINFO",
|
|
946
|
+
"AWS_CA_BUNDLE",
|
|
947
|
+
]);
|
|
948
|
+
export function isReservedEnvironmentName(name) {
|
|
949
|
+
const upper = name.toUpperCase();
|
|
950
|
+
return RESERVED_ENVIRONMENT_NAMES.has(upper) || upper.startsWith("NYLORUN_");
|
|
951
|
+
}
|
|
952
|
+
const EnvironmentNameSchema = z
|
|
953
|
+
.string()
|
|
954
|
+
.regex(ENVIRONMENT_NAME_PATTERN, "An environment variable name is a letter or _ followed by letters, digits or _")
|
|
955
|
+
.refine((name) => !isReservedEnvironmentName(name), "That environment variable name is reserved");
|
|
956
|
+
/** The value a sandbox sees for every `environment_secret` (R2c, D50): never the secret. */
|
|
957
|
+
export const ENVIRONMENT_SECRET_SENTINEL = "nylorun-managed";
|
|
958
|
+
/**
|
|
959
|
+
* How egress-gate writes an `environment_secret` into a request (R2c, D50): one header, set on
|
|
960
|
+
* every request to a bound host. `format` is text with `{value}` once, optionally inside a
|
|
961
|
+
* `{base64:…}` group, for example `Bearer {value}` (the default),
|
|
962
|
+
* `Basic {base64:x-access-token:{value}}` or `{value}`.
|
|
963
|
+
*/
|
|
964
|
+
export const ENVIRONMENT_SECRET_DEFAULT_INJECT = { header: "Authorization", format: "Bearer {value}" };
|
|
965
|
+
const BASE64_GROUP = /\{base64:((?:[^{}]|\{value\})*)\}/g;
|
|
966
|
+
export function isInjectFormat(format) {
|
|
967
|
+
if (/[\r\n\0]/.test(format))
|
|
968
|
+
return false;
|
|
969
|
+
const values = format.match(/\{value\}/g)?.length ?? 0;
|
|
970
|
+
const rest = format.replace(BASE64_GROUP, (_, inner) => inner.replace(/\{value\}/g, "")).replace(/\{value\}/g, "");
|
|
971
|
+
return values === 1 && !/[{}]/.test(rest);
|
|
972
|
+
}
|
|
973
|
+
/** `format` with `{value}` replaced, and each `{base64:…}` group encoded. */
|
|
974
|
+
export function renderInjectFormat(format, value) {
|
|
975
|
+
return format
|
|
976
|
+
.replace(BASE64_GROUP, (_, inner) => base64Utf8(inner.replace(/\{value\}/g, () => value)))
|
|
977
|
+
.replace(/\{value\}/g, () => value);
|
|
978
|
+
}
|
|
979
|
+
function base64Utf8(text) {
|
|
980
|
+
let binary = "";
|
|
981
|
+
for (const byte of new TextEncoder().encode(text))
|
|
982
|
+
binary += String.fromCharCode(byte);
|
|
983
|
+
return btoa(binary);
|
|
984
|
+
}
|
|
985
|
+
export const EnvironmentSecretInjectSchema = z
|
|
986
|
+
.object({
|
|
987
|
+
header: CredentialHeaderNameSchema,
|
|
988
|
+
format: z.string().min(1).refine(isInjectFormat, "format has {value} exactly once, optionally inside one {base64:…} group"),
|
|
989
|
+
})
|
|
990
|
+
.strict();
|
|
991
|
+
/** Exact host names an `environment_secret` may be sent to: no wildcards, no IP literals. */
|
|
992
|
+
const AllowedHostsSchema = z
|
|
993
|
+
.array(z
|
|
994
|
+
.string()
|
|
995
|
+
.toLowerCase()
|
|
996
|
+
.refine((host) => /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/.test(host) && !/^\d+(\.\d+){3}$/.test(host), "allowedHosts takes exact host names such as api.github.com: no wildcard, port or IP address"))
|
|
997
|
+
.min(1)
|
|
998
|
+
.max(32)
|
|
999
|
+
.refine((hosts) => new Set(hosts).size === hosts.length, "allowedHosts lists each host once");
|
|
1000
|
+
const EnvironmentValueSchema = z
|
|
1001
|
+
.string()
|
|
1002
|
+
.min(1)
|
|
1003
|
+
.max(8192)
|
|
1004
|
+
.refine((value) => !/[\r\n\0]/.test(value), "A value has no CR, LF or NUL");
|
|
909
1005
|
/**
|
|
910
1006
|
* A credential for the server at `url` (the URL a manifest names): `bearer` sends
|
|
911
1007
|
* `Authorization: Bearer <token>`, `headers` its header map (R2b C2). The header names may not be
|
|
@@ -932,6 +1028,22 @@ export const CreateCredentialRequestSchema = z
|
|
|
932
1028
|
...credentialRouting,
|
|
933
1029
|
})
|
|
934
1030
|
.strict(),
|
|
1031
|
+
z
|
|
1032
|
+
.object({
|
|
1033
|
+
type: z.literal("environment_secret"),
|
|
1034
|
+
secretName: EnvironmentNameSchema,
|
|
1035
|
+
secretValue: EnvironmentValueSchema,
|
|
1036
|
+
allowedHosts: AllowedHostsSchema,
|
|
1037
|
+
inject: EnvironmentSecretInjectSchema.optional(),
|
|
1038
|
+
})
|
|
1039
|
+
.strict(),
|
|
1040
|
+
z
|
|
1041
|
+
.object({
|
|
1042
|
+
type: z.literal("environment_variable"),
|
|
1043
|
+
variableName: EnvironmentNameSchema,
|
|
1044
|
+
variableValue: EnvironmentValueSchema,
|
|
1045
|
+
})
|
|
1046
|
+
.strict(),
|
|
935
1047
|
]),
|
|
936
1048
|
})
|
|
937
1049
|
.strict();
|
|
@@ -957,6 +1069,8 @@ export const RotateCredentialRequestSchema = z
|
|
|
957
1069
|
...credentialRoutingChange,
|
|
958
1070
|
})
|
|
959
1071
|
.strict(),
|
|
1072
|
+
z.object({ type: z.literal("environment_secret"), secretValue: EnvironmentValueSchema }).strict(),
|
|
1073
|
+
z.object({ type: z.literal("environment_variable"), variableValue: EnvironmentValueSchema }).strict(),
|
|
960
1074
|
]),
|
|
961
1075
|
})
|
|
962
1076
|
.strict();
|
|
@@ -1021,8 +1135,22 @@ export const CredentialInfoSchema = z
|
|
|
1021
1135
|
id: z.string(),
|
|
1022
1136
|
vaultId: z.string(),
|
|
1023
1137
|
name: z.string(),
|
|
1024
|
-
type: z.enum(["bearer", "headers"]),
|
|
1025
|
-
|
|
1138
|
+
type: z.enum(["bearer", "headers", "environment_secret", "environment_variable"]),
|
|
1139
|
+
/**
|
|
1140
|
+
* What the credential is bound to: the server `url` for `bearer` and `headers`; the variable
|
|
1141
|
+
* name and hosts for `environment_secret` (R2c); the name and its plain value for
|
|
1142
|
+
* `environment_variable`, which is not a secret. A secret's value is never shown.
|
|
1143
|
+
*/
|
|
1144
|
+
binding: z
|
|
1145
|
+
.object({
|
|
1146
|
+
url: z.string().optional(),
|
|
1147
|
+
secretName: z.string().optional(),
|
|
1148
|
+
allowedHosts: z.array(z.string()).optional(),
|
|
1149
|
+
inject: EnvironmentSecretInjectSchema.optional(),
|
|
1150
|
+
variableName: z.string().optional(),
|
|
1151
|
+
variableValue: z.string().optional(),
|
|
1152
|
+
})
|
|
1153
|
+
.strict(),
|
|
1026
1154
|
/** A `headers` credential's header names (lower case), never their values. */
|
|
1027
1155
|
headerNames: z.array(z.string()).optional(),
|
|
1028
1156
|
via: z.string().optional(),
|