@nylorun/core 0.34.0-beta → 0.36.0-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/compatibility.d.ts +9 -1
  3. package/dist/compatibility.js +8 -0
  4. package/dist/contracts.d.ts +352 -6
  5. package/dist/contracts.js +180 -6
  6. package/dist/definition/variant.js +8 -1
  7. package/dist/engine/blocks.d.ts +2 -0
  8. package/dist/engine/blocks.js +7 -0
  9. package/dist/engine/explain.d.ts +1 -1
  10. package/dist/engine/explain.js +27 -5
  11. package/dist/engine/index.d.ts +1 -0
  12. package/dist/engine/index.js +1 -0
  13. package/dist/engine/names.d.ts +1 -1
  14. package/dist/engine/names.js +1 -0
  15. package/dist/engine/preview.d.ts +6 -0
  16. package/dist/engine/preview.js +3 -1
  17. package/dist/engine/projection.d.ts +10 -6
  18. package/dist/engine/projection.js +110 -6
  19. package/dist/engine/tools.d.ts +32 -0
  20. package/dist/engine/tools.js +85 -1
  21. package/dist/folder/compile.d.ts +3 -3
  22. package/dist/folder/compile.js +82 -12
  23. package/dist/folder/engine.d.ts +14 -2
  24. package/dist/folder/engine.js +17 -3
  25. package/dist/folder/index.d.ts +2 -0
  26. package/dist/folder/index.js +2 -0
  27. package/dist/folder/migrate-v3.d.ts +20 -0
  28. package/dist/folder/migrate-v3.js +124 -0
  29. package/dist/folder/nested.js +5 -0
  30. package/dist/folder/schemas.js +19 -6
  31. package/dist/folder/v3.d.ts +66 -0
  32. package/dist/folder/v3.js +139 -0
  33. package/dist/harness-api/harness-api.schema.json +19 -4
  34. package/dist/harness-api/json-schema.js +3 -2
  35. package/dist/harness-api/schema.d.ts +6 -0
  36. package/dist/harness-api/schema.js +9 -2
  37. package/dist/manifest-schemas.js +6 -4
  38. package/dist/plugins/bundle.generated.d.ts +120 -0
  39. package/dist/plugins/bundle.generated.js +143 -0
  40. package/dist/plugins/index.d.ts +65 -0
  41. package/dist/plugins/index.js +62 -0
  42. package/dist/schemas/agent-folder/agent-md.schema.json +26 -4
  43. package/dist/schemas/agent-folder/runtime.schema.json +22 -1
  44. package/dist/schemas/agent-manifest.schema.json +72 -1
  45. package/dist/schemas/harness-manifest.schema.json +51 -1
  46. package/dist/schemas/runtime-manifest.schema.json +22 -1
  47. package/dist/types/manifest.d.ts +14 -0
  48. package/package.json +1 -1
@@ -1,6 +1,7 @@
1
- import { ARTIFACTS_READ_TEXT, ARTIFACTS_SAVE_TEXT, CONNECTION_TEXT, ENGINE_BLOCK_VERSIONS, MEMORY_DATA_RULE, MEMORY_READ_ONLY_DATA_RULE, OUTPUTS_AFTER_SAVE_TEXT, OUTPUTS_TEXT, PLAN_TEXT, SKILLS_USAGE, WAKE_TEXT, formatSkillCatalog, memoryRules, sandboxNote, skillFolderNote, } from "./blocks.js";
1
+ import { ARTIFACTS_READ_TEXT, ARTIFACTS_SAVE_TEXT, CONNECTION_TEXT, ENGINE_BLOCK_VERSIONS, MEMORY_DATA_RULE, MEMORY_READ_ONLY_DATA_RULE, OUTPUTS_AFTER_SAVE_TEXT, OUTPUTS_TEXT, PLAN_TEXT, SKILLS_USAGE, TRIGGERS_TEXT, WAKE_TEXT, formatSkillCatalog, memoryRules, sandboxNote, skillFolderNote, } from "./blocks.js";
2
2
  import { engineFeaturesOf } from "./features.js";
3
- import { DEFAULT_SANDBOX_TOOL_LIMITS, REQUEST_CONNECTION_TOOL, UPDATE_PLAN_TOOL, artifactTools, connectionToolOf, memoryToolOf, planToolOf, sandboxTools, skillTools, wakeToolOf, } from "./tools.js";
3
+ import { ASK_TOOL, DEFAULT_SANDBOX_TOOL_LIMITS, REQUEST_CONNECTION_TOOL, TRIGGERS_TOOL, UPDATE_PLAN_TOOL, artifactTools, askToolOf, connectionToolOf, memoryToolOf, planToolOf, sandboxTools, skillTools, triggersToolOf, wakeToolOf, } from "./tools.js";
4
+ import { PLUGIN_NAMES, pluginOf, pluginSkills, runtimeToolName } from "../plugins/index.js";
4
5
  /** The default of the harness's `artifactPageBytes` setting: one `read_artifact` page. */
5
6
  export const DEFAULT_ARTIFACT_PAGE_BYTES = 32 * 1024;
6
7
  /** The most bytes of one skill file the skill tools read into the model's context by default. */
@@ -16,10 +17,14 @@ export const DEFAULT_ENGINE_TOOL_LIMITS = Object.freeze({
16
17
  * with its memory (`turn.start.memory`). `memory.root` is false for an agent used as a tool,
17
18
  * which may only view memory. `plan` offers `update_plan`: true for the session's root agent when
18
19
  * the version sets `harness.loop.plan`; `connections` offers `request_connection` alike
19
- * (`harness.loop.connections`). An agent whose own tools name one of them keeps its own. What the
20
- * agent declares (`agent.engine`) decides the rest; a block it replaces is in its words.
20
+ * (`harness.loop.connections`). An agent whose own tools name one of them keeps its own.
21
+ * `triggers` offers the `triggers` tool and its text (D83): true for the session's root agent when
22
+ * the version declares `harness.engine.triggers` (`turn.start.agent.triggers`). What the agent
23
+ * declares (`agent.engine`) decides the rest; a block it replaces is in its words.
21
24
  */
22
- export function engineProjection(agent, runsOn, options, memory, plan = false, connections = false) {
25
+ export function engineProjection(agent, runsOn, options, memory, plan = false, connections = false, triggers = false, ask = false) {
26
+ if (agent.engine?.plugins !== undefined)
27
+ return pluginProjection(agent, agent.engine.plugins, runsOn, options, memory, plan, connections, triggers, ask);
23
28
  const skills = Object.values(agent.skills ?? {});
24
29
  const workspace = runsOn?.sandbox?.workspace;
25
30
  const features = engineFeaturesOf(agent.engine, { computer: workspace !== undefined });
@@ -61,6 +66,13 @@ export function engineProjection(agent, runsOn, options, memory, plan = false, c
61
66
  use("wake");
62
67
  instructions.push(text("wake", WAKE_TEXT));
63
68
  }
69
+ // The triggers the agent sets up itself (D83): the root agent's, when the version declares them.
70
+ const own = (name) => (agent.tools ?? []).some((tool) => tool.name === name);
71
+ const triggering = triggers && !own(TRIGGERS_TOOL);
72
+ if (triggering) {
73
+ use("triggers");
74
+ instructions.push(text("triggers", TRIGGERS_TEXT));
75
+ }
64
76
  // The Agent's memory (track T5, D72).
65
77
  const writes = memory !== undefined && memory.root && memory.access === "read_write";
66
78
  if (memory) {
@@ -71,7 +83,6 @@ export function engineProjection(agent, runsOn, options, memory, plan = false, c
71
83
  instructions.push([rules, ...(memory.instructions ? [`Memory instructions for this agent:\n${memory.instructions}`] : [])].join("\n\n"));
72
84
  }
73
85
  // The agent's plan (A2A profile v2, `progress/v1`).
74
- const own = (name) => (agent.tools ?? []).some((tool) => tool.name === name);
75
86
  const planning = plan && !own(UPDATE_PLAN_TOOL);
76
87
  if (planning) {
77
88
  use("plan");
@@ -89,6 +100,7 @@ export function engineProjection(agent, runsOn, options, memory, plan = false, c
89
100
  ...skillTools(skills),
90
101
  ...artifactTools({ read: features.artifactsRead, save: features.artifactsSave, sandboxed }, { pageBytes: options.artifactPageBytes }),
91
102
  ...(wake ? [wakeToolOf()] : []),
103
+ ...(triggering ? [triggersToolOf()] : []),
92
104
  ...(memory ? [memoryToolOf(writes)] : []),
93
105
  ...(planning ? [planToolOf()] : []),
94
106
  ...(connecting ? [connectionToolOf()] : []),
@@ -98,3 +110,95 @@ export function engineProjection(agent, runsOn, options, memory, plan = false, c
98
110
  features,
99
111
  };
100
112
  }
113
+ /** The first line of server `nylorun`'s text (ADR-106). */
114
+ export const RUNTIME_SERVER_HEADING = "# Server nylorun\nThe Runtime's own tools, from the plugins this agent declares. Their names begin with nylorun__.";
115
+ /** A sandbox section's network sentence: the hosts the runtime allows, or the policy note. */
116
+ function networkSentence(hosts) {
117
+ if (hosts === undefined || hosts.length === 0)
118
+ return "Network egress is limited by policy; a failed download usually means the host is not allowed.";
119
+ return `It can reach only these hosts: ${hosts.join(", ")}. A download from any other host fails.`;
120
+ }
121
+ /**
122
+ * Our engine's tools and text for an agent that declares the Runtime's plugins (`agent-folder/3`,
123
+ * ADR-106). The same tools as without plugins, with the same effects, named `nylorun__<tool>` for
124
+ * the model; the Runtime's words are one text, server `nylorun`, built from the declared plugins'
125
+ * sections in their order; their skills join the agent's own. `outputs`, the skills' usage and
126
+ * catalog, and the skills' folder note stay our engine's blocks.
127
+ */
128
+ function pluginProjection(agent, declared, runsOn, options, memory, plan, connections, triggers, ask) {
129
+ const names = PLUGIN_NAMES.filter((name) => declared.some((plugin) => plugin.name === name));
130
+ const on = (plugin, tool) => declared.some((item) => item.name === plugin && item.tools.includes(tool));
131
+ const own = (name) => (agent.tools ?? []).some((tool) => tool.name === name);
132
+ const folderSkills = Object.values(agent.skills ?? {});
133
+ const extra = pluginSkills(names).filter((skill) => !folderSkills.some((item) => item.name === skill.name));
134
+ const catalog = [...folderSkills.map(({ name, description }) => ({ name, description })), ...extra.map(({ name, description }) => ({ name, description }))];
135
+ const workspace = runsOn?.sandbox?.workspace;
136
+ const features = engineFeaturesOf(agent.engine, { computer: workspace !== undefined });
137
+ const sandbox = features.sandbox.filter((tool) => on("nylorun-sandbox", tool));
138
+ const sandboxed = sandbox.length > 0;
139
+ const readArtifacts = features.artifactsRead && on("nylorun-artifacts", "read_artifact");
140
+ const saveArtifacts = features.artifactsSave && on("nylorun-artifacts", "save_artifact");
141
+ const triggering = triggers && on("nylorun-triggers", "triggers") && !own(TRIGGERS_TOOL);
142
+ const remembering = memory !== undefined && (memory.root === false || on("nylorun-memory", "memory"));
143
+ const writes = memory !== undefined && memory.root && memory.access === "read_write";
144
+ const planning = plan && on("nylorun-plan", UPDATE_PLAN_TOOL) && !own(UPDATE_PLAN_TOOL);
145
+ const asking = ask && on("nylorun-interactions", ASK_TOOL) && !own(ASK_TOOL);
146
+ const connecting = connections && on("nylorun-interactions", REQUEST_CONNECTION_TOOL) && !own(REQUEST_CONNECTION_TOOL);
147
+ const instructions = [];
148
+ const blocks = [];
149
+ const use = (name) => blocks.push({ name, version: ENGINE_BLOCK_VERSIONS[name] });
150
+ if (catalog.length > 0) {
151
+ use("skills");
152
+ instructions.push(SKILLS_USAGE, formatSkillCatalog(catalog));
153
+ }
154
+ if (sandboxed && folderSkills.length > 0) {
155
+ use("skill_folder");
156
+ instructions.push(skillFolderNote(folderSkills));
157
+ }
158
+ if (features.outputs) {
159
+ use("outputs");
160
+ instructions.push(saveArtifacts ? OUTPUTS_AFTER_SAVE_TEXT : OUTPUTS_TEXT);
161
+ }
162
+ // Server nylorun: the declared plugins' sections, in plugin order.
163
+ const text = (plugin, section) => pluginOf(plugin).instructions[section];
164
+ const sections = [];
165
+ if (remembering)
166
+ sections.push(text("nylorun-memory", writes ? "memory" : "memory.view"));
167
+ if (triggering)
168
+ sections.push(text("nylorun-triggers", "triggers"));
169
+ if (planning)
170
+ sections.push(text("nylorun-plan", "update_plan"));
171
+ if (asking || connecting)
172
+ sections.push([text("nylorun-interactions", "_"), ...(asking ? [text("nylorun-interactions", "ask")] : []), ...(connecting ? [text("nylorun-interactions", "request_connection")] : [])].join("\n"));
173
+ if (readArtifacts || saveArtifacts)
174
+ sections.push([text("nylorun-artifacts", "_"), ...(saveArtifacts ? [text("nylorun-artifacts", "save_artifact")] : []), ...(readArtifacts ? [text("nylorun-artifacts", "read_artifact")] : [])].join("\n"));
175
+ if (sandboxed) {
176
+ const hosts = declared.find((plugin) => plugin.name === "nylorun-sandbox")?.hosts;
177
+ sections.push(text("nylorun-sandbox", "_")
178
+ .replace("{workspace}", workspace)
179
+ .replace("{tools}", sandbox.map(runtimeToolName).join(", "))
180
+ .replace("{network}", networkSentence(hosts)));
181
+ }
182
+ if (sections.length > 0)
183
+ instructions.push([RUNTIME_SERVER_HEADING, ...sections].join("\n\n"));
184
+ const named = (tool) => ({ ...tool, name: runtimeToolName(tool.name), effectName: tool.name });
185
+ const skillManifests = [
186
+ ...folderSkills,
187
+ ...extra.map((skill) => ({ name: skill.name, description: skill.description, files: { "SKILL.md": "sha256:" + "0".repeat(64) } })),
188
+ ];
189
+ return {
190
+ tools: [
191
+ ...(sandboxed ? sandboxTools(options.sandboxTools, workspace, sandbox).map(named) : []),
192
+ ...skillTools(skillManifests),
193
+ ...artifactTools({ read: readArtifacts, save: saveArtifacts, sandboxed }, { pageBytes: options.artifactPageBytes }).map(named),
194
+ ...(triggering ? [named(triggersToolOf())] : []),
195
+ ...(remembering ? [named(memoryToolOf(writes))] : []),
196
+ ...(planning ? [named(planToolOf())] : []),
197
+ ...(asking ? [named(askToolOf())] : []),
198
+ ...(connecting ? [named(connectionToolOf())] : []),
199
+ ],
200
+ instructions,
201
+ blocks,
202
+ features: { ...features, sandbox, artifactsRead: readArtifacts, artifactsSave: saveArtifacts },
203
+ };
204
+ }
@@ -22,6 +22,12 @@ export interface EngineTool {
22
22
  readonly instructions?: readonly string[];
23
23
  /** What runs its calls: their effects' `target` (an MCP tool's identity, our engine's `harness`). */
24
24
  readonly target?: EffectTarget;
25
+ /**
26
+ * The name its calls' effects carry (`toolName`), when the model reads another (ADR-106): a
27
+ * Runtime plugin's tool is `nylorun__memory` to the model and `memory` to its effect, so the
28
+ * record, tool policy and the harness's dispatch see it as without plugins.
29
+ */
30
+ readonly effectName?: string;
25
31
  }
26
32
  /** What the sandbox tools hold a call to: the harness's configuration of them. */
27
33
  export interface SandboxToolLimits {
@@ -81,6 +87,16 @@ export declare function memoryToolOf(writes: boolean): EngineTool;
81
87
  export declare const SCHEDULE_WAKE_TOOL = "schedule_wake";
82
88
  /** `schedule_wake` (track T4): a `runtime` effect. */
83
89
  export declare function wakeToolOf(): EngineTool;
90
+ /** The triggers tool's name (D83). */
91
+ export declare const TRIGGERS_TOOL = "triggers";
92
+ /** What serves a `triggers` call: the Runtime, in the call's own transaction. */
93
+ export declare const RUNTIME_TRIGGERS: EffectTarget;
94
+ /**
95
+ * `triggers` (D83): list, create and delete the triggers the calling session made, for an agent
96
+ * whose version declares `engine.triggers`; the root agent's only. A `runtime` effect, operation
97
+ * `triggers`; its input is `TriggerToolInputSchema`'s.
98
+ */
99
+ export declare function triggersToolOf(): EngineTool;
84
100
  /** The plan tool's name. */
85
101
  export declare const UPDATE_PLAN_TOOL = "update_plan";
86
102
  /** `update_plan` (A2A profile v2, `progress/v1`): runs in the harness. */
@@ -106,3 +122,19 @@ export declare function deferredToolsTools(config: {
106
122
  readonly toolSearchDefaultLimit: number;
107
123
  readonly toolSearchMaxLimit: number;
108
124
  }): readonly EngineTool[];
125
+ /** The question tool's name (ADR-106, `nylorun-interactions`). */
126
+ export declare const ASK_TOOL = "ask";
127
+ /** The most characters of a question, of a reason, and of one choice, and the most choices. */
128
+ export declare const ASK_LIMITS: Readonly<{
129
+ questionChars: 1000;
130
+ whyChars: 280;
131
+ choiceChars: 120;
132
+ choices: 6;
133
+ }>;
134
+ /**
135
+ * `ask` (ADR-106): the agent asks whoever gave it the task a question it can't answer itself,
136
+ * and waits. It runs in the harness, as `request_connection` does: a first call pauses the turn
137
+ * with an interaction of kind `response` whose metadata says `kind: "question"`, which the A2A
138
+ * server shows as a question (`INPUT_REQUIRED`); the answer runs it again with the value.
139
+ */
140
+ export declare function askToolOf(): EngineTool;
@@ -6,7 +6,7 @@
6
6
  * deliberately.
7
7
  */
8
8
  import { z } from "zod";
9
- import { ARTIFACT_NAME_MAX, PLAN_LIMITS, PLAN_STEP_STATES } from "../contracts.js";
9
+ import { ARTIFACT_NAME_MAX, PLAN_LIMITS, PLAN_STEP_STATES, TRIGGER_DELAY_PATTERN, TRIGGER_TITLE_MAX } from "../contracts.js";
10
10
  import { MEMORY_ROOT } from "../utils/memory.js";
11
11
  import { SANDBOX_TOOL_NAMES, SANDBOX_WORKSPACE } from "../utils/sandbox.js";
12
12
  import { SKILL_ENTRY } from "../utils/definition-files.js";
@@ -330,6 +330,54 @@ export function wakeToolOf() {
330
330
  target: RUNTIME_WAKE,
331
331
  };
332
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
+ }
333
381
  // --- update_plan -----------------------------------------------------------------------------
334
382
  /** The plan tool's name. */
335
383
  export const UPDATE_PLAN_TOOL = "update_plan";
@@ -458,3 +506,39 @@ export function deferredToolsTools(config) {
458
506
  function definedOf(value) {
459
507
  return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
460
508
  }
509
+ // --- ask -------------------------------------------------------------------------------------
510
+ /** The question tool's name (ADR-106, `nylorun-interactions`). */
511
+ export const ASK_TOOL = "ask";
512
+ /** The most characters of a question, of a reason, and of one choice, and the most choices. */
513
+ export const ASK_LIMITS = Object.freeze({ questionChars: 1000, whyChars: 280, choiceChars: 120, choices: 6 });
514
+ /**
515
+ * `ask` (ADR-106): the agent asks whoever gave it the task a question it can't answer itself,
516
+ * and waits. It runs in the harness, as `request_connection` does: a first call pauses the turn
517
+ * with an interaction of kind `response` whose metadata says `kind: "question"`, which the A2A
518
+ * server shows as a question (`INPUT_REQUIRED`); the answer runs it again with the value.
519
+ */
520
+ export function askToolOf() {
521
+ return {
522
+ name: ASK_TOOL,
523
+ description: [
524
+ "Ask whoever gave you this task a question you can't answer yourself, and wait for the answer.",
525
+ "Give the question, optionally up to " + ASK_LIMITS.choices + " short choices to pick from, and why you need it. Ask once, with everything you need.",
526
+ ].join(" "),
527
+ inputSchema: {
528
+ type: "object",
529
+ properties: {
530
+ question: { type: "string", minLength: 1, description: `The question, at most ${ASK_LIMITS.questionChars} characters.` },
531
+ choices: {
532
+ type: "array",
533
+ maxItems: ASK_LIMITS.choices,
534
+ items: { type: "string", minLength: 1 },
535
+ description: `Answers to pick from, each at most ${ASK_LIMITS.choiceChars} characters; leave it out for a free answer.`,
536
+ },
537
+ why: { type: "string", description: `Why you need the answer, at most ${ASK_LIMITS.whyChars} characters.` },
538
+ },
539
+ required: ["question"],
540
+ additionalProperties: false,
541
+ },
542
+ target: HARNESS,
543
+ };
544
+ }
@@ -6,7 +6,7 @@ export declare const AGENT_FOLDER_COMPILER = "agent-folder/1";
6
6
  * The formats this compiler builds: `agent-folder/1`, and `agent-folder/2` (ADR-100), whose
7
7
  * folder declares every engine feature it uses (`folder/engine.ts`).
8
8
  */
9
- export declare const AGENT_FOLDER_FORMATS: readonly ["agent-folder/1", "agent-folder/2"];
9
+ export declare const AGENT_FOLDER_FORMATS: readonly ["agent-folder/1", "agent-folder/2", "agent-folder/3"];
10
10
  export type AgentFolderFormat = (typeof AGENT_FOLDER_FORMATS)[number];
11
11
  /**
12
12
  * What a folder may hold, unless `compileAgentFolder` is given other limits (a Tenant's Runtime
@@ -72,12 +72,12 @@ export interface CompiledAgentFolder {
72
72
  */
73
73
  export declare const FOLDER_SCHEMAS = "https://docs.nylorun.com/schemas/agent-folder/v1/";
74
74
  export declare const SCHEMA_URLS: {
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"];
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"];
76
76
  readonly tool: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/tool.json"];
77
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"];
78
78
  readonly flow: readonly ["https://docs.nylorun.com/schemas/agent-folder/v1/flow.json"];
79
79
  };
80
- export declare const AGENT_KEYS: readonly ["name", "description", "format", "harness", "inputSchema", "outputSchema", "mcpServers", "skills", "memory", "loop", "model", "engine", "metadata"];
80
+ export declare const AGENT_KEYS: readonly ["name", "description", "format", "harness", "inputSchema", "outputSchema", "mcpServers", "skills", "memory", "loop", "model", "engine", "plugins", "metadata"];
81
81
  export declare const TRIGGER_KEYS: readonly ["schedule", "timezone", "at", "webhook", "session"];
82
82
  export declare const MCP_KEYS: readonly ["$schema", "mcpServers"];
83
83
  export declare const SERVER_KEYS: readonly ["type", "url", "headers"];
@@ -1,5 +1,7 @@
1
1
  import { AGENT_MANIFEST_V8_SCHEMA_VERSION, AGENT_MODEL_MAX_CHARS, AgentManifestV8Schema, ENVIRONMENT_NAME_PATTERN, HarnessIdSchema, RuntimeSectionSchema, TOOL_SECRET_NAME_PATTERN, TriggerSchema, agentModelChoice, isAgentManifestName, } from "../contracts.js";
2
2
  import { cronScheduleIssue, isTimeZone, timeZoneNames } from "../definition/cron.js";
3
+ import { RUNTIME_SERVER } from "../plugins/index.js";
4
+ import { enginePlugins, isFolderV3, pluginSkillNames, v3Declarations } from "./v3.js";
3
5
  import { DELEGATE_NAME_PATTERN } from "../definition/delegate.js";
4
6
  import { sectionGapsAt } from "../definition/sections.js";
5
7
  import { DEFAULT_HARNESS } from "../utils/harness-id.js";
@@ -16,7 +18,7 @@ export const AGENT_FOLDER_COMPILER = "agent-folder/1";
16
18
  * The formats this compiler builds: `agent-folder/1`, and `agent-folder/2` (ADR-100), whose
17
19
  * folder declares every engine feature it uses (`folder/engine.ts`).
18
20
  */
19
- export const AGENT_FOLDER_FORMATS = ["agent-folder/1", "agent-folder/2"];
21
+ export const AGENT_FOLDER_FORMATS = ["agent-folder/1", "agent-folder/2", "agent-folder/3"];
20
22
  /**
21
23
  * What a folder may hold, unless `compileAgentFolder` is given other limits (a Tenant's Runtime
22
24
  * limits `folderFiles`, `folderBytes` and `folderTextFileBytes`, which default to these).
@@ -42,8 +44,10 @@ const AGENT_PLUGINS_MCP_SCHEMA = "https://agent-plugins.org/schemas/1.0.0/mcp.sc
42
44
  export const FOLDER_SCHEMAS = "https://docs.nylorun.com/schemas/agent-folder/v1/";
43
45
  export const SCHEMA_URLS = {
44
46
  runtime: [
47
+ `${FOLDER_SCHEMAS}runtime.2.json`,
45
48
  `${FOLDER_SCHEMAS}runtime.1.json`,
46
49
  `${FOLDER_SCHEMAS}runtime.json`,
50
+ "https://docs.nylorun.com/schemas/runtime-manifest/v1.2.json",
47
51
  "https://docs.nylorun.com/schemas/runtime-manifest/v1.1.json",
48
52
  "https://docs.nylorun.com/schemas/runtime-manifest/v1.json",
49
53
  ],
@@ -52,7 +56,7 @@ export const SCHEMA_URLS = {
52
56
  flow: [`${FOLDER_SCHEMAS}flow.json`],
53
57
  };
54
58
  const SKILL_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
55
- export const AGENT_KEYS = ["name", "description", "format", "harness", "inputSchema", "outputSchema", "mcpServers", "skills", "memory", "loop", "model", "engine", "metadata"];
59
+ export const AGENT_KEYS = ["name", "description", "format", "harness", "inputSchema", "outputSchema", "mcpServers", "skills", "memory", "loop", "model", "engine", "plugins", "metadata"];
56
60
  const SKILL_KEYS = ["name", "description", "license", "compatibility", "metadata", "allowed-tools"];
57
61
  export const TRIGGER_KEYS = ["schedule", "timezone", "at", "webhook", "session"];
58
62
  export const MCP_KEYS = ["$schema", "mcpServers"];
@@ -65,8 +69,8 @@ export const TOOL_KEYS = ["description", "inputSchema", "outputSchema", "http"];
65
69
  * The loop settings our harness reads from `loop`: `plan` (`true` offers the agent `update_plan`)
66
70
  * and `connections` (`true` offers it `request_connection`). A custom harness reads its own.
67
71
  */
68
- const NYLORUN_LOOP_KEYS = ["plan", "connections"];
69
- const LOOP_TOOLS = { plan: "update_plan", connections: "request_connection" };
72
+ const NYLORUN_LOOP_KEYS = ["plan", "connections", "ask"];
73
+ const LOOP_TOOLS = { plan: "update_plan", connections: "request_connection", ask: "ask" };
70
74
  /** The runtime fields only a sandbox has, and the ones only a pod has. */
71
75
  const SANDBOX_FIELDS = ["image", "resources", "storage", "network", "setup", "files"];
72
76
  const POD_FIELDS = ["image", "storage", "setup", "files"];
@@ -215,6 +219,9 @@ export function compileAgentFolder(input, scope) {
215
219
  const diagnostics = [];
216
220
  /** The folder's format: the uploaded folder's `format`, which a folder inside it shares. */
217
221
  let format = scope?.engineFacts?.format ?? 1;
222
+ /** The folder is `agent-folder/3` (ADR-106): its plugins stand for v2 declarations (folder/v3.ts). */
223
+ let v3 = scope?.engineFacts?.v3 === true;
224
+ let v3Plugins;
218
225
  const parsed = new Map();
219
226
  const report = (severity, code, message, file, path, options = {}) => {
220
227
  let at = options.at;
@@ -332,6 +339,19 @@ export function compileAgentFolder(input, scope) {
332
339
  }
333
340
  return result.value;
334
341
  };
342
+ /** Whether runtime.json names a computer, read quietly before the runtime section is (v3). */
343
+ const earlyComputer = () => {
344
+ const bytes = input.files.get(RUNTIME_FILE);
345
+ if (!bytes)
346
+ return false;
347
+ try {
348
+ const value = JSON.parse(new TextDecoder().decode(bytes).replace(/^\uFEFF/, ""));
349
+ return value?.kind === "virtual" || value?.kind === "pod";
350
+ }
351
+ catch {
352
+ return false;
353
+ }
354
+ };
335
355
  const readMarkdown = (path) => {
336
356
  const text = textOf(path);
337
357
  if (text === undefined)
@@ -469,10 +489,44 @@ export function compileAgentFolder(input, scope) {
469
489
  error("description_missing", "description is required: what the agent does, in a sentence", AGENT_FILE, front.description === undefined ? undefined : ["description"]);
470
490
  else
471
491
  description = front.description.trim();
472
- if (!scope && folderFormatOf(front.format) === undefined)
492
+ if (!scope && isFolderV3(front.format)) {
493
+ v3 = true;
494
+ format = 2;
495
+ }
496
+ else if (!scope && folderFormatOf(front.format) === undefined)
473
497
  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
498
  else if (!scope)
475
499
  format = folderFormatOf(front.format);
500
+ // agent-folder/3 (ADR-106): the plugins stand for agent-folder/2's declarations.
501
+ if (v3 && scope?.role !== "plugin") {
502
+ const role = scope?.role === "subagent" ? "subagent" : "root";
503
+ v3Plugins = v3Declarations(front, {
504
+ error: (code, message, path, options) => error(code, message, AGENT_FILE, path, options),
505
+ computer: scope?.engineFacts ? scope.engineFacts.computer : earlyComputer(),
506
+ role,
507
+ ...(scope?.engineFacts?.plugins === undefined ? {} : { parent: scope.engineFacts.plugins }),
508
+ });
509
+ delete front.memory;
510
+ delete front.loop;
511
+ if (isObject(front.mcpServers)) {
512
+ const { [RUNTIME_SERVER]: _runtime, ...rest } = front.mcpServers;
513
+ if (Object.keys(rest).length > 0)
514
+ front.mcpServers = rest;
515
+ else
516
+ delete front.mcpServers;
517
+ }
518
+ if (v3Plugins) {
519
+ if (v3Plugins.memory)
520
+ front.memory = v3Plugins.memory;
521
+ if (v3Plugins.loop)
522
+ front.loop = v3Plugins.loop;
523
+ front.engine = v3Plugins.engine;
524
+ }
525
+ else
526
+ delete front.engine;
527
+ }
528
+ else if (front.plugins !== undefined && scope?.role !== "plugin")
529
+ error("v3_key", "plugins names the Runtime's plugins, a key of agent-folder/3. Fix: add format: agent-folder/3 to AGENT.md, or run nylorun migrate folder <dir> --to 3", AGENT_FILE, ["plugins"], { key: true });
476
530
  if (front.harness !== undefined) {
477
531
  if (HarnessIdSchema.safeParse(front.harness).success)
478
532
  harness.id = front.harness;
@@ -551,6 +605,8 @@ export function compileAgentFolder(input, scope) {
551
605
  const { $schema: _, extends: __, ...rest } = value;
552
606
  runtime = rest;
553
607
  origins.push([["runtime"], { file: RUNTIME_FILE, path: [] }]);
608
+ if (v3 && !scope && rest.selfWake !== undefined)
609
+ error("v3_refused", "selfWake is a key of agent-folder/2: in agent-folder/3, nylorun-triggers sets a follow-up (in or at, session: this). Fix: run nylorun migrate folder <dir> --to 3", RUNTIME_FILE, ["selfWake"], { key: true });
554
610
  if (isObject(rest.triggers))
555
611
  for (const [id, trigger] of Object.entries(rest.triggers))
556
612
  if (isObject(trigger))
@@ -604,7 +660,12 @@ export function compileAgentFolder(input, scope) {
604
660
  return trimmed;
605
661
  },
606
662
  });
607
- if (declared && !scope && computer && (declared.engine.sandbox ?? []).length === 0)
663
+ if (declared && v3) {
664
+ const network = isObject(runtime) && isObject(runtime.network) ? runtime.network : undefined;
665
+ const hosts = Array.isArray(network?.allowedHosts) ? network.allowedHosts.filter((host) => typeof host === "string") : undefined;
666
+ declared = { ...declared, engine: { ...declared.engine, plugins: enginePlugins(v3Plugins?.plugins ?? [], hosts) } };
667
+ }
668
+ if (declared && !scope && computer && !v3 && (declared.engine.sandbox ?? []).length === 0)
608
669
  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
670
  origins.push([["harness", "engine"], { file: AGENT_FILE, path: ["engine"] }]);
610
671
  }
@@ -617,6 +678,7 @@ export function compileAgentFolder(input, scope) {
617
678
  format,
618
679
  computer,
619
680
  ...(format === 2 && declared ? { engine: declared.engine } : {}),
681
+ ...(v3 ? { v3: true, plugins: v3Plugins?.plugins ?? [] } : {}),
620
682
  memory: isObject(front.memory),
621
683
  selfWake: isObject(runtime) && runtime.selfWake === true,
622
684
  };
@@ -820,6 +882,8 @@ export function compileAgentFolder(input, scope) {
820
882
  }
821
883
  }
822
884
  }
885
+ if (v3 && servers[RUNTIME_SERVER] !== undefined)
886
+ error("server_reserved", `${RUNTIME_SERVER} is the Runtime's own server, which its plugins share: name this server differently`, MCP_FILE, ["mcpServers", RUNTIME_SERVER], { key: true });
823
887
  if (Object.keys(servers).length > 0)
824
888
  harness.mcpServers = servers;
825
889
  // --- skills/ ---------------------------------------------------------------------------
@@ -932,6 +996,10 @@ export function compileAgentFolder(input, scope) {
932
996
  origins.push([["harness", "skills", key, "secrets"], { file: AGENT_FILE, path: [...at, "secrets"] }]);
933
997
  }
934
998
  }
999
+ if (v3 && v3Plugins)
1000
+ for (const name of pluginSkillNames(v3Plugins.plugins))
1001
+ if (skills[name] !== undefined)
1002
+ error("skill_reserved", `${name} is the skill of a plugin this folder declares: name the folder's skill differently`, `skills/${name}/SKILL.md`);
935
1003
  if (Object.keys(skills).length > 0)
936
1004
  harness.skills = skills;
937
1005
  // --- tools/ ----------------------------------------------------------------------------
@@ -1014,7 +1082,7 @@ export function compileAgentFolder(input, scope) {
1014
1082
  seeded[path.slice("files/".length)] = `sha256:${byPath.get(path).sha256}`;
1015
1083
  // --- agents/, flow.json and plugins/ (folder/nested.ts) ----------------------------------
1016
1084
  if (!parts.compose())
1017
- return finish(format, diagnostics);
1085
+ return finish(v3 ? 3 : format, diagnostics);
1018
1086
  // --- The engine blocks the agent gets (agent-folder/2) ------------------------------------
1019
1087
  if (declared && harness.kind !== "workflow") {
1020
1088
  const facts = engineFacts();
@@ -1037,6 +1105,8 @@ export function compileAgentFolder(input, scope) {
1037
1105
  : {}),
1038
1106
  plan: role === "root" && loop.plan === true,
1039
1107
  connections: role === "root" && loop.connections === true,
1108
+ triggers: role === "root" && declared.engine.triggers === true,
1109
+ ask: role === "root" && loop.ask === true,
1040
1110
  });
1041
1111
  for (const name of unusedInstructions(declared.engine, names))
1042
1112
  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 });
@@ -1062,7 +1132,7 @@ export function compileAgentFolder(input, scope) {
1062
1132
  }
1063
1133
  // --- Every field checked as the Runtime checks the manifest ------------------------------
1064
1134
  if (diagnostics.some((item) => item.severity === "error") || name === undefined || description === undefined)
1065
- return finish(format, diagnostics);
1135
+ return finish(v3 ? 3 : format, diagnostics);
1066
1136
  const document = {
1067
1137
  manifestSchemaVersion: AGENT_MANIFEST_V8_SCHEMA_VERSION,
1068
1138
  name,
@@ -1098,10 +1168,10 @@ export function compileAgentFolder(input, scope) {
1098
1168
  continue;
1099
1169
  place(issue, [], fromOrigins);
1100
1170
  }
1101
- return finish(format, diagnostics);
1171
+ return finish(v3 ? 3 : format, diagnostics);
1102
1172
  }
1103
1173
  if (diagnostics.some((item) => item.severity === "error"))
1104
- return finish(format, diagnostics);
1174
+ return finish(v3 ? 3 : format, diagnostics);
1105
1175
  const manifest = checked.data;
1106
1176
  // --- What the Runtime checks at save, where it needs no Tenant ---------------------------
1107
1177
  const hasRuntimeFile = byPath.has(RUNTIME_FILE);
@@ -1139,8 +1209,8 @@ export function compileAgentFolder(input, scope) {
1139
1209
  : `${field} ${POD_ONLY[field]}`, RUNTIME_FILE, [field], { key: true, pointer: pointerOf(["runtime", field]) });
1140
1210
  }
1141
1211
  if (diagnostics.some((item) => item.severity === "error"))
1142
- return finish(format, diagnostics);
1143
- return finish(format, diagnostics, manifest);
1212
+ return finish(v3 ? 3 : format, diagnostics);
1213
+ return finish(v3 ? 3 : format, diagnostics, manifest);
1144
1214
  /** A schema issue in the compiler's words, at the file and field that wrote it. */
1145
1215
  function place(issue, base, where) {
1146
1216
  const full = [...base, ...issue.path];
@@ -2,7 +2,7 @@ import { type EngineBlockName } from "../engine/names.js";
2
2
  import type { HarnessEngine, SkillManifest, ToolManifest } from "../types/manifest.js";
3
3
  import type { ReportOptions } from "./context.js";
4
4
  /** The keys of `AGENT.md`'s `engine:` block. */
5
- export declare const ENGINE_KEYS: readonly ["sandbox", "artifacts", "outputs", "toolSearch", "instructions"];
5
+ export declare const ENGINE_KEYS: readonly ["sandbox", "artifacts", "outputs", "toolSearch", "triggers", "instructions"];
6
6
  /** Where a folder keeps the files that replace a block's wording. */
7
7
  export declare const ENGINE_TEXT_DIR = "engine";
8
8
  /** A folder's format: 1 (`agent-folder/1`, the default) or 2 (`agent-folder/2`); undefined when it is neither. */
@@ -18,6 +18,13 @@ export interface EngineScopeFacts {
18
18
  readonly memory: boolean;
19
19
  /** The uploaded folder's runtime sets `selfWake`. */
20
20
  readonly selfWake: boolean;
21
+ /** The uploaded folder is `agent-folder/3` (ADR-106). */
22
+ readonly v3?: boolean;
23
+ /** Its plugins, under format 3: a subagent's are a subset. */
24
+ readonly plugins?: readonly {
25
+ readonly name: import("../plugins/index.js").PluginName;
26
+ readonly tools: readonly string[];
27
+ }[];
21
28
  }
22
29
  type Fail = (code: string, message: string, path?: readonly PropertyKey[], options?: ReportOptions) => void;
23
30
  /**
@@ -39,7 +46,8 @@ export declare function engineDeclarations(value: unknown, options: {
39
46
  /**
40
47
  * The text blocks an agent gets, from what it declares and what the folder says of its session:
41
48
  * 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
49
+ * whether it is the root agent declaring `engine.triggers`, and whether its MCP tools may be
50
+ * deferred. The harness's own projection decides them
43
51
  * (`engineProjection`), so the list is what a session's system text holds.
44
52
  */
45
53
  export declare function engineBlocksOf(agent: {
@@ -62,6 +70,10 @@ export declare function engineBlocksOf(agent: {
62
70
  };
63
71
  readonly plan: boolean;
64
72
  readonly connections: boolean;
73
+ /** The root agent declares `engine.triggers` (D83). */
74
+ readonly triggers?: boolean;
75
+ /** The root agent has `ask` (`agent-folder/3`, `harness.loop.ask`). */
76
+ readonly ask?: boolean;
65
77
  }): EngineBlockName[];
66
78
  /** `harness.engine` as the compiled manifest holds it: the declarations, then the blocks. */
67
79
  export declare function compiledEngine(engine: HarnessEngine, blocks: readonly EngineBlockName[], sources: Partial<Record<EngineBlockName, string>>): HarnessEngine;