@nylorun/core 0.33.0-beta → 0.34.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 +79 -0
- package/dist/compatibility.d.ts +17 -1
- package/dist/compatibility.js +16 -0
- package/dist/contracts.d.ts +438 -11
- package/dist/contracts.js +196 -16
- 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 +52 -0
- package/dist/engine/blocks.js +155 -0
- package/dist/engine/explain.d.ts +36 -0
- package/dist/engine/explain.js +108 -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 +25 -0
- package/dist/engine/preview.d.ts +88 -0
- package/dist/engine/preview.js +119 -0
- package/dist/engine/projection.d.ts +61 -0
- package/dist/engine/projection.js +100 -0
- package/dist/engine/tools.d.ts +108 -0
- package/dist/engine/tools.js +460 -0
- package/dist/folder/compile.d.ts +11 -4
- package/dist/folder/compile.js +123 -13
- package/dist/folder/context.d.ts +5 -0
- package/dist/folder/decompile.js +22 -1
- package/dist/folder/engine.d.ts +70 -0
- package/dist/folder/engine.js +210 -0
- package/dist/folder/nested.js +1 -0
- package/dist/folder/schemas.js +42 -3
- package/dist/harness-api/harness-api.schema.json +11 -4
- package/dist/harness-api/json-schema.js +5 -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 +9 -4
- package/dist/harness-api/schema.js +11 -2
- package/dist/manifest-schemas.js +8 -4
- package/dist/schemas/agent-folder/agent-md.schema.json +79 -3
- package/dist/schemas/agent-folder/runtime.schema.json +13 -1
- package/dist/schemas/agent-manifest.schema.json +139 -1
- package/dist/schemas/harness-manifest.schema.json +124 -1
- package/dist/schemas/runtime-manifest.schema.json +13 -1
- package/dist/types/manifest.d.ts +47 -0
- package/package.json +5 -1
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.1.json", "https://docs.nylorun.com/schemas/agent-folder/v1/runtime.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"];
|
package/dist/folder/compile.js
CHANGED
|
@@ -9,8 +9,14 @@ import { parseJson, pointerOf } from "./json.js";
|
|
|
9
9
|
import { jsonSchemaIssues } from "./json-schema.js";
|
|
10
10
|
import { naturalCompare, suggestion, suggestions } from "./suggest.js";
|
|
11
11
|
import { folderParts, nestedTextPaths, scopedSchema } from "./nested.js";
|
|
12
|
-
|
|
12
|
+
import { ENGINE_TEXT_DIR, compiledEngine, engineBlocksOf, engineDeclarations, folderFormatOf, unusedInstructions, } from "./engine.js";
|
|
13
|
+
/** The compiler format this version builds by default: a folder with no `format`, or `format: 1`. */
|
|
13
14
|
export const AGENT_FOLDER_COMPILER = "agent-folder/1";
|
|
15
|
+
/**
|
|
16
|
+
* The formats this compiler builds: `agent-folder/1`, and `agent-folder/2` (ADR-100), whose
|
|
17
|
+
* folder declares every engine feature it uses (`folder/engine.ts`).
|
|
18
|
+
*/
|
|
19
|
+
export const AGENT_FOLDER_FORMATS = ["agent-folder/1", "agent-folder/2"];
|
|
14
20
|
/**
|
|
15
21
|
* What a folder may hold, unless `compileAgentFolder` is given other limits (a Tenant's Runtime
|
|
16
22
|
* limits `folderFiles`, `folderBytes` and `folderTextFileBytes`, which default to these).
|
|
@@ -35,13 +41,18 @@ const AGENT_PLUGINS_MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.sc
|
|
|
35
41
|
*/
|
|
36
42
|
export const FOLDER_SCHEMAS = "https://docs.nylorun.com/schemas/agent-folder/v1/";
|
|
37
43
|
export const SCHEMA_URLS = {
|
|
38
|
-
runtime: [
|
|
44
|
+
runtime: [
|
|
45
|
+
`${FOLDER_SCHEMAS}runtime.1.json`,
|
|
46
|
+
`${FOLDER_SCHEMAS}runtime.json`,
|
|
47
|
+
"https://docs.nylorun.com/schemas/runtime-manifest/v1.1.json",
|
|
48
|
+
"https://docs.nylorun.com/schemas/runtime-manifest/v1.json",
|
|
49
|
+
],
|
|
39
50
|
tool: [`${FOLDER_SCHEMAS}tool.json`],
|
|
40
51
|
mcp: [`${FOLDER_SCHEMAS}mcp.json`, AGENT_PLUGINS_MCP_SCHEMA],
|
|
41
52
|
flow: [`${FOLDER_SCHEMAS}flow.json`],
|
|
42
53
|
};
|
|
43
54
|
const SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
44
|
-
export const AGENT_KEYS = ["name", "description", "format", "harness", "inputSchema", "outputSchema", "mcpServers", "skills", "memory", "loop", "model", "metadata"];
|
|
55
|
+
export const AGENT_KEYS = ["name", "description", "format", "harness", "inputSchema", "outputSchema", "mcpServers", "skills", "memory", "loop", "model", "engine", "metadata"];
|
|
45
56
|
const SKILL_KEYS = ["name", "description", "license", "compatibility", "metadata", "allowed-tools"];
|
|
46
57
|
export const TRIGGER_KEYS = ["schedule", "timezone", "at", "webhook", "session"];
|
|
47
58
|
export const MCP_KEYS = ["$schema", "mcpServers"];
|
|
@@ -141,6 +152,9 @@ function classify(path) {
|
|
|
141
152
|
return base.endsWith(".json") ? { kind: "schema" } : { code: "reserved_directory", error: "schemas/ holds JSON Schema files (.json)" };
|
|
142
153
|
if (top === ".nylorun")
|
|
143
154
|
return { kind: "other" };
|
|
155
|
+
// A block's wording, replaced (agent-folder/2, `engine.instructions`): read when it is named.
|
|
156
|
+
if (top === ENGINE_TEXT_DIR && base.endsWith(".md"))
|
|
157
|
+
return { kind: "engine_text" };
|
|
144
158
|
if (base.endsWith(".schema.json"))
|
|
145
159
|
return { kind: "schema" };
|
|
146
160
|
return { kind: "other" };
|
|
@@ -160,6 +174,7 @@ export function folderTextPaths(entries) {
|
|
|
160
174
|
kind.kind === "trigger" ||
|
|
161
175
|
kind.kind === "schema" ||
|
|
162
176
|
kind.kind === "flow" ||
|
|
177
|
+
kind.kind === "engine_text" ||
|
|
163
178
|
(kind.kind === "skill" && entry.path.split("/").length === 3 && entry.path.endsWith(`/${SKILL_ENTRY}`));
|
|
164
179
|
if (textual)
|
|
165
180
|
paths.push(entry.path);
|
|
@@ -198,6 +213,8 @@ const show = (value) => JSON.stringify(value) ?? String(value);
|
|
|
198
213
|
export function compileAgentFolder(input, scope) {
|
|
199
214
|
const limits = { ...AGENT_FOLDER_LIMITS, ...input.limits };
|
|
200
215
|
const diagnostics = [];
|
|
216
|
+
/** The folder's format: the uploaded folder's `format`, which a folder inside it shares. */
|
|
217
|
+
let format = scope?.engineFacts?.format ?? 1;
|
|
201
218
|
const parsed = new Map();
|
|
202
219
|
const report = (severity, code, message, file, path, options = {}) => {
|
|
203
220
|
let at = options.at;
|
|
@@ -452,8 +469,10 @@ export function compileAgentFolder(input, scope) {
|
|
|
452
469
|
error("description_missing", "description is required: what the agent does, in a sentence", AGENT_FILE, front.description === undefined ? undefined : ["description"]);
|
|
453
470
|
else
|
|
454
471
|
description = front.description.trim();
|
|
455
|
-
if (
|
|
456
|
-
error("format_unsupported", `format ${JSON.stringify(front.format)} is not supported: this compiler builds
|
|
472
|
+
if (!scope && folderFormatOf(front.format) === undefined)
|
|
473
|
+
error("format_unsupported", `format ${JSON.stringify(front.format)} is not supported: this compiler builds ${AGENT_FOLDER_FORMATS.join(" and ")} (the default, ${AGENT_FOLDER_COMPILER})`, AGENT_FILE, ["format"]);
|
|
474
|
+
else if (!scope)
|
|
475
|
+
format = folderFormatOf(front.format);
|
|
457
476
|
if (front.harness !== undefined) {
|
|
458
477
|
if (HarnessIdSchema.safeParse(front.harness).success)
|
|
459
478
|
harness.id = front.harness;
|
|
@@ -538,6 +557,69 @@ export function compileAgentFolder(input, scope) {
|
|
|
538
557
|
checkSchedule(RUNTIME_FILE, ["triggers", id], trigger);
|
|
539
558
|
}
|
|
540
559
|
}
|
|
560
|
+
// --- engine: (agent-folder/2, ADR-100; folder/engine.ts) -------------------------------
|
|
561
|
+
/** Whether the session's Agent has a computer: the uploaded folder's runtime kind. */
|
|
562
|
+
const runtimeKind = isObject(runtime) && typeof runtime.kind === "string" ? runtime.kind : "none";
|
|
563
|
+
const computer = scope?.engineFacts ? scope.engineFacts.computer : runtimeKind === "virtual" || runtimeKind === "pod";
|
|
564
|
+
const role = scope?.role === "subagent" ? "subagent" : "root";
|
|
565
|
+
let declared;
|
|
566
|
+
/** The engine text files a block's wording was read from. */
|
|
567
|
+
const engineTexts = new Set();
|
|
568
|
+
if (agent && scope?.role !== "plugin") {
|
|
569
|
+
const migrate = "add format: agent-folder/2 to AGENT.md, or run nylorun migrate folder <dir> --to 2, which writes the declarations that keep what the agent gets today";
|
|
570
|
+
if (format === 1) {
|
|
571
|
+
if (front.engine !== undefined)
|
|
572
|
+
error("engine_format", `engine declares the engine features of an agent-folder/2 folder, and this folder is agent-folder/1, which gets them all by default. Fix: ${migrate}`, AGENT_FILE, ["engine"], {
|
|
573
|
+
key: true,
|
|
574
|
+
});
|
|
575
|
+
if (isObject(front.memory) && front.memory.index !== undefined)
|
|
576
|
+
error("engine_format", `memory.index is a key of agent-folder/2: an agent-folder/1 folder always pins its memory index. Fix: ${migrate}`, AGENT_FILE, ["memory", "index"], {
|
|
577
|
+
key: true,
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
else if ([...kinds.values()].includes("flow")) {
|
|
581
|
+
if (front.engine !== undefined)
|
|
582
|
+
error("flow_refused", "engine is an agent's: set it in the AGENT.md of each agent under agents/ that uses an engine feature", AGENT_FILE, ["engine"], { key: true });
|
|
583
|
+
}
|
|
584
|
+
else {
|
|
585
|
+
declared = engineDeclarations(front.engine, {
|
|
586
|
+
error: (code, message, path, options) => error(code, message, AGENT_FILE, path, options),
|
|
587
|
+
computer,
|
|
588
|
+
role,
|
|
589
|
+
...(scope?.engineFacts?.engine === undefined ? {} : { parent: scope.engineFacts.engine }),
|
|
590
|
+
text: (path, at) => {
|
|
591
|
+
if (kinds.get(path) !== "engine_text") {
|
|
592
|
+
error("engine_text_missing", `${path} is not a file in the folder: write the block's wording there, in Markdown`, AGENT_FILE, at);
|
|
593
|
+
return undefined;
|
|
594
|
+
}
|
|
595
|
+
const text = textOf(path);
|
|
596
|
+
if (text === undefined)
|
|
597
|
+
return undefined;
|
|
598
|
+
engineTexts.add(path);
|
|
599
|
+
const trimmed = trimBlankLines(text);
|
|
600
|
+
if (trimmed === "") {
|
|
601
|
+
error("engine_text_empty", `${path} is empty: write the block's wording, or leave engine.instructions out to keep the engine's`, path);
|
|
602
|
+
return undefined;
|
|
603
|
+
}
|
|
604
|
+
return trimmed;
|
|
605
|
+
},
|
|
606
|
+
});
|
|
607
|
+
if (declared && !scope && computer && (declared.engine.sandbox ?? []).length === 0)
|
|
608
|
+
warn("sandbox_undeclared", `The runtime has a computer (kind ${JSON.stringify(runtimeKind)}), and engine.sandbox names no sandbox tool, so the agent gets no shell or file tools and no sandbox note. Fix: engine: { sandbox: [bash, read, write, edit, grep, glob] } (any of them), or a runtime without a computer`, AGENT_FILE, front.engine === undefined ? undefined : ["engine"], front.engine === undefined ? { at: { line: 1, column: 1 } } : { key: true });
|
|
609
|
+
origins.push([["harness", "engine"], { file: AGENT_FILE, path: ["engine"] }]);
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
for (const [path, kind] of kinds)
|
|
613
|
+
if (kind === "engine_text" && !engineTexts.has(path) && !(declared && Object.values(declared.sources).includes(path)))
|
|
614
|
+
report("note", "file_not_compiled", "Kept with the source; not part of the agent", path);
|
|
615
|
+
/** What a folder inside this one knows of it (folder/nested.ts). */
|
|
616
|
+
const engineFacts = () => scope?.engineFacts ?? {
|
|
617
|
+
format,
|
|
618
|
+
computer,
|
|
619
|
+
...(format === 2 && declared ? { engine: declared.engine } : {}),
|
|
620
|
+
memory: isObject(front.memory),
|
|
621
|
+
selfWake: isObject(runtime) && runtime.selfWake === true,
|
|
622
|
+
};
|
|
541
623
|
const derivedSlots = new Map();
|
|
542
624
|
/**
|
|
543
625
|
* A slot for `credential`, derived when runtime.json does not declare it. `at` places it in a
|
|
@@ -585,6 +667,7 @@ export function compileAgentFolder(input, scope) {
|
|
|
585
667
|
suggest: suggestion,
|
|
586
668
|
compile: compileAgentFolder,
|
|
587
669
|
folderTextPaths,
|
|
670
|
+
engineFacts,
|
|
588
671
|
});
|
|
589
672
|
// --- mcp.json --------------------------------------------------------------------------
|
|
590
673
|
const servers = {};
|
|
@@ -931,7 +1014,34 @@ export function compileAgentFolder(input, scope) {
|
|
|
931
1014
|
seeded[path.slice("files/".length)] = `sha256:${byPath.get(path).sha256}`;
|
|
932
1015
|
// --- agents/, flow.json and plugins/ (folder/nested.ts) ----------------------------------
|
|
933
1016
|
if (!parts.compose())
|
|
934
|
-
return finish(diagnostics);
|
|
1017
|
+
return finish(format, diagnostics);
|
|
1018
|
+
// --- The engine blocks the agent gets (agent-folder/2) ------------------------------------
|
|
1019
|
+
if (declared && harness.kind !== "workflow") {
|
|
1020
|
+
const facts = engineFacts();
|
|
1021
|
+
const loop = isObject(harness.loop) && (harness.id === undefined || harness.id === DEFAULT_HARNESS) ? harness.loop : {};
|
|
1022
|
+
const memory = isObject(harness.memory) ? harness.memory : undefined;
|
|
1023
|
+
const names = engineBlocksOf({
|
|
1024
|
+
engine: declared.engine,
|
|
1025
|
+
...(Array.isArray(harness.tools) ? { tools: harness.tools } : {}),
|
|
1026
|
+
...(isObject(harness.skills) ? { skills: harness.skills } : {}),
|
|
1027
|
+
...(isObject(harness.mcpServers) ? { mcpServers: harness.mcpServers } : {}),
|
|
1028
|
+
}, {
|
|
1029
|
+
computer,
|
|
1030
|
+
selfWake: facts.selfWake,
|
|
1031
|
+
...(role === "root"
|
|
1032
|
+
? memory
|
|
1033
|
+
? { memory: { root: true, ...(memory.access === "read_only" ? { access: "read_only" } : {}), index: memory.index !== false } }
|
|
1034
|
+
: {}
|
|
1035
|
+
: facts.memory
|
|
1036
|
+
? { memory: { root: false } }
|
|
1037
|
+
: {}),
|
|
1038
|
+
plan: role === "root" && loop.plan === true,
|
|
1039
|
+
connections: role === "root" && loop.connections === true,
|
|
1040
|
+
});
|
|
1041
|
+
for (const name of unusedInstructions(declared.engine, names))
|
|
1042
|
+
warn("engine_text_unused", `engine.instructions.${name} replaces the wording of the ${name} block, and the agent does not get that block, so the text is never read`, AGENT_FILE, ["engine", "instructions", name], { key: true });
|
|
1043
|
+
harness.engine = compiledEngine(declared.engine, names, declared.sources);
|
|
1044
|
+
}
|
|
935
1045
|
// --- The runtime section -----------------------------------------------------------------
|
|
936
1046
|
const needsRuntime = derivedSlots.size > 0 || Object.keys(triggers).length > 0 || Object.keys(seeded).length > 0;
|
|
937
1047
|
if (!runtime && needsRuntime)
|
|
@@ -952,7 +1062,7 @@ export function compileAgentFolder(input, scope) {
|
|
|
952
1062
|
}
|
|
953
1063
|
// --- Every field checked as the Runtime checks the manifest ------------------------------
|
|
954
1064
|
if (diagnostics.some((item) => item.severity === "error") || name === undefined || description === undefined)
|
|
955
|
-
return finish(diagnostics);
|
|
1065
|
+
return finish(format, diagnostics);
|
|
956
1066
|
const document = {
|
|
957
1067
|
manifestSchemaVersion: AGENT_MANIFEST_V8_SCHEMA_VERSION,
|
|
958
1068
|
name,
|
|
@@ -988,10 +1098,10 @@ export function compileAgentFolder(input, scope) {
|
|
|
988
1098
|
continue;
|
|
989
1099
|
place(issue, [], fromOrigins);
|
|
990
1100
|
}
|
|
991
|
-
return finish(diagnostics);
|
|
1101
|
+
return finish(format, diagnostics);
|
|
992
1102
|
}
|
|
993
1103
|
if (diagnostics.some((item) => item.severity === "error"))
|
|
994
|
-
return finish(diagnostics);
|
|
1104
|
+
return finish(format, diagnostics);
|
|
995
1105
|
const manifest = checked.data;
|
|
996
1106
|
// --- What the Runtime checks at save, where it needs no Tenant ---------------------------
|
|
997
1107
|
const hasRuntimeFile = byPath.has(RUNTIME_FILE);
|
|
@@ -1029,8 +1139,8 @@ export function compileAgentFolder(input, scope) {
|
|
|
1029
1139
|
: `${field} ${POD_ONLY[field]}`, RUNTIME_FILE, [field], { key: true, pointer: pointerOf(["runtime", field]) });
|
|
1030
1140
|
}
|
|
1031
1141
|
if (diagnostics.some((item) => item.severity === "error"))
|
|
1032
|
-
return finish(diagnostics);
|
|
1033
|
-
return finish(diagnostics, manifest);
|
|
1142
|
+
return finish(format, diagnostics);
|
|
1143
|
+
return finish(format, diagnostics, manifest);
|
|
1034
1144
|
/** A schema issue in the compiler's words, at the file and field that wrote it. */
|
|
1035
1145
|
function place(issue, base, where) {
|
|
1036
1146
|
const full = [...base, ...issue.path];
|
|
@@ -1187,13 +1297,13 @@ function issueMessage(issue, field, value) {
|
|
|
1187
1297
|
return `${named} does not fit any form it can take`;
|
|
1188
1298
|
}
|
|
1189
1299
|
}
|
|
1190
|
-
function finish(diagnostics, manifest) {
|
|
1300
|
+
function finish(format, diagnostics, manifest) {
|
|
1191
1301
|
const order = { error: 0, warning: 1, info: 2, note: 3 };
|
|
1192
1302
|
const sorted = [...diagnostics].sort((a, b) => order[a.severity] - order[b.severity] ||
|
|
1193
1303
|
compare(a.file ?? "", b.file ?? "") ||
|
|
1194
1304
|
(a.line ?? 0) - (b.line ?? 0) ||
|
|
1195
1305
|
(a.column ?? 0) - (b.column ?? 0));
|
|
1196
|
-
return { ...(manifest === undefined ? {} : { manifest }), diagnostics: sorted, compiler:
|
|
1306
|
+
return { ...(manifest === undefined ? {} : { manifest }), diagnostics: sorted, compiler: AGENT_FOLDER_FORMATS[format - 1] };
|
|
1197
1307
|
}
|
|
1198
1308
|
/** The closest recorded position for `path` in `file`: the field, else its nearest parent. */
|
|
1199
1309
|
function locate(file, path) {
|
package/dist/folder/context.d.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { AgentFolderDiagnostic, AgentFolderEntry, AgentFolderFix, CompileAgentFolderInput, CompiledAgentFolder } from "./compile.js";
|
|
8
8
|
import { type Position } from "./json.js";
|
|
9
|
+
import type { EngineScopeFacts } from "./engine.js";
|
|
9
10
|
/** A JSON Schema named by `/x` from a folder inside another: found, refused, or already reported. */
|
|
10
11
|
export type SchemaLookup = {
|
|
11
12
|
readonly schema: Record<string, unknown>;
|
|
@@ -23,6 +24,8 @@ export interface FolderScope {
|
|
|
23
24
|
readonly deriveSlot: (credential: string, type: "bearer" | "headers", url: string, file: string, at: Position | undefined, header?: string) => void;
|
|
24
25
|
/** `/x`: a JSON Schema file of the uploaded folder, by its path there. */
|
|
25
26
|
readonly schema: (target: string) => SchemaLookup;
|
|
27
|
+
/** The uploaded folder's format, computer and engine declarations (agent-folder/2, `engine.ts`). */
|
|
28
|
+
readonly engineFacts?: EngineScopeFacts;
|
|
26
29
|
}
|
|
27
30
|
/** What a loop manifest embeds for an agent of a flow: agent manifest v7 or workflow manifest v3. */
|
|
28
31
|
export type EmbeddedAgent = Record<string, unknown>;
|
|
@@ -78,6 +81,8 @@ export interface FolderContext {
|
|
|
78
81
|
readonly suggest: (name: string, known: readonly string[]) => string | undefined;
|
|
79
82
|
readonly compile: (input: CompileAgentFolderInput, scope?: FolderScope) => CompiledAgentFolder;
|
|
80
83
|
readonly folderTextPaths: (entries: readonly AgentFolderEntry[]) => string[];
|
|
84
|
+
/** What a folder inside this one knows of it: its format, computer and engine declarations. */
|
|
85
|
+
readonly engineFacts: () => EngineScopeFacts;
|
|
81
86
|
}
|
|
82
87
|
export declare const isObject: (value: unknown) => value is Record<string, unknown>;
|
|
83
88
|
export declare const compare: (a: string, b: string) => -1 | 0 | 1;
|
package/dist/folder/decompile.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* Each manifest field goes where the compiler reads it:
|
|
8
8
|
*
|
|
9
|
-
* - `name`, `description`, `metadata`, `harness.id`, `memory`, `loop`, `model`,
|
|
9
|
+
* - `name`, `description`, `metadata`, `harness.id`, `memory`, `loop`, `model`, `engine` (with
|
|
10
|
+
* `format: agent-folder/2`; each replaced wording as `engine/<block>.md`), and this agent's
|
|
10
11
|
* server and skill settings: `AGENT.md` frontmatter. `harness.outputSchema`:
|
|
11
12
|
* `output.schema.json`, named by `outputSchema`.
|
|
12
13
|
* - `harness.instructions`: the first as `AGENT.md`'s body, each other as
|
|
@@ -108,6 +109,7 @@ export function folderOfManifest(manifest, options = {}) {
|
|
|
108
109
|
};
|
|
109
110
|
const identity = { name: manifest.name, description: manifest.description, metadata: manifest.metadata };
|
|
110
111
|
const root = { prefix: "", role: "root" };
|
|
112
|
+
writer.declares = !isWorkflow(manifest.harness) && manifest.harness.engine !== undefined;
|
|
111
113
|
if (isWorkflow(manifest.harness))
|
|
112
114
|
writeFlow(writer, root, identity, manifest.harness);
|
|
113
115
|
else
|
|
@@ -272,6 +274,25 @@ function writeAgent(writer, place, identity, harness) {
|
|
|
272
274
|
else
|
|
273
275
|
note("harness.loop is not a map, which AGENT.md needs: it is left out.");
|
|
274
276
|
}
|
|
277
|
+
// agent-folder/2 (ADR-100): the declarations, each replaced wording a file under engine/. The
|
|
278
|
+
// blocks are the compiler's to list again.
|
|
279
|
+
if (harness.engine !== undefined && !root && !writer.declares)
|
|
280
|
+
note("The subagent declares its engine features and the manifest does not: an agent-folder/1 folder cannot say so, so it gets the defaults.");
|
|
281
|
+
else if (harness.engine !== undefined) {
|
|
282
|
+
if (root)
|
|
283
|
+
front.format = "agent-folder/2";
|
|
284
|
+
const { instructions, blocks: _, ...declared } = harness.engine;
|
|
285
|
+
const engine = { ...declared };
|
|
286
|
+
for (const [block, text] of Object.entries(instructions ?? {})) {
|
|
287
|
+
const file = `engine/${block}.md`;
|
|
288
|
+
files.set(at + file, `${text}\n`);
|
|
289
|
+
engine.instructions = { ...engine.instructions, [block]: file };
|
|
290
|
+
}
|
|
291
|
+
if (Object.keys(engine).length > 0)
|
|
292
|
+
front.engine = engine;
|
|
293
|
+
}
|
|
294
|
+
else if (!root && writer.declares)
|
|
295
|
+
note("The subagent declares no engine features, and in an agent-folder/2 folder it gets none: it is written as such.");
|
|
275
296
|
if (identity.metadata !== undefined) {
|
|
276
297
|
if (isObject(identity.metadata))
|
|
277
298
|
front.metadata = identity.metadata;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type EngineBlockName } from "../engine/names.js";
|
|
2
|
+
import type { HarnessEngine, SkillManifest, ToolManifest } from "../types/manifest.js";
|
|
3
|
+
import type { ReportOptions } from "./context.js";
|
|
4
|
+
/** The keys of `AGENT.md`'s `engine:` block. */
|
|
5
|
+
export declare const ENGINE_KEYS: readonly ["sandbox", "artifacts", "outputs", "toolSearch", "instructions"];
|
|
6
|
+
/** Where a folder keeps the files that replace a block's wording. */
|
|
7
|
+
export declare const ENGINE_TEXT_DIR = "engine";
|
|
8
|
+
/** A folder's format: 1 (`agent-folder/1`, the default) or 2 (`agent-folder/2`); undefined when it is neither. */
|
|
9
|
+
export declare function folderFormatOf(value: unknown): 1 | 2 | undefined;
|
|
10
|
+
/** What a folder inside another needs to know of the folder that holds it. */
|
|
11
|
+
export interface EngineScopeFacts {
|
|
12
|
+
readonly format: 1 | 2;
|
|
13
|
+
/** The uploaded folder's runtime has a computer (kind `virtual` or `pod`). */
|
|
14
|
+
readonly computer: boolean;
|
|
15
|
+
/** The root agent's declarations, under format 2: a subagent's are a subset. */
|
|
16
|
+
readonly engine?: HarnessEngine;
|
|
17
|
+
/** The root agent has memory: a subagent may view it. */
|
|
18
|
+
readonly memory: boolean;
|
|
19
|
+
/** The uploaded folder's runtime sets `selfWake`. */
|
|
20
|
+
readonly selfWake: boolean;
|
|
21
|
+
}
|
|
22
|
+
type Fail = (code: string, message: string, path?: readonly PropertyKey[], options?: ReportOptions) => void;
|
|
23
|
+
/**
|
|
24
|
+
* `AGENT.md`'s `engine:` block, checked: the declarations, with each replaced wording read from
|
|
25
|
+
* its file (`text`), and the files they came from (`sources`). Undefined, with the errors
|
|
26
|
+
* reported, when it is not one. `parent` is a subagent's parent's declarations.
|
|
27
|
+
*/
|
|
28
|
+
export declare function engineDeclarations(value: unknown, options: {
|
|
29
|
+
readonly error: Fail;
|
|
30
|
+
readonly computer: boolean;
|
|
31
|
+
readonly role: "root" | "subagent";
|
|
32
|
+
readonly parent?: HarnessEngine;
|
|
33
|
+
/** The text of a file of the folder that replaces a block's wording, or undefined after reporting why not. */
|
|
34
|
+
readonly text: (path: string, at: readonly PropertyKey[]) => string | undefined;
|
|
35
|
+
}): {
|
|
36
|
+
engine: HarnessEngine;
|
|
37
|
+
sources: Partial<Record<EngineBlockName, string>>;
|
|
38
|
+
} | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* The text blocks an agent gets, from what it declares and what the folder says of its session:
|
|
41
|
+
* whether its runtime has a computer and sets `selfWake`, its skills, memory and loop settings,
|
|
42
|
+
* and whether its MCP tools may be deferred. The harness's own projection decides them
|
|
43
|
+
* (`engineProjection`), so the list is what a session's system text holds.
|
|
44
|
+
*/
|
|
45
|
+
export declare function engineBlocksOf(agent: {
|
|
46
|
+
readonly engine: HarnessEngine;
|
|
47
|
+
readonly tools?: readonly ToolManifest[];
|
|
48
|
+
readonly skills?: Readonly<Record<string, SkillManifest>>;
|
|
49
|
+
readonly mcpServers?: Readonly<Record<string, {
|
|
50
|
+
readonly deferred?: boolean;
|
|
51
|
+
readonly tools?: Readonly<Record<string, {
|
|
52
|
+
readonly deferred?: boolean;
|
|
53
|
+
}>>;
|
|
54
|
+
}>>;
|
|
55
|
+
}, facts: {
|
|
56
|
+
readonly computer: boolean;
|
|
57
|
+
readonly selfWake: boolean;
|
|
58
|
+
readonly memory?: {
|
|
59
|
+
readonly root: boolean;
|
|
60
|
+
readonly access?: "read_write" | "read_only";
|
|
61
|
+
readonly index?: boolean;
|
|
62
|
+
};
|
|
63
|
+
readonly plan: boolean;
|
|
64
|
+
readonly connections: boolean;
|
|
65
|
+
}): EngineBlockName[];
|
|
66
|
+
/** `harness.engine` as the compiled manifest holds it: the declarations, then the blocks. */
|
|
67
|
+
export declare function compiledEngine(engine: HarnessEngine, blocks: readonly EngineBlockName[], sources: Partial<Record<EngineBlockName, string>>): HarnessEngine;
|
|
68
|
+
/** The blocks whose wording `engine` replaces that the agent does not get. */
|
|
69
|
+
export declare function unusedInstructions(engine: HarnessEngine, blocks: readonly EngineBlockName[]): EngineBlockName[];
|
|
70
|
+
export {};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `agent-folder/2` (ADR-100): a folder declares every engine feature it uses, and our engine adds
|
|
3
|
+
* nothing else. `AGENT.md` names the format (`format: agent-folder/2`, or `2`) and, in its
|
|
4
|
+
* `engine:` block, the features no other key declares:
|
|
5
|
+
*
|
|
6
|
+
* ```yaml
|
|
7
|
+
* format: agent-folder/2
|
|
8
|
+
* memory: { access: read_write, index: true } # index can be turned off
|
|
9
|
+
* engine:
|
|
10
|
+
* sandbox: [bash, read, write, edit, grep, glob] # any subset; needs a computer in runtime.json
|
|
11
|
+
* artifacts: { read: true, save: false } # save needs a computer
|
|
12
|
+
* outputs: true # save /workspace/outputs when a turn ends; needs a computer
|
|
13
|
+
* toolSearch: false # no automatic deferral; a server's own `deferred` still applies
|
|
14
|
+
* instructions: # a block's wording, replaced by a file under engine/
|
|
15
|
+
* memory: engine/memory.md
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* The compiled manifest's `harness.engine` holds the declarations, each replaced wording's text,
|
|
19
|
+
* and the text blocks the agent gets (`blocks`), each with its version and hash, so an engine
|
|
20
|
+
* release that changes a block changes the version's hash. A subagent (`agents/<id>/`) declares
|
|
21
|
+
* its own `engine:` block, a subset of its parent's; without one it gets no engine feature.
|
|
22
|
+
*/
|
|
23
|
+
import { SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE } from "../utils/sandbox.js";
|
|
24
|
+
import { ENGINE_BLOCK_NAMES, isEngineBlockName } from "../engine/names.js";
|
|
25
|
+
import { blockRefs } from "../engine/blocks.js";
|
|
26
|
+
import { DEFAULT_ENGINE_TOOL_LIMITS, engineProjection } from "../engine/projection.js";
|
|
27
|
+
import { TOOL_SEARCH_TOOL } from "../engine/tools.js";
|
|
28
|
+
import { suggestion } from "./suggest.js";
|
|
29
|
+
/** The keys of `AGENT.md`'s `engine:` block. */
|
|
30
|
+
export const ENGINE_KEYS = ["sandbox", "artifacts", "outputs", "toolSearch", "instructions"];
|
|
31
|
+
const ARTIFACT_KEYS = ["read", "save"];
|
|
32
|
+
/** Where a folder keeps the files that replace a block's wording. */
|
|
33
|
+
export const ENGINE_TEXT_DIR = "engine";
|
|
34
|
+
/** A folder's format: 1 (`agent-folder/1`, the default) or 2 (`agent-folder/2`); undefined when it is neither. */
|
|
35
|
+
export function folderFormatOf(value) {
|
|
36
|
+
if (value === undefined || value === 1 || value === "agent-folder/1")
|
|
37
|
+
return 1;
|
|
38
|
+
if (value === 2 || value === "agent-folder/2")
|
|
39
|
+
return 2;
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
43
|
+
/**
|
|
44
|
+
* `AGENT.md`'s `engine:` block, checked: the declarations, with each replaced wording read from
|
|
45
|
+
* its file (`text`), and the files they came from (`sources`). Undefined, with the errors
|
|
46
|
+
* reported, when it is not one. `parent` is a subagent's parent's declarations.
|
|
47
|
+
*/
|
|
48
|
+
export function engineDeclarations(value, options) {
|
|
49
|
+
const { error, computer, role, parent } = options;
|
|
50
|
+
const sources = {};
|
|
51
|
+
if (value === undefined)
|
|
52
|
+
return { engine: {}, sources };
|
|
53
|
+
if (!isObject(value)) {
|
|
54
|
+
error("value_invalid", `engine is a map of the engine features the agent uses: ${ENGINE_KEYS.join(", ")}`, ["engine"]);
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
let valid = true;
|
|
58
|
+
const fail = (...args) => {
|
|
59
|
+
valid = false;
|
|
60
|
+
error(...args);
|
|
61
|
+
};
|
|
62
|
+
const needsComputer = (what, path) => fail("engine_needs_computer", `${what} needs a computer, and the runtime has none. Fix: set "kind": "virtual" (or "pod") in runtime.json, or leave it out`, path);
|
|
63
|
+
const subset = (what, path) => fail("engine_subset", `${what}, and the agent that holds this subagent does not: a subagent's engine block is a subset of its parent's`, path);
|
|
64
|
+
for (const key of Object.keys(value))
|
|
65
|
+
if (!ENGINE_KEYS.includes(key)) {
|
|
66
|
+
const close = suggestion(key, ENGINE_KEYS);
|
|
67
|
+
fail("unknown_key", `Unknown key '${key}'.${close ? ` Did you mean '${close}'?` : ` Known keys: ${ENGINE_KEYS.join(", ")}.`}`, ["engine", key], {
|
|
68
|
+
key: true,
|
|
69
|
+
rename: ENGINE_KEYS,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
const engine = {};
|
|
73
|
+
// sandbox: any of the six, each once.
|
|
74
|
+
if (value.sandbox !== undefined) {
|
|
75
|
+
const at = ["engine", "sandbox"];
|
|
76
|
+
if (!Array.isArray(value.sandbox) || !value.sandbox.every((item) => typeof item === "string"))
|
|
77
|
+
fail("value_invalid", `engine.sandbox is a list of sandbox tools: any of ${SANDBOX_TOOL_NAMES.join(", ")}`, at);
|
|
78
|
+
else {
|
|
79
|
+
const names = [];
|
|
80
|
+
for (const [index, name] of value.sandbox.entries()) {
|
|
81
|
+
if (!SANDBOX_TOOL_NAMES.includes(name)) {
|
|
82
|
+
const close = suggestion(name, SANDBOX_TOOL_NAMES);
|
|
83
|
+
fail("value_invalid", `${name} is not a sandbox tool: ${SANDBOX_TOOL_NAMES.join(", ")}.${close ? ` Did you mean '${close}'?` : ""}`, [...at, index]);
|
|
84
|
+
}
|
|
85
|
+
else if (names.includes(name))
|
|
86
|
+
fail("value_invalid", `engine.sandbox names ${name} twice`, [...at, index]);
|
|
87
|
+
else
|
|
88
|
+
names.push(name);
|
|
89
|
+
}
|
|
90
|
+
if (names.length > 0 && !computer)
|
|
91
|
+
needsComputer("engine.sandbox", at);
|
|
92
|
+
const outside = names.filter((name) => parent !== undefined && !(parent.sandbox ?? []).includes(name));
|
|
93
|
+
if (role === "subagent" && outside.length > 0)
|
|
94
|
+
subset(`engine.sandbox names ${outside.join(", ")}`, at);
|
|
95
|
+
engine.sandbox = SANDBOX_TOOL_NAMES.filter((name) => names.includes(name));
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (value.artifacts !== undefined) {
|
|
99
|
+
const at = ["engine", "artifacts"];
|
|
100
|
+
if (!isObject(value.artifacts))
|
|
101
|
+
fail("value_invalid", "engine.artifacts is a map: read and save, each true or false", at);
|
|
102
|
+
else {
|
|
103
|
+
const artifacts = {};
|
|
104
|
+
for (const [key, flag] of Object.entries(value.artifacts)) {
|
|
105
|
+
if (!ARTIFACT_KEYS.includes(key)) {
|
|
106
|
+
fail("unknown_key", `Unknown key '${key}'. Known keys: read, save.`, [...at, key], { key: true, rename: ARTIFACT_KEYS });
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
if (typeof flag !== "boolean") {
|
|
110
|
+
fail("value_invalid", `engine.artifacts.${key} is true or false`, [...at, key]);
|
|
111
|
+
continue;
|
|
112
|
+
}
|
|
113
|
+
artifacts[key] = flag;
|
|
114
|
+
}
|
|
115
|
+
if (artifacts.save === true && !computer)
|
|
116
|
+
needsComputer("engine.artifacts.save (save_artifact saves a file of the sandbox)", [...at, "save"]);
|
|
117
|
+
if (role === "subagent" && artifacts.read === true && parent?.artifacts?.read !== true)
|
|
118
|
+
subset("engine.artifacts.read is true", [...at, "read"]);
|
|
119
|
+
if (role === "subagent" && artifacts.save === true && parent?.artifacts?.save !== true)
|
|
120
|
+
subset("engine.artifacts.save is true", [...at, "save"]);
|
|
121
|
+
engine.artifacts = artifacts;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (value.outputs !== undefined) {
|
|
125
|
+
const at = ["engine", "outputs"];
|
|
126
|
+
if (typeof value.outputs !== "boolean")
|
|
127
|
+
fail("value_invalid", `engine.outputs is true or false: true saves ${SANDBOX_WORKSPACE}/outputs when a turn ends`, at);
|
|
128
|
+
// A subagent shares its parent's sandbox: with outputs, it is told of the folder its parent's
|
|
129
|
+
// turn saves.
|
|
130
|
+
else if (role === "subagent" && value.outputs && parent?.outputs !== true)
|
|
131
|
+
subset("engine.outputs is true", at);
|
|
132
|
+
else {
|
|
133
|
+
if (value.outputs && !computer)
|
|
134
|
+
needsComputer(`engine.outputs (${SANDBOX_WORKSPACE}/outputs is a folder of the sandbox)`, at);
|
|
135
|
+
engine.outputs = value.outputs;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (value.toolSearch !== undefined) {
|
|
139
|
+
const at = ["engine", "toolSearch"];
|
|
140
|
+
if (typeof value.toolSearch !== "boolean")
|
|
141
|
+
fail("value_invalid", "engine.toolSearch is true or false: true defers MCP tools behind tool_search past the threshold", at);
|
|
142
|
+
else {
|
|
143
|
+
if (role === "subagent" && value.toolSearch && parent?.toolSearch !== true)
|
|
144
|
+
subset("engine.toolSearch is true", at);
|
|
145
|
+
engine.toolSearch = value.toolSearch;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
if (value.instructions !== undefined) {
|
|
149
|
+
const at = ["engine", "instructions"];
|
|
150
|
+
if (!isObject(value.instructions))
|
|
151
|
+
fail("value_invalid", `engine.instructions is a map of block names to Markdown files under ${ENGINE_TEXT_DIR}/: ${ENGINE_BLOCK_NAMES.join(", ")}`, at);
|
|
152
|
+
else {
|
|
153
|
+
const texts = {};
|
|
154
|
+
for (const [block, path] of Object.entries(value.instructions)) {
|
|
155
|
+
if (!isEngineBlockName(block)) {
|
|
156
|
+
const close = suggestion(block, ENGINE_BLOCK_NAMES);
|
|
157
|
+
fail("unknown_key", `${block} is not an engine text block.${close ? ` Did you mean '${close}'?` : ` The blocks are ${ENGINE_BLOCK_NAMES.join(", ")}.`}`, [...at, block], {
|
|
158
|
+
key: true,
|
|
159
|
+
rename: ENGINE_BLOCK_NAMES,
|
|
160
|
+
});
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
if (typeof path !== "string" || path === "") {
|
|
164
|
+
fail("value_invalid", `engine.instructions.${block} is the path of a Markdown file under ${ENGINE_TEXT_DIR}/, such as ${ENGINE_TEXT_DIR}/${block}.md`, [...at, block]);
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
const relative = path.replace(/^\.\//, "");
|
|
168
|
+
if (!relative.startsWith(`${ENGINE_TEXT_DIR}/`) || !relative.endsWith(".md")) {
|
|
169
|
+
fail("value_invalid", `engine.instructions.${block} names ${path}: a block's wording is a Markdown file under ${ENGINE_TEXT_DIR}/, such as ${ENGINE_TEXT_DIR}/${block}.md`, [...at, block]);
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
const text = options.text(relative, [...at, block]);
|
|
173
|
+
if (text === undefined) {
|
|
174
|
+
valid = false;
|
|
175
|
+
continue;
|
|
176
|
+
}
|
|
177
|
+
texts[block] = text;
|
|
178
|
+
sources[block] = relative;
|
|
179
|
+
}
|
|
180
|
+
if (Object.keys(texts).length > 0)
|
|
181
|
+
engine.instructions = texts;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return valid ? { engine, sources } : undefined;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* The text blocks an agent gets, from what it declares and what the folder says of its session:
|
|
188
|
+
* whether its runtime has a computer and sets `selfWake`, its skills, memory and loop settings,
|
|
189
|
+
* and whether its MCP tools may be deferred. The harness's own projection decides them
|
|
190
|
+
* (`engineProjection`), so the list is what a session's system text holds.
|
|
191
|
+
*/
|
|
192
|
+
export function engineBlocksOf(agent, facts) {
|
|
193
|
+
const projection = engineProjection(agent, { ...(facts.computer ? { sandbox: { workspace: SANDBOX_WORKSPACE } } : {}), ...(facts.selfWake ? { selfWake: true } : {}) }, DEFAULT_ENGINE_TOOL_LIMITS, facts.memory && { access: facts.memory.access ?? "read_write", root: facts.memory.root, index: facts.memory.index !== false }, facts.plan, facts.connections);
|
|
194
|
+
const names = projection.blocks.map((block) => block.name);
|
|
195
|
+
const servers = Object.values(agent.mcpServers ?? {});
|
|
196
|
+
const deferrable = servers.length > 0 &&
|
|
197
|
+
(agent.engine.toolSearch === true ||
|
|
198
|
+
servers.some((server) => server.deferred === true || Object.values(server.tools ?? {}).some((tool) => tool.deferred === true)));
|
|
199
|
+
if (deferrable && !(agent.tools ?? []).some((tool) => tool.name === TOOL_SEARCH_TOOL))
|
|
200
|
+
names.push("tool_search");
|
|
201
|
+
return names;
|
|
202
|
+
}
|
|
203
|
+
/** `harness.engine` as the compiled manifest holds it: the declarations, then the blocks. */
|
|
204
|
+
export function compiledEngine(engine, blocks, sources) {
|
|
205
|
+
return { ...engine, blocks: blockRefs(blocks, engine, sources) };
|
|
206
|
+
}
|
|
207
|
+
/** The blocks whose wording `engine` replaces that the agent does not get. */
|
|
208
|
+
export function unusedInstructions(engine, blocks) {
|
|
209
|
+
return Object.keys(engine.instructions ?? {}).filter((name) => !blocks.includes(name));
|
|
210
|
+
}
|
package/dist/folder/nested.js
CHANGED
|
@@ -128,6 +128,7 @@ function innerScope(ctx, prefix, role, namespace) {
|
|
|
128
128
|
...(namespace === undefined ? {} : { namespace }),
|
|
129
129
|
deriveSlot: (credential, type, url, file, at, header) => ctx.deriveSlot(credential, type, url, prefix + file, [], header, at),
|
|
130
130
|
schema: ctx.scope?.schema ?? rootSchema(ctx),
|
|
131
|
+
engineFacts: ctx.engineFacts(),
|
|
131
132
|
};
|
|
132
133
|
}
|
|
133
134
|
/** `/x` read from the uploaded folder: a JSON Schema file anywhere in it. */
|