@stratusagent/plugins 0.11.3 → 0.11.5

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,5 +1,5 @@
1
1
  import { constants } from 'node:fs';
2
- import { lstat, mkdir, open, readdir, readFile, realpath, stat } from 'node:fs/promises';
2
+ import { lstat, mkdir, open, readFile, realpath, stat } from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
  import { isTrustLevel, leastTrusted } from '@stratusagent/core';
5
5
  /** The ledger's filename inside an agent's workspace. Exported so `fs.write` can refuse to write it. */
@@ -130,12 +130,27 @@ export const ledgerTrustOfContent = (raw) => {
130
130
  };
131
131
  /**
132
132
  * The durable ledger, one append-only JSONL file per agent at
133
- * `<workspaceRoot>/<agentId>/fs-provenance.jsonl`, owner-only. Each record
134
- * is one `O_APPEND` write, so processes that share an agent — the daemon and
135
- * a `stratus run` — interleave records rather than overwrite each other.
133
+ * `<the agent's workspace>/fs-provenance.jsonl`, owner-only. Each record is
134
+ * one `O_APPEND` write, so processes that share an agent — the daemon and a
135
+ * `stratus run` — interleave records rather than overwrite each other.
136
+ *
137
+ * Takes resolvers rather than a root, because where an agent's workspace
138
+ * is is the host's to say: this package depends on `core` and `agents` only
139
+ * and cannot see the `~/.stratus` layout, which is exactly why it must not
140
+ * spell a depth. See `workspaceResolver`.
141
+ *
142
+ * Two of them, and the split is the point. Reading a ledger only needs the
143
+ * *name* of a file that may not exist — every `fs.read`, `fs.list` and
144
+ * `fs.search` takes a snapshot before it does anything — while recording a
145
+ * write needs the directory to be there and owner-only. Asking the
146
+ * preparing one on a read would let a workspace that cannot be made stop
147
+ * reads whose own roots are perfectly readable, and which could not have
148
+ * had a ledger at the blocked path anyway. `prepareFor` defaults to
149
+ * `workspaceFor` for a host that wires this by hand with one resolver.
136
150
  */
137
- export const createFileLedger = (workspaceRoot) => {
138
- const ledgerPath = (agentId) => path.join(workspaceRoot, agentId, LEDGER_FILENAME);
151
+ export const createFileLedger = (workspaceFor, prepareFor = workspaceFor) => {
152
+ const ledgerPath = (agentId) => path.join(workspaceFor(agentId), LEDGER_FILENAME);
153
+ const ledgerPathForWrite = (agentId) => path.join(prepareFor(agentId), LEDGER_FILENAME);
139
154
  const read = async (agentId) => {
140
155
  const filePath = ledgerPath(agentId);
141
156
  try {
@@ -165,7 +180,7 @@ export const createFileLedger = (workspaceRoot) => {
165
180
  // A clean write records nothing — see `TaintedWriteLedger`.
166
181
  return;
167
182
  }
168
- const filePath = ledgerPath(agentId);
183
+ const filePath = ledgerPathForWrite(agentId);
169
184
  await mkdir(path.dirname(filePath), { recursive: true, mode: 0o700 });
170
185
  // Read and appended through ONE descriptor. A ledger reached through
171
186
  // a link (a relocated workspace, a relocated file — both supported)
@@ -203,38 +218,98 @@ export const createFileLedger = (workspaceRoot) => {
203
218
  };
204
219
  /**
205
220
  * Whether `absolutePath` is an agent's ledger — exactly
206
- * `<workspaceRoot>/<agentId>/fs-provenance.json`, any agent's — which is the
207
- * one path `fs.write` refuses. Exactly that depth, not any descendant with
208
- * the name: a project an agent keeps under its workspace may legitimately
209
- * have a file called `fs-provenance.json` of its own.
221
+ * `<workspace>/fs-provenance.jsonl`, for any of the workspaces given —
222
+ * which is the one path `fs.write` refuses. Exactly that depth, not any
223
+ * descendant with the name: a project an agent keeps under its workspace
224
+ * may legitimately have a file called `fs-provenance.jsonl` of its own.
210
225
  *
211
- * `workspaceRoots` are every spelling of the workspace root worth checking
212
- * — the configured path and its canonical form — because the path being
213
- * judged arrives canonical from the root resolver, and a workspace an
226
+ * `workspaces` are the directories themselves, and every spelling worth
227
+ * checking — each configured path and its canonical form — because the path
228
+ * being judged arrives canonical from the root resolver, and a workspace an
214
229
  * operator moved behind a symlink would otherwise compare as outside.
230
+ *
231
+ * Directories, not a root to join an id onto: the depth from any root to an
232
+ * agent's workspace is the host's business, and this package cannot see it.
233
+ * When that depth lived here it was `<root>/<agent>/`, and the move to
234
+ * `agents/<id>/workspace/` would have left this guard silently matching
235
+ * nothing — the one failure mode it exists to prevent.
215
236
  */
216
- export const isLedgerPath = (workspaceRoots, absolutePath) => workspaceRoots.some((workspaceRoot) => {
217
- const relative = path.relative(workspaceRoot, absolutePath);
237
+ export const isLedgerPath = (workspaces, absolutePath) => workspaces.some((workspace) => {
238
+ const relative = path.relative(workspace, absolutePath);
218
239
  if (relative.length === 0 || relative.startsWith('..') || path.isAbsolute(relative)) {
219
240
  return false;
220
241
  }
221
242
  const segments = relative.split(path.sep);
222
- return segments.length === 2 && segments[1] === LEDGER_FILENAME;
243
+ return segments.length === 1 && segments[0] === LEDGER_FILENAME;
223
244
  });
224
245
  const identityKey = (identity) => `${identity.dev}:${identity.ino}`;
225
- export const ledgerGuard = async (workspaceRoot) => {
226
- if (workspaceRoot === undefined) {
246
+ /**
247
+ * Roots whose immediate children are workspaces, judged lexically.
248
+ *
249
+ * This is the `workspaceRoot` contract and nothing else: one directory per
250
+ * agent directly under the root. It is kept because a workspace that does
251
+ * not exist *yet* still has a reserved ledger path, and enumerating what is
252
+ * on disk cannot name it — so an agent's very first `fs.write` could create
253
+ * or clobber `<root>/<id>/fs-provenance.jsonl` before any tainted write had
254
+ * made the directory.
255
+ *
256
+ * The host's own layout gets no such rule, deliberately. There the
257
+ * workspace sits inside `agents/<id>/`, so a root wide enough to reach an
258
+ * agent that has no directory yet already reaches every other agent's
259
+ * `whitelist.json` and `sessions.db` — there is nothing left for this to
260
+ * save. Under a configured root, which holds workspaces and nothing else,
261
+ * the reason the rule existed still holds.
262
+ */
263
+ const isLedgerUnderRoot = (roots, absolutePath) => roots.some((root) => {
264
+ const relative = path.relative(root, absolutePath);
265
+ if (path.isAbsolute(relative) || relative === '..' || relative.startsWith(`..${path.sep}`)) {
266
+ return false;
267
+ }
268
+ const segments = relative.split(path.sep);
269
+ return segments.length === 2 && segments[1] === LEDGER_FILENAME;
270
+ });
271
+ /**
272
+ * Whether a canonicalization failure is one that *answers*: nothing is at
273
+ * that path, or it leads nowhere at all.
274
+ *
275
+ * Every other failure is this guard deciding a question by not being able
276
+ * to ask it, and in the direction that destroys something. `EIO`, `EACCES`
277
+ * or `EMFILE` on one workspace drops that agent's ledger out of the set
278
+ * below, and the set is the whole of what the guard refuses — so a write
279
+ * aimed at `fs-provenance.jsonl` would pass and truncate the file this
280
+ * exists to protect. The caller is a single tool call: propagating costs
281
+ * that call, which is the cheaper of the two answers by a long way.
282
+ */
283
+ const holdsNoLedger = (error) => {
284
+ const code = error.code;
285
+ return code === 'ENOENT' || code === 'ENOTDIR' || code === 'ELOOP';
286
+ };
287
+ export const ledgerGuard = async (workspaces, roots = []) => {
288
+ if (workspaces.length === 0 && roots.length === 0) {
227
289
  return async () => false;
228
290
  }
229
- const roots = [workspaceRoot];
230
- try {
231
- const canonical = await realpath(workspaceRoot);
232
- if (canonical !== workspaceRoot) {
233
- roots.push(canonical);
291
+ // Every spelling of every agent's workspace: the path the host gave and
292
+ // its canonical form, because the path being judged arrives canonical
293
+ // from the root resolver and a workspace behind a link would otherwise
294
+ // compare as outside.
295
+ const spellings = [];
296
+ // Both spellings of each root too, for the same reason the workspaces
297
+ // have both: the path being judged arrives canonical from the resolver.
298
+ const rootSpellings = [];
299
+ for (const root of roots) {
300
+ rootSpellings.push(root);
301
+ try {
302
+ const canonical = await realpath(root);
303
+ if (canonical !== root) {
304
+ rootSpellings.push(canonical);
305
+ }
306
+ }
307
+ catch (error) {
308
+ if (!holdsNoLedger(error)) {
309
+ throw error;
310
+ }
311
+ // Not there yet: only the spelling the operator gave.
234
312
  }
235
- }
236
- catch {
237
- // Not there yet: only the configured spelling, and no agents to list.
238
313
  }
239
314
  const ledgers = new Set();
240
315
  // And the files themselves, by identity: a hard link to a ledger from
@@ -242,39 +317,41 @@ export const ledgerGuard = async (workspaceRoot) => {
242
317
  // alone, and is the same bytes. Plain numbers, like the resolver's
243
318
  // `identity`, so the two sides of a comparison round the same way.
244
319
  const identities = new Set();
245
- let entries = [];
246
- try {
247
- entries = await readdir(workspaceRoot, { withFileTypes: true });
248
- }
249
- catch {
250
- entries = [];
251
- }
252
- for (const entry of entries) {
253
- if (!entry.isDirectory() && !entry.isSymbolicLink()) {
254
- continue;
255
- }
256
- const lexical = path.join(workspaceRoot, entry.name, LEDGER_FILENAME);
257
- // Two canonical spellings, because either component can be a link: the
258
- // agent directory (`ava -> /data/ava`, judged even before the ledger
259
- // exists there) and the ledger file itself (`fs-provenance.jsonl ->
260
- // /data/ava-ledger.jsonl`, whose target is what the resolver returns
261
- // and what a truncating write would empty).
320
+ for (const workspace of workspaces) {
321
+ spellings.push(workspace);
322
+ // Two canonical spellings, because either the workspace directory or
323
+ // the ledger file can be a link: the directory (`ava/workspace ->
324
+ // /data/ava`, judged even before the ledger exists there) and the file
325
+ // itself (`fs-provenance.jsonl -> /data/ava-ledger.jsonl`, whose target
326
+ // is what the resolver returns and what a truncating write would
327
+ // empty).
262
328
  try {
263
- ledgers.add(path.join(await realpath(path.dirname(lexical)), LEDGER_FILENAME));
329
+ const canonical = await realpath(workspace);
330
+ if (canonical !== workspace) {
331
+ spellings.push(canonical);
332
+ }
333
+ ledgers.add(path.join(canonical, LEDGER_FILENAME));
264
334
  }
265
- catch {
266
- // A dangling link holds no ledger.
335
+ catch (error) {
336
+ if (!holdsNoLedger(error)) {
337
+ throw error;
338
+ }
339
+ // Not there yet, or a dangling link: holds no ledger.
267
340
  }
341
+ const lexical = path.join(workspace, LEDGER_FILENAME);
268
342
  try {
269
343
  ledgers.add(await realpath(lexical));
270
344
  identities.add(identityKey(await stat(lexical)));
271
345
  }
272
- catch {
346
+ catch (error) {
347
+ if (!holdsNoLedger(error)) {
348
+ throw error;
349
+ }
273
350
  // No ledger there yet, or a dangling link: nothing to protect.
274
351
  }
275
352
  }
276
353
  return async (absolutePath, identity) => {
277
- if (isLedgerPath(roots, absolutePath) || ledgers.has(absolutePath)) {
354
+ if (isLedgerPath(spellings, absolutePath) || isLedgerUnderRoot(rootSpellings, absolutePath) || ledgers.has(absolutePath)) {
278
355
  return true;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 @@
1
+ import type { AgentWorkspaces } from '@stratusagent/core';
2
+ /**
3
+ * How a plugin finds an agent's workspace, from whichever of the two the
4
+ * host gave it.
5
+ *
6
+ * One implementation because there used to be five. Every plugin that
7
+ * writes a file was handed a `workspaceRoot` and appended the agent id to
8
+ * it, so each of them held a copy of the layout — and all five had to
9
+ * change when the workspace moved into the agent's own state directory,
10
+ * which is the cost that key was introduced to avoid and did not.
11
+ *
12
+ * An explicitly configured `workspaceRoot` wins, and the order matters:
13
+ * the loader no longer fills that key with the host's answer — the seam
14
+ * *is* the host's answer — so a value there is one an operator wrote, and
15
+ * relocating a workspace by writing it down is a thing they are documented
16
+ * to be able to do. Under it the old contract still holds: one directory
17
+ * per agent directly under the configured root, which is also what a host
18
+ * wiring a plugin by hand with no layout of its own supplies.
19
+ *
20
+ * Undefined means this host gave the plugin nowhere to write. A caller
21
+ * that needs a path must fail the call naming what is missing rather than
22
+ * choosing a directory of its own.
23
+ */
24
+ export declare const workspaceResolver: (workspaces: AgentWorkspaces | undefined, workspaceRoot: string | undefined) => ((agentId: string) => string) | undefined;
25
+ /**
26
+ * The same, for a caller that is about to write: the host creates the
27
+ * directory and settles its permissions before answering.
28
+ *
29
+ * Asked only by the call that needs the directory, never by one that only
30
+ * needs the name. Resolving is free; preparing is not, and it can fail —
31
+ * `agents/<id>/workspace` may be unmakeable — so a `browser.goto`, a
32
+ * `fs.read`'s ledger lookup, or a tool result that turned out to be text
33
+ * must not go down with it.
34
+ *
35
+ * A configured `workspaceRoot` is not a state directory, so there is
36
+ * nothing for the host to secure under it and the two answers are the
37
+ * same: plugins already make what they need beneath it.
38
+ */
39
+ export declare const workspacePreparer: (workspaces: AgentWorkspaces | undefined, workspaceRoot: string | undefined) => ((agentId: string) => string) | undefined;
40
+ /**
41
+ * Every agent workspace on this host, for the guard that has to recognise
42
+ * any agent's file rather than the caller's — see `ledgerGuard`.
43
+ *
44
+ * Same precedence as `workspaceResolver`: a configured root's own entries
45
+ * are the agents, which is what reading `workspaceRoot` as a root means,
46
+ * and the seam answers otherwise. A root that is not there yet holds no
47
+ * agents rather than failing, because a guard runs before the first write
48
+ * as well as after it — but only a root that is genuinely absent. See the
49
+ * catch below for why every other failure has to reach the caller.
50
+ */
51
+ export declare const allAgentWorkspaces: (workspaces: AgentWorkspaces | undefined, workspaceRoot: string | undefined) => Promise<readonly string[]>;
52
+ //# sourceMappingURL=workspace.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.d.ts","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,eAAe,GAAG,SAAS,EACvC,eAAe,MAAM,GAAG,SAAS,KAChC,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SASlC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,iBAAiB,GAC5B,YAAY,eAAe,GAAG,SAAS,EACvC,eAAe,MAAM,GAAG,SAAS,KAChC,CAAC,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,CAAC,GAAG,SASlC,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,GAC7B,YAAY,eAAe,GAAG,SAAS,EACvC,eAAe,MAAM,GAAG,SAAS,KAChC,OAAO,CAAC,SAAS,MAAM,EAAE,CA0B3B,CAAC"}
@@ -0,0 +1,98 @@
1
+ import { readdir } from 'node:fs/promises';
2
+ import path from 'node:path';
3
+ /**
4
+ * How a plugin finds an agent's workspace, from whichever of the two the
5
+ * host gave it.
6
+ *
7
+ * One implementation because there used to be five. Every plugin that
8
+ * writes a file was handed a `workspaceRoot` and appended the agent id to
9
+ * it, so each of them held a copy of the layout — and all five had to
10
+ * change when the workspace moved into the agent's own state directory,
11
+ * which is the cost that key was introduced to avoid and did not.
12
+ *
13
+ * An explicitly configured `workspaceRoot` wins, and the order matters:
14
+ * the loader no longer fills that key with the host's answer — the seam
15
+ * *is* the host's answer — so a value there is one an operator wrote, and
16
+ * relocating a workspace by writing it down is a thing they are documented
17
+ * to be able to do. Under it the old contract still holds: one directory
18
+ * per agent directly under the configured root, which is also what a host
19
+ * wiring a plugin by hand with no layout of its own supplies.
20
+ *
21
+ * Undefined means this host gave the plugin nowhere to write. A caller
22
+ * that needs a path must fail the call naming what is missing rather than
23
+ * choosing a directory of its own.
24
+ */
25
+ export const workspaceResolver = (workspaces, workspaceRoot) => {
26
+ if (workspaceRoot !== undefined && workspaceRoot.length > 0) {
27
+ const root = workspaceRoot;
28
+ return (agentId) => path.join(root, agentId);
29
+ }
30
+ if (workspaces !== undefined) {
31
+ return (agentId) => workspaces.forAgent(agentId);
32
+ }
33
+ return undefined;
34
+ };
35
+ /**
36
+ * The same, for a caller that is about to write: the host creates the
37
+ * directory and settles its permissions before answering.
38
+ *
39
+ * Asked only by the call that needs the directory, never by one that only
40
+ * needs the name. Resolving is free; preparing is not, and it can fail —
41
+ * `agents/<id>/workspace` may be unmakeable — so a `browser.goto`, a
42
+ * `fs.read`'s ledger lookup, or a tool result that turned out to be text
43
+ * must not go down with it.
44
+ *
45
+ * A configured `workspaceRoot` is not a state directory, so there is
46
+ * nothing for the host to secure under it and the two answers are the
47
+ * same: plugins already make what they need beneath it.
48
+ */
49
+ export const workspacePreparer = (workspaces, workspaceRoot) => {
50
+ if (workspaceRoot !== undefined && workspaceRoot.length > 0) {
51
+ const root = workspaceRoot;
52
+ return (agentId) => path.join(root, agentId);
53
+ }
54
+ if (workspaces !== undefined) {
55
+ return (agentId) => workspaces.prepare(agentId);
56
+ }
57
+ return undefined;
58
+ };
59
+ /**
60
+ * Every agent workspace on this host, for the guard that has to recognise
61
+ * any agent's file rather than the caller's — see `ledgerGuard`.
62
+ *
63
+ * Same precedence as `workspaceResolver`: a configured root's own entries
64
+ * are the agents, which is what reading `workspaceRoot` as a root means,
65
+ * and the seam answers otherwise. A root that is not there yet holds no
66
+ * agents rather than failing, because a guard runs before the first write
67
+ * as well as after it — but only a root that is genuinely absent. See the
68
+ * catch below for why every other failure has to reach the caller.
69
+ */
70
+ export const allAgentWorkspaces = async (workspaces, workspaceRoot) => {
71
+ if (workspaceRoot === undefined || workspaceRoot.length === 0) {
72
+ return workspaces !== undefined ? workspaces.all() : [];
73
+ }
74
+ try {
75
+ const entries = await readdir(workspaceRoot, { withFileTypes: true });
76
+ return entries
77
+ .filter((entry) => entry.isDirectory() || entry.isSymbolicLink())
78
+ .map((entry) => path.join(workspaceRoot, entry.name));
79
+ }
80
+ catch (error) {
81
+ const code = error.code;
82
+ // A root that is not there yet, or is not a directory, holds no
83
+ // workspaces and so no ledgers — nothing for a guard to miss.
84
+ //
85
+ // Anything else propagates, and the caller fails its tool call. This
86
+ // list is what `ledgerGuard` is built from, and an empty one is a guard
87
+ // that answers "not a ledger" to every path — so swallowing `EACCES`
88
+ // (a root that is executable but not listable, whose children are still
89
+ // writable by name) or a transient `EMFILE` would let `fs.write`
90
+ // truncate an agent's provenance ledger. "Cannot tell" is not "nothing
91
+ // to protect".
92
+ if (code === 'ENOENT' || code === 'ENOTDIR') {
93
+ return [];
94
+ }
95
+ throw error;
96
+ }
97
+ };
98
+ //# sourceMappingURL=workspace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspace.js","sourceRoot":"","sources":["../src/workspace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,IAAI,MAAM,WAAW,CAAC;AAG7B;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAuC,EACvC,aAAiC,EACU,EAAE;IAC7C,IAAI,aAAa,KAAK,SAAS,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5D,MAAM,IAAI,GAAG,aAAa,CAAC;QA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MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,EAAE,IAAI,KAAK,CAAC,cAAc,EAAE,CAAC;aAChE,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAC1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,GAAI,KAA+B,CAAC,IAAI,CAAC;QACnD,gEAAgE;QAChE,8DAA8D;QAC9D,EAAE;QACF,qEAAqE;QACrE,wEAAwE;QACxE,qEAAqE;QACrE,wEAAwE;QACxE,iEAAiE;QACjE,uEAAuE;QACvE,eAAe;QACf,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YAC5C,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stratusagent/plugins",
3
- "version": "0.11.3",
3
+ "version": "0.11.5",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -18,8 +18,8 @@
18
18
  "node": ">=22.13 <23 || >=23.4"
19
19
  },
20
20
  "dependencies": {
21
- "@stratusagent/agents": "0.11.3",
22
- "@stratusagent/core": "0.11.3"
21
+ "@stratusagent/agents": "0.11.5",
22
+ "@stratusagent/core": "0.11.5"
23
23
  },
24
24
  "devDependencies": {
25
25
  "@types/node": "^24.6.0",