@nylorun/core 0.17.0-beta → 0.18.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 +20 -0
- package/README.md +10 -0
- package/dist/contracts.d.ts +12 -2
- package/dist/contracts.js +46 -31
- 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 +701 -13
- package/dist/harness-api/schema.js +129 -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,25 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.18.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7780b2f: **One client and connection layer.** The Project link and credentials are read one way, and every Runtime client shares one `/health` probe.
|
|
8
|
+
|
|
9
|
+
- `@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`.
|
|
10
|
+
- `@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`.
|
|
11
|
+
- `@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`.
|
|
12
|
+
- `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.
|
|
13
|
+
- `@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.
|
|
14
|
+
- `@nylorun/studio`: the server's Runtime compatibility probe is `checkHealth` from `@nylorun/agents`.
|
|
15
|
+
|
|
16
|
+
- 070674d: **One source of truth for the manifest and Harness API schemas.**
|
|
17
|
+
|
|
18
|
+
- `@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).
|
|
19
|
+
- `@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.
|
|
20
|
+
- `@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.
|
|
21
|
+
- `@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.
|
|
22
|
+
|
|
3
23
|
## 0.17.0-beta
|
|
4
24
|
|
|
5
25
|
### 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/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
|
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
|
package/dist/definition/from.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { HarnessError } from "../errors.js";
|
|
2
2
|
import { assembleAgent } from "./assemble.js";
|
|
3
3
|
import { schemaFromJSON } from "./schema-json.js";
|
|
4
|
-
import {
|
|
5
|
-
import { REMOVED_CAPABILITY_FIELDS, manifestVersionIssue } from "./removed.js";
|
|
4
|
+
import { assertJson, deepFreeze } from "../utils/immutable.js";
|
|
6
5
|
import { delegateFromManifest, delegateOf } from "./delegate.js";
|
|
7
|
-
import { mcpToolSettingsVersionIssue, stdioMcpRefusal, usesMcpToolSettings } from "./mcp.js";
|
|
8
6
|
import { SKILL_TOOL_NAMES } from "./skill-tools.js";
|
|
9
|
-
import { skillFilesIssue } from "../utils/definition-files.js";
|
|
10
7
|
import { httpToolFromManifest, httpToolOf } from "./http-tool.js";
|
|
8
|
+
import { AgentManifestSchema } from "../contracts.js";
|
|
11
9
|
/** Tools the engine or the Runtime runs, which need no implementation: agents and HTTP tools. */
|
|
12
10
|
const declarative = (tool) => delegateOf(tool) !== undefined || httpToolOf(tool) !== undefined;
|
|
13
11
|
/** Rebuild an agent from manifest JSON + in-process implementations (T28). */
|
|
@@ -149,191 +147,27 @@ function resolveTools(capability, tools) {
|
|
|
149
147
|
throw new HarnessError("agent.build-failed", `Missing tool implementation '${declared.name}' for capability '${capability.id}'`);
|
|
150
148
|
});
|
|
151
149
|
}
|
|
150
|
+
/**
|
|
151
|
+
* The manifest as `AgentManifestSchema` accepts it (the Runtime's own check), as a frozen copy.
|
|
152
|
+
* A refusal is `agent.build-failed` with the schema's messages.
|
|
153
|
+
*/
|
|
152
154
|
function normalizeManifest(json) {
|
|
153
155
|
if (!json || typeof json !== "object" || Array.isArray(json))
|
|
154
156
|
throw new HarnessError("agent.build-failed", "Agent.from requires a manifest object");
|
|
155
|
-
const
|
|
156
|
-
if (
|
|
157
|
-
throw new HarnessError("agent.build-failed",
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
// Reject top-level model (Runtime-owned).
|
|
172
|
-
if ("model" in value && value.model !== undefined)
|
|
173
|
-
throw new HarnessError("agent.build-failed", "Manifest must not include top-level model; Runtime owns model resolution");
|
|
174
|
-
if ("description" in value && value.description !== undefined) {
|
|
175
|
-
if (typeof value.description !== "string")
|
|
176
|
-
throw new HarnessError("agent.build-failed", "Manifest description must be a string");
|
|
177
|
-
}
|
|
178
|
-
const metadata = "metadata" in value && value.metadata !== undefined
|
|
179
|
-
? copyJsonObject(value.metadata, "metadata")
|
|
180
|
-
: undefined;
|
|
181
|
-
const runtime = normalizeRuntime(value.runtime);
|
|
182
|
-
const capabilities = value.capabilities.map(normalizeCapability);
|
|
183
|
-
const version = value.manifestSchemaVersion;
|
|
184
|
-
const servers = new Set();
|
|
185
|
-
for (const capability of capabilities)
|
|
186
|
-
for (const [name, server] of Object.entries(capability.mcpServers ?? {})) {
|
|
187
|
-
if (servers.has(name))
|
|
188
|
-
throw new HarnessError("agent.build-failed", `Duplicate MCP server '${name}'`);
|
|
189
|
-
servers.add(name);
|
|
190
|
-
if (version === 5 && usesMcpToolSettings(server))
|
|
191
|
-
throw new HarnessError("agent.build-failed", mcpToolSettingsVersionIssue(name));
|
|
192
|
-
}
|
|
193
|
-
return deepFreeze({
|
|
194
|
-
// The manifest's own version: a v6 manifest without v6 fields keeps its hash.
|
|
195
|
-
manifestSchemaVersion: version,
|
|
196
|
-
id: value.id,
|
|
197
|
-
...(typeof value.name === "string" && value.name ? { name: value.name } : {}),
|
|
198
|
-
...(typeof value.description === "string"
|
|
199
|
-
? { description: value.description }
|
|
200
|
-
: {}),
|
|
201
|
-
...(metadata === undefined ? {} : { metadata }),
|
|
202
|
-
...(value.outputSchema && typeof value.outputSchema === "object"
|
|
203
|
-
? { outputSchema: value.outputSchema }
|
|
204
|
-
: {}),
|
|
205
|
-
capabilities,
|
|
206
|
-
...(runtime === undefined ? {} : { runtime }),
|
|
207
|
-
});
|
|
208
|
-
}
|
|
209
|
-
function normalizeRuntime(value) {
|
|
210
|
-
if (value === undefined)
|
|
211
|
-
return undefined;
|
|
212
|
-
if (!value ||
|
|
213
|
-
typeof value !== "object" ||
|
|
214
|
-
Array.isArray(value) ||
|
|
215
|
-
Object.keys(value).length > 0)
|
|
216
|
-
throw new HarnessError("agent.build-failed", "runtime must be an empty object when present");
|
|
217
|
-
return {};
|
|
218
|
-
}
|
|
219
|
-
function normalizeCapability(capability) {
|
|
220
|
-
const raw = capability;
|
|
221
|
-
if ("name" in raw && raw.name !== undefined) {
|
|
222
|
-
if (typeof raw.name !== "string" || !raw.name)
|
|
223
|
-
throw new HarnessError("agent.build-failed", `Capability '${capability.id}' name must be a non-empty string`);
|
|
224
|
-
}
|
|
225
|
-
if ("description" in raw && raw.description !== undefined) {
|
|
226
|
-
if (typeof raw.description !== "string")
|
|
227
|
-
throw new HarnessError("agent.build-failed", `Capability '${capability.id}' description must be a string`);
|
|
228
|
-
}
|
|
229
|
-
if ("model" in raw && raw.model !== undefined)
|
|
230
|
-
throw new HarnessError("agent.build-failed", `Capability '${capability.id}' must not include model; Runtime owns model resolution`);
|
|
231
|
-
if (capability.type !== "agent" && capability.type !== "agent-plugin")
|
|
232
|
-
throw new HarnessError("agent.build-failed", `Capability '${capability.id}' type must be agent or agent-plugin`);
|
|
233
|
-
for (const [field, message] of Object.entries(REMOVED_CAPABILITY_FIELDS))
|
|
234
|
-
if (field in raw)
|
|
235
|
-
throw new HarnessError("agent.build-failed", `Capability '${capability.id}': ${message}`);
|
|
236
|
-
const metadata = capability.metadata === undefined
|
|
237
|
-
? undefined
|
|
238
|
-
: copyJsonObject(capability.metadata, "metadata");
|
|
239
|
-
const mcpServers = normalizeMcpServers(capability.id, capability.mcpServers);
|
|
240
|
-
const skills = normalizeSkills(capability.id, capability.skills);
|
|
241
|
-
return Object.freeze({
|
|
242
|
-
id: capability.id,
|
|
243
|
-
type: capability.type,
|
|
244
|
-
...(typeof raw.name === "string" && raw.name ? { name: raw.name } : {}),
|
|
245
|
-
...(typeof raw.description === "string"
|
|
246
|
-
? { description: raw.description }
|
|
247
|
-
: {}),
|
|
248
|
-
...(metadata === undefined ? {} : { metadata }),
|
|
249
|
-
...(capability.instructions
|
|
250
|
-
? { instructions: Object.freeze([...capability.instructions]) }
|
|
251
|
-
: {}),
|
|
252
|
-
...(capability.tools
|
|
253
|
-
? { tools: Object.freeze(capability.tools.map(normalizeTool)) }
|
|
254
|
-
: {}),
|
|
255
|
-
...(skills === undefined ? {} : { skills }),
|
|
256
|
-
...(mcpServers === undefined ? {} : { mcpServers }),
|
|
257
|
-
...(capability.sandbox === undefined
|
|
258
|
-
? {}
|
|
259
|
-
: {
|
|
260
|
-
sandbox: deepFreeze(copyJsonObject(capability.sandbox, "sandbox")),
|
|
261
|
-
}),
|
|
262
|
-
});
|
|
263
|
-
}
|
|
264
|
-
function normalizeSkills(capabilityId, skills) {
|
|
265
|
-
if (skills === undefined)
|
|
266
|
-
return undefined;
|
|
267
|
-
if (!skills ||
|
|
268
|
-
typeof skills !== "object" ||
|
|
269
|
-
Array.isArray(skills) ||
|
|
270
|
-
Object.keys(skills).length === 0)
|
|
271
|
-
throw new HarnessError("agent.build-failed", `Capability '${capabilityId}' skills must be a non-empty map or omitted`);
|
|
272
|
-
const normalized = {};
|
|
273
|
-
for (const [key, skill] of Object.entries(skills)) {
|
|
274
|
-
if (!skill ||
|
|
275
|
-
typeof skill !== "object" ||
|
|
276
|
-
skill.name !== key ||
|
|
277
|
-
typeof skill.description !== "string" ||
|
|
278
|
-
skill.description.length === 0)
|
|
279
|
-
throw new HarnessError("agent.build-failed", `Capability '${capabilityId}' skills key '${key}' must equal the skill name`);
|
|
280
|
-
const issue = skillFilesIssue(skill.files);
|
|
281
|
-
if (issue)
|
|
282
|
-
throw new HarnessError("agent.build-failed", `Capability '${capabilityId}' skill '${key}' ${issue}`);
|
|
283
|
-
normalized[key] = Object.freeze({
|
|
284
|
-
name: skill.name,
|
|
285
|
-
description: skill.description,
|
|
286
|
-
files: Object.freeze({ ...skill.files }),
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
return Object.freeze(normalized);
|
|
290
|
-
}
|
|
291
|
-
function normalizeMcpServers(capabilityId, servers) {
|
|
292
|
-
if (servers === undefined)
|
|
293
|
-
return undefined;
|
|
294
|
-
if (!servers ||
|
|
295
|
-
typeof servers !== "object" ||
|
|
296
|
-
Array.isArray(servers) ||
|
|
297
|
-
Object.keys(servers).length === 0)
|
|
298
|
-
throw new HarnessError("agent.build-failed", `Capability '${capabilityId}' mcpServers must be a non-empty map or omitted`);
|
|
299
|
-
const normalized = {};
|
|
300
|
-
for (const [key, server] of Object.entries(servers)) {
|
|
301
|
-
if (server.type === "stdio")
|
|
302
|
-
throw new HarnessError("agent.build-failed", stdioMcpRefusal(key));
|
|
303
|
-
if (!isMcpServer(server) || server.name !== key)
|
|
304
|
-
throw new HarnessError("agent.build-failed", `Capability '${capabilityId}' mcpServers key '${key}' must equal the server name`);
|
|
305
|
-
normalized[key] = server;
|
|
306
|
-
}
|
|
307
|
-
return Object.freeze(normalized);
|
|
308
|
-
}
|
|
309
|
-
function isMcpServer(value) {
|
|
310
|
-
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
311
|
-
return false;
|
|
312
|
-
const server = value;
|
|
313
|
-
if (typeof server.name !== "string" || !server.name)
|
|
314
|
-
return false;
|
|
315
|
-
if (server.type === "streamable-http" || server.type === "sse")
|
|
316
|
-
return typeof server.url === "string" && server.url.length > 0;
|
|
317
|
-
return false;
|
|
318
|
-
}
|
|
319
|
-
function normalizeTool(tool) {
|
|
320
|
-
return Object.freeze({
|
|
321
|
-
name: tool.name,
|
|
322
|
-
...(tool.description === undefined
|
|
323
|
-
? {}
|
|
324
|
-
: { description: tool.description }),
|
|
325
|
-
inputSchema: tool.inputSchema,
|
|
326
|
-
...(tool.outputSchema === undefined
|
|
327
|
-
? {}
|
|
328
|
-
: { outputSchema: tool.outputSchema }),
|
|
329
|
-
...(tool.agent === undefined
|
|
330
|
-
? {}
|
|
331
|
-
: {
|
|
332
|
-
agent: "kind" in tool.agent
|
|
333
|
-
? deepFreeze(JSON.parse(JSON.stringify(tool.agent)))
|
|
334
|
-
: normalizeManifest(tool.agent),
|
|
335
|
-
}),
|
|
336
|
-
...(tool.http === undefined ? {} : { http: Object.freeze({ ...tool.http }) }),
|
|
337
|
-
...(tool.approval === undefined ? {} : { approval: tool.approval }),
|
|
338
|
-
});
|
|
157
|
+
const parsed = AgentManifestSchema.safeParse(json);
|
|
158
|
+
if (!parsed.success)
|
|
159
|
+
throw new HarnessError("agent.build-failed", parsed.error.issues
|
|
160
|
+
.map((issue) => issue.path.length === 0
|
|
161
|
+
? issue.message
|
|
162
|
+
: `${issue.path.join(".")}: ${issue.message}`)
|
|
163
|
+
.join("; "));
|
|
164
|
+
// The schema checks no value of a JSON object; metadata must be JSON data, as before.
|
|
165
|
+
const manifest = parsed.data;
|
|
166
|
+
for (const metadata of [
|
|
167
|
+
manifest.metadata,
|
|
168
|
+
...manifest.capabilities.map((capability) => capability.metadata),
|
|
169
|
+
])
|
|
170
|
+
if (metadata !== undefined)
|
|
171
|
+
assertJson(metadata, "metadata");
|
|
172
|
+
return deepFreeze(JSON.parse(JSON.stringify(manifest)));
|
|
339
173
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Capability fields that manifest v5 removed, and what replaces each. Manifest v5 (with workflow
|
|
3
3
|
* manifest v3 for flow agents) is the first where the Runtime never calls the developer's code
|
|
4
|
-
* during a session (see MIGRATION.md).
|
|
4
|
+
* during a session (see MIGRATION.md). `model` went earlier: the Runtime owns the model.
|
|
5
5
|
*/
|
|
6
6
|
export declare const REMOVED_CAPABILITY_FIELDS: Readonly<Record<string, string>>;
|
|
7
|
+
/** Manifest fields an older SDK wrote, and why each is refused. */
|
|
8
|
+
export declare const REMOVED_MANIFEST_FIELDS: Readonly<Record<string, string>>;
|
|
7
9
|
/**
|
|
8
10
|
* Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 5 and
|
|
9
11
|
* version 6 (R2b C9: an MCP server's `tools` and `deferred`; v5 is accepted unchanged).
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Capability fields that manifest v5 removed, and what replaces each. Manifest v5 (with workflow
|
|
3
3
|
* manifest v3 for flow agents) is the first where the Runtime never calls the developer's code
|
|
4
|
-
* during a session (see MIGRATION.md).
|
|
4
|
+
* during a session (see MIGRATION.md). `model` went earlier: the Runtime owns the model.
|
|
5
5
|
*/
|
|
6
6
|
export const REMOVED_CAPABILITY_FIELDS = Object.freeze({
|
|
7
7
|
hooks: "hooks were removed: the Runtime no longer calls your code during a session. Use an HTTP tool, approval on a tool, or a loop verifier instead (see MIGRATION.md)",
|
|
8
8
|
beforeModelCall: "beforeModelCall was removed with hooks (see MIGRATION.md)",
|
|
9
9
|
afterModelCall: "afterModelCall was removed with hooks (see MIGRATION.md)",
|
|
10
|
+
model: "A capability must not include model; the Runtime owns model resolution",
|
|
11
|
+
});
|
|
12
|
+
/** Manifest fields an older SDK wrote, and why each is refused. */
|
|
13
|
+
export const REMOVED_MANIFEST_FIELDS = Object.freeze({
|
|
14
|
+
schemaVersion: "Manifest field schemaVersion was renamed to manifestSchemaVersion",
|
|
15
|
+
model: "Manifest must not include top-level model; Runtime owns model resolution",
|
|
10
16
|
});
|
|
11
17
|
/**
|
|
12
18
|
* Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 5 and
|