@nylorun/harness 0.30.1-beta → 0.31.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,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.31.0-beta
4
+
5
+ ### Minor Changes
6
+
7
+ - 67ed2ea: An agent that declares its engine features (`engine`, `agent-folder/2`, ADR-100) gets only those:
8
+ no shell or file tools and no sandbox note without `engine.sandbox` (or only the tools it names),
9
+ no `read_artifact` or `save_artifact` or their text unless declared, and `/workspace/outputs` is
10
+ saved when a turn ends only with `engine.outputs`. Without `artifacts.read`, a tool result past
11
+ the inline cap is cut to its preview with `retrievable: false` (still stored), and file reference
12
+ lines do not offer `read_artifact`. Without `toolSearch`, MCP tools are never deferred
13
+ automatically (a server's own `deferred` still applies); past the threshold the harness claims
14
+ `engine.diagnostic` (`mcp_tools_inline`) once. A turn whose `memory` has no `index` pins none, and
15
+ the memory rules do not name one. A block the manifest replaces (`engine.instructions`) is in its
16
+ words, the memory rule that outside text is data kept. Agents that declare nothing get exactly
17
+ what they got before. The engine's text and tool definitions now come from
18
+ `@nylorun/core/engine`, which the SDK's `previewTurn` runs too.
19
+ - 67ed2ea: The memory index a session pinned is refreshed at its next turn's first segment (never mid-turn)
20
+ when another session of the Agent, or the API, wrote the Agent's memory since its last turn started:
21
+ `turn.start.memory.refresh` (Harness API), and our engine pins the index again (`runDurable`'s
22
+ `refreshPinned`). The Runtime keeps the newest memory version a turn saw on the session
23
+ (`Session.memoryIndex`, `memoryWritesSince`). A session's own writes leave its index as pinned.
24
+
25
+ ### Patch Changes
26
+
27
+ - Pin core to the tested release.
28
+ - Updated dependencies [67ed2ea]
29
+ - Updated dependencies [67ed2ea]
30
+ - Updated dependencies [67ed2ea]
31
+ - Updated dependencies [67ed2ea]
32
+ - Updated dependencies [67ed2ea]
33
+ - Updated dependencies [67ed2ea]
34
+ - Updated dependencies [67ed2ea]
35
+ - @nylorun/core@0.34.0-beta
36
+
3
37
  ## 0.30.1-beta
4
38
 
5
39
  ### Patch Changes
package/dist/api/host.js CHANGED
@@ -18,6 +18,7 @@
18
18
  */
19
19
  import { HarnessApiError, effectRequestHash, writeArtifactBytes, } from "@nylorun/core/harness-api";
20
20
  import { delegatesOf } from "@nylorun/core/define";
21
+ import { engineFeaturesOf } from "@nylorun/core/engine";
21
22
  import { isArtifactTool, runArtifactTool } from "../tools/artifacts.js";
22
23
  import { isSkillTool, mountSkills, runSkillTool } from "../tools/skills.js";
23
24
  import { StepBudget, jsonBytes, mayNeedShaping, shapeToolOutcome, spillKey, } from "../tools/results.js";
@@ -123,6 +124,7 @@ export function apiHost(channel, executors, run, engine, mcp) {
123
124
  ...(run.start.model ? { model: run.start.model } : {}),
124
125
  limits,
125
126
  config: engine.toolResults,
127
+ ...(readsArtifacts(effect) ? {} : { retrievable: false }),
126
128
  store: (bytes, artifact) => store(effect, bytes, artifact),
127
129
  });
128
130
  // Shaping keeps a result under its cap; one that a store could not hold is refused here,
@@ -132,6 +134,17 @@ export function apiHost(channel, executors, run, engine, mcp) {
132
134
  return fitted;
133
135
  });
134
136
  };
137
+ /** Whether the call's agent (the root, or the agent used as a tool) has `read_artifact`. */
138
+ const readsArtifacts = (effect) => {
139
+ const root = run.start.manifest;
140
+ if (!root || typeof root !== "object")
141
+ return true;
142
+ const agent = effect.agent === undefined
143
+ ? root
144
+ : (delegatesOf(root).find(({ manifest }) => manifest.id === effect.agent.id)?.manifest ??
145
+ root);
146
+ return engineFeaturesOf(agent.engine, { computer: false }).artifactsRead;
147
+ };
135
148
  /** Stores a tool result's bytes as an artifact of the run's session, linked to its call. */
136
149
  const store = async (effect, bytes, artifact) => {
137
150
  try {
package/dist/api/run.js CHANGED
@@ -12,6 +12,7 @@ import { runFlowDurable } from "../flow/engine.js";
12
12
  import { runAbortKind } from "./abort.js";
13
13
  import { apiHost } from "./host.js";
14
14
  import { engineToolsFor } from "../tools/engine-tools.js";
15
+ import { engineFeaturesOf } from "@nylorun/core/engine";
15
16
  import { memoryIndexBlock } from "../tools/memory.js";
16
17
  import { mcpToolSet } from "../tools/mcp.js";
17
18
  import { saveOutputs } from "../tools/outputs.js";
@@ -72,6 +73,8 @@ export async function runTurn(ctx, run) {
72
73
  access: memory.access,
73
74
  ...(memory.instructions === undefined ? {} : { instructions: memory.instructions }),
74
75
  root: agent.id === rootId,
76
+ // No index is pinned when the version sets `harness.memory.index: false` (ADR-100).
77
+ index: memory.index !== undefined,
75
78
  }, plan && agent.id === rootId, connections && agent.id === rootId);
76
79
  const mcp = start.engine === "agent" && start.mcp
77
80
  ? mcpToolSet(start.mcp, start.manifest, {
@@ -81,6 +84,18 @@ export async function runTurn(ctx, run) {
81
84
  taken: (agent) => engineTools(agent).tools.map((tool) => tool.name),
82
85
  })
83
86
  : undefined;
87
+ // What the agent's declarations leave our engine to say, not choose (ADR-100): claimed once,
88
+ // when the session's layout is decided.
89
+ for (const diagnostic of mcp?.diagnostics ?? [])
90
+ await ctx.channel
91
+ .request("event", {
92
+ runId,
93
+ sessionId,
94
+ turnId: run.grant.turnId,
95
+ type: "engine.diagnostic",
96
+ payload: diagnostic,
97
+ })
98
+ .catch(() => undefined);
84
99
  const host = apiHost(ctx.channel, ctx.executors, run, ctx.engine, mcp);
85
100
  const result = start.engine === "flow"
86
101
  ? await runFlowDurable({
@@ -99,16 +114,22 @@ export async function runTurn(ctx, run) {
99
114
  ...(mcp ? { mcp } : {}),
100
115
  // Our engine's own tools and text, from the turn's facts (protocol 15).
101
116
  engineTools,
102
- ...(memory ? { pinned: [memoryIndexBlock(memory)] } : {}),
117
+ ...(memory?.index !== undefined
118
+ ? { pinned: [memoryIndexBlock({ index: memory.index, truncated: memory.truncated })] }
119
+ : {}),
120
+ // Another session wrote the memory since this one's last turn: its index again.
121
+ ...(memory?.refresh ? { refreshPinned: true } : {}),
103
122
  ...(start.options.yieldAfter ? { yieldAfter: start.options.yieldAfter } : {}),
104
123
  ...(start.model ? { model: start.model } : {}),
105
- files: filesOf(ctx, run, start),
124
+ files: filesOf(ctx, run, start, start.manifest.engine),
106
125
  loop: ctx.engine.loop,
107
126
  });
108
- // Our engine's outputs folder (Q5): saved before the turn ends, while the run is held.
127
+ // Our engine's outputs folder (Q5): saved before the turn ends, while the run is held, for
128
+ // a root agent that declares nothing or declares `engine.outputs` (ADR-100).
109
129
  if (start.engine === "agent" &&
110
130
  result.status === "completed" &&
111
131
  start.agent?.sandbox !== undefined &&
132
+ engineFeaturesOf(start.manifest.engine, { computer: true }).outputs &&
112
133
  ctx.executors.files)
113
134
  await saveOutputs({
114
135
  channel: ctx.channel,
@@ -154,10 +175,14 @@ export async function runTurn(ctx, run) {
154
175
  * How the run's engine reads the turn's files (protocol 15): it decides from the model
155
176
  * descriptor and the Runtime limits, and reads text over the artifact seam.
156
177
  */
157
- function filesOf(ctx, run, start) {
178
+ function filesOf(ctx, run, start, engine) {
158
179
  return {
159
180
  ...(start.model ? { model: start.model } : {}),
160
181
  limits: start.limits,
182
+ // Reference lines offer `read_artifact` only to an agent that has it (ADR-100).
183
+ ...(engineFeaturesOf(engine, { computer: false }).artifactsRead
184
+ ? {}
185
+ : { artifactReads: false }),
161
186
  async read(reference, offset, length, signal) {
162
187
  const answer = await ctx.channel.request("artifact.read", {
163
188
  runId: run.runId,
@@ -82,19 +82,19 @@ function filesTokens(entry, files, config) {
82
82
  }, 0);
83
83
  }
84
84
  /** The files an entry names (protocol 12): a message's media parts, and a tool result's files. */
85
- function filesOf(entry) {
85
+ function filesOf(entry, readable = true) {
86
86
  if (entry.kind === "input") {
87
87
  const event = entry.event;
88
88
  if ((event.kind !== "user-message" && event.kind !== "interrupt") ||
89
89
  !("content" in event) ||
90
90
  !event.content)
91
91
  return [];
92
- return event.content.flatMap((part) => part.type === "media" ? [{ line: mediaReferenceLine(part, "uploaded"), part }] : []);
92
+ return event.content.flatMap((part) => part.type === "media" ? [{ line: mediaReferenceLine(part, "uploaded", readable), part }] : []);
93
93
  }
94
94
  if (entry.kind === "tool-results")
95
95
  return entry.results.flatMap((result) => result.kind === "completed" && result.files
96
96
  ? result.files.map((part) => ({
97
- line: mediaReferenceLine(part, { tool: result.toolName }),
97
+ line: mediaReferenceLine(part, { tool: result.toolName }, readable),
98
98
  part,
99
99
  }))
100
100
  : []);
@@ -133,6 +133,8 @@ export function findCut(transcript, keepTokens, config = DEFAULT_COMPACTION_CONF
133
133
  export async function compact(input) {
134
134
  const { transcript } = input;
135
135
  const config = input.config ?? DEFAULT_COMPACTION_CONFIG;
136
+ // An agent without `read_artifact` (ADR-100) is offered it in no line, a summary's either.
137
+ const readable = input.files?.artifactReads !== false;
136
138
  const tokensBefore = estimateTokens(transcript, input.turnId, input.files, config);
137
139
  const window = input.budget?.contextWindow ?? tokensBefore;
138
140
  const keepTokens = Math.max(1, Math.min(config.keepTokens, Math.floor(window * config.keepShare)));
@@ -153,7 +155,7 @@ export async function compact(input) {
153
155
  ...(previous?.files ?? []),
154
156
  ...older
155
157
  .filter((entry) => !request.includes(entry))
156
- .flatMap((entry) => filesOf(entry).map(({ line }) => line)),
158
+ .flatMap((entry) => filesOf(entry, readable).map(({ line }) => line)),
157
159
  ]),
158
160
  ];
159
161
  const keptTokens = tail.reduce((sum, entry) => sum + entryTokens(entry, config), 0);
@@ -247,8 +249,9 @@ function chunked(entries, limit, config) {
247
249
  return chunks;
248
250
  }
249
251
  function summaryCall(input, older, previous, maxOutputTokens, clip) {
252
+ const readable = input.files?.artifactReads !== false;
250
253
  const conversation = older
251
- .map((entry) => entryText(entry, clip))
254
+ .map((entry) => entryText(entry, clip, readable))
252
255
  .filter((text) => text !== "")
253
256
  .join("\n\n");
254
257
  const text = [
@@ -296,14 +299,14 @@ function summaryText(outcome) {
296
299
  return outcome.output.flatMap((block) => (block.type === "text" ? [block.text] : [])).join("");
297
300
  }
298
301
  /** The model-visible text of one entry, with tool payloads clipped to `clip` characters. */
299
- function entryText(entry, clip) {
302
+ function entryText(entry, clip, readable = true) {
300
303
  switch (entry.kind) {
301
304
  case "input": {
302
305
  const event = entry.event;
303
306
  if (event.kind === "user-message" || event.kind === "interrupt")
304
307
  return `[User]: ${"content" in event && event.content
305
308
  ? event.content
306
- .map((part) => part.type === "text" ? part.text : mediaReferenceLine(part, "uploaded"))
309
+ .map((part) => part.type === "text" ? part.text : mediaReferenceLine(part, "uploaded", readable))
307
310
  .join(" ")
308
311
  : (event.text ?? "")}`;
309
312
  if (event.kind === "approve")
@@ -329,7 +332,7 @@ function entryText(entry, clip) {
329
332
  .map((result) => result.kind === "completed"
330
333
  ? [
331
334
  `[Tool ${result.toolName} result]: ${clipped(result.output, clip)}`,
332
- ...(result.files ?? []).map((file) => mediaReferenceLine(file, { tool: result.toolName })),
335
+ ...(result.files ?? []).map((file) => mediaReferenceLine(file, { tool: result.toolName }, readable)),
333
336
  ].join("\n")
334
337
  : result.kind === "denied"
335
338
  ? `[Tool ${result.toolName} denied]: ${result.reason ?? ""}`
@@ -8,6 +8,8 @@ export interface DelegationHost {
8
8
  child(delegate: Delegate, ref: AgentRef): {
9
9
  readonly definition: AgentDefinition;
10
10
  readonly onModelCall: ModelAdapter;
11
+ /** Whether the child has `read_artifact` (ADR-100), when it is not the parent's. */
12
+ readonly artifactReads?: boolean;
11
13
  };
12
14
  /**
13
15
  * Run a flow agent used as a tool: the host starts it in its own linked session and
@@ -52,9 +52,16 @@ export async function runDelegation(invocation, execute, call, delegate) {
52
52
  input: task,
53
53
  onModelCall: child.onModelCall,
54
54
  signal,
55
- // A child calls the same model, and reads its files as the parent does.
55
+ // A child calls the same model, and reads its files as the parent does, with
56
+ // `read_artifact` as it declares (ADR-100).
56
57
  ...(options.model === undefined ? {} : { model: options.model }),
57
- ...(options.files === undefined ? {} : { files: options.files }),
58
+ ...(options.files === undefined
59
+ ? {}
60
+ : {
61
+ files: child.artifactReads === undefined
62
+ ? options.files
63
+ : { ...options.files, artifactReads: child.artifactReads },
64
+ }),
58
65
  ...(options.info === undefined ? {} : { info: options.info }),
59
66
  state: initializeExecutionState(child.definition, {
60
67
  executionId: `${invocation.state.executionId}/${call.invocationId}`,
@@ -27,6 +27,11 @@ export type FileView =
27
27
  };
28
28
  /** What `fileView` decides from: the turn's model and the Runtime limits. */
29
29
  export interface FileViewContext {
30
+ /**
31
+ * False when the agent has no `read_artifact` (ADR-100, an `agent-folder/2` agent without
32
+ * `engine.artifacts.read`): its files' reference lines do not offer it. Default true.
33
+ */
34
+ readonly artifactReads?: boolean;
30
35
  /** `turn.start.model`; undefined when the Runtime sent none. */
31
36
  readonly model?: ModelDescriptor;
32
37
  readonly limits: Pick<RuntimeLimits, "modelFileBytes">;
@@ -55,11 +60,12 @@ export declare function fileNote(name: string, type: string, why: string): strin
55
60
  /**
56
61
  * The line a file stands for in a prompt (protocol 12): its name, artifact id and version, and
57
62
  * how the model reads it again. A file a tool returned names the tool. Every file is its line
58
- * once its turn is over; in its own turn the line labels what follows it.
63
+ * once its turn is over; in its own turn the line labels what follows it. `readable` false for
64
+ * an agent without `read_artifact` (ADR-100): the line names the file only.
59
65
  */
60
66
  export declare function mediaReferenceLine(part: FilePart, origin: "uploaded" | {
61
67
  readonly tool: string;
62
- }): string;
68
+ }, readable?: boolean): string;
63
69
  /** A file of the turn in progress: its key (artifact and version), reference line and part. */
64
70
  export interface LiveFile {
65
71
  readonly key: string;
@@ -53,15 +53,17 @@ export function fileNote(name, type, why) {
53
53
  /**
54
54
  * The line a file stands for in a prompt (protocol 12): its name, artifact id and version, and
55
55
  * how the model reads it again. A file a tool returned names the tool. Every file is its line
56
- * once its turn is over; in its own turn the line labels what follows it.
56
+ * once its turn is over; in its own turn the line labels what follows it. `readable` false for
57
+ * an agent without `read_artifact` (ADR-100): the line names the file only.
57
58
  */
58
- export function mediaReferenceLine(part, origin) {
59
+ export function mediaReferenceLine(part, origin, readable = true) {
59
60
  const reference = mediaReferenceOf(part.reference);
60
61
  const what = origin === "uploaded" ? "Uploaded artifact" : `Tool ${origin.tool} returned artifact`;
61
62
  if (!reference)
62
63
  return `[${what} (${part.mediaType})]`;
63
64
  const name = JSON.stringify(reference.name ?? reference.artifactId);
64
- return `[${what} ${name} · ${reference.artifactId} v${reference.version} · read_artifact to view]`;
65
+ // An agent without `read_artifact` (ADR-100) is not offered it.
66
+ return `[${what} ${name} · ${reference.artifactId} v${reference.version}${readable ? " · read_artifact to view" : ""}]`;
65
67
  }
66
68
  /** The key a file goes by in one call: its artifact version, or its reference. */
67
69
  export function fileKeyOf(part) {
@@ -6,13 +6,14 @@ import { type LiveFile } from "./files.js";
6
6
  * messages, tool results and `read_artifact` loads) also go once, after the conversation and
7
7
  * the context, in one user message: each file's line, then what `files` (`representFiles`)
8
8
  * made of it, a media part, a `<file>` block or a note. Without `files`, each goes as its media
9
- * part. Their content reaches the model only in their own turn.
9
+ * part. Their content reaches the model only in their own turn. `readable` false for an agent
10
+ * without `read_artifact` (ADR-100): no reference line offers it.
10
11
  */
11
- export declare function projectModelCall(request: ModelRequest, files?: ReadonlyMap<string, readonly PromptContentPart[]>): ModelCall;
12
+ export declare function projectModelCall(request: ModelRequest, files?: ReadonlyMap<string, readonly PromptContentPart[]>, readable?: boolean): ModelCall;
12
13
  /**
13
14
  * The files of the turn in progress, in the order the prompt names them, once each: a user
14
15
  * message's media parts and the files its tool results returned.
15
16
  */
16
- export declare function liveFilesOf(request: ModelRequest): LiveFile[];
17
- /** What a turn with an output schema asks of the model's final answer. */
17
+ export declare function liveFilesOf(request: ModelRequest, readable?: boolean): LiveFile[];
18
+ /** What a turn with an output schema asks of the model's final answer (`@nylorun/core/engine`). */
18
19
  export declare function schemaInstruction(schema: NonNullable<ModelRequest["outputSchema"]>): string;
@@ -1,4 +1,5 @@
1
1
  import { copyJson, freezeGraph } from "@nylorun/core/define";
2
+ import { outputSchemaInstruction } from "@nylorun/core/engine";
2
3
  import { summaryPrompt } from "../compaction/index.js";
3
4
  import { FILES_MESSAGE_HEADER, fileKeyOf, mediaReferenceLine, } from "./files.js";
4
5
  /**
@@ -7,16 +8,17 @@ import { FILES_MESSAGE_HEADER, fileKeyOf, mediaReferenceLine, } from "./files.js
7
8
  * messages, tool results and `read_artifact` loads) also go once, after the conversation and
8
9
  * the context, in one user message: each file's line, then what `files` (`representFiles`)
9
10
  * made of it, a media part, a `<file>` block or a note. Without `files`, each goes as its media
10
- * part. Their content reaches the model only in their own turn.
11
+ * part. Their content reaches the model only in their own turn. `readable` false for an agent
12
+ * without `read_artifact` (ADR-100): no reference line offers it.
11
13
  */
12
- export function projectModelCall(request, files) {
14
+ export function projectModelCall(request, files, readable = true) {
13
15
  return freezeGraph({
14
16
  prompt: Object.freeze([
15
17
  ...projectInstructions(request.instructions, request.outputSchema),
16
18
  ...(request.pinned ?? []).map((text) => freezeItem({ kind: "context", role: "user", content: [textPart(text)] })),
17
- ...request.transcript.flatMap((entry) => projectEntry(entry, request.turnId)),
19
+ ...request.transcript.flatMap((entry) => projectEntry(entry, request.turnId, readable)),
18
20
  ...projectContext(request.context),
19
- ...projectFiles(liveFilesOf(request), files),
21
+ ...projectFiles(liveFilesOf(request, readable), files),
20
22
  ]),
21
23
  tools: Object.freeze(request.configuration.tools.map((tool) => Object.freeze({
22
24
  name: tool.name,
@@ -31,7 +33,7 @@ export function projectModelCall(request, files) {
31
33
  * The files of the turn in progress, in the order the prompt names them, once each: a user
32
34
  * message's media parts and the files its tool results returned.
33
35
  */
34
- export function liveFilesOf(request) {
36
+ export function liveFilesOf(request, readable = true) {
35
37
  const live = new Map();
36
38
  const add = (line, part) => {
37
39
  const key = fileKeyOf(part);
@@ -47,13 +49,13 @@ export function liveFilesOf(request) {
47
49
  continue;
48
50
  for (const part of event.content ?? [])
49
51
  if (part.type === "media")
50
- add(mediaReferenceLine(part, "uploaded"), part);
52
+ add(mediaReferenceLine(part, "uploaded", readable), part);
51
53
  }
52
54
  else if (entry.kind === "tool-results")
53
55
  for (const result of entry.results)
54
56
  if (result.kind === "completed")
55
57
  for (const file of result.files ?? [])
56
- add(mediaReferenceLine(file, { tool: result.toolName }), file);
58
+ add(mediaReferenceLine(file, { tool: result.toolName }, readable), file);
57
59
  }
58
60
  return [...live.values()];
59
61
  }
@@ -70,9 +72,9 @@ function projectInstructions(instructions, outputSchema) {
70
72
  return [];
71
73
  return [freezeItem({ kind: "instructions", role: "system", content: [textPart(text)] })];
72
74
  }
73
- /** What a turn with an output schema asks of the model's final answer. */
75
+ /** What a turn with an output schema asks of the model's final answer (`@nylorun/core/engine`). */
74
76
  export function schemaInstruction(schema) {
75
- return `Return the final answer as JSON matching this schema: ${JSON.stringify(schema)}. Use tools when needed before returning the final JSON.`;
77
+ return outputSchemaInstruction(schema);
76
78
  }
77
79
  function projectContext(context) {
78
80
  if (context.items.length === 0)
@@ -118,7 +120,7 @@ function projectFiles(files, represented) {
118
120
  }),
119
121
  ];
120
122
  }
121
- function projectEntry(entry, turnId) {
123
+ function projectEntry(entry, turnId, readable) {
122
124
  if (entry.kind === "input") {
123
125
  if (entry.event.kind !== "user-message" && entry.event.kind !== "interrupt")
124
126
  return [];
@@ -130,7 +132,7 @@ function projectEntry(entry, turnId) {
130
132
  ? entry.event.content.map((part) => {
131
133
  if (part.type === "text")
132
134
  return textPart(part.text);
133
- return textPart(mediaReferenceLine(part, "uploaded"));
135
+ return textPart(mediaReferenceLine(part, "uploaded", readable));
134
136
  })
135
137
  : [textPart(entry.event.text)],
136
138
  }),
@@ -174,14 +176,14 @@ function projectEntry(entry, turnId) {
174
176
  ];
175
177
  }
176
178
  if (entry.kind === "tool-results")
177
- return entry.results.map(projectToolResult);
179
+ return entry.results.map((result) => projectToolResult(result, readable));
178
180
  if (entry.kind === "compaction")
179
181
  return [
180
182
  freezeItem({ kind: "message", role: "user", content: [textPart(summaryPrompt(entry))] }),
181
183
  ];
182
184
  return [];
183
185
  }
184
- function projectToolResult(result) {
186
+ function projectToolResult(result, readable) {
185
187
  return freezeItem({
186
188
  kind: "tool-result",
187
189
  toolCallId: result.callId,
@@ -192,7 +194,7 @@ function projectToolResult(result) {
192
194
  // Files the tool returned, stored by the host (R2b C11): each is its reference line, and
193
195
  // goes to the model in its own turn with the turn's files.
194
196
  ...(result.kind === "completed" && result.files
195
- ? result.files.map((file) => textPart(mediaReferenceLine(file, { tool: result.toolName })))
197
+ ? result.files.map((file) => textPart(mediaReferenceLine(file, { tool: result.toolName }, readable)))
196
198
  : []),
197
199
  ],
198
200
  });
@@ -65,8 +65,9 @@ export async function runStep(input) {
65
65
  requestedModelId = request.model?.id;
66
66
  // How each file of the turn reaches the model is ours to decide (protocol 15): text is read
67
67
  // and inlined here, the rest goes as its reference or a note.
68
- const files = await representFiles(liveFilesOf(request), input.agent.files, input.signal);
69
- const call = projectModelCall(request, files);
68
+ const readable = input.agent.files?.artifactReads !== false;
69
+ const files = await representFiles(liveFilesOf(request, readable), input.agent.files, input.signal);
70
+ const call = projectModelCall(request, files, readable);
70
71
  const invocationId = createId("invocation");
71
72
  modelInvocationId = invocationId;
72
73
  input.observe(() => ({
@@ -1,4 +1,5 @@
1
1
  import { type EffectTarget, type ModelDescriptor } from "@nylorun/core/harness-api";
2
+ import { type EngineTool } from "@nylorun/core/engine";
2
3
  import type { FileContext } from "../loop/model/files.js";
3
4
  import type { AgentManifest } from "@nylorun/core/define";
4
5
  import type { ExecutionInput, ExecutionState, RunResult } from "../types/execution.js";
@@ -89,25 +90,9 @@ export type DurableResult = {
89
90
  };
90
91
  /**
91
92
  * A tool our engine adds to an agent for this execution (an MCP tool of the session, one of our
92
- * engine's own). It is not part of the hashed manifest.
93
+ * engine's own): `@nylorun/core/engine`'s `EngineTool`. It is not part of the hashed manifest.
93
94
  */
94
- export interface DurableSessionTool {
95
- /** The agent used as a tool that owns this tool; absent for the root agent. */
96
- readonly agentId?: string;
97
- readonly name: string;
98
- readonly description?: string;
99
- readonly inputSchema: JsonObject;
100
- readonly outputSchema?: JsonObject;
101
- /**
102
- * Not in the model's tool list (R2b C10): the model finds it with `tool_search` and runs it
103
- * with `tool_call`, which makes the call as this tool's own.
104
- */
105
- readonly deferred?: boolean;
106
- /** Text the model reads, after the engine's, while this tool is advertised. */
107
- readonly instructions?: readonly string[];
108
- /** What runs its calls: their effects' `target` (an MCP tool's identity, our engine's `harness`). */
109
- readonly target?: EffectTarget;
110
- }
95
+ export type DurableSessionTool = EngineTool;
111
96
  export declare function createDurableCheckpoint(input: {
112
97
  manifest: AgentManifest;
113
98
  sessionId: string;
@@ -146,6 +131,11 @@ export declare function runDurable(options: {
146
131
  * hashed.
147
132
  */
148
133
  pinned?: readonly string[];
134
+ /**
135
+ * Pin `pinned` in place of what the state pinned before: at a turn's first segment, when the
136
+ * Agent's memory changed elsewhere since (`turn.start.memory.refresh`).
137
+ */
138
+ refreshPinned?: boolean;
149
139
  /** Segment rollover (Model Calls §10): yield after this many steps or milliseconds. */
150
140
  yieldAfter?: {
151
141
  readonly steps?: number;
@@ -1,5 +1,6 @@
1
1
  import { HarnessError } from "@nylorun/core/define";
2
2
  import { effectIdOf } from "@nylorun/core/harness-api";
3
+ import { engineFeaturesOf } from "@nylorun/core/engine";
3
4
  import { AgentManifestSchema, checkMemoryCall } from "@nylorun/core/contracts";
4
5
  import { agentFrom, withHttpTarget } from "@nylorun/core/define";
5
6
  import { TOOL_CALL_TOOL } from "../tools/tool-search.js";
@@ -184,6 +185,9 @@ export async function runDurable(options) {
184
185
  child: (delegate, ref) => ({
185
186
  definition: hostedDefinition(delegate.manifest, ref),
186
187
  onModelCall: modelCall(ref),
188
+ artifactReads: engineFeaturesOf(delegate.manifest.engine, {
189
+ computer: false,
190
+ }).artifactsRead,
187
191
  }),
188
192
  // A flow agent used as a tool runs in its own linked session, like a flow's agent
189
193
  // step: the host starts it, and the effect settles when its turn ends.
@@ -204,7 +208,7 @@ export async function runDurable(options) {
204
208
  try {
205
209
  const result = await withDeterministicIds(`${checkpoint.turnId}_${checkpoint.segment}`, () => execute(hosted, {
206
210
  state: withPinned(withLayout(checkpoint.state ??
207
- initializeExecutionState(hosted, { executionId: checkpoint.sessionId }), options.mcp), options.pinned),
211
+ initializeExecutionState(hosted, { executionId: checkpoint.sessionId }), options.mcp), options.pinned, options.refreshPinned === true),
208
212
  input: checkpoint.input,
209
213
  info: checkpoint.info,
210
214
  signal: options.signal,
@@ -244,16 +248,17 @@ function withLayout(state, mcp) {
244
248
  }
245
249
  /**
246
250
  * The state with the text our engine keeps at the head of the conversation: what it pinned
247
- * before, or `pinned` when it has none (the session's first turn, or after a compaction).
251
+ * before, or `pinned` when it has none (the session's first turn, or after a compaction) or
252
+ * `refresh` asks for it again.
248
253
  */
249
- function withPinned(state, pinned) {
254
+ function withPinned(state, pinned, refresh = false) {
250
255
  if (pinned === undefined) {
251
256
  if (state.pinned === undefined)
252
257
  return state;
253
258
  const { pinned: _dropped, ...rest } = state;
254
259
  return rest;
255
260
  }
256
- return state.pinned === undefined ? { ...state, pinned: [...pinned] } : state;
261
+ return state.pinned === undefined || refresh ? { ...state, pinned: [...pinned] } : state;
257
262
  }
258
263
  /**
259
264
  * `memory` (track T5): each command's parameters are checked before the call is sent
@@ -9,11 +9,13 @@ export interface ArtifactToolOptions {
9
9
  /** True when `name` is one of our engine's artifact tools. */
10
10
  export declare function isArtifactTool(name: string | undefined): boolean;
11
11
  /**
12
- * The artifact tools our engine offers an agent: `save_artifact` when the session has a sandbox,
13
- * and `read_artifact`, which takes `path` only then. Each runs here (`harness`).
12
+ * The artifact tools our engine offers an agent that declares nothing (`agent-folder/1`):
13
+ * `save_artifact` when the session has a sandbox, and `read_artifact`, which takes `path` only
14
+ * then. Each runs here (`harness`). One that declares its engine features gets those it names
15
+ * (`engineProjection`).
14
16
  */
15
17
  export declare function artifactToolsFor(sandboxed: boolean, options: ArtifactToolOptions): DurableSessionTool[];
16
- /** What the model reads with the artifact tools, in their order. */
18
+ /** What the model reads with the artifact tools, in their order, for an agent that declares nothing. */
17
19
  export declare function artifactInstructions(sandboxed: boolean): string[];
18
20
  /** What an artifact tool runs with. */
19
21
  export interface ArtifactToolContext extends ArtifactToolOptions {