@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
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The memory directory's ONLY read/write authority (agent-memory spec 8.2 / 8.5,
|
|
3
|
+
* D-1, D-15, D-16, I-3, I-11, I-12, I-14).
|
|
4
|
+
*
|
|
5
|
+
* ASCII ONLY - `src/memory/**` is inside `glyphs.test.ts::inScope`.
|
|
6
|
+
*
|
|
7
|
+
* EVERY WRITE IS: read the file as it is NOW, compare its content hash with the `rev` the
|
|
8
|
+
* caller saw, back the old bytes up, write a temp file in the same directory, rename it
|
|
9
|
+
* over the target. No lock (D-16): a stale lock file is a worse failure than one lost race,
|
|
10
|
+
* and the backup turns the one lost race into "your earlier text is in `.trash/versions`".
|
|
11
|
+
*
|
|
12
|
+
* NOTHING HERE THROWS (I-3). A bad file becomes a skipped entry plus a one-time notice; an
|
|
13
|
+
* unwritable directory becomes `write_failed`. The caller always gets a value it can show.
|
|
14
|
+
*
|
|
15
|
+
* READS ARE FREE OF SIDE EFFECTS (I-14): no directory is created, no file is touched, no
|
|
16
|
+
* mtime changes. Opening the manager on a hand-written file must not rewrite it.
|
|
17
|
+
*
|
|
18
|
+
* THIS MODULE IS THE ONLY CODE THAT WRITES UNDER `getMemoryDir()` (I-12). The tool, the
|
|
19
|
+
* `/memory` command, the overlay and the desktop IPC handlers all come through here, which
|
|
20
|
+
* is what lets one test prove "nothing writes without a user action" for the whole feature.
|
|
21
|
+
*/
|
|
22
|
+
import { copyFileSync, linkSync, renameSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
23
|
+
import type { MemoryCatalogRow, MemoryDraftInput, MemoryNote, MemoryNoteSource, MemoryResult, MemoryTrashItem } from '@aragon-agent/tui/model/memory/types';
|
|
24
|
+
import { type MemoryTarget } from './paths.js';
|
|
25
|
+
export type { MemoryTarget };
|
|
26
|
+
export interface MemoryFsOps {
|
|
27
|
+
writeFileSync: typeof writeFileSync;
|
|
28
|
+
renameSync: typeof renameSync;
|
|
29
|
+
linkSync: typeof linkSync;
|
|
30
|
+
copyFileSync: typeof copyFileSync;
|
|
31
|
+
unlinkSync: typeof unlinkSync;
|
|
32
|
+
/** Called between rename retries; tests replace it with a no-op. */
|
|
33
|
+
sleep: (ms: number) => void;
|
|
34
|
+
}
|
|
35
|
+
/** Tests only: override pieces of the filesystem; call with no argument to restore. */
|
|
36
|
+
export declare function setMemoryFsOpsForTest(overrides?: Partial<MemoryFsOps>): void;
|
|
37
|
+
/** Number of successful writes to note files since start-up. Tests assert "one action, one write". */
|
|
38
|
+
export declare function getMemoryRevision(): number;
|
|
39
|
+
/** Drop every cached parse (tests, and after the home root changes). */
|
|
40
|
+
export declare function resetMemoryCacheForTest(): void;
|
|
41
|
+
/**
|
|
42
|
+
* What the last scans had to skip, once. `skipped` counts files that could not be used
|
|
43
|
+
* (bad name, not UTF-8, too large, a link out of the directory). Reading never backs
|
|
44
|
+
* anything up, so unlike the prompt library there is no "file was backed up" variant.
|
|
45
|
+
*/
|
|
46
|
+
export declare function takeMemoryRepairNotice(): {
|
|
47
|
+
skipped: number;
|
|
48
|
+
} | null;
|
|
49
|
+
export interface ScopeScan {
|
|
50
|
+
notes: MemoryNote[];
|
|
51
|
+
skipped: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Every usable note in one scope, parsed (cached by path + mtime + size). Never throws,
|
|
55
|
+
* never writes. Skipped files are counted and reported once via `takeMemoryRepairNotice`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function scanScope(target: MemoryTarget): ScopeScan;
|
|
58
|
+
/** Catalog rows (no bodies) for one scope. */
|
|
59
|
+
export declare function listCatalog(target: MemoryTarget): {
|
|
60
|
+
rows: MemoryCatalogRow[];
|
|
61
|
+
skipped: number;
|
|
62
|
+
};
|
|
63
|
+
/** Strip a note down to its catalog row. */
|
|
64
|
+
export declare function toCatalogRow(note: MemoryNote): MemoryCatalogRow;
|
|
65
|
+
/** One note, read fresh from its file (never from the cache - this is what CAS compares). */
|
|
66
|
+
export declare function readNote(target: MemoryTarget, id: string): MemoryResult<MemoryNote>;
|
|
67
|
+
export interface MemoryWriteOptions {
|
|
68
|
+
/** Who is writing. The agent is held to stricter rules (no secrets, ever). */
|
|
69
|
+
source: Exclude<MemoryNoteSource, 'hand'>;
|
|
70
|
+
/** The user saw the secret warning and chose to keep the text. Ignored for the agent. */
|
|
71
|
+
confirmSecret?: boolean;
|
|
72
|
+
/** The user's configured API keys, so a note containing one is caught by value. */
|
|
73
|
+
knownSecrets?: readonly string[];
|
|
74
|
+
/** Refuse a second enabled note with the same title in the scope (agent writes). */
|
|
75
|
+
rejectDuplicateTitle?: boolean;
|
|
76
|
+
/** Epoch ms; tests inject it. */
|
|
77
|
+
now?: number;
|
|
78
|
+
/** Where the project lives, for the `_project.json` sidecar. */
|
|
79
|
+
projectInfo?: {
|
|
80
|
+
root: string;
|
|
81
|
+
label: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Create a note. Mints the id; never overwrites an existing file. */
|
|
85
|
+
export declare function createNote(target: MemoryTarget, input: MemoryDraftInput, opts: MemoryWriteOptions): MemoryResult<MemoryNote>;
|
|
86
|
+
/**
|
|
87
|
+
* Replace a note's content, but only if it is still the version the caller saw (I-11).
|
|
88
|
+
*
|
|
89
|
+
* A mismatch returns `conflict` WITH the current note, so the editor can offer "reload" or
|
|
90
|
+
* "overwrite" - and "overwrite" is the same call again with the fresh `rev`, never a blind
|
|
91
|
+
* write. Saving content identical to what is on disk (and not in need of repair) writes
|
|
92
|
+
* nothing.
|
|
93
|
+
*/
|
|
94
|
+
export declare function updateNote(target: MemoryTarget, id: string, input: MemoryDraftInput, expectedRev: string, opts: MemoryWriteOptions): MemoryResult<MemoryNote>;
|
|
95
|
+
/** Move a note to the trash (30 days), if it is still the version the caller saw. */
|
|
96
|
+
export declare function trashNote(target: MemoryTarget, id: string, expectedRev: string, now?: number): MemoryResult<{
|
|
97
|
+
trashId: string;
|
|
98
|
+
}>;
|
|
99
|
+
/**
|
|
100
|
+
* Bring a trashed note back. If its id has been taken meanwhile, it returns under a NEW id
|
|
101
|
+
* (never over the live note) and the caller is told which.
|
|
102
|
+
*/
|
|
103
|
+
export declare function restoreNote(target: MemoryTarget, trashId: string): MemoryResult<{
|
|
104
|
+
id: string;
|
|
105
|
+
}>;
|
|
106
|
+
/** The trash for one scope, newest first. */
|
|
107
|
+
export declare function listTrash(target: MemoryTarget): MemoryTrashItem[];
|
|
108
|
+
/** Delete one trashed note for good. */
|
|
109
|
+
export declare function purgeTrash(target: MemoryTarget, trashId: string): MemoryResult<{
|
|
110
|
+
ok: true;
|
|
111
|
+
}>;
|
|
112
|
+
/**
|
|
113
|
+
* Delete trash and old backups older than the retention window. Best effort, bounded, and
|
|
114
|
+
* only ever inside `.trash/` - live notes are never touched (I-1). Called once at service
|
|
115
|
+
* start-up, off the hot path.
|
|
116
|
+
*/
|
|
117
|
+
export declare function purgeExpiredTrash(now?: number): number;
|
|
118
|
+
/**
|
|
119
|
+
* Move a note to the other scope: create the copy first, trash the original second. If the
|
|
120
|
+
* second step fails both exist (and the caller is told) - duplicate, never lost.
|
|
121
|
+
*/
|
|
122
|
+
export declare function moveNote(from: MemoryTarget, id: string, to: MemoryTarget, expectedRev: string, opts: MemoryWriteOptions): MemoryResult<MemoryNote>;
|
|
123
|
+
/** A project directory that holds notes (for "projects with memory"). */
|
|
124
|
+
export interface MemoryProjectEntry {
|
|
125
|
+
key: string;
|
|
126
|
+
label: string;
|
|
127
|
+
root: string;
|
|
128
|
+
count: number;
|
|
129
|
+
}
|
|
130
|
+
/** Projects that have a directory under `memory/projects/`. */
|
|
131
|
+
export declare function listProjectScopes(): MemoryProjectEntry[];
|
|
132
|
+
/** Convenience used by tests and the service: the current rev of a file's bytes. */
|
|
133
|
+
export declare function revOfBytes(bytes: Uint8Array): string;
|