@nylorun/core 0.51.0-beta → 0.52.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 +6 -0
- package/dist/contracts.js +5 -2
- package/dist/definition/assemble.js +5 -2
- package/dist/definition/builder.js +2 -2
- package/dist/definition/code-tools.js +1 -1
- package/dist/definition/delegate.d.ts +9 -0
- package/dist/definition/delegate.js +37 -0
- package/dist/definition/flow/compile.js +5 -5
- package/dist/definition/flow/from.js +1 -1
- package/dist/folder/compile.js +1 -1
- package/dist/folder/nested.js +13 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @nylorun/core
|
|
2
2
|
|
|
3
|
+
## 0.52.0-beta
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- b9b0965: A subagent used as a tool receives `{ task }` as a string, so one that declares an `inputSchema` that can't take a string is now refused when it is built or saved (ADR-162): `delegation.input` in the builder and the manifest contract, `delegation_input` in a manifest's files. Before, the manifest saved and the flow's first stage got a string it didn't declare. Messages and Studio now use ADR-162's words: an agent manifest is driven by a model loop or by a flow, and a flow's stages can be subagents; "flow agent" is no longer a kind. Studio's Agent manifests list filters by **Driven by** (Model loop or Flow), a flow's section is **Stages**, and a subagent used as a tool shows as "Subagent". No code, diagnostic code or wire format changes.
|
|
8
|
+
|
|
3
9
|
## 0.51.0-beta
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/contracts.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, isSandboxHostPattern, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
|
|
4
4
|
import { REMOVED_MANIFEST_FIELDS, REMOVED_RUNTIME_SECTION_FIELDS, agentManifestVersionIssue, manifestVersionIssue, workflowVersionIssue, } from "./definition/removed.js";
|
|
5
|
-
import { DELEGATE_INPUT_SCHEMA, DELEGATE_NAME_PATTERN } from "./definition/delegate.js";
|
|
5
|
+
import { DELEGATE_INPUT_SCHEMA, DELEGATE_NAME_PATTERN, delegateInputIssue } from "./definition/delegate.js";
|
|
6
6
|
import { stdioMcpRefusal } from "./definition/mcp.js";
|
|
7
7
|
import { APPROVAL_MODES, HTTP_TOOL_METHODS, httpInputIssue, httpUrlIssue, httpUrlTemplateIssue, httpVerifierIssue, } from "./definition/http-tool.js";
|
|
8
8
|
import { canonical } from "./utils/canonical.js";
|
|
@@ -348,7 +348,10 @@ function delegationIssues(manifest, issue) {
|
|
|
348
348
|
issue(`Agent tool '${tool.name}' must take the standard { task } input`);
|
|
349
349
|
if (tool.outputSchema !== undefined)
|
|
350
350
|
issue(`Agent tool '${tool.name}' must not declare outputSchema; the agent's outputSchema applies`);
|
|
351
|
-
|
|
351
|
+
const input = delegateInputIssue(child.id, child.inputSchema);
|
|
352
|
+
if (input)
|
|
353
|
+
issue(input);
|
|
354
|
+
// A subagent driven by a flow runs in its own linked session; its steps may delegate in turn.
|
|
352
355
|
if ("kind" in child)
|
|
353
356
|
continue;
|
|
354
357
|
if (child.tools?.some((item) => item.agent !== undefined))
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { bindAgent } from "./bind-agent.js";
|
|
2
2
|
import { createManifest, SESSION_PART_ID } from "./manifest.js";
|
|
3
|
-
import { DELEGATE_NAME_PATTERN, delegateOf, delegatesOf } from "./delegate.js";
|
|
3
|
+
import { DELEGATE_NAME_PATTERN, delegateInputIssue, delegateOf, delegatesOf } from "./delegate.js";
|
|
4
4
|
const diagnostic = (code, message, extra = {}) => Object.freeze({ code, message, ...extra });
|
|
5
5
|
export function assembleAgent(parts, identity) {
|
|
6
6
|
const diagnostics = [];
|
|
@@ -84,7 +84,10 @@ function delegationDiagnostics(items) {
|
|
|
84
84
|
found.push(diagnostic("delegation.invalid-name", `Agent '${child.id}' is used as a tool, so its id must be 1-64 letters, digits, '_' or '-'`, extra));
|
|
85
85
|
if (!child.description?.trim())
|
|
86
86
|
found.push(diagnostic("delegation.description-required", `Agent '${child.id}' is used as a tool and needs a description: the parent's model reads it to decide when to delegate`, extra));
|
|
87
|
-
|
|
87
|
+
const input = delegateInputIssue(child.id, child.inputSchema);
|
|
88
|
+
if (input)
|
|
89
|
+
found.push(diagnostic("delegation.input", input, extra));
|
|
90
|
+
// A subagent driven by a flow runs in its own linked session; its steps may delegate in turn.
|
|
88
91
|
if (child.kind === "workflow")
|
|
89
92
|
continue;
|
|
90
93
|
const nested = delegatesOf(child)[0];
|
|
@@ -255,11 +255,11 @@ export class AgentBuilder {
|
|
|
255
255
|
const diagnostic = kind === "react"
|
|
256
256
|
? Object.freeze({
|
|
257
257
|
code: "flow.no-model",
|
|
258
|
-
message: `'${snapshot.id}' is a flow
|
|
258
|
+
message: `'${snapshot.id}' is driven by a flow, which runs no model loop. Move .${method} to a subagent passed to .pipe().`,
|
|
259
259
|
})
|
|
260
260
|
: Object.freeze({
|
|
261
261
|
code: "agent.mixed-body",
|
|
262
|
-
message: `'${snapshot.id}' is a
|
|
262
|
+
message: `'${snapshot.id}' is driven by a model loop. An agent manifest is driven by a model loop or by a flow, not both: put the model loop in a subagent and add it with .pipe().`,
|
|
263
263
|
});
|
|
264
264
|
return { body: snapshot.body, diagnostics: addDiagnostics(snapshot.diagnostics, [diagnostic]) };
|
|
265
265
|
}
|
|
@@ -25,7 +25,7 @@ export function codeToolRefusal(manifest) {
|
|
|
25
25
|
if (!first)
|
|
26
26
|
return undefined;
|
|
27
27
|
const what = first.kind === "stage"
|
|
28
|
-
? `The tool stage '${first.name}' of flow
|
|
28
|
+
? `The tool stage '${first.name}' of the flow of '${first.owner}'`
|
|
29
29
|
: `Tool '${first.name}' of agent '${first.owner}'`;
|
|
30
30
|
const more = rest.length === 0 ? "" : ` (and ${rest.length} more)`;
|
|
31
31
|
return `${what}${more} runs your code, but the Runtime runs agents from their manifests alone. Make it an http() tool or serve it from a remote MCP server (see MIGRATION.md).`;
|
|
@@ -29,6 +29,15 @@ export declare const MODEL_TOOL_NAME_MAX = 64;
|
|
|
29
29
|
export declare const DELEGATE_NAME_PATTERN: RegExp;
|
|
30
30
|
/** The input every agent used as a tool accepts. Part of the hashed manifest; change deliberately. */
|
|
31
31
|
export declare const DELEGATE_INPUT_SCHEMA: JsonObject;
|
|
32
|
+
/**
|
|
33
|
+
* Whether a subagent's own `inputSchema` can take the task a tool call hands it: any string.
|
|
34
|
+
* False when its `type` excludes `"string"`, when it pins the value (`const`, `enum`), or when
|
|
35
|
+
* no branch of `anyOf`/`oneOf` (or not every branch of `allOf`) can take one. Other keywords
|
|
36
|
+
* (`minLength`, `pattern`) narrow which strings fit and are left to the run (ADR-162).
|
|
37
|
+
*/
|
|
38
|
+
export declare function acceptsTaskInput(schema: unknown): boolean;
|
|
39
|
+
/** Why a subagent used as a tool can't take its task, or undefined when it can (ADR-162). */
|
|
40
|
+
export declare function delegateInputIssue(id: string, inputSchema: unknown): string | undefined;
|
|
32
41
|
/** A built agent or an agent builder; both expose getBinding() and manifest. */
|
|
33
42
|
export declare function isAgentItem(value: unknown): value is Pick<BuiltAgent, "id" | "manifest" | "getBinding"> & {
|
|
34
43
|
build?: () => BuiltAgent;
|
|
@@ -25,6 +25,43 @@ const taskSchema = z
|
|
|
25
25
|
.strict();
|
|
26
26
|
/** The input every agent used as a tool accepts. Part of the hashed manifest; change deliberately. */
|
|
27
27
|
export const DELEGATE_INPUT_SCHEMA = normalizeSchema(taskSchema, "input").jsonSchema;
|
|
28
|
+
/**
|
|
29
|
+
* Whether a subagent's own `inputSchema` can take the task a tool call hands it: any string.
|
|
30
|
+
* False when its `type` excludes `"string"`, when it pins the value (`const`, `enum`), or when
|
|
31
|
+
* no branch of `anyOf`/`oneOf` (or not every branch of `allOf`) can take one. Other keywords
|
|
32
|
+
* (`minLength`, `pattern`) narrow which strings fit and are left to the run (ADR-162).
|
|
33
|
+
*/
|
|
34
|
+
export function acceptsTaskInput(schema) {
|
|
35
|
+
if (schema === true || schema === undefined)
|
|
36
|
+
return true;
|
|
37
|
+
if (schema === false || schema === null || typeof schema !== "object" || Array.isArray(schema))
|
|
38
|
+
return false;
|
|
39
|
+
const value = schema;
|
|
40
|
+
if ("const" in value || "enum" in value)
|
|
41
|
+
return false;
|
|
42
|
+
const type = value.type;
|
|
43
|
+
if (typeof type === "string" && type !== "string")
|
|
44
|
+
return false;
|
|
45
|
+
if (Array.isArray(type) && !type.includes("string"))
|
|
46
|
+
return false;
|
|
47
|
+
const branches = (key) => (Array.isArray(value[key]) ? value[key] : undefined);
|
|
48
|
+
const anyOf = branches("anyOf");
|
|
49
|
+
if (anyOf && !anyOf.some(acceptsTaskInput))
|
|
50
|
+
return false;
|
|
51
|
+
const oneOf = branches("oneOf");
|
|
52
|
+
if (oneOf && !oneOf.some(acceptsTaskInput))
|
|
53
|
+
return false;
|
|
54
|
+
const allOf = branches("allOf");
|
|
55
|
+
if (allOf && !allOf.every(acceptsTaskInput))
|
|
56
|
+
return false;
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
/** Why a subagent used as a tool can't take its task, or undefined when it can (ADR-162). */
|
|
60
|
+
export function delegateInputIssue(id, inputSchema) {
|
|
61
|
+
if (inputSchema === undefined || acceptsTaskInput(inputSchema))
|
|
62
|
+
return undefined;
|
|
63
|
+
return `'${id}' is used as a tool, so it receives { task } as a string; its inputSchema must accept a string or be left out`;
|
|
64
|
+
}
|
|
28
65
|
async function engineOnly() {
|
|
29
66
|
throw new ToolError("delegation.engine-only", "Agents used as tools are run by the Nylorun engine, not by an executor");
|
|
30
67
|
}
|
|
@@ -13,7 +13,7 @@ export function compileAgentFlow(options) {
|
|
|
13
13
|
const stages = expand(options.stages);
|
|
14
14
|
if (stages.length === 0)
|
|
15
15
|
fail([
|
|
16
|
-
diagnostic("flow.empty", `
|
|
16
|
+
diagnostic("flow.empty", `'${options.id}' is driven by a flow with no stages. Add .pipe(), .switch(), .parallel(), .map() or .loop().`),
|
|
17
17
|
]);
|
|
18
18
|
const build = {
|
|
19
19
|
id: options.id,
|
|
@@ -189,14 +189,14 @@ function embed(build, id, manifest) {
|
|
|
189
189
|
return;
|
|
190
190
|
}
|
|
191
191
|
if (canonical(existing) !== canonical(manifest))
|
|
192
|
-
build.diagnostics.push(diagnostic("flow.agent-conflict", `
|
|
192
|
+
build.diagnostics.push(diagnostic("flow.agent-conflict", `The flow of '${build.id}' uses two different subagents with the id '${id}'. Give each subagent its own id.`));
|
|
193
193
|
}
|
|
194
194
|
function addBinding(build, id, binding) {
|
|
195
195
|
const existing = build.bindings[id];
|
|
196
196
|
if (existing === undefined)
|
|
197
197
|
build.bindings[id] = binding;
|
|
198
198
|
else if (canonical(existing.manifest) !== canonical(binding.manifest))
|
|
199
|
-
build.diagnostics.push(diagnostic("flow.agent-conflict", `
|
|
199
|
+
build.diagnostics.push(diagnostic("flow.agent-conflict", `The flow of '${build.id}' uses two different subagents with the id '${id}'. Give each subagent its own id.`));
|
|
200
200
|
}
|
|
201
201
|
/** Put a stage's `id` on its node, wrapping it in a chain when it has its own. */
|
|
202
202
|
function withId(node, id, build) {
|
|
@@ -224,12 +224,12 @@ function bindNodes(root, build) {
|
|
|
224
224
|
const part = leafPart(node);
|
|
225
225
|
if (part !== undefined) {
|
|
226
226
|
if (leaves.has(part) || ids.has(part))
|
|
227
|
-
build.diagnostics.push(diagnostic("flow.duplicate-leaf", `'${part}' runs twice in flow
|
|
227
|
+
build.diagnostics.push(diagnostic("flow.duplicate-leaf", `'${part}' runs twice in the flow of '${build.id}'. Give one a new id: x.withId("${part}-2").`));
|
|
228
228
|
leaves.add(part);
|
|
229
229
|
}
|
|
230
230
|
else if ("id" in node && node.id !== undefined) {
|
|
231
231
|
if (ids.has(node.id) || leaves.has(node.id))
|
|
232
|
-
build.diagnostics.push(diagnostic("flow.duplicate-id", `Two stages of flow
|
|
232
|
+
build.diagnostics.push(diagnostic("flow.duplicate-id", `Two stages of the flow of '${build.id}' are named '${node.id}'. Stage ids must be unique.`));
|
|
233
233
|
ids.add(node.id);
|
|
234
234
|
}
|
|
235
235
|
const code = build.code.get(node);
|
|
@@ -30,7 +30,7 @@ export function flowFrom(json, implementations = {}) {
|
|
|
30
30
|
throw new HarnessError("agent.build-failed", `Missing flow implementation${missing.length === 1 ? "" : "s"}: ${missing.join(", ")}`);
|
|
31
31
|
const unknown = Object.keys(given).filter((key) => !needs.includes(key));
|
|
32
32
|
if (unknown.length)
|
|
33
|
-
throw new HarnessError("agent.build-failed", `
|
|
33
|
+
throw new HarnessError("agent.build-failed", `The flow of '${manifest.id}' has no tool node${unknown.length === 1 ? "" : "s"} ${unknown.join(", ")}`);
|
|
34
34
|
const bindings = {};
|
|
35
35
|
for (const [id, agent] of Object.entries(agents))
|
|
36
36
|
bindings[id] = agentFrom(agent, implementations.agents?.[id] ?? {}).getBinding();
|
package/dist/folder/compile.js
CHANGED
|
@@ -661,7 +661,7 @@ export function compileAgentFolder(input, scope) {
|
|
|
661
661
|
}
|
|
662
662
|
else if ([...kinds.values()].includes("flow")) {
|
|
663
663
|
if (front.engine !== undefined)
|
|
664
|
-
error("flow_refused", "engine
|
|
664
|
+
error("flow_refused", "engine belongs to a model loop: set it in the AGENT.md of each subagent under agents/ that uses an engine feature", AGENT_FILE, ["engine"], { key: true });
|
|
665
665
|
}
|
|
666
666
|
else {
|
|
667
667
|
declared = engineDeclarations(front.engine, {
|
package/dist/folder/nested.js
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
* and `./x` one from its own. A slot it needs is derived in the uploaded folder's runtime
|
|
21
21
|
* section.
|
|
22
22
|
*/
|
|
23
|
-
import { DELEGATE_INPUT_SCHEMA, DELEGATE_NAME_PATTERN } from "../definition/delegate.js";
|
|
23
|
+
import { DELEGATE_INPUT_SCHEMA, DELEGATE_NAME_PATTERN, delegateInputIssue } from "../definition/delegate.js";
|
|
24
24
|
import { loopManifestOf } from "../definition/sections.js";
|
|
25
25
|
import { TOOL_SECRET_NAME_PATTERN } from "../contracts.js";
|
|
26
26
|
import { addInner, cloneJson, foldersUnder, isObject, jsonPosition, } from "./context.js";
|
|
@@ -225,12 +225,12 @@ function nestedChecks(ctx) {
|
|
|
225
225
|
/** An agent: its `agents/` are tools, and its plugins are listed. */
|
|
226
226
|
function composeAgent(ctx) {
|
|
227
227
|
if (ctx.front.inputSchema !== undefined)
|
|
228
|
-
ctx.report("error", "input_schema_refused", "inputSchema is a flow
|
|
228
|
+
ctx.report("error", "input_schema_refused", "inputSchema is for a manifest driven by a flow: one driven by a model loop takes the message, and a subagent used as a tool takes { task }. flow.json makes a manifest driven by a flow", AGENT_FILE, ["inputSchema"], { key: true });
|
|
229
229
|
const harness = ctx.harness;
|
|
230
230
|
const folders = foldersUnder("agents", ctx.entries.keys());
|
|
231
231
|
if (folders.size > 0 && ctx.scope?.role === "subagent")
|
|
232
232
|
for (const [id, inner] of folders)
|
|
233
|
-
ctx.report("error", "subagent_depth", `A subagent has no subagents:
|
|
233
|
+
ctx.report("error", "subagent_depth", `A subagent has no subagents: subagents used as tools nest one level deep. Move agents/${id}/ to the manifest that uses it`, folderFile(id, inner));
|
|
234
234
|
else if (folders.size > 0) {
|
|
235
235
|
const tools = Array.isArray(harness.tools) ? harness.tools : [];
|
|
236
236
|
const httpTools = new Set(tools.map((tool) => tool.name));
|
|
@@ -244,6 +244,11 @@ function composeAgent(ctx) {
|
|
|
244
244
|
const manifest = compileInner(ctx, `agents/${id}/`, "subagent");
|
|
245
245
|
if (!manifest)
|
|
246
246
|
continue;
|
|
247
|
+
const input = delegateInputIssue(id, manifest.harness.inputSchema);
|
|
248
|
+
if (input) {
|
|
249
|
+
ctx.report("error", "delegation_input", input, `agents/${id}/${AGENT_FILE}`, ["inputSchema"], { key: true });
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
247
252
|
ctx.origins.push([["harness", "tools", tools.length], { file: `agents/${id}/${AGENT_FILE}`, path: [] }]);
|
|
248
253
|
// As the TypeScript builder emits an agent used as a tool (`delegateTool`).
|
|
249
254
|
tools.push({
|
|
@@ -303,7 +308,7 @@ function composeFlow(ctx) {
|
|
|
303
308
|
const lines = ctx.agent.body.split("\n");
|
|
304
309
|
const first = lines.findIndex((line) => line.trim() !== "");
|
|
305
310
|
if (first >= 0)
|
|
306
|
-
ctx.report("error", "flow_body", "A
|
|
311
|
+
ctx.report("error", "flow_body", "A manifest driven by a flow has no instructions, so its AGENT.md has no body: each subagent under agents/ has its own", AGENT_FILE, undefined, {
|
|
307
312
|
at: { line: ctx.agent.bodyLine + first, column: 1 },
|
|
308
313
|
});
|
|
309
314
|
}
|
|
@@ -311,17 +316,17 @@ function composeFlow(ctx) {
|
|
|
311
316
|
for (const [path, kind] of ctx.kinds) {
|
|
312
317
|
const top = path.split("/").slice(0, 2).join("/");
|
|
313
318
|
if (kind === "instructions")
|
|
314
|
-
refuse("A flow has no instructions: move this to the
|
|
319
|
+
refuse("A manifest driven by a flow has no instructions: move this to the subagent under agents/ that needs it", path);
|
|
315
320
|
else if (kind === "mcp")
|
|
316
|
-
refuse("A flow has no MCP servers of its own: give mcp.json to the
|
|
321
|
+
refuse("A manifest driven by a flow has no MCP servers of its own: give mcp.json to the subagents under agents/ that call them", path);
|
|
317
322
|
else if ((kind === "skill" || kind === "plugin") && !noted.has(top)) {
|
|
318
323
|
noted.add(top);
|
|
319
|
-
refuse(kind === "skill" ? `A flow has no skills of its own: move ${top}/ to the
|
|
324
|
+
refuse(kind === "skill" ? `A manifest driven by a flow has no skills of its own: move ${top}/ to the subagent that uses it` : `A manifest driven by a flow takes no plugins: vendor ${top}/ in the subagent that uses it`, `${top}/`);
|
|
320
325
|
}
|
|
321
326
|
}
|
|
322
327
|
for (const key of ["mcpServers", "skills", "memory", "model"])
|
|
323
328
|
if (front[key] !== undefined)
|
|
324
|
-
refuse(`${key}
|
|
329
|
+
refuse(`${key} belongs to a model loop: set it in the AGENT.md of the subagent under agents/ that needs it`, AGENT_FILE, [key]);
|
|
325
330
|
const inputSchema = front.inputSchema === undefined ? undefined : ctx.schemaAt(AGENT_FILE, ["inputSchema"], front.inputSchema);
|
|
326
331
|
// The agents it names: the flow root's.
|
|
327
332
|
const own = foldersUnder("agents", ctx.entries.keys());
|