@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
@@ -3,148 +3,107 @@ import { assembleAgent } from "./assemble.js";
3
3
  import { schemaFromJSON } from "./schema-json.js";
4
4
  import { assertJson, deepFreeze } from "../utils/immutable.js";
5
5
  import { delegateFromManifest, delegateOf } from "./delegate.js";
6
- import { SKILL_TOOL_NAMES } from "./skill-tools.js";
7
6
  import { httpToolFromManifest, httpToolOf } from "./http-tool.js";
7
+ import { RUNTIME_PART_ID } from "./manifest.js";
8
+ import { ToolError } from "./tool-error.js";
8
9
  import { AgentManifestSchema } from "../contracts.js";
9
- /** Tools the engine or the Runtime runs, which need no implementation: agents and HTTP tools. */
10
- const declarative = (tool) => delegateOf(tool) !== undefined || httpToolOf(tool) !== undefined;
11
- /** Rebuild an agent from manifest JSON + in-process implementations (T28). */
10
+ /**
11
+ * Rebuild an agent from its manifest and the code of its tools, by name (T28). Agents used as
12
+ * tools and HTTP tools need no code; neither do the tools in `runtime`, which the Runtime serves.
13
+ * A session tool (`sessionTools`) is offered with the `runtime` part and needs its code.
14
+ */
12
15
  export function agentFrom(json, implementations, options) {
13
16
  const manifest = normalizeManifest(json);
14
17
  const sessionTools = options?.sessionTools ?? [];
15
18
  assertSessionTools(manifest, sessionTools);
16
- const entries = [];
17
- const dynamics = new Map();
18
- for (const capability of manifest.capabilities) {
19
- const impl = implementations[capability.id] ?? {};
20
- const tools = resolveTools(capability, impl.tools);
21
- const owned = sessionTools.filter((item) => item.capabilityId === capability.id);
22
- const instructions = [
23
- ...(capability.instructions ?? []),
24
- ...owned.flatMap((item) => item.instructions ?? []),
25
- ];
26
- const session = owned
27
- .map((item) => {
28
- const live = impl.tools?.[item.name];
29
- if (!live)
30
- throw new HarnessError("agent.build-failed", `Missing session tool implementation '${item.name}' for capability '${capability.id}'`);
31
- return live;
32
- });
33
- const handle = impl.middleware ??
34
- (async (request, next) => {
35
- const advertised = [...tools, ...session];
36
- if (advertised.length)
37
- request.configuration.tools.set(capability.id, advertised.map((tool) => (declarative(tool)
38
- ? tool
39
- : implementations[capability.id]?.tools?.[tool.name]) ?? tool));
40
- if (instructions.length > 0)
41
- request.configuration.instructions.set(capability.id, instructions);
42
- return next();
43
- });
44
- entries.push(Object.freeze({
45
- id: capability.id,
46
- ...(capability.name === undefined ? {} : { name: capability.name }),
47
- ...(capability.description === undefined
19
+ const code = implementations.tools ?? {};
20
+ const parts = [];
21
+ const own = (manifest.tools ?? []).map((declared) => authoredTool(declared, code[declared.name]));
22
+ if (own.length > 0 ||
23
+ manifest.instructions !== undefined ||
24
+ manifest.skills !== undefined ||
25
+ manifest.mcpServers !== undefined)
26
+ parts.push(Object.freeze({
27
+ id: "agent",
28
+ ...(manifest.tools === undefined ? {} : { tools: own }),
29
+ ...(manifest.instructions === undefined ? {} : { instructions: manifest.instructions }),
30
+ ...(manifest.skills === undefined ? {} : { skills: manifest.skills }),
31
+ ...(manifest.mcpServers === undefined ? {} : { mcpServers: manifest.mcpServers }),
32
+ }));
33
+ const runtime = manifest.runtime;
34
+ const session = sessionTools.map((item) => {
35
+ const live = code[item.name];
36
+ if (!live)
37
+ throw new HarnessError("agent.build-failed", `Missing session tool implementation '${item.name}'`);
38
+ return live;
39
+ });
40
+ const sessionInstructions = sessionTools.flatMap((item) => item.instructions ?? []);
41
+ if (runtime !== undefined || session.length > 0)
42
+ parts.push(Object.freeze({
43
+ id: RUNTIME_PART_ID,
44
+ ...(runtime?.tools === undefined
48
45
  ? {}
49
- : { description: capability.description }),
50
- handle,
51
- hasMiddleware: impl.middleware !== undefined,
52
- tools: capability.tools !== undefined
53
- ? tools.map((tool) => {
54
- const live = declarative(tool) ? tool : impl.tools?.[tool.name];
55
- if (!live)
56
- throw new HarnessError("agent.build-failed", `Missing tool implementation '${tool.name}' for capability '${capability.id}'`);
57
- return live;
58
- })
59
- : undefined,
46
+ : { tools: runtime.tools.map((declared) => code[declared.name] ?? runtimeTool(declared)) }),
60
47
  ...(session.length === 0 ? {} : { sessionTools: session }),
61
- contributions: Object.freeze({
62
- ...(capability.instructions
63
- ? { instructions: capability.instructions }
64
- : {}),
65
- ...(capability.tools
66
- ? {
67
- tools: capability.tools.map((tool) => Object.freeze({
68
- name: tool.name,
69
- ...(tool.description === undefined
70
- ? {}
71
- : { description: tool.description }),
72
- })),
73
- }
74
- : {}),
75
- }),
76
- manifestType: capability.type,
77
- ...(capability.metadata === undefined
78
- ? {}
79
- : { metadata: capability.metadata }),
80
- ...(capability.mcpServers === undefined
81
- ? {}
82
- : { mcpServers: capability.mcpServers }),
83
- ...(capability.sandbox === undefined
84
- ? {}
85
- : { sandbox: capability.sandbox }),
86
- ...(capability.skills === undefined
87
- ? {}
88
- : { skills: capability.skills }),
48
+ ...(runtime?.instructions === undefined ? {} : { instructions: runtime.instructions }),
49
+ ...(sessionInstructions.length === 0 ? {} : { sessionInstructions }),
89
50
  }));
90
- dynamics.set(capability.id, impl.middleware ? { middleware: impl.middleware } : {});
91
- }
92
51
  const outputSchema = manifest.outputSchema
93
52
  ? schemaFromJSON(manifest.outputSchema)
94
53
  : undefined;
95
- const result = assembleAgent(entries, {
54
+ const result = assembleAgent(parts, {
96
55
  id: manifest.id,
97
56
  name: manifest.name,
98
57
  description: manifest.description,
99
58
  metadata: manifest.metadata,
100
59
  outputSchema,
60
+ ...(manifest.requires === undefined ? {} : { requires: manifest.requires }),
101
61
  runtime: manifest.runtime,
102
- manifestSchemaVersion: manifest.manifestSchemaVersion,
103
- }, dynamics);
62
+ });
104
63
  if (!result.ok)
105
64
  throw new HarnessError("agent.build-failed", result.diagnostics.map((item) => item.message).join("; "));
106
65
  return result.agent;
107
66
  }
108
67
  function assertSessionTools(manifest, sessionTools) {
68
+ const taken = new Set([
69
+ ...(manifest.tools ?? []).map((tool) => tool.name),
70
+ ...(manifest.runtime?.tools ?? []).map((tool) => tool.name),
71
+ ]);
109
72
  const seen = new Set();
110
73
  for (const item of sessionTools) {
111
74
  if (seen.has(item.name))
112
75
  throw new HarnessError("agent.build-failed", `Duplicate session tool '${item.name}'`);
113
76
  seen.add(item.name);
114
- const capability = manifest.capabilities.find((entry) => entry.id === item.capabilityId);
115
- if (!capability)
116
- throw new HarnessError("agent.build-failed", `Session tool '${item.name}' references unknown capability '${item.capabilityId}'`);
117
- if (capability.tools?.some((tool) => tool.name === item.name))
77
+ if (taken.has(item.name))
118
78
  throw new HarnessError("agent.build-failed", `Session tool '${item.name}' collides with a declared tool`);
119
79
  }
120
80
  }
121
- function resolveTools(capability, tools) {
122
- if (!capability.tools?.length)
123
- return [];
124
- return capability.tools.flatMap((declared) => {
125
- const live = tools?.[declared.name];
126
- // The engine runs agents used as tools; an authored delegate keeps its local child.
127
- if (declared.agent)
128
- return [
129
- live && delegateOf(live)?.manifest.id === declared.agent.id
130
- ? live
131
- : delegateFromManifest(declared.agent, declared),
132
- ];
133
- // The Runtime runs HTTP tools; a host's own (its engine's routing) is kept.
134
- if (declared.http)
135
- return [
136
- live && httpToolOf(live)
137
- ? live
138
- : httpToolFromManifest({ ...declared, http: declared.http }),
139
- ];
140
- if (live)
141
- return [live];
142
- // The build attaches the skill tools again; the Runtime serves them.
143
- if (SKILL_TOOL_NAMES.has(declared.name) &&
144
- capability.skills &&
145
- Object.keys(capability.skills).length > 0)
146
- return [];
147
- throw new HarnessError("agent.build-failed", `Missing tool implementation '${declared.name}' for capability '${capability.id}'`);
81
+ /**
82
+ * An authored tool: the engine runs agents used as tools (an authored delegate keeps its local
83
+ * child), the Runtime runs HTTP tools (a host's own keeps its routing), and any other tool is the
84
+ * caller's code.
85
+ */
86
+ function authoredTool(declared, live) {
87
+ if (declared.agent)
88
+ return live && delegateOf(live)?.manifest.id === declared.agent.id
89
+ ? live
90
+ : delegateFromManifest(declared.agent, declared);
91
+ if (declared.http)
92
+ return live && httpToolOf(live) ? live : httpToolFromManifest({ ...declared, http: declared.http });
93
+ if (live)
94
+ return live;
95
+ throw new HarnessError("agent.build-failed", `Missing tool implementation '${declared.name}'`);
96
+ }
97
+ /** A tool the Runtime serves, as a process without a Runtime sees it: calling it says so. */
98
+ function runtimeTool(declared) {
99
+ return Object.freeze({
100
+ name: declared.name,
101
+ ...(declared.description === undefined ? {} : { description: declared.description }),
102
+ inputSchema: schemaFromJSON(declared.inputSchema),
103
+ ...(declared.outputSchema === undefined ? {} : { outputSchema: schemaFromJSON(declared.outputSchema) }),
104
+ async execute() {
105
+ throw new ToolError("tool.runtime-only", `'${declared.name}' runs in the Nylorun Runtime. Connect the agent to a Runtime to use it.`);
106
+ },
148
107
  });
149
108
  }
150
109
  /**
@@ -163,11 +122,7 @@ function normalizeManifest(json) {
163
122
  .join("; "));
164
123
  // The schema checks no value of a JSON object; metadata must be JSON data, as before.
165
124
  const manifest = parsed.data;
166
- for (const metadata of [
167
- manifest.metadata,
168
- ...manifest.capabilities.map((capability) => capability.metadata),
169
- ])
170
- if (metadata !== undefined)
171
- assertJson(metadata, "metadata");
125
+ if (manifest.metadata !== undefined)
126
+ assertJson(manifest.metadata, "metadata");
172
127
  return deepFreeze(JSON.parse(JSON.stringify(manifest)));
173
128
  }
@@ -1,10 +1,3 @@
1
- import type { ModelAdapter } from "../types/model.js";
2
- import type { StepMiddleware } from "../types/middleware.js";
3
1
  import type { ToolDefinition, ToolInputSchema, ToolOutputSchema, ToolSchemaSource } from "../types/tool.js";
4
2
  export declare const tool: <InputSchema extends ToolInputSchema, Info = unknown, OutputSchema extends ToolOutputSchema | undefined = undefined>(value: ToolDefinition<InputSchema, Info, OutputSchema>) => ToolDefinition<InputSchema, Info, OutputSchema>;
5
- /** @deprecated Prefer Runtime model resolution. Capability-disguised `.use({ model })` is not the taught path. */
6
- export declare const model: <T extends ModelAdapter>(value: T) => T;
7
- /** @deprecated Runs in the local engine only. Kept through 1.0. */
8
- export declare const middleware: <T extends StepMiddleware>(value: T) => T;
9
- export { capability } from "./capability.js";
10
3
  export type { ToolSchemaSource };
@@ -1,7 +1,2 @@
1
1
  import { prepareTool } from "./schema.js";
2
2
  export const tool = (value) => prepareTool(value);
3
- /** @deprecated Prefer Runtime model resolution. Capability-disguised `.use({ model })` is not the taught path. */
4
- export const model = (value) => value;
5
- /** @deprecated Runs in the local engine only. Kept through 1.0. */
6
- export const middleware = (value) => value;
7
- export { capability } from "./capability.js";
@@ -1,13 +1,11 @@
1
1
  import type { ToolDefinition } from "../types/tool.js";
2
- import type { StepMiddleware } from "../types/middleware.js";
3
- /** In-process implementations table keyed by capability id (never serialized). */
2
+ /**
3
+ * The code of an agent's tools, by tool name, for `Agent.from(manifest, implementations)` (never
4
+ * serialized). Agents used as tools, HTTP tools and the Runtime's tools need none.
5
+ */
4
6
  export interface Implementations<Info = unknown> {
5
- readonly [capabilityId: string]: {
6
- readonly tools?: {
7
- readonly [toolName: string]: ToolDefinition<any, Info, any>;
8
- };
9
- /** @deprecated Local engine only through 1.0. */
10
- readonly middleware?: StepMiddleware<Info>;
7
+ readonly tools?: {
8
+ readonly [toolName: string]: ToolDefinition<any, Info, any>;
11
9
  };
12
10
  }
13
11
  export declare function emptyImplementations(): Implementations;
@@ -1,15 +1,21 @@
1
- import type { BoundMiddleware } from "./bound.js";
2
- import type { AgentManifest, ManifestSchemaVersion, RuntimeManifest } from "../types/manifest.js";
1
+ import type { DefinitionPart } from "./bound.js";
2
+ import type { AgentManifest, AgentRequirements, RuntimeManifest } from "../types/manifest.js";
3
3
  import type { JsonObject } from "../types/shared.js";
4
4
  import type { ToolSchemaSource } from "../types/tool.js";
5
+ /** The id of the part an agent rebuilt from a pinned manifest gets for its `runtime` block. */
6
+ export declare const RUNTIME_PART_ID = "runtime";
7
+ /**
8
+ * The agent's manifest (v7): its parts merged in order, the instructions and tools concatenated,
9
+ * the skills and servers keyed by name. The `runtime` part is not projected: `runtime` comes as
10
+ * it was pinned.
11
+ */
5
12
  export declare function createManifest(input: {
6
13
  id: string;
7
14
  name?: string;
8
15
  description?: string;
9
16
  metadata?: JsonObject;
10
17
  outputSchema?: ToolSchemaSource;
18
+ requires?: AgentRequirements;
11
19
  runtime?: RuntimeManifest;
12
- middleware: readonly BoundMiddleware[];
13
- /** The version a manifest rebuilt from JSON had; it never goes below what the capabilities need. */
14
- manifestSchemaVersion?: ManifestSchemaVersion;
20
+ parts: readonly DefinitionPart[];
15
21
  }): AgentManifest;
@@ -2,14 +2,26 @@ import { bindOutputContract } from "./output-contract.js";
2
2
  import { normalizedSchemasFor } from "./schema.js";
3
3
  import { delegateOf } from "./delegate.js";
4
4
  import { httpToolOf } from "./http-tool.js";
5
- import { manifestVersionFor } from "./mcp.js";
6
5
  import { copyJsonObject, deepFreeze } from "../utils/immutable.js";
6
+ /** The id of the part an agent rebuilt from a pinned manifest gets for its `runtime` block. */
7
+ export const RUNTIME_PART_ID = "runtime";
8
+ /**
9
+ * The agent's manifest (v7): its parts merged in order, the instructions and tools concatenated,
10
+ * the skills and servers keyed by name. The `runtime` part is not projected: `runtime` comes as
11
+ * it was pinned.
12
+ */
7
13
  export function createManifest(input) {
8
- const capabilities = input.middleware.map((item) => projectCapability(item));
9
- // 6 only when an MCP server sets `tools` or `deferred` (R2b C9), so other hashes stay.
10
- const needed = manifestVersionFor(capabilities);
14
+ const authored = input.parts.filter((part) => part.id !== RUNTIME_PART_ID);
15
+ const instructions = authored.flatMap((part) => part.instructions ?? []);
16
+ const tools = authored.flatMap((part) => (part.tools ?? []).map((tool) => projectTool(tool)));
17
+ const skills = {};
18
+ const mcpServers = {};
19
+ for (const part of authored) {
20
+ Object.assign(skills, part.skills ?? {});
21
+ Object.assign(mcpServers, part.mcpServers ?? {});
22
+ }
11
23
  return deepFreeze({
12
- manifestSchemaVersion: Math.max(needed, input.manifestSchemaVersion ?? needed),
24
+ manifestSchemaVersion: 7,
13
25
  id: input.id,
14
26
  ...(input.name === undefined ? {} : { name: input.name }),
15
27
  ...(input.description === undefined
@@ -24,31 +36,19 @@ export function createManifest(input) {
24
36
  outputSchema: bindOutputContract(input.outputSchema).schema
25
37
  .jsonSchema,
26
38
  }),
27
- capabilities,
39
+ ...(instructions.length === 0 ? {} : { instructions }),
40
+ ...(tools.length === 0 ? {} : { tools }),
41
+ ...(Object.keys(skills).length === 0 ? {} : { skills }),
42
+ ...(Object.keys(mcpServers).length === 0 ? {} : { mcpServers }),
43
+ ...(input.requires === undefined ? {} : { requires: copyRequirements(input.requires) }),
28
44
  ...(input.runtime === undefined ? {} : { runtime: input.runtime }),
29
45
  });
30
46
  }
31
- function projectCapability(item) {
32
- const contributions = item.contributions;
47
+ /** `requires` as plain data, its secret names sorted and each once. */
48
+ function copyRequirements(requires) {
33
49
  return {
34
- id: item.id,
35
- type: item.manifestType ?? "agent",
36
- ...(item.name === undefined ? {} : { name: item.name }),
37
- ...(item.description === undefined ? {} : { description: item.description }),
38
- ...(item.metadata === undefined
39
- ? {}
40
- : { metadata: copyJsonObject(item.metadata, "metadata") }),
41
- ...(contributions?.instructions === undefined
42
- ? {}
43
- : { instructions: contributions.instructions }),
44
- ...(item.tools === undefined
45
- ? {}
46
- : { tools: item.tools.map((tool) => projectTool(tool)) }),
47
- ...(item.skills === undefined ? {} : { skills: item.skills }),
48
- ...(item.mcpServers === undefined ? {} : { mcpServers: item.mcpServers }),
49
- ...(item.sandbox === undefined
50
- ? {}
51
- : { sandbox: copyJsonObject(item.sandbox, "sandbox") }),
50
+ ...(requires.sandbox === undefined ? {} : { sandbox: requires.sandbox }),
51
+ ...(requires.secrets === undefined ? {} : { secrets: [...new Set(requires.secrets)].sort() }),
52
52
  };
53
53
  }
54
54
  function projectTool(tool) {
@@ -1,5 +1,4 @@
1
- import type { CapabilityDeclaration } from "../types/middleware.js";
2
- import type { ApprovalMode, ManifestSchemaVersion, McpServerManifest } from "../types/manifest.js";
1
+ import type { ApprovalMode, McpServerManifest } from "../types/manifest.js";
3
2
  type WithOptionalName<T> = T extends {
4
3
  readonly name: string;
5
4
  } ? Omit<T, "name"> & {
@@ -7,49 +6,10 @@ type WithOptionalName<T> = T extends {
7
6
  } : never;
8
7
  /** An MCP server as written by an author: `name` defaults to the server's key. */
9
8
  export type McpServerSpec = WithOptionalName<McpServerManifest>;
10
- export interface McpOptions {
11
- /** Capability id. Defaults to `"mcp"`. */
12
- readonly id?: string;
13
- }
14
- export interface McpCapability extends CapabilityDeclaration {
15
- readonly mcpServers: Readonly<Record<string, McpServerManifest>>;
16
- }
17
9
  export declare class McpError extends Error {
18
10
  readonly code: string;
19
11
  constructor(code: string, message: string);
20
12
  }
21
- /**
22
- * Declare MCP servers as one capability.
23
- *
24
- * Prefer `Agent(...).mcp({ ... })`. Each key names a server; its `name` defaults to
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
- *
28
- * ```ts
29
- * Agent({ id: "assistant" }).mcp({
30
- * github: { type: "streamable-http", url: "https://mcp.example.com/github" },
31
- * })
32
- * ```
33
- *
34
- * `tools` sets tools by the server's own names, with `"*"` for the rest: an allowlist and
35
- * deferral per tool (R2b C9, C10). `deferred` defers every tool of the server. Either makes the
36
- * manifest v6. Whether a call waits for a person is the Tenant's tool policy (R5 step 2).
37
- *
38
- * ```ts
39
- * Agent({ id: "assistant" }).mcp({
40
- * github: {
41
- * type: "streamable-http",
42
- * url: "https://api.githubcopilot.com/mcp/",
43
- * tools: {
44
- * "*": { enabled: false },
45
- * search_issues: { enabled: true },
46
- * create_issue: { enabled: true },
47
- * },
48
- * },
49
- * })
50
- * ```
51
- */
52
- export declare function mcp(servers: Readonly<Record<string, McpServerSpec>>, options?: McpOptions): McpCapability;
53
13
  /** Why a `stdio` MCP server is refused: the one message the builder, plugins and manifests give. */
54
14
  export declare function stdioMcpRefusal(name: string): string;
55
15
  /** Validate a map of MCP servers and fill each `name` from its key. */
@@ -69,15 +29,4 @@ export interface ResolvedMcpToolSettings {
69
29
  * (enabled, approval `never`, deferral automatic).
70
30
  */
71
31
  export declare function mcpToolSettings(server: McpServerManifest, serverToolName: string): ResolvedMcpToolSettings;
72
- /** True when the server sets `tools` or `deferred`, which need manifest v6 (R2b C9, Q19). */
73
- export declare function usesMcpToolSettings(server: McpServerManifest): boolean;
74
- /** Why a manifest v5 with this server is refused (R2b C9, Q19). */
75
- export declare function mcpToolSettingsVersionIssue(serverName: string): string;
76
- /**
77
- * The manifest version a definition with these capabilities needs: 6 when an MCP server sets
78
- * `tools` or `deferred`, else 5, so a manifest that uses neither keeps its hash (Q19).
79
- */
80
- export declare function manifestVersionFor(capabilities: readonly {
81
- readonly mcpServers?: Readonly<Record<string, McpServerManifest>>;
82
- }[]): ManifestSchemaVersion;
83
32
  export {};
@@ -7,41 +7,6 @@ export class McpError extends Error {
7
7
  this.code = code;
8
8
  }
9
9
  }
10
- /**
11
- * Declare MCP servers as one capability.
12
- *
13
- * Prefer `Agent(...).mcp({ ... })`. Each key names a server; its `name` defaults to
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).
16
- *
17
- * ```ts
18
- * Agent({ id: "assistant" }).mcp({
19
- * github: { type: "streamable-http", url: "https://mcp.example.com/github" },
20
- * })
21
- * ```
22
- *
23
- * `tools` sets tools by the server's own names, with `"*"` for the rest: an allowlist and
24
- * deferral per tool (R2b C9, C10). `deferred` defers every tool of the server. Either makes the
25
- * manifest v6. Whether a call waits for a person is the Tenant's tool policy (R5 step 2).
26
- *
27
- * ```ts
28
- * Agent({ id: "assistant" }).mcp({
29
- * github: {
30
- * type: "streamable-http",
31
- * url: "https://api.githubcopilot.com/mcp/",
32
- * tools: {
33
- * "*": { enabled: false },
34
- * search_issues: { enabled: true },
35
- * create_issue: { enabled: true },
36
- * },
37
- * },
38
- * })
39
- * ```
40
- */
41
- export function mcp(servers, options = {}) {
42
- const id = options.id ?? "mcp";
43
- return { id, mcpServers: normalizeMcpServers(servers, "mcp()") };
44
- }
45
10
  /** Why a `stdio` MCP server is refused: the one message the builder, plugins and manifests give. */
46
11
  export function stdioMcpRefusal(name) {
47
12
  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.`;
@@ -94,23 +59,6 @@ export function mcpToolSettings(server, serverToolName) {
94
59
  ...(deferred === undefined ? {} : { deferred }),
95
60
  };
96
61
  }
97
- /** True when the server sets `tools` or `deferred`, which need manifest v6 (R2b C9, Q19). */
98
- export function usesMcpToolSettings(server) {
99
- return server.tools !== undefined || server.deferred !== undefined;
100
- }
101
- /** Why a manifest v5 with this server is refused (R2b C9, Q19). */
102
- export function mcpToolSettingsVersionIssue(serverName) {
103
- return `MCP server '${serverName}' sets tools or deferred, which need manifestSchemaVersion 6. Rebuild the agent with the current SDK`;
104
- }
105
- /**
106
- * The manifest version a definition with these capabilities needs: 6 when an MCP server sets
107
- * `tools` or `deferred`, else 5, so a manifest that uses neither keeps its hash (Q19).
108
- */
109
- export function manifestVersionFor(capabilities) {
110
- return capabilities.some((capability) => Object.values(capability.mcpServers ?? {}).some(usesMcpToolSettings))
111
- ? 6
112
- : 5;
113
- }
114
62
  function freezeServer(server) {
115
63
  return Object.freeze({
116
64
  name: server.name,
@@ -0,0 +1,23 @@
1
+ import type { JsonValue } from "../types/shared.js";
2
+ /**
3
+ * What a media part's `reference` holds when the Runtime made it (protocol 6, 12): the artifact
4
+ * version, by id, with the file's name and size in bytes when known.
5
+ */
6
+ export interface MediaReference {
7
+ readonly artifactId: string;
8
+ readonly version: number;
9
+ readonly name?: string;
10
+ readonly size?: number;
11
+ }
12
+ /** The reference of a media part the Runtime made, or undefined for another host's. */
13
+ export declare function mediaReferenceOf(value: JsonValue | undefined): MediaReference | undefined;
14
+ /**
15
+ * The line a file stands for in a prompt once its turn is over (protocol 12): its name, artifact
16
+ * id and version, and how the model reads it again. A file a tool returned names the tool.
17
+ */
18
+ export declare function mediaReferenceLine(part: {
19
+ readonly mediaType: string;
20
+ readonly reference: JsonValue;
21
+ }, origin: "uploaded" | {
22
+ readonly tool: string;
23
+ }): string;
@@ -0,0 +1,26 @@
1
+ /** The reference of a media part the Runtime made, or undefined for another host's. */
2
+ export function mediaReferenceOf(value) {
3
+ if (!value || typeof value !== "object" || Array.isArray(value))
4
+ return undefined;
5
+ const { artifactId, version, name, size } = value;
6
+ if (typeof artifactId !== "string" || typeof version !== "number" || !Number.isInteger(version))
7
+ return undefined;
8
+ return {
9
+ artifactId,
10
+ version,
11
+ ...(typeof name === "string" ? { name } : {}),
12
+ ...(typeof size === "number" ? { size } : {}),
13
+ };
14
+ }
15
+ /**
16
+ * The line a file stands for in a prompt once its turn is over (protocol 12): its name, artifact
17
+ * id and version, and how the model reads it again. A file a tool returned names the tool.
18
+ */
19
+ export function mediaReferenceLine(part, origin) {
20
+ const reference = mediaReferenceOf(part.reference);
21
+ const what = origin === "uploaded" ? "Uploaded artifact" : `Tool ${origin.tool} returned artifact`;
22
+ if (!reference)
23
+ return `[${what} (${part.mediaType})]`;
24
+ const name = JSON.stringify(reference.name ?? reference.artifactId);
25
+ return `[${what} ${name} · ${reference.artifactId} v${reference.version} · read_artifact to view]`;
26
+ }
@@ -1,15 +1,8 @@
1
- /**
2
- * Capability 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). `model` went earlier: the Runtime owns the model.
5
- */
6
- export declare const REMOVED_CAPABILITY_FIELDS: Readonly<Record<string, string>>;
1
+ /** Why a part may not carry a field that manifest v5 removed. */
2
+ export declare const REMOVED_PART_FIELDS: Readonly<Record<string, string>>;
7
3
  /** Manifest fields an older SDK wrote, and why each is refused. */
8
4
  export declare const REMOVED_MANIFEST_FIELDS: Readonly<Record<string, string>>;
9
- /**
10
- * Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 5 and
11
- * version 6 (R2b C9: an MCP server's `tools` and `deferred`; v5 is accepted unchanged).
12
- */
5
+ /** Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 7. */
13
6
  export declare function manifestVersionIssue(version: unknown): string | undefined;
14
7
  /** Why a workflow manifest with this `workflowSchemaVersion` is refused, or undefined for version 3. */
15
8
  export declare function workflowVersionIssue(version: unknown): string | undefined;
@@ -1,28 +1,21 @@
1
- /**
2
- * Capability 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). `model` went earlier: the Runtime owns the model.
5
- */
6
- export const REMOVED_CAPABILITY_FIELDS = Object.freeze({
7
- hooks: "hooks were removed: the Runtime runs agents from their manifests alone. 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
- model: "A capability must not include model; the Runtime owns model resolution",
1
+ /** Why a part may not carry a field that manifest v5 removed. */
2
+ export const REMOVED_PART_FIELDS = Object.freeze({
3
+ hooks: "hooks were removed: the Runtime runs agents from their manifests alone. Use an HTTP tool, the Tenant's tool policy, or a loop verifier instead (see MIGRATION.md)",
4
+ model: "An agent must not include model; the Runtime owns model resolution",
11
5
  });
12
6
  /** Manifest fields an older SDK wrote, and why each is refused. */
13
7
  export const REMOVED_MANIFEST_FIELDS = Object.freeze({
14
8
  schemaVersion: "Manifest field schemaVersion was renamed to manifestSchemaVersion",
15
9
  model: "Manifest must not include top-level model; Runtime owns model resolution",
10
+ hooks: "hooks were removed: the Runtime runs agents from their manifests alone. Use an HTTP tool, the Tenant's tool policy, or a loop verifier instead (see MIGRATION.md)",
11
+ capabilities: "Manifest v7 has no capabilities: the agent's instructions, tools, skills and mcpServers are top-level fields. Rebuild the agent with the current SDK (see MIGRATION.md)",
16
12
  });
17
- /**
18
- * Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 5 and
19
- * version 6 (R2b C9: an MCP server's `tools` and `deferred`; v5 is accepted unchanged).
20
- */
13
+ /** Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 7. */
21
14
  export function manifestVersionIssue(version) {
22
- if (version === 5 || version === 6)
15
+ if (version === 7)
23
16
  return undefined;
24
- if (version === 4 || version === 3)
25
- return `manifestSchemaVersion ${version} is no longer supported: manifest v5 removed hooks. Rebuild the agent with the current SDK (see MIGRATION.md)`;
17
+ if (typeof version === "number" && version >= 3 && version <= 6)
18
+ return `manifestSchemaVersion ${version} is no longer supported: manifest v7 has no capabilities. Rebuild the agent with the current SDK (see MIGRATION.md)`;
26
19
  return `Unsupported manifestSchemaVersion ${String(version)}`;
27
20
  }
28
21
  /** Why a workflow manifest with this `workflowSchemaVersion` is refused, or undefined for version 3. */