@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
package/dist/define.d.ts CHANGED
@@ -5,19 +5,20 @@ export type { HarnessErrorCode, HarnessErrorDetails, HarnessErrorOptions, } from
5
5
  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
- export { capability, middleware, model, tool } from "./definition/helpers.js";
8
+ export { tool } from "./definition/helpers.js";
9
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";
10
- export { ARTIFACTS_CAPABILITY_ID, READ_ARTIFACT_MAX_BYTES, READ_ARTIFACT_TOOL, SANDBOX_CAPABILITY_ID, SAVE_ARTIFACT_TOOL, artifactsCapabilityManifest, sandboxCapabilityManifest, } from "./definition/sandbox-capability.js";
11
- export { MCP_TOOL_DEFAULTS, manifestVersionFor, mcp, mcpToolSettings, McpError, normalizeMcpServers, stdioMcpRefusal, usesMcpToolSettings, } from "./definition/mcp.js";
12
- export { SERVER_INSTRUCTIONS_MAX_CHARS, TOOL_CALL_TOOL, TOOL_SEARCH_DEFAULT_LIMIT, TOOL_SEARCH_MAX_LIMIT, TOOL_SEARCH_TOOL, TOOLS_CAPABILITY_ID, deferredToolsInstructions, deferredToolsTools, toolsCapabilityManifest, type DeferredServerNote, } from "./definition/tools-capability.js";
10
+ export { READ_ARTIFACT_MAX_BYTES, READ_ARTIFACT_TOOL, SAVE_ARTIFACT_TOOL, runtimeManifestFor, runtimeToolOf, type RuntimeManifestOptions, } from "./definition/runtime-manifest.js";
11
+ export { RUNTIME_PART_ID } from "./definition/manifest.js";
12
+ export { RUNTIME_TOOL_NAMES, isRuntimeToolName } from "./utils/runtime-tools.js";
13
+ export { MCP_TOOL_DEFAULTS, mcpToolSettings, McpError, normalizeMcpServers, stdioMcpRefusal, } from "./definition/mcp.js";
14
+ export { SERVER_INSTRUCTIONS_MAX_CHARS, TOOL_CALL_TOOL, TOOL_SEARCH_DEFAULT_LIMIT, TOOL_SEARCH_MAX_LIMIT, TOOL_SEARCH_TOOL, deferredToolsInstructions, deferredToolsTools, type DeferredServerNote, } from "./definition/deferred-tools.js";
13
15
  export { codeToolRefusal, codeToolsOf } from "./definition/code-tools.js";
16
+ export { pluginOf, skillOfToolCall, type ToolCallTrace } from "./definition/trace.js";
14
17
  export { approvalRefusal, approvalsOf } from "./definition/approval.js";
15
18
  export type { CodeTool } from "./definition/code-tools.js";
16
- export { CapabilityBuilder, isCapabilityBuilder } from "./definition/capability.js";
17
- export type { CapabilityIdentity, CapabilityOptions } from "./definition/capability.js";
18
19
  export { flow, FlowBuilder, isFlowBuilder, ROOT_POSITION, childPosition, embeddedAgent, flowHttpTarget, forEachFlowNode, indexSuffix, isLeafNode, isWorkflowManifest, leafPart, leafPath, stageKey, stripIndices, } from "./definition/flow/index.js";
19
20
  export type { FlowAgentBuilder, Flow, Named, FlowOut, LoopOptions, StageOptions, FlowNodeVisit, FlowVisitNode, FlowHttpTarget, FlowImplementations, } from "./definition/flow/index.js";
20
- export type { McpCapability, McpOptions, McpServerSpec, ResolvedMcpToolSettings, } from "./definition/mcp.js";
21
+ export type { McpServerSpec, ResolvedMcpToolSettings, } from "./definition/mcp.js";
21
22
  export { ToolError, isToolError } from "./definition/tool-error.js";
22
23
  export { defineSchema } from "./definition/schema.js";
23
24
  export { hashManifest } from "./utils/hash.js";
@@ -25,11 +26,11 @@ export { MODEL_FAILURE_CODES, isModelFailureOutcome } from "./definition/model-f
25
26
  export { createSandboxTools, SANDBOX_INSTRUCTIONS, } from "./definition/sandbox-tools.js";
26
27
  export { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE, isSandboxHostPattern, isSandboxToolName, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
27
28
  export type { SandboxToolName } from "./utils/sandbox.js";
28
- export { LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILL_TOOL_NAMES, isSkillTool, } from "./definition/skill-tools.js";
29
- 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";
29
+ export { LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILL_TOOL_NAMES, isSkillTool, SKILLS_USAGE, formatSkillCatalog, } from "./definition/skill-tools.js";
30
+ export { DEFINITION_FILE_MAX_BYTES, SKILL_ENTRY, SKILL_FILES_MAX, SKILL_FILE_PATH_MAX, SKILLS_MOUNT, definitionFilesOf, skillFolderOf, isDefinitionFileHash, skillFilePathIssue, skillFilesIssue, skillInstructions, } from "./utils/definition-files.js";
30
31
  export type { Implementations } from "./definition/implementations.js";
31
- export type { AgentManifest, ApprovalMode, CapabilityManifest, HttpToolMethod, HttpToolTarget, McpServerManifest, McpToolSettings, RuntimeManifest, SandboxManifest, SandboxNetworkPreset, SkillManifest, ToolManifest, ManifestSchemaVersion, } from "./types/manifest.js";
32
- export type { CapabilityDeclaration, CapabilityInput, CapabilityItems, MiddlewareContributions, SkillFileSource, StepMiddleware, StepRequest, StepResponse, } from "./types/middleware.js";
32
+ export type { AgentManifest, ApprovalMode, HttpToolMethod, HttpToolTarget, McpServerManifest, McpToolSettings, PluginLabel, RuntimeManifest, SandboxManifest, SandboxNetworkPreset, SkillManifest, ToolManifest, ManifestSchemaVersion, } from "./types/manifest.js";
33
+ export type { PartDeclaration, SkillFileSource, } from "./types/part.js";
33
34
  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";
34
35
  export type { BuildDiagnostic, ContextItem, DeferredOutcome, JsonObject, JsonPrimitive, JsonValue, Tripwire, } from "./types/shared.js";
35
36
  export type { ObserveEvent, ObserveModelConfigurationSnapshot, ObserveModelRequested, ObserveSealedCall, ObserveToolSnapshot, Observer, } from "./types/observe.js";
@@ -42,11 +43,12 @@ export { VerdictSchema, isVerdict, WorkflowBuildError, isBuiltWorkflow, } from "
42
43
  export type { BuiltWorkflow } from "./definition/workflow/index.js";
43
44
  export { isVariantOf } from "./definition/variant.js";
44
45
  export type { Verdict, WorkflowBinding, WorkflowHttpVerify, WorkflowLoopVerify, WorkflowManifest, WorkflowNode, } from "./types/workflow.js";
45
- export type { BoundMiddleware, BoundToolDefinition, } from "./definition/bound.js";
46
+ export type { DefinitionPart, BoundToolDefinition, } from "./definition/bound.js";
46
47
  export { bindTool } from "./definition/bind-tool.js";
47
48
  export { bindOutputContract } from "./definition/output-contract.js";
48
49
  export type { TurnOutputContract } from "./definition/output-contract.js";
49
50
  export { agentFrom } from "./definition/from.js";
51
+ export { mediaReferenceLine, mediaReferenceOf, type MediaReference, } from "./definition/media-reference.js";
50
52
  export type { SessionToolRef } from "./definition/from.js";
51
53
  export { schemaFromJSON } from "./definition/schema-json.js";
52
54
  export { normalizeSchema } from "./definition/schema.js";
package/dist/define.js CHANGED
@@ -1,14 +1,16 @@
1
1
  export { Agent, AgentBuilder, AgentBuildError, AgentLifecycleError, } from "./definition/builder.js";
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
- export { capability, middleware, model, tool } from "./definition/helpers.js";
4
+ export { tool } from "./definition/helpers.js";
5
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";
6
- export { ARTIFACTS_CAPABILITY_ID, READ_ARTIFACT_MAX_BYTES, READ_ARTIFACT_TOOL, SANDBOX_CAPABILITY_ID, SAVE_ARTIFACT_TOOL, artifactsCapabilityManifest, sandboxCapabilityManifest, } from "./definition/sandbox-capability.js";
7
- export { MCP_TOOL_DEFAULTS, manifestVersionFor, mcp, mcpToolSettings, McpError, normalizeMcpServers, stdioMcpRefusal, usesMcpToolSettings, } from "./definition/mcp.js";
8
- export { SERVER_INSTRUCTIONS_MAX_CHARS, TOOL_CALL_TOOL, TOOL_SEARCH_DEFAULT_LIMIT, TOOL_SEARCH_MAX_LIMIT, TOOL_SEARCH_TOOL, TOOLS_CAPABILITY_ID, deferredToolsInstructions, deferredToolsTools, toolsCapabilityManifest, } from "./definition/tools-capability.js";
6
+ export { READ_ARTIFACT_MAX_BYTES, READ_ARTIFACT_TOOL, SAVE_ARTIFACT_TOOL, runtimeManifestFor, runtimeToolOf, } from "./definition/runtime-manifest.js";
7
+ export { RUNTIME_PART_ID } from "./definition/manifest.js";
8
+ export { RUNTIME_TOOL_NAMES, isRuntimeToolName } from "./utils/runtime-tools.js";
9
+ export { MCP_TOOL_DEFAULTS, mcpToolSettings, McpError, normalizeMcpServers, stdioMcpRefusal, } from "./definition/mcp.js";
10
+ export { SERVER_INSTRUCTIONS_MAX_CHARS, TOOL_CALL_TOOL, TOOL_SEARCH_DEFAULT_LIMIT, TOOL_SEARCH_MAX_LIMIT, TOOL_SEARCH_TOOL, deferredToolsInstructions, deferredToolsTools, } from "./definition/deferred-tools.js";
9
11
  export { codeToolRefusal, codeToolsOf } from "./definition/code-tools.js";
12
+ export { pluginOf, skillOfToolCall } from "./definition/trace.js";
10
13
  export { approvalRefusal, approvalsOf } from "./definition/approval.js";
11
- export { CapabilityBuilder, isCapabilityBuilder } from "./definition/capability.js";
12
14
  export { flow, FlowBuilder, isFlowBuilder, ROOT_POSITION, childPosition, embeddedAgent, flowHttpTarget, forEachFlowNode, indexSuffix, isLeafNode, isWorkflowManifest, leafPart, leafPath, stageKey, stripIndices, } from "./definition/flow/index.js";
13
15
  export { ToolError, isToolError } from "./definition/tool-error.js";
14
16
  export { defineSchema } from "./definition/schema.js";
@@ -16,8 +18,8 @@ export { hashManifest } from "./utils/hash.js";
16
18
  export { MODEL_FAILURE_CODES, isModelFailureOutcome } from "./definition/model-failure.js";
17
19
  export { createSandboxTools, SANDBOX_INSTRUCTIONS, } from "./definition/sandbox-tools.js";
18
20
  export { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE, isSandboxHostPattern, isSandboxToolName, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
19
- export { LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILL_TOOL_NAMES, isSkillTool, } from "./definition/skill-tools.js";
20
- 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";
21
+ export { LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILL_TOOL_NAMES, isSkillTool, SKILLS_USAGE, formatSkillCatalog, } from "./definition/skill-tools.js";
22
+ export { DEFINITION_FILE_MAX_BYTES, SKILL_ENTRY, SKILL_FILES_MAX, SKILL_FILE_PATH_MAX, SKILLS_MOUNT, definitionFilesOf, skillFolderOf, isDefinitionFileHash, skillFilePathIssue, skillFilesIssue, skillInstructions, } from "./utils/definition-files.js";
21
23
  export { normalizeToolDefinition, normalizedSchemasFor, } from "./definition/schema.js";
22
24
  export { implementationsFor, bindingFromAgent } from "./definition/binding.js";
23
25
  export { VerdictSchema, isVerdict, WorkflowBuildError, isBuiltWorkflow, } from "./definition/workflow/index.js";
@@ -25,6 +27,7 @@ export { isVariantOf } from "./definition/variant.js";
25
27
  export { bindTool } from "./definition/bind-tool.js";
26
28
  export { bindOutputContract } from "./definition/output-contract.js";
27
29
  export { agentFrom } from "./definition/from.js";
30
+ export { mediaReferenceLine, mediaReferenceOf, } from "./definition/media-reference.js";
28
31
  export { schemaFromJSON } from "./definition/schema-json.js";
29
32
  export { normalizeSchema } from "./definition/schema.js";
30
33
  export * from "./utils/immutable.js";
@@ -8,20 +8,18 @@ export function approvalsOf(manifest, into = []) {
8
8
  return into;
9
9
  }
10
10
  const agent = manifest;
11
- for (const capability of agent.capabilities) {
12
- for (const tool of capability.tools ?? []) {
13
- if (tool.agent !== undefined)
14
- approvalsOf(tool.agent, into);
15
- else if (tool.approval !== undefined)
16
- into.push(`tool '${tool.name}' of agent '${agent.id}'`);
17
- }
18
- for (const [key, server] of Object.entries(capability.mcpServers ?? {})) {
19
- if (server.approval !== undefined)
20
- into.push(`MCP server '${server.name ?? key}' of agent '${agent.id}'`);
21
- for (const [name, settings] of Object.entries(server.tools ?? {}))
22
- if (settings.approval !== undefined)
23
- into.push(`tool '${name}' of MCP server '${server.name ?? key}' of agent '${agent.id}'`);
24
- }
11
+ for (const tool of agent.tools ?? []) {
12
+ if (tool.agent !== undefined)
13
+ approvalsOf(tool.agent, into);
14
+ else if (tool.approval !== undefined)
15
+ into.push(`tool '${tool.name}' of agent '${agent.id}'`);
16
+ }
17
+ for (const [key, server] of Object.entries(agent.mcpServers ?? {})) {
18
+ if (server.approval !== undefined)
19
+ into.push(`MCP server '${server.name ?? key}' of agent '${agent.id}'`);
20
+ for (const [name, settings] of Object.entries(server.tools ?? {}))
21
+ if (settings.approval !== undefined)
22
+ into.push(`tool '${name}' of MCP server '${server.name ?? key}' of agent '${agent.id}'`);
25
23
  }
26
24
  return into;
27
25
  }
@@ -1,9 +1,8 @@
1
- import type { BoundMiddleware } from "./bound.js";
1
+ import type { DefinitionPart } from "./bound.js";
2
2
  import type { BuiltAgent } from "../types/agent.js";
3
- import type { AgentManifest, ManifestSchemaVersion, RuntimeManifest } from "../types/manifest.js";
3
+ import type { AgentManifest, AgentRequirements, 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 { StepMiddleware } from "../types/middleware.js";
7
6
  type BuildResult<Agent> = {
8
7
  readonly ok: true;
9
8
  readonly agent: Agent;
@@ -12,17 +11,14 @@ type BuildResult<Agent> = {
12
11
  readonly ok: false;
13
12
  readonly diagnostics: readonly BuildDiagnostic[];
14
13
  };
15
- export interface CapabilityDynamics {
16
- readonly middleware?: StepMiddleware<any>;
17
- }
18
- export declare function assembleAgent(middleware: readonly BoundMiddleware[], identity: Readonly<{
14
+ export declare function assembleAgent(parts: readonly DefinitionPart[], identity: Readonly<{
19
15
  id: string;
20
16
  name?: string;
21
17
  description?: string;
22
18
  metadata?: JsonObject;
23
19
  outputSchema?: ToolSchemaSource;
20
+ requires?: AgentRequirements;
21
+ /** A pinned manifest's `runtime` block, kept as it was (`agentFrom`). */
24
22
  runtime?: RuntimeManifest;
25
- /** A manifest rebuilt from JSON keeps its version (`agentFrom`); a new one takes the least. */
26
- manifestSchemaVersion?: ManifestSchemaVersion;
27
- }>, dynamics?: ReadonlyMap<string, CapabilityDynamics>): BuildResult<BuiltAgent>;
23
+ }>): BuildResult<BuiltAgent>;
28
24
  export {};
@@ -1,10 +1,9 @@
1
1
  import { bindAgent } from "./bind-agent.js";
2
- import { createManifest } from "./manifest.js";
3
- import { createSkillTools } from "./skill-tools.js";
2
+ import { createManifest, RUNTIME_PART_ID } from "./manifest.js";
4
3
  import { DELEGATE_NAME_PATTERN, delegateOf, delegatesOf } from "./delegate.js";
5
- import { SANDBOX_CAPABILITY_ID } from "./sandbox-capability.js";
4
+ import { isRuntimeToolName } from "../utils/runtime-tools.js";
6
5
  const diagnostic = (code, message, extra = {}) => Object.freeze({ code, message, ...extra });
7
- export function assembleAgent(middleware, identity, dynamics = new Map()) {
6
+ export function assembleAgent(parts, identity) {
8
7
  const diagnostics = [];
9
8
  if (typeof identity.id !== "string" || identity.id.length === 0) {
10
9
  diagnostics.push(diagnostic("agent.invalid-id", "Agent id must be a non-empty string"));
@@ -13,85 +12,67 @@ export function assembleAgent(middleware, identity, dynamics = new Map()) {
13
12
  (typeof identity.name !== "string" || identity.name.length === 0)) {
14
13
  diagnostics.push(diagnostic("agent.invalid-name", "Agent name must be a non-empty string"));
15
14
  }
16
- const middlewareIds = new Set();
15
+ const partIds = new Set();
17
16
  const frozen = [];
18
- for (const item of middleware) {
17
+ for (const item of parts) {
19
18
  if (!item.id)
20
- diagnostics.push(diagnostic("middleware.invalid-id", "Middleware id must not be empty"));
21
- else if (middlewareIds.has(item.id))
22
- diagnostics.push(diagnostic("middleware.duplicate-id", `Duplicate middleware id '${item.id}'`));
23
- else if (typeof item.handle !== "function")
24
- diagnostics.push(diagnostic("middleware.invalid", `Middleware '${item.id}' must provide a function`));
25
- else if (item.name !== undefined && item.name.length === 0)
26
- diagnostics.push(diagnostic("middleware.invalid", `Capability '${item.id}' name must be a non-empty string`));
19
+ diagnostics.push(diagnostic("part.invalid-id", "A part's id must not be empty"));
20
+ else if (partIds.has(item.id))
21
+ diagnostics.push(diagnostic("part.duplicate-id", `'${item.id}' is added twice`));
27
22
  else {
28
- middlewareIds.add(item.id);
29
- frozen.push(Object.freeze({
30
- id: item.id,
31
- ...(item.name === undefined ? {} : { name: item.name }),
32
- ...(item.description === undefined
33
- ? {}
34
- : { description: item.description }),
35
- handle: item.handle,
36
- hasMiddleware: item.hasMiddleware,
37
- ...(item.tools === undefined ? {} : { tools: item.tools }),
38
- ...(item.contributions === undefined
39
- ? {}
40
- : { contributions: item.contributions }),
41
- ...(item.manifestType === undefined
42
- ? {}
43
- : { manifestType: item.manifestType }),
44
- ...(item.metadata === undefined ? {} : { metadata: item.metadata }),
45
- ...(item.mcpServers === undefined
46
- ? {}
47
- : { mcpServers: item.mcpServers }),
48
- ...(item.sandbox === undefined ? {} : { sandbox: item.sandbox }),
49
- ...(item.skills === undefined ? {} : { skills: item.skills }),
50
- ...(item.skillFiles === undefined
51
- ? {}
52
- : { skillFiles: item.skillFiles }),
53
- ...(item.sessionTools === undefined
54
- ? {}
55
- : { sessionTools: item.sessionTools }),
56
- }));
23
+ partIds.add(item.id);
24
+ frozen.push(Object.freeze({ ...item }));
57
25
  }
58
26
  }
59
- const skilled = attachSkillTools(frozen);
60
- diagnostics.push(...skilled.diagnostics);
61
- // The wire schema rejects tool names shared across capabilities; report them at build time
62
- // with both owners. Duplicates within one capability keep their registration-time error.
63
- const toolOwners = new Map();
64
- for (const item of skilled.items)
27
+ // The wire schema rejects a tool name used twice; report it at build time.
28
+ const toolNames = new Set();
29
+ for (const item of frozen)
65
30
  for (const entry of item.tools ?? []) {
66
- const owner = toolOwners.get(entry.name);
67
- if (owner !== undefined && owner !== item.id)
68
- diagnostics.push(diagnostic("tool.duplicate-name", `Tool '${entry.name}' is declared by capabilities '${owner}' and '${item.id}'`));
69
- else
70
- toolOwners.set(entry.name, item.id);
31
+ if (toolNames.has(entry.name))
32
+ diagnostics.push(diagnostic("tool.duplicate-name", `Tool '${entry.name}' is declared twice`, {
33
+ toolName: entry.name,
34
+ }));
35
+ toolNames.add(entry.name);
36
+ if (item.id !== RUNTIME_PART_ID && isRuntimeToolName(entry.name))
37
+ diagnostics.push(diagnostic("tool.reserved-name", `Tool '${entry.name}' takes the name of a tool the Runtime serves; rename it`, { toolName: entry.name }));
38
+ if (item.id !== RUNTIME_PART_ID && entry.name.includes("__"))
39
+ diagnostics.push(diagnostic("tool.invalid-name", `Tool '${entry.name}' must not contain '__', which names an MCP server's tools`, { toolName: entry.name }));
71
40
  }
72
- diagnostics.push(...delegationDiagnostics(skilled.items));
73
- diagnostics.push(...sandboxDiagnostics(skilled.items));
41
+ diagnostics.push(...nameDiagnostics(frozen, "skills", "skill.duplicate-name", "skill"));
42
+ diagnostics.push(...nameDiagnostics(frozen, "mcpServers", "mcp.duplicate-server", "MCP server"));
43
+ diagnostics.push(...delegationDiagnostics(frozen));
44
+ diagnostics.push(...sandboxDiagnostics(frozen));
74
45
  if (diagnostics.length)
75
46
  return Object.freeze({
76
47
  ok: false,
77
48
  diagnostics: Object.freeze(diagnostics),
78
49
  });
79
- const frozenMiddleware = Object.freeze(skilled.items.map((item) => Object.freeze(item)));
50
+ const frozenParts = Object.freeze(frozen);
80
51
  const manifest = createManifest({
81
52
  id: identity.id,
82
53
  name: identity.name,
83
54
  description: identity.description,
84
55
  metadata: identity.metadata,
85
56
  outputSchema: identity.outputSchema,
57
+ requires: identity.requires,
86
58
  runtime: identity.runtime,
87
- middleware: frozenMiddleware,
88
- ...(identity.manifestSchemaVersion === undefined
89
- ? {}
90
- : { manifestSchemaVersion: identity.manifestSchemaVersion }),
59
+ parts: frozenParts,
91
60
  });
92
- const agent = bindAgent(frozenMiddleware, manifest, identity, dynamics);
61
+ const agent = bindAgent(frozenParts, manifest, identity);
93
62
  return Object.freeze({ ok: true, agent, manifest });
94
63
  }
64
+ /** A skill or MCP server name declared by two parts (two plugins, or a plugin and the agent). */
65
+ function nameDiagnostics(parts, field, code, what) {
66
+ const found = [];
67
+ const seen = new Set();
68
+ for (const part of parts)
69
+ for (const [key, value] of Object.entries(part[field] ?? {})) {
70
+ if (key !== value.name || seen.has(value.name))
71
+ found.push(diagnostic(code, `Duplicate ${what} '${value.name}'`));
72
+ seen.add(value.name);
73
+ }
74
+ return found;
75
+ }
95
76
  /** v1 delegation is one level deep and non-interactive; anything else fails the build by name. */
96
77
  function delegationDiagnostics(items) {
97
78
  const found = [];
@@ -105,7 +86,7 @@ function delegationDiagnostics(items) {
105
86
  if (!DELEGATE_NAME_PATTERN.test(child.id))
106
87
  found.push(diagnostic("delegation.invalid-name", `Agent '${child.id}' is used as a tool, so its id must be 1-64 letters, digits, '_' or '-'`, extra));
107
88
  if (!child.description?.trim())
108
- found.push(diagnostic("delegation.description-required", `Agent '${child.id}' is used as a tool by capability '${item.id}' and needs a description: the parent's model reads it to decide when to delegate`, extra));
89
+ found.push(diagnostic("delegation.description-required", `Agent '${child.id}' is used as a tool and needs a description: the parent's model reads it to decide when to delegate`, extra));
109
90
  // A flow agent runs in its own linked session; its agents may delegate in turn.
110
91
  if (child.kind === "workflow")
111
92
  continue;
@@ -119,50 +100,12 @@ function delegationDiagnostics(items) {
119
100
  return found;
120
101
  }
121
102
  /**
122
- * Definitions declare no sandbox: a session gets one when it is opened (Sandboxes v3). A
123
- * capability that still carries `sandbox` fails the build instead of being silently dropped.
124
- * The Runtime's own capability (`nylorun.sandbox`, in a session's pinned manifest) is exempt.
103
+ * Definitions declare no sandbox: a session gets one when it is opened (Sandboxes v3), and the
104
+ * Runtime pins it in the manifest's `runtime` block. A part that still carries `sandbox` fails the
105
+ * build instead of being silently dropped.
125
106
  */
126
107
  function sandboxDiagnostics(items) {
127
108
  return items
128
- .filter((item) => item.sandbox !== undefined && item.id !== SANDBOX_CAPABILITY_ID)
129
- .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.`));
130
- }
131
- /**
132
- * Gives the first capability with skills `load_skill` (and `read_skill_resource`) for every skill
133
- * of the agent. A tool of that name it already has is kept: an agent rebuilt from its manifest
134
- * brings the hosted ones the Runtime serves.
135
- */
136
- function attachSkillTools(items) {
137
- const skills = new Map();
138
- const diagnostics = [];
139
- let ownerId;
140
- for (const item of items)
141
- for (const [key, skill] of Object.entries(item.skills ?? {})) {
142
- if (key !== skill.name || skills.has(skill.name)) {
143
- diagnostics.push(diagnostic("skill.duplicate-name", `Duplicate skill '${skill.name}' on capability '${item.id}'`));
144
- continue;
145
- }
146
- skills.set(skill.name, skill);
147
- ownerId ??= item.id;
148
- }
149
- if (diagnostics.length > 0 || ownerId === undefined)
150
- return { items: [...items], diagnostics };
151
- const skillTools = createSkillTools(skills);
152
- const next = items.map((item) => {
153
- if (item.id !== ownerId)
154
- return item;
155
- const declared = new Set((item.tools ?? []).map((entry) => entry.name));
156
- const added = skillTools.filter((entry) => !declared.has(entry.name));
157
- if (added.length === 0)
158
- return item;
159
- const tools = [...(item.tools ?? []), ...added];
160
- const advertised = [...tools, ...(item.sessionTools ?? [])];
161
- const handle = async (request, next) => item.handle(request, async () => {
162
- request.configuration.tools.set(item.id, advertised);
163
- return next();
164
- });
165
- return { ...item, tools, handle };
166
- });
167
- return { items: next, diagnostics };
109
+ .filter((item) => item.sandbox !== undefined)
110
+ .map(() => diagnostic("sandbox.in-definition", "Agents no longer declare a sandbox: open the session with it instead, createSession({ sandbox: { image, network: { allow }, resources } }), or set the Tenant's default sandbox."));
168
111
  }
@@ -1,8 +1,7 @@
1
1
  import type { AgentManifest } from "../types/manifest.js";
2
- import type { BoundMiddleware } from "./bound.js";
2
+ import type { DefinitionPart } from "./bound.js";
3
3
  import type { BuiltAgent } from "../types/agent.js";
4
4
  import type { ToolSchemaSource } from "../types/tool.js";
5
- import type { CapabilityDynamics } from "./assemble.js";
6
- export declare function bindAgent(middleware: readonly BoundMiddleware[], manifest: AgentManifest, options?: {
5
+ export declare function bindAgent(parts: readonly DefinitionPart[], manifest: AgentManifest, options?: {
7
6
  outputSchema?: ToolSchemaSource;
8
- }, dynamics?: ReadonlyMap<string, CapabilityDynamics>): BuiltAgent;
7
+ }): BuiltAgent;
@@ -1,25 +1,23 @@
1
1
  import { bindTool } from "./bind-tool.js";
2
2
  import { HarnessError } from "../errors.js";
3
3
  import { bindOutputContract } from "./output-contract.js";
4
- export function bindAgent(middleware, manifest, options = {}, dynamics = new Map()) {
4
+ export function bindAgent(parts, manifest, options = {}) {
5
5
  const seen = new Set();
6
- const keys = new Set();
6
+ const names = new Set();
7
7
  const tools = [];
8
- for (const declaration of middleware)
9
- for (const tool of [
10
- ...(declaration.tools ?? []),
11
- ...(declaration.sessionTools ?? []),
12
- ]) {
13
- const key = JSON.stringify([declaration.id, tool.name]);
14
- if (seen.has(tool) || keys.has(key))
15
- throw new HarnessError("tool.invalid", `Duplicate registered tool '${tool.name}' in '${declaration.id}'`);
8
+ for (const part of parts)
9
+ for (const tool of [...(part.tools ?? []), ...(part.sessionTools ?? [])]) {
10
+ if (seen.has(tool) || names.has(tool.name))
11
+ throw new HarnessError("tool.invalid", `Duplicate registered tool '${tool.name}'`);
16
12
  seen.add(tool);
17
- keys.add(key);
18
- tools.push(bindTool(tool, { middlewareId: declaration.id, slot: declaration.id }));
13
+ names.add(tool.name);
14
+ tools.push(bindTool(tool, { partId: part.id, slot: part.id }));
19
15
  }
20
- const implementations = buildImplementations(middleware, dynamics, tools);
16
+ const implementations = Object.freeze(tools.length === 0
17
+ ? {}
18
+ : { tools: Object.freeze(Object.fromEntries(tools.map((tool) => [tool.name, tool]))) });
21
19
  const binding = Object.freeze({
22
- declarations: middleware,
20
+ parts,
23
21
  tools: Object.freeze(tools),
24
22
  ...(options.outputSchema === undefined
25
23
  ? {}
@@ -42,19 +40,3 @@ export function bindAgent(middleware, manifest, options = {}, dynamics = new Map
42
40
  });
43
41
  return agent;
44
42
  }
45
- function buildImplementations(middleware, dynamics, snapshots) {
46
- const table = {};
47
- for (const item of middleware) {
48
- const tools = {};
49
- for (const tool of snapshots.filter((tool) => tool.owner.middlewareId === item.id))
50
- tools[tool.name] = tool;
51
- const dyn = dynamics.get(item.id);
52
- table[item.id] = Object.freeze({
53
- ...(Object.keys(tools).length
54
- ? { tools: Object.freeze({ ...tools }) }
55
- : {}),
56
- ...(dyn?.middleware ? { middleware: dyn.middleware } : {}),
57
- });
58
- }
59
- return Object.freeze(table);
60
- }
@@ -1,13 +1,13 @@
1
1
  import type { AgentManifest } from "../types/manifest.js";
2
2
  import type { BuiltAgent } from "../types/agent.js";
3
3
  import type { ToolSchemaSource } from "../types/tool.js";
4
- import type { BoundMiddleware, BoundToolDefinition } from "./bound.js";
4
+ import type { DefinitionPart, BoundToolDefinition } from "./bound.js";
5
5
  import type { Implementations } from "./implementations.js";
6
6
  /** Local code binding. Only manifest is serializable; functions stay in the application. */
7
7
  export interface AgentBinding {
8
8
  readonly manifest: AgentManifest;
9
9
  readonly tools: readonly BoundToolDefinition[];
10
- readonly declarations: readonly BoundMiddleware[];
10
+ readonly parts: readonly DefinitionPart[];
11
11
  readonly implementations: Implementations;
12
12
  readonly outputSchema?: ToolSchemaSource;
13
13
  }
@@ -1,7 +1,6 @@
1
- import type { JsonObject } from "../types/shared.js";
2
1
  import type { McpServerManifest, SandboxManifest, SkillManifest } from "../types/manifest.js";
3
2
  import type { Delegate } from "./delegate.js";
4
- import type { MiddlewareContributions, SkillFileSource, StepMiddleware } from "../types/middleware.js";
3
+ import type { SkillFileSource } from "../types/part.js";
5
4
  import type { ToolApproval, ToolDefinition, ToolEffects, ToolExecutionContext, ToolInputSchema, ToolOutputSchema, ToolOwner, ToolRunResult, ToolSchema } from "../types/tool.js";
6
5
  export interface BoundToolDefinition<Info = unknown> extends Omit<ToolDefinition<ToolInputSchema, Info, ToolOutputSchema | undefined>, "inputSchema" | "outputSchema" | "execute" | "run" | "input" | "output"> {
7
6
  readonly inputSchema: ToolSchema<unknown>;
@@ -14,18 +13,19 @@ export interface BoundToolDefinition<Info = unknown> extends Omit<ToolDefinition
14
13
  /** Set when this tool is an agent used as a tool; the engine runs it. */
15
14
  readonly delegate?: Delegate;
16
15
  }
17
- export interface BoundMiddleware {
16
+ /**
17
+ * One part of an agent definition: what one builder call, skills folder or plugin added, or (in
18
+ * an agent rebuilt from a pinned manifest) the `runtime` block. The engine offers each part's
19
+ * tools and instructions to the model in part order; the manifest holds the parts merged.
20
+ */
21
+ export interface DefinitionPart {
18
22
  readonly id: string;
19
- readonly name?: string;
20
- readonly description?: string;
21
- readonly handle: StepMiddleware;
22
- readonly hasMiddleware: boolean;
23
23
  readonly tools?: readonly ToolDefinition<any, any, any>[];
24
24
  /** Execution-only tools. Advertised for this run and omitted from the manifest. */
25
25
  readonly sessionTools?: readonly ToolDefinition<any, any, any>[];
26
- readonly contributions?: MiddlewareContributions;
27
- readonly manifestType?: "agent" | "agent-plugin";
28
- readonly metadata?: JsonObject;
26
+ readonly instructions?: readonly string[];
27
+ /** Text the model reads while the session tools are advertised. Not in the manifest. */
28
+ readonly sessionInstructions?: readonly string[];
29
29
  readonly skills?: Readonly<Record<string, SkillManifest>>;
30
30
  /** Each skill file's bytes, by `sha256:<hex>`. Not a manifest field. */
31
31
  readonly skillFiles?: Readonly<Record<string, SkillFileSource>>;
@@ -1,13 +1,12 @@
1
- import type { BoundMiddleware } from "./bound.js";
2
- import type { CapabilityInput, StepMiddleware } from "../types/middleware.js";
1
+ import type { DefinitionPart } from "./bound.js";
2
+ import type { PartDeclaration } from "../types/part.js";
3
3
  import type { BuildDiagnostic, JsonObject } from "../types/shared.js";
4
4
  import { HarnessError } from "../errors.js";
5
5
  import type { ToolDefinition, ToolSchemaSource, SchemaOutput } from "../types/tool.js";
6
6
  import type { AgentTool, BuiltAgent } from "../types/agent.js";
7
- import type { AgentManifest, McpServerManifest } from "../types/manifest.js";
7
+ import type { AgentManifest, AgentRequirements, McpServerManifest } from "../types/manifest.js";
8
8
  import type { WorkflowBinding, WorkflowManifest } from "../types/workflow.js";
9
9
  import type { Implementations } from "./implementations.js";
10
- import { type CapabilityDynamics } from "./assemble.js";
11
10
  import { type McpServerSpec } from "./mcp.js";
12
11
  import { type FlowImplementations } from "./flow/from.js";
13
12
  import type { BuiltWorkflow } from "./workflow/types.js";
@@ -33,12 +32,13 @@ interface BuilderSnapshot {
33
32
  readonly metadata?: JsonObject;
34
33
  readonly outputSchema?: ToolSchemaSource;
35
34
  readonly inputSchema?: ToolSchemaSource;
36
- readonly entries: readonly BoundMiddleware[];
37
- readonly dynamics: ReadonlyMap<string, CapabilityDynamics>;
35
+ /** What the agent needs of its session's Environment (D65). */
36
+ readonly requires?: AgentRequirements;
37
+ readonly entries: readonly DefinitionPart[];
38
38
  /** Builder-level problems, reported with the assembly diagnostics. */
39
39
  readonly diagnostics?: readonly BuildDiagnostic[];
40
40
  readonly body: Body;
41
- /** Raw items of the `"agent"` capability, so later calls can add to it. */
41
+ /** Raw items of the `"agent"` part, so later calls can add to it. */
42
42
  readonly agentPart?: {
43
43
  readonly instructions?: readonly string[];
44
44
  readonly tools?: readonly (ToolDefinition<any, any, any> | AgentTool)[];
@@ -59,7 +59,7 @@ export declare function Agent<Info = unknown, Schema extends ToolSchemaSource |
59
59
  export declare namespace Agent {
60
60
  /** Rebuild a flow agent from its workflow manifest v3 and the tools its tool nodes name. */
61
61
  function from(json: WorkflowManifest, implementations?: FlowImplementations): BuiltWorkflow;
62
- /** Rebuild an agent from its manifest and the code its capabilities name. */
62
+ /** Rebuild an agent from its manifest and the code of its tools, by name. */
63
63
  function from<Info = unknown>(json: AgentManifest | import("../types/shared.js").JsonObject, implementations: Implementations<Info>): BuiltAgent<Info>;
64
64
  }
65
65
  declare const SNAPSHOT: unique symbol;
@@ -96,18 +96,16 @@ export declare class AgentBuilder<Info = unknown, Schema extends ToolSchemaSourc
96
96
  subagents(...agents: readonly AgentTool[]): this;
97
97
  /** Declare MCP servers. A server's `name` defaults to its key; calls merge. */
98
98
  mcp(servers: Readonly<Record<string, McpServerSpec>>): this;
99
- /** Attach a reusable bundle made with `capability({ id })`. */
100
- capability(bundle: CapabilityInput<Info> | {
101
- toDeclaration(): CapabilityInput<Info>;
102
- }): this;
99
+ /** @internal Add a part (the SDK's `.skills()` and `.plugin()` use it). */
100
+ protected withPart(declaration: PartDeclaration<Info>, method: string): this;
103
101
  /** The structured output. Set once. */
104
102
  output<S extends ToolSchemaSource>(schema: S): AgentBuilder<Info, S, Id>;
105
- /** @deprecated Use `.capability()`, `.mcp()`, `.skills()` or `.plugin()`. */
106
- use(middleware: StepMiddleware<Info>): this;
107
- /** @deprecated Use `.capability()`, `.mcp()`, `.skills()` or `.plugin()`. */
108
- use(id: string, middleware: StepMiddleware<Info>): this;
109
- /** @deprecated Use `.capability()`, `.mcp()`, `.skills()` or `.plugin()`. */
110
- use(declaration: CapabilityInput<Info>): this;
103
+ /**
104
+ * What the agent needs of the Environment its session opens on (protocol 14, D65): a sandbox
105
+ * (`any` or `pod`) and secret names its skills' scripts read. A session whose Environment lacks
106
+ * them is refused when it opens. The agent still names no Environment. Set once.
107
+ */
108
+ requires(requirements: AgentRequirements): AgentBuilder<Info, Schema, Id>;
111
109
  /** The flow agent's input. Set once. */
112
110
  input<S extends ToolSchemaSource>(schema: S): FlowAgentBuilder<Info, SchemaOutput<S>, SchemaOutput<S>, SchemaOut<Schema>, Id>;
113
111
  /** Add stages in order: the first gets the flow's input, each later one the previous output. */
@@ -131,8 +129,6 @@ export declare class AgentBuilder<Info = unknown, Schema extends ToolSchemaSourc
131
129
  private bodyFor;
132
130
  private addStages;
133
131
  private withAgentItems;
134
- private addDeclaration;
135
- private appendCompiled;
136
132
  }
137
133
  export type { Implementations };
138
134
  export type { WorkflowBinding, WorkflowManifest };