@aragon-agent/cli 0.6.68 → 0.6.71

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 (48) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +39 -15
  3. package/dist/agent/controller.d.ts +30 -1
  4. package/dist/agent/controller.js +91 -9
  5. package/dist/agent/project-guidance-prompt.js +97 -97
  6. package/dist/app/App.d.ts +12 -3
  7. package/dist/app/App.js +25 -2
  8. package/dist/app/use-governance-rounds.js +8 -4
  9. package/dist/cli.js +2 -2
  10. package/dist/commands/catalog.js +1 -1
  11. package/dist/config/cli-commands.d.ts +1 -1
  12. package/dist/config/cli-commands.js +4 -0
  13. package/dist/config/env.js +6 -0
  14. package/dist/config/load.js +36 -1
  15. package/dist/governance/engine/lifecycle.js +1 -1
  16. package/dist/governance/prompts/orchestrator-block.js +3 -3
  17. package/dist/host/controller-factory.d.ts +15 -0
  18. package/dist/host/controller-factory.js +10 -2
  19. package/dist/host/memory.d.ts +5 -1
  20. package/dist/host/memory.js +13 -0
  21. package/dist/memory/block.d.ts +38 -4
  22. package/dist/memory/block.js +52 -5
  23. package/dist/memory/command.js +56 -2
  24. package/dist/memory/journal.d.ts +58 -0
  25. package/dist/memory/journal.js +202 -0
  26. package/dist/memory/ledger.d.ts +54 -0
  27. package/dist/memory/ledger.js +105 -0
  28. package/dist/memory/paths.d.ts +10 -0
  29. package/dist/memory/paths.js +31 -0
  30. package/dist/memory/service.d.ts +54 -1
  31. package/dist/memory/service.js +156 -1
  32. package/dist/memory/store.d.ts +21 -3
  33. package/dist/memory/store.js +66 -6
  34. package/dist/memory/tools-batch.d.ts +27 -0
  35. package/dist/memory/tools-batch.js +462 -0
  36. package/dist/memory/tools-shared.d.ts +176 -0
  37. package/dist/memory/tools-shared.js +305 -0
  38. package/dist/memory/tools.d.ts +19 -28
  39. package/dist/memory/tools.js +148 -228
  40. package/dist/memory/undo.d.ts +53 -0
  41. package/dist/memory/undo.js +173 -0
  42. package/dist/redteam/prompt-template.js +16 -16
  43. package/dist/tools/index.d.ts +2 -2
  44. package/dist/tools/index.js +16 -1
  45. package/package.json +3 -3
  46. package/runtime/insecure-tls-warning.cjs +62 -62
  47. package/runtime/insecure-tls-warning.d.cts +5 -5
  48. package/skills/project-indexer/templates/artifact-hygiene-template.md +14 -14
@@ -24,9 +24,14 @@
24
24
  import { createHash } from 'node:crypto';
25
25
  import { CHARS_PER_TOKEN } from '@aragon-agent/core';
26
26
  import { DEFAULT_MEMORY_CONFIG } from '@aragon-agent/tui/model/config/schema';
27
+ import { beginAutonomyTurn, countAppliedWrites, decideMemoryWrite, emptyAutonomyState, noteDecision, } from '@aragon-agent/tui/model/memory/autonomy';
28
+ import { mintBatchId, seedAutonomyState } from '@aragon-agent/tui/model/memory/activity';
29
+ import { MEMORY_LIMITS } from '@aragon-agent/tui/model/memory/limits';
27
30
  import { nextMountAction, policyWantsBody } from '@aragon-agent/tui/model/memory/mount';
28
31
  import { compareMemoryRows, filterMemoryRows } from '@aragon-agent/tui/model/memory/search';
29
32
  import { getLogger } from '../logging/logger.js';
33
+ import { appendJournalEntry, pruneJournal, readJournal } from './journal.js';
34
+ import { undoBatch } from './undo.js';
30
35
  import { buildMemoryBlock } from './block.js';
31
36
  import { planMemoryContext, resolveMemoryBudgets } from './plan.js';
32
37
  import { isValidNoteId, resolveProjectKey, } from './paths.js';
@@ -45,10 +50,21 @@ export class MemoryService {
45
50
  block = '';
46
51
  lastEmitted = null;
47
52
  listeners = new Set();
53
+ /** Write counters for THIS process. Never persisted: an approval does not survive a restart. */
54
+ autonomy = emptyAutonomyState();
55
+ /** `pruneJournal` runs once per process, on the first real user turn. */
56
+ prunedThisProcess = false;
57
+ /** The one-shot "memory is now self-managed" line has been handed to a surface. */
58
+ autonomyNoticeTaken = false;
48
59
  constructor(deps) {
49
60
  this.deps = deps;
50
61
  this.memoryConfig = deps.getConfig().memory ?? DEFAULT_MEMORY_CONFIG;
51
62
  this.project = resolveProjectKey(deps.getCwd());
63
+ // THE 24h BUDGET IS REBUILT FROM THE JOURNAL HERE, ONCE (spec 5.3 / D-8). Session counters
64
+ // would be cleared by --resume, a second window or a restart - the journal is the only
65
+ // counter that spans processes. Read-only: the constructor may not create `.journal/`, or a
66
+ // session that writes nothing would still look like a write to a directory snapshot.
67
+ this.autonomy = emptyAutonomyState(this.seedUsedDay());
52
68
  this.sync();
53
69
  if (deps.purgeTrashOnStart !== false) {
54
70
  const timer = setTimeout(() => {
@@ -128,6 +144,107 @@ export class MemoryService {
128
144
  return 'off';
129
145
  return this.session.agentWrites ?? configured;
130
146
  }
147
+ // ---- autonomy ----------------------------------------------------------
148
+ /**
149
+ * The policy right now: the configured numbers, plus this session's `agentWrites` override.
150
+ *
151
+ * Read live on every call - a session can switch `ask` <-> `auto` between two tool calls, and a
152
+ * cached policy would keep deciding with the mode the user just left.
153
+ */
154
+ autonomyPolicy() {
155
+ const cfg = this.deps.getConfig().memory ?? this.memoryConfig;
156
+ return {
157
+ mode: this.effectiveAgentWrites(),
158
+ perTurn: cfg.autoWritesPerTurn ?? DEFAULT_MEMORY_CONFIG.autoWritesPerTurn,
159
+ perDay: cfg.autoWritesPerDay ?? DEFAULT_MEMORY_CONFIG.autoWritesPerDay,
160
+ bulkThreshold: cfg.bulkThreshold ?? DEFAULT_MEMORY_CONFIG.bulkThreshold,
161
+ protectUserNotes: cfg.protectUserNotes ?? DEFAULT_MEMORY_CONFIG.protectUserNotes,
162
+ };
163
+ }
164
+ /** The counters, read-only. The state object never leaves this class (RV-P2-1). */
165
+ autonomyState() {
166
+ return this.autonomy;
167
+ }
168
+ /** Decide one write. Pure: the policy and the counters go in, the verdict comes out (spec 6.2). */
169
+ decide(intent) {
170
+ return decideMemoryWrite(this.autonomyPolicy(), this.autonomy, intent);
171
+ }
172
+ /** Record an applied write (allow, or an approved confirm): both budgets advance. */
173
+ noteApplied(decision, intent, applied) {
174
+ const ids = intent.churnIds.map((entry) => entry.id);
175
+ this.autonomy = countAppliedWrites(noteDecision(this.autonomy, decision, 'applied'), applied, ids);
176
+ this.emitIfChanged();
177
+ }
178
+ /** Record a decline. Two of them in one turn stop every further write (D-4). */
179
+ noteDeclined(decision) {
180
+ this.autonomy = noteDecision(this.autonomy, decision, 'declined');
181
+ this.emitIfChanged();
182
+ }
183
+ /**
184
+ * Start of a real user turn: clear the per-turn counters and, once per process, prune the journal.
185
+ *
186
+ * CALLED FROM `prepareUserTurn`'s non-steering branch ONLY (spec 5.3 / RV-P2-6): a steering turn
187
+ * is the same turn with one more sentence in it, and treating it as new would hand the model a
188
+ * fresh batch of three automatic writes for saying "also, check the tests".
189
+ */
190
+ beginTurn() {
191
+ this.autonomy = beginAutonomyTurn(this.autonomy);
192
+ if (this.prunedThisProcess)
193
+ return;
194
+ this.prunedThisProcess = true;
195
+ try {
196
+ for (const target of this.targets())
197
+ pruneJournal(target, this.now());
198
+ }
199
+ catch {
200
+ // Housekeeping: a locked journal file must not stop a turn.
201
+ }
202
+ }
203
+ /** A fresh batch id (`mbt_` + 8 hex) for one tool call. */
204
+ newBatchId() {
205
+ return mintBatchId();
206
+ }
207
+ /** Append one row to the write ledger. Failures are logged there, never raised here. */
208
+ journalAppend(entry) {
209
+ appendJournalEntry(this.targetOf(entry.scope), { v: 1, at: this.now(), ...entry });
210
+ }
211
+ /** Recent ledger rows for both scopes, newest first (the activity page and `/memory activity`). */
212
+ activity(limit = MEMORY_LIMITS.activityRowsMax) {
213
+ const rows = [];
214
+ for (const target of this.targets()) {
215
+ rows.push(...readJournal(target, MEMORY_LIMITS.journalSeedScanMax).entries);
216
+ }
217
+ return rows.sort((a, b) => b.at - a.at).slice(0, Math.max(1, limit));
218
+ }
219
+ /** Undo one agent batch: the user's recovery lever (D-6). `reason: 'user'` marks the ledger row. */
220
+ undoLast(batchId) {
221
+ return undoBatch(this, batchId === undefined ? { reason: 'user' } : { batchId, reason: 'user' });
222
+ }
223
+ /**
224
+ * `true` exactly once per process: the first automatic write is announced, the second is not.
225
+ * The controller owns the sentence; this only owns "has it been said".
226
+ */
227
+ takeAutonomyNotice() {
228
+ if (this.autonomyNoticeTaken)
229
+ return false;
230
+ this.autonomyNoticeTaken = true;
231
+ return true;
232
+ }
233
+ /** The 24h write count as the journal remembers it, or 0 when it cannot be read. */
234
+ seedUsedDay() {
235
+ let used = 0;
236
+ try {
237
+ for (const target of this.targets()) {
238
+ used += seedAutonomyState(readJournal(target, MEMORY_LIMITS.journalSeedScanMax).entries, this.now());
239
+ }
240
+ }
241
+ catch {
242
+ // An unreadable ledger means "no history known", not "the feature is broken": a successful
243
+ // append restores the true count on the next start-up.
244
+ return 0;
245
+ }
246
+ return used;
247
+ }
131
248
  /** Apply a change to session state, deferring the prompt rewrite when a turn is running. */
132
249
  afterChange(promptAffected) {
133
250
  this.computed = null;
@@ -219,7 +336,16 @@ export class MemoryService {
219
336
  const computed = this.compute(config);
220
337
  if (this.blockKey === computed.key)
221
338
  return this.block;
222
- this.block = buildMemoryBlock(computed.plan);
339
+ // THE POLICY HALF OF THE BLOCK EXISTS ONLY UNDER `auto` (D-16 / I-14): `ask` and `off` have to
340
+ // stay byte for byte what they were before autonomy existed, and the key above already includes
341
+ // the mode, so switching back rebuilds instead of serving the old sentence.
342
+ const policy = this.effectiveAgentWrites() === 'auto'
343
+ ? {
344
+ bulkThreshold: this.autonomyPolicy().bulkThreshold,
345
+ protectUserNotes: this.autonomyPolicy().protectUserNotes,
346
+ }
347
+ : null;
348
+ this.block = buildMemoryBlock(computed.plan, policy);
223
349
  this.blockKey = computed.key;
224
350
  this.logRebuilt(computed);
225
351
  return this.block;
@@ -266,6 +392,15 @@ export class MemoryService {
266
392
  this.computed = { key, plan, budgets, autoload };
267
393
  return this.computed;
268
394
  }
395
+ /**
396
+ * The hash of everything the `<memory>` block depends on, and nothing else (I-4).
397
+ *
398
+ * THE POLICY IS PART OF IT, ALL THREE PARTS (RV-P1-4). The two policy sentences in the block are
399
+ * only appended under `auto`, so `auto -> ask` changes the bytes; without the mode in this key
400
+ * `renderBlock` short-circuits on the old key and the model keeps being told it needs no
401
+ * approval after the user switched back to asking. The threshold and the protection switch are in
402
+ * the sentences themselves, so they are in the key too.
403
+ */
269
404
  keyOf(autoload, budgets) {
270
405
  const notes = this.notes
271
406
  .map((note) => `${note.scope}:${note.id}:${note.rev}:${note.load}:${note.enabled ? 1 : 0}`)
@@ -273,12 +408,14 @@ export class MemoryService {
273
408
  // NOT sorted: for explicit mounts the order they were added in decides who is refused when
274
409
  // the ceiling is reached (see `planMemoryContext`), so it is part of what the block depends on.
275
410
  const overrides = Object.keys(this.session.overrides).map((id) => `${id}=${this.session.overrides[id]}`);
411
+ const policy = this.autonomyPolicy();
276
412
  const text = JSON.stringify([
277
413
  notes,
278
414
  overrides,
279
415
  autoload,
280
416
  [budgets.indexChars, budgets.bodyChars, budgets.perBodyChars, budgets.explicitCeiling, budgets.autoloadActive],
281
417
  this.project.key,
418
+ [policy.mode, policy.bulkThreshold, policy.protectUserNotes],
282
419
  ]);
283
420
  return createHash('sha1').update(text).digest('hex');
284
421
  }
@@ -533,6 +670,13 @@ export class MemoryService {
533
670
  },
534
671
  pending: this.pending,
535
672
  noteCount: this.notes.length,
673
+ autonomy: {
674
+ ...this.autonomyPolicy(),
675
+ usedTurn: this.autonomy.usedTurn,
676
+ usedDay: this.autonomy.usedDay,
677
+ turnGranted: this.autonomy.turnGranted,
678
+ deniedTurn: this.autonomy.deniedTurn,
679
+ },
536
680
  ...(this.notice !== null ? { notice: this.notice } : {}),
537
681
  };
538
682
  }
@@ -573,4 +717,15 @@ export const UNAVAILABLE_VIEW = {
573
717
  budget: { indexChars: 0, bodyChars: 0, usedChars: 0, tokensEstimate: 0, limitTokens: 0, overBudget: false },
574
718
  pending: false,
575
719
  noteCount: 0,
720
+ autonomy: {
721
+ mode: 'off',
722
+ perTurn: 0,
723
+ perDay: 0,
724
+ bulkThreshold: 0,
725
+ protectUserNotes: false,
726
+ usedTurn: 0,
727
+ usedDay: 0,
728
+ turnGranted: false,
729
+ deniedTurn: 0,
730
+ },
576
731
  };
@@ -15,9 +15,16 @@
15
15
  * READS ARE FREE OF SIDE EFFECTS (I-14): no directory is created, no file is touched, no
16
16
  * mtime changes. Opening the manager on a hand-written file must not rewrite it.
17
17
  *
18
- * THIS MODULE IS THE ONLY CODE THAT WRITES UNDER `getMemoryDir()` (I-12). The tool, the
19
- * `/memory` command, the overlay and the desktop IPC handlers all come through here, which
20
- * is what lets one test prove "nothing writes without a user action" for the whole feature.
18
+ * THIS MODULE IS THE ONLY CODE THAT WRITES **NOTE FILES** UNDER `getMemoryDir()` (I-12). The tool,
19
+ * the `/memory` command, the overlay and the desktop IPC handlers all come through here, which is
20
+ * what lets one test prove "nothing writes without a user action" for the whole feature. The one
21
+ * exception is the write ledger (`journal.ts`), which owns `.journal/**` and only ever appends.
22
+ *
23
+ * `source` IS THE CREATOR, AND IT IS MONOTONIC (memory-agent-autonomy D-21 / I-17). `createNote`
24
+ * writes it; `updateNote` and `restoreVersion` PRESERVE it. That is not cosmetic: the autonomy
25
+ * policy protects notes with `source !== 'agent'`, so an update that rewrote the field to the
26
+ * writer's identity would disarm that protection the first time the agent edited a note the user
27
+ * had written - exactly once, silently, with no test to notice.
21
28
  */
22
29
  import { copyFileSync, linkSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
23
30
  import type { MemoryCatalogRow, MemoryDraftInput, MemoryNote, MemoryNoteSource, MemoryResult, MemoryTrashItem } from '@aragon-agent/tui/model/memory/types';
@@ -81,6 +88,7 @@ export interface MemoryWriteOptions {
81
88
  label: string;
82
89
  };
83
90
  }
91
+ export declare function mkdirPrivate(dir: string): void;
84
92
  /** Create a note. Mints the id; never overwrites an existing file. */
85
93
  export declare function createNote(target: MemoryTarget, input: MemoryDraftInput, opts: MemoryWriteOptions): MemoryResult<MemoryNote>;
86
94
  /**
@@ -92,6 +100,16 @@ export declare function createNote(target: MemoryTarget, input: MemoryDraftInput
92
100
  * nothing.
93
101
  */
94
102
  export declare function updateNote(target: MemoryTarget, id: string, input: MemoryDraftInput, expectedRev: string, opts: MemoryWriteOptions): MemoryResult<MemoryNote>;
103
+ /**
104
+ * Write one version backup back over a note (memory-agent-autonomy spec 8.2).
105
+ *
106
+ * The inverse of `updateNote`, and it deliberately reuses it: same CAS check, same atomic write,
107
+ * same backup of what is there now. Two consequences the caller has to live with, both inherited
108
+ * on purpose: identical content is a no-op (the rev does not change) rather than a write, and a
109
+ * restored body that today looks like a secret is refused. The undo layer reports both as
110
+ * `skipped` instead of failing the whole batch.
111
+ */
112
+ export declare function restoreVersion(target: MemoryTarget, id: string, backupFile: string, expectedRev: string, opts: MemoryWriteOptions): MemoryResult<MemoryNote>;
95
113
  /** Move a note to the trash (30 days), if it is still the version the caller saw. */
96
114
  export declare function trashNote(target: MemoryTarget, id: string, expectedRev: string, now?: number): MemoryResult<{
97
115
  trashId: string;
@@ -15,9 +15,16 @@
15
15
  * READS ARE FREE OF SIDE EFFECTS (I-14): no directory is created, no file is touched, no
16
16
  * mtime changes. Opening the manager on a hand-written file must not rewrite it.
17
17
  *
18
- * THIS MODULE IS THE ONLY CODE THAT WRITES UNDER `getMemoryDir()` (I-12). The tool, the
19
- * `/memory` command, the overlay and the desktop IPC handlers all come through here, which
20
- * is what lets one test prove "nothing writes without a user action" for the whole feature.
18
+ * THIS MODULE IS THE ONLY CODE THAT WRITES **NOTE FILES** UNDER `getMemoryDir()` (I-12). The tool,
19
+ * the `/memory` command, the overlay and the desktop IPC handlers all come through here, which is
20
+ * what lets one test prove "nothing writes without a user action" for the whole feature. The one
21
+ * exception is the write ledger (`journal.ts`), which owns `.journal/**` and only ever appends.
22
+ *
23
+ * `source` IS THE CREATOR, AND IT IS MONOTONIC (memory-agent-autonomy D-21 / I-17). `createNote`
24
+ * writes it; `updateNote` and `restoreVersion` PRESERVE it. That is not cosmetic: the autonomy
25
+ * policy protects notes with `source !== 'agent'`, so an update that rewrote the field to the
26
+ * writer's identity would disarm that protection the first time the agent edited a note the user
27
+ * had written - exactly once, silently, with no test to notice.
21
28
  */
22
29
  import { chmodSync, copyFileSync, existsSync, linkSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync, } from 'node:fs';
23
30
  import { join } from 'node:path';
@@ -241,7 +248,7 @@ function revalidate(input) {
241
248
  return verdict.ok ? null : verdict.code;
242
249
  }
243
250
  const RETRY_CODES = new Set(['EPERM', 'EBUSY', 'EACCES']);
244
- function mkdirPrivate(dir) {
251
+ export function mkdirPrivate(dir) {
245
252
  mkdirSync(dir, { recursive: true, mode: 0o700 });
246
253
  if (process.platform !== 'win32') {
247
254
  try {
@@ -474,7 +481,10 @@ export function updateNote(target, id, input, expectedRev, opts) {
474
481
  createdAt: current.value.createdAt,
475
482
  updatedAt: Math.max(now, current.value.updatedAt),
476
483
  schema: current.value.schema,
477
- source: opts.source,
484
+ // PRESERVE THE CREATOR (I-17). `opts.source` deliberately does NOT appear on this line: the
485
+ // note was created by whoever created it, and "who edited it this time" is what the journal
486
+ // records. Changing this to `opts.source` re-breaks the protected-note rule; see the header.
487
+ source: current.value.source,
478
488
  ...(current.value.extra !== undefined ? { extra: current.value.extra } : {}),
479
489
  });
480
490
  if (writeFileAtomic(file, text, false) !== 'ok') {
@@ -485,7 +495,57 @@ export function updateNote(target, id, input, expectedRev, opts) {
485
495
  touchProjectMeta(target, opts.projectInfo, now);
486
496
  const note = reparse(file, id, target.scope, text, now);
487
497
  log('note_updated', { id, scope: target.scope, op: 'update', rev: note.rev, chars: note.bodyChars });
488
- return backup === 'failed' ? { ok: true, value: note, backup: 'failed' } : { ok: true, value: note };
498
+ // `backupFile` is what undo needs to find the previous version again (spec 8.2 / V-1): the file
499
+ // name inside `versionsDir`, which the caller cannot reconstruct (`now` may have been injected).
500
+ const version = `${now}.md`;
501
+ return backup === 'failed'
502
+ ? { ok: true, value: note, backup: 'failed' }
503
+ : { ok: true, value: note, backupFile: version };
504
+ }
505
+ const VERSION_FILE = /^\d{10,16}\.md$/;
506
+ /**
507
+ * Write one version backup back over a note (memory-agent-autonomy spec 8.2).
508
+ *
509
+ * The inverse of `updateNote`, and it deliberately reuses it: same CAS check, same atomic write,
510
+ * same backup of what is there now. Two consequences the caller has to live with, both inherited
511
+ * on purpose: identical content is a no-op (the rev does not change) rather than a write, and a
512
+ * restored body that today looks like a secret is refused. The undo layer reports both as
513
+ * `skipped` instead of failing the whole batch.
514
+ */
515
+ export function restoreVersion(target, id, backupFile, expectedRev, opts) {
516
+ if (!isValidNoteId(id))
517
+ return fail('invalid_id');
518
+ if (!VERSION_FILE.test(backupFile))
519
+ return fail('invalid_id');
520
+ const dir = versionsDir(target, id);
521
+ if (dir === null)
522
+ return fail('invalid_id');
523
+ const from = join(dir, backupFile);
524
+ if (!existsSync(from))
525
+ return fail('not_found');
526
+ let note;
527
+ try {
528
+ // THE SAME CEILING readNote APPLIES: a version file is a note file, and without this a copy
529
+ // dropped into versionsDir by a sync client would be read whole on every undo attempt.
530
+ if (statSync(from).size > MEMORY_LIMITS.maxFileBytes)
531
+ return fail('not_found');
532
+ note = parseNoteBytes(readFileSync(from), { id, scope: target.scope, mtimeMs: 0 });
533
+ }
534
+ catch {
535
+ return fail('not_found');
536
+ }
537
+ if (note === null)
538
+ return fail('not_found');
539
+ const draft = {
540
+ title: note.title,
541
+ summary: note.summary,
542
+ body: note.body,
543
+ tags: note.tags,
544
+ load: note.load,
545
+ enabled: note.enabled,
546
+ scope: note.scope,
547
+ };
548
+ return updateNote(target, id, draft, expectedRev, opts);
489
549
  }
490
550
  /** Move a note to the trash (30 days), if it is still the version the caller saw. */
491
551
  export function trashNote(target, id, expectedRev, now = Date.now()) {
@@ -0,0 +1,27 @@
1
+ /**
2
+ * `memory_batch`: several memory changes in one request, one approval for the whole plan
3
+ * (memory-agent-autonomy spec 7.2).
4
+ *
5
+ * ASCII ONLY - `src/memory/**` is inside `glyphs.test.ts::inScope`. Everything the model reads is
6
+ * English (agent-memory D-26); the user's own words appear only inside quoted titles.
7
+ *
8
+ * WHY A SECOND TOOL AND NOT A LOOP OF `memory_write`. A sweep that merges duplicates or retags ten
9
+ * notes is one decision for the user, not ten; asking ten times is how approval degrades into a
10
+ * reflex (D-3). And the whole batch has to be validated BEFORE anyone is asked, or the confirmation
11
+ * card and the execution disagree (D-11 / D-12).
12
+ *
13
+ * THREE RULES THAT ARE NOT NEGOTIABLE:
14
+ * - ALL OR NOTHING AT VALIDATION: one bad op refuses the batch, with the first few failing
15
+ * indexes, and not a byte is written.
16
+ * - A SECRET REFUSES THE WHOLE BATCH, before the card: half a batch is not a state anyone can
17
+ * reason about afterwards.
18
+ * - EXECUTION STOPS AT THE FIRST `conflict` / `write_failed` (D-13), and reports "applied N of
19
+ * M" plus the batch id, so what landed can still be undone as one unit.
20
+ *
21
+ * THIS FILE EXISTS FOR THE 1000-LINE CEILING (RV-P1-10): `tools.ts` was already 641 lines, and the
22
+ * shape -> validate -> secret -> decide -> card -> execute -> journal -> receipt chain below is
23
+ * roughly 220 of them.
24
+ */
25
+ import { type AgentTool } from '@aragon-agent/core';
26
+ import { type MemoryToolPorts } from './tools-shared.js';
27
+ export declare function batchTool(ports: MemoryToolPorts): AgentTool;