@nylorun/core 0.13.0-beta → 0.15.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 (90) hide show
  1. package/CHANGELOG.md +114 -0
  2. package/dist/compatibility.d.ts +49 -25
  3. package/dist/compatibility.js +48 -27
  4. package/dist/contracts.d.ts +318 -956
  5. package/dist/contracts.js +280 -515
  6. package/dist/define.d.ts +13 -10
  7. package/dist/define.js +7 -4
  8. package/dist/definition/assemble.d.ts +0 -3
  9. package/dist/definition/assemble.js +13 -19
  10. package/dist/definition/bind-agent.js +0 -2
  11. package/dist/definition/bind-tool.js +0 -1
  12. package/dist/definition/bound.d.ts +3 -10
  13. package/dist/definition/builder.d.ts +19 -55
  14. package/dist/definition/builder.js +19 -130
  15. package/dist/definition/capability.d.ts +3 -15
  16. package/dist/definition/capability.js +3 -25
  17. package/dist/definition/code-tools.d.ts +22 -0
  18. package/dist/definition/code-tools.js +46 -0
  19. package/dist/definition/declaration.d.ts +0 -3
  20. package/dist/definition/declaration.js +8 -11
  21. package/dist/definition/delegate.d.ts +7 -7
  22. package/dist/definition/flow/compile.d.ts +4 -5
  23. package/dist/definition/flow/compile.js +120 -72
  24. package/dist/definition/flow/from.d.ts +2 -2
  25. package/dist/definition/flow/from.js +14 -33
  26. package/dist/definition/flow/index.d.ts +2 -2
  27. package/dist/definition/flow/index.js +2 -2
  28. package/dist/definition/flow/paths.d.ts +32 -17
  29. package/dist/definition/flow/paths.js +35 -14
  30. package/dist/definition/flow/spec.d.ts +6 -9
  31. package/dist/definition/flow/spec.js +49 -31
  32. package/dist/definition/flow/types.d.ts +40 -116
  33. package/dist/definition/from.js +36 -41
  34. package/dist/definition/helpers.d.ts +1 -1
  35. package/dist/definition/helpers.js +1 -1
  36. package/dist/definition/http-tool.d.ts +66 -0
  37. package/dist/definition/http-tool.js +131 -0
  38. package/dist/definition/implementations.d.ts +0 -3
  39. package/dist/definition/manifest.js +5 -4
  40. package/dist/definition/mcp.d.ts +4 -2
  41. package/dist/definition/mcp.js +14 -18
  42. package/dist/definition/removed.d.ts +10 -0
  43. package/dist/definition/removed.js +26 -0
  44. package/dist/definition/sandbox-capability.d.ts +2 -0
  45. package/dist/definition/sandbox-capability.js +11 -1
  46. package/dist/definition/schema.js +0 -3
  47. package/dist/definition/skill-tools.d.ts +16 -2
  48. package/dist/definition/skill-tools.js +38 -31
  49. package/dist/definition/variant.d.ts +1 -1
  50. package/dist/definition/variant.js +3 -14
  51. package/dist/definition/workflow/diagnostics.d.ts +1 -7
  52. package/dist/definition/workflow/diagnostics.js +1 -24
  53. package/dist/definition/workflow/index.d.ts +3 -17
  54. package/dist/definition/workflow/index.js +2 -9
  55. package/dist/definition/workflow/runnable.d.ts +2 -34
  56. package/dist/definition/workflow/runnable.js +8 -142
  57. package/dist/definition/workflow/types.d.ts +1 -10
  58. package/dist/harness-api/messages.d.ts +24 -27
  59. package/dist/harness-api/messages.js +1 -1
  60. package/dist/harness-api/schema.d.ts +0 -16
  61. package/dist/harness-api/schema.js +5 -12
  62. package/dist/index.d.ts +1 -1
  63. package/dist/types/manifest.d.ts +41 -14
  64. package/dist/types/middleware.d.ts +11 -16
  65. package/dist/types/observe.d.ts +0 -6
  66. package/dist/types/tool.d.ts +0 -6
  67. package/dist/types/workflow.d.ts +54 -110
  68. package/dist/utils/definition-files.d.ts +31 -0
  69. package/dist/utils/definition-files.js +84 -0
  70. package/package.json +1 -1
  71. package/dist/definition/hooks.d.ts +0 -19
  72. package/dist/definition/hooks.js +0 -67
  73. package/dist/definition/workflow/build.d.ts +0 -28
  74. package/dist/definition/workflow/build.js +0 -40
  75. package/dist/definition/workflow/chain.d.ts +0 -49
  76. package/dist/definition/workflow/chain.js +0 -40
  77. package/dist/definition/workflow/loop.d.ts +0 -54
  78. package/dist/definition/workflow/loop.js +0 -100
  79. package/dist/definition/workflow/map.d.ts +0 -17
  80. package/dist/definition/workflow/map.js +0 -45
  81. package/dist/definition/workflow/parallel.d.ts +0 -19
  82. package/dist/definition/workflow/parallel.js +0 -36
  83. package/dist/definition/workflow/patch.d.ts +0 -11
  84. package/dist/definition/workflow/patch.js +0 -45
  85. package/dist/definition/workflow/slot.d.ts +0 -23
  86. package/dist/definition/workflow/slot.js +0 -16
  87. package/dist/definition/workflow/switch.d.ts +0 -26
  88. package/dist/definition/workflow/switch.js +0 -64
  89. package/dist/types/dynamics.d.ts +0 -101
  90. package/dist/types/dynamics.js +0 -1
package/dist/define.d.ts CHANGED
@@ -6,12 +6,15 @@ export type { AgentTool, BuiltAgent } from "./types/agent.js";
6
6
  export { DELEGATE_INPUT_SCHEMA, delegateManifest, delegateOf, delegatesOf, flowDelegatesOf, flowDelegateManifest, isFlowDelegate, } from "./definition/delegate.js";
7
7
  export type { Delegate } from "./definition/delegate.js";
8
8
  export { capability, middleware, model, tool } from "./definition/helpers.js";
9
+ export { APPROVAL_MODES, HTTP_TOOL_DEFAULT_TIMEOUT_MS, HTTP_TOOL_MAX_TIMEOUT_MS, HTTP_TOOL_METHODS, http, httpToolOf, isHttpTarget, withHttpTarget, type HttpTarget, type HttpTool, type HttpToolOptions, } from "./definition/http-tool.js";
9
10
  export { ARTIFACTS_CAPABILITY_ID, SANDBOX_CAPABILITY_ID, SAVE_ARTIFACT_TOOL, artifactsCapabilityManifest, sandboxCapabilityManifest, } from "./definition/sandbox-capability.js";
10
- export { mcp, McpError, normalizeMcpServers } from "./definition/mcp.js";
11
+ export { mcp, McpError, normalizeMcpServers, stdioMcpRefusal } from "./definition/mcp.js";
12
+ export { codeToolRefusal, codeToolsOf } from "./definition/code-tools.js";
13
+ export type { CodeTool } from "./definition/code-tools.js";
11
14
  export { CapabilityBuilder, isCapabilityBuilder } from "./definition/capability.js";
12
15
  export type { CapabilityIdentity, CapabilityOptions } from "./definition/capability.js";
13
- export { flow, FlowBuilder, isFlowBuilder, ROOT_POSITION, childPosition, embeddedAgent, forEachFlowNode, functionKey, indexSuffix, isLeafNode, isWorkflowManifestV2, leafPart, leafPath, stageKey, stripIndices, } from "./definition/flow/index.js";
14
- export type { FlowAgentBuilder, Flow, Named, StageArgs, NestedStageArgs, FlowOut, LoopChoice, LoopDecideArgs as FlowLoopDecideArgs, LoopVerifyFn as FlowLoopVerifyFn, FlowFunctionRole, FlowNodeVisit, FlowImplementations, } from "./definition/flow/index.js";
16
+ export { flow, FlowBuilder, isFlowBuilder, ROOT_POSITION, childPosition, embeddedAgent, flowHttpTarget, forEachFlowNode, indexSuffix, isLeafNode, isWorkflowManifest, leafPart, leafPath, stageKey, stripIndices, } from "./definition/flow/index.js";
17
+ export type { FlowAgentBuilder, Flow, Named, FlowOut, LoopOptions, StageOptions, FlowNodeVisit, FlowVisitNode, FlowHttpTarget, FlowImplementations, } from "./definition/flow/index.js";
15
18
  export type { McpCapability, McpOptions, McpServerSpec } from "./definition/mcp.js";
16
19
  export { ToolError, isToolError } from "./definition/tool-error.js";
17
20
  export { defineSchema } from "./definition/schema.js";
@@ -20,11 +23,11 @@ export { MODEL_FAILURE_CODES, isModelFailureOutcome } from "./definition/model-f
20
23
  export { createSandboxTools, SANDBOX_INSTRUCTIONS, } from "./definition/sandbox-tools.js";
21
24
  export { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE, isSandboxHostPattern, isSandboxToolName, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
22
25
  export type { SandboxToolName } from "./utils/sandbox.js";
26
+ export { LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILL_TOOL_NAMES, isSkillTool, } from "./definition/skill-tools.js";
27
+ export { DEFINITION_FILE_MAX_BYTES, SKILL_ENTRY, SKILL_FILES_MAX, SKILL_FILE_PATH_MAX, SKILLS_MOUNT, definitionFilesOf, isDefinitionFileHash, skillFilePathIssue, skillFilesIssue, skillInstructions, } from "./utils/definition-files.js";
23
28
  export type { Implementations } from "./definition/implementations.js";
24
- export type { AgentManifest, CapabilityManifest, McpServerManifest, RuntimeManifest, SandboxManifest, SandboxNetworkPreset, SkillManifest, ToolManifest, ManifestSchemaVersion, } from "./types/manifest.js";
25
- export type { CapabilityDeclaration, CapabilityInput, CapabilityItems, MiddlewareContributions, SkillRecord, StepMiddleware, StepRequest, StepResponse, } from "./types/middleware.js";
26
- export type { Patch, Decision, TurnDecision, HookAt, HookScope, HookManifest, HookState, HookToolCall, BeforeHook, AfterHook, BeforeHooks, AfterHooks, BeforeTurnArgs, BeforeStepArgs, AfterStepArgs, AfterTurnArgs, } from "./types/dynamics.js";
27
- export { HOOK_POINTS, hasHook, hookListIssue, hooksFrom, runHookPoint, } from "./definition/hooks.js";
29
+ export type { AgentManifest, ApprovalMode, CapabilityManifest, HttpToolMethod, HttpToolTarget, McpServerManifest, RuntimeManifest, SandboxManifest, SandboxNetworkPreset, SkillManifest, ToolManifest, ManifestSchemaVersion, } from "./types/manifest.js";
30
+ export type { CapabilityDeclaration, CapabilityInput, CapabilityItems, MiddlewareContributions, SkillFileSource, StepMiddleware, StepRequest, StepResponse, } from "./types/middleware.js";
28
31
  export type { ModelCandidate, ModelControls, ModelDirective, ModelEvidence, ModelFinishReason, ModelFailureCode, ModelFailureOutcome, ModelProducer, ModelAdapter, ModelAdapterContext, ModelPreparedCall, ContextContributor, ContextMutationOptions, ContextSnapshot, ModelCall, ModelCallTool, ModelOutputBlock, PromptContentPart, PromptItem, ModelConfigurationContributor, ModelConfigurationInstruction, ModelConfigurationMutationOptions, ModelConfigurationSnapshot, ModelConfigurationTool, ModelRequest, ModelToolCall, ModelUsage, } from "./types/model.js";
29
32
  export type { BuildDiagnostic, ContextItem, DeferredOutcome, JsonObject, JsonPrimitive, JsonValue, Tripwire, } from "./types/shared.js";
30
33
  export type { ObserveEvent, ObserveModelConfigurationSnapshot, ObserveModelRequested, ObserveSealedCall, ObserveToolSnapshot, Observer, } from "./types/observe.js";
@@ -33,10 +36,10 @@ export type { Interaction, RequiredInteraction, ToolContent, ToolDefinition, Too
33
36
  export { normalizeToolDefinition, normalizedSchemasFor, } from "./definition/schema.js";
34
37
  export { implementationsFor, bindingFromAgent } from "./definition/binding.js";
35
38
  export type { AgentBinding } from "./definition/binding.js";
36
- export { Loop, Chain, Switch, Parallel, Map, VerdictSchema, isVerdict, withInstructions, withoutTools, WorkflowBuildError, isSlot, isBuiltWorkflow, } from "./definition/workflow/index.js";
37
- export type { BuiltWorkflow, OutputOf, InputOf, LoopOptions, LoopRunnable, LoopVerify, LoopVerifyFn, LoopDecideFn, LoopVerifyArgs, LoopDecideArgs, LoopDecision, ChainOptions, ChainStep, ChainResults, ChainSlot, SwitchOptions, SwitchCases, ParallelOptions, ParallelBranches, MapOptions, MapOver, Slot, SlotInputArgs, WorkflowRunnable, } from "./definition/workflow/index.js";
39
+ export { VerdictSchema, isVerdict, WorkflowBuildError, isBuiltWorkflow, } from "./definition/workflow/index.js";
40
+ export type { BuiltWorkflow } from "./definition/workflow/index.js";
38
41
  export { isVariantOf } from "./definition/variant.js";
39
- export type { Verdict, WorkflowBinding, WorkflowManifest, WorkflowManifestV1, WorkflowManifestV2, WorkflowNodeV2, } from "./types/workflow.js";
42
+ export type { Verdict, WorkflowBinding, WorkflowHttpVerify, WorkflowLoopVerify, WorkflowManifest, WorkflowNode, } from "./types/workflow.js";
40
43
  export type { BoundMiddleware, BoundToolDefinition, } from "./definition/bound.js";
41
44
  export { bindTool } from "./definition/bind-tool.js";
42
45
  export { bindOutputContract } from "./definition/output-contract.js";
package/dist/define.js CHANGED
@@ -2,20 +2,23 @@ export { Agent, AgentBuilder, AgentBuildError, AgentLifecycleError, } from "./de
2
2
  export { HarnessError, isHarnessError } from "./errors.js";
3
3
  export { DELEGATE_INPUT_SCHEMA, delegateManifest, delegateOf, delegatesOf, flowDelegatesOf, flowDelegateManifest, isFlowDelegate, } from "./definition/delegate.js";
4
4
  export { capability, middleware, model, tool } from "./definition/helpers.js";
5
+ export { APPROVAL_MODES, HTTP_TOOL_DEFAULT_TIMEOUT_MS, HTTP_TOOL_MAX_TIMEOUT_MS, HTTP_TOOL_METHODS, http, httpToolOf, isHttpTarget, withHttpTarget, } from "./definition/http-tool.js";
5
6
  export { ARTIFACTS_CAPABILITY_ID, SANDBOX_CAPABILITY_ID, SAVE_ARTIFACT_TOOL, artifactsCapabilityManifest, sandboxCapabilityManifest, } from "./definition/sandbox-capability.js";
6
- export { mcp, McpError, normalizeMcpServers } from "./definition/mcp.js";
7
+ export { mcp, McpError, normalizeMcpServers, stdioMcpRefusal } from "./definition/mcp.js";
8
+ export { codeToolRefusal, codeToolsOf } from "./definition/code-tools.js";
7
9
  export { CapabilityBuilder, isCapabilityBuilder } from "./definition/capability.js";
8
- export { flow, FlowBuilder, isFlowBuilder, ROOT_POSITION, childPosition, embeddedAgent, forEachFlowNode, functionKey, indexSuffix, isLeafNode, isWorkflowManifestV2, leafPart, leafPath, stageKey, stripIndices, } from "./definition/flow/index.js";
10
+ export { flow, FlowBuilder, isFlowBuilder, ROOT_POSITION, childPosition, embeddedAgent, flowHttpTarget, forEachFlowNode, indexSuffix, isLeafNode, isWorkflowManifest, leafPart, leafPath, stageKey, stripIndices, } from "./definition/flow/index.js";
9
11
  export { ToolError, isToolError } from "./definition/tool-error.js";
10
12
  export { defineSchema } from "./definition/schema.js";
11
13
  export { hashManifest } from "./utils/hash.js";
12
14
  export { MODEL_FAILURE_CODES, isModelFailureOutcome } from "./definition/model-failure.js";
13
15
  export { createSandboxTools, SANDBOX_INSTRUCTIONS, } from "./definition/sandbox-tools.js";
14
16
  export { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE, isSandboxHostPattern, isSandboxToolName, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
15
- export { HOOK_POINTS, hasHook, hookListIssue, hooksFrom, runHookPoint, } from "./definition/hooks.js";
17
+ export { LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILL_TOOL_NAMES, isSkillTool, } from "./definition/skill-tools.js";
18
+ export { DEFINITION_FILE_MAX_BYTES, SKILL_ENTRY, SKILL_FILES_MAX, SKILL_FILE_PATH_MAX, SKILLS_MOUNT, definitionFilesOf, isDefinitionFileHash, skillFilePathIssue, skillFilesIssue, skillInstructions, } from "./utils/definition-files.js";
16
19
  export { normalizeToolDefinition, normalizedSchemasFor, } from "./definition/schema.js";
17
20
  export { implementationsFor, bindingFromAgent } from "./definition/binding.js";
18
- export { Loop, Chain, Switch, Parallel, Map, VerdictSchema, isVerdict, withInstructions, withoutTools, WorkflowBuildError, isSlot, isBuiltWorkflow, } from "./definition/workflow/index.js";
21
+ export { VerdictSchema, isVerdict, WorkflowBuildError, isBuiltWorkflow, } from "./definition/workflow/index.js";
19
22
  export { isVariantOf } from "./definition/variant.js";
20
23
  export { bindTool } from "./definition/bind-tool.js";
21
24
  export { bindOutputContract } from "./definition/output-contract.js";
@@ -3,7 +3,6 @@ import type { BuiltAgent } from "../types/agent.js";
3
3
  import type { AgentManifest, RuntimeManifest } from "../types/manifest.js";
4
4
  import type { BuildDiagnostic, JsonObject } from "../types/shared.js";
5
5
  import type { ToolSchemaSource } from "../types/tool.js";
6
- import type { AfterHooks, BeforeHooks } from "../types/dynamics.js";
7
6
  import type { StepMiddleware } from "../types/middleware.js";
8
7
  type BuildResult<Agent> = {
9
8
  readonly ok: true;
@@ -14,8 +13,6 @@ type BuildResult<Agent> = {
14
13
  readonly diagnostics: readonly BuildDiagnostic[];
15
14
  };
16
15
  export interface CapabilityDynamics {
17
- readonly before?: BeforeHooks<any>;
18
- readonly after?: AfterHooks<any>;
19
16
  readonly middleware?: StepMiddleware<any>;
20
17
  }
21
18
  export declare function assembleAgent(middleware: readonly BoundMiddleware[], identity: Readonly<{
@@ -38,7 +38,6 @@ export function assembleAgent(middleware, identity, dynamics = new Map()) {
38
38
  ...(item.contributions === undefined
39
39
  ? {}
40
40
  : { contributions: item.contributions }),
41
- ...(item.hooks === undefined ? {} : { hooks: item.hooks }),
42
41
  ...(item.manifestType === undefined
43
42
  ? {}
44
43
  : { manifestType: item.manifestType }),
@@ -48,13 +47,12 @@ export function assembleAgent(middleware, identity, dynamics = new Map()) {
48
47
  : { mcpServers: item.mcpServers }),
49
48
  ...(item.sandbox === undefined ? {} : { sandbox: item.sandbox }),
50
49
  ...(item.skills === undefined ? {} : { skills: item.skills }),
51
- ...(item.skillRecords === undefined
50
+ ...(item.skillFiles === undefined
52
51
  ? {}
53
- : { skillRecords: item.skillRecords }),
52
+ : { skillFiles: item.skillFiles }),
54
53
  ...(item.sessionTools === undefined
55
54
  ? {}
56
55
  : { sessionTools: item.sessionTools }),
57
- ...(item.pluginRoot === undefined ? {} : { pluginRoot: item.pluginRoot }),
58
56
  }));
59
57
  }
60
58
  }
@@ -127,21 +125,17 @@ function sandboxDiagnostics(items) {
127
125
  .filter((item) => item.sandbox !== undefined && item.id !== SANDBOX_CAPABILITY_ID)
128
126
  .map((item) => diagnostic("sandbox.in-definition", `Capability '${item.id}' declares a sandbox. Agents no longer declare one: open the session with it instead, createSession({ sandbox: { image, network: { allow }, resources } }), or set the Tenant's default sandbox.`));
129
127
  }
130
- const SKILL_TOOL_NAMES = new Set(["load_skill", "read_skill_resource"]);
128
+ /**
129
+ * Gives the first capability with skills `load_skill` (and `read_skill_resource`) for every skill
130
+ * of the agent. A tool of that name it already has is kept: an agent rebuilt from its manifest
131
+ * brings the hosted ones the Runtime serves.
132
+ */
131
133
  function attachSkillTools(items) {
132
134
  const skills = new Map();
133
135
  const diagnostics = [];
134
- const seen = new Set();
135
136
  let ownerId;
136
- for (const item of items) {
137
+ for (const item of items)
137
138
  for (const [key, skill] of Object.entries(item.skills ?? {})) {
138
- if (key !== skill.name || seen.has(skill.name)) {
139
- diagnostics.push(diagnostic("skill.duplicate-name", `Duplicate skill '${skill.name}' on capability '${item.id}'`));
140
- continue;
141
- }
142
- seen.add(skill.name);
143
- }
144
- for (const [key, skill] of Object.entries(item.skillRecords ?? {})) {
145
139
  if (key !== skill.name || skills.has(skill.name)) {
146
140
  diagnostics.push(diagnostic("skill.duplicate-name", `Duplicate skill '${skill.name}' on capability '${item.id}'`));
147
141
  continue;
@@ -149,17 +143,17 @@ function attachSkillTools(items) {
149
143
  skills.set(skill.name, skill);
150
144
  ownerId ??= item.id;
151
145
  }
152
- }
153
146
  if (diagnostics.length > 0 || ownerId === undefined)
154
147
  return { items: [...items], diagnostics };
155
148
  const skillTools = createSkillTools(skills);
156
149
  const next = items.map((item) => {
157
150
  if (item.id !== ownerId)
158
151
  return item;
159
- const tools = [
160
- ...(item.tools ?? []).filter((entry) => !SKILL_TOOL_NAMES.has(entry.name)),
161
- ...skillTools,
162
- ];
152
+ const declared = new Set((item.tools ?? []).map((entry) => entry.name));
153
+ const added = skillTools.filter((entry) => !declared.has(entry.name));
154
+ if (added.length === 0)
155
+ return item;
156
+ const tools = [...(item.tools ?? []), ...added];
163
157
  const advertised = [...tools, ...(item.sessionTools ?? [])];
164
158
  const handle = async (request, next) => item.handle(request, async () => {
165
159
  request.configuration.tools.set(item.id, advertised);
@@ -53,8 +53,6 @@ function buildImplementations(middleware, dynamics, snapshots) {
53
53
  ...(Object.keys(tools).length
54
54
  ? { tools: Object.freeze({ ...tools }) }
55
55
  : {}),
56
- ...(dyn?.before ? { before: Object.freeze({ ...dyn.before }) } : {}),
57
- ...(dyn?.after ? { after: Object.freeze({ ...dyn.after }) } : {}),
58
56
  ...(dyn?.middleware ? { middleware: dyn.middleware } : {}),
59
57
  });
60
58
  }
@@ -22,7 +22,6 @@ export function bindTool(item, owner) {
22
22
  execute: prepared.execute.bind(prepared),
23
23
  ...(prepared.approval === undefined ? {} : { approval: prepared.approval }),
24
24
  ...(prepared.effects === undefined ? {} : { effects: prepared.effects }),
25
- ...(prepared.background === undefined ? {} : { background: prepared.background }),
26
25
  owner: Object.freeze({ ...owner }),
27
26
  ...(delegate === undefined ? {} : { delegate }),
28
27
  });
@@ -1,9 +1,7 @@
1
1
  import type { JsonObject } from "../types/shared.js";
2
2
  import type { McpServerManifest, SandboxManifest, SkillManifest } from "../types/manifest.js";
3
- import type { SkillRecord } from "../types/middleware.js";
4
- import type { HookManifest } from "../types/dynamics.js";
5
3
  import type { Delegate } from "./delegate.js";
6
- import type { MiddlewareContributions, StepMiddleware } from "../types/middleware.js";
4
+ import type { MiddlewareContributions, SkillFileSource, StepMiddleware } from "../types/middleware.js";
7
5
  import type { ToolApproval, ToolDefinition, ToolEffects, ToolExecutionContext, ToolInputSchema, ToolOutputSchema, ToolOwner, ToolRunResult, ToolSchema } from "../types/tool.js";
8
6
  export interface BoundToolDefinition<Info = unknown> extends Omit<ToolDefinition<ToolInputSchema, Info, ToolOutputSchema | undefined>, "inputSchema" | "outputSchema" | "execute" | "run" | "input" | "output"> {
9
7
  readonly inputSchema: ToolSchema<unknown>;
@@ -11,8 +9,6 @@ export interface BoundToolDefinition<Info = unknown> extends Omit<ToolDefinition
11
9
  readonly execute: (args: unknown, context: ToolExecutionContext<Info>) => Promise<ToolRunResult>;
12
10
  readonly approval?: ToolApproval<ToolInputSchema>;
13
11
  readonly effects?: ToolEffects;
14
- /** Runs in the background when an Action endpoint serves it (`ToolDefinition.background`). */
15
- readonly background?: boolean;
16
12
  readonly owner: ToolOwner;
17
13
  readonly source: ToolDefinition<any, any, any>;
18
14
  /** Set when this tool is an agent used as a tool; the engine runs it. */
@@ -28,14 +24,11 @@ export interface BoundMiddleware {
28
24
  /** Execution-only tools. Advertised for this run and omitted from the manifest. */
29
25
  readonly sessionTools?: readonly ToolDefinition<any, any, any>[];
30
26
  readonly contributions?: MiddlewareContributions;
31
- /** Registered hook points, in canonical order. */
32
- readonly hooks?: readonly HookManifest[];
33
27
  readonly manifestType?: "agent" | "agent-plugin";
34
28
  readonly metadata?: JsonObject;
35
29
  readonly skills?: Readonly<Record<string, SkillManifest>>;
36
- readonly skillRecords?: Readonly<Record<string, SkillRecord>>;
30
+ /** Each skill file's bytes, by `sha256:<hex>`. Not a manifest field. */
31
+ readonly skillFiles?: Readonly<Record<string, SkillFileSource>>;
37
32
  readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
38
33
  readonly sandbox?: SandboxManifest;
39
- /** Package directory for a plugin capability. Not a manifest field. */
40
- readonly pluginRoot?: string;
41
34
  }
@@ -6,14 +6,13 @@ import type { ToolDefinition, ToolSchemaSource, SchemaOutput } from "../types/to
6
6
  import type { AgentTool, BuiltAgent } from "../types/agent.js";
7
7
  import type { AgentManifest, McpServerManifest } from "../types/manifest.js";
8
8
  import type { WorkflowBinding, WorkflowManifest } from "../types/workflow.js";
9
- import type { AfterHook, BeforeHook, HookScope } from "../types/dynamics.js";
10
9
  import type { Implementations } from "./implementations.js";
11
10
  import { type CapabilityDynamics } from "./assemble.js";
12
11
  import { type McpServerSpec } from "./mcp.js";
13
12
  import { type FlowImplementations } from "./flow/from.js";
14
- import { type BuiltWorkflow } from "./workflow/types.js";
13
+ import type { BuiltWorkflow } from "./workflow/types.js";
15
14
  import { type FlowStage } from "./flow/spec.js";
16
- import type { AddResult, BranchesOut, CaseKey, CasesOut, FlowAgentBuilder, FlowOut, IdOf, LoopChoice, LoopDecideArgs, LoopVerifyFn, Named, StageArgs } from "./flow/types.js";
15
+ import type { BranchesOut, CasesOut, FlowAgentBuilder, FlowOut, LoopOptions, Named, PipeOut, StageOptions } from "./flow/types.js";
17
16
  export interface AgentOptions<Schema extends ToolSchemaSource | undefined = undefined> {
18
17
  /** @deprecated Use `.output(schema)`. */
19
18
  readonly outputSchema?: Schema;
@@ -58,15 +57,15 @@ export declare function Agent<Info = unknown, Schema extends ToolSchemaSource |
58
57
  readonly id: Id;
59
58
  }): AgentBuilder<Info, Schema, Id>;
60
59
  export declare namespace Agent {
61
- /** Rebuild a flow agent from its workflow manifest v2 and the code its stage keys name. */
62
- function from(json: import("../types/workflow.js").WorkflowManifestV2, implementations?: FlowImplementations): BuiltWorkflow;
60
+ /** Rebuild a flow agent from its workflow manifest v3 and the tools its tool nodes name. */
61
+ function from(json: WorkflowManifest, implementations?: FlowImplementations): BuiltWorkflow;
63
62
  /** Rebuild an agent from its manifest and the code its capabilities name. */
64
63
  function from<Info = unknown>(json: AgentManifest | import("../types/shared.js").JsonObject, implementations: Implementations<Info>): BuiltAgent<Info>;
65
64
  }
66
65
  declare const SNAPSHOT: unique symbol;
67
66
  type SchemaOut<Schema> = Schema extends ToolSchemaSource ? SchemaOutput<Schema> : never;
68
67
  type ReactOutput<Schema> = Schema extends ToolSchemaSource ? SchemaOutput<Schema> : string;
69
- type StartFlow<Info, Schema, Id extends string, Cur, Results> = FlowAgentBuilder<Info, any, Cur, Results, SchemaOut<Schema>, Id>;
68
+ type StartFlow<Info, Schema, Id extends string, Cur> = FlowAgentBuilder<Info, any, Cur, SchemaOut<Schema>, Id>;
70
69
  export declare class AgentBuilder<Info = unknown, Schema extends ToolSchemaSource | undefined = undefined, Id extends string = string> {
71
70
  #private;
72
71
  /** Phantom carriers for flow typing (never set at runtime). */
@@ -101,14 +100,6 @@ export declare class AgentBuilder<Info = unknown, Schema extends ToolSchemaSourc
101
100
  capability(bundle: CapabilityInput<Info> | {
102
101
  toDeclaration(): CapabilityInput<Info>;
103
102
  }): this;
104
- /** Run `fn` before each turn. */
105
- beforeTurn(fn: BeforeHook<"turn", Info>): this;
106
- /** Run `fn` before every model call. */
107
- beforeModel(fn: BeforeHook<"step", Info>): this;
108
- /** Run `fn` after every model call. */
109
- afterModel(fn: AfterHook<"step", Info>): this;
110
- /** Run `fn` after the turn's final answer. */
111
- afterTurn(fn: AfterHook<"turn", Info>): this;
112
103
  /** The structured output. Set once. */
113
104
  output<S extends ToolSchemaSource>(schema: S): AgentBuilder<Info, S, Id>;
114
105
  /** @deprecated Use `.capability()`, `.mcp()`, `.skills()` or `.plugin()`. */
@@ -117,46 +108,20 @@ export declare class AgentBuilder<Info = unknown, Schema extends ToolSchemaSourc
117
108
  use(id: string, middleware: StepMiddleware<Info>): this;
118
109
  /** @deprecated Use `.capability()`, `.mcp()`, `.skills()` or `.plugin()`. */
119
110
  use(declaration: CapabilityInput<Info>): this;
120
- /**
121
- * @deprecated Use `.beforeTurn()` or `.beforeModel()`.
122
- * Run `fn` before each turn (`"turn"`) or before every model call (`"step"`).
123
- */
124
- before<S extends HookScope>(scope: S, fn: BeforeHook<S, Info>): this;
125
- /**
126
- * @deprecated Use `.afterModel()` or `.afterTurn()`.
127
- * Run `fn` after every model call (`"step"`) or after the turn's final answer (`"turn"`).
128
- */
129
- after<S extends HookScope>(scope: S, fn: AfterHook<S, Info>): this;
130
111
  /** The flow agent's input. Set once. */
131
- input<S extends ToolSchemaSource>(schema: S): FlowAgentBuilder<Info, SchemaOutput<S>, SchemaOutput<S>, {}, SchemaOut<Schema>, Id>;
132
- step<C, const StepId extends string = IdOf<C>>(child: C, options?: {
133
- readonly id?: StepId;
134
- readonly input?: (args: StageArgs<any, {}, any>) => unknown;
135
- }): StartFlow<Info, Schema, Id, FlowOut<C>, AddResult<{}, StepId, FlowOut<C>>>;
136
- switch<const Cases extends Readonly<Record<string, unknown>>, T, const StageId extends string = string>(cases: Cases, options: {
137
- readonly input: (args: StageArgs<any, {}, any>) => T;
138
- readonly on: (args: StageArgs<T, {}, any>) => CaseKey<Cases>;
139
- readonly id?: StageId;
140
- }): StartFlow<Info, Schema, Id, CasesOut<Cases>, AddResult<{}, StageId, CasesOut<Cases>>>;
141
- switch<const Cases extends Readonly<Record<string, unknown>>, const StageId extends string = string>(cases: Cases, options: {
142
- readonly on: (args: StageArgs<any, {}, any>) => CaseKey<Cases>;
143
- readonly id?: StageId;
144
- }): StartFlow<Info, Schema, Id, CasesOut<Cases>, AddResult<{}, StageId, CasesOut<Cases>>>;
145
- parallel<const Branches extends Readonly<Record<string, unknown>>, const StageId extends string = string>(branches: Branches, options?: {
146
- readonly id?: StageId;
147
- readonly input?: (args: StageArgs<any, {}, any>) => unknown;
148
- }): StartFlow<Info, Schema, Id, BranchesOut<Branches>, AddResult<{}, StageId, BranchesOut<Branches>>>;
149
- map<E, const StageId extends string = string>(each: E, options?: {
150
- readonly id?: StageId;
151
- readonly input?: (args: StageArgs<any, {}, any>) => readonly unknown[];
152
- }): StartFlow<Info, Schema, Id, FlowOut<E>[], AddResult<{}, StageId, FlowOut<E>[]>>;
153
- loop<B, const StageId extends string = string>(body: B, options: {
154
- readonly verify: LoopVerifyFn<any, FlowOut<B>> | object;
155
- readonly max?: number;
156
- readonly decide?: (args: LoopDecideArgs<any, FlowOut<B>>) => LoopChoice<FlowOut<B>>;
157
- readonly id?: StageId;
158
- readonly input?: (args: StageArgs<any, {}, any>) => unknown;
159
- }): StartFlow<Info, Schema, Id, FlowOut<B>, AddResult<{}, StageId, FlowOut<B>>>;
112
+ input<S extends ToolSchemaSource>(schema: S): FlowAgentBuilder<Info, SchemaOutput<S>, SchemaOutput<S>, SchemaOut<Schema>, Id>;
113
+ /** Add stages in order: the first gets the flow's input, each later one the previous output. */
114
+ pipe<const Children extends readonly unknown[]>(...children: Children): StartFlow<Info, Schema, Id, PipeOut<Children, any>>;
115
+ /** @deprecated Use `.pipe()`, and `.withId()` to rename a child. */
116
+ step<C>(child: C, options?: StageOptions): StartFlow<Info, Schema, Id, FlowOut<C>>;
117
+ /** Run one case, picked by the previous output: a string, or its `route` field. */
118
+ switch<const Cases extends Readonly<Record<string, unknown>>>(cases: Cases, options?: StageOptions): StartFlow<Info, Schema, Id, CasesOut<Cases>>;
119
+ /** Run every branch on the same input; the output is keyed by branch. */
120
+ parallel<const Branches extends Readonly<Record<string, unknown>>>(branches: Branches, options?: StageOptions): StartFlow<Info, Schema, Id, BranchesOut<Branches>>;
121
+ /** Run `each` once per item of the previous output: an array, or its `items` field. */
122
+ map<E>(each: E, options?: StageOptions): StartFlow<Info, Schema, Id, FlowOut<E>[]>;
123
+ /** Run `body` until the verifier agent passes it, at most `max` times. */
124
+ loop<B>(body: B, options: LoopOptions): StartFlow<Info, Schema, Id, FlowOut<B>>;
160
125
  /** Give this agent a new step id where there is no options object. */
161
126
  withId(id: string): Named<this>;
162
127
  /** Optional no-op: returns the assembled agent facade (a workflow for flow agents). */
@@ -164,11 +129,10 @@ export declare class AgentBuilder<Info = unknown, Schema extends ToolSchemaSourc
164
129
  private ensure;
165
130
  /** Record which body a method belongs to; mixing bodies is a build error. */
166
131
  private bodyFor;
167
- private addStage;
132
+ private addStages;
168
133
  private withAgentItems;
169
134
  private addDeclaration;
170
135
  private appendCompiled;
171
- private addAgentHook;
172
136
  }
173
137
  export type { Implementations };
174
138
  export type { WorkflowBinding, WorkflowManifest };
@@ -2,15 +2,13 @@ import { HarnessError } from "../errors.js";
2
2
  import { assembleAgent } from "./assemble.js";
3
3
  import { compileDeclaration } from "./declaration.js";
4
4
  import { agentFrom } from "./from.js";
5
- import { hooksFrom } from "./hooks.js";
6
5
  import { isAgentItem } from "./delegate.js";
7
6
  import { normalizeMcpServers } from "./mcp.js";
8
7
  import { deprecate } from "../utils/deprecate.js";
9
8
  import { WorkflowBuildError } from "./workflow/diagnostics.js";
10
9
  import { flowFrom } from "./flow/from.js";
11
- import { isBuiltWorkflow } from "./workflow/types.js";
12
10
  import { compileAgentFlow } from "./flow/compile.js";
13
- import { loopStage, mapStage, named, parallelStage, stepStage, switchStage, } from "./flow/spec.js";
11
+ import { loopStage, mapStage, named, parallelStage, pipeStages, stepStage, switchStage, } from "./flow/spec.js";
14
12
  import { isCapabilityBuilder } from "./capability.js";
15
13
  export class AgentBuildError extends HarnessError {
16
14
  diagnostics;
@@ -135,22 +133,6 @@ export class AgentBuilder {
135
133
  : bundle;
136
134
  return this.addDeclaration(declaration, "capability()");
137
135
  }
138
- /** Run `fn` before each turn. */
139
- beforeTurn(fn) {
140
- return this.addAgentHook("before", "turn", fn);
141
- }
142
- /** Run `fn` before every model call. */
143
- beforeModel(fn) {
144
- return this.addAgentHook("before", "step", fn);
145
- }
146
- /** Run `fn` after every model call. */
147
- afterModel(fn) {
148
- return this.addAgentHook("after", "step", fn);
149
- }
150
- /** Run `fn` after the turn's final answer. */
151
- afterTurn(fn) {
152
- return this.addAgentHook("after", "turn", fn);
153
- }
154
136
  /** The structured output. Set once. */
155
137
  output(schema) {
156
138
  const snapshot = this.#snapshot;
@@ -193,23 +175,7 @@ export class AgentBuilder {
193
175
  }
194
176
  return this.appendCompiled(compiled, body);
195
177
  }
196
- /**
197
- * @deprecated Use `.beforeTurn()` or `.beforeModel()`.
198
- * Run `fn` before each turn (`"turn"`) or before every model call (`"step"`).
199
- */
200
- before(scope, fn) {
201
- deprecate("NYLORUN_DEP_HOOKS", '.before()/.after() are deprecated. Use .beforeTurn(), .beforeModel(), .afterModel() or .afterTurn().');
202
- return this.addAgentHook("before", scope, fn);
203
- }
204
- /**
205
- * @deprecated Use `.afterModel()` or `.afterTurn()`.
206
- * Run `fn` after every model call (`"step"`) or after the turn's final answer (`"turn"`).
207
- */
208
- after(scope, fn) {
209
- deprecate("NYLORUN_DEP_HOOKS", '.before()/.after() are deprecated. Use .beforeTurn(), .beforeModel(), .afterModel() or .afterTurn().');
210
- return this.addAgentHook("after", scope, fn);
211
- }
212
- // ── Flow: code decides ─────────────────────────────────────────────────────
178
+ // ── Flow: the manifest decides ─────────────────────────────────────────────
213
179
  /** The flow agent's input. Set once. */
214
180
  input(schema) {
215
181
  const snapshot = this.#snapshot;
@@ -222,20 +188,23 @@ export class AgentBuilder {
222
188
  });
223
189
  return this.spawn({ ...snapshot, ...body, inputSchema: schema });
224
190
  }
191
+ pipe(...children) {
192
+ return this.addStages(pipeStages(children), "pipe()");
193
+ }
225
194
  step(child, options) {
226
- return this.addStage(stepStage(child, options), "step()");
195
+ return this.addStages([stepStage(child, options)], "step()");
227
196
  }
228
197
  switch(cases, options) {
229
- return this.addStage(switchStage(cases, options), "switch()");
198
+ return this.addStages([switchStage(cases, options)], "switch()");
230
199
  }
231
200
  parallel(branches, options) {
232
- return this.addStage(parallelStage(branches, options), "parallel()");
201
+ return this.addStages([parallelStage(branches, options)], "parallel()");
233
202
  }
234
203
  map(each, options) {
235
- return this.addStage(mapStage(each, options), "map()");
204
+ return this.addStages([mapStage(each, options)], "map()");
236
205
  }
237
206
  loop(body, options) {
238
- return this.addStage(loopStage(body, options), "loop()");
207
+ return this.addStages([loopStage(body, options)], "loop()");
239
208
  }
240
209
  /** Give this agent a new step id where there is no options object. */
241
210
  withId(id) {
@@ -302,46 +271,38 @@ export class AgentBuilder {
302
271
  const diagnostic = kind === "react"
303
272
  ? Object.freeze({
304
273
  code: "flow.no-model",
305
- message: `'${snapshot.id}' is a flow agent, which runs no model. Move .${method} to an agent passed to .step().`,
274
+ message: `'${snapshot.id}' is a flow agent, which runs no model. Move .${method} to an agent passed to .pipe().`,
306
275
  })
307
276
  : Object.freeze({
308
277
  code: "agent.mixed-body",
309
- message: `'${snapshot.id}' is a ReAct agent. An agent is either a ReAct loop or a flow: put the ReAct part in its own Agent and add it with .step().`,
278
+ message: `'${snapshot.id}' is a ReAct agent. An agent is either a ReAct loop or a flow: put the ReAct part in its own Agent and add it with .pipe().`,
310
279
  });
311
280
  return { body: snapshot.body, diagnostics: addDiagnostics(snapshot.diagnostics, [diagnostic]) };
312
281
  }
313
- addStage(stage, method) {
282
+ addStages(stages, method) {
314
283
  const snapshot = this.#snapshot;
315
284
  const body = this.bodyFor("flow", method);
316
- return this.spawn({ ...snapshot, ...body, stages: Object.freeze([...snapshot.stages, stage]) });
285
+ return this.spawn({ ...snapshot, ...body, stages: Object.freeze([...snapshot.stages, ...stages]) });
317
286
  }
318
287
  withAgentItems(method, items) {
319
288
  const snapshot = this.#snapshot;
320
289
  const body = this.bodyFor("react", method);
321
- const flows = (items.tools ?? []).filter((item) => isFlowItem(item));
322
290
  const part = {
323
291
  ...(snapshot.agentPart?.instructions !== undefined || items.instructions !== undefined
324
292
  ? { instructions: Object.freeze([...(snapshot.agentPart?.instructions ?? []), ...(items.instructions ?? [])]) }
325
293
  : {}),
326
294
  ...(snapshot.agentPart?.tools !== undefined || items.tools !== undefined
327
- ? { tools: Object.freeze([...(snapshot.agentPart?.tools ?? []), ...(items.tools ?? []).filter((item) => !isFlowItem(item))]) }
295
+ ? { tools: Object.freeze([...(snapshot.agentPart?.tools ?? []), ...(items.tools ?? [])]) }
328
296
  : {}),
329
297
  };
330
- const diagnostics = flows.map((item) => Object.freeze({
331
- code: "delegation.flow-unsupported",
332
- message: `'${item.id ?? "workflow"}' was built with Chain, Switch, Parallel, Map or Loop and cannot be a subagent. Write it as a flow agent, Agent({ id }).step(…), which can.`,
333
- }));
334
298
  const compiled = compileDeclaration({ id: "agent", ...part });
335
- const dynamics = snapshot.dynamics.get("agent") ?? {};
336
- const hooks = hooksFrom(dynamics.before, dynamics.after);
337
- const bound = hooks === undefined ? compiled.bound : Object.freeze({ ...compiled.bound, hooks });
338
299
  return this.spawn({
339
300
  ...snapshot,
340
301
  ...body,
341
302
  agentPart: Object.freeze(part),
342
- entries: replaceOrAppend(snapshot.entries, bound),
343
- dynamics: withDynamics(snapshot.dynamics, "agent", dynamics),
344
- diagnostics: addDiagnostics(body.diagnostics ?? snapshot.diagnostics, diagnostics),
303
+ entries: replaceOrAppend(snapshot.entries, compiled.bound),
304
+ dynamics: withDynamics(snapshot.dynamics, "agent", snapshot.dynamics.get("agent") ?? {}),
305
+ ...(body.diagnostics === undefined ? {} : { diagnostics: body.diagnostics }),
345
306
  });
346
307
  }
347
308
  addDeclaration(declaration, method) {
@@ -351,11 +312,7 @@ export class AgentBuilder {
351
312
  appendCompiled(compiled, body) {
352
313
  const snapshot = this.#snapshot;
353
314
  const dynamics = new Map(snapshot.dynamics);
354
- dynamics.set(compiled.bound.id, {
355
- ...(compiled.before ? { before: compiled.before } : {}),
356
- ...(compiled.after ? { after: compiled.after } : {}),
357
- ...(compiled.middleware ? { middleware: compiled.middleware } : {}),
358
- });
315
+ dynamics.set(compiled.bound.id, compiled.middleware ? { middleware: compiled.middleware } : {});
359
316
  return this.spawn({
360
317
  ...snapshot,
361
318
  ...body,
@@ -363,39 +320,6 @@ export class AgentBuilder {
363
320
  dynamics,
364
321
  });
365
322
  }
366
- addAgentHook(at, scope, fn) {
367
- if (typeof fn !== "function")
368
- throw new HarnessError("configuration.invalid", `${at}("${scope}") requires a function`);
369
- if (scope !== "turn" && scope !== "step")
370
- throw new HarnessError("configuration.invalid", `Unknown hook scope '${String(scope)}'; use "turn" or "step"`);
371
- const snapshot = this.#snapshot;
372
- const body = this.bodyFor("react", hookMethod(at, scope));
373
- const dynamics = new Map(snapshot.dynamics);
374
- const existing = dynamics.get("agent") ?? {};
375
- const current = existing[at];
376
- if (current?.[scope] !== undefined)
377
- return this.spawn({
378
- ...snapshot,
379
- ...body,
380
- diagnostics: addDiagnostics(body.diagnostics ?? snapshot.diagnostics, [
381
- Object.freeze({
382
- code: "hook.duplicate",
383
- message: `Agent hook ${at}("${scope}") is registered more than once`,
384
- }),
385
- ]),
386
- });
387
- const next = {
388
- ...existing,
389
- [at]: Object.freeze({ ...current, [scope]: fn }),
390
- };
391
- dynamics.set("agent", next);
392
- return this.spawn({
393
- ...snapshot,
394
- ...body,
395
- entries: withAgentHooks(snapshot.entries, next),
396
- dynamics,
397
- });
398
- }
399
323
  }
400
324
  function createSnapshot(options) {
401
325
  const entries = [];
@@ -438,9 +362,6 @@ function createSnapshot(options) {
438
362
  stages: Object.freeze([]),
439
363
  };
440
364
  }
441
- function hookMethod(at, scope) {
442
- return `${at}${scope === "turn" ? "Turn" : "Model"}()`;
443
- }
444
365
  function singleValue(id, what) {
445
366
  return Object.freeze({
446
367
  code: "agent.single-value",
@@ -464,15 +385,6 @@ function replaceOrAppend(entries, bound) {
464
385
  return Object.freeze([...entries, bound]);
465
386
  return Object.freeze([...entries.slice(0, index), bound, ...entries.slice(index + 1)]);
466
387
  }
467
- /**
468
- * A workflow built with the v1 primitives, placed where a subagent is expected. Flow
469
- * agents are subagents like any agent: they run in their own linked session.
470
- */
471
- function isFlowItem(value) {
472
- if (!value || typeof value !== "object" || value instanceof AgentBuilder)
473
- return false;
474
- return isBuiltWorkflow(value) && value.manifest.workflowSchemaVersion === 1;
475
- }
476
388
  function nextMiddlewareId(entries) {
477
389
  const taken = new Set(entries.map((item) => item.id));
478
390
  let seq = 0;
@@ -483,26 +395,3 @@ function nextMiddlewareId(entries) {
483
395
  } while (taken.has(id));
484
396
  return id;
485
397
  }
486
- /** Record the agent-level hooks on the synthetic `"agent"` capability, creating it if needed. */
487
- function withAgentHooks(entries, dynamics) {
488
- const hooks = hooksFrom(dynamics.before, dynamics.after);
489
- const index = entries.findIndex((item) => item.id === "agent");
490
- if (index >= 0) {
491
- const next = Object.freeze({ ...entries[index], hooks });
492
- return Object.freeze([
493
- ...entries.slice(0, index),
494
- next,
495
- ...entries.slice(index + 1),
496
- ]);
497
- }
498
- return Object.freeze([
499
- ...entries,
500
- Object.freeze({
501
- id: "agent",
502
- handle: async (_request, next) => next(),
503
- hasMiddleware: false,
504
- contributions: Object.freeze({}),
505
- hooks,
506
- }),
507
- ]);
508
- }