@duetso/agent 0.1.200 → 0.1.202
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 +40 -3
- package/dist/package.json +1 -1
- package/dist/src/cli/help.d.ts +1 -0
- package/dist/src/cli/help.d.ts.map +1 -1
- package/dist/src/cli/help.js +58 -5
- package/dist/src/cli/help.js.map +1 -1
- package/dist/src/cli/inline-slash.js +1 -1
- package/dist/src/cli/memory-add.d.ts +8 -1
- package/dist/src/cli/memory-add.d.ts.map +1 -1
- package/dist/src/cli/memory-add.js +49 -53
- package/dist/src/cli/memory-add.js.map +1 -1
- package/dist/src/cli/memory-db.d.ts +23 -0
- package/dist/src/cli/memory-db.d.ts.map +1 -1
- package/dist/src/cli/memory-db.js +48 -1
- package/dist/src/cli/memory-db.js.map +1 -1
- package/dist/src/cli/memory-json.d.ts +67 -0
- package/dist/src/cli/memory-json.d.ts.map +1 -0
- package/dist/src/cli/memory-json.js +28 -0
- package/dist/src/cli/memory-json.js.map +1 -0
- package/dist/src/cli/memory-query.d.ts +20 -1
- package/dist/src/cli/memory-query.d.ts.map +1 -1
- package/dist/src/cli/memory-query.js +45 -20
- package/dist/src/cli/memory-query.js.map +1 -1
- package/dist/src/cli/memory-recall.d.ts +53 -0
- package/dist/src/cli/memory-recall.d.ts.map +1 -0
- package/dist/src/cli/memory-recall.js +217 -0
- package/dist/src/cli/memory-recall.js.map +1 -0
- package/dist/src/cli/memory.d.ts +3 -1
- package/dist/src/cli/memory.d.ts.map +1 -1
- package/dist/src/cli/memory.js +10 -4
- package/dist/src/cli/memory.js.map +1 -1
- package/dist/src/cli/rpc.d.ts +19 -3
- package/dist/src/cli/rpc.d.ts.map +1 -1
- package/dist/src/cli/rpc.js +19 -3
- package/dist/src/cli/rpc.js.map +1 -1
- package/dist/src/cli/run.d.ts +8 -0
- package/dist/src/cli/run.d.ts.map +1 -1
- package/dist/src/cli/run.js +6 -5
- package/dist/src/cli/run.js.map +1 -1
- package/dist/src/cli/shared.d.ts +16 -3
- package/dist/src/cli/shared.d.ts.map +1 -1
- package/dist/src/cli/shared.js +19 -4
- package/dist/src/cli/shared.js.map +1 -1
- package/dist/src/cli/train.d.ts.map +1 -1
- package/dist/src/cli/train.js +39 -22
- package/dist/src/cli/train.js.map +1 -1
- package/dist/src/cli.d.ts +1 -0
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/cli.js +1 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/memory/recall.d.ts +44 -0
- package/dist/src/memory/recall.d.ts.map +1 -1
- package/dist/src/memory/recall.js +92 -6
- package/dist/src/memory/recall.js.map +1 -1
- package/dist/src/model-resolution/catalog.d.ts.map +1 -1
- package/dist/src/model-resolution/catalog.js +17 -0
- package/dist/src/model-resolution/catalog.js.map +1 -1
- package/dist/src/model-resolution/duet-gateway.d.ts +2 -2
- package/dist/src/model-resolution/duet-gateway.d.ts.map +1 -1
- package/dist/src/model-resolution/duet-gateway.js +16 -13
- package/dist/src/model-resolution/duet-gateway.js.map +1 -1
- package/dist/src/tui/app.d.ts +2 -2
- package/dist/src/tui/app.d.ts.map +1 -1
- package/dist/src/tui/app.js +20 -2
- package/dist/src/tui/app.js.map +1 -1
- package/dist/src/tui/paste-controller.d.ts +3 -0
- package/dist/src/tui/paste-controller.d.ts.map +1 -1
- package/dist/src/tui/paste-controller.js +25 -0
- package/dist/src/tui/paste-controller.js.map +1 -1
- package/dist/src/tui/session-subscription.d.ts +10 -0
- package/dist/src/tui/session-subscription.d.ts.map +1 -1
- package/dist/src/tui/session-subscription.js +22 -5
- package/dist/src/tui/session-subscription.js.map +1 -1
- package/dist/src/tui/slash-commands.d.ts +4 -4
- package/dist/src/tui/slash-commands.js +4 -4
- package/dist/src/turn-runner/tools.d.ts.map +1 -1
- package/dist/src/turn-runner/tools.js +15 -54
- package/dist/src/turn-runner/tools.js.map +1 -1
- package/dist/src/types/memory.d.ts +11 -0
- package/dist/src/types/memory.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -327,12 +327,12 @@ Type `/` in the composer to open the command picker, or send any of these as a m
|
|
|
327
327
|
- **`/model <name>`** — switch the model used for **subsequent** turns. Accepts the same shorthands and `provider:modelId` forms as the `--model` flag (e.g. `/model sonnet-4.6`, `/model anthropic:claude-opus-4-7`). Unknown shorthands or missing provider credentials surface an error and leave the current model in place. The in-flight turn (if any) keeps the model it started with.
|
|
328
328
|
- **`/thinking <level>`** — switch the thinking level for the **next** turn. One of `minimal`, `low`, `medium`, `high`, `xhigh`. The runner clamps to the active model's supported range at use-time. The in-flight turn (if any) keeps its level.
|
|
329
329
|
- **`/feedback <message>`** — send free-form feedback to the Duet team.
|
|
330
|
-
- **`/
|
|
330
|
+
- **`/clear`** — dispose the current session and start a fresh one.
|
|
331
331
|
- **`/copy [last|all|<N>]`** — copy transcript text to the system clipboard (default: last agent reply).
|
|
332
332
|
- **`/paste`**, **`/image <path>`**, **`/clear-images`** — image-attachment helpers, covered in the next section.
|
|
333
333
|
- **`/diag`** — toggle key and selection event logging when triaging terminal-specific issues.
|
|
334
334
|
|
|
335
|
-
`/model`, `/thinking`, `/
|
|
335
|
+
`/model`, `/thinking`, `/clear`, `/paste`, `/clear-images`, and `/diag` also work **anywhere inside a longer prompt**. `hey can you review this /model gpt-5.5` swaps the model for the very turn that delivers the message; the slash form is stripped from what the agent sees, so the model receives `hey can you review this`. When the whole prompt is just slash commands, no agent turn runs at all. Commands that take rest-of-line arguments (`/feedback`, `/copy`, `/image`) only fire when they own the whole message.
|
|
336
336
|
|
|
337
337
|
The inline form also works for the non-TUI one-shot CLI: `duet "hey can you review this /model gpt-5.5"` swaps the model and dispatches the stripped prompt to the agent; `duet "/model gpt-5.5"` applies the swap and exits without dispatching a turn.
|
|
338
338
|
|
|
@@ -353,6 +353,43 @@ The interactive TUI accepts image attachments (PNG, JPEG, GIF, WebP):
|
|
|
353
353
|
|
|
354
354
|
</details>
|
|
355
355
|
|
|
356
|
+
<details>
|
|
357
|
+
<summary><b>Query, recall, and add durable memory from the CLI</b></summary>
|
|
358
|
+
|
|
359
|
+
The same `~/.duet/memory.db` the runner reads is scriptable from the CLI. Bare `duet memory` opens the interactive TUI; adding `--json` or any filter turns the same invocation into a non-interactive query. Three subcommands cover the write and search paths:
|
|
360
|
+
|
|
361
|
+
```bash
|
|
362
|
+
# Filter/query mode — bare array of canonical memory objects
|
|
363
|
+
duet memory --json --type reflection --from 2026-06-26
|
|
364
|
+
duet memory --json --source user --session sess_abc123 # rows authored by one session
|
|
365
|
+
|
|
366
|
+
# Recall — hybrid semantic + keyword search, same pipeline as the recall_memory tool
|
|
367
|
+
duet memory recall wire byte budget cap # positional query
|
|
368
|
+
duet memory recall --query "how does the gateway race resolve" --expand
|
|
369
|
+
duet memory recall --scope global --session sess_abc123 --json qwiklabs
|
|
370
|
+
|
|
371
|
+
# Add — write a single user-authored note
|
|
372
|
+
duet memory add --priority high --tag billing "Enterprise discounts cap at 20%"
|
|
373
|
+
echo "note from a pipe" | duet memory add --source import --session sess_abc123 --json
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
All three share one **canonical memory JSON object** (`--json`), so a consumer parses one shape everywhere:
|
|
377
|
+
|
|
378
|
+
- Timestamps are ISO 8601 strings (e.g. `2026-07-06T00:00:00.000Z`); date-only fields (`observedDate`, `referencedDate`) stay `YYYY-MM-DD`.
|
|
379
|
+
- `source` is a flat string — one of `user | agent | system | api | import` (`system` is the training-origin value).
|
|
380
|
+
- `sessionId` is the session that authored the row: writable on `add` via `--session <id>`, filterable on `memory`/`recall` via `--session`, and echoed on output (absent on legacy rows).
|
|
381
|
+
- Two ranking scores are always named explicitly, never a generic `score`: `packScore` (recency × priority × kind bias, present everywhere) and `relevanceScore` (query-relevance, RRF-fused — present only in `memory recall` results).
|
|
382
|
+
|
|
383
|
+
Command-specific notes:
|
|
384
|
+
|
|
385
|
+
- **`duet memory` (query):** `--json` emits a bare array ordered by pack score; `--source` and `--session` narrow the set alongside `--type`, `--priority`, `--from`, and `--to`.
|
|
386
|
+
- **`duet memory recall`:** query text comes from `--query <q>` or positional args. `--scope session|global` requires `--session <id>` to compare against; `all` (default) ignores it. `--json` emits a bare array ordered best-first, each row carrying both `packScore` and `relevanceScore`.
|
|
387
|
+
- **`duet memory add`:** added rows are always `note` kind. `--source` defaults to `user`; `--session <id>` stamps the row (omit to leave it global). Content comes from positional args or stdin, and empty input is a usage error. `--json` emits one canonical object (`packScore` and `lastUsedAt` present, `relevanceScore` absent).
|
|
388
|
+
|
|
389
|
+
Every memory command accepts `--db <absolute-path>` (default `~/.duet/memory.db`) and `--wait <seconds>` (lock-wait budget, default 30; `0` fails immediately). Exit codes are stable for scripting: `0` success, `64` usage or validation error (unknown flag, bad value, empty input), `75` memory-DB lock-wait budget exhausted, and `1` for anything else.
|
|
390
|
+
|
|
391
|
+
</details>
|
|
392
|
+
|
|
356
393
|
<details>
|
|
357
394
|
<summary><b>Train a folder of docs into durable memory</b></summary>
|
|
358
395
|
|
|
@@ -508,7 +545,7 @@ const turnRunner = new TurnRunner({
|
|
|
508
545
|
});
|
|
509
546
|
```
|
|
510
547
|
|
|
511
|
-
By default, both `duet` (TUI/run) and `duet --rpc` store durable observations in `~/.duet/memory.db`. Override the path with `--db <path>` (the flag is accepted in both modes and is ignored when `--incognito` is also set), or run with `--incognito` (or `-i`) to set `memoryDbPath: false`, which disables observational memory and compaction for that session. Programmatic callers can pass `memoryDbPath: false` or provide a custom `memoryDbPath`. The CLI's `SessionManager` is a convenience layer that stores session snapshots under `~/.duet/sessions`, but the runner owns memory hydration, pi-turn observation/reflection, compaction, and observation persistence.
|
|
548
|
+
By default, both `duet` (TUI/run) and `duet --rpc` store durable observations in `~/.duet/memory.db`. Override the path with `--db <path>` (the flag is accepted in both modes and is ignored when `--incognito` is also set), or run with `--incognito` (or `-i`) to set `memoryDbPath: false`, which disables observational memory and compaction for that session. `duet --rpc` bypasses `SessionManager`, so it has no session of its own; pass `duet --rpc --session <id>` to attribute every observation written during the RPC process to a caller-owned session (one RPC process is one logical session). Omit it to leave those writes unattributed. Programmatic callers can pass `memoryDbPath: false` or provide a custom `memoryDbPath`. The CLI's `SessionManager` is a convenience layer that stores session snapshots under `~/.duet/sessions`, but the runner owns memory hydration, pi-turn observation/reflection, compaction, and observation persistence.
|
|
512
549
|
|
|
513
550
|
> [!WARNING]
|
|
514
551
|
> We strongly recommend running with a `memoryDbPath` (the default). Compaction is implemented as part of the observational memory pipeline: raw transcript content is replaced by observations/reflections that the observer and reflector write to the durable store. Without a database, the runner skips that pipeline entirely — there is no compaction, the transcript grows unbounded against the raw model context window, and long sessions will eventually hit a provider context-length error. `memoryDbPath: false` is appropriate for short-lived scripts, tests, and incognito runs that stay well under the model window.
|
package/dist/package.json
CHANGED
package/dist/src/cli/help.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare function printEnvHelp(): void;
|
|
|
11
11
|
export declare function printSkillsHelp(): void;
|
|
12
12
|
export declare function printMemoryHelp(): void;
|
|
13
13
|
export declare function printMemoryAddHelp(): void;
|
|
14
|
+
export declare function printMemoryRecallHelp(): void;
|
|
14
15
|
export declare function printMemoryReflectHelp(): void;
|
|
15
16
|
export declare function printModelHelp(): void;
|
|
16
17
|
export declare function printTrainHelp(): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/cli/help.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAEjD,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"help.d.ts","sourceRoot":"","sources":["../../../src/cli/help.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B,IAAI,CAAC;AAEjD,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CA2FtD;AAED,wBAAgB,cAAc,IAAI,IAAI,CA0BrC;AAED,wBAAgB,YAAY,IAAI,IAAI,CAsBnC;AAED,wBAAgB,eAAe,IAAI,IAAI,CAqBtC;AAED,wBAAgB,eAAe,IAAI,IAAI,CA4DtC;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CA8BzC;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAwC5C;AAED,wBAAgB,sBAAsB,IAAI,IAAI,CAuC7C;AAED,wBAAgB,cAAc,IAAI,IAAI,CAsCrC;AAED,wBAAgB,cAAc,IAAI,IAAI,CA+DrC;AAED,wBAAgB,qBAAqB,IAAI,IAAI,CAiB5C;AAED,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAe1D"}
|
package/dist/src/cli/help.js
CHANGED
|
@@ -53,6 +53,8 @@ OPTIONS
|
|
|
53
53
|
JSON from stdin and writes TurnEvent JSON to stdout. The first command must
|
|
54
54
|
be "start"; the process exits after the single turn reaches its terminal
|
|
55
55
|
event. Bypasses session persistence entirely.
|
|
56
|
+
--session <id> (--rpc only) Attribute memory written during the process to this caller-owned
|
|
57
|
+
session id. One RPC process is one logical session; omit to write with no id.
|
|
56
58
|
-v, --version Print the installed duet version and exit
|
|
57
59
|
-h, --help Show this help
|
|
58
60
|
|
|
@@ -175,7 +177,7 @@ duet memory — Browse, query, edit, and delete observational memories
|
|
|
175
177
|
USAGE
|
|
176
178
|
duet memory [--db <path>] [--wait <seconds>]
|
|
177
179
|
duet memory [--json] [--type <kind>] [--priority <level>] [--source <origin>]
|
|
178
|
-
[--from <date>] [--to <date>]
|
|
180
|
+
[--session <id>] [--from <date>] [--to <date>]
|
|
179
181
|
duet memory reflect [options]
|
|
180
182
|
|
|
181
183
|
ALIASES
|
|
@@ -185,9 +187,10 @@ DESCRIPTION
|
|
|
185
187
|
Bare \`duet memory\` opens an interactive TUI to browse, edit, and delete
|
|
186
188
|
durable observations. Passing --json or any filter flag instead runs a
|
|
187
189
|
non-TUI, scriptable query: it prints a flat, chronological list (newest
|
|
188
|
-
createdAt first) of the matching observations
|
|
189
|
-
\`score\`
|
|
190
|
-
|
|
190
|
+
createdAt first) of the matching observations. In table mode each row shows
|
|
191
|
+
a computed \`score\` matching the runner's global-pack ranking; --json emits
|
|
192
|
+
a machine-readable array of canonical memory objects (ISO timestamps, flat
|
|
193
|
+
\`source\` string, echoed \`sessionId\`, and that score as \`packScore\`).
|
|
191
194
|
|
|
192
195
|
Examples:
|
|
193
196
|
duet memory
|
|
@@ -197,6 +200,9 @@ DESCRIPTION
|
|
|
197
200
|
SUBCOMMANDS
|
|
198
201
|
add Write a single user-added note memory
|
|
199
202
|
(run \`duet memory add --help\` for add-specific options)
|
|
203
|
+
recall <query> Hybrid semantic + keyword search over durable memory,
|
|
204
|
+
the same pipeline the runner's recall_memory tool uses
|
|
205
|
+
(run \`duet memory recall --help\` for recall-specific options)
|
|
200
206
|
reflect Condense old global observations into reflection rows
|
|
201
207
|
(run \`duet memory reflect --help\` for reflect-specific options)
|
|
202
208
|
|
|
@@ -205,7 +211,8 @@ QUERY OPTIONS
|
|
|
205
211
|
--type <kind> Filter by kind: observation | reflection | note | manual
|
|
206
212
|
--kind <kind> Alias for --type
|
|
207
213
|
--priority <level> Filter by priority: high | medium | low
|
|
208
|
-
--source <origin> Filter by source: user | agent | system
|
|
214
|
+
--source <origin> Filter by source: user | agent | system | api | import
|
|
215
|
+
--session <id> Filter to rows authored by this session id
|
|
209
216
|
--from <date> Inclusive lower bound on createdAt. Accepts
|
|
210
217
|
YYYY-MM-DD (start of day UTC) or YYYY-MM-DDTHH:MM:SS (UTC)
|
|
211
218
|
--to <date> Inclusive upper bound on createdAt. Accepts
|
|
@@ -243,8 +250,54 @@ DESCRIPTION
|
|
|
243
250
|
|
|
244
251
|
OPTIONS
|
|
245
252
|
--priority <level> high, medium, or low (default: medium)
|
|
253
|
+
--source <origin> user, agent, system, api, or import (default: user)
|
|
254
|
+
--session <id> Stamp the row's authoring session; omit to leave it
|
|
255
|
+
global/unattributed
|
|
246
256
|
--tag <tag> Attach a label; repeat to add several
|
|
247
257
|
--db <path> Memory database path (default: ~/.duet/memory.db)
|
|
258
|
+
--json Emit the stored memory as one canonical JSON object
|
|
259
|
+
(with packScore) instead of the confirmation line
|
|
260
|
+
--wait <seconds> Seconds to wait for the cross-process open-lock
|
|
261
|
+
(default: 30; 0 fails immediately)
|
|
262
|
+
-h, --help Show this help
|
|
263
|
+
`);
|
|
264
|
+
}
|
|
265
|
+
export function printMemoryRecallHelp() {
|
|
266
|
+
console.log(`
|
|
267
|
+
duet memory recall — Hybrid semantic + keyword search over durable memory
|
|
268
|
+
|
|
269
|
+
USAGE
|
|
270
|
+
duet memory recall [options] [--query <q> | <query...>]
|
|
271
|
+
|
|
272
|
+
DESCRIPTION
|
|
273
|
+
Searches ~/.duet/memory.db with the exact pipeline the runner's
|
|
274
|
+
recall_memory tool uses: vector (embedding) search and keyword search run
|
|
275
|
+
in parallel and merge via Reciprocal Rank Fusion, so fuzzy paraphrases and
|
|
276
|
+
exact tokens (proper nouns, IDs, code symbols) both match. Results print
|
|
277
|
+
best-match first.
|
|
278
|
+
|
|
279
|
+
Embeddings use the Duet endpoint (DUET_API_KEY). When it is unavailable the
|
|
280
|
+
vector path is skipped and recall falls back to keyword-only, flagged in the
|
|
281
|
+
output. --expand adds model-generated paraphrases before fusion for vague
|
|
282
|
+
queries, at the cost of an extra model call.
|
|
283
|
+
|
|
284
|
+
Examples:
|
|
285
|
+
duet memory recall wire byte budget cap
|
|
286
|
+
duet memory recall --expand "how does the gateway race resolve"
|
|
287
|
+
duet memory recall --scope global --session <id> --json qwiklabs
|
|
288
|
+
|
|
289
|
+
OPTIONS
|
|
290
|
+
--query <q> Search text (alternative to positional <query>;
|
|
291
|
+
both are accepted and combine)
|
|
292
|
+
--scope <scope> session | global | all (default: all).
|
|
293
|
+
session/global require --session <id>
|
|
294
|
+
--session <id> Session id to compare against for --scope session/global
|
|
295
|
+
--limit <n> Maximum fused results to return (default: 8)
|
|
296
|
+
--expand Also run model-generated paraphrases before fusion
|
|
297
|
+
--model <name> Model used for --expand paraphrases (default: cheap CLI memory model)
|
|
298
|
+
--json Emit a bare JSON array of canonical memory objects
|
|
299
|
+
(best-first) with packScore + relevanceScore
|
|
300
|
+
--db <path> Memory database path (default: ~/.duet/memory.db)
|
|
248
301
|
--wait <seconds> Seconds to wait for the cross-process open-lock
|
|
249
302
|
(default: 30; 0 fails immediately)
|
|
250
303
|
-h, --help Show this help
|
package/dist/src/cli/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/cli/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAEjD,MAAM,UAAU,YAAY,CAAC,WAAmB;IAC9C,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;gDAqBkC,WAAW;;;;;;;;;;;;;gHAaqD,+BAA+B;;;;;oFAK3D,qBAAqB
|
|
1
|
+
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../../src/cli/help.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAExE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAEjD,MAAM,UAAU,YAAY,CAAC,WAAmB;IAC9C,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;gDAqBkC,WAAW;;;;;;;;;;;;;gHAaqD,+BAA+B;;;;;oFAK3D,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDxG,CAAC,CAAC;AACH,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,CAAC,GAAG,CAAC;;;;;;;;;;;wEAW0D,qBAAqB;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AED,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IAClD,OAAO,CAAC,GAAG,CAAC;oCACsB,WAAW;;;;;;;;;;;;CAY9C,CAAC,CAAC;AACH,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { resolveModelName } from "../model-resolution/resolver.js";
|
|
2
2
|
import { validateThinkingLevel } from "../session/thinking-level.js";
|
|
3
3
|
import { applyInlineSlashCommands } from "../tui/slash-commands.js";
|
|
4
|
-
/** Slash commands the non-TUI CLI applies inline. /
|
|
4
|
+
/** Slash commands the non-TUI CLI applies inline. /clear, /paste, /clear-images, /diag
|
|
5
5
|
* have no meaning in a one-shot run so the CLI intentionally ignores them. */
|
|
6
6
|
const CLI_INLINE_COMMANDS = new Set(["model", "thinking"]);
|
|
7
7
|
/**
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import type { ObservationPriority } from "../types/memory.js";
|
|
1
|
+
import type { ObservationPriority, ObservationSource } from "../types/memory.js";
|
|
2
|
+
type SourceKind = ObservationSource["kind"];
|
|
2
3
|
interface AddCommandOptions {
|
|
3
4
|
dbPath: string;
|
|
4
5
|
/** Positional content joined with spaces; empty when the caller pipes via stdin instead. */
|
|
5
6
|
content: string;
|
|
6
7
|
priority: ObservationPriority;
|
|
8
|
+
/** Provenance stamped on the row and echoed back; defaults to `user`. */
|
|
9
|
+
source: SourceKind;
|
|
7
10
|
tags: string[];
|
|
11
|
+
/** Session that authored the row; omitted leaves the row global/unattributed. */
|
|
12
|
+
sessionId?: string;
|
|
13
|
+
/** Emit one canonical memory JSON object instead of the human line. */
|
|
14
|
+
json: boolean;
|
|
8
15
|
waitBudgetMs?: number;
|
|
9
16
|
}
|
|
10
17
|
interface AddCommandIO {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-add.d.ts","sourceRoot":"","sources":["../../../src/cli/memory-add.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory-add.d.ts","sourceRoot":"","sources":["../../../src/cli/memory-add.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAOjF,KAAK,UAAU,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAE5C,UAAU,iBAAiB;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,4FAA4F;IAC5F,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,yEAAyE;IACzE,MAAM,EAAE,UAAU,CAAC;IACnB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,UAAU,YAAY;IACpB,MAAM,EAAE,MAAM,CAAC,cAAc,CAAC;IAC9B,KAAK,EAAE,MAAM,CAAC,cAAc,GAAG;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CACpD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EAAE,EACd,EAAE,GAAE,YAA+D,GAClE,OAAO,CAAC,IAAI,CAAC,CAqCf;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,iBAAiB,GAAG,SAAS,CA+DhF"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { runMigrations } from "../memory/migrations.js";
|
|
2
|
-
import { MemoryLockTimeoutError } from "../memory/pglite.js";
|
|
3
|
-
import { MemorySession } from "../memory/session.js";
|
|
4
1
|
import { appendObservation } from "../memory/storage.js";
|
|
5
2
|
import { DEFAULT_MEMORY_DB_PATH } from "../session/session-manager.js";
|
|
6
3
|
import { printMemoryAddHelp } from "./help.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { toMemoryJson } from "./memory-json.js";
|
|
5
|
+
import { scoreObservation, withMemorySession } from "./memory-db.js";
|
|
6
|
+
import { PRIORITIES, parseEnum, SOURCES } from "./memory-query.js";
|
|
7
|
+
import { fail, resolveUserPath, usageError } from "./shared.js";
|
|
9
8
|
/**
|
|
10
9
|
* Run `duet memory add` — write a single user-added note row into the same
|
|
11
10
|
* `~/.duet/memory.db` the runner reads from, so it surfaces in the next
|
|
@@ -25,44 +24,29 @@ export async function runMemoryAddCommand(args, io = { stdout: process.stdout, s
|
|
|
25
24
|
if (!options)
|
|
26
25
|
return;
|
|
27
26
|
const content = await resolveContent(options.content, io);
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
...(options.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
const observation = await appendObservation(session, {
|
|
41
|
-
kind: "note",
|
|
42
|
-
priority: options.priority,
|
|
43
|
-
source: { kind: "user" },
|
|
44
|
-
content,
|
|
45
|
-
tags: options.tags,
|
|
46
|
-
observedDate: new Date().toISOString().slice(0, 10),
|
|
47
|
-
});
|
|
48
|
-
if (!observation) {
|
|
49
|
-
fail(`Could not write memory to ${options.dbPath} (lock contention).`);
|
|
50
|
-
}
|
|
51
|
-
const tagSuffix = observation.tags.length > 0 ? ` [${observation.tags.join(", ")}]` : "";
|
|
52
|
-
io.stdout.write(`Added ${observation.priority}-priority memory ${observation.id} (${observation.observedDate})${tagSuffix}\n`);
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
if (error instanceof MemoryLockTimeoutError) {
|
|
56
|
-
fail(`Memory database at ${error.dataDir} is still locked by duet pid ${error.holderPid} after ${error.budgetMs / 1000}s. Stop that process (or pass --wait <seconds> to wait longer) and retry.`);
|
|
57
|
-
}
|
|
58
|
-
throw error;
|
|
27
|
+
const observation = await withMemorySession(options.dbPath, (session) => appendObservation(session, {
|
|
28
|
+
kind: "note",
|
|
29
|
+
priority: options.priority,
|
|
30
|
+
source: { kind: options.source },
|
|
31
|
+
content,
|
|
32
|
+
tags: options.tags,
|
|
33
|
+
observedDate: new Date().toISOString().slice(0, 10),
|
|
34
|
+
...(options.sessionId !== undefined ? { sessionId: options.sessionId } : {}),
|
|
35
|
+
}), { waitBudgetMs: options.waitBudgetMs });
|
|
36
|
+
if (!observation) {
|
|
37
|
+
fail(`Could not write memory to ${options.dbPath} (lock contention).`);
|
|
59
38
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
39
|
+
if (options.json) {
|
|
40
|
+
// Score with a single `now`; on insert `lastUsedAt == createdAt`, so the
|
|
41
|
+
// pack score reflects a freshly stored row. `relevanceScore` is absent —
|
|
42
|
+
// there is no query to rank the row against on an add.
|
|
43
|
+
const packScore = scoreObservation(observation, Date.now());
|
|
44
|
+
io.stdout.write(`${JSON.stringify(toMemoryJson(observation, { packScore }), null, 2)}\n`);
|
|
45
|
+
return;
|
|
63
46
|
}
|
|
47
|
+
const tagSuffix = observation.tags.length > 0 ? ` [${observation.tags.join(", ")}]` : "";
|
|
48
|
+
io.stdout.write(`Added ${observation.priority}-priority memory ${observation.id} (${observation.observedDate})${tagSuffix}\n`);
|
|
64
49
|
}
|
|
65
|
-
const PRIORITIES = ["high", "medium", "low"];
|
|
66
50
|
/**
|
|
67
51
|
* Parse `duet memory add` flags and positional content. Returns `undefined`
|
|
68
52
|
* when `--help` was handled. Pure (no I/O) so it can be unit-tested; stdin
|
|
@@ -71,6 +55,9 @@ const PRIORITIES = ["high", "medium", "low"];
|
|
|
71
55
|
export function parseMemoryAddArgs(args) {
|
|
72
56
|
let dbPath = DEFAULT_MEMORY_DB_PATH;
|
|
73
57
|
let priority = "medium";
|
|
58
|
+
let source = "user";
|
|
59
|
+
let sessionId;
|
|
60
|
+
let json = false;
|
|
74
61
|
const tags = [];
|
|
75
62
|
let waitBudgetMs;
|
|
76
63
|
const contentParts = [];
|
|
@@ -79,27 +66,33 @@ export function parseMemoryAddArgs(args) {
|
|
|
79
66
|
switch (arg) {
|
|
80
67
|
case "--db":
|
|
81
68
|
if (!args[i + 1] || args[i + 1]?.startsWith("-"))
|
|
82
|
-
|
|
69
|
+
usageError(`Missing value for ${arg}`);
|
|
83
70
|
dbPath = resolveUserPath(args[++i]);
|
|
84
71
|
break;
|
|
85
|
-
case "--priority":
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
72
|
+
case "--priority":
|
|
73
|
+
priority = parseEnum(args[++i], PRIORITIES, arg);
|
|
74
|
+
break;
|
|
75
|
+
case "--source":
|
|
76
|
+
source = parseEnum(args[++i], SOURCES, arg);
|
|
77
|
+
break;
|
|
78
|
+
case "--session":
|
|
79
|
+
if (!args[i + 1] || args[i + 1]?.startsWith("-"))
|
|
80
|
+
usageError(`Missing value for ${arg}`);
|
|
81
|
+
sessionId = args[++i];
|
|
82
|
+
break;
|
|
83
|
+
case "--json":
|
|
84
|
+
json = true;
|
|
91
85
|
break;
|
|
92
|
-
}
|
|
93
86
|
case "--tag":
|
|
94
87
|
if (!args[i + 1] || args[i + 1]?.startsWith("-"))
|
|
95
|
-
|
|
88
|
+
usageError(`Missing value for ${arg}`);
|
|
96
89
|
tags.push(args[++i]);
|
|
97
90
|
break;
|
|
98
91
|
case "--wait": {
|
|
99
92
|
const raw = args[++i];
|
|
100
93
|
const seconds = Number(raw);
|
|
101
94
|
if (!raw || !Number.isFinite(seconds) || seconds < 0) {
|
|
102
|
-
|
|
95
|
+
usageError(`Invalid --wait value: ${raw} (expected non-negative number of seconds)`);
|
|
103
96
|
}
|
|
104
97
|
waitBudgetMs = Math.round(seconds * 1000);
|
|
105
98
|
break;
|
|
@@ -110,7 +103,7 @@ export function parseMemoryAddArgs(args) {
|
|
|
110
103
|
return undefined;
|
|
111
104
|
default:
|
|
112
105
|
if (arg.startsWith("-"))
|
|
113
|
-
|
|
106
|
+
usageError(`Unknown add option: ${arg}`);
|
|
114
107
|
contentParts.push(arg);
|
|
115
108
|
}
|
|
116
109
|
}
|
|
@@ -118,7 +111,10 @@ export function parseMemoryAddArgs(args) {
|
|
|
118
111
|
dbPath,
|
|
119
112
|
content: contentParts.join(" ").trim(),
|
|
120
113
|
priority,
|
|
114
|
+
source,
|
|
121
115
|
tags,
|
|
116
|
+
json,
|
|
117
|
+
...(sessionId !== undefined ? { sessionId } : {}),
|
|
122
118
|
...(waitBudgetMs !== undefined ? { waitBudgetMs } : {}),
|
|
123
119
|
};
|
|
124
120
|
}
|
|
@@ -131,12 +127,12 @@ async function resolveContent(positional, io) {
|
|
|
131
127
|
let content = positional;
|
|
132
128
|
if (content.length === 0) {
|
|
133
129
|
if (io.stdin.isTTY) {
|
|
134
|
-
|
|
130
|
+
usageError("No memory content provided. Pass it as an argument or pipe via stdin.");
|
|
135
131
|
}
|
|
136
132
|
content = (await readStream(io.stdin)).trim();
|
|
137
133
|
}
|
|
138
134
|
if (content.length === 0)
|
|
139
|
-
|
|
135
|
+
usageError("Refusing to add an empty memory.");
|
|
140
136
|
return content;
|
|
141
137
|
}
|
|
142
138
|
async function readStream(stream) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-add.js","sourceRoot":"","sources":["../../../src/cli/memory-add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"memory-add.js","sourceRoot":"","sources":["../../../src/cli/memory-add.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE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,CAAC,CAAC,IAAI,EAAE,CAAC;IAChD,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,UAAU,CAAC,kCAAkC,CAAC,CAAC;IACzE,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,MAA6B;IACrD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QACjC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IACnE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
+
import { MemoryLockTimeoutError } from "../memory/pglite.js";
|
|
2
|
+
import { MemorySession } from "../memory/session.js";
|
|
1
3
|
import type { TrainListEntry, TrainRecord } from "../train/types.js";
|
|
2
4
|
import type { Observation, ObservationSource } from "../types/memory.js";
|
|
5
|
+
/**
|
|
6
|
+
* Report an exhausted memory-DB open lock and exit `75` (the contract's
|
|
7
|
+
* distinguished lock-wait code, distinct from a generic runtime failure).
|
|
8
|
+
* Every memory/train subcommand funnels its {@link MemoryLockTimeoutError}
|
|
9
|
+
* here so the friendly, actionable message and the exit code stay identical.
|
|
10
|
+
*/
|
|
11
|
+
export declare function failMemoryLockTimeout(error: MemoryLockTimeoutError): never;
|
|
3
12
|
/** Rows fetched per page by the ranked, lazily-paginated TUI list. */
|
|
4
13
|
export declare const MEMORY_PAGE_SIZE = 25;
|
|
5
14
|
export interface MemoryQueryFilters {
|
|
6
15
|
kind?: Observation["kind"];
|
|
7
16
|
priority?: Observation["priority"];
|
|
8
17
|
source?: ObservationSource["kind"];
|
|
18
|
+
/** Restrict to rows authored by this session (matches `session_id`). */
|
|
19
|
+
sessionId?: string;
|
|
9
20
|
fromMs?: number;
|
|
10
21
|
toMs?: number;
|
|
11
22
|
}
|
|
@@ -97,4 +108,16 @@ export declare class MemoryDb {
|
|
|
97
108
|
export declare function withMemoryDb<T>(dbPath: string, fn: (db: MemoryDb) => Promise<T>, { waitBudgetMs }?: {
|
|
98
109
|
waitBudgetMs?: number;
|
|
99
110
|
}): Promise<T>;
|
|
111
|
+
/**
|
|
112
|
+
* Run `fn` against a {@link MemorySession} opened on the shared memory
|
|
113
|
+
* database — the entry point for one-shot CLI commands that need the
|
|
114
|
+
* session's refcounted handle and cross-process lock (writes via
|
|
115
|
+
* `appendObservation`, hybrid recall) rather than the raw {@link MemoryDb}
|
|
116
|
+
* query wrapper. Applies migrations on open, installs shutdown handlers, and
|
|
117
|
+
* always disposes; a lock-contention timeout exits `75` via
|
|
118
|
+
* {@link failMemoryLockTimeout} so callers share one error message and code.
|
|
119
|
+
*/
|
|
120
|
+
export declare function withMemorySession<T>(dbPath: string, fn: (session: MemorySession) => Promise<T>, { waitBudgetMs }?: {
|
|
121
|
+
waitBudgetMs?: number;
|
|
122
|
+
}): Promise<T>;
|
|
100
123
|
//# sourceMappingURL=memory-db.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-db.d.ts","sourceRoot":"","sources":["../../../src/cli/memory-db.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory-db.d.ts","sourceRoot":"","sources":["../../../src/cli/memory-db.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,sBAAsB,EAEvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAGrD,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAI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Ac,EAAE,CAAC;IAOhD;;;;;OAKG;IACG,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;YAO1D,qBAAqB;YAWrB,YAAY;IAe1B,gFAAgF;IAC1E,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/D;;;;;OAKG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAKjC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7B;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAClC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,EAChC,EAAE,YAAY,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAED;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CAAC,CAAC,EACvC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,CAAC,CAAC,EAC1C,EAAE,YAAY,EAAE,GAAE;IAAE,YAAY,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/C,OAAO,CAAC,CAAC,CAAC,CAuBZ"}
|
|
@@ -2,10 +2,20 @@ import { observationScore, PRIORITY_WEIGHT } from "../memory/loader.js";
|
|
|
2
2
|
import { runMigrations } from "../memory/migrations.js";
|
|
3
3
|
import { DEFAULT_MANUAL_BIAS, DEFAULT_NOTE_BIAS, DEFAULT_RECENCY_HALF_LIFE_MS, DEFAULT_REFLECTION_BIAS, } from "../memory/observational.js";
|
|
4
4
|
import { DEFAULT_OPEN_LOCK_WAIT_BUDGET_MS, MemoryLockTimeoutError, openPGliteWaitingForLock, } from "../memory/pglite.js";
|
|
5
|
+
import { MemorySession } from "../memory/session.js";
|
|
5
6
|
import { readArchiveManifest, removeArchive } from "../train/archive.js";
|
|
6
7
|
import { isTrainTagged, slugFromTags } from "../train/tags.js";
|
|
7
8
|
import { fail } from "./shared.js";
|
|
8
9
|
import { installShutdownHandlers } from "./shutdown.js";
|
|
10
|
+
/**
|
|
11
|
+
* Report an exhausted memory-DB open lock and exit `75` (the contract's
|
|
12
|
+
* distinguished lock-wait code, distinct from a generic runtime failure).
|
|
13
|
+
* Every memory/train subcommand funnels its {@link MemoryLockTimeoutError}
|
|
14
|
+
* here so the friendly, actionable message and the exit code stay identical.
|
|
15
|
+
*/
|
|
16
|
+
export function failMemoryLockTimeout(error) {
|
|
17
|
+
return fail(`Memory database at ${error.dataDir} is still locked by duet pid ${error.holderPid} after ${error.budgetMs / 1000}s. Stop that process (or pass --wait <seconds> to wait longer) and retry.`, 75);
|
|
18
|
+
}
|
|
9
19
|
/** Rows fetched per page by the ranked, lazily-paginated TUI list. */
|
|
10
20
|
export const MEMORY_PAGE_SIZE = 25;
|
|
11
21
|
/**
|
|
@@ -120,6 +130,8 @@ export class MemoryDb {
|
|
|
120
130
|
bind("priority = $?", filters.priority);
|
|
121
131
|
if (filters.source !== undefined)
|
|
122
132
|
bind("(source_json::json->>'kind') = $?", filters.source);
|
|
133
|
+
if (filters.sessionId !== undefined)
|
|
134
|
+
bind("session_id = $?", filters.sessionId);
|
|
123
135
|
if (filters.fromMs !== undefined)
|
|
124
136
|
bind("created_at >= $?", filters.fromMs);
|
|
125
137
|
if (filters.toMs !== undefined)
|
|
@@ -208,7 +220,7 @@ export async function withMemoryDb(dbPath, fn, { waitBudgetMs } = {}) {
|
|
|
208
220
|
}
|
|
209
221
|
catch (error) {
|
|
210
222
|
if (error instanceof MemoryLockTimeoutError) {
|
|
211
|
-
|
|
223
|
+
failMemoryLockTimeout(error);
|
|
212
224
|
}
|
|
213
225
|
throw error;
|
|
214
226
|
}
|
|
@@ -221,6 +233,41 @@ export async function withMemoryDb(dbPath, fn, { waitBudgetMs } = {}) {
|
|
|
221
233
|
await db.close();
|
|
222
234
|
}
|
|
223
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Run `fn` against a {@link MemorySession} opened on the shared memory
|
|
238
|
+
* database — the entry point for one-shot CLI commands that need the
|
|
239
|
+
* session's refcounted handle and cross-process lock (writes via
|
|
240
|
+
* `appendObservation`, hybrid recall) rather than the raw {@link MemoryDb}
|
|
241
|
+
* query wrapper. Applies migrations on open, installs shutdown handlers, and
|
|
242
|
+
* always disposes; a lock-contention timeout exits `75` via
|
|
243
|
+
* {@link failMemoryLockTimeout} so callers share one error message and code.
|
|
244
|
+
*/
|
|
245
|
+
export async function withMemorySession(dbPath, fn, { waitBudgetMs } = {}) {
|
|
246
|
+
const session = new MemorySession({
|
|
247
|
+
path: dbPath,
|
|
248
|
+
openOptions: {
|
|
249
|
+
init: async (db) => {
|
|
250
|
+
await runMigrations(db);
|
|
251
|
+
},
|
|
252
|
+
},
|
|
253
|
+
...(waitBudgetMs !== undefined ? { lockWaitBudgetMs: waitBudgetMs } : {}),
|
|
254
|
+
idleCloseMs: 60_000,
|
|
255
|
+
});
|
|
256
|
+
const removeShutdownHandlers = installShutdownHandlers(() => session.dispose());
|
|
257
|
+
try {
|
|
258
|
+
return await fn(session);
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
if (error instanceof MemoryLockTimeoutError) {
|
|
262
|
+
failMemoryLockTimeout(error);
|
|
263
|
+
}
|
|
264
|
+
throw error;
|
|
265
|
+
}
|
|
266
|
+
finally {
|
|
267
|
+
removeShutdownHandlers();
|
|
268
|
+
await session.dispose();
|
|
269
|
+
}
|
|
270
|
+
}
|
|
224
271
|
function rowToObservation(row) {
|
|
225
272
|
return {
|
|
226
273
|
id: row.id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-db.js","sourceRoot":"","sources":["../../../src/cli/memory-db.ts"],"names":[],"mappings":"AACA,OAAO,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