@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.
Files changed (88) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/README.md +2 -2
  3. package/dist/compatibility.d.ts +84 -10
  4. package/dist/compatibility.js +84 -10
  5. package/dist/contracts.d.ts +1328 -110
  6. package/dist/contracts.js +544 -157
  7. package/dist/define.d.ts +14 -12
  8. package/dist/define.js +10 -7
  9. package/dist/definition/approval.js +12 -14
  10. package/dist/definition/assemble.d.ts +6 -10
  11. package/dist/definition/assemble.js +48 -105
  12. package/dist/definition/bind-agent.d.ts +3 -4
  13. package/dist/definition/bind-agent.js +12 -30
  14. package/dist/definition/binding.d.ts +2 -2
  15. package/dist/definition/bound.d.ts +10 -10
  16. package/dist/definition/builder.d.ts +16 -20
  17. package/dist/definition/builder.js +29 -81
  18. package/dist/definition/code-tools.d.ts +3 -3
  19. package/dist/definition/code-tools.js +6 -21
  20. package/dist/definition/declaration.d.ts +4 -7
  21. package/dist/definition/declaration.js +29 -99
  22. package/dist/definition/{tools-capability.d.ts → deferred-tools.d.ts} +3 -13
  23. package/dist/definition/{tools-capability.js → deferred-tools.js} +2 -18
  24. package/dist/definition/delegate.d.ts +2 -4
  25. package/dist/definition/delegate.js +8 -10
  26. package/dist/definition/from.d.ts +7 -4
  27. package/dist/definition/from.js +72 -117
  28. package/dist/definition/helpers.d.ts +0 -7
  29. package/dist/definition/helpers.js +0 -5
  30. package/dist/definition/implementations.d.ts +6 -8
  31. package/dist/definition/manifest.d.ts +11 -5
  32. package/dist/definition/manifest.js +26 -26
  33. package/dist/definition/mcp.d.ts +1 -52
  34. package/dist/definition/mcp.js +0 -52
  35. package/dist/definition/media-reference.d.ts +23 -0
  36. package/dist/definition/media-reference.js +26 -0
  37. package/dist/definition/removed.d.ts +3 -10
  38. package/dist/definition/removed.js +10 -17
  39. package/dist/definition/runtime-manifest.d.ts +30 -0
  40. package/dist/definition/runtime-manifest.js +132 -0
  41. package/dist/definition/sandbox-tools.d.ts +1 -1
  42. package/dist/definition/sandbox-tools.js +1 -1
  43. package/dist/definition/skill-tools.d.ts +13 -7
  44. package/dist/definition/skill-tools.js +23 -10
  45. package/dist/definition/trace.d.ts +18 -0
  46. package/dist/definition/trace.js +42 -0
  47. package/dist/definition/variant.d.ts +5 -4
  48. package/dist/definition/variant.js +18 -51
  49. package/dist/definition/workflow/runnable.js +1 -1
  50. package/dist/errors.d.ts +1 -1
  51. package/dist/harness-api/entries.d.ts +1 -0
  52. package/dist/harness-api/entries.js +1 -0
  53. package/dist/harness-api/gates.d.ts +1 -6
  54. package/dist/harness-api/gates.js +1 -3
  55. package/dist/harness-api/harness-api.schema.json +11 -92
  56. package/dist/harness-api/index.d.ts +2 -2
  57. package/dist/harness-api/index.js +2 -2
  58. package/dist/harness-api/mcp.d.ts +0 -4
  59. package/dist/harness-api/mcp.js +0 -2
  60. package/dist/harness-api/messages.d.ts +1 -3
  61. package/dist/harness-api/messages.js +1 -3
  62. package/dist/harness-api/schema.d.ts +5 -17
  63. package/dist/harness-api/schema.js +9 -6
  64. package/dist/index.d.ts +1 -1
  65. package/dist/manifest-schemas.d.ts +6 -0
  66. package/dist/manifest-schemas.js +34 -0
  67. package/dist/schemas/agent-manifest.schema.json +897 -0
  68. package/dist/schemas/environment-manifest.schema.json +329 -0
  69. package/dist/types/agent.d.ts +1 -1
  70. package/dist/types/manifest.d.ts +33 -19
  71. package/dist/types/model.d.ts +2 -2
  72. package/dist/types/observe.d.ts +5 -18
  73. package/dist/types/part.d.ts +25 -0
  74. package/dist/types/tool.d.ts +1 -1
  75. package/dist/types/transcript.d.ts +5 -0
  76. package/dist/utils/definition-files.d.ts +11 -6
  77. package/dist/utils/definition-files.js +19 -9
  78. package/dist/utils/runtime-tools.d.ts +19 -0
  79. package/dist/utils/runtime-tools.js +30 -0
  80. package/dist/utils/sandbox.d.ts +1 -1
  81. package/dist/utils/sandbox.js +1 -1
  82. package/package.json +9 -3
  83. package/dist/definition/capability.d.ts +0 -43
  84. package/dist/definition/capability.js +0 -82
  85. package/dist/definition/sandbox-capability.d.ts +0 -44
  86. package/dist/definition/sandbox-capability.js +0 -139
  87. package/dist/types/middleware.d.ts +0 -94
  88. /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 compiled = compileDeclaration({ id: "mcp", mcpServers: Object.freeze(merged) });
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, compiled.bound),
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
- /** Attach a reusable bundle made with `capability({ id })`. */
130
- capability(bundle) {
131
- const declaration = isCapabilityBuilder(bundle)
132
- ? bundle.toDeclaration()
133
- : bundle;
134
- return this.addDeclaration(declaration, "capability()");
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
- use(idOrMiddleware, middleware) {
147
- if (typeof idOrMiddleware === "object") {
148
- deprecate("NYLORUN_DEP_USE", ".use(capability) is deprecated. Use .capability(), .mcp(), .skills() or .plugin().");
149
- const declaration = isCapabilityBuilder(idOrMiddleware)
150
- ? idOrMiddleware.toDeclaration()
151
- : idOrMiddleware;
152
- return this.addDeclaration(declaration, "use()");
153
- }
154
- const body = this.bodyFor("react", "use()");
155
- let compiled;
156
- if (typeof idOrMiddleware === "function") {
157
- compiled = {
158
- bound: {
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
- }, snapshot.dynamics);
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, compiled.bound),
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
- const compiled = compileDeclaration({
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` and no
3
- * `agent` that is not one of the Runtime's built-ins (sandbox tools, skill tools,
4
- * `save_artifact`, `read_artifact`), and a flow agent's `tool` stage without `http`. The
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 capability of manifest.capabilities)
18
- for (const tool of capability.tools ?? []) {
19
- if (tool.agent !== undefined)
20
- codeToolsOf(tool.agent, into);
21
- else if (!runsWithoutCode(capability, tool))
22
- into.push({ name: tool.name, owner: manifest.id, kind: "tool" });
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 { BoundMiddleware } from "./bound.js";
2
- import type { CapabilityInput, StepMiddleware } from "../types/middleware.js";
3
- export interface CompiledCapability {
4
- readonly bound: BoundMiddleware;
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 { REMOVED_CAPABILITY_FIELDS } from "./removed.js";
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 ["before", "after"])
6
+ for (const [field, message] of Object.entries(REMOVED_FIELDS))
6
7
  if (declaration[field] !== undefined)
7
- throw new HarnessError("configuration.invalid", `Capability '${declaration.id}': ${REMOVED_CAPABILITY_FIELDS.hooks}`);
8
- const tools = asTools(copyItems(declaration.tools, declaration.id));
9
- const instructions = copyItems(declaration.instructions, declaration.id);
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
- bound: {
25
- id: declaration.id,
26
- ...(declaration.name === undefined ? {} : { name: declaration.name }),
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: snapInstructions }),
77
- ...(snapTools === undefined ? {} : { tools: snapTools }),
78
- });
79
- }
80
- function copyItems(value, defaultSlot) {
81
- if (value === undefined)
82
- return undefined;
83
- if (!("items" in value))
84
- return Object.freeze({
85
- slot: defaultSlot,
86
- items: Object.freeze([...value]),
87
- });
88
- return Object.freeze({
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 { CapabilityManifest, ToolManifest } from "../types/manifest.js";
2
- /**
3
- * Id of the capability that holds `tool_search` and `tool_call` (R2b C10): the Runtime adds it at
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
- * Id of the capability that holds `tool_search` and `tool_call` (R2b C10): the Runtime adds it at
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
- * with the capability that declares each. Flow agents are in `flowDelegatesOf`.
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
- * with the capability that declares each. Flow agents are in `flowDelegatesOf`.
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 capability of manifest.capabilities)
79
- for (const tool of capability.tools ?? [])
80
- if (tool.agent && !("kind" in tool.agent))
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 capability of manifest.capabilities)
88
- for (const tool of capability.tools ?? [])
89
- if (tool.agent && "kind" in tool.agent)
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 with the capability's instructions while the tool is advertised, such
11
- * as `tool_search`'s note of the servers whose tools are deferred (R2b C10). Not hashed.
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
- /** Rebuild an agent from manifest JSON + in-process implementations (T28). */
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>;