@nylorun/core 0.35.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @nylorun/core
2
2
 
3
+ ## 0.36.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - 2afa44d: The Runtime's primitives as its own Agent Plugins (ADR-106, D84). An `agent-folder/3` folder lists them under `plugins:` (`nylorun-memory`, `nylorun-triggers`, `nylorun-plan`, `nylorun-interactions`, `nylorun-artifacts`, `nylorun-sandbox`, which needs a computer), with no versions, and turns one of their tools off with `mcpServers.nylorun.tools.<tool>.enabled: false`. The compiler reads them as the `agent-folder/2` declarations they stand for (`memory`, `loop`, `engine.sandbox`, `engine.artifacts`, `engine.triggers`, which v3 refuses) and records them in `harness.engine.plugins`, each with its tools and the hash of its files. The engine presents their tools as the reserved server `nylorun`: the model reads `nylorun__memory` and the declared plugins' words as one text, with their skills (`memory`, `triggers`) in the catalog, served from the bundle; every effect keeps its target and `toolName`, so the record, tool policy (`kind: "runtime"` rules) and dispatch are unchanged. New: `ask` (`nylorun-interactions`, `harness.loop.ask`), a question that pauses the turn as an A2A `question`; `removeTools` takes `nylorun__<tool>`; `triggers` answers carry `now`; under `nylorun-triggers`, an agent-made trigger's run starts with a `[trigger <id> · <title> · nobody is watching]` line, and a turn a trigger started may set a one-off follow-up (`in` or `at`, `session: "this"`); the sandbox's instructions name the hosts `runtime.json` allows. `nylorun migrate folder <dir> --to 3` writes the plugins that keep an agent's tools and features, and `nylorun check --explain` names the plugin behind each. The JSON Schemas are republished as `agent-manifest/v8.4`, `harness-manifest/v1.4` and `agent-folder/v1/agent-md.4`.
8
+
3
9
  ## 0.35.0-beta
4
10
 
5
11
  ### Minor Changes
@@ -96,6 +96,19 @@ export declare const HarnessEngineSchema: z.ZodObject<{
96
96
  sha256: z.ZodString;
97
97
  source: z.ZodOptional<z.ZodString>;
98
98
  }, z.core.$strict>>>;
99
+ plugins: z.ZodOptional<z.ZodArray<z.ZodObject<{
100
+ name: z.ZodEnum<{
101
+ "nylorun-artifacts": "nylorun-artifacts";
102
+ "nylorun-interactions": "nylorun-interactions";
103
+ "nylorun-memory": "nylorun-memory";
104
+ "nylorun-plan": "nylorun-plan";
105
+ "nylorun-sandbox": "nylorun-sandbox";
106
+ "nylorun-triggers": "nylorun-triggers";
107
+ }>;
108
+ tools: z.ZodArray<z.ZodString>;
109
+ sha256: z.ZodString;
110
+ hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
111
+ }, z.core.$strict>>>;
99
112
  }, z.core.$strict>;
100
113
  /**
101
114
  * An agent's manifest (manifest v7). Its output is checked against `AgentManifest` here and below
@@ -1489,6 +1502,7 @@ export declare const TriggerToolOutputSchema: z.ZodUnion<readonly [z.ZodObject<{
1489
1502
  }>;
1490
1503
  nextRunAt: z.ZodNullable<z.ZodString>;
1491
1504
  session: z.ZodString;
1505
+ now: z.ZodOptional<z.ZodString>;
1492
1506
  }, z.core.$strict>, z.ZodObject<{
1493
1507
  triggers: z.ZodArray<z.ZodObject<{
1494
1508
  id: z.ZodString;
@@ -1505,6 +1519,7 @@ export declare const TriggerToolOutputSchema: z.ZodUnion<readonly [z.ZodObject<{
1505
1519
  nextRunAt: z.ZodNullable<z.ZodString>;
1506
1520
  prompt: z.ZodString;
1507
1521
  }, z.core.$strict>>;
1522
+ now: z.ZodOptional<z.ZodString>;
1508
1523
  }, z.core.$strict>, z.ZodObject<{
1509
1524
  id: z.ZodString;
1510
1525
  deleted: z.ZodLiteral<true>;
@@ -2166,6 +2181,19 @@ export declare const HarnessManifestFileSchema: z.ZodObject<{
2166
2181
  sha256: z.ZodString;
2167
2182
  source: z.ZodOptional<z.ZodString>;
2168
2183
  }, z.core.$strict>>>;
2184
+ plugins: z.ZodOptional<z.ZodArray<z.ZodObject<{
2185
+ name: z.ZodEnum<{
2186
+ "nylorun-artifacts": "nylorun-artifacts";
2187
+ "nylorun-interactions": "nylorun-interactions";
2188
+ "nylorun-memory": "nylorun-memory";
2189
+ "nylorun-plan": "nylorun-plan";
2190
+ "nylorun-sandbox": "nylorun-sandbox";
2191
+ "nylorun-triggers": "nylorun-triggers";
2192
+ }>;
2193
+ tools: z.ZodArray<z.ZodString>;
2194
+ sha256: z.ZodString;
2195
+ hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
2196
+ }, z.core.$strict>>>;
2169
2197
  }, z.core.$strict>>;
2170
2198
  credentials: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2171
2199
  requires: z.ZodOptional<z.ZodObject<{
@@ -2433,6 +2461,19 @@ export declare const AgentManifestFileSchema: z.ZodObject<{
2433
2461
  sha256: z.ZodString;
2434
2462
  source: z.ZodOptional<z.ZodString>;
2435
2463
  }, z.core.$strict>>>;
2464
+ plugins: z.ZodOptional<z.ZodArray<z.ZodObject<{
2465
+ name: z.ZodEnum<{
2466
+ "nylorun-artifacts": "nylorun-artifacts";
2467
+ "nylorun-interactions": "nylorun-interactions";
2468
+ "nylorun-memory": "nylorun-memory";
2469
+ "nylorun-plan": "nylorun-plan";
2470
+ "nylorun-sandbox": "nylorun-sandbox";
2471
+ "nylorun-triggers": "nylorun-triggers";
2472
+ }>;
2473
+ tools: z.ZodArray<z.ZodString>;
2474
+ sha256: z.ZodString;
2475
+ hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
2476
+ }, z.core.$strict>>>;
2436
2477
  }, z.core.$strict>>;
2437
2478
  credentials: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2438
2479
  requires: z.ZodOptional<z.ZodObject<{
package/dist/contracts.js CHANGED
@@ -269,6 +269,15 @@ export const HarnessEngineSchema = z
269
269
  .optional()
270
270
  .meta({ description: "A block's wording replaced, by block name" }),
271
271
  blocks: z.array(engineBlockRefSchema).optional().meta({ description: "The engine text blocks the agent gets, with their hashes" }),
272
+ plugins: z
273
+ .array(z.strictObject({
274
+ name: z.enum(["nylorun-memory", "nylorun-triggers", "nylorun-plan", "nylorun-interactions", "nylorun-artifacts", "nylorun-sandbox"]),
275
+ tools: z.array(z.string().min(1)),
276
+ sha256: z.string().regex(/^sha256:[0-9a-f]{64}$/),
277
+ hosts: z.array(z.string().min(1)).optional(),
278
+ }))
279
+ .optional()
280
+ .meta({ description: "The Runtime's plugins the agent declares (agent-folder/3, ADR-106): each with the tools left on and the hash of its files" }),
272
281
  })
273
282
  .meta({ id: "HarnessEngine" });
274
283
  const harnessEngineField = HarnessEngineSchema.optional();
@@ -2013,8 +2022,15 @@ export const TriggerToolItemSchema = z
2013
2022
  });
2014
2023
  /** What a `triggers` call answers: the trigger made, the list, or the one deleted. */
2015
2024
  export const TriggerToolOutputSchema = z.union([
2016
- z.strictObject({ id: z.string(), status: z.enum(TRIGGER_STATUSES), nextRunAt: z.string().nullable(), session: z.string() }),
2017
- z.strictObject({ triggers: z.array(TriggerToolItemSchema) }),
2025
+ z.strictObject({
2026
+ id: z.string(),
2027
+ status: z.enum(TRIGGER_STATUSES),
2028
+ nextRunAt: z.string().nullable(),
2029
+ session: z.string(),
2030
+ /** The Runtime's clock when it answered, so the model knows the time (ADR-106). */
2031
+ now: z.string().optional(),
2032
+ }),
2033
+ z.strictObject({ triggers: z.array(TriggerToolItemSchema), now: z.string().optional() }),
2018
2034
  z.strictObject({ id: z.string(), deleted: z.literal(true) }),
2019
2035
  ]);
2020
2036
  /**
@@ -1,3 +1,4 @@
1
+ import { runtimeToolOf } from "../plugins/index.js";
1
2
  import { canonical } from "../utils/canonical.js";
2
3
  function same(a, b) {
3
4
  return canonical(a) === canonical(b);
@@ -120,7 +121,12 @@ export function withoutTools(manifest, names) {
120
121
  return same(next, manifest) ? manifest : next;
121
122
  }
122
123
  function narrowAgent(agent, removed, root) {
123
- const { tools: _tools, mcpServers: _servers, ...rest } = agent;
124
+ const { tools: _tools, mcpServers: _servers, engine: _engine, ...rest } = agent;
125
+ // A Runtime plugin's tool by the name the model reads (ADR-106): `nylorun__ask` turns `ask` off.
126
+ const offPlugin = new Set([...removed].flatMap((name) => runtimeToolOf(name) ?? []));
127
+ const engine = agent.engine?.plugins !== undefined && offPlugin.size > 0
128
+ ? { ...agent.engine, plugins: agent.engine.plugins.map((plugin) => ({ ...plugin, tools: plugin.tools.filter((tool) => !offPlugin.has(tool)) })) }
129
+ : agent.engine;
124
130
  const tools = agent.tools
125
131
  ?.filter((tool) => !removed.has(tool.name))
126
132
  .map((tool) => {
@@ -134,6 +140,7 @@ function narrowAgent(agent, removed, root) {
134
140
  ...rest,
135
141
  ...(tools === undefined ? {} : { tools }),
136
142
  ...(servers === undefined ? {} : { mcpServers: servers }),
143
+ ...(engine === undefined ? {} : { engine }),
137
144
  };
138
145
  }
139
146
  function narrowServer(server, removed) {
@@ -1,7 +1,8 @@
1
1
  import { SANDBOX_TOOL_NAMES } from "../utils/sandbox.js";
2
2
  import { ENGINE_BLOCK_VERSIONS } from "./blocks.js";
3
3
  import { previewTurn } from "./preview.js";
4
- import { LOAD_SKILL_TOOL, MEMORY_TOOL, READ_SKILL_RESOURCE_TOOL, REQUEST_CONNECTION_TOOL, SCHEDULE_WAKE_TOOL, TOOL_CALL_TOOL, TRIGGERS_TOOL, TOOL_SEARCH_TOOL, UPDATE_PLAN_TOOL, } from "./tools.js";
4
+ import { LOAD_SKILL_TOOL, MEMORY_TOOL, READ_SKILL_RESOURCE_TOOL, REQUEST_CONNECTION_TOOL, SCHEDULE_WAKE_TOOL, TOOL_CALL_TOOL, TRIGGERS_TOOL, TOOL_SEARCH_TOOL, UPDATE_PLAN_TOOL, ASK_TOOL, } from "./tools.js";
5
+ import { runtimeToolOf } from "../plugins/index.js";
5
6
  import { READ_ARTIFACT_TOOL, SAVE_ARTIFACT_TOOL } from "../utils/runtime-tools.js";
6
7
  import { loopManifestOf } from "../definition/sections.js";
7
8
  /** The engine features, in the order the harness adds them. */
@@ -28,9 +29,20 @@ const TOOLS = {
28
29
  triggers: [TRIGGERS_TOOL],
29
30
  memory: [MEMORY_TOOL],
30
31
  plan: [UPDATE_PLAN_TOOL],
31
- connections: [REQUEST_CONNECTION_TOOL],
32
+ connections: [REQUEST_CONNECTION_TOOL, ASK_TOOL],
32
33
  toolSearch: [TOOL_SEARCH_TOOL, TOOL_CALL_TOOL],
33
34
  };
35
+ /** The Runtime plugin that declares each feature in an `agent-folder/3` folder (ADR-106). */
36
+ const PLUGIN_OF = {
37
+ sandbox: "nylorun-sandbox",
38
+ "artifacts.save": "nylorun-artifacts",
39
+ "artifacts.read": "nylorun-artifacts",
40
+ selfWake: "nylorun-triggers",
41
+ triggers: "nylorun-triggers",
42
+ memory: "nylorun-memory",
43
+ plan: "nylorun-plan",
44
+ connections: "nylorun-interactions",
45
+ };
34
46
  const BLOCKS = {
35
47
  skills: ["skills", "skill_folder"],
36
48
  sandbox: ["sandbox"],
@@ -47,6 +59,9 @@ const BLOCKS = {
47
59
  function explainOne(id, preview, facts) {
48
60
  const declared = preview.features.declared;
49
61
  const by = (feature) => {
62
+ // agent-folder/3: the plugin that brings it (ADR-106), or skills/ and the plugins' skills.
63
+ if (facts.plugins)
64
+ return PLUGIN_OF[feature] ?? (feature === "skills" ? "skills/ and the plugins' skills" : `engine.${feature}`);
50
65
  switch (feature) {
51
66
  case "skills":
52
67
  return "skills/";
@@ -65,7 +80,8 @@ function explainOne(id, preview, facts) {
65
80
  }
66
81
  };
67
82
  const blocks = new Set(preview.blocks.map((block) => block.name));
68
- const tools = new Set(preview.engineTools);
83
+ // A Runtime plugin's tool by its own name: nylorun__memory is memory (ADR-106).
84
+ const tools = new Set(preview.engineTools.map((name) => runtimeToolOf(name) ?? name));
69
85
  const features = ENGINE_FEATURES.map((feature) => {
70
86
  const added = TOOLS[feature].filter((name) => tools.has(name));
71
87
  const text = BLOCKS[feature].filter((name) => blocks.has(name)).map((name) => `${name}@${ENGINE_BLOCK_VERSIONS[name]}`);
@@ -105,9 +121,10 @@ export function explainEngine(manifest) {
105
121
  const preview = previewTurn(manifest);
106
122
  const loop = loopManifestOf(manifest);
107
123
  const mcpOf = (agent) => Object.keys(agent.mcpServers ?? {}).length > 0;
108
- const root = explainOne(manifest.name, preview, { root: true, pinned: preview.pinned.length > 0, mcp: mcpOf(loop) });
124
+ const plugins = manifest.harness.engine?.plugins !== undefined;
125
+ const root = explainOne(manifest.name, preview, { root: true, pinned: preview.pinned.length > 0, mcp: mcpOf(loop), plugins });
109
126
  const subagents = (loop.tools ?? []).flatMap((tool) => tool.agent && !("kind" in tool.agent) && preview.agents[tool.agent.id]
110
- ? [explainOne(tool.agent.id, preview.agents[tool.agent.id], { root: false, pinned: false, mcp: mcpOf(tool.agent) })]
127
+ ? [explainOne(tool.agent.id, preview.agents[tool.agent.id], { root: false, pinned: false, mcp: mcpOf(tool.agent), plugins })]
111
128
  : []);
112
129
  return [root, ...subagents];
113
130
  }
@@ -12,3 +12,4 @@ export * from "./mcp.js";
12
12
  export * from "./projection.js";
13
13
  export * from "./preview.js";
14
14
  export * from "./explain.js";
15
+ export * from "../plugins/index.js";
@@ -12,3 +12,4 @@ export * from "./mcp.js";
12
12
  export * from "./projection.js";
13
13
  export * from "./preview.js";
14
14
  export * from "./explain.js";
15
+ export * from "../plugins/index.js";
@@ -52,6 +52,7 @@ export interface PreviewTurnOptions {
52
52
  readonly loop?: {
53
53
  readonly plan?: boolean;
54
54
  readonly connections?: boolean;
55
+ readonly ask?: boolean;
55
56
  };
56
57
  /** The harness's configuration of our engine's tools. Default: the harness's defaults. */
57
58
  readonly limits?: Partial<EngineToolLimits>;
@@ -64,6 +64,7 @@ export function previewTurn(manifest, options = {}) {
64
64
  const plan = options.loop?.plan ?? settings.plan === true;
65
65
  const connections = options.loop?.connections ?? settings.connections === true;
66
66
  const triggers = options.triggers ?? harness?.engine?.triggers === true;
67
+ const ask = options.loop?.ask ?? settings.ask === true;
67
68
  const limits = { ...DEFAULT_ENGINE_TOOL_LIMITS, ...options.limits };
68
69
  const memoryOf = (agent) => memory && {
69
70
  access: memory.access ?? "read_write",
@@ -71,7 +72,7 @@ export function previewTurn(manifest, options = {}) {
71
72
  root: agent.id === loop.id,
72
73
  index: memory.index !== false,
73
74
  };
74
- const projection = (agent) => engineProjection(agent, runsOn, limits, memoryOf(agent), plan && agent.id === loop.id, connections && agent.id === loop.id, triggers && agent.id === loop.id);
75
+ const projection = (agent) => engineProjection(agent, runsOn, limits, memoryOf(agent), plan && agent.id === loop.id, connections && agent.id === loop.id, triggers && agent.id === loop.id, ask && agent.id === loop.id);
75
76
  const mcp = mcpToolSet(options.mcpFacts, loop, {
76
77
  config: mcpToolConfigOf(options.mcpTools),
77
78
  ...(options.model ? { model: options.model } : {}),
@@ -60,4 +60,6 @@ export interface EngineProjection {
60
60
  * the version declares `harness.engine.triggers` (`turn.start.agent.triggers`). What the agent
61
61
  * declares (`agent.engine`) decides the rest; a block it replaces is in its words.
62
62
  */
63
- export declare function engineProjection(agent: Pick<AgentManifest, "skills" | "tools" | "engine">, runsOn: Pick<TurnAgent, "sandbox" | "selfWake"> | undefined, options: Pick<EngineToolLimits, "artifactPageBytes" | "sandboxTools">, memory?: EngineMemory, plan?: boolean, connections?: boolean, triggers?: boolean): EngineProjection;
63
+ export declare function engineProjection(agent: Pick<AgentManifest, "skills" | "tools" | "engine">, runsOn: Pick<TurnAgent, "sandbox" | "selfWake"> | undefined, options: Pick<EngineToolLimits, "artifactPageBytes" | "sandboxTools">, memory?: EngineMemory, plan?: boolean, connections?: boolean, triggers?: boolean, ask?: boolean): EngineProjection;
64
+ /** The first line of server `nylorun`'s text (ADR-106). */
65
+ export declare const RUNTIME_SERVER_HEADING = "# Server nylorun\nThe Runtime's own tools, from the plugins this agent declares. Their names begin with nylorun__.";
@@ -1,6 +1,7 @@
1
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, TRIGGERS_TOOL, UPDATE_PLAN_TOOL, artifactTools, connectionToolOf, memoryToolOf, planToolOf, sandboxTools, skillTools, triggersToolOf, 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. */
@@ -21,7 +22,9 @@ export const DEFAULT_ENGINE_TOOL_LIMITS = Object.freeze({
21
22
  * the version declares `harness.engine.triggers` (`turn.start.agent.triggers`). What the agent
22
23
  * declares (`agent.engine`) decides the rest; a block it replaces is in its words.
23
24
  */
24
- export function engineProjection(agent, runsOn, options, memory, plan = false, connections = false, triggers = 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);
25
28
  const skills = Object.values(agent.skills ?? {});
26
29
  const workspace = runsOn?.sandbox?.workspace;
27
30
  const features = engineFeaturesOf(agent.engine, { computer: workspace !== undefined });
@@ -107,3 +110,95 @@ export function engineProjection(agent, runsOn, options, memory, plan = false, c
107
110
  features,
108
111
  };
109
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 {
@@ -116,3 +122,19 @@ export declare function deferredToolsTools(config: {
116
122
  readonly toolSearchDefaultLimit: number;
117
123
  readonly toolSearchMaxLimit: number;
118
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;
@@ -506,3 +506,39 @@ export function deferredToolsTools(config) {
506
506
  function definedOf(value) {
507
507
  return Object.fromEntries(Object.entries(value).filter(([, item]) => item !== undefined));
508
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
@@ -77,7 +77,7 @@ export declare const SCHEMA_URLS: {
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"];