@nylorun/core 0.20.0-beta → 0.21.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 +76 -0
- package/README.md +2 -2
- package/dist/compatibility.d.ts +84 -10
- package/dist/compatibility.js +84 -10
- package/dist/contracts.d.ts +1328 -110
- package/dist/contracts.js +544 -157
- package/dist/define.d.ts +14 -12
- package/dist/define.js +10 -7
- package/dist/definition/approval.js +12 -14
- package/dist/definition/assemble.d.ts +6 -10
- package/dist/definition/assemble.js +48 -105
- package/dist/definition/bind-agent.d.ts +3 -4
- package/dist/definition/bind-agent.js +12 -30
- package/dist/definition/binding.d.ts +2 -2
- package/dist/definition/bound.d.ts +10 -10
- package/dist/definition/builder.d.ts +16 -20
- package/dist/definition/builder.js +29 -81
- package/dist/definition/code-tools.d.ts +3 -3
- package/dist/definition/code-tools.js +6 -21
- package/dist/definition/declaration.d.ts +4 -7
- package/dist/definition/declaration.js +29 -99
- package/dist/definition/{tools-capability.d.ts → deferred-tools.d.ts} +3 -13
- package/dist/definition/{tools-capability.js → deferred-tools.js} +2 -18
- package/dist/definition/delegate.d.ts +2 -4
- package/dist/definition/delegate.js +8 -10
- package/dist/definition/from.d.ts +7 -4
- package/dist/definition/from.js +72 -117
- package/dist/definition/helpers.d.ts +0 -7
- package/dist/definition/helpers.js +0 -5
- package/dist/definition/implementations.d.ts +6 -8
- package/dist/definition/manifest.d.ts +11 -5
- package/dist/definition/manifest.js +26 -26
- package/dist/definition/mcp.d.ts +1 -52
- package/dist/definition/mcp.js +0 -52
- package/dist/definition/media-reference.d.ts +23 -0
- package/dist/definition/media-reference.js +26 -0
- package/dist/definition/removed.d.ts +3 -10
- package/dist/definition/removed.js +10 -17
- package/dist/definition/runtime-manifest.d.ts +30 -0
- package/dist/definition/runtime-manifest.js +132 -0
- package/dist/definition/sandbox-tools.d.ts +1 -1
- package/dist/definition/sandbox-tools.js +1 -1
- package/dist/definition/skill-tools.d.ts +13 -7
- package/dist/definition/skill-tools.js +23 -10
- package/dist/definition/trace.d.ts +18 -0
- package/dist/definition/trace.js +42 -0
- package/dist/definition/variant.d.ts +5 -4
- package/dist/definition/variant.js +18 -51
- package/dist/definition/workflow/runnable.js +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/harness-api/entries.d.ts +1 -0
- package/dist/harness-api/entries.js +1 -0
- package/dist/harness-api/gates.d.ts +1 -6
- package/dist/harness-api/gates.js +1 -3
- package/dist/harness-api/harness-api.schema.json +11 -92
- package/dist/harness-api/index.d.ts +2 -2
- package/dist/harness-api/index.js +2 -2
- package/dist/harness-api/mcp.d.ts +0 -4
- package/dist/harness-api/mcp.js +0 -2
- package/dist/harness-api/messages.d.ts +1 -3
- package/dist/harness-api/messages.js +1 -3
- package/dist/harness-api/schema.d.ts +5 -17
- package/dist/harness-api/schema.js +9 -6
- package/dist/index.d.ts +1 -1
- package/dist/manifest-schemas.d.ts +6 -0
- package/dist/manifest-schemas.js +34 -0
- package/dist/schemas/agent-manifest.schema.json +897 -0
- package/dist/schemas/environment-manifest.schema.json +329 -0
- package/dist/types/agent.d.ts +1 -1
- package/dist/types/manifest.d.ts +33 -19
- package/dist/types/model.d.ts +2 -2
- package/dist/types/observe.d.ts +5 -18
- package/dist/types/part.d.ts +25 -0
- package/dist/types/tool.d.ts +1 -1
- package/dist/types/transcript.d.ts +5 -0
- package/dist/utils/definition-files.d.ts +11 -6
- package/dist/utils/definition-files.js +19 -9
- package/dist/utils/runtime-tools.d.ts +19 -0
- package/dist/utils/runtime-tools.js +30 -0
- package/dist/utils/sandbox.d.ts +1 -1
- package/dist/utils/sandbox.js +1 -1
- package/package.json +9 -3
- package/dist/definition/capability.d.ts +0 -43
- package/dist/definition/capability.js +0 -82
- package/dist/definition/sandbox-capability.d.ts +0 -44
- package/dist/definition/sandbox-capability.js +0 -139
- package/dist/types/middleware.d.ts +0 -94
- /package/dist/types/{middleware.js → part.js} +0 -0
|
@@ -9,7 +9,6 @@ import { WorkflowBuildError } from "./workflow/diagnostics.js";
|
|
|
9
9
|
import { flowFrom } from "./flow/from.js";
|
|
10
10
|
import { compileAgentFlow } from "./flow/compile.js";
|
|
11
11
|
import { loopStage, mapStage, named, parallelStage, pipeStages, stepStage, switchStage, } from "./flow/spec.js";
|
|
12
|
-
import { isCapabilityBuilder } from "./capability.js";
|
|
13
12
|
export class AgentBuildError extends HarnessError {
|
|
14
13
|
diagnostics;
|
|
15
14
|
constructor(diagnostics) {
|
|
@@ -116,22 +115,24 @@ export class AgentBuilder {
|
|
|
116
115
|
}));
|
|
117
116
|
merged[key] = server;
|
|
118
117
|
}
|
|
119
|
-
const
|
|
118
|
+
const part = compileDeclaration({ id: "mcp", mcpServers: Object.freeze(merged) });
|
|
120
119
|
return this.spawn({
|
|
121
120
|
...snapshot,
|
|
122
121
|
...body,
|
|
123
122
|
mcpServers: Object.freeze(merged),
|
|
124
|
-
entries: replaceOrAppend(snapshot.entries,
|
|
125
|
-
dynamics: withDynamics(snapshot.dynamics, "mcp", {}),
|
|
123
|
+
entries: replaceOrAppend(snapshot.entries, part),
|
|
126
124
|
diagnostics: addDiagnostics(body.diagnostics ?? snapshot.diagnostics, diagnostics),
|
|
127
125
|
});
|
|
128
126
|
}
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
127
|
+
/** @internal Add a part (the SDK's `.skills()` and `.plugin()` use it). */
|
|
128
|
+
withPart(declaration, method) {
|
|
129
|
+
const body = this.bodyFor("react", method);
|
|
130
|
+
const snapshot = this.#snapshot;
|
|
131
|
+
return this.spawn({
|
|
132
|
+
...snapshot,
|
|
133
|
+
...body,
|
|
134
|
+
entries: Object.freeze([...snapshot.entries, compileDeclaration(declaration)]),
|
|
135
|
+
});
|
|
135
136
|
}
|
|
136
137
|
/** The structured output. Set once. */
|
|
137
138
|
output(schema) {
|
|
@@ -143,37 +144,19 @@ export class AgentBuilder {
|
|
|
143
144
|
});
|
|
144
145
|
return this.spawn({ ...snapshot, outputSchema: schema });
|
|
145
146
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
id: nextMiddlewareId(this.#snapshot.entries),
|
|
160
|
-
handle: idOrMiddleware,
|
|
161
|
-
hasMiddleware: true,
|
|
162
|
-
},
|
|
163
|
-
middleware: idOrMiddleware,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
compiled = {
|
|
168
|
-
bound: {
|
|
169
|
-
id: idOrMiddleware,
|
|
170
|
-
handle: middleware,
|
|
171
|
-
hasMiddleware: true,
|
|
172
|
-
},
|
|
173
|
-
middleware: middleware,
|
|
174
|
-
};
|
|
175
|
-
}
|
|
176
|
-
return this.appendCompiled(compiled, body);
|
|
147
|
+
/**
|
|
148
|
+
* What the agent needs of the Environment its session opens on (protocol 14, D65): a sandbox
|
|
149
|
+
* (`any` or `pod`) and secret names its skills' scripts read. A session whose Environment lacks
|
|
150
|
+
* them is refused when it opens. The agent still names no Environment. Set once.
|
|
151
|
+
*/
|
|
152
|
+
requires(requirements) {
|
|
153
|
+
const snapshot = this.#snapshot;
|
|
154
|
+
if (snapshot.requires !== undefined)
|
|
155
|
+
return this.spawn({
|
|
156
|
+
...snapshot,
|
|
157
|
+
diagnostics: addDiagnostics(snapshot.diagnostics, [singleValue(snapshot.id, "requires")]),
|
|
158
|
+
});
|
|
159
|
+
return this.spawn({ ...snapshot, requires: requirements });
|
|
177
160
|
}
|
|
178
161
|
// ── Flow: the manifest decides ─────────────────────────────────────────────
|
|
179
162
|
/** The flow agent's input. Set once. */
|
|
@@ -254,7 +237,8 @@ export class AgentBuilder {
|
|
|
254
237
|
description: snapshot.description,
|
|
255
238
|
metadata: snapshot.metadata,
|
|
256
239
|
outputSchema: snapshot.outputSchema,
|
|
257
|
-
|
|
240
|
+
requires: snapshot.requires,
|
|
241
|
+
});
|
|
258
242
|
if (!result.ok) {
|
|
259
243
|
this.#error = new AgentBuildError(result.diagnostics);
|
|
260
244
|
throw this.#error;
|
|
@@ -295,35 +279,17 @@ export class AgentBuilder {
|
|
|
295
279
|
? { tools: Object.freeze([...(snapshot.agentPart?.tools ?? []), ...(items.tools ?? [])]) }
|
|
296
280
|
: {}),
|
|
297
281
|
};
|
|
298
|
-
const compiled = compileDeclaration({ id: "agent", ...part });
|
|
299
282
|
return this.spawn({
|
|
300
283
|
...snapshot,
|
|
301
284
|
...body,
|
|
302
285
|
agentPart: Object.freeze(part),
|
|
303
|
-
entries: replaceOrAppend(snapshot.entries,
|
|
304
|
-
dynamics: withDynamics(snapshot.dynamics, "agent", snapshot.dynamics.get("agent") ?? {}),
|
|
286
|
+
entries: replaceOrAppend(snapshot.entries, compileDeclaration({ id: "agent", ...part })),
|
|
305
287
|
...(body.diagnostics === undefined ? {} : { diagnostics: body.diagnostics }),
|
|
306
288
|
});
|
|
307
289
|
}
|
|
308
|
-
addDeclaration(declaration, method) {
|
|
309
|
-
const body = this.bodyFor("react", method);
|
|
310
|
-
return this.appendCompiled(compileDeclaration(declaration), body);
|
|
311
|
-
}
|
|
312
|
-
appendCompiled(compiled, body) {
|
|
313
|
-
const snapshot = this.#snapshot;
|
|
314
|
-
const dynamics = new Map(snapshot.dynamics);
|
|
315
|
-
dynamics.set(compiled.bound.id, compiled.middleware ? { middleware: compiled.middleware } : {});
|
|
316
|
-
return this.spawn({
|
|
317
|
-
...snapshot,
|
|
318
|
-
...body,
|
|
319
|
-
entries: Object.freeze([...snapshot.entries, compiled.bound]),
|
|
320
|
-
dynamics,
|
|
321
|
-
});
|
|
322
|
-
}
|
|
323
290
|
}
|
|
324
291
|
function createSnapshot(options) {
|
|
325
292
|
const entries = [];
|
|
326
|
-
const dynamics = new Map();
|
|
327
293
|
const instructions = options.instructions === undefined
|
|
328
294
|
? undefined
|
|
329
295
|
: typeof options.instructions === "string"
|
|
@@ -332,13 +298,11 @@ function createSnapshot(options) {
|
|
|
332
298
|
if (instructions !== undefined || options.tools !== undefined || options.outputSchema !== undefined)
|
|
333
299
|
deprecate("NYLORUN_DEP_AGENT_OPTIONS", "Agent({ instructions, tools, outputSchema }) is deprecated. Use .instructions(), .tools(), .subagents() and .output().");
|
|
334
300
|
if (instructions !== undefined || options.tools !== undefined) {
|
|
335
|
-
|
|
301
|
+
entries.push(compileDeclaration({
|
|
336
302
|
id: "agent",
|
|
337
303
|
...(instructions === undefined ? {} : { instructions }),
|
|
338
304
|
...(options.tools === undefined ? {} : { tools: options.tools }),
|
|
339
|
-
});
|
|
340
|
-
entries.push(compiled.bound);
|
|
341
|
-
dynamics.set("agent", {});
|
|
305
|
+
}));
|
|
342
306
|
}
|
|
343
307
|
return {
|
|
344
308
|
id: options.id,
|
|
@@ -349,7 +313,6 @@ function createSnapshot(options) {
|
|
|
349
313
|
...(options.metadata === undefined ? {} : { metadata: options.metadata }),
|
|
350
314
|
outputSchema: options.outputSchema,
|
|
351
315
|
entries: Object.freeze(entries),
|
|
352
|
-
dynamics,
|
|
353
316
|
body: instructions !== undefined || options.tools !== undefined ? "react" : "none",
|
|
354
317
|
...(instructions === undefined && options.tools === undefined
|
|
355
318
|
? {}
|
|
@@ -373,11 +336,6 @@ function addDiagnostics(current, added) {
|
|
|
373
336
|
return current;
|
|
374
337
|
return Object.freeze([...(current ?? []), ...added]);
|
|
375
338
|
}
|
|
376
|
-
function withDynamics(dynamics, id, value) {
|
|
377
|
-
const next = new Map(dynamics);
|
|
378
|
-
next.set(id, value);
|
|
379
|
-
return next;
|
|
380
|
-
}
|
|
381
339
|
/** Replace the entry with the same id in place, or append it. */
|
|
382
340
|
function replaceOrAppend(entries, bound) {
|
|
383
341
|
const index = entries.findIndex((item) => item.id === bound.id);
|
|
@@ -385,13 +343,3 @@ function replaceOrAppend(entries, bound) {
|
|
|
385
343
|
return Object.freeze([...entries, bound]);
|
|
386
344
|
return Object.freeze([...entries.slice(0, index), bound, ...entries.slice(index + 1)]);
|
|
387
345
|
}
|
|
388
|
-
function nextMiddlewareId(entries) {
|
|
389
|
-
const taken = new Set(entries.map((item) => item.id));
|
|
390
|
-
let seq = 0;
|
|
391
|
-
let id;
|
|
392
|
-
do {
|
|
393
|
-
seq += 1;
|
|
394
|
-
id = `middleware-${seq}`;
|
|
395
|
-
} while (taken.has(id));
|
|
396
|
-
return id;
|
|
397
|
-
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tools that would run the developer's code (track R2 M6): an agent tool with no `http`
|
|
3
|
-
* `agent
|
|
4
|
-
*
|
|
2
|
+
* Tools that would run the developer's code (track R2 M6): an agent's own tool with no `http`
|
|
3
|
+
* and no `agent`, and a flow agent's `tool` stage without `http`. The tools in a pinned
|
|
4
|
+
* manifest's `runtime` block are the Runtime's own. The
|
|
5
5
|
* Runtime runs agents from their manifests alone, so `PUT /v1/agents/:id` refuses a definition
|
|
6
6
|
* with one, and the SDK refuses it before sending. The local engine (`@nylorun/harness/run`)
|
|
7
7
|
* still runs `tool({ run })`.
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { isSandboxToolName } from "../utils/sandbox.js";
|
|
2
1
|
import { forEachFlowNode } from "./flow/paths.js";
|
|
3
|
-
import { ARTIFACTS_CAPABILITY_ID, READ_ARTIFACT_TOOL, SAVE_ARTIFACT_TOOL, } from "./sandbox-capability.js";
|
|
4
|
-
import { isSkillTool } from "./skill-tools.js";
|
|
5
2
|
/** Every code tool of a definition document, the agents it embeds or uses as tools included. */
|
|
6
3
|
export function codeToolsOf(manifest, into = []) {
|
|
7
4
|
if ("kind" in manifest && manifest.kind === "workflow") {
|
|
@@ -14,26 +11,14 @@ export function codeToolsOf(manifest, into = []) {
|
|
|
14
11
|
codeToolsOf(agent, into);
|
|
15
12
|
return into;
|
|
16
13
|
}
|
|
17
|
-
for (const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
14
|
+
for (const tool of manifest.tools ?? []) {
|
|
15
|
+
if (tool.agent !== undefined)
|
|
16
|
+
codeToolsOf(tool.agent, into);
|
|
17
|
+
else if (tool.http === undefined)
|
|
18
|
+
into.push({ name: tool.name, owner: manifest.id, kind: "tool" });
|
|
19
|
+
}
|
|
24
20
|
return into;
|
|
25
21
|
}
|
|
26
|
-
/** An HTTP tool, or a built-in the Runtime serves. */
|
|
27
|
-
function runsWithoutCode(capability, tool) {
|
|
28
|
-
if (tool.http !== undefined)
|
|
29
|
-
return true;
|
|
30
|
-
if (capability.sandbox !== undefined && isSandboxToolName(tool.name))
|
|
31
|
-
return true;
|
|
32
|
-
if (capability.id === ARTIFACTS_CAPABILITY_ID &&
|
|
33
|
-
(tool.name === SAVE_ARTIFACT_TOOL || tool.name === READ_ARTIFACT_TOOL))
|
|
34
|
-
return true;
|
|
35
|
-
return isSkillTool(capability, tool.name);
|
|
36
|
-
}
|
|
37
22
|
/** Why a definition with code tools is refused, naming the first; undefined when it has none. */
|
|
38
23
|
export function codeToolRefusal(manifest) {
|
|
39
24
|
const [first, ...rest] = codeToolsOf(manifest);
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly middleware?: StepMiddleware<any>;
|
|
6
|
-
}
|
|
7
|
-
export declare function compileDeclaration<State>(declaration: CapabilityInput<State>): CompiledCapability;
|
|
1
|
+
import type { DefinitionPart } from "./bound.js";
|
|
2
|
+
import type { PartDeclaration } from "../types/part.js";
|
|
3
|
+
/** The definition part a declaration adds: its tools (agents become delegate tools) and text. */
|
|
4
|
+
export declare function compileDeclaration<Info>(declaration: PartDeclaration<Info>): DefinitionPart;
|
|
@@ -1,106 +1,36 @@
|
|
|
1
1
|
import { delegateTool, isAgentItem } from "./delegate.js";
|
|
2
2
|
import { HarnessError } from "../errors.js";
|
|
3
|
-
import {
|
|
3
|
+
import { REMOVED_PART_FIELDS } from "./removed.js";
|
|
4
|
+
/** The definition part a declaration adds: its tools (agents become delegate tools) and text. */
|
|
4
5
|
export function compileDeclaration(declaration) {
|
|
5
|
-
for (const field of
|
|
6
|
+
for (const [field, message] of Object.entries(REMOVED_FIELDS))
|
|
6
7
|
if (declaration[field] !== undefined)
|
|
7
|
-
throw new HarnessError("configuration.invalid", `
|
|
8
|
-
const tools =
|
|
9
|
-
const
|
|
10
|
-
const model = declaration.model;
|
|
11
|
-
const contributions = snapshotContributions(instructions?.items, tools?.items, model);
|
|
12
|
-
const handle = async (request, next) => {
|
|
13
|
-
if (tools)
|
|
14
|
-
request.configuration.tools.set(tools.slot, tools.items);
|
|
15
|
-
if (instructions)
|
|
16
|
-
request.configuration.instructions.set(instructions.slot, instructions.items);
|
|
17
|
-
if (model)
|
|
18
|
-
request.configuration.model.select(model);
|
|
19
|
-
return declaration.middleware
|
|
20
|
-
? declaration.middleware(request, next)
|
|
21
|
-
: next();
|
|
22
|
-
};
|
|
8
|
+
throw new HarnessError("configuration.invalid", `'${declaration.id}': ${message}`);
|
|
9
|
+
const tools = declaration.tools?.map((item) => isAgentItem(item) ? delegateTool(item) : item);
|
|
10
|
+
const sandbox = declaration.sandbox;
|
|
23
11
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
...(declaration.description === undefined
|
|
28
|
-
? {}
|
|
29
|
-
: { description: declaration.description }),
|
|
30
|
-
handle,
|
|
31
|
-
hasMiddleware: declaration.middleware !== undefined,
|
|
32
|
-
tools: tools?.items,
|
|
33
|
-
...(contributions === undefined ? {} : { contributions }),
|
|
34
|
-
...(declaration.type === undefined ? {} : { manifestType: declaration.type }),
|
|
35
|
-
...(declaration.metadata === undefined
|
|
36
|
-
? {}
|
|
37
|
-
: { metadata: declaration.metadata }),
|
|
38
|
-
...(declaration.skills === undefined ||
|
|
39
|
-
Object.keys(declaration.skills).length === 0
|
|
40
|
-
? {}
|
|
41
|
-
: { skills: declaration.skills }),
|
|
42
|
-
...(declaration.skillFiles === undefined ||
|
|
43
|
-
Object.keys(declaration.skillFiles).length === 0
|
|
44
|
-
? {}
|
|
45
|
-
: { skillFiles: declaration.skillFiles }),
|
|
46
|
-
...(declaration.mcpServers === undefined ||
|
|
47
|
-
Object.keys(declaration.mcpServers).length === 0
|
|
48
|
-
? {}
|
|
49
|
-
: { mcpServers: declaration.mcpServers }),
|
|
50
|
-
// Definitions declare no sandbox; carry one through so the build can refuse it by name.
|
|
51
|
-
...(sandboxOf(declaration) === undefined
|
|
52
|
-
? {}
|
|
53
|
-
: { sandbox: sandboxOf(declaration) }),
|
|
54
|
-
},
|
|
55
|
-
...(declaration.middleware ? { middleware: declaration.middleware } : {}),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
function snapshotContributions(instructions, tools, model) {
|
|
59
|
-
const snapInstructions = instructions === undefined ? undefined : Object.freeze([...instructions]);
|
|
60
|
-
const snapTools = tools === undefined
|
|
61
|
-
? undefined
|
|
62
|
-
: Object.freeze(tools.map((tool) => Object.freeze({
|
|
63
|
-
name: tool.name,
|
|
64
|
-
...(tool.description === undefined
|
|
65
|
-
? {}
|
|
66
|
-
: { description: tool.description }),
|
|
67
|
-
})));
|
|
68
|
-
// Model is Runtime-owned for the published manifest; still allow local middleware select().
|
|
69
|
-
void model;
|
|
70
|
-
if (snapInstructions === undefined && snapTools === undefined) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
return Object.freeze({
|
|
74
|
-
...(snapInstructions === undefined
|
|
12
|
+
id: declaration.id,
|
|
13
|
+
...(tools === undefined ? {} : { tools: Object.freeze(tools) }),
|
|
14
|
+
...(declaration.instructions === undefined
|
|
75
15
|
? {}
|
|
76
|
-
: { instructions:
|
|
77
|
-
...(
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
slot: value.slot,
|
|
90
|
-
items: Object.freeze([...value.items]),
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
/** Agents placed in `tools` become the tools that delegate to them. */
|
|
94
|
-
function asTools(value) {
|
|
95
|
-
if (value === undefined)
|
|
96
|
-
return undefined;
|
|
97
|
-
if (!value.items.some(isAgentItem))
|
|
98
|
-
return value;
|
|
99
|
-
return Object.freeze({
|
|
100
|
-
slot: value.slot,
|
|
101
|
-
items: Object.freeze(value.items.map((item) => (isAgentItem(item) ? delegateTool(item) : item))),
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
function sandboxOf(declaration) {
|
|
105
|
-
return declaration.sandbox;
|
|
16
|
+
: { instructions: Object.freeze([...declaration.instructions]) }),
|
|
17
|
+
...(declaration.skills === undefined || Object.keys(declaration.skills).length === 0
|
|
18
|
+
? {}
|
|
19
|
+
: { skills: declaration.skills }),
|
|
20
|
+
...(declaration.skillFiles === undefined || Object.keys(declaration.skillFiles).length === 0
|
|
21
|
+
? {}
|
|
22
|
+
: { skillFiles: declaration.skillFiles }),
|
|
23
|
+
...(declaration.mcpServers === undefined || Object.keys(declaration.mcpServers).length === 0
|
|
24
|
+
? {}
|
|
25
|
+
: { mcpServers: declaration.mcpServers }),
|
|
26
|
+
// Definitions declare no sandbox; carry one through so the build can refuse it by name.
|
|
27
|
+
...(sandbox === undefined ? {} : { sandbox }),
|
|
28
|
+
};
|
|
106
29
|
}
|
|
30
|
+
/** Fields a part no longer takes, and why. */
|
|
31
|
+
const REMOVED_FIELDS = Object.freeze({
|
|
32
|
+
before: REMOVED_PART_FIELDS.hooks,
|
|
33
|
+
after: REMOVED_PART_FIELDS.hooks,
|
|
34
|
+
middleware: "step middleware was removed: an agent is its manifest alone (see MIGRATION.md)",
|
|
35
|
+
model: REMOVED_PART_FIELDS.model,
|
|
36
|
+
});
|
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* session open to each agent with a remote MCP server, empty. When some of the agent's MCP tools
|
|
5
|
-
* are deferred, the session's tools put `tool_search` and `tool_call` in it.
|
|
6
|
-
*/
|
|
7
|
-
export declare const TOOLS_CAPABILITY_ID = "nylorun.tools";
|
|
8
|
-
/** Finds deferred tools by a query (BM25 over their names and descriptions). */
|
|
9
|
-
export declare const TOOL_SEARCH_TOOL = "tool_search";
|
|
10
|
-
/** Runs a deferred tool by name, as a call of that tool. */
|
|
11
|
-
export declare const TOOL_CALL_TOOL = "tool_call";
|
|
1
|
+
import type { ToolManifest } from "../types/manifest.js";
|
|
2
|
+
import { TOOL_CALL_TOOL, TOOL_SEARCH_TOOL } from "../utils/runtime-tools.js";
|
|
3
|
+
export { TOOL_CALL_TOOL, TOOL_SEARCH_TOOL };
|
|
12
4
|
/** How many tools `tool_search` returns when the model sets no `limit`. */
|
|
13
5
|
export declare const TOOL_SEARCH_DEFAULT_LIMIT = 8;
|
|
14
6
|
/** The most tools one `tool_search` returns. */
|
|
@@ -23,8 +15,6 @@ export interface DeferredServerNote {
|
|
|
23
15
|
/** The server's own instructions (MCP `initialize`), if it gave any. */
|
|
24
16
|
readonly instructions?: string;
|
|
25
17
|
}
|
|
26
|
-
/** The capability the Runtime adds to an agent with a remote MCP server: empty, until tools are deferred. */
|
|
27
|
-
export declare function toolsCapabilityManifest(): CapabilityManifest;
|
|
28
18
|
/**
|
|
29
19
|
* `tool_search` and `tool_call`, as the session gives them to an agent with deferred tools. Their
|
|
30
20
|
* schemas reach the model; change them deliberately.
|
|
@@ -2,16 +2,8 @@ import { z } from "zod";
|
|
|
2
2
|
import { tool } from "./helpers.js";
|
|
3
3
|
import { ToolError } from "./tool-error.js";
|
|
4
4
|
import { normalizedSchemasFor } from "./schema.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* session open to each agent with a remote MCP server, empty. When some of the agent's MCP tools
|
|
8
|
-
* are deferred, the session's tools put `tool_search` and `tool_call` in it.
|
|
9
|
-
*/
|
|
10
|
-
export const TOOLS_CAPABILITY_ID = "nylorun.tools";
|
|
11
|
-
/** Finds deferred tools by a query (BM25 over their names and descriptions). */
|
|
12
|
-
export const TOOL_SEARCH_TOOL = "tool_search";
|
|
13
|
-
/** Runs a deferred tool by name, as a call of that tool. */
|
|
14
|
-
export const TOOL_CALL_TOOL = "tool_call";
|
|
5
|
+
import { TOOL_CALL_TOOL, TOOL_SEARCH_TOOL } from "../utils/runtime-tools.js";
|
|
6
|
+
export { TOOL_CALL_TOOL, TOOL_SEARCH_TOOL };
|
|
15
7
|
/** How many tools `tool_search` returns when the model sets no `limit`. */
|
|
16
8
|
export const TOOL_SEARCH_DEFAULT_LIMIT = 8;
|
|
17
9
|
/** The most tools one `tool_search` returns. */
|
|
@@ -21,14 +13,6 @@ export const SERVER_INSTRUCTIONS_MAX_CHARS = 2_000;
|
|
|
21
13
|
async function toolsRuntimeOnly() {
|
|
22
14
|
throw new ToolError("tools.runtime-only", "tool_search and tool_call run in the Nylorun Runtime. Connect the agent to a Runtime to use them.");
|
|
23
15
|
}
|
|
24
|
-
/** The capability the Runtime adds to an agent with a remote MCP server: empty, until tools are deferred. */
|
|
25
|
-
export function toolsCapabilityManifest() {
|
|
26
|
-
return {
|
|
27
|
-
id: TOOLS_CAPABILITY_ID,
|
|
28
|
-
type: "agent",
|
|
29
|
-
description: "Deferred MCP tools: tool_search finds them and tool_call runs them.",
|
|
30
|
-
};
|
|
31
|
-
}
|
|
32
16
|
/**
|
|
33
17
|
* `tool_search` and `tool_call`, as the session gives them to an agent with deferred tools. Their
|
|
34
18
|
* schemas reach the model; change them deliberately.
|
|
@@ -38,16 +38,14 @@ export declare function delegateFromManifest(manifest: AgentManifest | WorkflowM
|
|
|
38
38
|
/** The delegate behind a tool definition, or behind the bound snapshot of one. */
|
|
39
39
|
export declare function delegateOf(tool: unknown): Delegate | undefined;
|
|
40
40
|
/**
|
|
41
|
-
* The ReAct agents a manifest delegates to, which the engine runs inside the parent's run
|
|
42
|
-
*
|
|
41
|
+
* The ReAct agents a manifest delegates to, which the engine runs inside the parent's run.
|
|
42
|
+
* Flow agents are in `flowDelegatesOf`.
|
|
43
43
|
*/
|
|
44
44
|
export declare function delegatesOf(manifest: AgentManifest): readonly {
|
|
45
|
-
readonly capabilityId: string;
|
|
46
45
|
readonly manifest: AgentManifest;
|
|
47
46
|
}[];
|
|
48
47
|
/** The flow agents a manifest delegates to: each runs in its own linked session. */
|
|
49
48
|
export declare function flowDelegatesOf(manifest: AgentManifest): readonly {
|
|
50
|
-
readonly capabilityId: string;
|
|
51
49
|
readonly manifest: WorkflowManifest;
|
|
52
50
|
}[];
|
|
53
51
|
/** The flow agent `id` a manifest delegates to, or undefined. */
|
|
@@ -70,24 +70,22 @@ export function delegateOf(tool) {
|
|
|
70
70
|
return value[DELEGATE] ?? (value.source === tool ? undefined : delegateOf(value.source));
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* The ReAct agents a manifest delegates to, which the engine runs inside the parent's run
|
|
74
|
-
*
|
|
73
|
+
* The ReAct agents a manifest delegates to, which the engine runs inside the parent's run.
|
|
74
|
+
* Flow agents are in `flowDelegatesOf`.
|
|
75
75
|
*/
|
|
76
76
|
export function delegatesOf(manifest) {
|
|
77
77
|
const found = [];
|
|
78
|
-
for (const
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
found.push({ capabilityId: capability.id, manifest: tool.agent });
|
|
78
|
+
for (const tool of manifest.tools ?? [])
|
|
79
|
+
if (tool.agent && !("kind" in tool.agent))
|
|
80
|
+
found.push({ manifest: tool.agent });
|
|
82
81
|
return found;
|
|
83
82
|
}
|
|
84
83
|
/** The flow agents a manifest delegates to: each runs in its own linked session. */
|
|
85
84
|
export function flowDelegatesOf(manifest) {
|
|
86
85
|
const found = [];
|
|
87
|
-
for (const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
found.push({ capabilityId: capability.id, manifest: tool.agent });
|
|
86
|
+
for (const tool of manifest.tools ?? [])
|
|
87
|
+
if (tool.agent && "kind" in tool.agent)
|
|
88
|
+
found.push({ manifest: tool.agent });
|
|
91
89
|
return found;
|
|
92
90
|
}
|
|
93
91
|
/** The flow agent `id` a manifest delegates to, or undefined. */
|
|
@@ -4,15 +4,18 @@ import type { JsonObject } from "../types/shared.js";
|
|
|
4
4
|
import type { Implementations } from "./implementations.js";
|
|
5
5
|
/** A tool that exists for one execution and is not part of the hashed manifest. */
|
|
6
6
|
export interface SessionToolRef {
|
|
7
|
-
readonly capabilityId: string;
|
|
8
7
|
readonly name: string;
|
|
9
8
|
/**
|
|
10
|
-
* Text the model reads
|
|
11
|
-
*
|
|
9
|
+
* Text the model reads while the tool is advertised, such as `tool_search`'s note of the
|
|
10
|
+
* servers whose tools are deferred (R2b C10). Not hashed.
|
|
12
11
|
*/
|
|
13
12
|
readonly instructions?: readonly string[];
|
|
14
13
|
}
|
|
15
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Rebuild an agent from its manifest and the code of its tools, by name (T28). Agents used as
|
|
16
|
+
* tools and HTTP tools need no code; neither do the tools in `runtime`, which the Runtime serves.
|
|
17
|
+
* A session tool (`sessionTools`) is offered with the `runtime` part and needs its code.
|
|
18
|
+
*/
|
|
16
19
|
export declare function agentFrom<Info = unknown>(json: AgentManifest | JsonObject, implementations: Implementations<Info>, options?: {
|
|
17
20
|
readonly sessionTools?: readonly SessionToolRef[];
|
|
18
21
|
}): BuiltAgent<Info>;
|