@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
@@ -1,11 +1,12 @@
1
1
  import { bindOutputContract } from "./output-contract.js";
2
2
  import { normalizedSchemasFor } from "./schema.js";
3
3
  import { delegateOf } from "./delegate.js";
4
+ import { httpToolOf } from "./http-tool.js";
4
5
  import { copyJsonObject, deepFreeze } from "../utils/immutable.js";
5
6
  export function createManifest(input) {
6
7
  const capabilities = input.middleware.map((item) => projectCapability(item));
7
8
  return deepFreeze({
8
- manifestSchemaVersion: 4,
9
+ manifestSchemaVersion: 5,
9
10
  id: input.id,
10
11
  ...(input.name === undefined ? {} : { name: input.name }),
11
12
  ...(input.description === undefined
@@ -45,14 +46,12 @@ function projectCapability(item) {
45
46
  ...(item.sandbox === undefined
46
47
  ? {}
47
48
  : { sandbox: copyJsonObject(item.sandbox, "sandbox") }),
48
- ...(item.hooks === undefined
49
- ? {}
50
- : { hooks: item.hooks.map((hook) => ({ at: hook.at, scope: hook.scope })) }),
51
49
  };
52
50
  }
53
51
  function projectTool(tool) {
54
52
  const schemas = normalizedSchemasFor(tool);
55
53
  const delegate = delegateOf(tool);
54
+ const http = httpToolOf(tool);
56
55
  return {
57
56
  name: tool.name,
58
57
  ...(tool.description === undefined
@@ -63,5 +62,7 @@ function projectTool(tool) {
63
62
  ? {}
64
63
  : { outputSchema: schemas.outputSchema.jsonSchema }),
65
64
  ...(delegate === undefined ? {} : { agent: delegate.manifest }),
65
+ ...(http === undefined ? {} : { http: { ...http.http } }),
66
+ ...(http?.approval === undefined ? {} : { approval: http.approval }),
66
67
  };
67
68
  }
@@ -22,8 +22,8 @@ export declare class McpError extends Error {
22
22
  * Declare MCP servers as one capability.
23
23
  *
24
24
  * Prefer `Agent(...).mcp({ ... })`. Each key names a server; its `name` defaults to
25
- * the key and, when given, must equal it. Supported transports are `stdio`,
26
- * `streamable-http`, and `sse` (see https://agent-plugins.org/plugin-authors/mcp-servers).
25
+ * the key and, when given, must equal it. Nylorun accepts remote servers only:
26
+ * `streamable-http` and `sse` (see https://agent-plugins.org/plugin-authors/mcp-servers).
27
27
  *
28
28
  * ```ts
29
29
  * Agent({ id: "assistant" }).mcp({
@@ -32,6 +32,8 @@ export declare class McpError extends Error {
32
32
  * ```
33
33
  */
34
34
  export declare function mcp(servers: Readonly<Record<string, McpServerSpec>>, options?: McpOptions): McpCapability;
35
+ /** Why a `stdio` MCP server is refused: the one message the builder, plugins and manifests give. */
36
+ export declare function stdioMcpRefusal(name: string): string;
35
37
  /** Validate a map of MCP servers and fill each `name` from its key. */
36
38
  export declare function normalizeMcpServers(servers: Readonly<Record<string, McpServerSpec>>, caller?: string): Readonly<Record<string, McpServerManifest>>;
37
39
  export {};
@@ -1,3 +1,4 @@
1
+ import { APPROVAL_MODES } from "./http-tool.js";
1
2
  export class McpError extends Error {
2
3
  code;
3
4
  constructor(code, message) {
@@ -10,8 +11,8 @@ export class McpError extends Error {
10
11
  * Declare MCP servers as one capability.
11
12
  *
12
13
  * Prefer `Agent(...).mcp({ ... })`. Each key names a server; its `name` defaults to
13
- * the key and, when given, must equal it. Supported transports are `stdio`,
14
- * `streamable-http`, and `sse` (see https://agent-plugins.org/plugin-authors/mcp-servers).
14
+ * the key and, when given, must equal it. Nylorun accepts remote servers only:
15
+ * `streamable-http` and `sse` (see https://agent-plugins.org/plugin-authors/mcp-servers).
15
16
  *
16
17
  * ```ts
17
18
  * Agent({ id: "assistant" }).mcp({
@@ -23,6 +24,10 @@ export function mcp(servers, options = {}) {
23
24
  const id = options.id ?? "mcp";
24
25
  return { id, mcpServers: normalizeMcpServers(servers, "mcp()") };
25
26
  }
27
+ /** Why a `stdio` MCP server is refused: the one message the builder, plugins and manifests give. */
28
+ export function stdioMcpRefusal(name) {
29
+ return `MCP server '${name}' uses stdio; Nylorun accepts remote MCP servers only (streamable-http or sse). Run the server behind an HTTP transport and declare its URL.`;
30
+ }
26
31
  /** Validate a map of MCP servers and fill each `name` from its key. */
27
32
  export function normalizeMcpServers(servers, caller = "mcp()") {
28
33
  if (!isRecord(servers)) {
@@ -35,8 +40,10 @@ export function normalizeMcpServers(servers, caller = "mcp()") {
35
40
  const mcpServers = {};
36
41
  for (const [key, spec] of entries) {
37
42
  const server = isRecord(spec) && spec.name === undefined ? { ...spec, name: key } : spec;
43
+ if (isRecord(server) && server.type === "stdio")
44
+ throw new McpError("mcp.stdio", stdioMcpRefusal(key));
38
45
  if (!isMcpServer(server)) {
39
- throw new McpError("mcp.invalid-server", `MCP server '${key}' is not a valid stdio, streamable-http, or sse declaration`);
46
+ throw new McpError("mcp.invalid-server", `MCP server '${key}' is not a valid streamable-http or sse declaration`);
40
47
  }
41
48
  if (server.name !== key) {
42
49
  throw new McpError("mcp.name-mismatch", `MCP server key '${key}' must equal the server name '${server.name}'`);
@@ -46,18 +53,6 @@ export function normalizeMcpServers(servers, caller = "mcp()") {
46
53
  return Object.freeze(mcpServers);
47
54
  }
48
55
  function freezeServer(server) {
49
- if (server.type === "stdio") {
50
- return Object.freeze({
51
- name: server.name,
52
- type: "stdio",
53
- command: server.command,
54
- ...(server.args === undefined ? {} : { args: Object.freeze([...server.args]) }),
55
- ...(server.env === undefined
56
- ? {}
57
- : { env: Object.freeze({ ...server.env }) }),
58
- ...(server.cwd === undefined ? {} : { cwd: server.cwd }),
59
- });
60
- }
61
56
  return Object.freeze({
62
57
  name: server.name,
63
58
  type: server.type,
@@ -65,15 +60,16 @@ function freezeServer(server) {
65
60
  ...(server.headers === undefined
66
61
  ? {}
67
62
  : { headers: Object.freeze({ ...server.headers }) }),
63
+ ...(server.approval === undefined ? {} : { approval: server.approval }),
68
64
  });
69
65
  }
70
66
  function isMcpServer(value) {
71
67
  if (!isRecord(value) || typeof value.name !== "string" || !value.name)
72
68
  return false;
73
- if (value.type === "stdio")
74
- return typeof value.command === "string" && value.command.length > 0;
75
69
  if (value.type === "streamable-http" || value.type === "sse")
76
- return typeof value.url === "string" && value.url.length > 0;
70
+ return (typeof value.url === "string" &&
71
+ value.url.length > 0 &&
72
+ (value.approval === undefined || APPROVAL_MODES.includes(value.approval)));
77
73
  return false;
78
74
  }
79
75
  function isRecord(value) {
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Manifest fields that manifest v5 removed, and what replaces each. Manifest v5 (with workflow
3
+ * manifest v3 for flow agents) is the first where the Runtime never calls the developer's code
4
+ * during a session (see MIGRATION.md).
5
+ */
6
+ export declare const REMOVED_CAPABILITY_FIELDS: Readonly<Record<string, string>>;
7
+ /** Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 5. */
8
+ export declare function manifestVersionIssue(version: unknown): string | undefined;
9
+ /** Why a workflow manifest with this `workflowSchemaVersion` is refused, or undefined for version 3. */
10
+ export declare function workflowVersionIssue(version: unknown): string | undefined;
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Manifest fields that manifest v5 removed, and what replaces each. Manifest v5 (with workflow
3
+ * manifest v3 for flow agents) is the first where the Runtime never calls the developer's code
4
+ * during a session (see MIGRATION.md).
5
+ */
6
+ export const REMOVED_CAPABILITY_FIELDS = Object.freeze({
7
+ hooks: "hooks were removed: the Runtime no longer calls your code during a session. Use an HTTP tool, approval on a tool, or a loop verifier instead (see MIGRATION.md)",
8
+ beforeModelCall: "beforeModelCall was removed with hooks (see MIGRATION.md)",
9
+ afterModelCall: "afterModelCall was removed with hooks (see MIGRATION.md)",
10
+ });
11
+ /** Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 5. */
12
+ export function manifestVersionIssue(version) {
13
+ if (version === 5)
14
+ return undefined;
15
+ if (version === 4 || version === 3)
16
+ return `manifestSchemaVersion ${version} is no longer supported: manifest v5 removed hooks. Rebuild the agent with the current SDK (see MIGRATION.md)`;
17
+ return `Unsupported manifestSchemaVersion ${String(version)}`;
18
+ }
19
+ /** Why a workflow manifest with this `workflowSchemaVersion` is refused, or undefined for version 3. */
20
+ export function workflowVersionIssue(version) {
21
+ if (version === 3)
22
+ return undefined;
23
+ if (version === 2 || version === 1)
24
+ return `workflowSchemaVersion ${version} is no longer supported: flows run no code since manifest v5 (no input, on, verify or decide functions). Rebuild the flow with the current SDK (see MIGRATION.md)`;
25
+ return `Unsupported workflowSchemaVersion ${String(version)}`;
26
+ }
@@ -22,4 +22,6 @@ export declare function artifactsCapabilityManifest(): CapabilityManifest;
22
22
  export declare function sandboxCapabilityManifest(spec: SandboxManifest, options?: {
23
23
  /** The workspace path the backend uses, named in the tools' text. Default `/workspace`. */
24
24
  readonly workspace?: string;
25
+ /** The agent's skills, whose files the sandbox holds under `/skills/<name>/`. */
26
+ readonly skills?: readonly string[];
25
27
  }): CapabilityManifest;
@@ -3,6 +3,7 @@ import { SANDBOX_INSTRUCTIONS, createSandboxTools } from "./sandbox-tools.js";
3
3
  import { tool } from "./helpers.js";
4
4
  import { ToolError } from "./tool-error.js";
5
5
  import { SANDBOX_WORKSPACE } from "../utils/sandbox.js";
6
+ import { SKILLS_MOUNT } from "../utils/definition-files.js";
6
7
  import { normalizedSchemasFor } from "./schema.js";
7
8
  import { copyJsonObject } from "../utils/immutable.js";
8
9
  /** Id of the capability the Runtime adds to a session whose sandbox was chosen at open. */
@@ -85,7 +86,16 @@ export function sandboxCapabilityManifest(spec, options = {}) {
85
86
  return {
86
87
  id: SANDBOX_CAPABILITY_ID,
87
88
  type: "agent",
88
- instructions: [text(SANDBOX_INSTRUCTIONS)],
89
+ instructions: [
90
+ text(SANDBOX_INSTRUCTIONS),
91
+ ...(options.skills?.length
92
+ ? [
93
+ `Each skill's files are in the sandbox, read-only, under ${SKILLS_MOUNT}/<name>/ (${options.skills
94
+ .map((name) => `${SKILLS_MOUNT}/${name}/`)
95
+ .join(", ")}): read them there and run their scripts with bash.`,
96
+ ]
97
+ : []),
98
+ ],
89
99
  tools,
90
100
  sandbox: copyJsonObject(spec, "sandbox"),
91
101
  };
@@ -49,9 +49,6 @@ export function normalizeToolDefinition(definition) {
49
49
  ...(definition.effects === undefined
50
50
  ? {}
51
51
  : { effects: definition.effects }),
52
- ...(definition.background === undefined
53
- ? {}
54
- : { background: definition.background }),
55
52
  };
56
53
  }
57
54
  /** Returns cached normalized contracts, preparing raw definitions on first bind. */
@@ -1,3 +1,17 @@
1
- import type { SkillRecord } from "../types/middleware.js";
1
+ import type { CapabilityManifest, SkillManifest } from "../types/manifest.js";
2
2
  import type { ToolDefinition } from "../types/tool.js";
3
- export declare function createSkillTools(skills: ReadonlyMap<string, SkillRecord>): readonly ToolDefinition[];
3
+ export declare const LOAD_SKILL_TOOL = "load_skill";
4
+ export declare const READ_SKILL_RESOURCE_TOOL = "read_skill_resource";
5
+ export declare const SKILL_TOOL_NAMES: ReadonlySet<string>;
6
+ /**
7
+ * Whether `toolName` is a skill tool the Runtime serves: `load_skill` or `read_skill_resource`
8
+ * declared by a capability that has skills (the first one, where the build attaches them). A
9
+ * tool of that name elsewhere is the author's own.
10
+ */
11
+ export declare function isSkillTool(capability: CapabilityManifest | undefined, toolName: string | undefined): boolean;
12
+ /**
13
+ * `load_skill` for every skill of an agent, and `read_skill_resource` when a skill has files
14
+ * besides `SKILL.md`. Their names and input schemas are part of the hashed manifest; the Runtime
15
+ * runs them.
16
+ */
17
+ export declare function createSkillTools(skills: ReadonlyMap<string, SkillManifest>): readonly ToolDefinition[];
@@ -1,6 +1,38 @@
1
1
  import { z } from "zod";
2
+ import { SKILL_ENTRY } from "../utils/definition-files.js";
2
3
  import { tool } from "./helpers.js";
4
+ import { ToolError } from "./tool-error.js";
5
+ export const LOAD_SKILL_TOOL = "load_skill";
6
+ export const READ_SKILL_RESOURCE_TOOL = "read_skill_resource";
7
+ export const SKILL_TOOL_NAMES = new Set([
8
+ LOAD_SKILL_TOOL,
9
+ READ_SKILL_RESOURCE_TOOL,
10
+ ]);
3
11
  const USAGE = "Load the full instructions for a named skill. Call this before following a skill.";
12
+ /**
13
+ * Whether `toolName` is a skill tool the Runtime serves: `load_skill` or `read_skill_resource`
14
+ * declared by a capability that has skills (the first one, where the build attaches them). A
15
+ * tool of that name elsewhere is the author's own.
16
+ */
17
+ export function isSkillTool(capability, toolName) {
18
+ return (capability !== undefined &&
19
+ toolName !== undefined &&
20
+ SKILL_TOOL_NAMES.has(toolName) &&
21
+ Object.keys(capability.skills ?? {}).length > 0 &&
22
+ capability.tools?.some((item) => item.name === toolName) === true);
23
+ }
24
+ /**
25
+ * Stub implementation for the developer process. The Runtime serves the skill tools from the
26
+ * skill files uploaded with the agent; reaching this means the agent ran without a Runtime.
27
+ */
28
+ async function runtimeOnly() {
29
+ throw new ToolError("skills.runtime-only", "Skills are served by the Nylorun Runtime from the files uploaded with the agent. Connect the agent to a Runtime to use them.");
30
+ }
31
+ /**
32
+ * `load_skill` for every skill of an agent, and `read_skill_resource` when a skill has files
33
+ * besides `SKILL.md`. Their names and input schemas are part of the hashed manifest; the Runtime
34
+ * runs them.
35
+ */
4
36
  export function createSkillTools(skills) {
5
37
  const names = [...skills.keys()].sort();
6
38
  const nameSchema = names.length === 1
@@ -8,49 +40,24 @@ export function createSkillTools(skills) {
8
40
  : z.enum(names);
9
41
  const definitions = [
10
42
  tool({
11
- name: "load_skill",
43
+ name: LOAD_SKILL_TOOL,
12
44
  description: USAGE,
13
45
  inputSchema: z.object({ name: nameSchema }),
14
46
  effects: "read",
15
- async execute(args) {
16
- const name = args.name;
17
- const skill = skills.get(name);
18
- if (!skill)
19
- return { unknown: name, available: names };
20
- const loaded = {
21
- name: skill.name,
22
- content: skill.instructions,
23
- };
24
- const resources = Object.keys(skill.resources ?? {}).sort();
25
- if (resources.length === 0)
26
- return loaded;
27
- return { ...loaded, resources };
28
- },
47
+ execute: runtimeOnly,
29
48
  }),
30
49
  ];
31
- const hasResources = [...skills.values()].some((skill) => skill.resources !== undefined && Object.keys(skill.resources).length > 0);
32
- if (hasResources) {
50
+ const hasResources = [...skills.values()].some((skill) => Object.keys(skill.files).some((path) => path !== SKILL_ENTRY));
51
+ if (hasResources)
33
52
  definitions.push(tool({
34
- name: "read_skill_resource",
53
+ name: READ_SKILL_RESOURCE_TOOL,
35
54
  description: "Read one text resource from a skill after load_skill.",
36
55
  inputSchema: z.object({
37
56
  name: nameSchema,
38
57
  path: z.string().min(1),
39
58
  }),
40
59
  effects: "read",
41
- async execute(args) {
42
- const { name, path } = args;
43
- const skill = skills.get(name);
44
- const content = skill?.resources?.[path];
45
- if (!skill || content === undefined)
46
- return {
47
- kind: "failed",
48
- code: "skill.unknown_resource",
49
- message: `Skill '${name}' has no resource '${path}'.`,
50
- };
51
- return { kind: "completed", output: { name, path, content } };
52
- },
60
+ execute: runtimeOnly,
53
61
  }));
54
- }
55
62
  return definitions;
56
63
  }
@@ -1,7 +1,7 @@
1
1
  import type { AgentManifest } from "../types/manifest.js";
2
2
  /**
3
3
  * Whether `candidate` is a valid turn-manifest variant of the session's pinned
4
- * manifest (`loops.md` §3.4). Hooks and setup (MCP, sandbox) are fixed;
4
+ * manifest (`loops.md` §3.4). Setup (MCP, sandbox) is fixed;
5
5
  * code-backed tools/skills/agents-as-tools are remove-only; plain data may change.
6
6
  */
7
7
  export declare function isVariantOf(candidate: AgentManifest, pinned: AgentManifest): boolean;
@@ -29,7 +29,7 @@ function removeOnlySkills(pinned, candidate) {
29
29
  }
30
30
  /**
31
31
  * Whether `candidate` is a valid turn-manifest variant of the session's pinned
32
- * manifest (`loops.md` §3.4). Hooks and setup (MCP, sandbox) are fixed;
32
+ * manifest (`loops.md` §3.4). Setup (MCP, sandbox) is fixed;
33
33
  * code-backed tools/skills/agents-as-tools are remove-only; plain data may change.
34
34
  */
35
35
  export function isVariantOf(candidate, pinned) {
@@ -43,11 +43,7 @@ export function isVariantOf(candidate, pinned) {
43
43
  const candidateById = new Map(candidate.capabilities.map((capability) => [capability.id, capability]));
44
44
  for (const [, prior] of pinnedById) {
45
45
  const next = candidateById.get(prior.id);
46
- if (prior.hooks?.length) {
47
- // Hooks — and any capability that registers them — must not change or be removed.
48
- if (!next || !same(next.hooks, prior.hooks))
49
- return false;
50
- }
46
+ // Setup — and any capability that declares it — must not change or be removed.
51
47
  if (prior.mcpServers !== undefined) {
52
48
  if (!next || !same(next.mcpServers, prior.mcpServers))
53
49
  return false;
@@ -68,19 +64,12 @@ export function isVariantOf(candidate, pinned) {
68
64
  if (!removeOnlySkills(prior.skills, next.skills))
69
65
  return false;
70
66
  // Free: name, description, metadata, instructions (and model once it exists).
71
- if (prior.hooks?.length) {
72
- if (!same(next.hooks, prior.hooks))
73
- return false;
74
- }
75
- else if (next.hooks?.length) {
76
- return false; // cannot add hooks
77
- }
78
67
  if (!same(next.mcpServers, prior.mcpServers))
79
68
  return false;
80
69
  if (!same(next.sandbox, prior.sandbox))
81
70
  return false;
82
71
  }
83
- // Dropping a capability is allowed only when it had no hooks / MCP / sandbox
72
+ // Dropping a capability is allowed only when it had no MCP / sandbox
84
73
  // (those are enforced above). Tools and skills on a dropped capability are
85
74
  // removals, which §3.4 permits.
86
75
  return true;
@@ -1,14 +1,8 @@
1
1
  import type { BuildDiagnostic } from "../../types/shared.js";
2
- /** Thrown when a workflow primitive fails its build-time checks. */
2
+ /** Thrown when a flow agent fails its build-time checks. */
3
3
  export declare class WorkflowBuildError extends Error {
4
4
  readonly diagnostics: readonly BuildDiagnostic[];
5
5
  constructor(diagnostics: readonly BuildDiagnostic[]);
6
6
  }
7
7
  export declare function diagnostic(code: string, message: string, extra?: Partial<BuildDiagnostic>): BuildDiagnostic;
8
8
  export declare function fail(diagnostics: readonly BuildDiagnostic[]): never;
9
- export declare function failOne(code: string, message: string, extra?: Partial<BuildDiagnostic>): never;
10
- /** Path parts: non-empty, with no `/`, `[` or `]`. */
11
- export declare function isValidPathPart(part: string): boolean;
12
- export declare function assertValidPathPart(part: string, label: string): void;
13
- /** Record duplicate sibling path parts; returns diagnostics (does not throw). */
14
- export declare function siblingUniquenessDiagnostics(parts: readonly string[], label: string): BuildDiagnostic[];
@@ -1,4 +1,4 @@
1
- /** Thrown when a workflow primitive fails its build-time checks. */
1
+ /** Thrown when a flow agent fails its build-time checks. */
2
2
  export class WorkflowBuildError extends Error {
3
3
  diagnostics;
4
4
  constructor(diagnostics) {
@@ -13,26 +13,3 @@ export function diagnostic(code, message, extra = {}) {
13
13
  export function fail(diagnostics) {
14
14
  throw new WorkflowBuildError(Object.freeze([...diagnostics]));
15
15
  }
16
- export function failOne(code, message, extra) {
17
- fail([diagnostic(code, message, extra)]);
18
- }
19
- /** Path parts: non-empty, with no `/`, `[` or `]`. */
20
- export function isValidPathPart(part) {
21
- return part.length > 0 && !/[\/\[\]]/.test(part);
22
- }
23
- export function assertValidPathPart(part, label) {
24
- if (!isValidPathPart(part))
25
- failOne("workflow.invalid-path-part", `${label} '${part}' must be a non-empty path part with no '/', '[' or ']'`);
26
- }
27
- /** Record duplicate sibling path parts; returns diagnostics (does not throw). */
28
- export function siblingUniquenessDiagnostics(parts, label) {
29
- const seen = new Map();
30
- const found = [];
31
- for (const part of parts) {
32
- const count = (seen.get(part) ?? 0) + 1;
33
- seen.set(part, count);
34
- if (count === 2)
35
- found.push(diagnostic("workflow.duplicate-sibling", `Duplicate ${label} id '${part}'; path parts must be unique among siblings`, { details: { id: part } }));
36
- }
37
- return found;
38
- }
@@ -1,18 +1,4 @@
1
- export { Loop } from "./loop.js";
2
- export type { LoopOptions, LoopRunnable, LoopVerify, LoopVerifyFn, LoopDecideFn, LoopVerifyArgs, LoopDecideArgs, LoopDecision, } from "./loop.js";
3
- export { Chain } from "./chain.js";
4
- export type { ChainOptions, ChainStep, ChainResults, ChainSlot, LastOutput, } from "./chain.js";
5
- export { Switch } from "./switch.js";
6
- export type { SwitchOptions, SwitchCases, SwitchOn, SwitchOutput, } from "./switch.js";
7
- export { Parallel } from "./parallel.js";
8
- export type { ParallelOptions, ParallelBranches, ParallelOutput } from "./parallel.js";
9
- export { Map } from "./map.js";
10
- export type { MapOptions, MapOver } from "./map.js";
11
- export { isSlot } from "./slot.js";
12
- export type { Slot, SlotInputArgs, ChildRef } from "./slot.js";
13
- export { Verdict, VerdictSchema, isVerdict } from "./verdict.js";
14
- export { withInstructions, withoutTools } from "./patch.js";
15
- export { WorkflowBuildError, isValidPathPart } from "./diagnostics.js";
1
+ export { VerdictSchema, isVerdict } from "./verdict.js";
2
+ export { WorkflowBuildError } from "./diagnostics.js";
16
3
  export { isBuiltWorkflow } from "./types.js";
17
- export type { BuiltWorkflow, OutputOf, InputOf } from "./types.js";
18
- export type { WorkflowRunnable } from "./runnable.js";
4
+ export type { BuiltWorkflow } from "./types.js";
@@ -1,10 +1,3 @@
1
- export { Loop } from "./loop.js";
2
- export { Chain } from "./chain.js";
3
- export { Switch } from "./switch.js";
4
- export { Parallel } from "./parallel.js";
5
- export { Map } from "./map.js";
6
- export { isSlot } from "./slot.js";
7
- export { Verdict, VerdictSchema, isVerdict } from "./verdict.js";
8
- export { withInstructions, withoutTools } from "./patch.js";
9
- export { WorkflowBuildError, isValidPathPart } from "./diagnostics.js";
1
+ export { VerdictSchema, isVerdict } from "./verdict.js";
2
+ export { WorkflowBuildError } from "./diagnostics.js";
10
3
  export { isBuiltWorkflow } from "./types.js";
@@ -1,25 +1,9 @@
1
+ /** What a flow stage may hold, and how a tool becomes a tool node. */
1
2
  import type { AgentTool, BuiltAgent } from "../../types/agent.js";
2
3
  import type { ToolDefinition } from "../../types/tool.js";
3
- import type { WorkflowNode, WorkflowToolNode } from "../../types/workflow.js";
4
- import type { AgentBinding } from "../binding.js";
4
+ import type { WorkflowToolNode } from "../../types/workflow.js";
5
5
  import type { BoundToolDefinition } from "../bound.js";
6
- import { type BuiltWorkflow } from "./types.js";
7
- import { type ChildRef } from "./slot.js";
8
- /** Anything a primitive accepts as a child (or a slot wrapping one). */
9
- export type WorkflowRunnable = BuiltAgent | AgentTool | {
10
- build(): BuiltAgent;
11
- } | ToolDefinition<any, any, any> | BuiltWorkflow;
12
- export type ResolvedChild = {
13
- readonly id: string;
14
- readonly node: WorkflowNode;
15
- readonly agents: Record<string, AgentBinding>;
16
- /** Nested workflow implementations, keyed relative to the child root id. */
17
- readonly nodes: Record<string, import("../../types/workflow.js").WorkflowNodeImplementation>;
18
- readonly tool?: BoundToolDefinition;
19
- readonly isReshapingSlot: boolean;
20
- };
21
6
  export declare function isToolDefinition(value: unknown): value is ToolDefinition;
22
- export declare function isAgentLike(value: unknown): value is BuiltAgent | AgentTool;
23
7
  export declare function builtAgentOf(run: BuiltAgent | AgentTool | {
24
8
  build(): BuiltAgent;
25
9
  }): BuiltAgent;
@@ -30,19 +14,3 @@ export declare function builtAgentOf(run: BuiltAgent | AgentTool | {
30
14
  */
31
15
  export declare function bindToolNode(tool: ToolDefinition): BoundToolDefinition;
32
16
  export declare function toolManifestNode(bound: BoundToolDefinition): WorkflowToolNode;
33
- /**
34
- * Resolve a runnable or slot into a manifest node plus local bindings.
35
- * When the slot has `input`, the node is wrapped as `{ slot: { id?, input, run } }`.
36
- */
37
- export declare function resolveChild(child: ChildRef, defaultRename?: string): ResolvedChild;
38
- /**
39
- * Rewrite node keys that are rooted at `fromRoot` so they sit at `toPath`.
40
- * Used when nesting a child under a parent path (workflows.md §6).
41
- *
42
- * Example: Loop nodes `{ code, code/decide }` nested at `ship/code` become
43
- * `{ ship/code, ship/code/decide }`.
44
- */
45
- export declare function remapNodeKeys(nodes: Record<string, import("../../types/workflow.js").WorkflowNodeImplementation>, fromRoot: string, toPath: string): Record<string, import("../../types/workflow.js").WorkflowNodeImplementation>;
46
- /** @deprecated Prefer remapNodeKeys — kept for call-site clarity during migration. */
47
- export declare function prefixNodeKeys(nodes: Record<string, import("../../types/workflow.js").WorkflowNodeImplementation>, parentPath: string): Record<string, import("../../types/workflow.js").WorkflowNodeImplementation>;
48
- export declare function runnableId(child: ChildRef): string;