@aragon-agent/cli 0.6.53 → 0.6.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/README.md +4042 -3982
- package/dist/agent/controller.d.ts +26 -0
- package/dist/agent/controller.js +129 -1
- package/dist/agent/system-prompt.d.ts +14 -0
- package/dist/agent/system-prompt.js +3 -0
- package/dist/app/App.d.ts +7 -0
- package/dist/app/App.js +135 -6
- package/dist/cli.js +25 -1
- package/dist/commands/builtins.js +10 -0
- package/dist/commands/catalog.js +1 -0
- package/dist/commands/registry.d.ts +7 -0
- package/dist/compaction/compactor.d.ts +26 -0
- package/dist/compaction/compactor.js +81 -8
- package/dist/compaction/summarize-call.d.ts +22 -0
- package/dist/compaction/summarize-call.js +29 -0
- package/dist/compaction/wiring.js +22 -3
- package/dist/config/app-paths.d.ts +13 -0
- package/dist/config/app-paths.js +15 -0
- package/dist/config/cli-commands.d.ts +15 -0
- package/dist/config/cli-commands.js +32 -1
- package/dist/config/env.d.ts +1 -0
- package/dist/config/env.js +11 -0
- package/dist/config/load.d.ts +6 -0
- package/dist/config/load.js +10 -1
- package/dist/config/store.js +10 -1
- package/dist/exec/bridge/server.js +9 -2
- package/dist/exec/options.js +16 -2
- package/dist/governance/prompts/orchestrator-block.js +2 -2
- package/dist/host/controller-factory.d.ts +25 -0
- package/dist/host/controller-factory.js +7 -0
- package/dist/host/follow-up-seed.d.ts +109 -0
- package/dist/host/follow-up-seed.js +196 -0
- package/dist/host/follow-up.d.ts +73 -0
- package/dist/host/follow-up.js +123 -0
- package/dist/host/index.d.ts +3 -0
- package/dist/host/index.js +3 -0
- package/dist/host/memory.d.ts +21 -0
- package/dist/host/memory.js +17 -0
- package/dist/host/sessions.d.ts +32 -2
- package/dist/host/sessions.js +40 -2
- package/dist/logging/install.d.ts +1 -0
- package/dist/logging/install.js +4 -0
- package/dist/logging/logger.d.ts +1 -1
- package/dist/memory/block.d.ts +24 -0
- package/dist/memory/block.js +54 -0
- package/dist/memory/command.d.ts +31 -0
- package/dist/memory/command.js +350 -0
- package/dist/memory/format.d.ts +51 -0
- package/dist/memory/format.js +308 -0
- package/dist/memory/paths.d.ts +68 -0
- package/dist/memory/paths.js +172 -0
- package/dist/memory/plan.d.ts +37 -0
- package/dist/memory/plan.js +184 -0
- package/dist/memory/resolve.d.ts +45 -0
- package/dist/memory/resolve.js +54 -0
- package/dist/memory/secrets.d.ts +30 -0
- package/dist/memory/secrets.js +73 -0
- package/dist/memory/service.d.ts +175 -0
- package/dist/memory/service.js +576 -0
- package/dist/memory/store.d.ts +133 -0
- package/dist/memory/store.js +694 -0
- package/dist/memory/tools.d.ts +36 -0
- package/dist/memory/tools.js +527 -0
- package/dist/memory/transfer.d.ts +53 -0
- package/dist/memory/transfer.js +93 -0
- package/dist/session/checkpoint.d.ts +18 -0
- package/dist/session/checkpoint.js +34 -0
- package/dist/session/limits.d.ts +16 -0
- package/dist/session/limits.js +16 -0
- package/dist/session/persist.d.ts +47 -0
- package/dist/session/persist.js +1 -0
- package/dist/session/startup-session.d.ts +6 -0
- package/dist/session/startup-session.js +3 -0
- package/dist/session/store.d.ts +14 -0
- package/dist/session/store.js +18 -0
- package/dist/session/validate-session.js +98 -0
- package/dist/tools/index.d.ts +21 -2
- package/dist/tools/index.js +33 -0
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { formatHomeMigrationNotice, migrateToHome } from './config/migrate-home.
|
|
|
13
13
|
import { migrateStateOutOfConfig } from './config/migrate-state-out-of-config.js';
|
|
14
14
|
import { runHistoryCommand } from './config/history-commands.js';
|
|
15
15
|
import { checkGovernanceCommandLine } from './config/governance-launch.js';
|
|
16
|
-
import { COMPACTION_CONFIG_SET_KEYS, FAST_CONFIG_SET_KEYS, LOG_CONFIG_SET_KEYS, RETRY_CONFIG_SET_KEYS, TEAM_CONFIG_SET_KEYS, GOVERNANCE_CONFIG_SET_KEYS, JOBS_CONFIG_SET_KEYS, TASK_SUMMARY_CONFIG_SET_KEYS, UPDATE_CONFIG_SET_KEYS, applyCompactionConfigSet, applyFastConfigSet, applyLogConfigSet, applyRetryConfigSet, applyTeamConfigSet, applyGovernanceConfigSet, applyJobsConfigSet, applyTaskSummaryConfigSet, applyUpdateConfigSet, runConfigEdit, runConfigGet, runConfigHome, runConfigList, warnIfRedactionDisabled, } from './config/cli-commands.js';
|
|
16
|
+
import { COMPACTION_CONFIG_SET_KEYS, FAST_CONFIG_SET_KEYS, LOG_CONFIG_SET_KEYS, RETRY_CONFIG_SET_KEYS, TEAM_CONFIG_SET_KEYS, GOVERNANCE_CONFIG_SET_KEYS, MEMORY_CONFIG_SET_KEYS, applyMemoryConfigSet, JOBS_CONFIG_SET_KEYS, TASK_SUMMARY_CONFIG_SET_KEYS, UPDATE_CONFIG_SET_KEYS, applyCompactionConfigSet, applyFastConfigSet, applyLogConfigSet, applyRetryConfigSet, applyTeamConfigSet, applyGovernanceConfigSet, applyJobsConfigSet, applyTaskSummaryConfigSet, applyUpdateConfigSet, runConfigEdit, runConfigGet, runConfigHome, runConfigList, warnIfRedactionDisabled, } from './config/cli-commands.js';
|
|
17
17
|
import { attachAgentEvents, attachTeamEvents, installLogging, setScreenRestore, setSignalTerminator, } from './logging/install.js';
|
|
18
18
|
import { getLogger } from './logging/logger.js';
|
|
19
19
|
import { runLogsCommand } from './logging/cli-commands.js';
|
|
@@ -212,6 +212,10 @@ function toFlags(opts) {
|
|
|
212
212
|
govern: opts.govern,
|
|
213
213
|
planGovern: opts.planGovern,
|
|
214
214
|
governance: opts.governance === false ? false : undefined,
|
|
215
|
+
// Site three of three for `--no-memory`, declared alone like `--no-governance`: commander
|
|
216
|
+
// defaults `opts.memory` to `true` when it is absent, so only an explicit `false` is
|
|
217
|
+
// forwarded and silence can never read as an override.
|
|
218
|
+
memory: opts.memory === false ? false : undefined,
|
|
215
219
|
// Site three of three for `--resume` / `--save` -- ELEVEN features, one trap
|
|
216
220
|
// (`mouse` P1-2, `team` P1-4, `todo` C-9, render L4, retry, fast, update,
|
|
217
221
|
// compaction, now session identity). A flag needs the `.option()`
|
|
@@ -1061,6 +1065,10 @@ async function runInteractive(flags, extras = {}) {
|
|
|
1061
1065
|
const terminalBridge = {
|
|
1062
1066
|
mouseSelect: wantSelect,
|
|
1063
1067
|
deleteDisambiguated: filter !== null,
|
|
1068
|
+
// The memory pages tell a user whose `Ctrl+M` is still Enter where to go instead
|
|
1069
|
+
// (agent-memory 9.1, RV2-2). The SAME expression the translation runs under, never a
|
|
1070
|
+
// second derivation: the line is true exactly when the key frame cannot be produced.
|
|
1071
|
+
enhancedKeys: enhancedKeysOn,
|
|
1064
1072
|
scrollbar,
|
|
1065
1073
|
...(mouseOn
|
|
1066
1074
|
? {
|
|
@@ -1466,6 +1474,10 @@ const CONFIG_SET_KEYS = new Set([
|
|
|
1466
1474
|
// and without the matching case in `runConfigSet` the membership set accepts a write
|
|
1467
1475
|
// that never happens.
|
|
1468
1476
|
...GOVERNANCE_CONFIG_SET_KEYS,
|
|
1477
|
+
// `memory.*` keys are handled by `applyMemoryConfigSet`, same reasoning again (agent-memory
|
|
1478
|
+
// spec 5.6): without this line they fall through to `Unknown config key`, and without the
|
|
1479
|
+
// matching case in `runConfigSet` the membership set accepts a write that never happens.
|
|
1480
|
+
...MEMORY_CONFIG_SET_KEYS,
|
|
1469
1481
|
]);
|
|
1470
1482
|
/**
|
|
1471
1483
|
* `aragon config set maxTokens <n|auto|default>`.
|
|
@@ -1646,6 +1658,15 @@ function runConfigSetValue(key, value) {
|
|
|
1646
1658
|
process.stdout.write(`Set ${key} = ${String(merged.governance[field])}\n`);
|
|
1647
1659
|
return;
|
|
1648
1660
|
}
|
|
1661
|
+
const memoryPatch = applyMemoryConfigSet(key, value);
|
|
1662
|
+
if (memoryPatch) {
|
|
1663
|
+
// Echoed from the STORED value, like every section above: `config set
|
|
1664
|
+
// memory.agentWrites banana` prints `ask`, which is what the read path will report.
|
|
1665
|
+
const merged = updatePersistedConfig(memoryPatch);
|
|
1666
|
+
const field = key.slice('memory.'.length);
|
|
1667
|
+
process.stdout.write(`Set ${key} = ${String(merged.memory?.[field])}\n`);
|
|
1668
|
+
return;
|
|
1669
|
+
}
|
|
1649
1670
|
const patch = {};
|
|
1650
1671
|
switch (key) {
|
|
1651
1672
|
case 'provider':
|
|
@@ -2073,6 +2094,9 @@ function buildProgram() {
|
|
|
2073
2094
|
.option('--govern', 'Start in GOVERN posture (a governed team of dev / review / test roles)')
|
|
2074
2095
|
.option('--plan-govern', 'Start in PLAN+GOVERN posture (clarify and plan first, then govern)')
|
|
2075
2096
|
.option('--no-governance', 'Disable governance mode for this launch (not persisted)')
|
|
2097
|
+
// Negative-only for the reason `--no-governance` records: it can only ever switch the
|
|
2098
|
+
// feature off for this launch, and `toFlags` forwards it only when explicitly given.
|
|
2099
|
+
.option('--no-memory', 'Disable agent memory for this launch (no memory tools or prompt block; not persisted)')
|
|
2076
2100
|
.option('--no-skills', 'Disable the skill system entirely (no catalog, no skill tools)')
|
|
2077
2101
|
.option('--skill <name>', 'Force-load a skill at Level 2 for this run (repeatable)', (value, previous = []) => [...previous, value])
|
|
2078
2102
|
.option('--skills-yes', 'Approve skill installs for this run (CI / headless)')
|
|
@@ -25,6 +25,7 @@ import { runBranchCommand } from './branch-command.js';
|
|
|
25
25
|
import { getLogger } from '../logging/logger.js';
|
|
26
26
|
import { registerQueueCommand } from './queue-command.js';
|
|
27
27
|
import { registerPromptCommands } from '../prompts/command.js';
|
|
28
|
+
import { registerMemoryCommands } from '../memory/command.js';
|
|
28
29
|
import { registerKitCommand } from './kit-command.js';
|
|
29
30
|
import { registerAgentsCommand } from './agents-command.js';
|
|
30
31
|
import { registerSubagentCommand } from './subagent-command.js';
|
|
@@ -1174,6 +1175,13 @@ const COMMANDS = [
|
|
|
1174
1175
|
' { key = "Enter", mods = "Shift", chars = "\\u001b[13;2u" }',
|
|
1175
1176
|
' macOS Terminal.app / old conhost cannot rebind Enter; use Ctrl+J',
|
|
1176
1177
|
'',
|
|
1178
|
+
// Ctrl+M rides the SAME keyboard-enhancement channel (agent-memory spec 9.1): in a terminal
|
|
1179
|
+
// that reports modified keys it opens the memory manager; in one that does not, it is the
|
|
1180
|
+
// same byte as Enter. Said here because this is the command a user runs to find out which
|
|
1181
|
+
// kind of terminal they have.
|
|
1182
|
+
'Ctrl+M (memory manager) needs the same enhancement: without it Ctrl+M',
|
|
1183
|
+
'is Enter and submits the draft. Alt+M and /memory work everywhere.',
|
|
1184
|
+
'',
|
|
1177
1185
|
'Windows needs Node >= 22.17 (or >= 24.2): older versions never',
|
|
1178
1186
|
'turn on virtual-terminal input, so no report can arrive.',
|
|
1179
1187
|
'Opt out of the push entirely:',
|
|
@@ -1345,6 +1353,8 @@ export function registerBuiltinCommands(registry) {
|
|
|
1345
1353
|
// REGISTERED UNCONDITIONALLY, even with `prompts.enabled=false` - that is the only
|
|
1346
1354
|
// way the command can report that the feature is off (D-19 / AC-30).
|
|
1347
1355
|
registerPromptCommands(registry);
|
|
1356
|
+
// UNCONDITIONAL, like `/prompts`: with `memory.enabled=false` the command stays and says so.
|
|
1357
|
+
registerMemoryCommands(registry);
|
|
1348
1358
|
// The read-only subagent board (tui-subagent-panel §6.4). Same shape again: the
|
|
1349
1359
|
// body is `commands/agents-command.ts` and the registration is this one line.
|
|
1350
1360
|
registerAgentsCommand(registry);
|
package/dist/commands/catalog.js
CHANGED
|
@@ -43,6 +43,7 @@ export const BUILTIN_COMMAND_CATALOG = [
|
|
|
43
43
|
{ name: 'queue', aliases: [], description: '\u67e5\u770b\u5f85\u5904\u7406\u6d88\u606f\u5168\u6587' },
|
|
44
44
|
{ name: 'kit', aliases: [], description: 'Agent kits: status, list, use for this session' },
|
|
45
45
|
{ name: 'prompts', aliases: [], description: 'Quick prompt library: pick, list, add, edit, remove, reorder' },
|
|
46
|
+
{ name: 'memory', aliases: ['mem'], description: 'Memory manager: list, save, show, remove, mount, auto-load, agent writes' },
|
|
46
47
|
{ name: 'agents', aliases: [], description: 'Open the subagent board: every child, its facts and its timeline' },
|
|
47
48
|
{ name: 'subagent', aliases: [], description: 'Deprecated alias of /team - same arguments' },
|
|
48
49
|
{ name: 'team', aliases: [], description: 'Force team mode and start now: /team <brief>; /team [on [n]|off|status]' },
|
|
@@ -14,6 +14,7 @@ import type { UpdateCommandPort } from '@aragon-agent/tui/model/update/types';
|
|
|
14
14
|
import type { SessionCommandPort } from './session-command.js';
|
|
15
15
|
import type { BranchCommandPort } from './branch-command.js';
|
|
16
16
|
import type { PromptCommandPort } from '@aragon-agent/tui/model/prompts/types';
|
|
17
|
+
import type { MemoryCommandPort } from '@aragon-agent/tui/model/memory/types';
|
|
17
18
|
export interface CommandContext {
|
|
18
19
|
/** App-owned shared lock and single feedback path for command and selection copies. */
|
|
19
20
|
requestCopy?: (request: CopyRequest) => Promise<CopyRequestResult>;
|
|
@@ -187,6 +188,12 @@ export interface CommandContext {
|
|
|
187
188
|
* needs the SHAPE of the port, never a value at run time.
|
|
188
189
|
*/
|
|
189
190
|
prompts?: PromptCommandPort;
|
|
191
|
+
/**
|
|
192
|
+
* The memory manager's two capabilities: whether memory is on, and opening the manager on a page
|
|
193
|
+
* (agent-memory spec 9.5). OPTIONAL for the reason `prompts` above records - `CommandContext` is
|
|
194
|
+
* constructed by literal in dozens of fixtures. TYPE-ONLY import: the command needs the SHAPE.
|
|
195
|
+
*/
|
|
196
|
+
memory?: MemoryCommandPort;
|
|
190
197
|
/**
|
|
191
198
|
* The task label's three capabilities (`/keys`, `/task`; tui-shortcut-drawer-and-
|
|
192
199
|
* task-summary §6.4).
|
|
@@ -100,6 +100,7 @@ export declare class Compactor implements ContextManager {
|
|
|
100
100
|
private pricingUnknown;
|
|
101
101
|
private costUsd;
|
|
102
102
|
private consecutiveNoProgress;
|
|
103
|
+
private consecutiveTransportFailures;
|
|
103
104
|
private selfDisabled;
|
|
104
105
|
private selfDisabledReason;
|
|
105
106
|
private pendingManual;
|
|
@@ -130,6 +131,15 @@ export declare class Compactor implements ContextManager {
|
|
|
130
131
|
private checkMinimumCandidate;
|
|
131
132
|
private digestFor;
|
|
132
133
|
private summarize;
|
|
134
|
+
/**
|
|
135
|
+
* Whether the second attempt moves to the main model.
|
|
136
|
+
*
|
|
137
|
+
* After an unusable answer it always does (a stronger model may do better). After a
|
|
138
|
+
* transport failure it only does when the main model is reached through a DIFFERENT
|
|
139
|
+
* endpoint: against the same one the switch is a no-op that also rebuilds the digest,
|
|
140
|
+
* and the retry should simply be the same request again.
|
|
141
|
+
*/
|
|
142
|
+
private shouldEscalate;
|
|
133
143
|
private callOnce;
|
|
134
144
|
private checkCandidate;
|
|
135
145
|
private isCurrent;
|
|
@@ -166,7 +176,23 @@ export declare class Compactor implements ContextManager {
|
|
|
166
176
|
tokensBefore?: number;
|
|
167
177
|
tokensAfter: number;
|
|
168
178
|
}): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Route one non-applied verdict to the counter that owns it.
|
|
181
|
+
*
|
|
182
|
+
* TWO COUNTERS, NOT ONE (compaction-network-error-fetch-failed RC-3 / B'-2). A failure
|
|
183
|
+
* to reach the summarizer says nothing about the history, so it must not be the first
|
|
184
|
+
* strike of the 2-strike `stuckLimit` - but it cannot be free either: `maxPerRun`
|
|
185
|
+
* resets on every run, so without its own ceiling a persistently unreachable endpoint
|
|
186
|
+
* would raise a red card on every run and never pause. The transport check comes
|
|
187
|
+
* BEFORE the `abort|cancel|stale` filter because a cause string can contain "abort"
|
|
188
|
+
* (`UND_ERR_ABORTED`) and the reverse order would let it bypass both counters.
|
|
189
|
+
* Cancellations leave both counters alone; any other failure got an answer from the
|
|
190
|
+
* summarizer, which proves the path works, so the transport streak ends.
|
|
191
|
+
*/
|
|
192
|
+
private noteFailure;
|
|
193
|
+
private noteTransportFailure;
|
|
169
194
|
private noteNoProgress;
|
|
195
|
+
private selfDisable;
|
|
170
196
|
measure(_probe: Pick<CompactionProbe, 'lastUsage'> & {
|
|
171
197
|
messages?: readonly Message[];
|
|
172
198
|
systemPrompt?: string;
|
|
@@ -5,7 +5,7 @@ import { resolveFastTier } from '@aragon-agent/tui/model/fast/resolve';
|
|
|
5
5
|
import { COMPACTION_LIMITS } from '@aragon-agent/tui/model/compaction/limits';
|
|
6
6
|
import { buildDigest } from './digest.js';
|
|
7
7
|
import { buildCompactedBlock, countProtectedPrefix } from './summary-prompt.js';
|
|
8
|
-
import { accumulateUsage, errorText, runSummarizeCall, buildSummarizeRequest } from './summarize-call.js';
|
|
8
|
+
import { accumulateUsage, describeTransportFailure, errorText, runSummarizeCall, buildSummarizeRequest, TRANSPORT_FAILURE_CODE, } from './summarize-call.js';
|
|
9
9
|
import { shouldCompactAt } from '@aragon-agent/tui/model/compaction/pressure';
|
|
10
10
|
import { ContextMeter } from '@aragon-agent/tui/model/compaction/meter';
|
|
11
11
|
import { CompactionOperation } from './operation.js';
|
|
@@ -13,7 +13,7 @@ import { prepareMemoryInput } from './memory-input.js';
|
|
|
13
13
|
import { mergeMemory, parseMemoryDelta } from './memory.js';
|
|
14
14
|
import { validateMemoryDelta } from './memory-validation.js';
|
|
15
15
|
import { renderMemoryMarkdown } from './memory-render.js';
|
|
16
|
-
import { compactionReasonLine } from '@aragon-agent/tui/model/compaction/reason-text';
|
|
16
|
+
import { compactionReasonCode, compactionReasonLine, } from '@aragon-agent/tui/model/compaction/reason-text';
|
|
17
17
|
import { createCompactionIdentity, verifyCompactionIdentity, } from './memory-identity.js';
|
|
18
18
|
export class Compactor {
|
|
19
19
|
deps;
|
|
@@ -28,6 +28,7 @@ export class Compactor {
|
|
|
28
28
|
pricingUnknown = false;
|
|
29
29
|
costUsd = 0;
|
|
30
30
|
consecutiveNoProgress = 0;
|
|
31
|
+
consecutiveTransportFailures = 0;
|
|
31
32
|
selfDisabled = false;
|
|
32
33
|
selfDisabledReason;
|
|
33
34
|
pendingManual = null;
|
|
@@ -253,21 +254,34 @@ export class Compactor {
|
|
|
253
254
|
async summarize(state, input, selected, instructions) {
|
|
254
255
|
let choice = selected.choice;
|
|
255
256
|
let digest = selected.digest;
|
|
257
|
+
// WHAT THE NEXT ATTEMPT IS TOLD WENT WRONG: only a rejection of the model's own
|
|
258
|
+
// output. A request that never got an answer (`transportFailure`) is a different
|
|
259
|
+
// fact and is tracked apart - framing it as "Previous delta rejected" told a model
|
|
260
|
+
// that had never seen the earlier request to correct an error it did not make
|
|
261
|
+
// (compaction-network-error-fetch-failed RC-4).
|
|
256
262
|
let previousError;
|
|
263
|
+
let transportFailure = null;
|
|
257
264
|
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
258
265
|
if (state.operation.signal.aborted)
|
|
259
266
|
throw new Error('aborted');
|
|
260
|
-
if (attempt > 0) {
|
|
267
|
+
if (attempt > 0 && this.shouldEscalate(choice, transportFailure)) {
|
|
261
268
|
choice = this.mainChoice();
|
|
262
269
|
digest = this.digestFor(input, choice, instructions);
|
|
263
270
|
}
|
|
264
|
-
const
|
|
271
|
+
const answer = await this.callOnce(state, choice, {
|
|
265
272
|
digest: digest.text, hasPriorSummary: !!input.prior,
|
|
266
273
|
...(instructions ? { instructions } : {}),
|
|
267
274
|
...(previousError ? { validationError: previousError } : {}),
|
|
268
|
-
}).
|
|
275
|
+
}).then((reply) => ({ text: reply, transport: null }), (error) => {
|
|
276
|
+
const transport = describeTransportFailure(error, state.operation.signal);
|
|
277
|
+
if (transport === null)
|
|
278
|
+
previousError = errorText(error);
|
|
279
|
+
return { text: null, transport };
|
|
280
|
+
});
|
|
281
|
+
transportFailure = answer.transport;
|
|
269
282
|
if (state.operation.signal.aborted)
|
|
270
283
|
throw new Error(previousError ?? 'aborted');
|
|
284
|
+
const text = answer.text;
|
|
271
285
|
if (text === null)
|
|
272
286
|
continue;
|
|
273
287
|
try {
|
|
@@ -282,8 +296,28 @@ export class Compactor {
|
|
|
282
296
|
throw error;
|
|
283
297
|
}
|
|
284
298
|
}
|
|
299
|
+
// THE LAST ATTEMPT'S KIND DECIDES THE REASON: a failure to reach the summarizer must
|
|
300
|
+
// settle as `summarizer_unreachable` even when an earlier attempt got an unusable
|
|
301
|
+
// answer, otherwise it would be counted as "no progress" and push toward a pause.
|
|
302
|
+
if (transportFailure !== null)
|
|
303
|
+
throw new Error(transportFailure);
|
|
285
304
|
throw new Error(previousError ?? 'invalid_memory_delta');
|
|
286
305
|
}
|
|
306
|
+
/**
|
|
307
|
+
* Whether the second attempt moves to the main model.
|
|
308
|
+
*
|
|
309
|
+
* After an unusable answer it always does (a stronger model may do better). After a
|
|
310
|
+
* transport failure it only does when the main model is reached through a DIFFERENT
|
|
311
|
+
* endpoint: against the same one the switch is a no-op that also rebuilds the digest,
|
|
312
|
+
* and the retry should simply be the same request again.
|
|
313
|
+
*/
|
|
314
|
+
shouldEscalate(current, transportFailure) {
|
|
315
|
+
if (transportFailure === null)
|
|
316
|
+
return true;
|
|
317
|
+
const main = this.mainChoice();
|
|
318
|
+
return current.ref.providerId !== main.ref.providerId ||
|
|
319
|
+
(current.ref.baseUrl ?? '') !== (main.ref.baseUrl ?? '');
|
|
320
|
+
}
|
|
287
321
|
async callOnce(state, choice, input) {
|
|
288
322
|
const apiKey = this.deps.getApiKey(choice.ref.providerId, choice.role);
|
|
289
323
|
if (!apiKey)
|
|
@@ -427,6 +461,8 @@ export class Compactor {
|
|
|
427
461
|
this.generation = state.generation ?? this.generation;
|
|
428
462
|
this.appliedCompactions += 1;
|
|
429
463
|
this.recordApplied(verdict.tokensBefore ?? state.pressure.occupied, verdict.tokensAfter);
|
|
464
|
+
// A summary came back, so the path to the summarizer works.
|
|
465
|
+
this.consecutiveTransportFailures = 0;
|
|
430
466
|
this.meter().onHistorySpliced();
|
|
431
467
|
const projected = (verdict.tokensAfter + (state.pressure.estimateOffset ?? 0)) /
|
|
432
468
|
state.pressure.contextWindow;
|
|
@@ -437,9 +473,7 @@ export class Compactor {
|
|
|
437
473
|
this.noteNoProgress(state.trigger, 'insufficient_reclaim');
|
|
438
474
|
}
|
|
439
475
|
else {
|
|
440
|
-
|
|
441
|
-
if (!/abort|cancel|stale/.test(reason))
|
|
442
|
-
this.noteNoProgress(state.trigger, reason);
|
|
476
|
+
this.noteFailure(state.trigger, verdict.reason ?? state.reason ?? 'invalid_history');
|
|
443
477
|
}
|
|
444
478
|
this.log.info('compaction_settled', {
|
|
445
479
|
operationId: state.operation.id, trigger: state.trigger, applied: verdict.applied,
|
|
@@ -450,12 +484,50 @@ export class Compactor {
|
|
|
450
484
|
});
|
|
451
485
|
return true;
|
|
452
486
|
}
|
|
487
|
+
/**
|
|
488
|
+
* Route one non-applied verdict to the counter that owns it.
|
|
489
|
+
*
|
|
490
|
+
* TWO COUNTERS, NOT ONE (compaction-network-error-fetch-failed RC-3 / B'-2). A failure
|
|
491
|
+
* to reach the summarizer says nothing about the history, so it must not be the first
|
|
492
|
+
* strike of the 2-strike `stuckLimit` - but it cannot be free either: `maxPerRun`
|
|
493
|
+
* resets on every run, so without its own ceiling a persistently unreachable endpoint
|
|
494
|
+
* would raise a red card on every run and never pause. The transport check comes
|
|
495
|
+
* BEFORE the `abort|cancel|stale` filter because a cause string can contain "abort"
|
|
496
|
+
* (`UND_ERR_ABORTED`) and the reverse order would let it bypass both counters.
|
|
497
|
+
* Cancellations leave both counters alone; any other failure got an answer from the
|
|
498
|
+
* summarizer, which proves the path works, so the transport streak ends.
|
|
499
|
+
*/
|
|
500
|
+
noteFailure(trigger, reason) {
|
|
501
|
+
if (compactionReasonCode(reason) === TRANSPORT_FAILURE_CODE) {
|
|
502
|
+
this.noteTransportFailure(trigger, reason);
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
if (/abort|cancel|stale/.test(reason))
|
|
506
|
+
return;
|
|
507
|
+
if (trigger !== 'manual')
|
|
508
|
+
this.consecutiveTransportFailures = 0;
|
|
509
|
+
this.noteNoProgress(trigger, reason);
|
|
510
|
+
}
|
|
511
|
+
noteTransportFailure(trigger, reason) {
|
|
512
|
+
if (trigger === 'manual')
|
|
513
|
+
return;
|
|
514
|
+
// `compactionsThisRun` is deliberately NOT refunded: it is what bounds how long one
|
|
515
|
+
// run can be held by failing attempts.
|
|
516
|
+
this.consecutiveTransportFailures += 1;
|
|
517
|
+
if (this.consecutiveTransportFailures < COMPACTION_LIMITS.transportStuckLimit ||
|
|
518
|
+
this.selfDisabled)
|
|
519
|
+
return;
|
|
520
|
+
this.selfDisable(trigger, reason);
|
|
521
|
+
}
|
|
453
522
|
noteNoProgress(trigger, reason) {
|
|
454
523
|
if (trigger === 'manual')
|
|
455
524
|
return;
|
|
456
525
|
this.consecutiveNoProgress += 1;
|
|
457
526
|
if (this.consecutiveNoProgress < COMPACTION_LIMITS.stuckLimit || this.selfDisabled)
|
|
458
527
|
return;
|
|
528
|
+
this.selfDisable(trigger, reason);
|
|
529
|
+
}
|
|
530
|
+
selfDisable(trigger, reason) {
|
|
459
531
|
this.selfDisabled = true;
|
|
460
532
|
this.selfDisabledReason = reason;
|
|
461
533
|
// THE LOG LINE IS BACK ON PURPOSE (C / analysis 3.3.1 (c)). Commit 4b61a2f8a
|
|
@@ -483,6 +555,7 @@ export class Compactor {
|
|
|
483
555
|
this.selfDisabled = false;
|
|
484
556
|
this.selfDisabledReason = undefined;
|
|
485
557
|
this.consecutiveNoProgress = 0;
|
|
558
|
+
this.consecutiveTransportFailures = 0;
|
|
486
559
|
}
|
|
487
560
|
isSelfDisabled() { return this.selfDisabled; }
|
|
488
561
|
resolveSummarizer() {
|
|
@@ -3,6 +3,28 @@ import type { AssistantMessage, LLMRequest, ModelRef, TokenUsage } from '@aragon
|
|
|
3
3
|
/** The assistant text of a completion, or `''` for an answer with no text block. */
|
|
4
4
|
export declare function assistantText(message: AssistantMessage | undefined): string;
|
|
5
5
|
export declare function errorText(err: unknown): string;
|
|
6
|
+
/** The stable reason code of a summarization whose request never got an answer. */
|
|
7
|
+
export declare const TRANSPORT_FAILURE_CODE = "summarizer_unreachable";
|
|
8
|
+
/**
|
|
9
|
+
* `summarizer_unreachable: <message>` when `err` is a transport failure, else `null`.
|
|
10
|
+
*
|
|
11
|
+
* THE QUESTION IS "DID THE REQUEST GET A MODEL ANSWER AT ALL" - it decides whether the
|
|
12
|
+
* failure says anything about the history or the summarizer's output (it does not), so
|
|
13
|
+
* it must not feed `validationError`, escalate to another model, or count as "no
|
|
14
|
+
* progress" (compaction-network-error-fetch-failed RC-3 / RC-4).
|
|
15
|
+
*
|
|
16
|
+
* THE ORDER IS THE SEMANTICS:
|
|
17
|
+
* 1. An aborted signal is never a transport failure. `wrapFetchError` marks a user
|
|
18
|
+
* Esc `retryable`, so blaming the network for it would be wrong twice over
|
|
19
|
+
* (`core/llm/retry.ts` applies the same ordering).
|
|
20
|
+
* 2. Only `errorType === 'network_error'` qualifies, read structurally rather than
|
|
21
|
+
* with `instanceof` (the same error can come from a second copy of core). A 429 or
|
|
22
|
+
* 5xx reached the provider and says something about quota or load, so those keep
|
|
23
|
+
* counting as no-progress; a local `timeout` aborts the whole operation anyway.
|
|
24
|
+
*
|
|
25
|
+
* The message already carries the cause (`wrapFetchError`), so it is not re-derived here.
|
|
26
|
+
*/
|
|
27
|
+
export declare function describeTransportFailure(err: unknown, signal: AbortSignal): string | null;
|
|
6
28
|
/**
|
|
7
29
|
* The call's spend.
|
|
8
30
|
*
|
|
@@ -14,6 +14,35 @@ export function assistantText(message) {
|
|
|
14
14
|
export function errorText(err) {
|
|
15
15
|
return err instanceof Error ? err.message : String(err);
|
|
16
16
|
}
|
|
17
|
+
/** The stable reason code of a summarization whose request never got an answer. */
|
|
18
|
+
export const TRANSPORT_FAILURE_CODE = 'summarizer_unreachable';
|
|
19
|
+
/**
|
|
20
|
+
* `summarizer_unreachable: <message>` when `err` is a transport failure, else `null`.
|
|
21
|
+
*
|
|
22
|
+
* THE QUESTION IS "DID THE REQUEST GET A MODEL ANSWER AT ALL" - it decides whether the
|
|
23
|
+
* failure says anything about the history or the summarizer's output (it does not), so
|
|
24
|
+
* it must not feed `validationError`, escalate to another model, or count as "no
|
|
25
|
+
* progress" (compaction-network-error-fetch-failed RC-3 / RC-4).
|
|
26
|
+
*
|
|
27
|
+
* THE ORDER IS THE SEMANTICS:
|
|
28
|
+
* 1. An aborted signal is never a transport failure. `wrapFetchError` marks a user
|
|
29
|
+
* Esc `retryable`, so blaming the network for it would be wrong twice over
|
|
30
|
+
* (`core/llm/retry.ts` applies the same ordering).
|
|
31
|
+
* 2. Only `errorType === 'network_error'` qualifies, read structurally rather than
|
|
32
|
+
* with `instanceof` (the same error can come from a second copy of core). A 429 or
|
|
33
|
+
* 5xx reached the provider and says something about quota or load, so those keep
|
|
34
|
+
* counting as no-progress; a local `timeout` aborts the whole operation anyway.
|
|
35
|
+
*
|
|
36
|
+
* The message already carries the cause (`wrapFetchError`), so it is not re-derived here.
|
|
37
|
+
*/
|
|
38
|
+
export function describeTransportFailure(err, signal) {
|
|
39
|
+
if (signal.aborted)
|
|
40
|
+
return null;
|
|
41
|
+
const errorType = err?.errorType;
|
|
42
|
+
if (errorType !== 'network_error')
|
|
43
|
+
return null;
|
|
44
|
+
return `${TRANSPORT_FAILURE_CODE}: ${errorText(err)}`;
|
|
45
|
+
}
|
|
17
46
|
/**
|
|
18
47
|
* The call's spend.
|
|
19
48
|
*
|
|
@@ -6,14 +6,33 @@ import { createChildContextManager } from './child.js';
|
|
|
6
6
|
import { Compactor } from './compactor.js';
|
|
7
7
|
import { ContextMeter } from '@aragon-agent/tui/model/compaction/meter';
|
|
8
8
|
/**
|
|
9
|
-
*
|
|
10
|
-
* (D-10).
|
|
9
|
+
* At most three retries inside 18 s - bounded, and not the user's ten (D-10).
|
|
11
10
|
*
|
|
12
11
|
* Inheriting the user's `/retry` policy would let a background repair compete
|
|
13
12
|
* with the user's own work for a rate-limited provider's quota, and it would put
|
|
14
13
|
* up to ten backoffs inside a window the idle watchdog is PAUSED across.
|
|
14
|
+
*
|
|
15
|
+
* WHY MORE THAN THE ONE RETRY THIS USED TO BE (compaction-network-error-fetch-failed
|
|
16
|
+
* C-lite). A dropped connection never reaches the provider, so retrying it spends no
|
|
17
|
+
* quota, and on the reporting machine outages come in bursts (median 11 s) that four
|
|
18
|
+
* tries in two summarize attempts could not ride out. The budget is the wall clock,
|
|
19
|
+
* not the count: `maxElapsedMs` makes `decide()` stop with `budget_exhausted` once the
|
|
20
|
+
* next wait would not fit, which also bounds the quota concern - a 429 whose
|
|
21
|
+
* `Retry-After` exceeds the remaining budget is raised at once instead of waited out.
|
|
22
|
+
*
|
|
23
|
+
* THE NUMBERS ARE COUPLED TO TWO CEILINGS THIS FILE DOES NOT OWN, and
|
|
24
|
+
* `compaction-wiring.test.ts` pins them. One call must finish inside
|
|
25
|
+
* `COMPACTION_LIMITS.callTimeoutMs` (45 s) even when every failed try takes the slow
|
|
26
|
+
* ~12 s observed, i.e. `2 x 12 s + maxElapsedMs < 45 s`; a call that crosses it is cut
|
|
27
|
+
* as `timeout`, which ends the WHOLE operation. And two such calls (90 s) must fit in
|
|
28
|
+
* core's engine-level `COMPACTION_HARD_TIMEOUT_MS` (120 s), which reports
|
|
29
|
+
* `manager_timeout` - a code with no wording that counts as "no progress". Raising
|
|
30
|
+
* `maxRetries` alone is therefore worse than not raising it. Do not touch the timeouts
|
|
31
|
+
* in `limits.ts` to make room; the 120 s ceiling is not configurable from here.
|
|
15
32
|
*/
|
|
16
|
-
const COMPACTION_RETRY_POLICY = {
|
|
33
|
+
const COMPACTION_RETRY_POLICY = {
|
|
34
|
+
...DEFAULT_RETRY_POLICY, maxRetries: 3, maxElapsedMs: 18_000,
|
|
35
|
+
};
|
|
17
36
|
/** The status of a session that never had compaction (the wiring is `null`). */
|
|
18
37
|
export function offCompactionSnapshot() {
|
|
19
38
|
return {
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* ├── logs/ JSONL logs (0700 on POSIX)
|
|
22
22
|
* ├── sessions/ /save · /resume
|
|
23
23
|
* ├── skills/ `aragon skills install` target
|
|
24
|
+
* ├── memory/ agent memory: one Markdown file per note (0700 / 0600 on POSIX)
|
|
24
25
|
* └── skill-usage.json
|
|
25
26
|
*
|
|
26
27
|
* The two files added by config-state-separation are DIRECT CHILDREN of the
|
|
@@ -161,6 +162,18 @@ export declare function getCompactionArchiveDir(): string;
|
|
|
161
162
|
* The caller creates it (0700 on POSIX); this function only names it.
|
|
162
163
|
*/
|
|
163
164
|
export declare function getGovernanceDir(): string;
|
|
165
|
+
/**
|
|
166
|
+
* `<home>/memory` - agent memory (agent-memory spec 5.1).
|
|
167
|
+
*
|
|
168
|
+
* ITS OWN ROOT, for the reason `getCompactionArchiveDir` and `getGovernanceDir` record:
|
|
169
|
+
* `logs/`, `sessions/` and `skills/` are scan roots, and every extra directory inside one
|
|
170
|
+
* is another thing each walk has to recognise and skip. Derived from the same
|
|
171
|
+
* `resolution.root`, so the `ARAGON_HOME` / VITEST isolation contract at the top of this
|
|
172
|
+
* file covers it too: a test that clears `getMemoryDir()` recursively would be deleting a
|
|
173
|
+
* real user's notes, so tests delete single files or directories they built themselves.
|
|
174
|
+
* The caller creates it (0700 on POSIX); this function only names it.
|
|
175
|
+
*/
|
|
176
|
+
export declare function getMemoryDir(): string;
|
|
164
177
|
/** `<home>` — parent of `skills/`, and where sidecar state such as usage lives. */
|
|
165
178
|
export declare function getUserDataDir(): string;
|
|
166
179
|
export declare function getUserSkillsDir(): string;
|
package/dist/config/app-paths.js
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
* ├── logs/ JSONL logs (0700 on POSIX)
|
|
22
22
|
* ├── sessions/ /save · /resume
|
|
23
23
|
* ├── skills/ `aragon skills install` target
|
|
24
|
+
* ├── memory/ agent memory: one Markdown file per note (0700 / 0600 on POSIX)
|
|
24
25
|
* └── skill-usage.json
|
|
25
26
|
*
|
|
26
27
|
* The two files added by config-state-separation are DIRECT CHILDREN of the
|
|
@@ -254,6 +255,20 @@ export function getCompactionArchiveDir() {
|
|
|
254
255
|
export function getGovernanceDir() {
|
|
255
256
|
return join(resolution.root, 'governance');
|
|
256
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* `<home>/memory` - agent memory (agent-memory spec 5.1).
|
|
260
|
+
*
|
|
261
|
+
* ITS OWN ROOT, for the reason `getCompactionArchiveDir` and `getGovernanceDir` record:
|
|
262
|
+
* `logs/`, `sessions/` and `skills/` are scan roots, and every extra directory inside one
|
|
263
|
+
* is another thing each walk has to recognise and skip. Derived from the same
|
|
264
|
+
* `resolution.root`, so the `ARAGON_HOME` / VITEST isolation contract at the top of this
|
|
265
|
+
* file covers it too: a test that clears `getMemoryDir()` recursively would be deleting a
|
|
266
|
+
* real user's notes, so tests delete single files or directories they built themselves.
|
|
267
|
+
* The caller creates it (0700 on POSIX); this function only names it.
|
|
268
|
+
*/
|
|
269
|
+
export function getMemoryDir() {
|
|
270
|
+
return join(resolution.root, 'memory');
|
|
271
|
+
}
|
|
257
272
|
/** `<home>` — parent of `skills/`, and where sidecar state such as usage lives. */
|
|
258
273
|
export function getUserDataDir() {
|
|
259
274
|
return resolution.root;
|
|
@@ -101,6 +101,11 @@ export declare const COMPACTION_CONFIG_SET_KEYS: readonly ["compaction.enabled",
|
|
|
101
101
|
* Every key is writable and ONE level deep, so `runConfigGet`'s single-dot split resolves it.
|
|
102
102
|
*/
|
|
103
103
|
export declare const GOVERNANCE_CONFIG_SET_KEYS: readonly ["governance.enabled", "governance.shiftTab", "governance.panel", "governance.profile", "governance.maxWorkPackages", "governance.maxPhases", "governance.maxRework", "governance.maxFixCycles", "governance.minAskRounds", "governance.budgetTokens", "governance.confirmCharter"];
|
|
104
|
+
/**
|
|
105
|
+
* Config keys under `memory.` that `aragon config set` accepts (agent-memory spec 5.6).
|
|
106
|
+
* Every key is writable and ONE level deep, so `runConfigGet`'s single-dot split resolves it.
|
|
107
|
+
*/
|
|
108
|
+
export declare const MEMORY_CONFIG_SET_KEYS: readonly ["memory.enabled", "memory.autoload", "memory.agentWrites", "memory.indexMaxChars", "memory.bodyBudgetChars", "memory.perBodyMaxChars"];
|
|
104
109
|
/**
|
|
105
110
|
* Translate a `log.*` dotted key into a patch, or `null` for anything else.
|
|
106
111
|
*
|
|
@@ -149,6 +154,16 @@ export declare function applyTaskSummaryConfigSet(key: string, value: string): P
|
|
|
149
154
|
* `governance` (the ninth time that trap is recorded in `store.ts`).
|
|
150
155
|
*/
|
|
151
156
|
export declare function applyGovernanceConfigSet(key: string, value: string): Partial<PersistedConfig> | null;
|
|
157
|
+
/**
|
|
158
|
+
* Translate a `memory.*` dotted key into a patch, or `null` for anything else.
|
|
159
|
+
*
|
|
160
|
+
* EVERY KEY ROUTES THROUGH `clampMemoryConfig`, so `config set memory.agentWrites banana`
|
|
161
|
+
* stores `ask` (the safe direction) and the caller echoes the STORED value. A numeric
|
|
162
|
+
* argument that does not parse becomes `NaN`, which the clamp repairs to the default.
|
|
163
|
+
* The patch is a PARTIAL section, safe only because `updatePersistedConfig` deep-merges
|
|
164
|
+
* `memory` (the tenth time that trap is recorded in `store.ts`).
|
|
165
|
+
*/
|
|
166
|
+
export declare function applyMemoryConfigSet(key: string, value: string): Partial<PersistedConfig> | null;
|
|
152
167
|
/**
|
|
153
168
|
* Translate a `team.*` dotted key into a patch, or `null` for anything else.
|
|
154
169
|
*
|
|
@@ -14,7 +14,7 @@ import { getConfigBackupPath, getConfigPath, getHomeRoot, getLogsDir, getPromptH
|
|
|
14
14
|
import { getHomeMigrationBreadcrumbPath } from './migrate-home.js';
|
|
15
15
|
import { loadPersistedConfig, updatePersistedConfig } from './store.js';
|
|
16
16
|
import { normalizeModelProfiles, validateModelProfiles } from '@aragon-agent/tui/model/config/model-profiles';
|
|
17
|
-
import { clampFastConfig, clampRetryConfig, clampCompactionConfig, clampTeamConfig, parseThresholdInput, clampUpdateConfig, coercePositiveInt, maskSecret, DEFAULT_FAST_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_TEAM_CONFIG, DEFAULT_COMPACTION_CONFIG, DEFAULT_UPDATE_CONFIG, DEFAULT_JOBS_CONFIG, clampJobsConfig, clampGovernanceConfig, DEFAULT_GOVERNANCE_CONFIG, } from '@aragon-agent/tui/model/config/schema';
|
|
17
|
+
import { clampFastConfig, clampRetryConfig, clampCompactionConfig, clampTeamConfig, parseThresholdInput, clampUpdateConfig, coercePositiveInt, maskSecret, DEFAULT_FAST_CONFIG, DEFAULT_RETRY_CONFIG, DEFAULT_TEAM_CONFIG, DEFAULT_COMPACTION_CONFIG, DEFAULT_UPDATE_CONFIG, DEFAULT_JOBS_CONFIG, clampJobsConfig, clampGovernanceConfig, clampMemoryConfig, DEFAULT_GOVERNANCE_CONFIG, DEFAULT_MEMORY_CONFIG, } from '@aragon-agent/tui/model/config/schema';
|
|
18
18
|
import { clampLogLevel } from '@aragon-agent/tui/model/logging/levels';
|
|
19
19
|
/** Config keys under `log.` that `aragon config set` accepts. */
|
|
20
20
|
export const LOG_CONFIG_SET_KEYS = [
|
|
@@ -184,6 +184,18 @@ export const GOVERNANCE_CONFIG_SET_KEYS = [
|
|
|
184
184
|
'governance.budgetTokens',
|
|
185
185
|
'governance.confirmCharter',
|
|
186
186
|
];
|
|
187
|
+
/**
|
|
188
|
+
* Config keys under `memory.` that `aragon config set` accepts (agent-memory spec 5.6).
|
|
189
|
+
* Every key is writable and ONE level deep, so `runConfigGet`'s single-dot split resolves it.
|
|
190
|
+
*/
|
|
191
|
+
export const MEMORY_CONFIG_SET_KEYS = [
|
|
192
|
+
'memory.enabled',
|
|
193
|
+
'memory.autoload',
|
|
194
|
+
'memory.agentWrites',
|
|
195
|
+
'memory.indexMaxChars',
|
|
196
|
+
'memory.bodyBudgetChars',
|
|
197
|
+
'memory.perBodyMaxChars',
|
|
198
|
+
];
|
|
187
199
|
function isTrue(value) {
|
|
188
200
|
return value === 'true' || value === '1';
|
|
189
201
|
}
|
|
@@ -292,6 +304,25 @@ export function applyGovernanceConfigSet(key, value) {
|
|
|
292
304
|
const clamped = clampGovernanceConfig({ ...DEFAULT_GOVERNANCE_CONFIG, [field]: typed });
|
|
293
305
|
return { governance: { [field]: clamped[field] } };
|
|
294
306
|
}
|
|
307
|
+
/**
|
|
308
|
+
* Translate a `memory.*` dotted key into a patch, or `null` for anything else.
|
|
309
|
+
*
|
|
310
|
+
* EVERY KEY ROUTES THROUGH `clampMemoryConfig`, so `config set memory.agentWrites banana`
|
|
311
|
+
* stores `ask` (the safe direction) and the caller echoes the STORED value. A numeric
|
|
312
|
+
* argument that does not parse becomes `NaN`, which the clamp repairs to the default.
|
|
313
|
+
* The patch is a PARTIAL section, safe only because `updatePersistedConfig` deep-merges
|
|
314
|
+
* `memory` (the tenth time that trap is recorded in `store.ts`).
|
|
315
|
+
*/
|
|
316
|
+
export function applyMemoryConfigSet(key, value) {
|
|
317
|
+
if (!MEMORY_CONFIG_SET_KEYS.includes(key))
|
|
318
|
+
return null;
|
|
319
|
+
const field = key.slice('memory.'.length);
|
|
320
|
+
const trimmed = value.trim();
|
|
321
|
+
const kind = typeof DEFAULT_MEMORY_CONFIG[field];
|
|
322
|
+
const typed = kind === 'boolean' ? isTrue(trimmed) : kind === 'number' ? (trimmed === '' ? Number.NaN : Number(trimmed)) : trimmed;
|
|
323
|
+
const clamped = clampMemoryConfig({ ...DEFAULT_MEMORY_CONFIG, [field]: typed });
|
|
324
|
+
return { memory: { [field]: clamped[field] } };
|
|
325
|
+
}
|
|
295
326
|
function parseGovernanceArgument(field, value) {
|
|
296
327
|
const kind = typeof DEFAULT_GOVERNANCE_CONFIG[field];
|
|
297
328
|
const trimmed = value.trim();
|
package/dist/config/env.d.ts
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* ARAGON_JOBS_ENABLED, ARAGON_JOBS_WAIT_SECONDS, ARAGON_JOBS_STALL_SECONDS,
|
|
23
23
|
* ARAGON_JOBS_PERSIST_LOG, ARAGON_JOBS_NOTICE_STEER,
|
|
24
24
|
* ARAGON_PROMPTS (the quick-prompt library's `enabled` switch, and only that),
|
|
25
|
+
* ARAGON_MEMORY (agent memory's kill switch: `0` turns it off, nothing turns it on),
|
|
25
26
|
* ARAGON_GOVERNANCE (a KILL switch: `0` disables governance mode, nothing enables it).
|
|
26
27
|
*
|
|
27
28
|
* READ ELSEWHERE, ON PURPOSE: `ARAGON_UPDATE_REGISTRY` and `npm_config_registry`
|
package/dist/config/env.js
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
* ARAGON_JOBS_ENABLED, ARAGON_JOBS_WAIT_SECONDS, ARAGON_JOBS_STALL_SECONDS,
|
|
23
23
|
* ARAGON_JOBS_PERSIST_LOG, ARAGON_JOBS_NOTICE_STEER,
|
|
24
24
|
* ARAGON_PROMPTS (the quick-prompt library's `enabled` switch, and only that),
|
|
25
|
+
* ARAGON_MEMORY (agent memory's kill switch: `0` turns it off, nothing turns it on),
|
|
25
26
|
* ARAGON_GOVERNANCE (a KILL switch: `0` disables governance mode, nothing enables it).
|
|
26
27
|
*
|
|
27
28
|
* READ ELSEWHERE, ON PURPOSE: `ARAGON_UPDATE_REGISTRY` and `npm_config_registry`
|
|
@@ -337,6 +338,16 @@ export function readEnvConfig() {
|
|
|
337
338
|
if (isGovernanceEnvDisabled(process.env)) {
|
|
338
339
|
partial.governance = { enabled: false };
|
|
339
340
|
}
|
|
341
|
+
// ARAGON_MEMORY=0 is the agent-memory KILL switch (agent-memory spec 5.6): it can only
|
|
342
|
+
// switch `enabled` OFF, and it outranks the config file. Like `ARAGON_GOVERNANCE` it is
|
|
343
|
+
// not a toggle - `ARAGON_MEMORY=1` writes nothing, so an environment variable can never
|
|
344
|
+
// re-enable what the user's config or `--no-memory` turned off, and it can never reach
|
|
345
|
+
// `agentWrites`: an env var that silently let the model write to persistent memory
|
|
346
|
+
// would not be a kill switch.
|
|
347
|
+
const memory = process.env.ARAGON_MEMORY?.trim().toLowerCase();
|
|
348
|
+
if (memory === '0' || memory === 'false' || memory === 'off' || memory === 'no') {
|
|
349
|
+
partial.memory = { enabled: false };
|
|
350
|
+
}
|
|
340
351
|
// ARAGON_TASK_SUMMARY is the header label's kill switch
|
|
341
352
|
// (tui-shortcut-drawer-and-task-summary §4.8 / P2-7), and it maps `enabled` and
|
|
342
353
|
// NOTHING ELSE - the same wording and the same reason as the block above. A
|
package/dist/config/load.d.ts
CHANGED
|
@@ -255,6 +255,12 @@ export interface CliFlags {
|
|
|
255
255
|
* never written to the store.
|
|
256
256
|
*/
|
|
257
257
|
governance?: boolean;
|
|
258
|
+
/**
|
|
259
|
+
* `--no-memory`, carried as `false` ONLY, for the reason `governance` above records: a
|
|
260
|
+
* lone negative flag makes commander default its option to `true`, so `cli.tsx` forwards
|
|
261
|
+
* `undefined` for silence. Launch-only: never written to the store.
|
|
262
|
+
*/
|
|
263
|
+
memory?: boolean;
|
|
258
264
|
/**
|
|
259
265
|
* `--resume <id|path>` - continue a saved session under a NEW id
|
|
260
266
|
* (tui-session-id-resume 4).
|