@aragon-agent/cli 0.6.53 → 0.6.55

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 (101) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +135 -6
  3. package/dist/agent/controller.d.ts +98 -0
  4. package/dist/agent/controller.js +341 -1
  5. package/dist/agent/redteam-prompt.d.ts +47 -0
  6. package/dist/agent/redteam-prompt.js +161 -0
  7. package/dist/agent/redteam-wiring.d.ts +159 -0
  8. package/dist/agent/redteam-wiring.js +349 -0
  9. package/dist/agent/system-prompt.d.ts +27 -0
  10. package/dist/agent/system-prompt.js +10 -0
  11. package/dist/app/App.d.ts +17 -1
  12. package/dist/app/App.js +266 -26
  13. package/dist/app/use-redteam-mode.d.ts +56 -0
  14. package/dist/app/use-redteam-mode.js +121 -0
  15. package/dist/cli.js +78 -4
  16. package/dist/commands/builtins.js +49 -1
  17. package/dist/commands/catalog.js +5 -0
  18. package/dist/commands/index-build.js +2 -1
  19. package/dist/commands/redteam-command.d.ts +22 -0
  20. package/dist/commands/redteam-command.js +141 -0
  21. package/dist/commands/registry.d.ts +7 -0
  22. package/dist/compaction/compactor.d.ts +26 -0
  23. package/dist/compaction/compactor.js +81 -8
  24. package/dist/compaction/summarize-call.d.ts +22 -0
  25. package/dist/compaction/summarize-call.js +29 -0
  26. package/dist/compaction/wiring.js +22 -3
  27. package/dist/config/app-paths.d.ts +13 -0
  28. package/dist/config/app-paths.js +15 -0
  29. package/dist/config/cli-commands.d.ts +15 -0
  30. package/dist/config/cli-commands.js +32 -1
  31. package/dist/config/env.d.ts +3 -1
  32. package/dist/config/env.js +23 -1
  33. package/dist/config/load.d.ts +18 -0
  34. package/dist/config/load.js +19 -1
  35. package/dist/config/redteam-launch.d.ts +77 -0
  36. package/dist/config/redteam-launch.js +58 -0
  37. package/dist/config/store.js +20 -1
  38. package/dist/config/ui-state.d.ts +44 -0
  39. package/dist/config/ui-state.js +38 -0
  40. package/dist/exec/bridge/server.js +9 -2
  41. package/dist/exec/options.js +16 -2
  42. package/dist/governance/prompts/orchestrator-block.js +2 -2
  43. package/dist/host/controller-factory.d.ts +33 -0
  44. package/dist/host/controller-factory.js +14 -0
  45. package/dist/host/follow-up-seed.d.ts +109 -0
  46. package/dist/host/follow-up-seed.js +196 -0
  47. package/dist/host/follow-up.d.ts +73 -0
  48. package/dist/host/follow-up.js +123 -0
  49. package/dist/host/index.d.ts +3 -0
  50. package/dist/host/index.js +3 -0
  51. package/dist/host/memory.d.ts +21 -0
  52. package/dist/host/memory.js +17 -0
  53. package/dist/host/sessions.d.ts +32 -2
  54. package/dist/host/sessions.js +40 -2
  55. package/dist/logging/install.d.ts +1 -0
  56. package/dist/logging/install.js +4 -0
  57. package/dist/logging/logger.d.ts +1 -1
  58. package/dist/memory/block.d.ts +24 -0
  59. package/dist/memory/block.js +54 -0
  60. package/dist/memory/command.d.ts +31 -0
  61. package/dist/memory/command.js +350 -0
  62. package/dist/memory/format.d.ts +51 -0
  63. package/dist/memory/format.js +308 -0
  64. package/dist/memory/paths.d.ts +68 -0
  65. package/dist/memory/paths.js +172 -0
  66. package/dist/memory/plan.d.ts +37 -0
  67. package/dist/memory/plan.js +184 -0
  68. package/dist/memory/resolve.d.ts +45 -0
  69. package/dist/memory/resolve.js +54 -0
  70. package/dist/memory/secrets.d.ts +30 -0
  71. package/dist/memory/secrets.js +73 -0
  72. package/dist/memory/service.d.ts +175 -0
  73. package/dist/memory/service.js +576 -0
  74. package/dist/memory/store.d.ts +133 -0
  75. package/dist/memory/store.js +694 -0
  76. package/dist/memory/tools.d.ts +36 -0
  77. package/dist/memory/tools.js +527 -0
  78. package/dist/memory/transfer.d.ts +53 -0
  79. package/dist/memory/transfer.js +93 -0
  80. package/dist/session/checkpoint.d.ts +33 -0
  81. package/dist/session/checkpoint.js +52 -0
  82. package/dist/session/limits.d.ts +16 -0
  83. package/dist/session/limits.js +16 -0
  84. package/dist/session/persist.d.ts +68 -0
  85. package/dist/session/persist.js +11 -0
  86. package/dist/session/startup-session.d.ts +17 -2
  87. package/dist/session/startup-session.js +15 -2
  88. package/dist/session/store.d.ts +14 -0
  89. package/dist/session/store.js +18 -0
  90. package/dist/session/validate-session.js +129 -0
  91. package/dist/team/runtime.d.ts +11 -0
  92. package/dist/team/runtime.js +6 -0
  93. package/dist/team/subagent.d.ts +21 -0
  94. package/dist/team/subagent.js +7 -0
  95. package/dist/tools/index.d.ts +45 -2
  96. package/dist/tools/index.js +53 -3
  97. package/package.json +3 -3
  98. package/skills/project-indexer/SKILL.md +275 -147
  99. package/skills/project-indexer/templates/artifact-hygiene-template.md +14 -0
  100. package/skills/project-indexer/templates/config-template.md +12 -0
  101. package/skills/project-indexer/templates/index-template.md +4 -0
@@ -2,6 +2,8 @@ import { isAdapterProvider } from '@aragon-agent/tui/model/config/schema';
2
2
  import { normalizeTodos } from '../todo/normalize.js';
3
3
  import { TODO_LIMITS } from '@aragon-agent/tui/model/todo/limits';
4
4
  import { acceptanceSummary, normalizeAcceptance } from '@aragon-agent/tui/model/todo/acceptance';
5
+ import { isValidNoteId } from '../memory/paths.js';
6
+ import { FOLLOW_UP_META_LIMITS } from './limits.js';
5
7
  import { validateCompactionIdentity } from '../compaction/memory-identity.js';
6
8
  import { MemoryError } from '../compaction/memory.js';
7
9
  import { GOVERNANCE_CARD_FALLBACK_TEXT, normalizeGovernanceCard } from '../governance/card-normalize.js';
@@ -285,6 +287,7 @@ export function validateSession(value) {
285
287
  }
286
288
  // Missing fields remain missing in old files, including exec metadata.
287
289
  const prepared = { ...source };
290
+ prepared.meta = sanitizeSessionMeta(source.meta);
288
291
  if (source.todos !== undefined) {
289
292
  prepared.todos = normalizeTodos(source.todos, TODO_LIMITS.maxItems).items;
290
293
  }
@@ -294,9 +297,135 @@ export function validateSession(value) {
294
297
  if (source.acceptance !== undefined) {
295
298
  prepared.acceptance = normalizeAcceptance(source.acceptance, [], { enabled: true }).items;
296
299
  }
300
+ // THE MEMORY STATE IS VALIDATED LENIENTLY (agent-memory 5.5): a hand-edited or newer file with a
301
+ // malformed field loses THAT field, never the whole conversation. Only note ids and the three
302
+ // small enums survive; the service drops ids that no longer exist when it restores.
303
+ if (source.memory !== undefined)
304
+ prepared.memory = sanitizeMemoryState(source.memory);
305
+ // TWO NAMED CASES, NOT A GLOBAL LOOSENING (RV-5 / C-4). `shape()` above does not declare these
306
+ // two fields at all, so a wrong TYPE would ride the spread untouched; the alternative - declaring
307
+ // them as `boolean`/`number` - makes a hand-edited `redTeam: "yes"` throw
308
+ // `Invalid session file: ... must be a boolean`, and `loadSession` then refuses the WHOLE
309
+ // conversation. For a session POSTURE that is a punishment out of all proportion to the mistake:
310
+ // losing a mode costs one keystroke, losing the conversation costs the work. So each field is
311
+ // read on its own and dropped if it cannot be read; every other field's strictness is unchanged.
312
+ const armed = readTolerantBoolean(source.redTeam);
313
+ if (armed === undefined)
314
+ delete prepared.redTeam;
315
+ else
316
+ prepared.redTeam = armed;
317
+ const waiver = readTolerantCount(source.redTeamWaiverVersion);
318
+ if (waiver === undefined)
319
+ delete prepared.redTeamWaiverVersion;
320
+ else
321
+ prepared.redTeamWaiverVersion = waiver;
297
322
  prepared.entries = sanitizeGovernanceEntries(sanitizeEntryAcceptance(prepared.entries));
298
323
  return prepared;
299
324
  }
325
+ /** A boolean, or `undefined`. Anything else reads as "the file did not say". */
326
+ function readTolerantBoolean(value) {
327
+ if (value === true)
328
+ return true;
329
+ if (value === false)
330
+ return false;
331
+ return undefined;
332
+ }
333
+ /** A non-negative integer, or `undefined`. Anything else reads as "the file did not say". */
334
+ function readTolerantCount(value) {
335
+ if (typeof value !== 'number' || !Number.isFinite(value) || value < 0)
336
+ return undefined;
337
+ return Math.floor(value);
338
+ }
339
+ /**
340
+ * `meta`, repaired field by field - and `meta.followUp` in particular (desktop-follow-up-panel
341
+ * 8.3).
342
+ *
343
+ * A SESSION FILE IS AN INPUT. `meta` used to be passed through untouched because nothing but
344
+ * `writeSession` ever produced one; a follow-up anchor is 4000 characters of user-visible text
345
+ * that reaches a SYSTEM PROMPT, so it is now checked here rather than trusted downstream. The
346
+ * failure mode being prevented is not a crash - it is a hand-edited file quietly turning into
347
+ * instructions in a child session's prompt.
348
+ *
349
+ * A BAD ANCHOR DROPS THE ANCHOR, NOT THE FILE (8.3): the session degrades to an ordinary one
350
+ * with no excerpt. Losing a conversation to protect a footnote would be the worse trade.
351
+ */
352
+ function sanitizeSessionMeta(raw) {
353
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
354
+ return raw;
355
+ const meta = { ...raw };
356
+ if (meta.followUp === undefined)
357
+ return meta;
358
+ const followUp = sanitizeFollowUpMeta(meta.followUp);
359
+ if (followUp)
360
+ meta.followUp = followUp;
361
+ else
362
+ delete meta.followUp;
363
+ return meta;
364
+ }
365
+ function sanitizeFollowUpMeta(raw) {
366
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
367
+ return undefined;
368
+ const src = raw;
369
+ if (typeof src.parentId !== 'string' || src.parentId.length === 0)
370
+ return undefined;
371
+ const anchor = sanitizeFollowUpAnchor(src.anchor);
372
+ if (!anchor)
373
+ return undefined;
374
+ const seedSource = src.seedSource === 'excerpt' ? 'excerpt' : 'history';
375
+ const omitted = typeof src.omittedTurns === 'number' && Number.isFinite(src.omittedTurns)
376
+ ? Math.min(FOLLOW_UP_META_LIMITS.maxOmittedTurns, Math.max(0, Math.floor(src.omittedTurns)))
377
+ : 0;
378
+ return { parentId: src.parentId, anchor, seedSource, omittedTurns: omitted };
379
+ }
380
+ function sanitizeFollowUpAnchor(raw) {
381
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw))
382
+ return undefined;
383
+ const src = raw;
384
+ if (typeof src.text !== 'string' || src.text.length === 0)
385
+ return undefined;
386
+ if (src.text.length > FOLLOW_UP_META_LIMITS.excerptChars)
387
+ return undefined;
388
+ if (typeof src.entryKind !== 'string' || src.entryKind.length > FOLLOW_UP_META_LIMITS.entryKindChars) {
389
+ return undefined;
390
+ }
391
+ const entryId = typeof src.entryId === 'string' && src.entryId.length > 0 ? src.entryId : null;
392
+ return {
393
+ entryId,
394
+ entryKind: src.entryKind,
395
+ text: src.text,
396
+ truncated: src.truncated === true,
397
+ charStart: finiteOrZero(src.charStart),
398
+ charEnd: finiteOrZero(src.charEnd),
399
+ streaming: src.streaming === true,
400
+ };
401
+ }
402
+ /** A character offset that is not a finite non-negative number reads as 0, never as NaN. */
403
+ function finiteOrZero(value) {
404
+ return typeof value === 'number' && Number.isFinite(value) && value >= 0 ? Math.floor(value) : 0;
405
+ }
406
+ /** The memory fields a session file may carry, reduced to the shape the service accepts. */
407
+ function sanitizeMemoryState(raw) {
408
+ if (raw === null || typeof raw !== 'object')
409
+ return undefined;
410
+ const src = raw;
411
+ const overrides = {};
412
+ if (src.overrides && typeof src.overrides === 'object') {
413
+ for (const [id, value] of Object.entries(src.overrides)) {
414
+ if (Object.keys(overrides).length >= 400)
415
+ break;
416
+ if (isValidNoteId(id) && (value === 'mount' || value === 'unmount'))
417
+ overrides[id] = value;
418
+ }
419
+ }
420
+ const autoload = typeof src.autoload === 'boolean' ? src.autoload : null;
421
+ // Authority never travels in a file (agent-memory I-19): a hand-edited or foreign session
422
+ // must not be able to turn write approval off, so only the stricter value survives.
423
+ const agentWrites = src.agentWrites === 'ask' ? 'ask' : null;
424
+ if (autoload === null && agentWrites === null && Object.keys(overrides).length === 0) {
425
+ return undefined;
426
+ }
427
+ return { autoload, overrides, agentWrites };
428
+ }
300
429
  /**
301
430
  * Repair every governance card the file carries, or degrade it to a one-line notice.
302
431
  *
@@ -65,6 +65,17 @@ export interface TeamRuntimeDeps {
65
65
  sourceNames: string[];
66
66
  }) => void;
67
67
  humanQueue?: TeamHumanQueue;
68
+ /**
69
+ * The lead's red team bypass predicate and its audit sink, forwarded to every child
70
+ * (red-team-security-mode D-16 / RV-2).
71
+ *
72
+ * ABSENT ON EVERY NON-RED-TEAM SESSION, which keeps `SubagentDeps` the object it was - the
73
+ * conditional-spread discipline the four lines below record, applied to a security control.
74
+ */
75
+ confirmBypass?: SubagentDeps['confirmBypass'];
76
+ onConfirmBypass?: SubagentDeps['onConfirmBypass'];
77
+ /** The child's trimmed `<redteam_mode>` block, forwarded; absent means no block. */
78
+ redteamBlock?: SubagentDeps['redteamBlock'];
68
79
  /**
69
80
  * The lead's caller-approval gate, one instance per child (headless-host-bridge
70
81
  * section 2.3.7). Absent outside bridge mode, which is what keeps a dispatch's
@@ -501,6 +501,12 @@ export class TeamRuntime {
501
501
  : {}),
502
502
  confirmTools: config.confirmTools,
503
503
  ...(this.deps.humanQueue ? { humanQueue: this.deps.humanQueue } : {}),
504
+ // SITE TWO OF TWO for the red team predicate, in the shape every line around it records:
505
+ // declared on `TeamRuntimeDeps` and forgotten here, a child would keep its own bypass
506
+ // closed (or worse, the lead's open) with nothing to report it (RV-2 / R-5).
507
+ ...(this.deps.confirmBypass ? { confirmBypass: this.deps.confirmBypass } : {}),
508
+ ...(this.deps.onConfirmBypass ? { onConfirmBypass: this.deps.onConfirmBypass } : {}),
509
+ ...(this.deps.redteamBlock ? { redteamBlock: this.deps.redteamBlock } : {}),
504
510
  // Site two of two, in the same shape as the policy and compaction lines
505
511
  // around it: declaring it on `TeamRuntimeDeps` and forgetting this line
506
512
  // type-checks and forwards nothing, and the failure is silent - every child
@@ -97,6 +97,27 @@ export interface SubagentDeps {
97
97
  sourceNames: string[];
98
98
  }) => void;
99
99
  confirmTools: boolean;
100
+ /**
101
+ * The lead's red team bypass predicate, passed DOWN rather than shared
102
+ * (red-team-security-mode D-16 / RV-2).
103
+ *
104
+ * IT CANNOT BE INHERITED AUTOMATICALLY, and v1 assumed it could: this module builds its OWN
105
+ * `confirm` closure two fields above (`humanQueue.request`), not the lead's, so "the same
106
+ * wrapper is in place" is false. Without this predicate one `task` call walks around the arm
107
+ * state, and a child that writes files then runs with a permission the session says it has
108
+ * switched off - a hole rather than a switch (R-5).
109
+ */
110
+ confirmBypass?: () => boolean;
111
+ /** The audit sink for a bypassed child call; same contract as the lead's. */
112
+ onConfirmBypass?: (tool: string) => void;
113
+ /**
114
+ * The child's trimmed `<redteam_mode>` block, or `''` (D-8 / D-16).
115
+ *
116
+ * A FUNCTION because the block changes with the posture and the scope, and a child is built
117
+ * per dispatch. Absent on every session without the mode, which is what keeps a child's
118
+ * system prompt byte-identical to today's (I-1).
119
+ */
120
+ redteamBlock?: () => string;
100
121
  /** Present only when `--confirm` is on AND a human channel exists. */
101
122
  humanQueue?: TeamHumanQueue;
102
123
  agentFactory: SubagentAgentFactory;
@@ -91,6 +91,10 @@ getModel) {
91
91
  const built = createBuiltinTools({
92
92
  getCwd: deps.getCwd,
93
93
  confirmTools: deps.confirmTools,
94
+ // THE EXPLICIT HAND-OVER (RV-2): the child's own confirm closure is built below, so the
95
+ // bypass has to be passed as a PREDICATE, not assumed to arrive with the wrapper.
96
+ ...(deps.confirmBypass ? { confirmBypass: deps.confirmBypass } : {}),
97
+ ...(deps.onConfirmBypass ? { onConfirmBypass: deps.onConfirmBypass } : {}),
94
98
  // Only when BOTH halves exist; either missing and the child's `read_file` is the old one.
95
99
  ...(imageSupportFor && getModel
96
100
  ? {
@@ -304,6 +308,9 @@ export function createSubagent(spec, deps, hooks) {
304
308
  ...(spec.governance && deps.governanceRoleBlockFor
305
309
  ? { governanceRoleBlock: deps.governanceRoleBlockFor(spec) }
306
310
  : {}),
311
+ // THE CHILD'S HALF OF THE RED TEAM INHERITANCE (D-8 / D-16). `''` for every session without
312
+ // the mode, and `buildSystemPrompt` splices conditionally, so those prompts are unchanged.
313
+ ...(deps.redteamBlock ? { redteamBlock: deps.redteamBlock() } : {}),
307
314
  });
308
315
  // LAZY ACCESSORS OVER `agentRef`, WHICH IS ASSIGNED AFTER THIS RETURNS. A
309
316
  // non-lazy read here is `undefined` at construction and the child's estimate
@@ -81,6 +81,30 @@ export interface BuiltinToolsOptions {
81
81
  confirmTools?: boolean;
82
82
  /** Awaited before a mutating tool runs; resolve `false` to cancel. */
83
83
  confirm?: (req: ConfirmRequest) => Promise<boolean>;
84
+ /**
85
+ * Read AT CALL TIME: red team mode is armed and its bypass applies
86
+ * (red-team-security-mode 4.5 / I-5).
87
+ *
88
+ * A FUNCTION, NOT A BOOLEAN. The tool array is fixed once `new Agent(...)` returns, so a
89
+ * boolean would turn this feature into "active from the next launch"; `armed` changes on a
90
+ * keystroke.
91
+ *
92
+ * IT IS READ IN EXACTLY ONE PLACE (`withConfirmation`) AND NOWHERE ELSE. Plan mode's gate and
93
+ * the governance gate are wrapped OUTSIDE it, so an armed + PLAN turn never reaches the code
94
+ * that consults this - a structural guarantee rather than a promise (I-6 / R-4).
95
+ *
96
+ * Omitting it (every caller but `AgentController`) leaves the confirm wrapper exactly as it
97
+ * was, which is what keeps every other host's tool behaviour byte-identical.
98
+ */
99
+ confirmBypass?: () => boolean;
100
+ /**
101
+ * Called once per BYPASSED call with the tool's name, never its arguments.
102
+ *
103
+ * This is the audit trail that answers "what did it run without asking me", and the reason it
104
+ * is a callback rather than a `getLogger()` call here: `tools/` has no logger import, and the
105
+ * controller already owns the `redteam.*` event vocabulary (D-9 / R-12).
106
+ */
107
+ onConfirmBypass?: (tool: string) => void;
84
108
  /**
85
109
  * `skill` / `skill_install` / `skill_create`, appended verbatim.
86
110
  *
@@ -205,6 +229,17 @@ export interface BuiltinToolsOptions {
205
229
  * to the pre-feature build.
206
230
  */
207
231
  jobTools?: AgentTool[];
232
+ /**
233
+ * `memory_search` / `memory_read` / `memory_write`, appended verbatim (agent-memory 7.1).
234
+ *
235
+ * THROUGH THE FACTORY FOR THE REASON `jobTools` RECORDS: `tools.test.ts::C7` asserts
236
+ * `HOST_TOOL_NAMES` equals what this factory PRODUCES, so appending them in
237
+ * `AgentController` afterwards would turn that test red with a message about two lists of
238
+ * names. SPREAD CONDITIONALLY by the caller: with memory off (or headless, or a subagent)
239
+ * the options bag has no such key and the tool array is the one built before this feature
240
+ * existed, which is provable by identity (I-2).
241
+ */
242
+ memoryTools?: AgentTool[];
208
243
  /**
209
244
  * `submit_result`, appended verbatim when the caller supplied `--result-schema`
210
245
  * (headless-request-scope-and-typed-result section 2.3.9).
@@ -403,7 +438,7 @@ export declare function gatedToolTimeouts(toolTimeoutMs: number, decisionBudgetM
403
438
  * is the whole of what this mechanism is worth, and saying so plainly beats
404
439
  * implying it covers more.
405
440
  */
406
- export declare const SKILL_TOOL_FLOOR: readonly ["read_file", "list_dir", "glob", "grep", "skill", "skill_find", "ask_user", "submit_plan", "task", "todo_write", "bash_output", "job_wait", "job_list"];
441
+ export declare const SKILL_TOOL_FLOOR: readonly ["read_file", "list_dir", "glob", "grep", "skill", "skill_find", "ask_user", "submit_plan", "task", "todo_write", "bash_output", "job_wait", "job_list", "memory_search", "memory_read"];
407
442
  /**
408
443
  * The five tools plan mode refuses: exactly the complement of `SKILL_TOOL_FLOOR`
409
444
  * within `HOST_TOOL_NAMES` — "the five that change something", the set this file
@@ -436,5 +471,13 @@ export declare const PLAN_MODE_BLOCKED_TOOLS: ReadonlySet<string>;
436
471
  * declaration MEANS, and that reading must not change with how the CLI was
437
472
  * started.
438
473
  */
439
- export declare const HOST_TOOL_NAMES: readonly ["read_file", "write_file", "edit_file", "list_dir", "glob", "grep", "bash", "skill", "skill_find", "skill_install", "skill_create", "ask_user", "submit_plan", "todo_write", "bash_output", "bash_kill", "job_wait", "job_list", "submit_result", "task"];
474
+ export declare const HOST_TOOL_NAMES: readonly ["read_file", "write_file", "edit_file", "list_dir", "glob", "grep", "bash", "skill", "skill_find", "skill_install", "skill_create", "ask_user", "submit_plan", "todo_write", "bash_output", "bash_kill", "job_wait", "job_list", "memory_search", "memory_read", "memory_write", "submit_result", "task"];
475
+ /**
476
+ * The three memory tools, as one constant (agent-memory 7.1).
477
+ *
478
+ * Exported so `exec/bridge/server.ts` can SUBTRACT it from its reserved-name set: the
479
+ * headless path never registers these tools, so reserving their names would only reject
480
+ * caller tools that are perfectly legitimate (`memory_search` is a very common name).
481
+ */
482
+ export declare const MEMORY_TOOL_NAMES: readonly ["memory_search", "memory_read", "memory_write"];
440
483
  export declare function createBuiltinTools(options: BuiltinToolsOptions): AgentTool[];
@@ -125,6 +125,13 @@ export const SKILL_TOOL_FLOOR = [
125
125
  // mode the user is actually in.
126
126
  'job_wait',
127
127
  'job_list',
128
+ // `memory_search` / `memory_read` join the FLOOR for the reason `job_wait` did: reading
129
+ // the user's saved notes cannot write to disk, and a skill whose `allowed-tools` omits
130
+ // them would otherwise be unable to consult memory at all. `memory_write` is the
131
+ // opposite: it writes to disk, so it belongs to the BLOCKED set below. The partition
132
+ // test makes both choices conscious (agent-memory D-8).
133
+ 'memory_search',
134
+ 'memory_read',
128
135
  ];
129
136
  /**
130
137
  * The five tools plan mode refuses: exactly the complement of `SKILL_TOOL_FLOOR`
@@ -148,6 +155,11 @@ export const PLAN_MODE_BLOCKED_TOOLS = new Set([
148
155
  // is dead-ended by it: `Ctrl+C` and `/bg stop` both remain available to the
149
156
  // USER in plan mode, so the person can always stop what the agent started.
150
157
  'bash_kill',
158
+ // `memory_write` WRITES TO DISK (agent-memory D-8): the floor's membership test is "cannot
159
+ // write", so it is blocked in plan mode like `write_file`. Nothing dead-ends: the user can
160
+ // still save with Ctrl+M / `/memory save` (a UI action, not a tool call), and the tool's
161
+ // description tells the model to say so.
162
+ 'memory_write',
151
163
  ]);
152
164
  /**
153
165
  * Every tool name this host CAN register (7 built-ins + 4 skill tools).
@@ -197,6 +209,13 @@ export const HOST_TOOL_NAMES = [
197
209
  // (long-task-jobs §4.3).
198
210
  'job_wait',
199
211
  'job_list',
212
+ // The memory names (agent-memory 7.1): in the superset so `allowed-tools: [memory_read]`
213
+ // is answerable by `skills doctor`. REGISTRATION is separate - headless runs and
214
+ // subagents never register them - which is why the `exec` bridge's reserved-name set
215
+ // subtracts `MEMORY_TOOL_NAMES` (RV-5).
216
+ 'memory_search',
217
+ 'memory_read',
218
+ 'memory_write',
200
219
  // `submit_result` (headless-request-scope-and-typed-result section 2.3.9) belongs to
201
220
  // the superset for the reason the two job names above do: a skill's
202
221
  // `allowed-tools: [submit_result]` must be answerable, and `--allow-tool` /
@@ -212,6 +231,14 @@ export const HOST_TOOL_NAMES = [
212
231
  // mechanism answering a different question.
213
232
  'task',
214
233
  ];
234
+ /**
235
+ * The three memory tools, as one constant (agent-memory 7.1).
236
+ *
237
+ * Exported so `exec/bridge/server.ts` can SUBTRACT it from its reserved-name set: the
238
+ * headless path never registers these tools, so reserving their names would only reject
239
+ * caller tools that are perfectly legitimate (`memory_search` is a very common name).
240
+ */
241
+ export const MEMORY_TOOL_NAMES = ['memory_search', 'memory_read', 'memory_write'];
215
242
  function summarize(toolName, params) {
216
243
  if (toolName === 'bash')
217
244
  return `Run: ${String(params.command ?? '')}`;
@@ -221,12 +248,25 @@ function summarize(toolName, params) {
221
248
  return `Edit: ${String(params.path ?? '')}`;
222
249
  return toolName;
223
250
  }
224
- /** Wrap a tool so its execution is gated behind a confirmation callback. */
225
- function withConfirmation(tool, confirm) {
251
+ /**
252
+ * Wrap a tool so its execution is gated behind a confirmation callback.
253
+ *
254
+ * `bypass` IS CHECKED FIRST AND COSTS NO `confirm` CALL (red-team-security-mode 4.5): when it
255
+ * answers true the tool runs immediately and `onBypass` records the fact. The order is the whole
256
+ * contract - a bypass consulted AFTER the dialog had been shown would be a slower way of asking.
257
+ */
258
+ function withConfirmation(tool, confirm, bypass, onBypass) {
226
259
  const original = tool.execute;
227
260
  return {
228
261
  ...tool,
229
262
  async execute(id, params, ctx) {
263
+ if (bypass?.() === true) {
264
+ // THE AUDIT LINE, and it carries the tool name ONLY. Deliberately no arguments: a
265
+ // command line can hold a credential, and this is the one log in the product that is
266
+ // written while a user believes they are not being asked.
267
+ onBypass?.(tool.name);
268
+ return original(id, params, ctx);
269
+ }
230
270
  const approved = await confirm({
231
271
  tool: tool.name,
232
272
  summary: summarize(tool.name, params),
@@ -345,7 +385,11 @@ export function createBuiltinTools(options) {
345
385
  ];
346
386
  if (options.confirmTools && options.confirm) {
347
387
  const confirm = options.confirm;
348
- tools = tools.map((t) => (MUTATING_TOOLS.has(t.name) ? withConfirmation(t, confirm) : t));
388
+ const bypass = options.confirmBypass;
389
+ const onBypass = options.onConfirmBypass;
390
+ tools = tools.map((t) => (MUTATING_TOOLS.has(t.name)
391
+ ? withConfirmation(t, confirm, bypass, onBypass)
392
+ : t));
349
393
  }
350
394
  if (options.skillTools && options.skillTools.length > 0) {
351
395
  tools = [...tools, ...options.skillTools];
@@ -369,6 +413,12 @@ export function createBuiltinTools(options) {
369
413
  if (options.jobTools && options.jobTools.length > 0) {
370
414
  tools = [...tools, ...options.jobTools];
371
415
  }
416
+ // AFTER `jobTools` and BEFORE `resultTool` (agent-memory 7.1): the memory tools are the
417
+ // fourth group of host-side handles, and `HOST_TOOL_NAMES` places them between `job_list`
418
+ // and `submit_result`, so the constant changes by one insertion rather than a reshuffle.
419
+ if (options.memoryTools && options.memoryTools.length > 0) {
420
+ tools = [...tools, ...options.memoryTools];
421
+ }
372
422
  // AFTER `jobTools`, BEFORE `teamTools`: `submit_result` is the answer-shaped sibling
373
423
  // of the plan tools rather than a team tool, and keeping a lead's `task` last means
374
424
  // `HOST_TOOL_NAMES` grows by one insertion instead of a reshuffle
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aragon-agent/cli",
3
- "version": "0.6.53",
3
+ "version": "0.6.55",
4
4
  "description": "AragonAgent CLI — a Claude-Code / Codex-style interactive terminal UI (TUI) on top of the @aragon-agent/core engine. Installable and runnable via npm / npx.",
5
5
  "license": "MIT",
6
6
  "author": "AragonAgent contributors",
@@ -58,8 +58,8 @@
58
58
  "prepublishOnly": "npm run build"
59
59
  },
60
60
  "dependencies": {
61
- "@aragon-agent/core": "^0.2.65",
62
- "@aragon-agent/tui": "0.0.6",
61
+ "@aragon-agent/core": "^0.2.67",
62
+ "@aragon-agent/tui": "0.0.8",
63
63
  "commander": "^12.1.0",
64
64
  "dotenv": "^16.6.1",
65
65
  "env-paths": "^3.0.0",