@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.
- package/CHANGELOG.md +64 -0
- package/README.md +135 -6
- package/dist/agent/controller.d.ts +98 -0
- package/dist/agent/controller.js +341 -1
- package/dist/agent/redteam-prompt.d.ts +47 -0
- package/dist/agent/redteam-prompt.js +161 -0
- package/dist/agent/redteam-wiring.d.ts +159 -0
- package/dist/agent/redteam-wiring.js +349 -0
- package/dist/agent/system-prompt.d.ts +27 -0
- package/dist/agent/system-prompt.js +10 -0
- package/dist/app/App.d.ts +17 -1
- package/dist/app/App.js +266 -26
- package/dist/app/use-redteam-mode.d.ts +56 -0
- package/dist/app/use-redteam-mode.js +121 -0
- package/dist/cli.js +78 -4
- package/dist/commands/builtins.js +49 -1
- package/dist/commands/catalog.js +5 -0
- package/dist/commands/index-build.js +2 -1
- package/dist/commands/redteam-command.d.ts +22 -0
- package/dist/commands/redteam-command.js +141 -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 +3 -1
- package/dist/config/env.js +23 -1
- package/dist/config/load.d.ts +18 -0
- package/dist/config/load.js +19 -1
- package/dist/config/redteam-launch.d.ts +77 -0
- package/dist/config/redteam-launch.js +58 -0
- package/dist/config/store.js +20 -1
- package/dist/config/ui-state.d.ts +44 -0
- package/dist/config/ui-state.js +38 -0
- 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 +33 -0
- package/dist/host/controller-factory.js +14 -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 +33 -0
- package/dist/session/checkpoint.js +52 -0
- package/dist/session/limits.d.ts +16 -0
- package/dist/session/limits.js +16 -0
- package/dist/session/persist.d.ts +68 -0
- package/dist/session/persist.js +11 -0
- package/dist/session/startup-session.d.ts +17 -2
- package/dist/session/startup-session.js +15 -2
- package/dist/session/store.d.ts +14 -0
- package/dist/session/store.js +18 -0
- package/dist/session/validate-session.js +129 -0
- package/dist/team/runtime.d.ts +11 -0
- package/dist/team/runtime.js +6 -0
- package/dist/team/subagent.d.ts +21 -0
- package/dist/team/subagent.js +7 -0
- package/dist/tools/index.d.ts +45 -2
- package/dist/tools/index.js +53 -3
- package/package.json +3 -3
- package/skills/project-indexer/SKILL.md +275 -147
- package/skills/project-indexer/templates/artifact-hygiene-template.md +14 -0
- package/skills/project-indexer/templates/config-template.md +12 -0
- package/skills/project-indexer/templates/index-template.md +4 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Export and import of notes (agent-memory spec 5.7, P1).
|
|
3
|
+
*
|
|
4
|
+
* ASCII ONLY - `src/memory/**` is inside `glyphs.test.ts::inScope`.
|
|
5
|
+
*
|
|
6
|
+
* PURE: text in, text or drafts out. The caller does the file I/O, and the WRITES go through the
|
|
7
|
+
* service (so `store.ts` stays the only code that writes under the memory directory, I-12).
|
|
8
|
+
*
|
|
9
|
+
* WHAT TRAVELS: scope, title, summary, tags, load, enabled and body - and nothing that identifies
|
|
10
|
+
* a file on THIS machine. No id, no rev, no history, no path. An import mints fresh ids and never
|
|
11
|
+
* overwrites an existing note, so importing the same file twice yields two copies rather than a
|
|
12
|
+
* silent replacement, and a hand-edited export cannot aim at somebody's existing id.
|
|
13
|
+
*
|
|
14
|
+
* AN IMPORT IS A TRUST BOUNDARY: the file may come from anyone. Every note is validated by the same
|
|
15
|
+
* `validateMemoryDraft` the editor uses, the secret sniffer still applies (an imported note is
|
|
16
|
+
* refused, not confirmed), and the file itself is bounded in size and note count.
|
|
17
|
+
*/
|
|
18
|
+
import { validateMemoryDraft } from '@aragon-agent/tui/model/memory/validate';
|
|
19
|
+
export const TRANSFER_SCHEMA = 1;
|
|
20
|
+
/** An import file bigger than this is refused before it is parsed. */
|
|
21
|
+
export const MAX_IMPORT_BYTES = 2 * 1024 * 1024;
|
|
22
|
+
/** More notes than two scopes can hold; the rest of a bigger file is ignored and counted. */
|
|
23
|
+
export const MAX_IMPORT_NOTES = 400;
|
|
24
|
+
/** The text of an export file for `notes`. Stable field order; one trailing newline. */
|
|
25
|
+
export function buildExport(notes, now) {
|
|
26
|
+
const file = {
|
|
27
|
+
schema: TRANSFER_SCHEMA,
|
|
28
|
+
exportedAt: new Date(now).toISOString(),
|
|
29
|
+
notes: notes.map((note) => ({
|
|
30
|
+
scope: note.scope,
|
|
31
|
+
title: note.title,
|
|
32
|
+
// A derived summary is not exported as if the user wrote it: it is re-derived on import.
|
|
33
|
+
summary: note.summaryDerived ? '' : note.summary,
|
|
34
|
+
tags: [...note.tags],
|
|
35
|
+
load: note.load,
|
|
36
|
+
enabled: note.enabled,
|
|
37
|
+
body: note.body,
|
|
38
|
+
})),
|
|
39
|
+
};
|
|
40
|
+
return `${JSON.stringify(file, null, 2)}\n`;
|
|
41
|
+
}
|
|
42
|
+
function asRecord(value) {
|
|
43
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
44
|
+
? value
|
|
45
|
+
: null;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Parse an export file into validated drafts. NEVER throws. Project-scope notes are kept as
|
|
49
|
+
* `project` here; the service files them under the CURRENT project.
|
|
50
|
+
*/
|
|
51
|
+
export function parseImport(text) {
|
|
52
|
+
const empty = { drafts: [], skipped: 0, ignored: 0 };
|
|
53
|
+
if (Buffer.byteLength(text, 'utf-8') > MAX_IMPORT_BYTES)
|
|
54
|
+
return { ...empty, failure: 'too_large' };
|
|
55
|
+
let parsed;
|
|
56
|
+
try {
|
|
57
|
+
parsed = JSON.parse(text.replace(/^\uFEFF/, ''));
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
return { ...empty, failure: 'not_json' };
|
|
61
|
+
}
|
|
62
|
+
const file = asRecord(parsed);
|
|
63
|
+
if (file === null || file.schema !== TRANSFER_SCHEMA || !Array.isArray(file.notes)) {
|
|
64
|
+
return { ...empty, failure: 'bad_schema' };
|
|
65
|
+
}
|
|
66
|
+
const drafts = [];
|
|
67
|
+
let skipped = 0;
|
|
68
|
+
const entries = file.notes;
|
|
69
|
+
for (const entry of entries.slice(0, MAX_IMPORT_NOTES)) {
|
|
70
|
+
const note = asRecord(entry);
|
|
71
|
+
if (note === null) {
|
|
72
|
+
skipped += 1;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
const tags = Array.isArray(note.tags)
|
|
76
|
+
? note.tags.filter((tag) => typeof tag === 'string')
|
|
77
|
+
: [];
|
|
78
|
+
const verdict = validateMemoryDraft({
|
|
79
|
+
title: typeof note.title === 'string' ? note.title : '',
|
|
80
|
+
summary: typeof note.summary === 'string' ? note.summary : '',
|
|
81
|
+
body: typeof note.body === 'string' ? note.body : '',
|
|
82
|
+
tags: tags.join(','),
|
|
83
|
+
load: note.load === 'pinned' || note.load === 'manual' ? note.load : 'auto',
|
|
84
|
+
enabled: note.enabled !== false,
|
|
85
|
+
scope: note.scope === 'global' ? 'global' : 'project',
|
|
86
|
+
});
|
|
87
|
+
if (verdict.ok)
|
|
88
|
+
drafts.push(verdict.input);
|
|
89
|
+
else
|
|
90
|
+
skipped += 1;
|
|
91
|
+
}
|
|
92
|
+
return { drafts, skipped, ignored: Math.max(0, entries.length - MAX_IMPORT_NOTES) };
|
|
93
|
+
}
|
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
import { type Message, type ModelRef } from '@aragon-agent/core';
|
|
33
33
|
import type { Entry, UsageTotal } from '@aragon-agent/tui/model/agent/reducer';
|
|
34
34
|
import type { AcceptanceItem, TodoItem } from '@aragon-agent/tui/model/todo/types';
|
|
35
|
+
import type { MemorySessionState } from '@aragon-agent/tui/model/memory/types';
|
|
35
36
|
import type { CompactionIdentity } from '../compaction/memory-identity.js';
|
|
37
|
+
import { type SessionFollowUpMeta } from './persist.js';
|
|
36
38
|
import { type SessionLockHandle } from './store.js';
|
|
37
39
|
/**
|
|
38
40
|
* What the view side can tell the writer: the identity, the transcript, and this
|
|
@@ -65,6 +67,22 @@ export interface CheckpointDeps {
|
|
|
65
67
|
* every existing test double — keeps compiling and writes no key.
|
|
66
68
|
*/
|
|
67
69
|
readAcceptance?(): AcceptanceItem[];
|
|
70
|
+
/**
|
|
71
|
+
* The memory session state (agent-memory 5.5): mounts, the auto-load switch, the write
|
|
72
|
+
* policy - ids and enums only. OPTIONAL and `undefined` when everything is at its default,
|
|
73
|
+
* so a session that never touched memory writes no key and a file identical to today's.
|
|
74
|
+
*/
|
|
75
|
+
readMemory?(): MemorySessionState | undefined;
|
|
76
|
+
/**
|
|
77
|
+
* Red team mode's armed state and the waiver version it was armed under
|
|
78
|
+
* (red-team-security-mode 4.10). OPTIONAL for the reason `readMemory` is: a caller that has no
|
|
79
|
+
* red team chain writes no key at all, and every existing test double keeps compiling.
|
|
80
|
+
*
|
|
81
|
+
* NOT IN THE CHANGE PLAN, AND HAS TO BE HERE ANYWAY: the spec expected `saveSession` to be one
|
|
82
|
+
* call site, but the TUI's route to it is this writer. Recorded in the spec's
|
|
83
|
+
* implementation findings.
|
|
84
|
+
*/
|
|
85
|
+
readRedTeam?(): RedTeamSessionState | undefined;
|
|
68
86
|
readModel(): ModelRef;
|
|
69
87
|
/** `meta.cwd`; read at every write because `/cwd` can change it. */
|
|
70
88
|
readCwd(): string;
|
|
@@ -77,6 +95,16 @@ export interface CheckpointDeps {
|
|
|
77
95
|
readParentId?(): string | undefined;
|
|
78
96
|
/** `--save <id>` starts the session pinned; `/session pin` sets it later. */
|
|
79
97
|
startPinned?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* The follow-up panel this session belongs to, as a VALUE (desktop-follow-up-panel P1-1).
|
|
100
|
+
*
|
|
101
|
+
* NOT A READER. `createSessionWriter` forwards only the dependencies it names
|
|
102
|
+
* (`controller-factory.ts`), so a `readFollowUp()` that nobody registers is a key that silently
|
|
103
|
+
* never reaches the file - the anchor would simply be missing after a reload with no error
|
|
104
|
+
* anywhere. A value cannot go missing that way: it is either in this bag or it is not, and the
|
|
105
|
+
* desktop host passes it exactly once, when it boots a follow-up.
|
|
106
|
+
*/
|
|
107
|
+
followUp?: SessionFollowUpMeta;
|
|
80
108
|
now?(): number;
|
|
81
109
|
/** The target path; injected so tests point at a temporary directory. */
|
|
82
110
|
pathFor?(id: string): string;
|
|
@@ -262,3 +290,8 @@ export declare class SessionCheckpointWriter {
|
|
|
262
290
|
*/
|
|
263
291
|
private fingerprint;
|
|
264
292
|
}
|
|
293
|
+
/** The armed half of the red team posture, as `saveSession` wants it. */
|
|
294
|
+
export interface RedTeamSessionState {
|
|
295
|
+
armed: boolean;
|
|
296
|
+
waiverVersion?: number;
|
|
297
|
+
}
|
|
@@ -327,6 +327,11 @@ export class SessionCheckpointWriter {
|
|
|
327
327
|
...(this.deps.readAcceptance
|
|
328
328
|
? { acceptance: this.deps.readAcceptance() }
|
|
329
329
|
: {}),
|
|
330
|
+
...memoryField(this.deps.readMemory?.()),
|
|
331
|
+
// The red team posture travels with the checkpoint (red-team-security-mode 4.10), read at
|
|
332
|
+
// WRITE TIME because a user can arm or disarm between two checkpoints. Absent - the whole
|
|
333
|
+
// object - for a session without the chain, so those files are byte-identical to today's.
|
|
334
|
+
...redTeamField(this.deps.readRedTeam?.()),
|
|
330
335
|
meta: this.buildMeta(input),
|
|
331
336
|
};
|
|
332
337
|
try {
|
|
@@ -379,6 +384,9 @@ export class SessionCheckpointWriter {
|
|
|
379
384
|
// still here", and both exit paths know better.
|
|
380
385
|
...(input.reason === 'running' ? { live: true } : {}),
|
|
381
386
|
...(parentId ? { branchOf: parentId } : {}),
|
|
387
|
+
// A follow-up file carries its anchor; an ordinary one writes no key at all, which is
|
|
388
|
+
// what keeps its bytes identical to a file written before this feature (P1-1).
|
|
389
|
+
...(this.deps.followUp ? { followUp: this.deps.followUp } : {}),
|
|
382
390
|
};
|
|
383
391
|
}
|
|
384
392
|
/**
|
|
@@ -456,6 +464,10 @@ export class SessionCheckpointWriter {
|
|
|
456
464
|
// unchanged: that is the one transition a `todos.length` key cannot see.
|
|
457
465
|
this.deps.readAcceptance?.().filter((item) => item.status !== 'pending').length ?? 0,
|
|
458
466
|
this.pinned ? 'pin' : '-',
|
|
467
|
+
// THE FOLLOW-UP DIMENSION (P1-1 / R-14). Without this key, a write whose ONLY change is the
|
|
468
|
+
// follow-up block (a seed that fell back from `history` to `excerpt`) is skipped as
|
|
469
|
+
// "nothing settled", and the file keeps claiming `history` for the rest of the session.
|
|
470
|
+
followUpFingerprint(this.deps.followUp),
|
|
459
471
|
].join('|');
|
|
460
472
|
}
|
|
461
473
|
}
|
|
@@ -518,3 +530,43 @@ function unlinkQuietly(path) {
|
|
|
518
530
|
// Already gone, or a handle still open. Neither is worth failing a run for.
|
|
519
531
|
}
|
|
520
532
|
}
|
|
533
|
+
/**
|
|
534
|
+
* The follow-up block as one comparable string, for `fingerprint()` and nothing else.
|
|
535
|
+
*
|
|
536
|
+
* THE EXCERPT TEXT IS NOT HASHED, only its length: hashing four thousand characters on every write
|
|
537
|
+
* would cost as much as writing the file, which is the one thing `fingerprint()` exists to avoid
|
|
538
|
+
* (K-1). Length plus the three scalars that decide what the panel SHOWS is the right granularity -
|
|
539
|
+
* a seed that fell back to excerpt-only changes `seedSource`, and that is the transition this key
|
|
540
|
+
* has to see.
|
|
541
|
+
*/
|
|
542
|
+
function followUpFingerprint(followUp) {
|
|
543
|
+
if (!followUp)
|
|
544
|
+
return '-';
|
|
545
|
+
return [
|
|
546
|
+
followUp.parentId,
|
|
547
|
+
followUp.seedSource,
|
|
548
|
+
followUp.omittedTurns,
|
|
549
|
+
followUp.anchor.entryKind,
|
|
550
|
+
followUp.anchor.entryId ?? '-',
|
|
551
|
+
followUp.anchor.text.length,
|
|
552
|
+
followUp.anchor.truncated ? 'trunc' : '-',
|
|
553
|
+
].join(',');
|
|
554
|
+
}
|
|
555
|
+
/** `{ memory }` only when there is something to save, so the default state writes no key. */
|
|
556
|
+
function memoryField(state) {
|
|
557
|
+
return state === undefined ? {} : { memory: state };
|
|
558
|
+
}
|
|
559
|
+
/**
|
|
560
|
+
* `{ redTeam, redTeamWaiverVersion }` only while ARMED, so a session that never used the mode
|
|
561
|
+
* writes neither key and its file is byte-identical to one from before the feature (4.10).
|
|
562
|
+
*/
|
|
563
|
+
function redTeamField(state) {
|
|
564
|
+
if (state?.armed !== true)
|
|
565
|
+
return {};
|
|
566
|
+
return {
|
|
567
|
+
redTeam: true,
|
|
568
|
+
...(typeof state.waiverVersion === 'number'
|
|
569
|
+
? { redTeamWaiverVersion: state.waiverVersion }
|
|
570
|
+
: {}),
|
|
571
|
+
};
|
|
572
|
+
}
|
package/dist/session/limits.d.ts
CHANGED
|
@@ -35,6 +35,22 @@ export declare const SESSION_CHECKPOINT_LIMITS: {
|
|
|
35
35
|
/** Consecutive failures before the log record is raised from warn to error. */
|
|
36
36
|
readonly loudFailureStreak: 3;
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Structural bounds for a follow-up panel's persisted anchor (desktop-follow-up-panel D-13).
|
|
40
|
+
*
|
|
41
|
+
* EVERY ENTRY HAS AN ENFORCEMENT POINT, which is this file's standing rule: `excerptChars` and
|
|
42
|
+
* `entryKindChars` are checked by `sanitizeFollowUpMeta` by `validate-session.ts` when a file is
|
|
43
|
+
* read, and `excerptChars` again by the desktop main process when the panel opens. Nothing here
|
|
44
|
+
* is user-tunable.
|
|
45
|
+
*/
|
|
46
|
+
export declare const FOLLOW_UP_META_LIMITS: {
|
|
47
|
+
/** The excerpt that may reach a system prompt. Longer than this and the prompt is unbounded. */
|
|
48
|
+
readonly excerptChars: 4000;
|
|
49
|
+
/** `entryKind` is one of five words; anything longer is not one of them. */
|
|
50
|
+
readonly entryKindChars: 32;
|
|
51
|
+
/** `omittedTurns` is reported to the user; a nonsense number is worse than zero. */
|
|
52
|
+
readonly maxOmittedTurns: 1000000;
|
|
53
|
+
};
|
|
38
54
|
/**
|
|
39
55
|
* Structural bounds for branching a session into a NEW terminal window
|
|
40
56
|
* (tui-branch-terminal-shortcut 5.3).
|
package/dist/session/limits.js
CHANGED
|
@@ -35,6 +35,22 @@ export const SESSION_CHECKPOINT_LIMITS = {
|
|
|
35
35
|
/** Consecutive failures before the log record is raised from warn to error. */
|
|
36
36
|
loudFailureStreak: 3,
|
|
37
37
|
};
|
|
38
|
+
/**
|
|
39
|
+
* Structural bounds for a follow-up panel's persisted anchor (desktop-follow-up-panel D-13).
|
|
40
|
+
*
|
|
41
|
+
* EVERY ENTRY HAS AN ENFORCEMENT POINT, which is this file's standing rule: `excerptChars` and
|
|
42
|
+
* `entryKindChars` are checked by `sanitizeFollowUpMeta` by `validate-session.ts` when a file is
|
|
43
|
+
* read, and `excerptChars` again by the desktop main process when the panel opens. Nothing here
|
|
44
|
+
* is user-tunable.
|
|
45
|
+
*/
|
|
46
|
+
export const FOLLOW_UP_META_LIMITS = {
|
|
47
|
+
/** The excerpt that may reach a system prompt. Longer than this and the prompt is unbounded. */
|
|
48
|
+
excerptChars: 4_000,
|
|
49
|
+
/** `entryKind` is one of five words; anything longer is not one of them. */
|
|
50
|
+
entryKindChars: 32,
|
|
51
|
+
/** `omittedTurns` is reported to the user; a nonsense number is worse than zero. */
|
|
52
|
+
maxOmittedTurns: 1_000_000,
|
|
53
|
+
};
|
|
38
54
|
/**
|
|
39
55
|
* Structural bounds for branching a session into a NEW terminal window
|
|
40
56
|
* (tui-branch-terminal-shortcut 5.3).
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import type { Message, ModelRef } from '@aragon-agent/core';
|
|
9
9
|
import type { Entry } from '@aragon-agent/tui/model/agent/reducer';
|
|
10
|
+
import type { MemorySessionState } from '@aragon-agent/tui/model/memory/types';
|
|
10
11
|
import type { AcceptanceItem, TodoItem } from '@aragon-agent/tui/model/todo/types';
|
|
11
12
|
import { type CompactionIdentity } from '../compaction/memory-identity.js';
|
|
12
13
|
/**
|
|
@@ -59,6 +60,41 @@ export interface SessionMeta {
|
|
|
59
60
|
live?: true;
|
|
60
61
|
/** The id this session branched from (D-5); absent for a fresh or named one. */
|
|
61
62
|
branchOf?: string;
|
|
63
|
+
/**
|
|
64
|
+
* The follow-up panel this session belongs to (desktop-follow-up-panel D-12).
|
|
65
|
+
*
|
|
66
|
+
* THE ANCHOR LIVES HERE, NOT IN `desktop-state.json`: the excerpt is conversation content (up to
|
|
67
|
+
* 4000 characters of it), and keeping it beside the messages is what lets a reloaded window
|
|
68
|
+
* restore the panel with no side channel at all.
|
|
69
|
+
*
|
|
70
|
+
* ADDITIVE AND OPTIONAL, like `todos` and `memory`, so `SESSION_VERSION` stays 1 and an ordinary
|
|
71
|
+
* session file is byte-identical to one written before this feature. `validate-session.ts`
|
|
72
|
+
* repairs an unreadable value into "no follow-up" rather than refusing the file.
|
|
73
|
+
*/
|
|
74
|
+
followUp?: SessionFollowUpMeta;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The parts of a follow-up anchor that survive a round trip through a session file.
|
|
78
|
+
*
|
|
79
|
+
* Deliberately NARROWER than the wire shape (`FollowUpAnchorInput`): the viewport rectangle that
|
|
80
|
+
* decided where to put the panel is a property of one screen, and `meta` is history.
|
|
81
|
+
*/
|
|
82
|
+
export interface SessionFollowUpAnchorMeta {
|
|
83
|
+
entryId: string | null;
|
|
84
|
+
entryKind: string;
|
|
85
|
+
/** At most `FOLLOW_UP_LIMITS.excerptChars`; a longer value drops the anchor, not the file. */
|
|
86
|
+
text: string;
|
|
87
|
+
truncated: boolean;
|
|
88
|
+
charStart: number;
|
|
89
|
+
charEnd: number;
|
|
90
|
+
streaming: boolean;
|
|
91
|
+
}
|
|
92
|
+
export interface SessionFollowUpMeta {
|
|
93
|
+
parentId: string;
|
|
94
|
+
anchor: SessionFollowUpAnchorMeta;
|
|
95
|
+
/** `'history'` = the parent's tail came along; `'excerpt'` = the degraded, excerpt-only start. */
|
|
96
|
+
seedSource: 'history' | 'excerpt';
|
|
97
|
+
omittedTurns: number;
|
|
62
98
|
}
|
|
63
99
|
export interface SavedSession {
|
|
64
100
|
version: number;
|
|
@@ -88,6 +124,15 @@ export interface SavedSession {
|
|
|
88
124
|
* criterion is being checked.
|
|
89
125
|
*/
|
|
90
126
|
acceptance?: AcceptanceItem[];
|
|
127
|
+
/**
|
|
128
|
+
* The memory session state at save time (agent-memory spec 5.5 / D-12): which notes the user
|
|
129
|
+
* mounted or unmounted, the auto-load switch, the agent-write policy.
|
|
130
|
+
*
|
|
131
|
+
* ADDITIVE AND OPTIONAL, like `todos` and `acceptance`, so `SESSION_VERSION` stays 1 and an
|
|
132
|
+
* older file simply restores the defaults. IDS ONLY, NEVER TEXT (I-18): a checkpoint is
|
|
133
|
+
* rewritten constantly and can be shared, and the notes already live in their own files.
|
|
134
|
+
*/
|
|
135
|
+
memory?: MemorySessionState;
|
|
91
136
|
/**
|
|
92
137
|
* Written by `aragon exec` (cli-integration-surface §5.2 / D-10) AND by the
|
|
93
138
|
* TUI's session checkpoint (tui-session-id-resume §6.1).
|
|
@@ -100,6 +145,21 @@ export interface SavedSession {
|
|
|
100
145
|
* one, and is told apart from an exec file by `meta.origin`.
|
|
101
146
|
*/
|
|
102
147
|
meta?: SessionMeta;
|
|
148
|
+
/**
|
|
149
|
+
* Red team mode was ARMED at save time (red-team-security-mode 4.10).
|
|
150
|
+
*
|
|
151
|
+
* ADDITIVE AND OPTIONAL, so `SESSION_VERSION` stays 1 for the fifth time: an older file
|
|
152
|
+
* simply yields `undefined`, which restores as disarmed - the right answer for a session that
|
|
153
|
+
* predates the feature. It is a BOOLEAN and not the whole mode: the scope is deliberately
|
|
154
|
+
* absent (D-9 - a target name can itself be the sensitive part of an engagement), and the
|
|
155
|
+
* waiver lives in `state.json` because it is a machine fact (D-3).
|
|
156
|
+
*/
|
|
157
|
+
redTeam?: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* The waiver version this session was armed under, for the reconciliation `/resume` does
|
|
160
|
+
* (4.10 / I-12): a file written under version 1 must not silently re-arm under version 2.
|
|
161
|
+
*/
|
|
162
|
+
redTeamWaiverVersion?: number;
|
|
103
163
|
}
|
|
104
164
|
/** Resolve a `/save` target: absolute/relative path, or a name in the data dir. */
|
|
105
165
|
export declare function resolveSessionPath(nameOrPath: string | undefined, cwd: string): string;
|
|
@@ -127,7 +187,15 @@ export declare function saveSession(filePath: string, data: {
|
|
|
127
187
|
* additive for callers that predate it; every writer in this package passes it.
|
|
128
188
|
*/
|
|
129
189
|
acceptance?: AcceptanceItem[];
|
|
190
|
+
/** Omitted when every memory setting is at its default, so such a file is byte-identical. */
|
|
191
|
+
memory?: MemorySessionState;
|
|
130
192
|
meta?: SessionMeta;
|
|
193
|
+
/**
|
|
194
|
+
* Red team mode's armed state, ADDED TO `data` AND NOT AS TWO MORE PARAMETERS (RV-14):
|
|
195
|
+
* `saveSession(filePath, data)` takes two positional arguments, the second one this object.
|
|
196
|
+
*/
|
|
197
|
+
redTeam?: boolean;
|
|
198
|
+
redTeamWaiverVersion?: number;
|
|
131
199
|
}): void;
|
|
132
200
|
/**
|
|
133
201
|
* Settle any team entry that was saved mid-dispatch (team-subagents §5.3 / P1-5),
|
package/dist/session/persist.js
CHANGED
|
@@ -142,7 +142,18 @@ export function saveSession(filePath, data) {
|
|
|
142
142
|
...(data.acceptance && data.acceptance.length > 0
|
|
143
143
|
? { acceptance: data.acceptance }
|
|
144
144
|
: {}),
|
|
145
|
+
...(data.memory ? { memory: data.memory } : {}),
|
|
145
146
|
...(data.meta ? { meta: data.meta } : {}),
|
|
147
|
+
// WRITTEN ONLY WHEN ARMED, so a session that never used the mode produces a file
|
|
148
|
+
// byte-identical to today's (4.10). The version rides with the flag for the same reason.
|
|
149
|
+
...(data.redTeam === true
|
|
150
|
+
? {
|
|
151
|
+
redTeam: true,
|
|
152
|
+
...(typeof data.redTeamWaiverVersion === 'number'
|
|
153
|
+
? { redTeamWaiverVersion: data.redTeamWaiverVersion }
|
|
154
|
+
: {}),
|
|
155
|
+
}
|
|
156
|
+
: {}),
|
|
146
157
|
};
|
|
147
158
|
writeFileSync(filePath, `${JSON.stringify(payload, null, 2)}\n`, 'utf-8');
|
|
148
159
|
}
|
|
@@ -56,6 +56,21 @@ export interface SessionRestorePort {
|
|
|
56
56
|
* the same additive shape as `SavedSession.acceptance`.
|
|
57
57
|
*/
|
|
58
58
|
restoreTodos(items: TodoItem[], acceptance?: AcceptanceItem[]): void;
|
|
59
|
+
/**
|
|
60
|
+
* The saved memory mounts and switches (agent-memory 5.5). OPTIONAL on the port for the same
|
|
61
|
+
* reason `acceptance` is: a test double or an `exec` caller that predates the feature keeps
|
|
62
|
+
* compiling, and a headless controller (no memory service) ignores it.
|
|
63
|
+
*/
|
|
64
|
+
restoreMemory?(state: unknown): void;
|
|
65
|
+
/**
|
|
66
|
+
* The saved red team posture (red-team-security-mode 4.10). OPTIONAL on the port for the same
|
|
67
|
+
* reason the two above are, and it RETURNS WHAT TO TELL THE USER: a session that comes back
|
|
68
|
+
* disarmed because the waiver changed has to say so, or the user will assume the mode stuck.
|
|
69
|
+
*/
|
|
70
|
+
restoreRedTeam?(state: {
|
|
71
|
+
armed?: boolean;
|
|
72
|
+
waiverVersion?: number;
|
|
73
|
+
}): string | null;
|
|
59
74
|
setModel(providerId: string, modelId: string, baseUrl?: string): void;
|
|
60
75
|
}
|
|
61
76
|
export type StartupSessionResolution = {
|
|
@@ -65,7 +80,7 @@ export type StartupSessionResolution = {
|
|
|
65
80
|
notice?: string;
|
|
66
81
|
/** The file this session was branched from, if any. */
|
|
67
82
|
saved?: SavedSession;
|
|
68
|
-
apply(port: SessionRestorePort):
|
|
83
|
+
apply(port: SessionRestorePort): string | null;
|
|
69
84
|
} | {
|
|
70
85
|
ok: false;
|
|
71
86
|
exitCode: 2;
|
|
@@ -86,7 +101,7 @@ export type StartupSessionResolution = {
|
|
|
86
101
|
*/
|
|
87
102
|
export declare function applyRestoredSession(port: SessionRestorePort, saved: SavedSession, opts?: {
|
|
88
103
|
skipModel?: boolean;
|
|
89
|
-
}):
|
|
104
|
+
}): string | null;
|
|
90
105
|
/**
|
|
91
106
|
* Work out which session this process is, and what it starts from.
|
|
92
107
|
*
|
|
@@ -44,9 +44,22 @@ export function applyRestoredSession(port, saved, opts = {}) {
|
|
|
44
44
|
// restoring the steps and dropping the conclusions shows a plan as unstarted that
|
|
45
45
|
// the user already watched being verified.
|
|
46
46
|
port.restoreTodos(saved.todos ?? [], saved.acceptance ?? []);
|
|
47
|
+
// Absence means "defaults", exactly as absent todos mean "clear": the file says what the
|
|
48
|
+
// session had, and a file that predates memory had nothing mounted.
|
|
49
|
+
port.restoreMemory?.(saved.memory);
|
|
50
|
+
// THE POSTURE, AND THE NOTICE IT MAY PRODUCE (4.10 / I-12). A file that says `redTeam: true`
|
|
51
|
+
// restores the mode only while the waiver it was armed under is still current; otherwise the
|
|
52
|
+
// port answers with the sentence explaining that, which the caller shows.
|
|
53
|
+
const redTeamNotice = port.restoreRedTeam?.({
|
|
54
|
+
...(saved.redTeam === true ? { armed: true } : {}),
|
|
55
|
+
...(typeof saved.redTeamWaiverVersion === 'number'
|
|
56
|
+
? { waiverVersion: saved.redTeamWaiverVersion }
|
|
57
|
+
: {}),
|
|
58
|
+
}) ?? null;
|
|
47
59
|
if (!opts.skipModel && saved.model?.providerId && saved.model?.modelId) {
|
|
48
60
|
port.setModel(saved.model.providerId, saved.model.modelId, saved.model.baseUrl);
|
|
49
61
|
}
|
|
62
|
+
return redTeamNotice;
|
|
50
63
|
}
|
|
51
64
|
/**
|
|
52
65
|
* Work out which session this process is, and what it starts from.
|
|
@@ -81,7 +94,7 @@ function resolveFresh(saveAs) {
|
|
|
81
94
|
identity: { id: saveAs, kind: 'named', pinned: true },
|
|
82
95
|
initialEntries: [],
|
|
83
96
|
notice: `Session ${saveAs} (pinned). Resume it from any terminal: aragon --resume ${saveAs}`,
|
|
84
|
-
apply: () =>
|
|
97
|
+
apply: () => null,
|
|
85
98
|
};
|
|
86
99
|
}
|
|
87
100
|
// A collision is not a failure for an auto-minted id: another process took the
|
|
@@ -94,7 +107,7 @@ function resolveFresh(saveAs) {
|
|
|
94
107
|
if (fate === 'unwritable')
|
|
95
108
|
return unwritable(id);
|
|
96
109
|
if (fate === 'ok') {
|
|
97
|
-
return { ok: true, identity: { id, kind: 'fresh' }, initialEntries: [], apply: () =>
|
|
110
|
+
return { ok: true, identity: { id, kind: 'fresh' }, initialEntries: [], apply: () => null };
|
|
98
111
|
}
|
|
99
112
|
}
|
|
100
113
|
return {
|
package/dist/session/store.d.ts
CHANGED
|
@@ -71,6 +71,20 @@ export interface SessionListEntry {
|
|
|
71
71
|
}
|
|
72
72
|
export declare function sessionsDir(): string;
|
|
73
73
|
export declare function sessionPathFor(id: string): string;
|
|
74
|
+
/**
|
|
75
|
+
* `<sessions>/follow-ups`: where follow-up panel sessions are checkpointed
|
|
76
|
+
* (desktop-follow-up-panel D-2).
|
|
77
|
+
*
|
|
78
|
+
* A SUBDIRECTORY IS THE WHOLE EXCLUSION MECHANISM. `listSessions` below walks the sessions folder
|
|
79
|
+
* with a flat `readdirSync` and keeps only names ending in `.json`, and the desktop's
|
|
80
|
+
* `scanSessionFiles` additionally requires `isFile()`; a directory therefore cannot appear in the
|
|
81
|
+
* sidebar, in `aragon sessions list` or in `prune` whatever it is called. `sessions/cleared/` is
|
|
82
|
+
* the precedent. Adding a recursive scan to either of those two functions would surface every
|
|
83
|
+
* follow-up as a session, which is the one change this comment exists to prevent.
|
|
84
|
+
*/
|
|
85
|
+
export declare function followUpsDir(): string;
|
|
86
|
+
/** `<sessions>/follow-ups/<id>.json`. Validated by the same choke point as every other id. */
|
|
87
|
+
export declare function followUpSessionPathFor(id: string): string;
|
|
74
88
|
/**
|
|
75
89
|
* The id a RESUMED session writes back under.
|
|
76
90
|
*
|
package/dist/session/store.js
CHANGED
|
@@ -80,6 +80,24 @@ function assertSessionId(id) {
|
|
|
80
80
|
export function sessionPathFor(id) {
|
|
81
81
|
return join(getSessionsDir(), `${assertSessionId(id)}.json`);
|
|
82
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* `<sessions>/follow-ups`: where follow-up panel sessions are checkpointed
|
|
85
|
+
* (desktop-follow-up-panel D-2).
|
|
86
|
+
*
|
|
87
|
+
* A SUBDIRECTORY IS THE WHOLE EXCLUSION MECHANISM. `listSessions` below walks the sessions folder
|
|
88
|
+
* with a flat `readdirSync` and keeps only names ending in `.json`, and the desktop's
|
|
89
|
+
* `scanSessionFiles` additionally requires `isFile()`; a directory therefore cannot appear in the
|
|
90
|
+
* sidebar, in `aragon sessions list` or in `prune` whatever it is called. `sessions/cleared/` is
|
|
91
|
+
* the precedent. Adding a recursive scan to either of those two functions would surface every
|
|
92
|
+
* follow-up as a session, which is the one change this comment exists to prevent.
|
|
93
|
+
*/
|
|
94
|
+
export function followUpsDir() {
|
|
95
|
+
return join(getSessionsDir(), 'follow-ups');
|
|
96
|
+
}
|
|
97
|
+
/** `<sessions>/follow-ups/<id>.json`. Validated by the same choke point as every other id. */
|
|
98
|
+
export function followUpSessionPathFor(id) {
|
|
99
|
+
return join(followUpsDir(), `${assertSessionId(id)}.json`);
|
|
100
|
+
}
|
|
83
101
|
/**
|
|
84
102
|
* The id a RESUMED session writes back under.
|
|
85
103
|
*
|