@nylorun/core 0.22.0-beta → 0.23.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.
- package/CHANGELOG.md +102 -0
- package/README.md +1 -1
- package/dist/compatibility.d.ts +32 -16
- package/dist/compatibility.js +33 -17
- package/dist/contracts.d.ts +531 -88
- package/dist/contracts.js +297 -199
- package/dist/define.d.ts +8 -12
- package/dist/define.js +7 -11
- package/dist/definition/assemble.d.ts +1 -3
- package/dist/definition/assemble.js +4 -8
- package/dist/definition/bound.d.ts +1 -1
- package/dist/definition/delegate.d.ts +5 -0
- package/dist/definition/delegate.js +6 -1
- package/dist/definition/from.d.ts +4 -2
- package/dist/definition/from.js +11 -29
- package/dist/definition/http-tool.d.ts +5 -3
- package/dist/definition/http-tool.js +8 -5
- package/dist/definition/manifest.d.ts +7 -6
- package/dist/definition/manifest.js +7 -6
- package/dist/definition/mcp.d.ts +1 -1
- package/dist/definition/media-reference.d.ts +2 -11
- package/dist/definition/media-reference.js +0 -12
- package/dist/definition/model-failure.js +1 -0
- package/dist/definition/removed.js +1 -0
- package/dist/definition/trace.d.ts +0 -7
- package/dist/definition/trace.js +0 -34
- package/dist/definition/variant.d.ts +1 -1
- package/dist/definition/variant.js +1 -3
- package/dist/harness-api/artifacts.d.ts +84 -0
- package/dist/harness-api/artifacts.js +128 -0
- package/dist/harness-api/gates.d.ts +0 -4
- package/dist/harness-api/gates.js +0 -4
- package/dist/harness-api/harness-api.schema.json +2422 -924
- package/dist/harness-api/index.d.ts +9 -6
- package/dist/harness-api/index.js +9 -6
- package/dist/harness-api/json-schema.js +5 -2
- package/dist/harness-api/mcp.d.ts +77 -30
- package/dist/harness-api/mcp.js +42 -25
- package/dist/harness-api/messages.d.ts +45 -17
- package/dist/harness-api/messages.js +20 -5
- package/dist/harness-api/schema.d.ts +538 -198
- package/dist/harness-api/schema.js +298 -59
- package/dist/harness-api/transcript.d.ts +8 -10
- package/dist/harness-api/transcript.js +27 -11
- package/dist/harness-api/transport.d.ts +7 -1
- package/dist/harness-api/transport.js +10 -7
- package/dist/schemas/agent-manifest.schema.json +5 -146
- package/dist/schemas/environment-manifest.schema.json +56 -16
- package/dist/types/manifest.d.ts +3 -13
- package/dist/types/model.d.ts +10 -5
- package/dist/utils/definition-files.d.ts +20 -6
- package/dist/utils/definition-files.js +31 -17
- package/dist/utils/file-systems.d.ts +20 -0
- package/dist/utils/file-systems.js +20 -0
- package/dist/utils/harness-id.d.ts +4 -1
- package/dist/utils/harness-id.js +4 -1
- package/dist/utils/media-types.d.ts +30 -0
- package/dist/utils/media-types.js +128 -0
- package/dist/utils/runtime-limits.d.ts +229 -0
- package/dist/utils/runtime-limits.js +482 -0
- package/dist/utils/runtime-tools.d.ts +8 -16
- package/dist/utils/runtime-tools.js +8 -27
- package/dist/utils/sandbox.d.ts +4 -1
- package/dist/utils/sandbox.js +4 -1
- package/package.json +1 -1
- package/dist/definition/deferred-tools.d.ts +0 -27
- package/dist/definition/deferred-tools.js +0 -82
- package/dist/definition/runtime-manifest.d.ts +0 -30
- package/dist/definition/runtime-manifest.js +0 -132
- package/dist/definition/sandbox-tools.d.ts +0 -5
- package/dist/definition/sandbox-tools.js +0 -109
- package/dist/definition/skill-tools.d.ts +0 -23
- 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,
|
|
10
|
-
export {
|
|
11
|
-
export {
|
|
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,
|
|
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 {
|
|
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,
|
|
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,7 @@ 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 {
|
|
47
|
+
export { mediaReferenceOf, type MediaReference } from "./definition/media-reference.js";
|
|
52
48
|
export type { SessionToolRef } from "./definition/from.js";
|
|
53
49
|
export { schemaFromJSON } from "./definition/schema-json.js";
|
|
54
50
|
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,
|
|
6
|
-
export {
|
|
7
|
-
export {
|
|
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
|
|
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 {
|
|
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,7 @@ 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 {
|
|
26
|
+
export { mediaReferenceOf } from "./definition/media-reference.js";
|
|
31
27
|
export { schemaFromJSON } from "./definition/schema-json.js";
|
|
32
28
|
export { normalizeSchema } from "./definition/schema.js";
|
|
33
29
|
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
|
|
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,
|
|
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 !==
|
|
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
|
|
105
|
-
*
|
|
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
|
|
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 =
|
|
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
|
|
17
|
-
*
|
|
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>;
|
package/dist/definition/from.js
CHANGED
|
@@ -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 {
|
|
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
|
|
13
|
-
*
|
|
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 =
|
|
41
|
-
|
|
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:
|
|
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
|
-
/**
|
|
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
|
-
/**
|
|
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 >
|
|
105
|
-
return `timeoutMs must be a positive integer of at most ${
|
|
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
|
|
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
|
-
/**
|
|
6
|
-
|
|
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
|
|
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
|
-
/**
|
|
7
|
-
|
|
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
|
|
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 !==
|
|
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. */
|
package/dist/definition/mcp.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
}
|
|
@@ -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: "Manifest field runtime was removed: since protocol 15 the harness writes the model's instructions and defines the sandbox and skill tools. Register the manifest your builder makes (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) {
|
|
@@ -4,13 +4,6 @@ export interface ToolCallTrace {
|
|
|
4
4
|
readonly skill?: string;
|
|
5
5
|
readonly plugin?: PluginLabel;
|
|
6
6
|
}
|
|
7
|
-
/**
|
|
8
|
-
* The skill of `manifest` a tool call ran. `load_skill` and `read_skill_resource` name it in their
|
|
9
|
-
* input. A sandbox tool (`bash`, `read`, `grep`, `glob`, …) is matched on the skills' mount path,
|
|
10
|
-
* `/skills/<name>@<hash>/` (or `/skills/<name>/`, before D66), in its input's text: exact for a path argument, and for `bash` only when the
|
|
11
|
-
* command names the path. The first skill of the agent the input names wins.
|
|
12
|
-
*/
|
|
13
|
-
export declare function skillOfToolCall(manifest: Pick<AgentManifest, "skills"> | undefined, toolName: string | undefined, input: unknown): string | undefined;
|
|
14
7
|
/** The plugin that brought the skill or MCP server `name` to `manifest`, if one did. */
|
|
15
8
|
export declare function pluginOf(manifest: Pick<AgentManifest, "skills" | "mcpServers"> | undefined, what: {
|
|
16
9
|
readonly skill?: string;
|
package/dist/definition/trace.js
CHANGED
|
@@ -1,29 +1,3 @@
|
|
|
1
|
-
import { SKILLS_MOUNT } from "../utils/definition-files.js";
|
|
2
|
-
import { isSandboxToolName } from "../utils/sandbox.js";
|
|
3
|
-
import { SKILL_TOOL_NAMES } from "./skill-tools.js";
|
|
4
|
-
const MOUNT = new RegExp(`${SKILLS_MOUNT}/([^/@\\s"'\`]+)(?:@[0-9a-f]{12})?/`, "g");
|
|
5
|
-
/**
|
|
6
|
-
* The skill of `manifest` a tool call ran. `load_skill` and `read_skill_resource` name it in their
|
|
7
|
-
* input. A sandbox tool (`bash`, `read`, `grep`, `glob`, …) is matched on the skills' mount path,
|
|
8
|
-
* `/skills/<name>@<hash>/` (or `/skills/<name>/`, before D66), in its input's text: exact for a path argument, and for `bash` only when the
|
|
9
|
-
* command names the path. The first skill of the agent the input names wins.
|
|
10
|
-
*/
|
|
11
|
-
export function skillOfToolCall(manifest, toolName, input) {
|
|
12
|
-
const skills = manifest?.skills;
|
|
13
|
-
if (!skills || toolName === undefined)
|
|
14
|
-
return undefined;
|
|
15
|
-
if (SKILL_TOOL_NAMES.has(toolName)) {
|
|
16
|
-
const name = input?.name;
|
|
17
|
-
return typeof name === "string" && skills[name] !== undefined ? name : undefined;
|
|
18
|
-
}
|
|
19
|
-
if (!isSandboxToolName(toolName))
|
|
20
|
-
return undefined;
|
|
21
|
-
for (const text of strings(input))
|
|
22
|
-
for (const match of text.matchAll(MOUNT))
|
|
23
|
-
if (skills[match[1]] !== undefined)
|
|
24
|
-
return match[1];
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
1
|
/** The plugin that brought the skill or MCP server `name` to `manifest`, if one did. */
|
|
28
2
|
export function pluginOf(manifest, what) {
|
|
29
3
|
if (what.skill !== undefined)
|
|
@@ -32,11 +6,3 @@ export function pluginOf(manifest, what) {
|
|
|
32
6
|
return manifest?.mcpServers?.[what.server]?.plugin;
|
|
33
7
|
return undefined;
|
|
34
8
|
}
|
|
35
|
-
/** The string values of a tool's input, one level deep: its path, pattern or command. */
|
|
36
|
-
function strings(input) {
|
|
37
|
-
if (typeof input === "string")
|
|
38
|
-
return [input];
|
|
39
|
-
if (!input || typeof input !== "object")
|
|
40
|
-
return [];
|
|
41
|
-
return Object.values(input).filter((value) => typeof value === "string");
|
|
42
|
-
}
|
|
@@ -4,6 +4,6 @@ import type { AgentManifest } from "../types/manifest.js";
|
|
|
4
4
|
* (`loops.md` §3.4). A variant may remove tools (agents used as tools and HTTP tools included),
|
|
5
5
|
* tighten its MCP servers' tool settings (R2b C9, Q18), and change its instructions, name,
|
|
6
6
|
* description and metadata. Its skills and servers are setup: the sandbox holds the skills from
|
|
7
|
-
* the session's start.
|
|
7
|
+
* the session's start.
|
|
8
8
|
*/
|
|
9
9
|
export declare function isVariantOf(candidate: AgentManifest, pinned: AgentManifest): boolean;
|
|
@@ -58,15 +58,13 @@ function tightensServers(pinned, candidate) {
|
|
|
58
58
|
* (`loops.md` §3.4). A variant may remove tools (agents used as tools and HTTP tools included),
|
|
59
59
|
* tighten its MCP servers' tool settings (R2b C9, Q18), and change its instructions, name,
|
|
60
60
|
* description and metadata. Its skills and servers are setup: the sandbox holds the skills from
|
|
61
|
-
* the session's start.
|
|
61
|
+
* the session's start.
|
|
62
62
|
*/
|
|
63
63
|
export function isVariantOf(candidate, pinned) {
|
|
64
64
|
if (candidate.id !== pinned.id)
|
|
65
65
|
return false;
|
|
66
66
|
if (candidate.manifestSchemaVersion !== pinned.manifestSchemaVersion)
|
|
67
67
|
return false;
|
|
68
|
-
if (candidate.runtime !== undefined)
|
|
69
|
-
return false;
|
|
70
68
|
if (!same(candidate.outputSchema, pinned.outputSchema))
|
|
71
69
|
return false;
|
|
72
70
|
// What the agent needs of its Environment was checked when the session opened (D65).
|