@nylorun/harness 0.30.1-beta → 0.31.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 +34 -0
- package/dist/api/host.js +13 -0
- package/dist/api/run.js +29 -4
- package/dist/loop/compaction/index.js +11 -8
- package/dist/loop/delegation.d.ts +2 -0
- package/dist/loop/delegation.js +9 -2
- package/dist/loop/model/files.d.ts +8 -2
- package/dist/loop/model/files.js +5 -3
- package/dist/loop/model/project.d.ts +5 -4
- package/dist/loop/model/project.js +16 -14
- package/dist/loop/step/run.js +3 -2
- package/dist/run/durable.d.ts +8 -18
- package/dist/run/durable.js +9 -4
- package/dist/tools/artifacts.d.ts +5 -3
- package/dist/tools/artifacts.js +13 -107
- package/dist/tools/connection.d.ts +2 -8
- package/dist/tools/connection.js +20 -39
- package/dist/tools/engine-tools.d.ts +22 -16
- package/dist/tools/engine-tools.js +6 -52
- package/dist/tools/mcp.d.ts +5 -90
- package/dist/tools/mcp.js +5 -238
- package/dist/tools/memory.d.ts +18 -5
- package/dist/tools/memory.js +4 -125
- package/dist/tools/plan.d.ts +6 -7
- package/dist/tools/plan.js +4 -48
- package/dist/tools/results.d.ts +6 -0
- package/dist/tools/results.js +3 -2
- package/dist/tools/sandbox.d.ts +13 -33
- package/dist/tools/sandbox.js +13 -127
- package/dist/tools/skills.d.ts +4 -24
- package/dist/tools/skills.js +3 -69
- package/dist/tools/tool-search.d.ts +1 -22
- package/dist/tools/tool-search.js +2 -78
- package/dist/tools/wake.d.ts +0 -7
- package/dist/tools/wake.js +10 -30
- package/package.json +2 -2
package/dist/tools/sandbox.js
CHANGED
|
@@ -1,129 +1,15 @@
|
|
|
1
|
-
/** The sandbox tools' limits when the harness sets none. */
|
|
2
|
-
export const DEFAULT_SANDBOX_TOOL_LIMITS = Object.freeze({
|
|
3
|
-
outputChars: 30_000,
|
|
4
|
-
defaultTimeoutS: 120,
|
|
5
|
-
maxTimeoutS: 600,
|
|
6
|
-
readLines: 2000,
|
|
7
|
-
maxReadLines: 5000,
|
|
8
|
-
lineChars: 2000,
|
|
9
|
-
grepResults: 200,
|
|
10
|
-
maxGrepResults: 1000,
|
|
11
|
-
globResults: 500,
|
|
12
|
-
globScan: 20_000,
|
|
13
|
-
});
|
|
14
|
-
/** The limits in force: `set`, with the default for each it leaves out. */
|
|
15
|
-
export function sandboxToolLimitsOf(set) {
|
|
16
|
-
return Object.freeze({ ...DEFAULT_SANDBOX_TOOL_LIMITS, ...definedOf(set ?? {}) });
|
|
17
|
-
}
|
|
18
|
-
function definedOf(value) {
|
|
19
|
-
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
|
|
20
|
-
}
|
|
21
|
-
const SANDBOX = Object.freeze({ kind: "sandbox" });
|
|
22
|
-
const SCHEMA = "http://json-schema.org/draft-07/schema#";
|
|
23
|
-
/** The note on the sandbox the model reads with the sandbox tools. */
|
|
24
|
-
export function sandboxInstructions(workspace) {
|
|
25
|
-
return (`You have an isolated Linux sandbox with a persistent working directory at ${workspace}. ` +
|
|
26
|
-
"Use bash to run commands, read/write/edit to work with files, and grep/glob to search. " +
|
|
27
|
-
"Network egress is limited by policy; a failed download usually means the host is not allowed.");
|
|
28
|
-
}
|
|
29
|
-
const object = (properties, required) => ({
|
|
30
|
-
$schema: SCHEMA,
|
|
31
|
-
type: "object",
|
|
32
|
-
properties,
|
|
33
|
-
required: [...required],
|
|
34
|
-
additionalProperties: false,
|
|
35
|
-
});
|
|
36
|
-
const path = { type: "string", minLength: 1 };
|
|
37
1
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
2
|
+
* Our engine's sandbox tools (protocol 15): `bash`, `read`, `write`, `edit`, `grep` and `glob`,
|
|
3
|
+
* offered to an agent of a session with a sandbox (`turn.start.agent.sandbox`), all six or those
|
|
4
|
+
* its manifest declares (ADR-100, `engine.sandbox`), with the note on the sandbox that goes with
|
|
5
|
+
* them. Our engine names, describes and instructs them (`@nylorun/core/engine`, which the SDK's
|
|
6
|
+
* `previewTurn` reads too); each call is a `sandbox` effect named by its operation, which the host
|
|
7
|
+
* runs in the session's sandbox (`executors.tool`), so the record keeps `environment.exec` and the
|
|
8
|
+
* sandbox's network policy holds.
|
|
9
|
+
*
|
|
10
|
+
* Their limits are the harness's configuration (`SandboxToolLimits`): the schema maxima and
|
|
11
|
+
* defaults the model reads here, and the same numbers where the host runs the call.
|
|
40
12
|
*/
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
name: "bash",
|
|
46
|
-
description: `Run a bash command in the sandbox. The working directory is ${workspace}. ` +
|
|
47
|
-
"Returns exitCode, stdout and stderr; a non-zero exit code is a normal result, not an error. " +
|
|
48
|
-
"Long output is truncated in the middle.",
|
|
49
|
-
inputSchema: object({
|
|
50
|
-
command: {
|
|
51
|
-
type: "string",
|
|
52
|
-
minLength: 1,
|
|
53
|
-
description: "The command line to run with bash.",
|
|
54
|
-
},
|
|
55
|
-
timeout: {
|
|
56
|
-
description: `Seconds before the command is killed. Default ${limits.defaultTimeoutS}, maximum ${limits.maxTimeoutS}.`,
|
|
57
|
-
type: "integer",
|
|
58
|
-
minimum: 1,
|
|
59
|
-
maximum: limits.maxTimeoutS,
|
|
60
|
-
},
|
|
61
|
-
}, ["command"]),
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
name: "read",
|
|
65
|
-
description: `Read a text file from the sandbox. ${relative} Returns numbered lines. ` +
|
|
66
|
-
"Use offset and limit to page through large files.",
|
|
67
|
-
inputSchema: object({
|
|
68
|
-
path,
|
|
69
|
-
offset: {
|
|
70
|
-
description: "First line to return, 1-based.",
|
|
71
|
-
type: "integer",
|
|
72
|
-
minimum: 1,
|
|
73
|
-
maximum: Number.MAX_SAFE_INTEGER,
|
|
74
|
-
},
|
|
75
|
-
limit: {
|
|
76
|
-
description: `Maximum number of lines. Default ${limits.readLines}.`,
|
|
77
|
-
type: "integer",
|
|
78
|
-
minimum: 1,
|
|
79
|
-
maximum: limits.maxReadLines,
|
|
80
|
-
},
|
|
81
|
-
}, ["path"]),
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
name: "write",
|
|
85
|
-
description: `Create or overwrite a text file in the sandbox. ${relative} Parent directories are created.`,
|
|
86
|
-
inputSchema: object({ path, content: { type: "string" } }, ["path", "content"]),
|
|
87
|
-
},
|
|
88
|
-
{
|
|
89
|
-
name: "edit",
|
|
90
|
-
description: `Replace text in a sandbox file. ${relative} old_string must match exactly and be unique ` +
|
|
91
|
-
"unless replace_all is true.",
|
|
92
|
-
inputSchema: object({
|
|
93
|
-
path,
|
|
94
|
-
old_string: { type: "string", minLength: 1 },
|
|
95
|
-
new_string: { type: "string" },
|
|
96
|
-
replace_all: { type: "boolean" },
|
|
97
|
-
}, ["path", "old_string", "new_string"]),
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
name: "grep",
|
|
101
|
-
description: `Search file contents in the sandbox with an extended regular expression. ${relative} ` +
|
|
102
|
-
"Returns matching lines as path:line:text.",
|
|
103
|
-
inputSchema: object({
|
|
104
|
-
pattern: { type: "string", minLength: 1 },
|
|
105
|
-
path: { description: `Directory or file to search. Default ${workspace}.`, ...path },
|
|
106
|
-
glob: {
|
|
107
|
-
description: 'Only search files whose name matches, e.g. "*.py".',
|
|
108
|
-
...path,
|
|
109
|
-
},
|
|
110
|
-
ignore_case: { type: "boolean" },
|
|
111
|
-
max_results: {
|
|
112
|
-
description: `Default ${limits.grepResults}.`,
|
|
113
|
-
type: "integer",
|
|
114
|
-
minimum: 1,
|
|
115
|
-
maximum: limits.maxGrepResults,
|
|
116
|
-
},
|
|
117
|
-
}, ["pattern"]),
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
name: "glob",
|
|
121
|
-
description: `Find files in the sandbox by glob pattern, e.g. "**/*.csv". ${relative} Returns matching paths.`,
|
|
122
|
-
inputSchema: object({
|
|
123
|
-
pattern: { type: "string", minLength: 1 },
|
|
124
|
-
path: { description: `Directory to search. Default ${workspace}.`, ...path },
|
|
125
|
-
}, ["pattern"]),
|
|
126
|
-
},
|
|
127
|
-
];
|
|
128
|
-
return tools.map((tool) => ({ ...tool, target: SANDBOX }));
|
|
129
|
-
}
|
|
13
|
+
export { DEFAULT_SANDBOX_TOOL_LIMITS, sandboxToolLimitsOf, sandboxTools, } from "@nylorun/core/engine";
|
|
14
|
+
/** The note on the sandbox the model reads with the sandbox tools (block `sandbox`). */
|
|
15
|
+
export { sandboxNote as sandboxInstructions } from "@nylorun/core/engine";
|
package/dist/tools/skills.d.ts
CHANGED
|
@@ -21,37 +21,18 @@
|
|
|
21
21
|
* `executors.files.mount` (`mountSkills`). The host only writes the files, and answers `present`
|
|
22
22
|
* for a folder the sandbox already holds since it last started.
|
|
23
23
|
*/
|
|
24
|
-
import { type AgentManifest
|
|
24
|
+
import { type AgentManifest } from "@nylorun/core/define";
|
|
25
25
|
import { type HarnessChannel } from "@nylorun/core/harness-api";
|
|
26
|
-
import type {
|
|
26
|
+
import type { HostEffect } from "../run/durable.js";
|
|
27
27
|
import type { FailedFileOutcome, HarnessFiles, HarnessRun } from "../api/executors.js";
|
|
28
|
-
|
|
29
|
-
export declare const LOAD_SKILL_TOOL = "load_skill";
|
|
30
|
-
/** Reads one resource file of a skill. */
|
|
31
|
-
export declare const READ_SKILL_RESOURCE_TOOL = "read_skill_resource";
|
|
32
|
-
/** The most bytes of one skill file the skill tools read into the model's context by default. */
|
|
33
|
-
export declare const DEFAULT_SKILL_READ_BYTES: number;
|
|
28
|
+
export { DEFAULT_SKILL_READ_BYTES, LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILLS_USAGE, formatSkillCatalog, skillFolderNote, skillTools, } from "@nylorun/core/engine";
|
|
34
29
|
/** True when `name` is one of our engine's skill tools. */
|
|
35
30
|
export declare function isSkillTool(name: string | undefined): boolean;
|
|
36
|
-
/**
|
|
37
|
-
export declare const SKILLS_USAGE = "The following skills provide specialized instructions. When a task matches a skill description, call load_skill with that name before proceeding.";
|
|
38
|
-
/** The skills the model may load, by name and description. */
|
|
39
|
-
export declare function formatSkillCatalog(skills: readonly {
|
|
40
|
-
readonly name: string;
|
|
41
|
-
readonly description: string;
|
|
42
|
-
}[]): string;
|
|
43
|
-
/** What the model reads of an agent's skills: when to load one, and the catalog. */
|
|
31
|
+
/** What the model reads of an agent's skills: when to load one, and the catalog (block `skills`). */
|
|
44
32
|
export declare function skillCatalogText(skills: readonly {
|
|
45
33
|
readonly name: string;
|
|
46
34
|
readonly description: string;
|
|
47
35
|
}[]): string[];
|
|
48
|
-
/** Where each skill's files are in the sandbox, for an agent with skills and a sandbox. */
|
|
49
|
-
export declare function skillFolderNote(skills: readonly SkillManifest[]): string;
|
|
50
|
-
/**
|
|
51
|
-
* `load_skill` for the agent's skills, and `read_skill_resource` when a skill has files besides
|
|
52
|
-
* `SKILL.md`. Empty for an agent without skills. Each runs here (`harness`).
|
|
53
|
-
*/
|
|
54
|
-
export declare function skillTools(skills: readonly SkillManifest[]): DurableSessionTool[];
|
|
55
36
|
/** What a skill tool runs with. */
|
|
56
37
|
export interface SkillToolContext {
|
|
57
38
|
readonly channel: Pick<HarnessChannel, "request">;
|
|
@@ -91,4 +72,3 @@ export declare function definitionFileChunks(channel: Pick<HarnessChannel, "requ
|
|
|
91
72
|
* one cannot be; nothing when the tree has no skills.
|
|
92
73
|
*/
|
|
93
74
|
export declare function mountSkills(files: HarnessFiles, channel: Pick<HarnessChannel, "request">, run: HarnessRun, signal: AbortSignal): Promise<FailedFileOutcome | undefined>;
|
|
94
|
-
export {};
|
package/dist/tools/skills.js
CHANGED
|
@@ -22,86 +22,20 @@
|
|
|
22
22
|
* for a folder the sandbox already holds since it last started.
|
|
23
23
|
*/
|
|
24
24
|
import { SKILL_ENTRY, SKILLS_MOUNT, skillFolderOf, skillInstructions, } from "@nylorun/core/define";
|
|
25
|
+
import { LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILLS_USAGE, formatSkillCatalog, } from "@nylorun/core/engine";
|
|
25
26
|
import { fromBase64 } from "@nylorun/core/harness-api";
|
|
26
|
-
|
|
27
|
-
export const LOAD_SKILL_TOOL = "load_skill";
|
|
28
|
-
/** Reads one resource file of a skill. */
|
|
29
|
-
export const READ_SKILL_RESOURCE_TOOL = "read_skill_resource";
|
|
30
|
-
/** The most bytes of one skill file the skill tools read into the model's context by default. */
|
|
31
|
-
export const DEFAULT_SKILL_READ_BYTES = 10 * 1024 * 1024;
|
|
27
|
+
export { DEFAULT_SKILL_READ_BYTES, LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILLS_USAGE, formatSkillCatalog, skillFolderNote, skillTools, } from "@nylorun/core/engine";
|
|
32
28
|
/** True when `name` is one of our engine's skill tools. */
|
|
33
29
|
export function isSkillTool(name) {
|
|
34
30
|
return name === LOAD_SKILL_TOOL || name === READ_SKILL_RESOURCE_TOOL;
|
|
35
31
|
}
|
|
36
|
-
/**
|
|
37
|
-
export const SKILLS_USAGE = "The following skills provide specialized instructions. When a task matches a skill description, call load_skill with that name before proceeding.";
|
|
38
|
-
/** The skills the model may load, by name and description. */
|
|
39
|
-
export function formatSkillCatalog(skills) {
|
|
40
|
-
const entries = skills
|
|
41
|
-
.map((skill) => ` <skill>\n <name>${escapeXml(skill.name)}</name>\n <description>${escapeXml(skill.description)}</description>\n </skill>`)
|
|
42
|
-
.join("\n");
|
|
43
|
-
return `<available_skills>\n${entries}\n</available_skills>`;
|
|
44
|
-
}
|
|
45
|
-
function escapeXml(value) {
|
|
46
|
-
return value
|
|
47
|
-
.replaceAll("&", "&")
|
|
48
|
-
.replaceAll("<", "<")
|
|
49
|
-
.replaceAll(">", ">")
|
|
50
|
-
.replaceAll('"', """);
|
|
51
|
-
}
|
|
52
|
-
/** What the model reads of an agent's skills: when to load one, and the catalog. */
|
|
32
|
+
/** What the model reads of an agent's skills: when to load one, and the catalog (block `skills`). */
|
|
53
33
|
export function skillCatalogText(skills) {
|
|
54
34
|
return [
|
|
55
35
|
SKILLS_USAGE,
|
|
56
36
|
formatSkillCatalog(skills.map(({ name, description }) => ({ name, description }))),
|
|
57
37
|
];
|
|
58
38
|
}
|
|
59
|
-
/** Where each skill's files are in the sandbox, for an agent with skills and a sandbox. */
|
|
60
|
-
export function skillFolderNote(skills) {
|
|
61
|
-
return `Each skill's files are in the sandbox, read-only, in its own folder under ${SKILLS_MOUNT}/ (${skills
|
|
62
|
-
.map((skill) => `${skill.name}: ${skillFolderOf(skill)}/`)
|
|
63
|
-
.join(", ")}): read them there and run their scripts with bash.`;
|
|
64
|
-
}
|
|
65
|
-
const HARNESS = Object.freeze({ kind: "harness" });
|
|
66
|
-
const SCHEMA = "http://json-schema.org/draft-07/schema#";
|
|
67
|
-
/**
|
|
68
|
-
* `load_skill` for the agent's skills, and `read_skill_resource` when a skill has files besides
|
|
69
|
-
* `SKILL.md`. Empty for an agent without skills. Each runs here (`harness`).
|
|
70
|
-
*/
|
|
71
|
-
export function skillTools(skills) {
|
|
72
|
-
if (skills.length === 0)
|
|
73
|
-
return [];
|
|
74
|
-
const names = skills.map((skill) => skill.name).sort();
|
|
75
|
-
const name = names.length === 1 ? { type: "string", const: names[0] } : { type: "string", enum: names };
|
|
76
|
-
const tools = [
|
|
77
|
-
{
|
|
78
|
-
name: LOAD_SKILL_TOOL,
|
|
79
|
-
description: "Load the full instructions for a named skill. Call this before following a skill.",
|
|
80
|
-
inputSchema: {
|
|
81
|
-
$schema: SCHEMA,
|
|
82
|
-
type: "object",
|
|
83
|
-
properties: { name },
|
|
84
|
-
required: ["name"],
|
|
85
|
-
additionalProperties: false,
|
|
86
|
-
},
|
|
87
|
-
target: HARNESS,
|
|
88
|
-
},
|
|
89
|
-
];
|
|
90
|
-
if (skills.some((skill) => Object.keys(skill.files).some((path) => path !== SKILL_ENTRY)))
|
|
91
|
-
tools.push({
|
|
92
|
-
name: READ_SKILL_RESOURCE_TOOL,
|
|
93
|
-
description: "Read one text resource from a skill after load_skill.",
|
|
94
|
-
inputSchema: {
|
|
95
|
-
$schema: SCHEMA,
|
|
96
|
-
type: "object",
|
|
97
|
-
properties: { name, path: { type: "string", minLength: 1 } },
|
|
98
|
-
required: ["name", "path"],
|
|
99
|
-
additionalProperties: false,
|
|
100
|
-
},
|
|
101
|
-
target: HARNESS,
|
|
102
|
-
});
|
|
103
|
-
return tools;
|
|
104
|
-
}
|
|
105
39
|
const failed = (code, message) => ({
|
|
106
40
|
kind: "failed",
|
|
107
41
|
code,
|
|
@@ -1,27 +1,6 @@
|
|
|
1
1
|
import type { DurableSessionTool, HostEffect } from "../run/durable.js";
|
|
2
2
|
import type { McpToolConfig } from "./mcp.js";
|
|
3
|
-
|
|
4
|
-
export declare const TOOL_SEARCH_TOOL = "tool_search";
|
|
5
|
-
/** Runs a deferred tool by name, as a call of that tool. */
|
|
6
|
-
export declare const TOOL_CALL_TOOL = "tool_call";
|
|
7
|
-
/** A server some of whose tools are deferred, as the model's note names it. */
|
|
8
|
-
export interface DeferredServerNote {
|
|
9
|
-
readonly serverName: string;
|
|
10
|
-
/** How many of its tools are deferred. */
|
|
11
|
-
readonly tools: number;
|
|
12
|
-
/** The server's own instructions (MCP `initialize`), if it gave any. */
|
|
13
|
-
readonly instructions?: string;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* `tool_search` (ours, `harness`) and `tool_call`, as our engine gives them to an agent with
|
|
17
|
-
* deferred tools. Their schemas reach the model; change them deliberately.
|
|
18
|
-
*/
|
|
19
|
-
export declare function deferredToolsTools(config: Pick<McpToolConfig, "toolSearchDefaultLimit" | "toolSearchMaxLimit">): readonly DurableSessionTool[];
|
|
20
|
-
/**
|
|
21
|
-
* The note the model reads beside `tool_search`: each server with deferred tools, how many, and
|
|
22
|
-
* its own instructions cut to `config.serverInstructionsMaxChars`.
|
|
23
|
-
*/
|
|
24
|
-
export declare function deferredToolsNote(servers: readonly DeferredServerNote[], config: Pick<McpToolConfig, "serverInstructionsMaxChars">): string;
|
|
3
|
+
export { TOOL_CALL_TOOL, TOOL_SEARCH_TOOL, deferredToolsNote, deferredToolsTools, type DeferredServerNote, } from "@nylorun/core/engine";
|
|
25
4
|
/** True when `effect` calls our engine's `tool_search`. */
|
|
26
5
|
export declare function isToolSearch(effect: Pick<HostEffect, "toolName" | "target">): boolean;
|
|
27
6
|
/** Runs `tool_search` over `deferred`, the deferred tools of the call's agent. */
|
|
@@ -6,87 +6,11 @@
|
|
|
6
6
|
* reads only the run's MCP tools (`McpToolSet`), so the same query finds the same tools while the
|
|
7
7
|
* session's layout stands; a tool the turn disables is never there.
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
/** Finds deferred tools by a query (BM25 over their names and descriptions). */
|
|
12
|
-
export const TOOL_SEARCH_TOOL = "tool_search";
|
|
13
|
-
/** Runs a deferred tool by name, as a call of that tool. */
|
|
14
|
-
export const TOOL_CALL_TOOL = "tool_call";
|
|
9
|
+
import { TOOL_SEARCH_TOOL } from "@nylorun/core/engine";
|
|
10
|
+
export { TOOL_CALL_TOOL, TOOL_SEARCH_TOOL, deferredToolsNote, deferredToolsTools, } from "@nylorun/core/engine";
|
|
15
11
|
/** BM25's term saturation and length normalization, the usual values. */
|
|
16
12
|
const K1 = 1.2;
|
|
17
13
|
const B = 0.75;
|
|
18
|
-
const HARNESS = Object.freeze({ kind: "harness" });
|
|
19
|
-
async function runsInHarness() {
|
|
20
|
-
throw new ToolError("tools.runtime-only", "tool_search and tool_call run in Nylorun's harness. Connect the agent to a Runtime to use them.");
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* `tool_search` (ours, `harness`) and `tool_call`, as our engine gives them to an agent with
|
|
24
|
-
* deferred tools. Their schemas reach the model; change them deliberately.
|
|
25
|
-
*/
|
|
26
|
-
export function deferredToolsTools(config) {
|
|
27
|
-
return [searchTool(config), callTool()].map((item, index) => {
|
|
28
|
-
const schemas = normalizedSchemasFor(item);
|
|
29
|
-
const manifest = {
|
|
30
|
-
name: item.name,
|
|
31
|
-
...(item.description === undefined ? {} : { description: item.description }),
|
|
32
|
-
inputSchema: schemas.inputSchema.jsonSchema,
|
|
33
|
-
};
|
|
34
|
-
// `tool_call` makes the effect of the tool it names; it is never one itself.
|
|
35
|
-
return index === 0 ? { ...manifest, target: HARNESS } : manifest;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* The note the model reads beside `tool_search`: each server with deferred tools, how many, and
|
|
40
|
-
* its own instructions cut to `config.serverInstructionsMaxChars`.
|
|
41
|
-
*/
|
|
42
|
-
export function deferredToolsNote(servers, config) {
|
|
43
|
-
const max = config.serverInstructionsMaxChars;
|
|
44
|
-
const lines = servers.map((server) => {
|
|
45
|
-
const head = `- ${server.serverName}: ${server.tools} tool${server.tools === 1 ? "" : "s"}`;
|
|
46
|
-
const text = server.instructions?.trim();
|
|
47
|
-
if (!text)
|
|
48
|
-
return head;
|
|
49
|
-
const cut = text.length > max ? `${text.slice(0, max)}…` : text;
|
|
50
|
-
return `${head}. The server says: ${cut}`;
|
|
51
|
-
});
|
|
52
|
-
return [
|
|
53
|
-
"Some tools of these MCP servers are not in your tool list. Find them with tool_search (a few words of what you need), then run one with tool_call, passing its name and arguments that match its inputSchema.",
|
|
54
|
-
...lines,
|
|
55
|
-
].join("\n");
|
|
56
|
-
}
|
|
57
|
-
function searchTool(config) {
|
|
58
|
-
return tool({
|
|
59
|
-
name: TOOL_SEARCH_TOOL,
|
|
60
|
-
description: "Search the tools not in your tool list by name and description. Returns the best matches, each with its name, description and inputSchema. Run one with tool_call.",
|
|
61
|
-
inputSchema: z.object({
|
|
62
|
-
query: z.string().min(1).describe("Words of what the tool does, or of its name."),
|
|
63
|
-
limit: z
|
|
64
|
-
.number()
|
|
65
|
-
.int()
|
|
66
|
-
.min(1)
|
|
67
|
-
.max(config.toolSearchMaxLimit)
|
|
68
|
-
.optional()
|
|
69
|
-
.describe(`How many tools to return. Default ${config.toolSearchDefaultLimit}.`),
|
|
70
|
-
}),
|
|
71
|
-
effects: "read",
|
|
72
|
-
execute: runsInHarness,
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function callTool() {
|
|
76
|
-
return tool({
|
|
77
|
-
name: TOOL_CALL_TOOL,
|
|
78
|
-
description: "Run a tool tool_search found, by its name. arguments must match that tool's inputSchema; the result is the tool's own.",
|
|
79
|
-
inputSchema: z.object({
|
|
80
|
-
name: z.string().min(1).describe("The tool's name, as tool_search returned it."),
|
|
81
|
-
arguments: z
|
|
82
|
-
.record(z.string(), z.unknown())
|
|
83
|
-
.optional()
|
|
84
|
-
.describe("The tool's arguments, matching its inputSchema. Default {}."),
|
|
85
|
-
}),
|
|
86
|
-
effects: "write",
|
|
87
|
-
execute: runsInHarness,
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
14
|
/** True when `effect` calls our engine's `tool_search`. */
|
|
91
15
|
export function isToolSearch(effect) {
|
|
92
16
|
return effect.target?.kind === "harness" && effect.toolName === TOOL_SEARCH_TOOL;
|
package/dist/tools/wake.d.ts
CHANGED
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `schedule_wake` (track T4, D77): the agent books its own session's next turn, "check the deploy
|
|
3
|
-
* again in two hours". Offered when the version the session runs sets `runtime.selfWake`
|
|
4
|
-
* (`turn.start.agent.selfWake`). The Runtime serves it (a `runtime` effect): it writes the booking
|
|
5
|
-
* in the call's own transaction, keyed by the call, so a replayed turn books once. A session holds
|
|
6
|
-
* one booking; a new one replaces it. The booked turn starts with the note as its message.
|
|
7
|
-
*/
|
|
8
1
|
import type { DurableSessionTool } from "../run/durable.js";
|
|
9
2
|
/** The tool, and the text the model reads with it. */
|
|
10
3
|
export declare function wakeTool(): {
|
package/dist/tools/wake.js
CHANGED
|
@@ -1,33 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* `schedule_wake` (track T4, D77): the agent books its own session's next turn, "check the deploy
|
|
3
|
+
* again in two hours". Offered when the version the session runs sets `runtime.selfWake`
|
|
4
|
+
* (`turn.start.agent.selfWake`). The Runtime serves it (a `runtime` effect): it writes the booking
|
|
5
|
+
* in the call's own transaction, keyed by the call, so a replayed turn books once. A session holds
|
|
6
|
+
* one booking; a new one replaces it. The booked turn starts with the note as its message. The
|
|
7
|
+
* tool and its text are `@nylorun/core/engine`'s (block `wake`).
|
|
8
|
+
*/
|
|
9
|
+
import { WAKE_TEXT, wakeToolOf } from "@nylorun/core/engine";
|
|
2
10
|
/** The tool, and the text the model reads with it. */
|
|
3
11
|
export function wakeTool() {
|
|
4
|
-
return {
|
|
5
|
-
tool: {
|
|
6
|
-
name: "schedule_wake",
|
|
7
|
-
description: "Book this session's next turn for later, when nobody may be here to ask: give `in` (a duration such as 30m, 2h or 1d) or `at` (an RFC 3339 time with an offset), and a `note` that will be your message at that turn. A session holds one booking: a new one replaces it, and `cancel: true` removes it. Returns when it is booked for.",
|
|
8
|
-
inputSchema: {
|
|
9
|
-
type: "object",
|
|
10
|
-
properties: {
|
|
11
|
-
in: {
|
|
12
|
-
type: "string",
|
|
13
|
-
pattern: "^[1-9][0-9]*(s|m|h|d)$",
|
|
14
|
-
description: "How long from now: 30m, 2h, 1d.",
|
|
15
|
-
},
|
|
16
|
-
at: {
|
|
17
|
-
type: "string",
|
|
18
|
-
description: "An RFC 3339 time with an offset, such as 2026-11-01T09:00:00+05:30.",
|
|
19
|
-
},
|
|
20
|
-
note: {
|
|
21
|
-
type: "string",
|
|
22
|
-
minLength: 1,
|
|
23
|
-
description: "What to do then, in your own words: your message at that turn.",
|
|
24
|
-
},
|
|
25
|
-
cancel: { type: "boolean", description: "Remove the session's booking instead." },
|
|
26
|
-
},
|
|
27
|
-
additionalProperties: false,
|
|
28
|
-
},
|
|
29
|
-
target: RUNTIME_WAKE,
|
|
30
|
-
},
|
|
31
|
-
instructions: "You can book this session's next turn with schedule_wake, to check on something later or keep a routine going. Booking again replaces the booking you have.",
|
|
32
|
-
};
|
|
12
|
+
return { tool: wakeToolOf(), instructions: WAKE_TEXT };
|
|
33
13
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nylorun/harness",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.31.0-beta",
|
|
4
4
|
"description": "Nylorun's TypeScript agent execution engine. See github.com/nylorun/agents.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"zod": "^4.6.7"
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@nylorun/core": "0.
|
|
80
|
+
"@nylorun/core": "0.34.0-beta"
|
|
81
81
|
},
|
|
82
82
|
"peerDependencies": {
|
|
83
83
|
"zod": "^4.6.7"
|