agent-working-memory 0.14.1 → 0.14.6
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/README.md +240 -653
- package/dist/adapters/claude-code.d.ts.map +1 -1
- package/dist/adapters/claude-code.js +234 -131
- package/dist/adapters/claude-code.js.map +1 -1
- package/dist/adapters/common.d.ts +44 -5
- package/dist/adapters/common.d.ts.map +1 -1
- package/dist/adapters/common.js +111 -41
- package/dist/adapters/common.js.map +1 -1
- package/dist/adapters/hook-scripts.d.ts +54 -0
- package/dist/adapters/hook-scripts.d.ts.map +1 -0
- package/dist/adapters/hook-scripts.js +340 -0
- package/dist/adapters/hook-scripts.js.map +1 -0
- package/dist/adapters/types.d.ts +13 -3
- package/dist/adapters/types.d.ts.map +1 -1
- package/dist/cli.js +21 -5
- package/dist/cli.js.map +1 -1
- package/dist/core/agent-id.d.ts +19 -0
- package/dist/core/agent-id.d.ts.map +1 -0
- package/dist/core/agent-id.js +28 -0
- package/dist/core/agent-id.js.map +1 -0
- package/dist/core/whoami.d.ts +9 -1
- package/dist/core/whoami.d.ts.map +1 -1
- package/dist/core/whoami.js +12 -2
- package/dist/core/whoami.js.map +1 -1
- package/dist/engine/activation.d.ts +2 -0
- package/dist/engine/activation.d.ts.map +1 -1
- package/dist/engine/activation.js +18 -3
- package/dist/engine/activation.js.map +1 -1
- package/dist/engine/eval.d.ts +15 -0
- package/dist/engine/eval.d.ts.map +1 -1
- package/dist/engine/eval.js +23 -0
- package/dist/engine/eval.js.map +1 -1
- package/dist/hooks/prime.d.ts +10 -4
- package/dist/hooks/prime.d.ts.map +1 -1
- package/dist/hooks/prime.js +16 -6
- package/dist/hooks/prime.js.map +1 -1
- package/dist/hooks/sidecar.d.ts +18 -2
- package/dist/hooks/sidecar.d.ts.map +1 -1
- package/dist/hooks/sidecar.js +30 -4
- package/dist/hooks/sidecar.js.map +1 -1
- package/dist/mcp.js +48 -19
- package/dist/mcp.js.map +1 -1
- package/dist/storage/pglite.d.ts +7 -0
- package/dist/storage/pglite.d.ts.map +1 -1
- package/dist/storage/pglite.js +17 -3
- package/dist/storage/pglite.js.map +1 -1
- package/dist/storage/postgres.d.ts +7 -0
- package/dist/storage/postgres.d.ts.map +1 -1
- package/dist/storage/postgres.js +17 -3
- package/dist/storage/postgres.js.map +1 -1
- package/dist/storage/sqlite.d.ts +12 -0
- package/dist/storage/sqlite.d.ts.map +1 -1
- package/dist/storage/sqlite.js +24 -3
- package/dist/storage/sqlite.js.map +1 -1
- package/dist/types/engram.d.ts +16 -0
- package/dist/types/engram.d.ts.map +1 -1
- package/dist/types/eval.d.ts +2 -0
- package/dist/types/eval.d.ts.map +1 -1
- package/package.json +94 -72
- package/src/adapters/claude-code.ts +223 -125
- package/src/adapters/common.ts +117 -42
- package/src/adapters/hook-scripts.ts +370 -0
- package/src/adapters/types.ts +14 -3
- package/src/cli.ts +19 -5
- package/src/core/agent-id.ts +28 -0
- package/src/core/whoami.ts +11 -1
- package/src/engine/activation.ts +18 -3
- package/src/engine/eval.ts +34 -0
- package/src/hooks/prime.ts +22 -7
- package/src/hooks/sidecar.ts +50 -6
- package/src/mcp.ts +50 -18
- package/src/storage/pglite.ts +22 -4
- package/src/storage/postgres.ts +22 -4
- package/src/storage/sqlite.ts +26 -4
- package/src/types/engram.ts +16 -0
- package/src/types/eval.ts +3 -1
package/dist/adapters/common.js
CHANGED
|
@@ -11,6 +11,7 @@ import { resolve, join, dirname, basename } from 'node:path';
|
|
|
11
11
|
import { randomBytes } from 'node:crypto';
|
|
12
12
|
import { homedir as osHomedir } from 'node:os';
|
|
13
13
|
import { fileURLToPath } from 'node:url';
|
|
14
|
+
import { deriveAgentFromDir } from '../core/agent-id.js';
|
|
14
15
|
const __filename = fileURLToPath(import.meta.url);
|
|
15
16
|
const __dirname = dirname(__filename);
|
|
16
17
|
/** Resolve the AWM package root (where src/ and dist/ live). */
|
|
@@ -40,14 +41,40 @@ export function resolveHookSecret(dbPath) {
|
|
|
40
41
|
writeFileSync(secretPath, secret + '\n');
|
|
41
42
|
return secret;
|
|
42
43
|
}
|
|
43
|
-
/**
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Retrieval settings `awm setup` turns on for a new install (0.14.6).
|
|
46
|
+
*
|
|
47
|
+
* All three ship default-off in the engine so an existing process never changes
|
|
48
|
+
* behaviour on upgrade, but the README has recommended them together since 0.14.0:
|
|
49
|
+
* second-stage rerank by the cross-encoder's own score, a 400-char rerank window
|
|
50
|
+
* on the densest query-term region (25% → 87.5% on long memories), and tags in the
|
|
51
|
+
* rerank passage (+7.4pp). A value the user already has in their config wins.
|
|
52
|
+
*/
|
|
53
|
+
export const RECOMMENDED_ENV = {
|
|
54
|
+
AWM_RERANK2: '1',
|
|
55
|
+
AWM_RERANK_WINDOW: 'query',
|
|
56
|
+
AWM_RERANK_TAGS: '1',
|
|
57
|
+
};
|
|
58
|
+
/** Keys `awm setup` owns outright; everything else in an existing env block is the user's. */
|
|
59
|
+
export const OWNED_ENV_KEYS = ['AWM_DB_PATH', 'AWM_AGENT_ID', 'AWM_HOOK_PORT', 'AWM_HOOK_PORT_RANGE', 'AWM_HOOK_SECRET'];
|
|
60
|
+
/**
|
|
61
|
+
* Build environment variables for the MCP server process.
|
|
62
|
+
*
|
|
63
|
+
* Layering, lowest to highest: recommended defaults → whatever the user's current
|
|
64
|
+
* entry already carries (rerank flags they tuned, AWM_WORKSPACE, backend choice…)
|
|
65
|
+
* → the keys setup owns. Before 0.14.6 the entry was replaced wholesale, which
|
|
66
|
+
* dropped hand-set flags on every re-run.
|
|
67
|
+
*/
|
|
68
|
+
export function buildEnvVars(dbPath, agentId, hookPort, hookSecret, isWindows, opts = {}) {
|
|
69
|
+
const owned = {
|
|
70
|
+
AWM_DB_PATH: isWindows ? dbPath.split('\\').join('/') : dbPath,
|
|
47
71
|
AWM_AGENT_ID: agentId,
|
|
48
72
|
AWM_HOOK_PORT: hookPort,
|
|
49
73
|
AWM_HOOK_SECRET: hookSecret,
|
|
50
74
|
};
|
|
75
|
+
if (opts.hookPortRange && opts.hookPortRange !== '10')
|
|
76
|
+
owned.AWM_HOOK_PORT_RANGE = opts.hookPortRange;
|
|
77
|
+
return { ...RECOMMENDED_ENV, ...(opts.existing ?? {}), ...owned };
|
|
51
78
|
}
|
|
52
79
|
/**
|
|
53
80
|
* Resolve the MCP server command + args.
|
|
@@ -74,7 +101,18 @@ export function resolveMcpCommand(ctx) {
|
|
|
74
101
|
args: ['tsx', ctx.mcpScript],
|
|
75
102
|
};
|
|
76
103
|
}
|
|
77
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* Build a full SetupContext from parsed CLI flags.
|
|
106
|
+
*
|
|
107
|
+
* Precedence for every owned value: an explicit flag → the value in the entry a
|
|
108
|
+
* previous `awm setup` wrote (`existingEnv`) → the default. So re-running setup to
|
|
109
|
+
* pick up new hooks or guidance never repoints the database, renames the agent or
|
|
110
|
+
* moves the sidecar port underneath a working install.
|
|
111
|
+
*
|
|
112
|
+
* Global default agent id is `work` (was `claude` before 0.14.6): it matches what
|
|
113
|
+
* the server itself resolves to when AWM_AGENT_ID is unset (see core/agent-id.ts),
|
|
114
|
+
* so a config with and without the key name the same pool.
|
|
115
|
+
*/
|
|
78
116
|
export function buildSetupContext(opts) {
|
|
79
117
|
const cwd = process.cwd();
|
|
80
118
|
const projectName = basename(cwd).toLowerCase().replace(/[^a-z0-9-]/g, '-');
|
|
@@ -83,10 +121,15 @@ export function buildSetupContext(opts) {
|
|
|
83
121
|
const mcpDist = join(packageRoot, 'dist', 'mcp.js');
|
|
84
122
|
const hasDist = existsSync(mcpDist);
|
|
85
123
|
const isWindows = process.platform === 'win32';
|
|
86
|
-
const
|
|
87
|
-
const
|
|
124
|
+
const existing = opts.existingEnv ?? null;
|
|
125
|
+
const agentId = opts.agentId
|
|
126
|
+
?? existing?.AWM_AGENT_ID
|
|
127
|
+
?? (opts.isGlobal ? deriveAgentFromDir('') : projectName);
|
|
128
|
+
const dbPath = resolveDbPath(packageRoot, opts.dbPath ?? existing?.AWM_DB_PATH ?? null);
|
|
129
|
+
const hookPort = opts.hookPort ?? existing?.AWM_HOOK_PORT ?? '8401';
|
|
130
|
+
const hookPortRange = opts.hookPortRange ?? existing?.AWM_HOOK_PORT_RANGE ?? '10';
|
|
88
131
|
const hookSecret = resolveHookSecret(dbPath);
|
|
89
|
-
const envVars = buildEnvVars(dbPath, agentId,
|
|
132
|
+
const envVars = buildEnvVars(dbPath, agentId, hookPort, hookSecret, isWindows, { hookPortRange, existing });
|
|
90
133
|
return {
|
|
91
134
|
cwd,
|
|
92
135
|
projectName,
|
|
@@ -97,15 +140,20 @@ export function buildSetupContext(opts) {
|
|
|
97
140
|
mcpScript,
|
|
98
141
|
hasDist,
|
|
99
142
|
hookSecret,
|
|
100
|
-
hookPort
|
|
143
|
+
hookPort,
|
|
144
|
+
hookPortRange,
|
|
145
|
+
installPrime: opts.installPrime ?? true,
|
|
101
146
|
isGlobal: opts.isGlobal,
|
|
102
147
|
isWindows,
|
|
103
148
|
envVars,
|
|
104
149
|
};
|
|
105
150
|
}
|
|
106
|
-
/**
|
|
151
|
+
/**
|
|
152
|
+
* Home directory. `AWM_SETUP_HOME` overrides it so `awm setup` / `awm doctor` can be
|
|
153
|
+
* exercised against a scratch tree (tests do this; so does a cautious upgrade).
|
|
154
|
+
*/
|
|
107
155
|
export function homedir() {
|
|
108
|
-
return osHomedir();
|
|
156
|
+
return process.env.AWM_SETUP_HOME || osHomedir();
|
|
109
157
|
}
|
|
110
158
|
// ─── Instruction content ────────────────────────────────
|
|
111
159
|
/**
|
|
@@ -236,7 +284,12 @@ you write them; AWM stays current because every agent reads + writes the same st
|
|
|
236
284
|
than one filesystem search.
|
|
237
285
|
4. **As you learn things**: call \`memory_write\` proactively. Don't batch.
|
|
238
286
|
5. **Finishing a task**: call \`memory_task_end\` with a summary.
|
|
239
|
-
6. **
|
|
287
|
+
6. **Hooks do the rest.** \`awm setup\` installs three: a **prime** hook that recalls against
|
|
288
|
+
each prompt and injects what clears confidence (or nothing), and checkpoint hooks on
|
|
289
|
+
compaction and session end (plus a 15-min timer). Primed context arrives labelled
|
|
290
|
+
\`[class · age]\` — treat it by the volatility rubric, not as user input. If a turn
|
|
291
|
+
arrives with no primed context, that is a signal too: recall explicitly before
|
|
292
|
+
asserting anything.
|
|
240
293
|
|
|
241
294
|
### Write memory when:
|
|
242
295
|
- A project decision is made or changed
|
|
@@ -432,10 +485,9 @@ When it isn't:
|
|
|
432
485
|
return nothing, the memory probably isn't there — read the code instead of
|
|
433
486
|
burning more recalls.
|
|
434
487
|
|
|
435
|
-
### Recall tuning
|
|
436
|
-
Default \`memory_recall\` is tuned for the common case.
|
|
437
|
-
|
|
438
|
-
when the default doesn't match what you actually need.
|
|
488
|
+
### Recall tuning — opt-in parameters
|
|
489
|
+
Default \`memory_recall\` is tuned for the common case. Four opt-in parameters change
|
|
490
|
+
the cost/quality tradeoff. Use them when the default doesn't match what you need.
|
|
439
491
|
|
|
440
492
|
- **\`granularity: 'compact'\`** — every result carries a 200-char \`summary\`
|
|
441
493
|
field with a query-aware snippet (the densest window of query terms in the
|
|
@@ -446,30 +498,37 @@ when the default doesn't match what you actually need.
|
|
|
446
498
|
winner, it gets a longer summary while the rest are compact. If confidence
|
|
447
499
|
is uniform across results, everything is compact. Use when you don't know
|
|
448
500
|
in advance whether one result will dominate.
|
|
449
|
-
- **\`require_confidence
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
501
|
+
- **\`require_confidence\`** — abstention. The default (0.05) is already a light
|
|
502
|
+
gate: when the top results don't stand out from the rest, recall returns
|
|
503
|
+
nothing and the reply says **\`RECALL ABSTAINED\`** with the count it withheld.
|
|
504
|
+
An empty result *without* that line is genuine absence. The gate is on the
|
|
505
|
+
SHAPE of the score distribution, not relevance — so raising it silences
|
|
506
|
+
specific questions with one clear winner first (measured: 0.25 abstained on
|
|
507
|
+
two identifier queries scoring 0.26–0.38 while passing a vague one at 0.92).
|
|
508
|
+
Leave it alone for ordinary recall; \`0.10\` is the ceiling that still helps for
|
|
509
|
+
push-style use where nobody asked. When abstention fires, reformulate once
|
|
510
|
+
with the exact identifier, then read the code — don't retry with a lower
|
|
511
|
+
threshold to force an answer.
|
|
457
512
|
- **\`workspace: "<name>"\`** — hive-mode recall across all agents in the
|
|
458
513
|
workspace. Use when other agents may have written canonical knowledge you
|
|
459
514
|
need. Default is agent-scoped (your own memories only). Can also be set
|
|
460
|
-
globally via the \`AWM_WORKSPACE\` env var.
|
|
515
|
+
globally via the \`AWM_WORKSPACE\` env var. Memories live in the agent pool
|
|
516
|
+
they were written to; if a session lands in an unexpected pool, \`memory_whoami\`
|
|
517
|
+
says which one before you conclude the memory is missing.
|
|
461
518
|
|
|
462
519
|
### Keep memory fresh
|
|
463
520
|
- After recalling a memory, if you observe the real state is different → call
|
|
464
521
|
\`memory_supersede\` immediately with the corrected version.
|
|
465
|
-
- After using a recalled memory: call \`memory_feedback\` (useful/not-useful)
|
|
466
|
-
|
|
522
|
+
- After using a recalled memory: call \`memory_feedback\` (useful/not-useful) **with the
|
|
523
|
+
\`recall_id\`** printed at the end of the recall output (\`[recall_id: …]\`). That id
|
|
524
|
+
joins the feedback to the recall that produced it, which is what lets AWM learn
|
|
525
|
+
which recalls were worth their tokens; feedback without it is a bare vote.
|
|
467
526
|
- If you discover a memory is factually wrong: \`memory_retract\` to remove it.
|
|
468
527
|
- **If you bypass AWM (file-memory, in-context notes, "I'll just remember"), the memory
|
|
469
528
|
drifts out of date. The system relies on you to keep it current. This is the #1
|
|
470
529
|
failure mode.**
|
|
471
530
|
|
|
472
|
-
### Cognition recipes — YOU do the thinking, AWM keeps the result
|
|
531
|
+
### Cognition recipes — YOU do the thinking, AWM keeps the result
|
|
473
532
|
AWM contains no LLM. When memory needs real thinking — distilling a repeatable
|
|
474
533
|
procedure, reflecting on a failure — AWM hands YOU a versioned recipe (prompt +
|
|
475
534
|
strict output shape) and you run it as a SEPARATE focused pass, then write the
|
|
@@ -487,7 +546,7 @@ result back as an ordinary memory with provenance.
|
|
|
487
546
|
- Re-deriving the same skill name reinforces the existing memory instead of
|
|
488
547
|
duplicating it, so don't fear writing a skill you may have written before.
|
|
489
548
|
|
|
490
|
-
### Content fade — write-and-forget is safe
|
|
549
|
+
### Content fade — write-and-forget is safe
|
|
491
550
|
Un-recalled engrams gradually fade their content while preserving cue pathways
|
|
492
551
|
(concept + tags + embedding stay intact). This is Paper 1 — storage
|
|
493
552
|
degradation. Practical implications:
|
|
@@ -502,7 +561,7 @@ degradation. Practical implications:
|
|
|
502
561
|
its fade clock. Frequently-recalled memories stay full-fidelity automatically.
|
|
503
562
|
- **Supersede is the right tool for stale facts.** When you observe a memory
|
|
504
563
|
is outdated, call \`memory_supersede\` — the new version inherits the old
|
|
505
|
-
one's coherent associations (counter-narrative replacement
|
|
564
|
+
one's coherent associations (counter-narrative replacement) so cue
|
|
506
565
|
pathways carry forward to the replacement.
|
|
507
566
|
|
|
508
567
|
### Example — good vs bad memory_write
|
|
@@ -554,7 +613,7 @@ comprehension cost. This is output-only: it never changes the data or your memor
|
|
|
554
613
|
- Don't bother for small outputs — it only compresses when the saving is worthwhile
|
|
555
614
|
and falls back to plain JSON if TOON wouldn't reproduce the data exactly.
|
|
556
615
|
|
|
557
|
-
### Backend (SQLite vs PGlite
|
|
616
|
+
### Backend (SQLite vs PGlite)
|
|
558
617
|
AWM ships two storage backends. The installer picks SQLite by default; both
|
|
559
618
|
are functionally equivalent for cognitive workloads, but differ in operational
|
|
560
619
|
guarantees:
|
|
@@ -574,15 +633,26 @@ For the comparison table (recall quality parity, BM25 vs \`ts_rank_cd\`,
|
|
|
574
633
|
multi-process guarantees), see \`docs/pglite-feature-parity.md\`.
|
|
575
634
|
|
|
576
635
|
### Diagnostics / escape hatches (env vars, only if you know why)
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
636
|
+
Each optimisation is gated by an env var so it can be disabled for A/B testing if a
|
|
637
|
+
regression appears in your workload. \`memory_whoami\` prints the active fingerprint.
|
|
638
|
+
|
|
639
|
+
Retrieval (set ON by \`awm setup\` since 0.14.6 — the measured-good configuration):
|
|
640
|
+
- \`AWM_RERANK2=1\` — second-stage rerank by the cross-encoder's own score.
|
|
641
|
+
- \`AWM_RERANK_WINDOW=query\` — 400-char rerank window on the densest query-term
|
|
642
|
+
region instead of the prefix (25% → 87.5% on long memories).
|
|
643
|
+
- \`AWM_RERANK_TAGS=1\` — tags fed into the rerank passage (+7.4pp s@1).
|
|
644
|
+
|
|
645
|
+
Hook sidecar (0.14.2):
|
|
646
|
+
- \`AWM_HOOK_PORT=8401\` / \`AWM_HOOK_PORT_RANGE=10\` — each MCP process binds the
|
|
647
|
+
first free port in the range, so several sessions can run at once. The shipped
|
|
648
|
+
hooks find their own session's sidecar by probing the range and matching
|
|
649
|
+
\`agentId\` on \`/health\`; \`memory_whoami\` reports the port actually bound.
|
|
650
|
+
|
|
651
|
+
Recall pipeline:
|
|
583
652
|
- \`AWM_DISABLE_POOL_FILTER=1\` — disables the candidate pool reduction
|
|
584
653
|
pre-filter in recall. Reverts to scoring all active candidates.
|
|
585
|
-
- \`AWM_ENTITY_INDEX_FETCH=1\` — see "Entity index" above (
|
|
654
|
+
- \`AWM_ENTITY_INDEX_FETCH=1\` — see "Entity index" above (default off; measured
|
|
655
|
+
no effect on the real-store benchmark, 0.14.5).
|
|
586
656
|
- \`AWM_DISABLE_SLIM_CACHE=1\` — disables the in-memory slim cache.
|
|
587
657
|
Reverts to per-recall SQL fetch + Buffer→Float32Array conversion.
|
|
588
658
|
- \`AWM_DISABLE_RERANK_SKIP=1\` — disables the cross-encoder skip on
|
|
@@ -590,8 +660,8 @@ Recall pipeline (0.7.x):
|
|
|
590
660
|
- \`AWM_DISABLE_EXPANSION_CACHE=1\` — disables the query expansion skip
|
|
591
661
|
heuristic + LRU cache. Forces every recall through flan-t5-small.
|
|
592
662
|
|
|
593
|
-
Write pipeline + lifecycle
|
|
594
|
-
- \`AWM_SLOW_WRITE_MS=250\`
|
|
663
|
+
Write pipeline + lifecycle:
|
|
664
|
+
- \`AWM_SLOW_WRITE_MS=250\` — any write slower than this logs one stderr
|
|
595
665
|
line with a phase-time breakdown (embed/novelty/persist, event-loop lag,
|
|
596
666
|
embed-model cold-load ms). \`0\` disables. Useful for diagnosing why a session's
|
|
597
667
|
first write/recall feels slow.
|
|
@@ -607,7 +677,7 @@ Write pipeline + lifecycle (0.8.x, plus 0.12.x telemetry):
|
|
|
607
677
|
- \`AWM_GRANULARITY_FULL_LEN=1000\` — char budget for the top result in
|
|
608
678
|
\`granularity: 'auto'\` mode when there's a clear winner.
|
|
609
679
|
|
|
610
|
-
PGlite backend
|
|
680
|
+
PGlite backend:
|
|
611
681
|
- \`AWM_PGLITE_BM25_M=1\` — multiplier on PGlite \`ts_rank_cd\` to calibrate
|
|
612
682
|
against SQLite FTS5 BM25 distribution. M=1 (default) is passthrough;
|
|
613
683
|
higher M boosts PGlite scores at the cost of recall-ranking precision
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/adapters/common.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,sCAAsC;AAEtC;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../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O,GACX,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,aAAa,CAAC,UAAU,CAAC,GAAG,MAAM;QAClC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAClC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,GAAG,KAAK,8DAA8D,CAAC;AAChF,CAAC;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8atC,CAAC,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Claude Code hook scripts shipped by `awm setup` (0.14.6).
|
|
3
|
+
*
|
|
4
|
+
* WHY SCRIPTS AND NOT INLINE CURL
|
|
5
|
+
* -------------------------------
|
|
6
|
+
* Until 0.14.5 `awm setup` wrote PreCompact/SessionEnd hooks as one-line curl
|
|
7
|
+
* commands with the sidecar port and the bearer secret baked into
|
|
8
|
+
* settings.json. Three things broke, each silently:
|
|
9
|
+
*
|
|
10
|
+
* 1. The port was fixed (8401, falling back to 8402). Since 0.14.2 every MCP
|
|
11
|
+
* process binds the first free port in 8401..8410, so a session that lands
|
|
12
|
+
* on 8403 had no hooks at all — and with two pools open, the fallback
|
|
13
|
+
* posted a work session's checkpoint into the personal pool's process.
|
|
14
|
+
* 2. The secret was a literal in settings.json. When the secret file was
|
|
15
|
+
* regenerated the hooks got 401s, and `curl -sf` hid them. Observed twice.
|
|
16
|
+
* 3. There was no prime hook. The only mechanism that injects memory without
|
|
17
|
+
* the model choosing to call recall was a documentation page.
|
|
18
|
+
*
|
|
19
|
+
* These scripts resolve everything at run time: which agent this session is
|
|
20
|
+
* (from the MCP config that governs its cwd), which sidecar belongs to that
|
|
21
|
+
* agent (by probing the port range and reading /health), and the secret (from
|
|
22
|
+
* the same config, or the secret file next to the database). Nothing here is
|
|
23
|
+
* baked in at setup time except a fallback record in ~/.claude/hooks/awm-hooks.json.
|
|
24
|
+
*
|
|
25
|
+
* Every script fails OPEN: any problem prints nothing and exits 0. A hook that
|
|
26
|
+
* blocks a prompt or a compaction is worse than no hook.
|
|
27
|
+
*
|
|
28
|
+
* The JavaScript bodies deliberately avoid template literals so they can live
|
|
29
|
+
* inside these TypeScript template strings without escaping.
|
|
30
|
+
*/
|
|
31
|
+
/** Bumped when any shipped script changes; written into awm-hooks.json and the
|
|
32
|
+
* script headers so `awm doctor` can tell a stale install from a current one. */
|
|
33
|
+
export declare const AWM_HOOKS_VERSION = "0.14.6";
|
|
34
|
+
/** File whose presence turns the prime hook off without uninstalling it. */
|
|
35
|
+
export declare const PRIME_DISABLE_FILE = "awm-prime.disabled";
|
|
36
|
+
export declare const FIND_SIDECAR_SCRIPT: string;
|
|
37
|
+
export declare const CHECKPOINT_HOOK_SCRIPT: string;
|
|
38
|
+
export declare const PRIME_HOOK_SCRIPT: string;
|
|
39
|
+
/** Everything `awm setup` places in ~/.claude/hooks/. */
|
|
40
|
+
export declare const HOOK_SCRIPTS: ReadonlyArray<{
|
|
41
|
+
file: string;
|
|
42
|
+
source: string;
|
|
43
|
+
}>;
|
|
44
|
+
/** The fallback record the finder reads when no MCP config governs a cwd. */
|
|
45
|
+
export interface HooksRecord {
|
|
46
|
+
version: string;
|
|
47
|
+
agentId: string;
|
|
48
|
+
dbPath: string;
|
|
49
|
+
secretPath: string;
|
|
50
|
+
hookPort: string;
|
|
51
|
+
hookPortRange: string;
|
|
52
|
+
installedAt: string;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=hook-scripts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hook-scripts.d.ts","sourceRoot":"","sources":["../../src/adapters/hook-scripts.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;kFACkF;AAClF,eAAO,MAAM,iBAAiB,WAAW,CAAC;AAE1C,4EAA4E;AAC5E,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AAUvD,eAAO,MAAM,mBAAmB,QAgJ/B,CAAC;AAIF,eAAO,MAAM,sBAAsB,QAsDlC,CAAC;AAIF,eAAO,MAAM,iBAAiB,QAgG7B,CAAC;AAEF,yDAAyD;AACzD,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAIxE,CAAC;AAEF,6EAA6E;AAC7E,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;CACrB"}
|