@nylorun/harness 0.37.3-beta → 0.38.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 (55) hide show
  1. package/CHANGELOG.md +67 -41
  2. package/HOST_CONTRACT.md +9 -10
  3. package/dist/api/executors.d.ts +4 -4
  4. package/dist/api/harness.d.ts +3 -3
  5. package/dist/api/harness.js +1 -1
  6. package/dist/api/host.d.ts +0 -18
  7. package/dist/api/host.js +8 -4
  8. package/dist/api/run.d.ts +1 -9
  9. package/dist/api/run.js +17 -14
  10. package/dist/flow/engine.d.ts +1 -1
  11. package/dist/flow/engine.js +1 -1
  12. package/dist/flow/limits.d.ts +1 -1
  13. package/dist/flow/limits.js +1 -1
  14. package/dist/flow/paths.d.ts +2 -2
  15. package/dist/flow/paths.js +2 -2
  16. package/dist/loop/compaction/config.d.ts +2 -2
  17. package/dist/loop/compaction/config.js +1 -1
  18. package/dist/loop/compaction/index.d.ts +2 -2
  19. package/dist/loop/compaction/index.js +2 -2
  20. package/dist/loop/delegation.d.ts +3 -3
  21. package/dist/loop/delegation.js +1 -1
  22. package/dist/loop/model/files.d.ts +3 -3
  23. package/dist/loop/model/files.js +4 -4
  24. package/dist/loop/model/project.d.ts +1 -1
  25. package/dist/loop/model/project.js +2 -2
  26. package/dist/loop/options.js +1 -1
  27. package/dist/loop/run.js +4 -4
  28. package/dist/loop/step/canonicalize.d.ts +2 -2
  29. package/dist/loop/step/canonicalize.js +2 -2
  30. package/dist/loop/step/step-context.d.ts +1 -1
  31. package/dist/loop/step/step-context.js +1 -1
  32. package/dist/loop/tool-result.js +2 -2
  33. package/dist/loop/transcript.js +1 -1
  34. package/dist/run/durable.d.ts +4 -4
  35. package/dist/run/durable.js +6 -6
  36. package/dist/tools/ask.d.ts +6 -6
  37. package/dist/tools/ask.js +1 -1
  38. package/dist/tools/engine-tools.d.ts +5 -5
  39. package/dist/tools/mcp.d.ts +1 -1
  40. package/dist/tools/mcp.js +1 -1
  41. package/dist/tools/memory.d.ts +3 -3
  42. package/dist/tools/outputs.js +1 -1
  43. package/dist/tools/person-started.d.ts +12 -0
  44. package/dist/tools/person-started.js +31 -0
  45. package/dist/tools/read-media.js +1 -1
  46. package/dist/tools/results.d.ts +1 -1
  47. package/dist/tools/results.js +3 -3
  48. package/dist/tools/sandbox.d.ts +1 -1
  49. package/dist/tools/sandbox.js +1 -1
  50. package/dist/tools/skills.d.ts +9 -4
  51. package/dist/tools/skills.js +32 -6
  52. package/dist/tools/tool-search.js +1 -1
  53. package/dist/tools/wake.js +1 -1
  54. package/dist/types/execution.d.ts +4 -4
  55. package/package.json +2 -2
@@ -32,7 +32,7 @@ export interface HostEffect {
32
32
  /**
33
33
  * `delegation` journals when an agent used as a tool starts and settles; hosts record it and resolve it at once.
34
34
  * Flow effects: `agent` and `tool` (node) — each carries `path`, `key`, and `iterations`.
35
- * `inputs` (D85) takes the messages steered into the running turn before a step; hosts answer it
35
+ * `inputs` takes the messages steered into the running turn before a step; hosts answer it
36
36
  * at once with `{events}`.
37
37
  */
38
38
  readonly kind: "model" | "tool" | "delegation" | "agent" | "inputs";
@@ -128,7 +128,7 @@ export declare function runDurable(options: {
128
128
  engineTools?: (agent: AgentManifest) => EngineTools;
129
129
  /**
130
130
  * Text to keep at the head of the conversation (`ExecutionState.pinned`): the memory index
131
- * block (`memoryIndexBlock`, track T5). The state keeps what it pinned at the session's first
131
+ * block (`memoryIndexBlock`). The state keeps what it pinned at the session's first
132
132
  * turn, and after a compaction takes this; without it, the state drops its pinned text. Not
133
133
  * hashed.
134
134
  */
@@ -138,13 +138,13 @@ export declare function runDurable(options: {
138
138
  * Agent's memory changed elsewhere since (`turn.start.memory.refresh`).
139
139
  */
140
140
  refreshPinned?: boolean;
141
- /** Segment rollover (Model Calls §10): yield after this many steps or milliseconds. */
141
+ /** Segment rollover: yield after this many steps or milliseconds. */
142
142
  yieldAfter?: {
143
143
  readonly steps?: number;
144
144
  readonly ms?: number;
145
145
  };
146
146
  /**
147
- * Ask the host for the messages steered into the turn (D85) before every step but its first:
147
+ * Ask the host for the messages steered into the turn before every step but its first:
148
148
  * an `inputs` effect, which a host that serves it answers at once with `{events}`. Off unless
149
149
  * set; the Harness API run sets it, since core serves it. Not hashed.
150
150
  */
@@ -82,7 +82,7 @@ export async function runDurable(options) {
82
82
  ...(tool.description === undefined ? {} : { description: tool.description }),
83
83
  inputSchema: schemaFromJSON(tool.inputSchema),
84
84
  ...(tool.outputSchema ? { outputSchema: schemaFromJSON(tool.outputSchema) } : {}),
85
- // No approval here: the Tool Gate holds a call its policy asks a person about (R5 step 2).
85
+ // No approval here: the Tool Gate holds a call its policy asks a person about.
86
86
  async execute(args, ctx) {
87
87
  const previous = patchTail;
88
88
  let release;
@@ -134,7 +134,7 @@ export async function runDurable(options) {
134
134
  ...(engine?.tools ?? []),
135
135
  ...sessionTools.filter((tool) => (tool.agentId ?? manifest.id) === agent.id),
136
136
  ];
137
- // Deferred tools stay out of the model's list; `tool_call` runs them (R2b C10).
137
+ // Deferred tools stay out of the model's list; `tool_call` runs them.
138
138
  const owned = mine.filter((tool) => !tool.deferred);
139
139
  const deferred = new Map(mine.filter((tool) => tool.deferred).map((tool) => [tool.name, tool]));
140
140
  const tools = {};
@@ -202,7 +202,7 @@ export async function runDurable(options) {
202
202
  },
203
203
  };
204
204
  /**
205
- * The messages steered into the root's turn (D85), before step `stepNumber`: an `inputs`
205
+ * The messages steered into the root's turn, before step `stepNumber`: an `inputs`
206
206
  * effect, journaled by core even when empty, so a replay takes the same at the same step. A
207
207
  * core that doesn't know the kind (`invalid`) turns taking off for this run: its steers start
208
208
  * the next turn instead.
@@ -285,7 +285,7 @@ function withPinned(state, pinned, refresh = false) {
285
285
  return state.pinned === undefined || refresh ? { ...state, pinned: [...pinned] } : state;
286
286
  }
287
287
  /**
288
- * `memory` (track T5): each command's parameters are checked before the call is sent
288
+ * `memory`: each command's parameters are checked before the call is sent
289
289
  * (`checkMemoryCall`), so a call the Runtime would refuse is never journaled; the model reads the
290
290
  * error text and may call again.
291
291
  */
@@ -304,7 +304,7 @@ function checkedMemoryTool(run) {
304
304
  function identityOf(agent, tool, input, ref) {
305
305
  const skill = skillOfToolCall(agent, tool, input);
306
306
  return {
307
- // A Runtime plugin's tool carries its own name (ADR-106): `memory`, not `nylorun__memory`.
307
+ // A Runtime plugin's tool carries its own name: `memory`, not `nylorun__memory`.
308
308
  toolName: tool.effectName ?? tool.name,
309
309
  ...(tool.target === undefined ? {} : { target: tool.target }),
310
310
  ...(skill === undefined ? {} : { skill }),
@@ -316,7 +316,7 @@ function scoped(ref, identity) {
316
316
  return ref ? `${ref.delegationId}/${identity}` : identity;
317
317
  }
318
318
  /**
319
- * `tool_call` (R2b C10): runs a deferred tool by name, as that tool's own call. It checks the
319
+ * `tool_call`: runs a deferred tool by name, as that tool's own call. It checks the
320
320
  * arguments against the tool's `inputSchema` first, so a mistake comes back to the model as a
321
321
  * failed result it can fix. The effect then names the tool and its identity (`target`), so the
322
322
  * record routes it and records `tool.completed` as for a direct call, the host shapes its result,
@@ -4,21 +4,21 @@ export { ASK_LIMITS, ASK_TOOL } from "@nylorun/core/engine";
4
4
  export declare function isAskTool(effect: HostEffect): boolean;
5
5
  /** Runs a call of `ask`: the interaction to wait on, or, once answered, the answer. */
6
6
  export declare function runAskTool(effect: HostEffect): {
7
+ output?: undefined;
7
8
  readonly kind: "failed";
8
9
  readonly code: "ask.invalid_input";
9
10
  readonly message: "Give question, what you need to know.";
10
- readonly output?: undefined;
11
11
  readonly interaction?: undefined;
12
12
  } | {
13
- readonly code?: undefined;
14
- readonly message?: undefined;
13
+ code?: undefined;
14
+ message?: undefined;
15
15
  readonly kind: "completed";
16
16
  readonly output: `Answer: ${string}`;
17
17
  readonly interaction?: undefined;
18
18
  } | {
19
- readonly code?: undefined;
20
- readonly message?: undefined;
21
- readonly output?: undefined;
19
+ code?: undefined;
20
+ message?: undefined;
21
+ output?: undefined;
22
22
  readonly kind: "interaction-required";
23
23
  readonly interaction: {
24
24
  readonly kind: "response";
package/dist/tools/ask.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `ask` (ADR-106, `nylorun-interactions`): the agent asks whoever gave it the task a question it
2
+ * `ask` (`nylorun-interactions`): the agent asks whoever gave it the task a question it
3
3
  * can't answer itself, and waits. Offered to the session's root agent when the version sets
4
4
  * `harness.loop.ask: true` (`turn.start.loop.ask`; in an `agent-folder/3` folder, the
5
5
  * `nylorun-interactions` plugin with its `ask` tool on).
@@ -1,5 +1,5 @@
1
1
  /**
2
- * What our engine adds to each agent of a session (protocol 15, ADR-100): the model-facing text
2
+ * What our engine adds to each agent of a session (protocol 15): the model-facing text
3
3
  * and tools that come with the session's Environment, its memory and loop settings, and the
4
4
  * agent's skills, as the agent declares them (`engine`, `agent-folder/2`) or, when it declares
5
5
  * nothing, every default of `agent-folder/1`. The Runtime states facts in `turn.start` (the
@@ -9,9 +9,9 @@
9
9
  * - instructions: the skills' usage and catalog; the sandbox note; the skills' folder note;
10
10
  * the artifact notes; the wake note; the memory rules; the plan and connection notes;
11
11
  * - tools: the sandbox tools; the skill tools; `save_artifact`; `read_artifact`;
12
- * `schedule_wake` when the session's version sets `runtime.selfWake` (track T4); `memory`
13
- * when it sets `harness.memory` (track T5); and, for the root agent, `triggers` when it
14
- * declares `harness.engine.triggers` (D83, `turn.start.agent.triggers`), `update_plan` when it
12
+ * `schedule_wake` when the session's version sets `runtime.selfWake`; `memory`
13
+ * when it sets `harness.memory`; and, for the root agent, `triggers` when it
14
+ * declares `harness.engine.triggers` (`turn.start.agent.triggers`), `update_plan` when it
15
15
  * sets `harness.loop.plan` and `request_connection` when it sets `harness.loop.connections` (A2A
16
16
  * profile v2).
17
17
  *
@@ -46,7 +46,7 @@ export interface EngineToolOptions {
46
46
  export interface EngineTools {
47
47
  readonly tools: readonly DurableSessionTool[];
48
48
  readonly instructions: readonly string[];
49
- /** The text blocks the agent got (ADR-100), in order. */
49
+ /** The text blocks the agent got, in order. */
50
50
  readonly blocks?: readonly EngineBlockUse[];
51
51
  /** The engine features the agent got. */
52
52
  readonly features?: EngineFeatures;
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The session's MCP tools as our engine offers them (protocol 15): named, deferred behind
3
- * `tool_search` past the threshold (only for an agent that declares tool search, ADR-100, or
3
+ * `tool_search` past the threshold (only for an agent that declares tool search, or
4
4
  * declares nothing), and laid out once per session's facts. The code is `@nylorun/core/engine`'s,
5
5
  * which the SDK's `previewTurn` runs too.
6
6
  */
package/dist/tools/mcp.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * The session's MCP tools as our engine offers them (protocol 15): named, deferred behind
3
- * `tool_search` past the threshold (only for an agent that declares tool search, ADR-100, or
3
+ * `tool_search` past the threshold (only for an agent that declares tool search, or
4
4
  * declares nothing), and laid out once per session's facts. The code is `@nylorun/core/engine`'s,
5
5
  * which the SDK's `previewTurn` runs too.
6
6
  */
@@ -1,9 +1,9 @@
1
1
  /**
2
- * `memory` (track T5, D72): the agent reads and edits its Agent's memory, Markdown files under
2
+ * `memory`: the agent reads and edits its Agent's memory, Markdown files under
3
3
  * `/memories` that outlive the session. Offered when the version the session runs sets
4
4
  * `harness.memory` (`turn.start.memory`). The tool is Anthropic's memory tool: one `memory` tool
5
5
  * whose `command` is view, create, str_replace, insert, delete or rename, with Anthropic's
6
- * parameters and answers, the shape the T5 experiment found models of every size call well.
6
+ * parameters and answers, a shape models of every size call well.
7
7
  *
8
8
  * The Runtime serves it (a `runtime` effect, operation `memory`) in the call's own transaction, so
9
9
  * a replayed turn applies a write once, and checks every call: a missing parameter, a path outside
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * The index the Runtime renders (one line per memory, newest first) is pinned at the head of the
14
14
  * conversation, as user-role context, so a session's prompt prefix stays the same; see
15
- * `ExecutionState.pinned`. A version that sets `harness.memory.index: false` (ADR-100) has none.
15
+ * `ExecutionState.pinned`. A version that sets `harness.memory.index: false` has none.
16
16
  * The tool and its text are `@nylorun/core/engine`'s (block `memory`).
17
17
  */
18
18
  import type { TurnMemory } from "@nylorun/core/harness-api";
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Our engine's outputs folder (protocol 15, Q5): a convention of our engine, not of the Runtime.
2
+ * Our engine's outputs folder (protocol 15): a convention of our engine, not of the Runtime.
3
3
  * When an agent's segment ends its turn `completed` in a session with a sandbox, our engine saves
4
4
  * the files under its outputs directory (`/workspace/outputs` by default) as a version of the
5
5
  * session's folder artifact `outputs`, over the artifact seam (`artifact.write` with
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Skills only a person starts (Host feature `person-started-skills`): a skill with
3
+ * `disableModelInvocation: true` is left out of what the model sees (its catalog, `load_skill`'s
4
+ * names and what `load_skill` serves) unless the turn's input names it in `metadata.skill`, which
5
+ * the Runtime sets from the message's `skill`. An agent used as a tool never gets one: a person
6
+ * starts a skill for the root agent's turn.
7
+ */
8
+ import type { AgentManifest } from "@nylorun/core/define";
9
+ /** The skills a person started for a turn: `metadata.skill` of its input, or of each queued message. */
10
+ export declare function startedSkillsOf(input: unknown): ReadonlySet<string>;
11
+ /** The agent as its model sees it: each skill only a person starts left out unless `started` names it. */
12
+ export declare function withPersonStartedSkills<T extends Pick<AgentManifest, "skills">>(agent: T, started?: ReadonlySet<string>): T;
@@ -0,0 +1,31 @@
1
+ const NONE = new Set();
2
+ /** The skills a person started for a turn: `metadata.skill` of its input, or of each queued message. */
3
+ export function startedSkillsOf(input) {
4
+ const names = new Set();
5
+ const read = (value) => {
6
+ if (!value || typeof value !== "object")
7
+ return;
8
+ const item = value;
9
+ if (item.kind === "messages" && Array.isArray(item.messages)) {
10
+ for (const message of item.messages)
11
+ read(message);
12
+ return;
13
+ }
14
+ if (typeof item.metadata?.skill === "string")
15
+ names.add(item.metadata.skill);
16
+ };
17
+ read(input);
18
+ return names.size === 0 ? NONE : names;
19
+ }
20
+ /** The agent as its model sees it: each skill only a person starts left out unless `started` names it. */
21
+ export function withPersonStartedSkills(agent, started = NONE) {
22
+ const skills = agent.skills;
23
+ if (!skills)
24
+ return agent;
25
+ const shown = (skill) => skill.disableModelInvocation !== true || started.has(skill.name);
26
+ if (Object.values(skills).every(shown))
27
+ return agent;
28
+ const kept = Object.fromEntries(Object.entries(skills).filter(([, skill]) => shown(skill)));
29
+ const { skills: _, ...rest } = agent;
30
+ return (Object.keys(kept).length === 0 ? rest : { ...rest, skills: kept });
31
+ }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `read` of a sandbox file the turn's model reads as media (ADR-139): an image, a PDF, an Office
2
+ * `read` of a sandbox file the turn's model reads as media: an image, a PDF, an Office
3
3
  * document, audio or video, known by its extension. Our engine runs it here instead of in the
4
4
  * sandbox, which reads text: it reads the bytes (`files.read`), stores them as an artifact of the
5
5
  * session for the model only (`artifact.write` with `audience: "model"`, keyed by the call), and
@@ -46,7 +46,7 @@ export interface ShapeContext {
46
46
  readonly limits: Pick<RuntimeLimits, "modelFileBytes">;
47
47
  readonly config: ToolResultConfig;
48
48
  /**
49
- * False when the call's agent has no `read_artifact` (ADR-100, an `agent-folder/2` agent
49
+ * False when the call's agent has no `read_artifact` (an `agent-folder/2` agent
50
50
  * without `engine.artifacts.read`): a cut result says `retrievable: false`, since the model
51
51
  * cannot read the rest. It is stored all the same, for people. Default true.
52
52
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tool results that fit (R2b C11, Q22–Q24; protocol 15): our engine shapes what a tool returned
2
+ * Tool results that fit (protocol 15): our engine shapes what a tool returned
3
3
  * before it reports the outcome (`effect.outcome`), since the record refuses an entry past the
4
4
  * Runtime limit `recordEntryBytes` and a step's results are one transcript entry. The Tool Gate
5
5
  * already refused an answer past `toolAnswerBytes` (`mcp.too-large`, `http.too-large`) and
@@ -25,7 +25,7 @@
25
25
  * Each stored result's key (`spillKey`) is the call's effect id with the bytes' hash: a call run
26
26
  * again after a crash, which the gate answers with the same bytes, writes nothing new, and other
27
27
  * bytes never take the key of a preview already recorded. The model reads a stored result with
28
- * `read_artifact`; for an agent without it (ADR-100), the stub says `retrievable: false`.
28
+ * `read_artifact`; for an agent without it, the stub says `retrievable: false`.
29
29
  */
30
30
  import { createHash } from "node:crypto";
31
31
  import { ARTIFACT_NAME_MAX, DEFAULT_CONTENT_TYPE, extensionFor, isText, normalizeContentType, } from "@nylorun/core/contracts";
@@ -240,7 +240,7 @@ async function shapeBinary(ctx, part, index, files) {
240
240
  DEFAULT_CONTENT_TYPE;
241
241
  const name = nameOf(ctx, contentType, index);
242
242
  const kept = await ctx.store(fromBase64(data), { name, contentType, index });
243
- // An image the turn's model reads goes to it as a file, beside the part (Q23).
243
+ // An image the turn's model reads goes to it as a file, beside the part.
244
244
  if (part.type === "image" && "artifactId" in kept) {
245
245
  const file = {
246
246
  mediaType: contentType,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Our engine's sandbox tools (protocol 15): `bash`, `read`, `write`, `edit`, `grep` and `glob`,
3
3
  * offered to an agent of a session with a sandbox (`turn.start.agent.sandbox`), all six or those
4
- * its manifest declares (ADR-100, `engine.sandbox`), with the note on the sandbox that goes with
4
+ * its manifest declares (`engine.sandbox`), with the note on the sandbox that goes with
5
5
  * them. Our engine names, describes and instructs them (`@nylorun/core/engine`, which the SDK's
6
6
  * `previewTurn` reads too); each call is a `sandbox` effect named by its operation, which the host
7
7
  * runs in the session's sandbox (`executors.tool`), so the record keeps `environment.exec` and the
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Our engine's sandbox tools (protocol 15): `bash`, `read`, `write`, `edit`, `grep` and `glob`,
3
3
  * offered to an agent of a session with a sandbox (`turn.start.agent.sandbox`), all six or those
4
- * its manifest declares (ADR-100, `engine.sandbox`), with the note on the sandbox that goes with
4
+ * its manifest declares (`engine.sandbox`), with the note on the sandbox that goes with
5
5
  * them. Our engine names, describes and instructs them (`@nylorun/core/engine`, which the SDK's
6
6
  * `previewTurn` reads too); each call is a `sandbox` effect named by its operation, which the host
7
7
  * runs in the session's sandbox (`executors.tool`), so the record keeps `environment.exec` and the
@@ -38,7 +38,7 @@ export interface SkillToolContext {
38
38
  readonly channel: Pick<HarnessChannel, "request">;
39
39
  readonly run: HarnessRun;
40
40
  /** The agent whose skill the call reads: the turn's agent, or the agent used as a tool. */
41
- readonly agent: Pick<AgentManifest, "skills" | "engine">;
41
+ readonly agent: Pick<AgentManifest, "skills" | "engine" | "plugins">;
42
42
  /**
43
43
  * The most bytes of one file read into the model's context: the harness's `skillReadBytes`.
44
44
  * The answer is also held to the run's `limits.recordEntryBytes`, since it is one record entry.
@@ -67,8 +67,13 @@ export declare function sandboxSkillsOf(manifest: AgentManifest | undefined, int
67
67
  */
68
68
  export declare function definitionFileChunks(channel: Pick<HarnessChannel, "request">, run: HarnessRun, sha256: string, signal: AbortSignal): AsyncGenerator<Uint8Array>;
69
69
  /**
70
- * Mounts the skill folders of the run's tree in its sandbox, before a `sandbox` call: each one
71
- * the sandbox does not hold yet is written, read-only. A failed outcome (the call's, then) when
72
- * one cannot be; nothing when the tree has no skills.
70
+ * The Agent Plugins mounted whole by `manifest` and by the agents it uses as tools (they share its
71
+ * sandbox), by folder (`/plugins/<name>@<hash>`): each distinct version once.
72
+ */
73
+ export declare function sandboxPluginsOf(manifest: AgentManifest | undefined, into?: Map<string, Readonly<Record<string, string>>>): Map<string, SkillFiles>;
74
+ /**
75
+ * Mounts the skill folders of the run's tree in its sandbox, and the folders of the Agent Plugins
76
+ * it mounts whole, before a `sandbox` call: each one the sandbox does not hold yet is written,
77
+ * read-only. A failed outcome (the call's, then) when one cannot be; nothing when the tree has none.
73
78
  */
74
79
  export declare function mountSkills(files: HarnessFiles, channel: Pick<HarnessChannel, "request">, run: HarnessRun, signal: AbortSignal): Promise<FailedFileOutcome | undefined>;
@@ -21,7 +21,7 @@
21
21
  * `executors.files.mount` (`mountSkills`). The host only writes the files, and answers `present`
22
22
  * for a folder the sandbox already holds since it last started.
23
23
  */
24
- import { SKILL_ENTRY, SKILLS_MOUNT, skillFolderOf, skillInstructions, } from "@nylorun/core/define";
24
+ import { SKILL_ENTRY, SKILLS_MOUNT, pluginFolderOf, skillFolderOf, skillInstructions, } from "@nylorun/core/define";
25
25
  import { LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, pluginSkill, pluginSkills, SKILLS_USAGE, formatSkillCatalog, } from "@nylorun/core/engine";
26
26
  import { fromBase64 } from "@nylorun/core/harness-api";
27
27
  export { DEFAULT_SKILL_READ_BYTES, LOAD_SKILL_TOOL, READ_SKILL_RESOURCE_TOOL, SKILLS_USAGE, formatSkillCatalog, skillFolderNote, skillTools, } from "@nylorun/core/engine";
@@ -86,7 +86,7 @@ export async function runSkillTool(effect, context) {
86
86
  const skills = new Map(Object.values(context.agent.skills ?? {}).map((skill) => [skill.name, skill]));
87
87
  const name = typeof input.name === "string" ? input.name : "";
88
88
  const skill = skills.get(name);
89
- // A skill of a Runtime plugin the agent declares (ADR-106) is the plugin's: served from the bundle.
89
+ // A skill of a Runtime plugin the agent declares is the plugin's: served from the bundle.
90
90
  const declared = (context.agent.engine?.plugins ?? []).map((plugin) => plugin.name);
91
91
  const ofPlugin = skill ? undefined : pluginSkill(declared, name);
92
92
  if (ofPlugin)
@@ -113,6 +113,13 @@ export async function runSkillTool(effect, context) {
113
113
  const recordBytes = context.run.start.limits.recordEntryBytes;
114
114
  const maxBytes = Math.min(context.readBytes, recordBytes);
115
115
  const directory = `${skillFolderOf(skill)}/`;
116
+ // The folder of the Agent Plugin the skill came from, when that plugin is mounted whole: where the
117
+ // skill's references to the plugin's own files (agents/…, resources/…) are found.
118
+ const mounted = skill.plugin &&
119
+ (context.agent.plugins ?? []).find((plugin) => plugin.name === skill.plugin.name && plugin.files);
120
+ const pluginPath = mounted?.files
121
+ ? `${pluginFolderOf({ name: mounted.name, files: mounted.files })}/`
122
+ : undefined;
116
123
  const tooLarge = (path) => failed("skill.resource_too_large", sandboxed
117
124
  ? `${path} is larger than ${maxBytes} bytes, too large to read here. It is in the sandbox at ${directory}${path}; use it there.`
118
125
  : `${path} is larger than ${maxBytes} bytes; only smaller files can be read without a sandbox.`);
@@ -136,6 +143,7 @@ export async function runSkillTool(effect, context) {
136
143
  content: skillInstructions(text),
137
144
  ...(resources.length === 0 ? {} : { resources }),
138
145
  ...(sandboxed ? { sandboxPath: directory } : {}),
146
+ ...(sandboxed && pluginPath ? { pluginPath } : {}),
139
147
  });
140
148
  }
141
149
  const path = typeof input.path === "string" ? input.path : "";
@@ -182,12 +190,30 @@ export async function* definitionFileChunks(channel, run, sha256, signal) {
182
190
  }
183
191
  }
184
192
  /**
185
- * Mounts the skill folders of the run's tree in its sandbox, before a `sandbox` call: each one
186
- * the sandbox does not hold yet is written, read-only. A failed outcome (the call's, then) when
187
- * one cannot be; nothing when the tree has no skills.
193
+ * The Agent Plugins mounted whole by `manifest` and by the agents it uses as tools (they share its
194
+ * sandbox), by folder (`/plugins/<name>@<hash>`): each distinct version once.
195
+ */
196
+ export function sandboxPluginsOf(manifest, into = new Map()) {
197
+ for (const plugin of manifest?.plugins ?? []) {
198
+ if (!plugin.files)
199
+ continue;
200
+ const folder = pluginFolderOf({ name: plugin.name, files: plugin.files });
201
+ if (!into.has(folder))
202
+ into.set(folder, plugin.files);
203
+ }
204
+ for (const tool of manifest?.tools ?? [])
205
+ if (tool.agent !== undefined && !("kind" in tool.agent))
206
+ sandboxPluginsOf(tool.agent, into);
207
+ return into;
208
+ }
209
+ /**
210
+ * Mounts the skill folders of the run's tree in its sandbox, and the folders of the Agent Plugins
211
+ * it mounts whole, before a `sandbox` call: each one the sandbox does not hold yet is written,
212
+ * read-only. A failed outcome (the call's, then) when one cannot be; nothing when the tree has none.
188
213
  */
189
214
  export async function mountSkills(files, channel, run, signal) {
190
- for (const [folder, skill] of sandboxSkillsOf(run.start.manifest)) {
215
+ const manifest = run.start.manifest;
216
+ for (const [folder, skill] of [...sandboxSkillsOf(manifest), ...sandboxPluginsOf(manifest)]) {
191
217
  const mounted = await files.mount(run, folder, skill, (sha256) => definitionFileChunks(channel, run, sha256, signal), signal);
192
218
  if (mounted.kind === "failed")
193
219
  return mounted;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Deferred MCP tools (R2b C10, Q20), run by our engine: `tool_search` finds an agent's deferred
2
+ * Deferred MCP tools, run by our engine: `tool_search` finds an agent's deferred
3
3
  * tools, ranked with BM25 over their names and descriptions, and returns each match's name,
4
4
  * description and `inputSchema`; `tool_call` runs one by name, as that tool's own call
5
5
  * (`deferredToolCall` in `run/durable.ts`). `tool_search` is our engine's tool (`harness`): it
@@ -1,5 +1,5 @@
1
1
  /**
2
- * `schedule_wake` (track T4, D77): the agent books its own session's next turn, "check the deploy
2
+ * `schedule_wake`: the agent books its own session's next turn, "check the deploy
3
3
  * again in two hours". Offered when the version the session runs sets `runtime.selfWake`
4
4
  * (`turn.start.agent.selfWake`). The Runtime serves it (a `runtime` effect): it writes the booking
5
5
  * in the call's own transaction, keyed by the call, so a replayed turn books once. A session holds
@@ -75,7 +75,7 @@ export interface TurnState {
75
75
  export interface ExecutionState {
76
76
  readonly version: 1;
77
77
  readonly agentId: string;
78
- /** Definition binding — required for resume after Phase 2. Optional on legacy states. */
78
+ /** Definition binding — required for resume. Optional on legacy states. */
79
79
  readonly manifestHash?: string;
80
80
  readonly executionId: string;
81
81
  readonly outputContract?: JsonObject;
@@ -94,7 +94,7 @@ export interface ExecutionState {
94
94
  */
95
95
  readonly state?: JsonObject;
96
96
  /**
97
- * Which of the session's MCP tools our engine defers (R2b C10, `McpLayout`), decided once for
97
+ * Which of the session's MCP tools our engine defers (`McpLayout`), decided once for
98
98
  * the facts whose hash it names and kept while they stay the same.
99
99
  */
100
100
  readonly mcpLayout?: {
@@ -103,7 +103,7 @@ export interface ExecutionState {
103
103
  };
104
104
  /**
105
105
  * Text our engine keeps at the head of the conversation, after the instructions: the Agent's
106
- * memory index (track T5), pinned at the session's first turn so the prompt's prefix stays
106
+ * memory index, pinned at the session's first turn so the prompt's prefix stays
107
107
  * the same. A compaction drops it, and the next segment pins the index of that moment.
108
108
  */
109
109
  readonly pinned?: readonly string[];
@@ -155,7 +155,7 @@ export type RunResult<Output = string> = {
155
155
  }
156
156
  /**
157
157
  * A durable segment ended at a step boundary so the turn continues in a new segment
158
- * (Model Calls §10). The state is mid-turn; resume it with `{ kind: "continue" }`.
158
+ *. The state is mid-turn; resume it with `{ kind: "continue" }`.
159
159
  */
160
160
  | {
161
161
  readonly status: "yielded";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nylorun/harness",
3
- "version": "0.37.3-beta",
3
+ "version": "0.38.0-beta",
4
4
  "description": "Nylorun's TypeScript agent execution engine. See github.com/nylorun/agents.",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -77,7 +77,7 @@
77
77
  "zod": "^4.6.7"
78
78
  },
79
79
  "dependencies": {
80
- "@nylorun/core": "0.52.0-beta"
80
+ "@nylorun/core": "0.54.0-beta"
81
81
  },
82
82
  "peerDependencies": {
83
83
  "zod": "^4.6.7"