@nylorun/core 0.33.0-beta → 0.35.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 +85 -0
- package/dist/compatibility.d.ts +25 -1
- package/dist/compatibility.js +24 -0
- package/dist/contracts.d.ts +749 -17
- package/dist/contracts.js +360 -22
- package/dist/define.d.ts +1 -1
- package/dist/define.js +1 -1
- package/dist/definition/assemble.d.ts +2 -1
- package/dist/definition/assemble.js +1 -0
- package/dist/definition/from.js +1 -0
- package/dist/definition/manifest.d.ts +2 -1
- package/dist/definition/manifest.js +1 -0
- package/dist/definition/sections.d.ts +1 -1
- package/dist/definition/sections.js +5 -1
- package/dist/definition/variant.d.ts +16 -1
- package/dist/definition/variant.js +81 -3
- package/dist/engine/blocks.d.ts +54 -0
- package/dist/engine/blocks.js +162 -0
- package/dist/engine/explain.d.ts +36 -0
- package/dist/engine/explain.js +113 -0
- package/dist/engine/features.d.ts +28 -0
- package/dist/engine/features.js +34 -0
- package/dist/engine/index.d.ts +14 -0
- package/dist/engine/index.js +14 -0
- package/dist/engine/mcp.d.ts +119 -0
- package/dist/engine/mcp.js +267 -0
- package/dist/engine/names.d.ts +12 -0
- package/dist/engine/names.js +26 -0
- package/dist/engine/preview.d.ts +93 -0
- package/dist/engine/preview.js +120 -0
- package/dist/engine/projection.d.ts +63 -0
- package/dist/engine/projection.js +109 -0
- package/dist/engine/tools.d.ts +118 -0
- package/dist/engine/tools.js +508 -0
- package/dist/folder/compile.d.ts +11 -4
- package/dist/folder/compile.js +126 -13
- package/dist/folder/context.d.ts +5 -0
- package/dist/folder/decompile.js +22 -1
- package/dist/folder/engine.d.ts +73 -0
- package/dist/folder/engine.js +224 -0
- package/dist/folder/nested.js +6 -0
- package/dist/folder/schemas.js +47 -3
- package/dist/harness-api/harness-api.schema.json +29 -7
- package/dist/harness-api/json-schema.js +6 -2
- package/dist/harness-api/messages.d.ts +4 -2
- package/dist/harness-api/messages.js +4 -1
- package/dist/harness-api/schema.d.ts +15 -4
- package/dist/harness-api/schema.js +20 -4
- package/dist/manifest-schemas.js +9 -4
- package/dist/schemas/agent-folder/agent-md.schema.json +84 -3
- package/dist/schemas/agent-folder/runtime.schema.json +34 -1
- package/dist/schemas/agent-manifest.schema.json +166 -1
- package/dist/schemas/harness-manifest.schema.json +130 -1
- package/dist/schemas/runtime-manifest.schema.json +34 -1
- package/dist/types/manifest.d.ts +49 -0
- package/package.json +5 -1
|
@@ -0,0 +1,508 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Our engine's own tools as the model reads them (protocol 15, ADR-100): each tool's name,
|
|
3
|
+
* description, input schema and the effect its calls make. Our harness runs them
|
|
4
|
+
* (`@nylorun/harness`); the compiler and the SDK's `previewTurn` read the same definitions, so
|
|
5
|
+
* what a preview shows is what a session is offered. Their schemas reach the model: change them
|
|
6
|
+
* deliberately.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
import { ARTIFACT_NAME_MAX, PLAN_LIMITS, PLAN_STEP_STATES, TRIGGER_DELAY_PATTERN, TRIGGER_TITLE_MAX } from "../contracts.js";
|
|
10
|
+
import { MEMORY_ROOT } from "../utils/memory.js";
|
|
11
|
+
import { SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE } from "../utils/sandbox.js";
|
|
12
|
+
import { SKILL_ENTRY } from "../utils/definition-files.js";
|
|
13
|
+
import { READ_ARTIFACT_TOOL, SAVE_ARTIFACT_TOOL } from "../utils/runtime-tools.js";
|
|
14
|
+
import { tool } from "../definition/helpers.js";
|
|
15
|
+
import { normalizedSchemasFor } from "../definition/schema.js";
|
|
16
|
+
import { ToolError } from "../definition/tool-error.js";
|
|
17
|
+
const SCHEMA = "http://json-schema.org/draft-07/schema#";
|
|
18
|
+
const HARNESS = Object.freeze({ kind: "harness" });
|
|
19
|
+
const SANDBOX = Object.freeze({ kind: "sandbox" });
|
|
20
|
+
/** The sandbox tools' limits when the harness sets none. */
|
|
21
|
+
export const DEFAULT_SANDBOX_TOOL_LIMITS = Object.freeze({
|
|
22
|
+
outputChars: 30_000,
|
|
23
|
+
defaultTimeoutS: 120,
|
|
24
|
+
maxTimeoutS: 600,
|
|
25
|
+
readLines: 2000,
|
|
26
|
+
maxReadLines: 5000,
|
|
27
|
+
lineChars: 2000,
|
|
28
|
+
grepResults: 200,
|
|
29
|
+
maxGrepResults: 1000,
|
|
30
|
+
globResults: 500,
|
|
31
|
+
globScan: 20_000,
|
|
32
|
+
});
|
|
33
|
+
/** The limits in force: `set`, with the default for each it leaves out. */
|
|
34
|
+
export function sandboxToolLimitsOf(set) {
|
|
35
|
+
return Object.freeze({ ...DEFAULT_SANDBOX_TOOL_LIMITS, ...definedOf(set ?? {}) });
|
|
36
|
+
}
|
|
37
|
+
const object = (properties, required) => ({
|
|
38
|
+
$schema: SCHEMA,
|
|
39
|
+
type: "object",
|
|
40
|
+
properties,
|
|
41
|
+
required: [...required],
|
|
42
|
+
additionalProperties: false,
|
|
43
|
+
});
|
|
44
|
+
const pathField = { type: "string", minLength: 1 };
|
|
45
|
+
/**
|
|
46
|
+
* The sandbox tools, in the order the model reads them, with `workspace` named in their text
|
|
47
|
+
* and `limits` in their schemas: all six, or those `names` lists (ADR-100, `engine.sandbox`),
|
|
48
|
+
* still in our order. Each is a `sandbox` effect named by its operation.
|
|
49
|
+
*/
|
|
50
|
+
export function sandboxTools(limits, workspace, names = SANDBOX_TOOL_NAMES) {
|
|
51
|
+
const relative = `Relative paths resolve under ${workspace}.`;
|
|
52
|
+
const tools = [
|
|
53
|
+
{
|
|
54
|
+
name: "bash",
|
|
55
|
+
description: `Run a bash command in the sandbox. The working directory is ${workspace}. ` +
|
|
56
|
+
"Returns exitCode, stdout and stderr; a non-zero exit code is a normal result, not an error. " +
|
|
57
|
+
"Long output is truncated in the middle.",
|
|
58
|
+
inputSchema: object({
|
|
59
|
+
command: { type: "string", minLength: 1, description: "The command line to run with bash." },
|
|
60
|
+
timeout: {
|
|
61
|
+
description: `Seconds before the command is killed. Default ${limits.defaultTimeoutS}, maximum ${limits.maxTimeoutS}.`,
|
|
62
|
+
type: "integer",
|
|
63
|
+
minimum: 1,
|
|
64
|
+
maximum: limits.maxTimeoutS,
|
|
65
|
+
},
|
|
66
|
+
}, ["command"]),
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "read",
|
|
70
|
+
description: `Read a text file from the sandbox. ${relative} Returns numbered lines. ` +
|
|
71
|
+
"Use offset and limit to page through large files.",
|
|
72
|
+
inputSchema: object({
|
|
73
|
+
path: pathField,
|
|
74
|
+
offset: {
|
|
75
|
+
description: "First line to return, 1-based.",
|
|
76
|
+
type: "integer",
|
|
77
|
+
minimum: 1,
|
|
78
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
79
|
+
},
|
|
80
|
+
limit: {
|
|
81
|
+
description: `Maximum number of lines. Default ${limits.readLines}.`,
|
|
82
|
+
type: "integer",
|
|
83
|
+
minimum: 1,
|
|
84
|
+
maximum: limits.maxReadLines,
|
|
85
|
+
},
|
|
86
|
+
}, ["path"]),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "write",
|
|
90
|
+
description: `Create or overwrite a text file in the sandbox. ${relative} Parent directories are created.`,
|
|
91
|
+
inputSchema: object({ path: pathField, content: { type: "string" } }, ["path", "content"]),
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
name: "edit",
|
|
95
|
+
description: `Replace text in a sandbox file. ${relative} old_string must match exactly and be unique ` +
|
|
96
|
+
"unless replace_all is true.",
|
|
97
|
+
inputSchema: object({
|
|
98
|
+
path: pathField,
|
|
99
|
+
old_string: { type: "string", minLength: 1 },
|
|
100
|
+
new_string: { type: "string" },
|
|
101
|
+
replace_all: { type: "boolean" },
|
|
102
|
+
}, ["path", "old_string", "new_string"]),
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "grep",
|
|
106
|
+
description: `Search file contents in the sandbox with an extended regular expression. ${relative} ` +
|
|
107
|
+
"Returns matching lines as path:line:text.",
|
|
108
|
+
inputSchema: object({
|
|
109
|
+
pattern: { type: "string", minLength: 1 },
|
|
110
|
+
path: { description: `Directory or file to search. Default ${workspace}.`, ...pathField },
|
|
111
|
+
glob: { description: 'Only search files whose name matches, e.g. "*.py".', ...pathField },
|
|
112
|
+
ignore_case: { type: "boolean" },
|
|
113
|
+
max_results: {
|
|
114
|
+
description: `Default ${limits.grepResults}.`,
|
|
115
|
+
type: "integer",
|
|
116
|
+
minimum: 1,
|
|
117
|
+
maximum: limits.maxGrepResults,
|
|
118
|
+
},
|
|
119
|
+
}, ["pattern"]),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: "glob",
|
|
123
|
+
description: `Find files in the sandbox by glob pattern, e.g. "**/*.csv". ${relative} Returns matching paths.`,
|
|
124
|
+
inputSchema: object({
|
|
125
|
+
pattern: { type: "string", minLength: 1 },
|
|
126
|
+
path: { description: `Directory to search. Default ${workspace}.`, ...pathField },
|
|
127
|
+
}, ["pattern"]),
|
|
128
|
+
},
|
|
129
|
+
];
|
|
130
|
+
return tools.filter((item) => names.includes(item.name)).map((item) => ({ ...item, target: SANDBOX }));
|
|
131
|
+
}
|
|
132
|
+
// --- The artifact tools ----------------------------------------------------------------------
|
|
133
|
+
const SAVE_DESCRIPTION = `Save a file as an artifact of this session, for the user to download. Give path (a file in the sandbox; relative paths resolve under ${SANDBOX_WORKSPACE}) or content (text), not both. ` +
|
|
134
|
+
"Returns the artifact's id and version. Pass artifactId to save a new version of an artifact you saved before.";
|
|
135
|
+
const SAVE_SCHEMA = {
|
|
136
|
+
$schema: SCHEMA,
|
|
137
|
+
type: "object",
|
|
138
|
+
properties: {
|
|
139
|
+
path: { description: "A file in the sandbox.", type: "string", minLength: 1 },
|
|
140
|
+
content: { description: "Text to save instead of a file.", type: "string" },
|
|
141
|
+
name: {
|
|
142
|
+
description: "The artifact's name. Default: the file's name.",
|
|
143
|
+
type: "string",
|
|
144
|
+
minLength: 1,
|
|
145
|
+
maxLength: ARTIFACT_NAME_MAX,
|
|
146
|
+
},
|
|
147
|
+
contentType: {
|
|
148
|
+
description: "The media type, e.g. image/png. Default: from the name's extension.",
|
|
149
|
+
type: "string",
|
|
150
|
+
minLength: 1,
|
|
151
|
+
},
|
|
152
|
+
artifactId: { description: "Save a new version of this artifact.", type: "string", minLength: 1 },
|
|
153
|
+
},
|
|
154
|
+
additionalProperties: false,
|
|
155
|
+
};
|
|
156
|
+
function readDescription(pageBytes, sandboxed) {
|
|
157
|
+
return (`Read an artifact of this session, such as a tool result marked truncated or a file from an earlier turn. A text file returns up to ${pageBytes} bytes from offset, ` +
|
|
158
|
+
"with nextOffset while more remains: pass it as offset to read on. An image or another file you can read is shown to you." +
|
|
159
|
+
(sandboxed
|
|
160
|
+
? ` Pass path to copy the whole artifact into the sandbox instead (relative paths resolve under ${SANDBOX_WORKSPACE}), for a command to use.`
|
|
161
|
+
: ""));
|
|
162
|
+
}
|
|
163
|
+
function readSchema(pageBytes, sandboxed) {
|
|
164
|
+
return {
|
|
165
|
+
$schema: SCHEMA,
|
|
166
|
+
type: "object",
|
|
167
|
+
properties: {
|
|
168
|
+
artifactId: { type: "string", minLength: 1, description: "The artifact to read, e.g. a truncated result's artifactId." },
|
|
169
|
+
version: {
|
|
170
|
+
description: "The version to read. Default: the latest.",
|
|
171
|
+
type: "integer",
|
|
172
|
+
minimum: 1,
|
|
173
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
174
|
+
},
|
|
175
|
+
offset: {
|
|
176
|
+
description: "The byte to start at. Default 0.",
|
|
177
|
+
type: "integer",
|
|
178
|
+
minimum: 0,
|
|
179
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
180
|
+
},
|
|
181
|
+
length: {
|
|
182
|
+
description: `How many bytes to read. Default and most: ${pageBytes}.`,
|
|
183
|
+
type: "integer",
|
|
184
|
+
minimum: 1,
|
|
185
|
+
maximum: pageBytes,
|
|
186
|
+
},
|
|
187
|
+
...(sandboxed
|
|
188
|
+
? {
|
|
189
|
+
path: {
|
|
190
|
+
description: "Copy the artifact to this file in the sandbox instead of reading it.",
|
|
191
|
+
type: "string",
|
|
192
|
+
minLength: 1,
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
: {}),
|
|
196
|
+
},
|
|
197
|
+
required: ["artifactId"],
|
|
198
|
+
additionalProperties: false,
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
/** `save_artifact` (with `save`) and `read_artifact` (with `read`), which takes `path` with a sandbox. */
|
|
202
|
+
export function artifactTools(offer, options) {
|
|
203
|
+
return [
|
|
204
|
+
...(offer.save ? [{ name: SAVE_ARTIFACT_TOOL, description: SAVE_DESCRIPTION, inputSchema: SAVE_SCHEMA, target: HARNESS }] : []),
|
|
205
|
+
...(offer.read
|
|
206
|
+
? [
|
|
207
|
+
{
|
|
208
|
+
name: READ_ARTIFACT_TOOL,
|
|
209
|
+
description: readDescription(options.pageBytes, offer.sandboxed),
|
|
210
|
+
inputSchema: readSchema(options.pageBytes, offer.sandboxed),
|
|
211
|
+
target: HARNESS,
|
|
212
|
+
},
|
|
213
|
+
]
|
|
214
|
+
: []),
|
|
215
|
+
];
|
|
216
|
+
}
|
|
217
|
+
// --- The skill tools -------------------------------------------------------------------------
|
|
218
|
+
/** Loads a skill's `SKILL.md`. */
|
|
219
|
+
export const LOAD_SKILL_TOOL = "load_skill";
|
|
220
|
+
/** Reads one resource file of a skill. */
|
|
221
|
+
export const READ_SKILL_RESOURCE_TOOL = "read_skill_resource";
|
|
222
|
+
/**
|
|
223
|
+
* `load_skill` for the agent's skills, and `read_skill_resource` when a skill has files besides
|
|
224
|
+
* `SKILL.md`. Empty for an agent without skills. Each runs in the harness.
|
|
225
|
+
*/
|
|
226
|
+
export function skillTools(skills) {
|
|
227
|
+
if (skills.length === 0)
|
|
228
|
+
return [];
|
|
229
|
+
const names = skills.map((skill) => skill.name).sort();
|
|
230
|
+
const name = names.length === 1 ? { type: "string", const: names[0] } : { type: "string", enum: names };
|
|
231
|
+
const tools = [
|
|
232
|
+
{
|
|
233
|
+
name: LOAD_SKILL_TOOL,
|
|
234
|
+
description: "Load the full instructions for a named skill. Call this before following a skill.",
|
|
235
|
+
inputSchema: { $schema: SCHEMA, type: "object", properties: { name }, required: ["name"], additionalProperties: false },
|
|
236
|
+
target: HARNESS,
|
|
237
|
+
},
|
|
238
|
+
];
|
|
239
|
+
if (skills.some((skill) => Object.keys(skill.files).some((path) => path !== SKILL_ENTRY)))
|
|
240
|
+
tools.push({
|
|
241
|
+
name: READ_SKILL_RESOURCE_TOOL,
|
|
242
|
+
description: "Read one text resource from a skill after load_skill.",
|
|
243
|
+
inputSchema: {
|
|
244
|
+
$schema: SCHEMA,
|
|
245
|
+
type: "object",
|
|
246
|
+
properties: { name, path: { type: "string", minLength: 1 } },
|
|
247
|
+
required: ["name", "path"],
|
|
248
|
+
additionalProperties: false,
|
|
249
|
+
},
|
|
250
|
+
target: HARNESS,
|
|
251
|
+
});
|
|
252
|
+
return tools;
|
|
253
|
+
}
|
|
254
|
+
// --- memory ----------------------------------------------------------------------------------
|
|
255
|
+
/** The memory tool's name. */
|
|
256
|
+
export const MEMORY_TOOL = "memory";
|
|
257
|
+
const RUNTIME_MEMORY = Object.freeze({ kind: "runtime", operation: "memory" });
|
|
258
|
+
const MEMORY_WRITES = ["create", "str_replace", "insert", "delete", "rename"];
|
|
259
|
+
/** `memory`: view, and the writes when the agent may write. A `runtime` effect, operation `memory`. */
|
|
260
|
+
export function memoryToolOf(writes) {
|
|
261
|
+
return {
|
|
262
|
+
name: MEMORY_TOOL,
|
|
263
|
+
description: [
|
|
264
|
+
`Read${writes ? " and edit" : ""} your persistent memory directory, ${MEMORY_ROOT}. Files there survive across sessions.`,
|
|
265
|
+
"Commands:",
|
|
266
|
+
"- view: show a directory listing, or a file's contents with line numbers. Params: path, optional view_range [start, end] (end -1 means to the end).",
|
|
267
|
+
...(writes
|
|
268
|
+
? [
|
|
269
|
+
"- create: create a file, or replace an existing one. Params: path, file_text.",
|
|
270
|
+
"- str_replace: replace text that appears exactly once in a file. Params: path, old_str, new_str (omit new_str to delete old_str).",
|
|
271
|
+
"- insert: insert text after a line number (0 inserts at the top). Params: path, insert_line, insert_text.",
|
|
272
|
+
"- delete: delete a file or directory. Params: path.",
|
|
273
|
+
"- rename: rename or move a file or directory; never overwrites. Params: old_path, new_path.",
|
|
274
|
+
]
|
|
275
|
+
: []),
|
|
276
|
+
`All paths are under ${MEMORY_ROOT} and memory files end in .md.`,
|
|
277
|
+
].join("\n"),
|
|
278
|
+
inputSchema: {
|
|
279
|
+
type: "object",
|
|
280
|
+
properties: {
|
|
281
|
+
command: { type: "string", enum: writes ? ["view", ...MEMORY_WRITES] : ["view"], description: "The operation to perform." },
|
|
282
|
+
path: {
|
|
283
|
+
type: "string",
|
|
284
|
+
description: writes ? `Path under ${MEMORY_ROOT}. Used by view, create, str_replace, insert and delete.` : `Path under ${MEMORY_ROOT}.`,
|
|
285
|
+
},
|
|
286
|
+
view_range: {
|
|
287
|
+
type: "array",
|
|
288
|
+
items: { type: "integer" },
|
|
289
|
+
minItems: 2,
|
|
290
|
+
maxItems: 2,
|
|
291
|
+
description: "view only: [start_line, end_line], 1-indexed; end_line -1 means to the end.",
|
|
292
|
+
},
|
|
293
|
+
...(writes
|
|
294
|
+
? {
|
|
295
|
+
file_text: { type: "string", description: "create only: the full file contents." },
|
|
296
|
+
old_str: { type: "string", description: "str_replace only: text that appears exactly once in the file." },
|
|
297
|
+
new_str: { type: "string", description: "str_replace only: the replacement text." },
|
|
298
|
+
insert_line: { type: "integer", description: "insert only: insert after this line; 0 inserts at the top." },
|
|
299
|
+
insert_text: { type: "string", description: "insert only: the text to insert." },
|
|
300
|
+
old_path: { type: "string", description: "rename only: the current path." },
|
|
301
|
+
new_path: { type: "string", description: "rename only: the new path." },
|
|
302
|
+
}
|
|
303
|
+
: {}),
|
|
304
|
+
},
|
|
305
|
+
required: ["command"],
|
|
306
|
+
additionalProperties: false,
|
|
307
|
+
},
|
|
308
|
+
target: RUNTIME_MEMORY,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
// --- schedule_wake ---------------------------------------------------------------------------
|
|
312
|
+
/** The self-wake tool's name. */
|
|
313
|
+
export const SCHEDULE_WAKE_TOOL = "schedule_wake";
|
|
314
|
+
const RUNTIME_WAKE = Object.freeze({ kind: "runtime", operation: "schedule_wake" });
|
|
315
|
+
/** `schedule_wake` (track T4): a `runtime` effect. */
|
|
316
|
+
export function wakeToolOf() {
|
|
317
|
+
return {
|
|
318
|
+
name: SCHEDULE_WAKE_TOOL,
|
|
319
|
+
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.",
|
|
320
|
+
inputSchema: {
|
|
321
|
+
type: "object",
|
|
322
|
+
properties: {
|
|
323
|
+
in: { type: "string", pattern: "^[1-9][0-9]*(s|m|h|d)$", description: "How long from now: 30m, 2h, 1d." },
|
|
324
|
+
at: { type: "string", description: "An RFC 3339 time with an offset, such as 2026-11-01T09:00:00+05:30." },
|
|
325
|
+
note: { type: "string", minLength: 1, description: "What to do then, in your own words: your message at that turn." },
|
|
326
|
+
cancel: { type: "boolean", description: "Remove the session's booking instead." },
|
|
327
|
+
},
|
|
328
|
+
additionalProperties: false,
|
|
329
|
+
},
|
|
330
|
+
target: RUNTIME_WAKE,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
// --- triggers --------------------------------------------------------------------------------
|
|
334
|
+
/** The triggers tool's name (D83). */
|
|
335
|
+
export const TRIGGERS_TOOL = "triggers";
|
|
336
|
+
/** What serves a `triggers` call: the Runtime, in the call's own transaction. */
|
|
337
|
+
export const RUNTIME_TRIGGERS = Object.freeze({ kind: "runtime", operation: "triggers" });
|
|
338
|
+
/**
|
|
339
|
+
* `triggers` (D83): list, create and delete the triggers the calling session made, for an agent
|
|
340
|
+
* whose version declares `engine.triggers`; the root agent's only. A `runtime` effect, operation
|
|
341
|
+
* `triggers`; its input is `TriggerToolInputSchema`'s.
|
|
342
|
+
*/
|
|
343
|
+
export function triggersToolOf() {
|
|
344
|
+
return {
|
|
345
|
+
name: TRIGGERS_TOOL,
|
|
346
|
+
description: [
|
|
347
|
+
"Set up work that runs later, when nobody may be here to ask: a trigger runs its prompt as your message, on a schedule, at a time or after a delay.",
|
|
348
|
+
"Commands:",
|
|
349
|
+
"- list: the triggers this session made, each with its id, title, status, when and next run.",
|
|
350
|
+
"- create: make a trigger, or replace the one this session made with the same id. Params: id, title (optional, a few words), exactly one of schedule (five cron fields: minute hour day-of-month month day-of-week, with an optional IANA timezone, default UTC), at (an RFC 3339 time with an offset) or in (a delay: 30m, 2h, 1d), session (this: run here, as a follow-up; own: run in a session of its own, kept across runs), and prompt (what to do then, in your own words).",
|
|
351
|
+
"- delete: remove a trigger this session made. Params: id.",
|
|
352
|
+
"Returns the trigger's id, status, next run and the session it runs in.",
|
|
353
|
+
].join("\n"),
|
|
354
|
+
inputSchema: {
|
|
355
|
+
type: "object",
|
|
356
|
+
properties: {
|
|
357
|
+
command: { type: "string", enum: ["list", "create", "delete"], description: "The operation to perform." },
|
|
358
|
+
id: {
|
|
359
|
+
type: "string",
|
|
360
|
+
pattern: "^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$",
|
|
361
|
+
description: "create and delete: the trigger's id, such as daily-standup: 1-64 letters, digits, '.', '_' and '-'.",
|
|
362
|
+
},
|
|
363
|
+
title: { type: "string", minLength: 1, maxLength: TRIGGER_TITLE_MAX, description: "create only: a few words that name it." },
|
|
364
|
+
schedule: { type: "string", description: "create only: five cron fields, such as 0 9 * * 1-5 (weekdays at nine)." },
|
|
365
|
+
timezone: { type: "string", description: "create only, with schedule: an IANA time zone, such as Europe/Berlin; default UTC." },
|
|
366
|
+
at: { type: "string", description: "create only: one run at an RFC 3339 time with an offset, such as 2026-11-01T09:00:00+05:30." },
|
|
367
|
+
in: { type: "string", pattern: TRIGGER_DELAY_PATTERN.source, description: "create only: one run after a delay: 30m, 2h, 1d." },
|
|
368
|
+
session: {
|
|
369
|
+
type: "string",
|
|
370
|
+
enum: ["this", "own"],
|
|
371
|
+
description: "create only: this runs it in this session; own runs it in a session of its own, kept across its runs.",
|
|
372
|
+
},
|
|
373
|
+
prompt: { type: "string", minLength: 1, description: "create only: what to do then, in your own words: your message when it runs." },
|
|
374
|
+
},
|
|
375
|
+
required: ["command"],
|
|
376
|
+
additionalProperties: false,
|
|
377
|
+
},
|
|
378
|
+
target: RUNTIME_TRIGGERS,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
// --- update_plan -----------------------------------------------------------------------------
|
|
382
|
+
/** The plan tool's name. */
|
|
383
|
+
export const UPDATE_PLAN_TOOL = "update_plan";
|
|
384
|
+
/** `update_plan` (A2A profile v2, `progress/v1`): runs in the harness. */
|
|
385
|
+
export function planToolOf() {
|
|
386
|
+
return {
|
|
387
|
+
name: UPDATE_PLAN_TOOL,
|
|
388
|
+
description: [
|
|
389
|
+
"Keep your plan for this task: a short list of steps, each with a state, which the person or agent who asked sees while you work.",
|
|
390
|
+
"Pass the whole plan each time, never only the changes: the steps in order, each with a label (a few words) and a state (pending, active, done, blocked or skipped), and optionally a note (a short fact, such as why a step is blocked).",
|
|
391
|
+
`At most ${PLAN_LIMITS.steps} steps; a label is cut at ${PLAN_LIMITS.labelChars} characters and a note at ${PLAN_LIMITS.noteChars}.`,
|
|
392
|
+
"Never put tool arguments, results, secrets or file contents in a label or note.",
|
|
393
|
+
].join(" "),
|
|
394
|
+
inputSchema: {
|
|
395
|
+
type: "object",
|
|
396
|
+
properties: {
|
|
397
|
+
steps: {
|
|
398
|
+
type: "array",
|
|
399
|
+
description: `The whole plan, in order: at most ${PLAN_LIMITS.steps} steps.`,
|
|
400
|
+
items: {
|
|
401
|
+
type: "object",
|
|
402
|
+
properties: {
|
|
403
|
+
label: {
|
|
404
|
+
type: "string",
|
|
405
|
+
minLength: 1,
|
|
406
|
+
description: `What the step does, in a few words (at most ${PLAN_LIMITS.labelChars} characters).`,
|
|
407
|
+
},
|
|
408
|
+
state: { type: "string", enum: [...PLAN_STEP_STATES], description: "The step's state." },
|
|
409
|
+
note: { type: "string", description: `A short fact about the step (at most ${PLAN_LIMITS.noteChars} characters).` },
|
|
410
|
+
},
|
|
411
|
+
required: ["label", "state"],
|
|
412
|
+
additionalProperties: false,
|
|
413
|
+
},
|
|
414
|
+
},
|
|
415
|
+
},
|
|
416
|
+
required: ["steps"],
|
|
417
|
+
additionalProperties: false,
|
|
418
|
+
},
|
|
419
|
+
target: HARNESS,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
// --- request_connection ----------------------------------------------------------------------
|
|
423
|
+
/** The connection tool's name. */
|
|
424
|
+
export const REQUEST_CONNECTION_TOOL = "request_connection";
|
|
425
|
+
/** The most characters of the app's name and of the reason. */
|
|
426
|
+
export const CONNECTION_LIMITS = Object.freeze({ appChars: 80, reasonChars: 280 });
|
|
427
|
+
/** `request_connection` (A2A profile v2, `interactions/v1` kind `connection`): runs in the harness. */
|
|
428
|
+
export function connectionToolOf() {
|
|
429
|
+
return {
|
|
430
|
+
name: REQUEST_CONNECTION_TOOL,
|
|
431
|
+
description: [
|
|
432
|
+
"Ask the person or agent who gave you this task to connect an app you need and cannot reach, such as their GitHub, Linear or Google Drive, then wait for their answer.",
|
|
433
|
+
"Give the app's name and the reason, in a sentence they can act on.",
|
|
434
|
+
"It answers Connected: <app> once they connected it, so try again; or Not connected: <app>, so go on without it or say what you could not do.",
|
|
435
|
+
"Use it only when a tool says the app is not connected or its credential is missing; never to ask anything else.",
|
|
436
|
+
].join(" "),
|
|
437
|
+
inputSchema: {
|
|
438
|
+
type: "object",
|
|
439
|
+
properties: {
|
|
440
|
+
app: {
|
|
441
|
+
type: "string",
|
|
442
|
+
minLength: 1,
|
|
443
|
+
description: `The app to connect, by its name (at most ${CONNECTION_LIMITS.appChars} characters).`,
|
|
444
|
+
},
|
|
445
|
+
reason: {
|
|
446
|
+
type: "string",
|
|
447
|
+
minLength: 1,
|
|
448
|
+
description: `Why you need it, in a sentence (at most ${CONNECTION_LIMITS.reasonChars} characters).`,
|
|
449
|
+
},
|
|
450
|
+
},
|
|
451
|
+
required: ["app", "reason"],
|
|
452
|
+
additionalProperties: false,
|
|
453
|
+
},
|
|
454
|
+
target: HARNESS,
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
// --- tool_search and tool_call ---------------------------------------------------------------
|
|
458
|
+
/** Finds deferred tools by a query (BM25 over their names and descriptions). */
|
|
459
|
+
export const TOOL_SEARCH_TOOL = "tool_search";
|
|
460
|
+
/** Runs a deferred tool by name, as a call of that tool. */
|
|
461
|
+
export const TOOL_CALL_TOOL = "tool_call";
|
|
462
|
+
async function runsInHarness() {
|
|
463
|
+
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.");
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* `tool_search` (ours, `harness`) and `tool_call`, as our engine gives them to an agent with
|
|
467
|
+
* deferred tools. `tool_call` makes the effect of the tool it names; it is never one itself.
|
|
468
|
+
*/
|
|
469
|
+
export function deferredToolsTools(config) {
|
|
470
|
+
const search = tool({
|
|
471
|
+
name: TOOL_SEARCH_TOOL,
|
|
472
|
+
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.",
|
|
473
|
+
inputSchema: z.object({
|
|
474
|
+
query: z.string().min(1).describe("Words of what the tool does, or of its name."),
|
|
475
|
+
limit: z
|
|
476
|
+
.number()
|
|
477
|
+
.int()
|
|
478
|
+
.min(1)
|
|
479
|
+
.max(config.toolSearchMaxLimit)
|
|
480
|
+
.optional()
|
|
481
|
+
.describe(`How many tools to return. Default ${config.toolSearchDefaultLimit}.`),
|
|
482
|
+
}),
|
|
483
|
+
effects: "read",
|
|
484
|
+
execute: runsInHarness,
|
|
485
|
+
});
|
|
486
|
+
const call = tool({
|
|
487
|
+
name: TOOL_CALL_TOOL,
|
|
488
|
+
description: "Run a tool tool_search found, by its name. arguments must match that tool's inputSchema; the result is the tool's own.",
|
|
489
|
+
inputSchema: z.object({
|
|
490
|
+
name: z.string().min(1).describe("The tool's name, as tool_search returned it."),
|
|
491
|
+
arguments: z.record(z.string(), z.unknown()).optional().describe("The tool's arguments, matching its inputSchema. Default {}."),
|
|
492
|
+
}),
|
|
493
|
+
effects: "write",
|
|
494
|
+
execute: runsInHarness,
|
|
495
|
+
});
|
|
496
|
+
return [search, call].map((item, index) => {
|
|
497
|
+
const schemas = normalizedSchemasFor(item);
|
|
498
|
+
const manifest = {
|
|
499
|
+
name: item.name,
|
|
500
|
+
...(item.description === undefined ? {} : { description: item.description }),
|
|
501
|
+
inputSchema: schemas.inputSchema.jsonSchema,
|
|
502
|
+
};
|
|
503
|
+
return index === 0 ? { ...manifest, target: HARNESS } : manifest;
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
function definedOf(value) {
|
|
507
|
+
return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
|
|
508
|
+
}
|
package/dist/folder/compile.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import { type AgentFolderFix, type AgentManifestV8 } from "../contracts.js";
|
|
2
2
|
import { type FolderScope } from "./nested.js";
|
|
3
|
-
/** The compiler format this version builds: a folder with no `format`, or `format: 1`. */
|
|
3
|
+
/** The compiler format this version builds by default: a folder with no `format`, or `format: 1`. */
|
|
4
4
|
export declare const AGENT_FOLDER_COMPILER = "agent-folder/1";
|
|
5
|
+
/**
|
|
6
|
+
* The formats this compiler builds: `agent-folder/1`, and `agent-folder/2` (ADR-100), whose
|
|
7
|
+
* folder declares every engine feature it uses (`folder/engine.ts`).
|
|
8
|
+
*/
|
|
9
|
+
export declare const AGENT_FOLDER_FORMATS: readonly ["agent-folder/1", "agent-folder/2"];
|
|
10
|
+
export type AgentFolderFormat = (typeof AGENT_FOLDER_FORMATS)[number];
|
|
5
11
|
/**
|
|
6
12
|
* What a folder may hold, unless `compileAgentFolder` is given other limits (a Tenant's Runtime
|
|
7
13
|
* limits `folderFiles`, `folderBytes` and `folderTextFileBytes`, which default to these).
|
|
@@ -57,7 +63,8 @@ export interface CompiledAgentFolder {
|
|
|
57
63
|
/** The manifest, when nothing is an error. */
|
|
58
64
|
readonly manifest?: AgentManifestV8;
|
|
59
65
|
readonly diagnostics: readonly AgentFolderDiagnostic[];
|
|
60
|
-
|
|
66
|
+
/** The format the folder was compiled as: `agent-folder/1` or `agent-folder/2`. */
|
|
67
|
+
readonly compiler: AgentFolderFormat;
|
|
61
68
|
}
|
|
62
69
|
/**
|
|
63
70
|
* The schemas a JSON file of a folder may name in `$schema`, by the kind of file: ours first,
|
|
@@ -65,12 +72,12 @@ export interface CompiledAgentFolder {
|
|
|
65
72
|
*/
|
|
66
73
|
export declare const FOLDER_SCHEMAS = "https://docs.nylorun.com/schemas/agent-folder/v1/";
|
|
67
74
|
export declare const SCHEMA_URLS: {
|
|
68
|
-
readonly runtime: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/runtime.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.json"];
|
|
75
|
+
readonly runtime: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/runtime.2.json", "https://docs.nylorun.com/schemas/agent-folder/v1/runtime.1.json", "https://docs.nylorun.com/schemas/agent-folder/v1/runtime.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.2.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.1.json", "https://docs.nylorun.com/schemas/runtime-manifest/v1.json"];
|
|
69
76
|
readonly tool: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/tool.json"];
|
|
70
77
|
readonly mcp: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/mcp.json", "https://agent-plugins.org/schemas/1.0.0/mcp.schema.json"];
|
|
71
78
|
readonly flow: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/flow.json"];
|
|
72
79
|
};
|
|
73
|
-
export declare const AGENT_KEYS: readonly ["name", "description", "format", "harness", "inputSchema", "outputSchema", "mcpServers", "skills", "memory", "loop", "model", "metadata"];
|
|
80
|
+
export declare const AGENT_KEYS: readonly ["name", "description", "format", "harness", "inputSchema", "outputSchema", "mcpServers", "skills", "memory", "loop", "model", "engine", "metadata"];
|
|
74
81
|
export declare const TRIGGER_KEYS: readonly ["schedule", "timezone", "at", "webhook", "session"];
|
|
75
82
|
export declare const MCP_KEYS: readonly ["$schema", "mcpServers"];
|
|
76
83
|
export declare const SERVER_KEYS: readonly ["type", "url", "headers"];
|