@zenera/neo 1.1.55 → 1.1.56

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.
@@ -1,11 +1,39 @@
1
1
  import { type MemoryFile } from './types.ts';
2
- /** Where remembered files appear in the agent's namespace. */
3
- export declare const MEMORY_MOUNT = "/memory";
4
2
  /**
5
3
  * Big enough for any script or config worth re-running, small enough that the
6
4
  * memory directory cannot become a place where build outputs go to hide.
7
5
  */
8
6
  export declare const MAX_FILE_BYTES: number;
7
+ /**
8
+ * Where a remembered file's bytes come from, read for memory by whoever owns
9
+ * them — the workspace's own driver, so it does not matter whether the files
10
+ * are on this machine. `path` names it, and its extension decides the copy's.
11
+ */
12
+ export interface FileSource {
13
+ path: string;
14
+ stat(): Promise<{
15
+ size: number;
16
+ isFile(): boolean;
17
+ }>;
18
+ read(): Promise<Uint8Array>;
19
+ }
20
+ /** A file on this machine's disk, as a source. */
21
+ export declare function hostFile(path: string): FileSource;
22
+ /**
23
+ * The agent's workspace, as memory needs it: a file to remember is read from
24
+ * it, and a remembered file is copied back into it. Both are contained and
25
+ * permission-checked exactly as the file tools are. `Workspace` is one.
26
+ */
27
+ export interface WorkspaceFiles {
28
+ source(path: string): FileSource;
29
+ /**
30
+ * Writes bytes and answers with the path the model knows the file by.
31
+ * Refuses to replace an existing file unless told to.
32
+ */
33
+ write(path: string, data: Uint8Array, opts?: {
34
+ overwrite?: boolean;
35
+ }): Promise<string>;
36
+ }
9
37
  export interface RememberOptions {
10
38
  maxBytes?: number;
11
39
  /** Display path as passed to the tool, for reporting errors without leaking the host filesystem */
@@ -18,7 +46,13 @@ export interface RememberOptions {
18
46
  * the digest provably belongs to the copy that was kept — re-reading the source
19
47
  * to hash it would leave a window for it to change in between.
20
48
  */
21
- export declare function rememberFile(dir: string, source: string, id: string, opts?: RememberOptions): Promise<MemoryFile>;
49
+ export declare function rememberFile(dir: string, source: FileSource, id: string, opts?: RememberOptions): Promise<MemoryFile>;
50
+ /**
51
+ * What a remembered file is called: `<id>.<ext>`. The name the model is shown,
52
+ * and where a copy lands by default. Graphs written while the tree was still
53
+ * mounted stored `/memory/<id>.<ext>`; the base name is the same for both.
54
+ */
55
+ export declare function storedName(file: Pick<MemoryFile, 'path'>): string;
22
56
  /** The host path of a remembered file, for reading it back or deleting it. */
23
57
  export declare function hostPath(dir: string, file: Pick<MemoryFile, 'path'>): string;
24
58
  /** Drop the bytes of a forgotten node. Missing is success — the goal is absence. */
@@ -13,12 +13,12 @@ import { MemoryError } from "./types.js";
13
13
  // describes them. The copy is the point: a reference to a workspace path would
14
14
  // dangle the moment the run ends.
15
15
  //
16
- // The tree is mounted read-only at /memory. Nothing writes there through the
17
- // file tools, so every file under it has a node that explains what it is, and
18
- // the graph cannot acquire orphans that no recollection can ever surface.
16
+ // The tree is never mounted into a sandbox. A file leaves it only as a copy,
17
+ // through `memory_copy_file`, and enters it only through a commit, so every
18
+ // file here has a node that explains what it is and the graph cannot acquire
19
+ // orphans that no recollection can ever surface. It also means a sandbox holds
20
+ // nothing that changes under it while it runs.
19
21
  // ---------------------------------------------------------------------------
20
- /** Where remembered files appear in the agent's namespace. */
21
- export const MEMORY_MOUNT = '/memory';
22
22
  /**
23
23
  * Big enough for any script or config worth re-running, small enough that the
24
24
  * memory directory cannot become a place where build outputs go to hide.
@@ -26,6 +26,10 @@ export const MEMORY_MOUNT = '/memory';
26
26
  export const MAX_FILE_BYTES = 2 * 1024 * 1024;
27
27
  /** Extensions are for `run_command` and syntax hints, not a type system. */
28
28
  const MAX_FORMAT_LEN = 16;
29
+ /** A file on this machine's disk, as a source. */
30
+ export function hostFile(path) {
31
+ return { path, stat: () => stat(path), read: () => readFile(path) };
32
+ }
29
33
  /**
30
34
  * Copy `source` into the memory directory under `id` and describe it.
31
35
  *
@@ -35,7 +39,7 @@ const MAX_FORMAT_LEN = 16;
35
39
  */
36
40
  export async function rememberFile(dir, source, id, opts = {}) {
37
41
  const maxBytes = opts.maxBytes ?? MAX_FILE_BYTES;
38
- const name = opts.path ?? source;
42
+ const name = opts.path ?? source.path;
39
43
  const info = await describe(source, name);
40
44
  if (!info.isFile()) {
41
45
  throw new MemoryError(`${name} is not a regular file`, 'only files can be remembered; write a `fact` node describing a directory instead');
@@ -43,33 +47,41 @@ export async function rememberFile(dir, source, id, opts = {}) {
43
47
  if (info.size > maxBytes) {
44
48
  throw new MemoryError(`${name} is ${info.size} bytes, over the ${maxBytes} byte limit for a remembered file`, 'keep the artifact in the workspace and remember a `snippet` of the part that matters');
45
49
  }
46
- const bytes = await readFile(source);
50
+ const bytes = await source.read();
47
51
  if (bytes.byteLength > maxBytes) {
48
52
  throw new MemoryError(`${name} grew past the ${maxBytes} byte limit while being read`);
49
53
  }
50
- const format = formatOf(source);
51
- const fileName = id + (format ? `.${format}` : '');
54
+ const format = formatOf(source.path);
55
+ const stored = id + (format ? `.${format}` : '');
52
56
  await mkdir(join(dir, FILES_DIR), { recursive: true });
53
- await writeFile(join(dir, FILES_DIR, fileName), bytes);
57
+ await writeFile(join(dir, FILES_DIR, stored), bytes);
54
58
  return {
55
- path: `${MEMORY_MOUNT}/${fileName}`,
59
+ path: stored,
56
60
  bytes: bytes.byteLength,
57
61
  sha256: createHash('sha256').update(bytes).digest('hex'),
58
62
  format,
59
63
  };
60
64
  }
65
+ /**
66
+ * What a remembered file is called: `<id>.<ext>`. The name the model is shown,
67
+ * and where a copy lands by default. Graphs written while the tree was still
68
+ * mounted stored `/memory/<id>.<ext>`; the base name is the same for both.
69
+ */
70
+ export function storedName(file) {
71
+ return basename(file.path);
72
+ }
61
73
  /** The host path of a remembered file, for reading it back or deleting it. */
62
74
  export function hostPath(dir, file) {
63
75
  // Through `basename` so a stored path can never climb out of the tree.
64
- return join(dir, FILES_DIR, basename(file.path));
76
+ return join(dir, FILES_DIR, storedName(file));
65
77
  }
66
78
  /** Drop the bytes of a forgotten node. Missing is success — the goal is absence. */
67
79
  export async function forgetFile(dir, file) {
68
80
  await rm(hostPath(dir, file), { force: true });
69
81
  }
70
- async function describe(source, name = source) {
82
+ async function describe(source, name) {
71
83
  try {
72
- return await stat(source);
84
+ return await source.stat();
73
85
  }
74
86
  catch {
75
87
  throw new MemoryError(`${name} does not exist`, 'remember a file the run actually wrote, by the path the file tools use');
@@ -18,8 +18,8 @@ import { MemoryError } from "./types.js";
18
18
  // the bytes of a remembered file are the thing itself. An exact match belongs
19
19
  // against all three.
20
20
  //
21
- // Two rules keep this honest against raw `grep` over /memory, which is what it
22
- // exists to replace. Superseded nodes are excluded unless asked for, and come
21
+ // Two rules keep this honest against a raw `grep` over the memory directory,
22
+ // which is what it exists to replace. Superseded nodes are excluded unless asked for, and come
23
23
  // back flagged when they are — serving a withdrawn correction as current is
24
24
  // the failure mode the mount is warned about. And reading here is not use:
25
25
  // recency decay is meant to track what an agent actually opened, and a finder
@@ -1,8 +1,9 @@
1
1
  import type { Embedder } from '../embedding.ts';
2
2
  import type { IdClock } from '../ids.ts';
3
+ import { type FileSource } from './files.ts';
3
4
  import { type MemoryGraph } from './graph.ts';
4
5
  import type { MemoryStore } from './store.ts';
5
- import { type MemoryNode, type MemoryQuery, type Recollection } from './types.ts';
6
+ import { type MemoryFile, type MemoryNode, type MemoryQuery, type Recollection } from './types.ts';
6
7
  /** Past this a `load` returns the path and lets the agent open it itself. */
7
8
  export declare const INLINE_FILE_BYTES: number;
8
9
  /**
@@ -28,9 +29,9 @@ export interface CommitNode {
28
29
  text?: string;
29
30
  audience?: string[];
30
31
  metadata?: Record<string, unknown>;
31
- /** absolute host path of a file to copy in, already resolved by the caller */
32
+ /** the file to copy in, already resolved and contained by the caller */
32
33
  file?: {
33
- source: string;
34
+ source: FileSource;
34
35
  path?: string;
35
36
  };
36
37
  expectedRevision?: number;
@@ -98,6 +99,16 @@ export declare class MemoryIndex {
98
99
  * an agent actually read, and a search hands back context it never opened.
99
100
  */
100
101
  load(ids: readonly string[], sees: readonly string[], clock: IdClock): Promise<LoadedNode[]>;
102
+ /**
103
+ * A remembered file's record and bytes, for copying it back into a
104
+ * workspace. Visible nodes only, and missing reads the same as hidden.
105
+ * Not a load: copying a file is not reading the memory, so recency is
106
+ * left alone.
107
+ */
108
+ fileOf(id: string, sees: readonly string[]): Promise<{
109
+ file: MemoryFile;
110
+ bytes: Buffer;
111
+ }>;
101
112
  commit(tx: MemoryTransaction, opts: CommitOptions): Promise<CommitResult>;
102
113
  forget(ids: readonly string[], sees: readonly string[]): Promise<MemoryNode[]>;
103
114
  }
@@ -127,6 +127,23 @@ export class MemoryIndex {
127
127
  }
128
128
  return out;
129
129
  }
130
+ /**
131
+ * A remembered file's record and bytes, for copying it back into a
132
+ * workspace. Visible nodes only, and missing reads the same as hidden.
133
+ * Not a load: copying a file is not reading the memory, so recency is
134
+ * left alone.
135
+ */
136
+ async fileOf(id, sees) {
137
+ this.refresh();
138
+ const node = this.graph.get(id);
139
+ if (!node || !visible(node, sees)) {
140
+ throw new MemoryError(`no memory ${id}`, 'use an id from the legend of a memory_search result');
141
+ }
142
+ if (!node.file) {
143
+ throw new MemoryError(`${id} holds no file`, 'only nodes committed with a `file` have one to copy');
144
+ }
145
+ return { file: node.file, bytes: await readFile(hostPath(this.store.dir, node.file)) };
146
+ }
130
147
  async commit(tx, opts) {
131
148
  const nodes = tx.nodes ?? [];
132
149
  const edges = tx.edges ?? [];
@@ -1,3 +1,4 @@
1
+ import { storedName } from "./files.js";
1
2
  import { SPINE_RELATIONS, } from "./types.js";
2
3
  // ---------------------------------------------------------------------------
3
4
  // What the model actually reads
@@ -176,7 +177,7 @@ function block(entry, opts) {
176
177
  const indent = ' '.repeat(Math.max(TEXT_COLUMN, (entry.depth + 2) * STEP));
177
178
  const lines = [`${' '.repeat(entry.depth * STEP)}${header(entry)}`];
178
179
  if (node.file) {
179
- const facts = [node.file.path, bytes(node.file.bytes), used(node, now)];
180
+ const facts = [storedName(node.file), bytes(node.file.bytes), used(node, now)];
180
181
  lines.push(`${indent}${facts.join(' · ')}`);
181
182
  }
182
183
  const summary = clipped(node.text, opts.clip ?? TEXT_CLIP);
@@ -1,5 +1,5 @@
1
1
  /**
2
- * The five tools an agent gets. `search` and `load` are split because finding
2
+ * The six tools an agent gets. `search` and `load` are split because finding
3
3
  * is not reading — search returns stitched context the model never asked for,
4
4
  * and counting that as use would poison recency. `grep` is separate from
5
5
  * `search` because exactness is not a tuning of nearness: a ranking returns the
@@ -8,14 +8,16 @@
8
8
  * building it with three calls leaves the graph half-formed if the model stops
9
9
  * early. `forget` is separate because deleting rarely happens in the same
10
10
  * breath as creating, and a `forget` buried inside a truncated commit preview
11
- * would be both irreversible and invisible.
11
+ * would be both irreversible and invisible. `copy_file` is the only way a
12
+ * remembered file reaches the sandbox, which never mounts the memory.
12
13
  *
13
14
  * `audience` reaches the schema only when the binding grants more than one
14
15
  * label, and `sees` never does: an agent that could name its own audience
15
16
  * could read another agent's slice just by asking for it.
16
17
  */
17
18
  import { hash } from "../payload.js";
18
- import { MEMORY_COMMIT_TOOL, MEMORY_FORGET_TOOL, MEMORY_GREP_TOOL, MEMORY_LOAD_TOOL, MEMORY_SEARCH_TOOL, tool, withEffects, } from "../types.js";
19
+ import { MEMORY_COMMIT_TOOL, MEMORY_COPY_FILE_TOOL, MEMORY_FORGET_TOOL, MEMORY_GREP_TOOL, MEMORY_LOAD_TOOL, MEMORY_SEARCH_TOOL, tool, withEffects, } from "../types.js";
20
+ import { storedName } from "./files.js";
19
21
  import { RevisionMismatch } from "./graph.js";
20
22
  import { GREP_FIELDS, grepMemory } from "./grep.js";
21
23
  import { renderRecollection } from "./render.js";
@@ -97,7 +99,7 @@ export function memoryTools(opts) {
97
99
  name: MEMORY_LOAD_TOOL,
98
100
  description: 'Read memories in full by id, using the ids from a ' +
99
101
  `${MEMORY_SEARCH_TOOL} legend. A remembered file comes back inline when it ` +
100
- 'is small, otherwise as a path under /memory you can open or run.',
102
+ `is small; to open or run it, copy it into the workspace with ${MEMORY_COPY_FILE_TOOL}.`,
101
103
  parameters: {
102
104
  type: 'object',
103
105
  properties: {
@@ -131,7 +133,7 @@ export function memoryTools(opts) {
131
133
  revision: l.node.revision,
132
134
  metadata: l.node.metadata,
133
135
  file: l.node.file
134
- ? { path: l.node.file.path, bytes: l.node.file.bytes }
136
+ ? { name: storedName(l.node.file), bytes: l.node.file.bytes }
135
137
  : undefined,
136
138
  content: l.content,
137
139
  })), { kind: 'memory_op', spec });
@@ -144,7 +146,7 @@ export function memoryTools(opts) {
144
146
  `instead of ${MEMORY_SEARCH_TOOL} when the answer has to be complete rather ` +
145
147
  'than close — whether something was already recorded, or where a name, path, ' +
146
148
  'id or command appears. This is the only correct way to search the memory ' +
147
- 'directly; never run a shell grep over /memory. Read a whole node with ' +
149
+ 'directly. Read a whole node with ' +
148
150
  `${MEMORY_LOAD_TOOL}.`,
149
151
  parameters: {
150
152
  type: 'object',
@@ -218,7 +220,7 @@ export function memoryTools(opts) {
218
220
  id: m.node.id,
219
221
  kind: m.node.kind,
220
222
  stale: m.stale || undefined,
221
- file: m.node.file?.path,
223
+ file: m.node.file && storedName(m.node.file),
222
224
  hits: m.hits.map((h) => ({ in: h.where, line: h.line, text: h.text })),
223
225
  more: m.more || undefined,
224
226
  })),
@@ -228,6 +230,57 @@ export function memoryTools(opts) {
228
230
  }, { kind: 'memory_op', spec });
229
231
  },
230
232
  }),
233
+ // The one way a remembered file reaches the sandbox. Memory is never
234
+ // mounted, so the box only ever holds the workspace and the project's
235
+ // read-only trees, and the files stay with the graph that explains them.
236
+ // Reading memory is enough to copy from it: the write is the workspace's.
237
+ tool({
238
+ name: MEMORY_COPY_FILE_TOOL,
239
+ description: 'Copies a remembered file into the workspace so a command can open or run it. ' +
240
+ `Give the id of a node that holds a file, from ${MEMORY_SEARCH_TOOL} or ` +
241
+ `${MEMORY_LOAD_TOOL}. The copy is yours to edit; remembering the edited ` +
242
+ `version is a new ${MEMORY_COMMIT_TOOL}.`,
243
+ parameters: {
244
+ type: 'object',
245
+ properties: {
246
+ id: { type: 'string', description: 'the node that holds the file' },
247
+ to: {
248
+ type: 'string',
249
+ description: 'where in the workspace to put it; the file’s own name ' +
250
+ '(<id>.<ext>) at the workspace root when omitted',
251
+ },
252
+ overwrite: {
253
+ type: 'boolean',
254
+ description: 'replace a file already at that path',
255
+ },
256
+ },
257
+ required: ['id'],
258
+ additionalProperties: false,
259
+ },
260
+ execute: async (args, tc) => {
261
+ if (!tc.services.files) {
262
+ return {
263
+ error: 'this agent has no workspace to copy into',
264
+ hint: `read the file inline with ${MEMORY_LOAD_TOOL} instead`,
265
+ };
266
+ }
267
+ try {
268
+ const { file, bytes } = await index.fileOf(args.id, binding.sees);
269
+ const path = await tc.services.files.write(args.to?.trim() || storedName(file), bytes, {
270
+ overwrite: args.overwrite,
271
+ });
272
+ return { id: args.id, path, bytes: bytes.byteLength, copied: true };
273
+ }
274
+ catch (err) {
275
+ if (err instanceof MemoryError) {
276
+ return refusal(err);
277
+ }
278
+ // The workspace's refusals — read-only, outside, already there —
279
+ // are things the model can fix by choosing another `to`.
280
+ return { error: err instanceof Error ? err.message : String(err) };
281
+ }
282
+ },
283
+ }),
231
284
  ];
232
285
  if (!canWrite(binding)) {
233
286
  return tools;
@@ -469,11 +522,11 @@ function extractFilePath(raw) {
469
522
  return '';
470
523
  }
471
524
  function source(tc, path) {
472
- if (!tc.services.resolveFile) {
525
+ if (!tc.services.files) {
473
526
  throw new MemoryError('this agent cannot remember files', 'commit the node without `file`, or give the agent a workspace');
474
527
  }
475
528
  try {
476
- return tc.services.resolveFile(path);
529
+ return tc.services.files.source(path);
477
530
  }
478
531
  catch (err) {
479
532
  if (err instanceof MemoryError) {
@@ -47,7 +47,7 @@ export declare class MemoryError extends Error {
47
47
  constructor(message: string, hint?: string);
48
48
  }
49
49
  export interface MemoryFile {
50
- /** what the agent sees, e.g. `/memory/01J8….py` — a mount path, not a host path */
50
+ /** `<id>.<ext>`; older graphs hold `/memory/<id>.<ext>` — read it through `storedName` */
51
51
  path: string;
52
52
  bytes: number;
53
53
  sha256: string;
@@ -46,7 +46,7 @@ export const KIND_HELP = {
46
46
  plan: 'an approach that worked, worth reusing on a similar request',
47
47
  fact: 'a durable truth about the environment or the domain',
48
48
  snippet: 'a short piece of code or configuration, too small to be a file',
49
- file: 'an artifact kept whole under /memory and re-runnable',
49
+ file: 'an artifact kept whole, to copy back into the workspace and run again',
50
50
  operation: 'an external call that was made — an endpoint, command or query',
51
51
  preference: 'a standing instruction from the user that applies to every run',
52
52
  };
@@ -348,30 +348,7 @@ export declare const projectSchema: z.ZodObject<{
348
348
  limit: z.ZodDefault<z.ZodInt>;
349
349
  }, z.core.$strict>]>>;
350
350
  }, z.core.$strict>>, unknown>>;
351
- sandbox: z.ZodOptional<z.ZodObject<{
352
- image: z.ZodOptional<z.ZodString>;
353
- build: z.ZodOptional<z.ZodObject<{
354
- dockerfile: z.ZodString;
355
- context: z.ZodOptional<z.ZodString>;
356
- }, z.core.$strict>>;
357
- cpus: z.ZodOptional<z.ZodNumber>;
358
- memory: z.ZodOptional<z.ZodInt>;
359
- network: z.ZodOptional<z.ZodEnum<{
360
- none: "none";
361
- host: "host";
362
- bridge: "bridge";
363
- }>>;
364
- workdir: z.ZodOptional<z.ZodString>;
365
- timeout: z.ZodOptional<z.ZodInt>;
366
- hardening: z.ZodOptional<z.ZodEnum<{
367
- strict: "strict";
368
- standard: "standard";
369
- }>>;
370
- user: z.ZodOptional<z.ZodString>;
371
- persist: z.ZodOptional<z.ZodBoolean>;
372
- env: z.ZodOptional<z.ZodArray<z.ZodString>>;
373
- keys: z.ZodOptional<z.ZodBoolean>;
374
- }, z.core.$strict>>;
351
+ sandbox: z.ZodOptional<z.ZodNever>;
375
352
  default: z.ZodOptional<z.ZodBoolean>;
376
353
  }, z.core.$strict>>;
377
354
  }, z.core.$strict>;
@@ -360,11 +360,16 @@ const agent = z
360
360
  .preprocess((v) => (typeof v === 'boolean' ? (v ? {} : undefined) : v), memoryBinding.optional())
361
361
  .optional(),
362
362
  /**
363
- * Overrides on the project's sandbox. An agent that overrides nothing
364
- * shares the container with everyone else, which is what a hand-off
365
- * usually wants; an agent that names its own image gets its own.
363
+ * Gone: a session has one sandbox, the project's, shared by every
364
+ * agent. Refused rather than ignored, so a project that relied on it
365
+ * hears where its settings have to go instead.
366
366
  */
367
- sandbox: sandbox.optional(),
367
+ sandbox: z
368
+ .never({
369
+ error: 'per-agent sandboxes were removed — a session has one sandbox, shared by ' +
370
+ "every agent; move these settings to the project's top-level `sandbox:`",
371
+ })
372
+ .optional(),
368
373
  /** entrypoint, when no top-level `default` is given */
369
374
  default: z.boolean().optional(),
370
375
  })
@@ -1,6 +1,7 @@
1
1
  import { Agent, AgentRegistry } from '../agent.ts';
2
2
  import type { Embedder } from '../embedding.ts';
3
3
  import { RunStream } from '../events.ts';
4
+ import type { WorkspaceFiles } from '../memory/files.ts';
4
5
  import { MemoryIndex } from '../memory/index.ts';
5
6
  import { ModelRegistry, type EmbeddingRef, type ModelRef, type ProviderSpec } from '../models/factory.ts';
6
7
  import type { PayloadStore } from '../payload.ts';
@@ -65,9 +66,7 @@ export interface ProjectOptions<TCtx = unknown> {
65
66
  memory?: MemoryIndex;
66
67
  /**
67
68
  * Another directory to keep the memory graph in, relative to the project
68
- * root when it is not absolute. Whoever sets it must mount that directory
69
- * as `/memory` too, or the agent reads its remembered files from one graph
70
- * and writes to another.
69
+ * root when it is not absolute.
71
70
  */
72
71
  memoryDir?: string;
73
72
  /**
@@ -77,8 +76,8 @@ export interface ProjectOptions<TCtx = unknown> {
77
76
  * warmed memory at once, which the directory lock otherwise forbids.
78
77
  */
79
78
  memoryReadOnly?: boolean;
80
- /** turns an agent-visible path into a host path, so files can be remembered */
81
- resolveFile?: (path: string) => string;
79
+ /** the agent's workspace, so files can be remembered and copied back */
80
+ files?: WorkspaceFiles;
82
81
  payloads?: PayloadStore;
83
82
  /** extra providers merged with the ones the project declares */
84
83
  skills?: SkillProvider[];
@@ -184,9 +183,8 @@ export declare class AgentProject<TCtx = unknown> {
184
183
  export declare function projectRegistry<TCtx>(config: ProjectConfig, opts?: ProjectOptions<TCtx>): ModelRegistry;
185
184
  /**
186
185
  * Where this project's memory lives, or `undefined` when it has none. Shared
187
- * with the front end, which has to mount the same directory into the sandbox:
188
- * two answers to this question would mean `/memory` pointing somewhere the
189
- * graph is not.
186
+ * with the front end, which reports and exports the same directory: two
187
+ * answers to this question would mean two graphs.
190
188
  *
191
189
  * `override` is the host pointing the run at another graph — `zen run
192
190
  * --memory`. It answers for a project that declares no memory at all, because
@@ -173,7 +173,7 @@ export class AgentProject {
173
173
  const runner = new AgentRunner({
174
174
  payloads: this.#options.payloads,
175
175
  memory: this.memory,
176
- resolveFile: this.#options.resolveFile,
176
+ files: this.#options.files,
177
177
  skills: [...this.skillProviders],
178
178
  ...overrides,
179
179
  });
@@ -530,9 +530,8 @@ function memoryFor(spec) {
530
530
  }
531
531
  /**
532
532
  * Where this project's memory lives, or `undefined` when it has none. Shared
533
- * with the front end, which has to mount the same directory into the sandbox:
534
- * two answers to this question would mean `/memory` pointing somewhere the
535
- * graph is not.
533
+ * with the front end, which reports and exports the same directory: two
534
+ * answers to this question would mean two graphs.
536
535
  *
537
536
  * `override` is the host pointing the run at another graph — `zen run
538
537
  * --memory`. It answers for a project that declares no memory at all, because
package/dist/runner.d.ts CHANGED
@@ -3,6 +3,7 @@ import { Agent, AgentRegistry, type AgentOptions } from './agent.ts';
3
3
  import { type Architecture } from './architecture.ts';
4
4
  import { RunStream } from './events.ts';
5
5
  import { type IdClock } from './ids.ts';
6
+ import type { WorkspaceFiles } from './memory/files.ts';
6
7
  import type { MemoryIndex } from './memory/index.ts';
7
8
  import type { Model } from './model.ts';
8
9
  import { PayloadResolver, type PayloadStore } from './payload.ts';
@@ -42,8 +43,8 @@ export interface RunnerOptions<TCtx = unknown> {
42
43
  services?: Services;
43
44
  payloads?: PayloadStore | PayloadResolver;
44
45
  memory?: MemoryIndex;
45
- /** turns an agent-visible path into a host path, so files can be remembered */
46
- resolveFile?: (path: string) => string;
46
+ /** the agent's workspace, so files can be remembered and copied back */
47
+ files?: WorkspaceFiles;
47
48
  skills?: SkillProvider[];
48
49
  handoffPolicy?: HandoffPolicy;
49
50
  /** renders the nodes a policy selected; defaults to a structural note */
package/dist/runner.js CHANGED
@@ -84,7 +84,7 @@ export class AgentRunner {
84
84
  new Services({
85
85
  payloads: opts.payloads,
86
86
  memory: opts.memory,
87
- resolveFile: opts.resolveFile,
87
+ files: opts.files,
88
88
  skills: opts.skills,
89
89
  clock: this.#clock,
90
90
  });
@@ -1,5 +1,6 @@
1
1
  import { PayloadResolver, type PayloadStore } from './payload.ts';
2
2
  import { type IdClock } from './ids.ts';
3
+ import type { WorkspaceFiles } from './memory/files.ts';
3
4
  import type { MemoryIndex } from './memory/index.ts';
4
5
  import type { SkillProvider } from './skills.ts';
5
6
  /**
@@ -18,12 +19,13 @@ export declare class Services {
18
19
  /** the one memory graph, when the project has one */
19
20
  readonly memory?: MemoryIndex;
20
21
  /**
21
- * Turns a path the agent can see into a host path, for the one tool that
22
- * needs it: remembering a file. Supplied by whoever built the workspace,
23
- * because only it knows the mounts. Without it, files cannot be
24
- * remembered — which is a refusal, not a crash.
22
+ * The agent's workspace, for the two memory tools that cross into it:
23
+ * remembering a file reads from it, and copying a remembered file back
24
+ * writes to it — memory is never mounted, so that copy is the only way its
25
+ * files reach the sandbox. Supplied by whoever built the workspace, because
26
+ * only it knows the mounts. Without it both are refusals, not crashes.
25
27
  */
26
- readonly resolveFile?: (path: string) => string;
28
+ readonly files?: WorkspaceFiles;
27
29
  /** the driver's clock, so a tool that stamps a node stays replayable */
28
30
  readonly clock: IdClock;
29
31
  constructor(opts?: {
@@ -31,7 +33,7 @@ export declare class Services {
31
33
  memory?: MemoryIndex;
32
34
  skills?: SkillProvider[];
33
35
  clock?: IdClock;
34
- resolveFile?: (path: string) => string;
36
+ files?: WorkspaceFiles;
35
37
  });
36
38
  skillProvider(id: string): SkillProvider;
37
39
  hasMemory(): boolean;
package/dist/services.js CHANGED
@@ -18,12 +18,13 @@ export class Services {
18
18
  /** the one memory graph, when the project has one */
19
19
  memory;
20
20
  /**
21
- * Turns a path the agent can see into a host path, for the one tool that
22
- * needs it: remembering a file. Supplied by whoever built the workspace,
23
- * because only it knows the mounts. Without it, files cannot be
24
- * remembered — which is a refusal, not a crash.
21
+ * The agent's workspace, for the two memory tools that cross into it:
22
+ * remembering a file reads from it, and copying a remembered file back
23
+ * writes to it — memory is never mounted, so that copy is the only way its
24
+ * files reach the sandbox. Supplied by whoever built the workspace, because
25
+ * only it knows the mounts. Without it both are refusals, not crashes.
25
26
  */
26
- resolveFile;
27
+ files;
27
28
  /** the driver's clock, so a tool that stamps a node stays replayable */
28
29
  clock;
29
30
  #skills = new Map();
@@ -31,7 +32,7 @@ export class Services {
31
32
  const p = opts.payloads ?? new InMemoryPayloadStore();
32
33
  this.payloads = p instanceof PayloadResolver ? p : new PayloadResolver(p);
33
34
  this.memory = opts.memory;
34
- this.resolveFile = opts.resolveFile;
35
+ this.files = opts.files;
35
36
  this.clock = opts.clock ?? systemClock;
36
37
  for (const s of opts.skills ?? []) {
37
38
  this.#skills.set(s.id, s);