@nylorun/core 0.22.0-beta → 0.24.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 (82) hide show
  1. package/CHANGELOG.md +126 -0
  2. package/README.md +1 -1
  3. package/dist/compatibility.d.ts +120 -47
  4. package/dist/compatibility.js +122 -49
  5. package/dist/contracts.d.ts +2824 -907
  6. package/dist/contracts.js +1286 -585
  7. package/dist/define.d.ts +9 -12
  8. package/dist/define.js +8 -11
  9. package/dist/definition/assemble.d.ts +1 -3
  10. package/dist/definition/assemble.js +4 -8
  11. package/dist/definition/bound.d.ts +1 -1
  12. package/dist/definition/delegate.d.ts +5 -0
  13. package/dist/definition/delegate.js +6 -1
  14. package/dist/definition/from.d.ts +4 -2
  15. package/dist/definition/from.js +11 -29
  16. package/dist/definition/http-tool.d.ts +5 -3
  17. package/dist/definition/http-tool.js +8 -5
  18. package/dist/definition/manifest.d.ts +7 -6
  19. package/dist/definition/manifest.js +7 -6
  20. package/dist/definition/mcp.d.ts +1 -1
  21. package/dist/definition/media-reference.d.ts +2 -11
  22. package/dist/definition/media-reference.js +0 -12
  23. package/dist/definition/model-failure.js +1 -0
  24. package/dist/definition/removed.d.ts +7 -0
  25. package/dist/definition/removed.js +21 -0
  26. package/dist/definition/sections.d.ts +63 -0
  27. package/dist/definition/sections.js +204 -0
  28. package/dist/definition/trace.d.ts +0 -7
  29. package/dist/definition/trace.js +0 -34
  30. package/dist/definition/variant.d.ts +1 -1
  31. package/dist/definition/variant.js +1 -3
  32. package/dist/harness-api/artifacts.d.ts +84 -0
  33. package/dist/harness-api/artifacts.js +128 -0
  34. package/dist/harness-api/gates.d.ts +0 -4
  35. package/dist/harness-api/gates.js +0 -4
  36. package/dist/harness-api/harness-api.schema.json +2798 -1124
  37. package/dist/harness-api/index.d.ts +9 -6
  38. package/dist/harness-api/index.js +9 -6
  39. package/dist/harness-api/json-schema.js +5 -2
  40. package/dist/harness-api/mcp.d.ts +77 -30
  41. package/dist/harness-api/mcp.js +42 -25
  42. package/dist/harness-api/messages.d.ts +47 -17
  43. package/dist/harness-api/messages.js +20 -5
  44. package/dist/harness-api/schema.d.ts +609 -200
  45. package/dist/harness-api/schema.js +345 -62
  46. package/dist/harness-api/transcript.d.ts +8 -10
  47. package/dist/harness-api/transcript.js +27 -11
  48. package/dist/harness-api/transport.d.ts +7 -1
  49. package/dist/harness-api/transport.js +10 -7
  50. package/dist/manifest-schemas.d.ts +9 -5
  51. package/dist/manifest-schemas.js +23 -27
  52. package/dist/schemas/agent-manifest.schema.json +1508 -365
  53. package/dist/schemas/harness-manifest.schema.json +1273 -0
  54. package/dist/schemas/{environment-manifest.schema.json → runtime-manifest.schema.json} +165 -84
  55. package/dist/types/manifest.d.ts +72 -14
  56. package/dist/types/manifest.js +4 -0
  57. package/dist/types/model.d.ts +15 -5
  58. package/dist/utils/definition-files.d.ts +20 -6
  59. package/dist/utils/definition-files.js +31 -17
  60. package/dist/utils/file-systems.d.ts +20 -0
  61. package/dist/utils/file-systems.js +20 -0
  62. package/dist/utils/harness-id.d.ts +4 -1
  63. package/dist/utils/harness-id.js +4 -1
  64. package/dist/utils/media-types.d.ts +30 -0
  65. package/dist/utils/media-types.js +128 -0
  66. package/dist/utils/memory.d.ts +64 -0
  67. package/dist/utils/memory.js +139 -0
  68. package/dist/utils/runtime-limits.d.ts +280 -0
  69. package/dist/utils/runtime-limits.js +585 -0
  70. package/dist/utils/runtime-tools.d.ts +8 -16
  71. package/dist/utils/runtime-tools.js +8 -27
  72. package/dist/utils/sandbox.d.ts +4 -1
  73. package/dist/utils/sandbox.js +4 -1
  74. package/package.json +6 -5
  75. package/dist/definition/deferred-tools.d.ts +0 -27
  76. package/dist/definition/deferred-tools.js +0 -82
  77. package/dist/definition/runtime-manifest.d.ts +0 -30
  78. package/dist/definition/runtime-manifest.js +0 -132
  79. package/dist/definition/sandbox-tools.d.ts +0 -5
  80. package/dist/definition/sandbox-tools.js +0 -109
  81. package/dist/definition/skill-tools.d.ts +0 -23
  82. package/dist/definition/skill-tools.js +0 -76
package/dist/define.d.ts CHANGED
@@ -3,17 +3,15 @@ export type { AgentOptions } from "./definition/builder.js";
3
3
  export { HarnessError, isHarnessError } from "./errors.js";
4
4
  export type { HarnessErrorCode, HarnessErrorDetails, HarnessErrorOptions, } from "./errors.js";
5
5
  export type { AgentTool, BuiltAgent } from "./types/agent.js";
6
- export { DELEGATE_INPUT_SCHEMA, delegateManifest, delegateOf, delegatesOf, flowDelegatesOf, flowDelegateManifest, isFlowDelegate, } from "./definition/delegate.js";
6
+ export { DELEGATE_INPUT_SCHEMA, delegateManifest, delegateOf, delegatesOf, flowDelegatesOf, flowDelegateManifest, isFlowDelegate, MODEL_TOOL_NAME_MAX, } from "./definition/delegate.js";
7
7
  export type { Delegate } from "./definition/delegate.js";
8
8
  export { tool } from "./definition/helpers.js";
9
- export { APPROVAL_MODES, HTTP_TOOL_DEFAULT_TIMEOUT_MS, HTTP_TOOL_MAX_TIMEOUT_MS, HTTP_TOOL_METHODS, HTTP_BODY_METHODS, http, httpPathParameters, httpToolOf, httpToolRequest, isHttpTarget, withHttpTarget, type HttpTarget, type HttpTool, type HttpToolOptions, type HttpToolRequest, } from "./definition/http-tool.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";
9
+ export { APPROVAL_MODES, HTTP_TOOL_DEFAULT_TIMEOUT_MS, HTTP_TOOL_METHODS, HTTP_BODY_METHODS, http, httpPathParameters, httpToolOf, httpToolRequest, isHttpTarget, withHttpTarget, type HttpTarget, type HttpTool, type HttpToolOptions, type HttpToolRequest, } from "./definition/http-tool.js";
10
+ export { SESSION_PART_ID } from "./definition/manifest.js";
11
+ export { READ_ARTIFACT_TOOL, SAVE_ARTIFACT_TOOL, } from "./utils/runtime-tools.js";
13
12
  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";
15
13
  export { codeToolRefusal, codeToolsOf } from "./definition/code-tools.js";
16
- export { pluginOf, skillOfToolCall, type ToolCallTrace } from "./definition/trace.js";
14
+ export { pluginOf, type ToolCallTrace } from "./definition/trace.js";
17
15
  export { approvalRefusal, approvalsOf } from "./definition/approval.js";
18
16
  export type { CodeTool } from "./definition/code-tools.js";
19
17
  export { flow, FlowBuilder, isFlowBuilder, ROOT_POSITION, childPosition, embeddedAgent, flowHttpTarget, forEachFlowNode, indexSuffix, isLeafNode, isWorkflowManifest, leafPart, leafPath, stageKey, stripIndices, } from "./definition/flow/index.js";
@@ -23,13 +21,11 @@ export { ToolError, isToolError } from "./definition/tool-error.js";
23
21
  export { defineSchema } from "./definition/schema.js";
24
22
  export { hashManifest } from "./utils/hash.js";
25
23
  export { MODEL_FAILURE_CODES, isModelFailureOutcome } from "./definition/model-failure.js";
26
- export { createSandboxTools, SANDBOX_INSTRUCTIONS, } from "./definition/sandbox-tools.js";
27
24
  export { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE, isSandboxHostPattern, isSandboxToolName, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.js";
28
25
  export type { SandboxToolName } from "./utils/sandbox.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";
26
+ export { SKILL_ENTRY, SKILL_TOTAL_BYTES_DEFAULT, SKILL_FILE_PATH_MAX, SKILLS_MOUNT, definitionFilesOf, skillsOf, skillFolderOf, isDefinitionFileHash, skillFilePathIssue, skillFilesIssue, skillInstructions, } from "./utils/definition-files.js";
31
27
  export type { Implementations } from "./definition/implementations.js";
32
- export type { AgentManifest, ApprovalMode, HttpToolMethod, HttpToolTarget, McpServerManifest, McpToolSettings, PluginLabel, RuntimeManifest, SandboxManifest, SandboxNetworkPreset, SkillManifest, ToolManifest, ManifestSchemaVersion, } from "./types/manifest.js";
28
+ export type { AgentManifest, ApprovalMode, HttpToolMethod, HttpToolTarget, McpServerManifest, McpToolSettings, PluginLabel, SandboxManifest, SandboxNetworkPreset, SkillManifest, ToolManifest, ManifestSchemaVersion, } from "./types/manifest.js";
33
29
  export type { PartDeclaration, SkillFileSource, } from "./types/part.js";
34
30
  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";
35
31
  export type { BuildDiagnostic, ContextItem, DeferredOutcome, JsonObject, JsonPrimitive, JsonValue, Tripwire, } from "./types/shared.js";
@@ -48,7 +44,8 @@ export { bindTool } from "./definition/bind-tool.js";
48
44
  export { bindOutputContract } from "./definition/output-contract.js";
49
45
  export type { TurnOutputContract } from "./definition/output-contract.js";
50
46
  export { agentFrom } from "./definition/from.js";
51
- export { mediaReferenceLine, mediaReferenceOf, type MediaReference, } from "./definition/media-reference.js";
47
+ export { harnessIdOf, harnessSectionOf, isWorkflowHarness, kindMeets, loopManifestOf, normalizeCredentialUrl, pluginsOf, runtimeOf, sandboxNeedOf, sectionGaps, type SandboxNeed, } from "./definition/sections.js";
48
+ export { mediaReferenceOf, type MediaReference } from "./definition/media-reference.js";
52
49
  export type { SessionToolRef } from "./definition/from.js";
53
50
  export { schemaFromJSON } from "./definition/schema-json.js";
54
51
  export { normalizeSchema } from "./definition/schema.js";
package/dist/define.js CHANGED
@@ -1,25 +1,21 @@
1
1
  export { Agent, AgentBuilder, AgentBuildError, AgentLifecycleError, } from "./definition/builder.js";
2
2
  export { HarnessError, isHarnessError } from "./errors.js";
3
- export { DELEGATE_INPUT_SCHEMA, delegateManifest, delegateOf, delegatesOf, flowDelegatesOf, flowDelegateManifest, isFlowDelegate, } from "./definition/delegate.js";
3
+ export { DELEGATE_INPUT_SCHEMA, delegateManifest, delegateOf, delegatesOf, flowDelegatesOf, flowDelegateManifest, isFlowDelegate, MODEL_TOOL_NAME_MAX, } from "./definition/delegate.js";
4
4
  export { tool } from "./definition/helpers.js";
5
- export { APPROVAL_MODES, HTTP_TOOL_DEFAULT_TIMEOUT_MS, HTTP_TOOL_MAX_TIMEOUT_MS, HTTP_TOOL_METHODS, HTTP_BODY_METHODS, http, httpPathParameters, httpToolOf, httpToolRequest, isHttpTarget, withHttpTarget, } from "./definition/http-tool.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";
5
+ export { APPROVAL_MODES, HTTP_TOOL_DEFAULT_TIMEOUT_MS, HTTP_TOOL_METHODS, HTTP_BODY_METHODS, http, httpPathParameters, httpToolOf, httpToolRequest, isHttpTarget, withHttpTarget, } from "./definition/http-tool.js";
6
+ export { SESSION_PART_ID } from "./definition/manifest.js";
7
+ export { READ_ARTIFACT_TOOL, SAVE_ARTIFACT_TOOL, } from "./utils/runtime-tools.js";
9
8
  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";
11
9
  export { codeToolRefusal, codeToolsOf } from "./definition/code-tools.js";
12
- export { pluginOf, skillOfToolCall } from "./definition/trace.js";
10
+ export { pluginOf } from "./definition/trace.js";
13
11
  export { approvalRefusal, approvalsOf } from "./definition/approval.js";
14
12
  export { flow, FlowBuilder, isFlowBuilder, ROOT_POSITION, childPosition, embeddedAgent, flowHttpTarget, forEachFlowNode, indexSuffix, isLeafNode, isWorkflowManifest, leafPart, leafPath, stageKey, stripIndices, } from "./definition/flow/index.js";
15
13
  export { ToolError, isToolError } from "./definition/tool-error.js";
16
14
  export { defineSchema } from "./definition/schema.js";
17
15
  export { hashManifest } from "./utils/hash.js";
18
16
  export { MODEL_FAILURE_CODES, isModelFailureOutcome } from "./definition/model-failure.js";
19
- export { createSandboxTools, SANDBOX_INSTRUCTIONS, } from "./definition/sandbox-tools.js";
20
17
  export { SANDBOX_NETWORK_PRESETS, SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE, isSandboxHostPattern, isSandboxToolName, parseSandboxDuration, parseSandboxSize, } from "./utils/sandbox.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";
18
+ export { SKILL_ENTRY, SKILL_TOTAL_BYTES_DEFAULT, SKILL_FILE_PATH_MAX, SKILLS_MOUNT, definitionFilesOf, skillsOf, skillFolderOf, isDefinitionFileHash, skillFilePathIssue, skillFilesIssue, skillInstructions, } from "./utils/definition-files.js";
23
19
  export { normalizeToolDefinition, normalizedSchemasFor, } from "./definition/schema.js";
24
20
  export { implementationsFor, bindingFromAgent } from "./definition/binding.js";
25
21
  export { VerdictSchema, isVerdict, WorkflowBuildError, isBuiltWorkflow, } from "./definition/workflow/index.js";
@@ -27,7 +23,8 @@ export { isVariantOf } from "./definition/variant.js";
27
23
  export { bindTool } from "./definition/bind-tool.js";
28
24
  export { bindOutputContract } from "./definition/output-contract.js";
29
25
  export { agentFrom } from "./definition/from.js";
30
- export { mediaReferenceLine, mediaReferenceOf, } from "./definition/media-reference.js";
26
+ export { harnessIdOf, harnessSectionOf, isWorkflowHarness, kindMeets, loopManifestOf, normalizeCredentialUrl, pluginsOf, runtimeOf, sandboxNeedOf, sectionGaps, } from "./definition/sections.js";
27
+ export { mediaReferenceOf } from "./definition/media-reference.js";
31
28
  export { schemaFromJSON } from "./definition/schema-json.js";
32
29
  export { normalizeSchema } from "./definition/schema.js";
33
30
  export * from "./utils/immutable.js";
@@ -1,6 +1,6 @@
1
1
  import type { DefinitionPart } from "./bound.js";
2
2
  import type { BuiltAgent } from "../types/agent.js";
3
- import type { AgentManifest, AgentRequirements, RuntimeManifest } from "../types/manifest.js";
3
+ import type { AgentManifest, AgentRequirements } from "../types/manifest.js";
4
4
  import type { BuildDiagnostic, JsonObject } from "../types/shared.js";
5
5
  import type { ToolSchemaSource } from "../types/tool.js";
6
6
  type BuildResult<Agent> = {
@@ -18,7 +18,5 @@ export declare function assembleAgent(parts: readonly DefinitionPart[], identity
18
18
  metadata?: JsonObject;
19
19
  outputSchema?: ToolSchemaSource;
20
20
  requires?: AgentRequirements;
21
- /** A pinned manifest's `runtime` block, kept as it was (`agentFrom`). */
22
- runtime?: RuntimeManifest;
23
21
  }>): BuildResult<BuiltAgent>;
24
22
  export {};
@@ -1,7 +1,6 @@
1
1
  import { bindAgent } from "./bind-agent.js";
2
- import { createManifest, RUNTIME_PART_ID } from "./manifest.js";
2
+ import { createManifest, SESSION_PART_ID } from "./manifest.js";
3
3
  import { DELEGATE_NAME_PATTERN, delegateOf, delegatesOf } from "./delegate.js";
4
- import { isRuntimeToolName } from "../utils/runtime-tools.js";
5
4
  const diagnostic = (code, message, extra = {}) => Object.freeze({ code, message, ...extra });
6
5
  export function assembleAgent(parts, identity) {
7
6
  const diagnostics = [];
@@ -33,9 +32,7 @@ export function assembleAgent(parts, identity) {
33
32
  toolName: entry.name,
34
33
  }));
35
34
  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("__"))
35
+ if (item.id !== SESSION_PART_ID && entry.name.includes("__"))
39
36
  diagnostics.push(diagnostic("tool.invalid-name", `Tool '${entry.name}' must not contain '__', which names an MCP server's tools`, { toolName: entry.name }));
40
37
  }
41
38
  diagnostics.push(...nameDiagnostics(frozen, "skills", "skill.duplicate-name", "skill"));
@@ -55,7 +52,6 @@ export function assembleAgent(parts, identity) {
55
52
  metadata: identity.metadata,
56
53
  outputSchema: identity.outputSchema,
57
54
  requires: identity.requires,
58
- runtime: identity.runtime,
59
55
  parts: frozenParts,
60
56
  });
61
57
  const agent = bindAgent(frozenParts, manifest, identity);
@@ -101,8 +97,8 @@ function delegationDiagnostics(items) {
101
97
  }
102
98
  /**
103
99
  * 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.
100
+ * Runtime keeps its spec on the session. A part that still carries `sandbox` fails the build
101
+ * instead of being silently dropped.
106
102
  */
107
103
  function sandboxDiagnostics(items) {
108
104
  return items
@@ -15,7 +15,7 @@ export interface BoundToolDefinition<Info = unknown> extends Omit<ToolDefinition
15
15
  }
16
16
  /**
17
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
18
+ * an agent rebuilt from its manifest) what one run adds, its session part. The engine offers each part's
19
19
  * tools and instructions to the model in part order; the manifest holds the parts merged.
20
20
  */
21
21
  export interface DefinitionPart {
@@ -20,6 +20,11 @@ export interface Delegate {
20
20
  export declare function isFlowDelegate(delegate: Delegate): delegate is Delegate & {
21
21
  readonly manifest: WorkflowManifest;
22
22
  };
23
+ /**
24
+ * The longest tool name every model provider accepts (R2b C6, Q14): OpenAI's and Anthropic's
25
+ * `^[a-zA-Z0-9_-]{1,64}$`. A provider's ceiling, not a setting.
26
+ */
27
+ export declare const MODEL_TOOL_NAME_MAX = 64;
23
28
  /** Model-facing tool names: what every supported provider accepts. */
24
29
  export declare const DELEGATE_NAME_PATTERN: RegExp;
25
30
  /** The input every agent used as a tool accepts. Part of the hashed manifest; change deliberately. */
@@ -8,8 +8,13 @@ const DELEGATE = Symbol.for("@nylorun/core/delegate");
8
8
  export function isFlowDelegate(delegate) {
9
9
  return delegate.manifest.kind === "workflow";
10
10
  }
11
+ /**
12
+ * The longest tool name every model provider accepts (R2b C6, Q14): OpenAI's and Anthropic's
13
+ * `^[a-zA-Z0-9_-]{1,64}$`. A provider's ceiling, not a setting.
14
+ */
15
+ export const MODEL_TOOL_NAME_MAX = 64;
11
16
  /** Model-facing tool names: what every supported provider accepts. */
12
- export const DELEGATE_NAME_PATTERN = /^[A-Za-z0-9_-]{1,64}$/;
17
+ export const DELEGATE_NAME_PATTERN = new RegExp(`^[A-Za-z0-9_-]{1,${MODEL_TOOL_NAME_MAX}}$`);
13
18
  const taskSchema = z
14
19
  .object({
15
20
  task: z
@@ -13,9 +13,11 @@ export interface SessionToolRef {
13
13
  }
14
14
  /**
15
15
  * Rebuild an agent from its manifest and the code of its tools, by name (T28). Agents used as
16
- * tools and HTTP tools need no code; neither do the tools in `runtime`, which the Runtime serves.
17
- * A session tool (`sessionTools`) is offered with the `runtime` part and needs its code.
16
+ * tools and HTTP tools need no code. A session tool (`sessionTools`) is offered in the session
17
+ * part, after the agent's own, with `sessionInstructions` (text not tied to one tool) before its
18
+ * tools' own; it needs its code, and its name may not be one of the agent's tools.
18
19
  */
19
20
  export declare function agentFrom<Info = unknown>(json: AgentManifest | JsonObject, implementations: Implementations<Info>, options?: {
20
21
  readonly sessionTools?: readonly SessionToolRef[];
22
+ readonly sessionInstructions?: readonly string[];
21
23
  }): BuiltAgent<Info>;
@@ -4,13 +4,13 @@ import { schemaFromJSON } from "./schema-json.js";
4
4
  import { assertJson, deepFreeze } from "../utils/immutable.js";
5
5
  import { delegateFromManifest, delegateOf } from "./delegate.js";
6
6
  import { httpToolFromManifest, httpToolOf } from "./http-tool.js";
7
- import { RUNTIME_PART_ID } from "./manifest.js";
8
- import { ToolError } from "./tool-error.js";
7
+ import { SESSION_PART_ID } from "./manifest.js";
9
8
  import { AgentManifestSchema } from "../contracts.js";
10
9
  /**
11
10
  * 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.
11
+ * tools and HTTP tools need no code. A session tool (`sessionTools`) is offered in the session
12
+ * part, after the agent's own, with `sessionInstructions` (text not tied to one tool) before its
13
+ * tools' own; it needs its code, and its name may not be one of the agent's tools.
14
14
  */
15
15
  export function agentFrom(json, implementations, options) {
16
16
  const manifest = normalizeManifest(json);
@@ -30,22 +30,20 @@ export function agentFrom(json, implementations, options) {
30
30
  ...(manifest.skills === undefined ? {} : { skills: manifest.skills }),
31
31
  ...(manifest.mcpServers === undefined ? {} : { mcpServers: manifest.mcpServers }),
32
32
  }));
33
- const runtime = manifest.runtime;
34
33
  const session = sessionTools.map((item) => {
35
34
  const live = code[item.name];
36
35
  if (!live)
37
36
  throw new HarnessError("agent.build-failed", `Missing session tool implementation '${item.name}'`);
38
37
  return live;
39
38
  });
40
- const sessionInstructions = sessionTools.flatMap((item) => item.instructions ?? []);
41
- if (runtime !== undefined || session.length > 0)
39
+ const sessionInstructions = [
40
+ ...(options?.sessionInstructions ?? []),
41
+ ...sessionTools.flatMap((item) => item.instructions ?? []),
42
+ ];
43
+ if (session.length > 0 || sessionInstructions.length > 0)
42
44
  parts.push(Object.freeze({
43
- id: RUNTIME_PART_ID,
44
- ...(runtime?.tools === undefined
45
- ? {}
46
- : { tools: runtime.tools.map((declared) => code[declared.name] ?? runtimeTool(declared)) }),
45
+ id: SESSION_PART_ID,
47
46
  ...(session.length === 0 ? {} : { sessionTools: session }),
48
- ...(runtime?.instructions === undefined ? {} : { instructions: runtime.instructions }),
49
47
  ...(sessionInstructions.length === 0 ? {} : { sessionInstructions }),
50
48
  }));
51
49
  const outputSchema = manifest.outputSchema
@@ -58,17 +56,13 @@ export function agentFrom(json, implementations, options) {
58
56
  metadata: manifest.metadata,
59
57
  outputSchema,
60
58
  ...(manifest.requires === undefined ? {} : { requires: manifest.requires }),
61
- runtime: manifest.runtime,
62
59
  });
63
60
  if (!result.ok)
64
61
  throw new HarnessError("agent.build-failed", result.diagnostics.map((item) => item.message).join("; "));
65
62
  return result.agent;
66
63
  }
67
64
  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
- ]);
65
+ const taken = new Set((manifest.tools ?? []).map((tool) => tool.name));
72
66
  const seen = new Set();
73
67
  for (const item of sessionTools) {
74
68
  if (seen.has(item.name))
@@ -94,18 +88,6 @@ function authoredTool(declared, live) {
94
88
  return live;
95
89
  throw new HarnessError("agent.build-failed", `Missing tool implementation '${declared.name}'`);
96
90
  }
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
- },
107
- });
108
- }
109
91
  /**
110
92
  * The manifest as `AgentManifestSchema` accepts it (the Runtime's own check), as a frozen copy.
111
93
  * A refusal is `agent.build-failed` with the schema's messages.
@@ -19,10 +19,12 @@ export declare const HTTP_TOOL_METHODS: readonly ["GET", "POST", "PUT", "PATCH",
19
19
  /** The methods that send the input as a JSON body; the others send it as the query string. */
20
20
  export declare const HTTP_BODY_METHODS: readonly ["POST", "PUT", "PATCH"];
21
21
  export declare const APPROVAL_MODES: readonly ["never", "always"];
22
- /** How long a service may take to answer when the tool sets no `timeoutMs`. */
22
+ /**
23
+ * The default of a tool's `timeoutMs` setting: how long a service may take to answer when the
24
+ * tool sets none. The longest a tool may set is the Tenant's Runtime limit `httpToolTimeoutMs`,
25
+ * checked when the agent is deployed and when the tool is called.
26
+ */
23
27
  export declare const HTTP_TOOL_DEFAULT_TIMEOUT_MS = 60000;
24
- /** The longest `timeoutMs` a tool may set. */
25
- export declare const HTTP_TOOL_MAX_TIMEOUT_MS = 300000;
26
28
  /** What an HTTP tool puts in its manifest entry besides its name and schemas. */
27
29
  export interface HttpTool {
28
30
  readonly http: HttpToolTarget;
@@ -3,6 +3,7 @@ import { HarnessError } from "../errors.js";
3
3
  import { ToolError } from "./tool-error.js";
4
4
  import { normalizedSchemasFor, prepareTool } from "./schema.js";
5
5
  import { schemaFromJSON } from "./schema-json.js";
6
+ import { TIMER_MAX_MS } from "../utils/runtime-limits.js";
6
7
  /** Survives duplicate installed copies of core, like the delegate brand. */
7
8
  const HTTP = Symbol.for("@nylorun/core/http-tool");
8
9
  const TARGET = Symbol.for("@nylorun/core/http-target");
@@ -10,10 +11,12 @@ export const HTTP_TOOL_METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
10
11
  /** The methods that send the input as a JSON body; the others send it as the query string. */
11
12
  export const HTTP_BODY_METHODS = ["POST", "PUT", "PATCH"];
12
13
  export const APPROVAL_MODES = ["never", "always"];
13
- /** How long a service may take to answer when the tool sets no `timeoutMs`. */
14
+ /**
15
+ * The default of a tool's `timeoutMs` setting: how long a service may take to answer when the
16
+ * tool sets none. The longest a tool may set is the Tenant's Runtime limit `httpToolTimeoutMs`,
17
+ * checked when the agent is deployed and when the tool is called.
18
+ */
14
19
  export const HTTP_TOOL_DEFAULT_TIMEOUT_MS = 60_000;
15
- /** The longest `timeoutMs` a tool may set. */
16
- export const HTTP_TOOL_MAX_TIMEOUT_MS = 300_000;
17
20
  export function http(options) {
18
21
  if (!("name" in options) && !("input" in options))
19
22
  return httpTarget(options);
@@ -101,8 +104,8 @@ export function httpTargetIssue(target) {
101
104
  if (target.credential !== undefined && (typeof target.credential !== "string" || target.credential === ""))
102
105
  return "credential must be a non-empty name";
103
106
  if (target.timeoutMs !== undefined &&
104
- (!Number.isInteger(target.timeoutMs) || target.timeoutMs <= 0 || target.timeoutMs > HTTP_TOOL_MAX_TIMEOUT_MS))
105
- return `timeoutMs must be a positive integer of at most ${HTTP_TOOL_MAX_TIMEOUT_MS}`;
107
+ (!Number.isInteger(target.timeoutMs) || target.timeoutMs <= 0 || target.timeoutMs > TIMER_MAX_MS))
108
+ return `timeoutMs must be a positive integer of at most ${TIMER_MAX_MS}`;
106
109
  return undefined;
107
110
  }
108
111
  /** Why `url` is not an HTTP tool's URL, or undefined. */
@@ -1,13 +1,15 @@
1
1
  import type { DefinitionPart } from "./bound.js";
2
- import type { AgentManifest, AgentRequirements, RuntimeManifest } from "../types/manifest.js";
2
+ import type { AgentManifest, AgentRequirements } 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";
5
+ /**
6
+ * The id of the part an agent rebuilt from its manifest gets for what one run adds to it: the
7
+ * session's tools and the text that goes with them (`agentFrom` `sessionTools`). Not hashed.
8
+ */
9
+ export declare const SESSION_PART_ID = "session";
7
10
  /**
8
11
  * 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.
12
+ * the skills and servers keyed by name. The session part is not projected.
11
13
  */
12
14
  export declare function createManifest(input: {
13
15
  id: string;
@@ -16,6 +18,5 @@ export declare function createManifest(input: {
16
18
  metadata?: JsonObject;
17
19
  outputSchema?: ToolSchemaSource;
18
20
  requires?: AgentRequirements;
19
- runtime?: RuntimeManifest;
20
21
  parts: readonly DefinitionPart[];
21
22
  }): AgentManifest;
@@ -3,15 +3,17 @@ import { normalizedSchemasFor } from "./schema.js";
3
3
  import { delegateOf } from "./delegate.js";
4
4
  import { httpToolOf } from "./http-tool.js";
5
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";
6
+ /**
7
+ * The id of the part an agent rebuilt from its manifest gets for what one run adds to it: the
8
+ * session's tools and the text that goes with them (`agentFrom` `sessionTools`). Not hashed.
9
+ */
10
+ export const SESSION_PART_ID = "session";
8
11
  /**
9
12
  * 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.
13
+ * the skills and servers keyed by name. The session part is not projected.
12
14
  */
13
15
  export function createManifest(input) {
14
- const authored = input.parts.filter((part) => part.id !== RUNTIME_PART_ID);
16
+ const authored = input.parts.filter((part) => part.id !== SESSION_PART_ID);
15
17
  const instructions = authored.flatMap((part) => part.instructions ?? []);
16
18
  const tools = authored.flatMap((part) => (part.tools ?? []).map((tool) => projectTool(tool)));
17
19
  const skills = {};
@@ -41,7 +43,6 @@ export function createManifest(input) {
41
43
  ...(Object.keys(skills).length === 0 ? {} : { skills }),
42
44
  ...(Object.keys(mcpServers).length === 0 ? {} : { mcpServers }),
43
45
  ...(input.requires === undefined ? {} : { requires: copyRequirements(input.requires) }),
44
- ...(input.runtime === undefined ? {} : { runtime: input.runtime }),
45
46
  });
46
47
  }
47
48
  /** `requires` as plain data, its secret names sorted and each once. */
@@ -20,7 +20,7 @@ export declare const MCP_TOOL_DEFAULTS = "*";
20
20
  export interface ResolvedMcpToolSettings {
21
21
  readonly enabled: boolean;
22
22
  readonly approval: ApprovalMode;
23
- /** Undefined: nothing sets it, and the Runtime decides (R2b C10, automatic deferral). */
23
+ /** Undefined: nothing sets it, and the harness decides (R2b C10, automatic deferral). */
24
24
  readonly deferred?: boolean;
25
25
  }
26
26
  /**
@@ -1,7 +1,8 @@
1
1
  import type { JsonValue } from "../types/shared.js";
2
2
  /**
3
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.
4
+ * version, by id, with the file's name and size in bytes when known. The Model Gate fetches it,
5
+ * and a harness reads it to decide how the model sees the file (protocol 15).
5
6
  */
6
7
  export interface MediaReference {
7
8
  readonly artifactId: string;
@@ -11,13 +12,3 @@ export interface MediaReference {
11
12
  }
12
13
  /** The reference of a media part the Runtime made, or undefined for another host's. */
13
14
  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;
@@ -12,15 +12,3 @@ export function mediaReferenceOf(value) {
12
12
  ...(typeof size === "number" ? { size } : {}),
13
13
  };
14
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
- }
@@ -8,6 +8,7 @@ export const MODEL_FAILURE_CODES = Object.freeze([
8
8
  "auth",
9
9
  "invalid_request",
10
10
  "invalid_output",
11
+ "unsupported_input",
11
12
  "budget_exhausted",
12
13
  ]);
13
14
  /** True for a model adapter's failure outcome (`{ kind: "failed", code, message, retryable }`). */
@@ -6,3 +6,10 @@ export declare const REMOVED_MANIFEST_FIELDS: Readonly<Record<string, string>>;
6
6
  export declare function manifestVersionIssue(version: unknown): string | undefined;
7
7
  /** Why a workflow manifest with this `workflowSchemaVersion` is refused, or undefined for version 3. */
8
8
  export declare function workflowVersionIssue(version: unknown): string | undefined;
9
+ /**
10
+ * Why an agent manifest with this `manifestSchemaVersion` is refused at
11
+ * `/v1/agent-manifests/{name}` (protocol 16), or undefined for version 8.
12
+ */
13
+ export declare function agentManifestVersionIssue(version: unknown): string | undefined;
14
+ /** Fields an environment manifest had that the runtime section of agent manifest v8 refuses. */
15
+ export declare const REMOVED_RUNTIME_SECTION_FIELDS: Readonly<Record<string, string>>;
@@ -9,6 +9,7 @@ export const REMOVED_MANIFEST_FIELDS = Object.freeze({
9
9
  model: "Manifest must not include top-level model; Runtime owns model resolution",
10
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
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)",
12
+ runtime: "This is a pre-v8 runtime block: since protocol 15 the harness writes the model's instructions and defines the sandbox and skill tools. In agent manifest v8, runtime is a top-level section beside harness and says what the Runtime provides (see MIGRATION.md)",
12
13
  });
13
14
  /** Why a manifest with this `manifestSchemaVersion` is refused, or undefined for version 7. */
14
15
  export function manifestVersionIssue(version) {
@@ -26,3 +27,23 @@ export function workflowVersionIssue(version) {
26
27
  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)`;
27
28
  return `Unsupported workflowSchemaVersion ${String(version)}`;
28
29
  }
30
+ /**
31
+ * Why an agent manifest with this `manifestSchemaVersion` is refused at
32
+ * `/v1/agent-manifests/{name}` (protocol 16), or undefined for version 8.
33
+ */
34
+ export function agentManifestVersionIssue(version) {
35
+ if (version === 8)
36
+ return undefined;
37
+ if (version === 7)
38
+ return "manifestSchemaVersion 7 is no longer saved: agent manifest v8 holds a harness and a runtime section. Rebuild it with nylorun migrate v8 (see MIGRATION.md)";
39
+ if (typeof version === "number" && version >= 3 && version <= 6)
40
+ return `manifestSchemaVersion ${version} is no longer supported. Rebuild the agent with the current SDK, then run nylorun migrate v8 (see MIGRATION.md)`;
41
+ return `Unsupported manifestSchemaVersion ${String(version)}: use 8`;
42
+ }
43
+ /** Fields an environment manifest had that the runtime section of agent manifest v8 refuses. */
44
+ export const REMOVED_RUNTIME_SECTION_FIELDS = Object.freeze({
45
+ harness: "runtime.harness moved to harness.id in agent manifest v8: the harness section names the harness that runs the loop",
46
+ manifestSchemaVersion: "manifestSchemaVersion belongs at the top of the agent manifest, not in runtime",
47
+ name: "name belongs at the top of the agent manifest, not in runtime",
48
+ description: "description belongs at the top of the agent manifest, not in runtime",
49
+ });
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Agent manifest v8's two sections against each other (protocol 16, track T2). The Runtime sees
3
+ * both sections when a manifest is saved, so it checks there what `requires` used to check when a
4
+ * session opened: every gap is named in one `422 manifest_inconsistent`, and a dry run reports
5
+ * them as plan errors. The CLI and the SDK run the same checks while they compose the files.
6
+ */
7
+ import type { AgentManifestV8, RuntimeSection } from "../contracts.js";
8
+ import type { AgentHarnessSection, AgentManifest, HarnessSection, WorkflowHarnessSection } from "../types/manifest.js";
9
+ import type { WorkflowManifest } from "../types/workflow.js";
10
+ /** What the loop needs of the runtime: a pod, any sandbox (`virtual` or `pod`), or nothing. */
11
+ export type SandboxNeed = "pod" | "sandbox" | "none";
12
+ export declare function isWorkflowHarness(harness: HarnessSection): harness is WorkflowHarnessSection;
13
+ /** The harness that runs the loop: `harness.id`, else ours. */
14
+ export declare function harnessIdOf(harness: HarnessSection): string;
15
+ /**
16
+ * What the harness section needs of the runtime, derived rather than declared: a custom harness
17
+ * needs a pod (it runs from the pod's image); skills need a sandbox to be mounted in; otherwise
18
+ * nothing.
19
+ */
20
+ export declare function sandboxNeedOf(harness: HarnessSection): SandboxNeed;
21
+ /** Whether a runtime of `kind` gives the loop what it needs. */
22
+ export declare function kindMeets(kind: RuntimeSection["kind"], need: SandboxNeed): boolean;
23
+ /**
24
+ * A credential URL as the vault compares it: origin, path and query, with the default port and
25
+ * no fragment. Undefined for a URL the vault would refuse. The vault binds a `bearer` or
26
+ * `headers` credential to one URL and sends it to a server or HTTP tool declared at exactly that
27
+ * URL, so a slot covers a server when the two normalize the same.
28
+ */
29
+ export declare function normalizeCredentialUrl(input: string): string | undefined;
30
+ /** The runtime section an Agent made from `manifest` has: `kind: "none"` when it is absent. */
31
+ export declare function runtimeOf(manifest: Pick<AgentManifestV8, "runtime">): RuntimeSection;
32
+ /**
33
+ * Every gap between the harness and runtime sections, worded for a person, in the manifest's
34
+ * order. Empty when they fit:
35
+ *
36
+ * 1. A custom harness (`harness.id` not `nylorun`) needs `runtime.kind` `pod` with an `image`.
37
+ * 2. Every credential the harness names is a declared slot of the right type: an MCP server's or
38
+ * HTTP tool's `credential` a `bearer` or `headers` slot bound to its URL, a skill's `secrets`
39
+ * `environment_secret` or `environment_variable` slots.
40
+ * 3. The runtime's kind gives the harness the sandbox it needs (`sandboxNeedOf`).
41
+ */
42
+ export declare function sectionGaps(manifest: Pick<AgentManifestV8, "harness" | "runtime">): string[];
43
+ /**
44
+ * The loop manifest the harness runs for a version of an agent manifest: the harness section
45
+ * with the manifest's name as its id, in the shape the engine reads (agent manifest v7, workflow
46
+ * manifest v3). The fields only the Runtime reads (`credential`, a skill's `secrets`, `plugins`,
47
+ * `loop`, the harness id) stay out.
48
+ */
49
+ export declare function loopManifestOf(manifest: Pick<AgentManifestV8, "name" | "description" | "metadata" | "harness">): AgentManifest | WorkflowManifest;
50
+ /**
51
+ * The harness section a loop manifest makes (an SDK-built agent or flow, or a v7 manifest being
52
+ * migrated): its loop fields, without its identity, which the agent manifest holds. A v7
53
+ * manifest's `requires.secrets` become no skill's: the composer asks for them by name.
54
+ */
55
+ export declare function harnessSectionOf(loop: AgentManifest | WorkflowManifest, options?: {
56
+ harness?: string;
57
+ plugins?: AgentHarnessSection["plugins"];
58
+ }): HarnessSection;
59
+ /** The Agent Plugins whose labels a loop manifest's skills and servers carry, each once, by name. */
60
+ export declare function pluginsOf(loop: AgentManifest | WorkflowManifest): {
61
+ name: string;
62
+ version?: string;
63
+ }[];