draken 0.2.0 → 0.3.0
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/ACCEPTANCE.md +4 -1
- package/CHANGELOG.md +32 -0
- package/CONTRIBUTING.md +1 -1
- package/MEMORY.md +26 -6
- package/README.md +18 -6
- package/SETUP.md +2 -2
- package/SOURCES.md +1 -1
- package/VOICE.md +11 -3
- package/dist/db/schema.d.ts.map +1 -1
- package/dist/db/schema.js +6 -0
- package/dist/db/schema.js.map +1 -1
- package/dist/memory/automatic.d.ts +1 -1
- package/dist/memory/automatic.d.ts.map +1 -1
- package/dist/memory/automatic.js +1 -1
- package/dist/memory/automatic.js.map +1 -1
- package/dist/memory/context.d.ts +4 -4
- package/dist/memory/context.d.ts.map +1 -1
- package/dist/memory/context.js +64 -16
- package/dist/memory/context.js.map +1 -1
- package/dist/memory/embedding-pool.d.ts +1 -1
- package/dist/memory/embedding-pool.d.ts.map +1 -1
- package/dist/memory/embedding-pool.js +1 -1
- package/dist/memory/embedding-pool.js.map +1 -1
- package/dist/memory/index.d.ts +8 -2
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +195 -37
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/model-files.d.ts +9 -0
- package/dist/memory/model-files.d.ts.map +1 -0
- package/dist/memory/model-files.js +13 -0
- package/dist/memory/model-files.js.map +1 -0
- package/dist/memory/model.d.ts +1 -1
- package/dist/memory/model.d.ts.map +1 -1
- package/dist/memory/model.js +11 -16
- package/dist/memory/model.js.map +1 -1
- package/dist/memory/readiness.d.ts +16 -0
- package/dist/memory/readiness.d.ts.map +1 -0
- package/dist/memory/readiness.js +131 -0
- package/dist/memory/readiness.js.map +1 -0
- package/dist/memory/reconcile.d.ts +11 -0
- package/dist/memory/reconcile.d.ts.map +1 -0
- package/dist/memory/reconcile.js +132 -0
- package/dist/memory/reconcile.js.map +1 -0
- package/dist/memory/service.d.ts +4 -2
- package/dist/memory/service.d.ts.map +1 -1
- package/dist/memory/service.js +34 -8
- package/dist/memory/service.js.map +1 -1
- package/dist/memory/sources.d.ts +2 -2
- package/dist/memory/sources.d.ts.map +1 -1
- package/dist/memory/sources.js +12 -5
- package/dist/memory/sources.js.map +1 -1
- package/dist/memory/storage.d.ts.map +1 -1
- package/dist/memory/storage.js +9 -0
- package/dist/memory/storage.js.map +1 -1
- package/dist/memory/types.d.ts +22 -1
- package/dist/memory/types.d.ts.map +1 -1
- package/dist/memory/types.js.map +1 -1
- package/dist/memory/worker.js +4 -2
- package/dist/memory/worker.js.map +1 -1
- package/dist/routes/sync.d.ts.map +1 -1
- package/dist/routes/sync.js +22 -4
- package/dist/routes/sync.js.map +1 -1
- package/dist/sync/collector.d.ts +1 -1
- package/dist/sync/collector.d.ts.map +1 -1
- package/dist/sync/collector.js +109 -69
- package/dist/sync/collector.js.map +1 -1
- package/dist/sync/manager.d.ts +4 -1
- package/dist/sync/manager.d.ts.map +1 -1
- package/dist/sync/manager.js +89 -13
- package/dist/sync/manager.js.map +1 -1
- package/dist/sync/reconciliation.d.ts +16 -0
- package/dist/sync/reconciliation.d.ts.map +1 -0
- package/dist/sync/reconciliation.js +22 -0
- package/dist/sync/reconciliation.js.map +1 -0
- package/dist/sync/store.js +1 -1
- package/dist/types.d.ts +9 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/voice/continuation.d.ts.map +1 -1
- package/dist/voice/continuation.js +1 -0
- package/dist/voice/continuation.js.map +1 -1
- package/dist/voice/history-focus.d.ts +14 -0
- package/dist/voice/history-focus.d.ts.map +1 -0
- package/dist/voice/history-focus.js +39 -0
- package/dist/voice/history-focus.js.map +1 -0
- package/dist/voice/live-context.d.ts +1 -1
- package/dist/voice/live-context.d.ts.map +1 -1
- package/dist/voice/live-context.js +3 -3
- package/dist/voice/live-context.js.map +1 -1
- package/dist/voice/live.d.ts.map +1 -1
- package/dist/voice/live.js +47 -33
- package/dist/voice/live.js.map +1 -1
- package/dist/voice/preparation.d.ts +8 -0
- package/dist/voice/preparation.d.ts.map +1 -0
- package/dist/voice/preparation.js +59 -0
- package/dist/voice/preparation.js.map +1 -0
- package/package.json +1 -1
- package/public/assets/index-CYCbTSh1.js +131 -0
- package/public/assets/{index-DmRid5xE.css → index-DntUQtGK.css} +1 -1
- package/public/assets/{persona-XbLvCqRT.js → persona-BVIfx5k8.js} +1 -1
- package/public/index.html +3 -3
- package/public/persona/chat-avatar.webp +0 -0
- package/public/persona.html +3 -3
- package/voice/realtime/native.mjs +1 -1
- package/public/assets/index-CYz_kpAp.js +0 -126
- /package/public/assets/{index-Ymd62i3g.js → index-BQFBaSKm.js} +0 -0
package/ACCEPTANCE.md
CHANGED
|
@@ -18,7 +18,10 @@ Use disposable histories first. Real-provider checks below require the operator'
|
|
|
18
18
|
- [ ] **Explicit permissions:** Codex/Claude imports stay off until independently enabled. Opening Settings/setup/status does not scan transcript bodies, prepare a snapshot, download an embedding model, call a provider, or request a microphone. Background indexing permission is separate from source permission.
|
|
19
19
|
- [ ] **Small tails and restart:** fewer than 64 distinct changed source records wait indefinitely in the background. Session bookkeeping and frozen aliases do not multiply the count. Foreground preparation handles smaller tails. Restart does not make an unchanged archive new again.
|
|
20
20
|
- [ ] **Evidence availability:** removing/changing a frozen original fails visibly; no cached-source fallback invents availability. Notes/discussion remain inspectable. Restore the exact original and verify recovery without regenerated evidence or review.
|
|
21
|
-
- [ ] **
|
|
21
|
+
- [ ] **Import completeness:** a source larger than 32 MiB reaches its captured tail before a new snapshot or call readiness. Cancellation retains committed chunks without marking a partial import complete; retry resumes. An unfinished final record is deferred; an oversized or unreadable record blocks preparation. Later appends do not cause an endless chase.
|
|
22
|
+
- [ ] **Useful retrieval:** replay project-status and follow-up questions with older identical user questions and acknowledgements present. Confirm original project evidence, latest recorded work, technical definitions and concrete remaining work—not just source IDs. Include duplicate passages, ambiguous topics, project switches, explicit conversation recall, source readback and per-turn source lists. Passing transport tests alone is insufficient.
|
|
23
|
+
- [ ] **Call readiness:** a complete briefing with unfinished history keeps Call disabled. Prepare or cancel history on the sync page, with no call reservation or microphone. A 64-record background batch can establish readiness; a smaller pending tail cannot silently flush inside call setup. Retry/restart reuses completed work. Changed/missing sources invalidate readiness, and original bytes still require verification.
|
|
24
|
+
- [ ] **Call lifecycle:** cancel history preparation before a call; separately cancel connection before the create response arrives. Reload and start again. Microphone acquisition stays after preparation and explicit intent. End/Stop/mute/hidden-page behavior is understandable; no call restarts itself.
|
|
22
25
|
- [ ] **Review is yours:** included/retrieved/summarized/generated/heard/agreed/reviewed are not interchangeable. Only explicit review advances coverage. Discard, failure, cancellation and app restart do not mark work reviewed.
|
|
23
26
|
- [ ] **Real account and audio, separately:** configuration metadata alone does not prove provider/model access, token refresh, quota, billing or audible playback. If desired, test each explicitly with the intended account/device/browser; do not infer them from CI.
|
|
24
27
|
- [ ] **Physical desktop tray:** on actual macOS and Windows desktops, check icon visibility, all menu actions, browser opening, close-terminal survival, external-server observation, owned Stop/Quit and helper loss. No saved-PID adoption, external-server termination, silent settings changes or second same-data listener. Hosted helper smoke is not this test.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
This release adds a separate text-chat experience and improves how Draken prepares history and checks later updates.
|
|
6
|
+
|
|
7
|
+
### Chat without a call
|
|
8
|
+
|
|
9
|
+
- Choose **Chat instead** on Home or an existing sync. Chat uses configured pi, without native voice setup, microphone permission or WebRTC.
|
|
10
|
+
- Keep saved messages, original-source links, a square Draken portrait and real searching/thinking status across reloads.
|
|
11
|
+
- Stop a reply or explicitly retry a failed one. Accepted questions remain saved even if generation fails; repeated delivery of the same request does not generate another answer.
|
|
12
|
+
- Sending a message never implicitly saves edited notes, marks work reviewed or starts a voice call. The model/quota notice was removed from the chat view.
|
|
13
|
+
|
|
14
|
+
### More reliable history preparation and retrieval
|
|
15
|
+
|
|
16
|
+
- Finish bounded import passes to the captured end of each log before freezing a snapshot. An indexed but incompletely imported prefix no longer qualifies as ready.
|
|
17
|
+
- Prepare history before enabling a call, with explicit progress, cancellation and server-side readiness checks. Live retrieval does not silently download the local model or rebuild corpus embeddings.
|
|
18
|
+
- Keep project scope across follow-up questions using actual user turns and admitted metadata. Prefer original project records over stale Draken replies, with better deduplication and explanatory excerpts.
|
|
19
|
+
- Show the prepared-history cutoff and make refreshing history explicit. New chat messages do not force a corpus rebuild after every turn; changed or missing captured originals still invalidate readiness.
|
|
20
|
+
|
|
21
|
+
### Reconcile later evidence in text status answers
|
|
22
|
+
|
|
23
|
+
- Check later related reports within the same original session, including follow-ups that themselves became stale. Keep client implementation, backend foundations, delivery enablement and device/provider acceptance distinct.
|
|
24
|
+
- Supply a larger bounded text-history packet and retain closing qualifications when excerpts are shortened.
|
|
25
|
+
- If a draft cites a linked old checkpoint while ignoring its supplied follow-ups, permit one correction through the same final model and invocation budget. A second failure is visible; rejected drafts are not saved.
|
|
26
|
+
- The correction can consume one additional final-model request. These checks improve retrieval and citation consistency; they do not independently verify every claim or exhaustively reconcile all sessions. Native voice retains its separate smaller lookup path.
|
|
27
|
+
|
|
28
|
+
### Upgrading from 0.2.0
|
|
29
|
+
|
|
30
|
+
- Node.js 22.19+ and npm remain required. Back up original agent logs and Draken data first; wait for active calls and preparation/indexing jobs to finish, then stop the server before upgrading and restart it afterward.
|
|
31
|
+
- This release adds import-completeness metadata and nullable chat request IDs with a uniqueness constraint. Existing conversations, notes, review state and compatible embedding vectors are retained. Do not restore an older backup over newer user activity or use an older binary to undo migrations.
|
|
32
|
+
- No provider/account replacement, automatic paid summarization or new background-indexing policy is introduced. Chat and its correction attempts remain outside the preparation-only cost estimate.
|
|
33
|
+
- Automated tests use synthetic provider replies. Real local-embedding checks do not establish real-account quota, model-answer correctness, physical-device audio or end-to-end notification delivery in your projects.
|
|
34
|
+
|
|
3
35
|
## 0.2.0
|
|
4
36
|
|
|
5
37
|
Draken now helps you catch up on what your coding agents did. It reads saved sessions, prepares summaries with links to the original messages, and lets you ask questions and save decisions. It does not run project commands or change your code.
|
package/CONTRIBUTING.md
CHANGED
|
@@ -98,7 +98,7 @@ The native smoke check opens a temporary icon, updates status and checks orderly
|
|
|
98
98
|
|
|
99
99
|
`site/` is plain HTML/CSS with a small, synthetic evidence-reference interaction. It has no account/API integration, remote fonts, analytics or microphone access. Keep demo content labelled and never use private project screenshots or histories.
|
|
100
100
|
|
|
101
|
-
Merging `site/**` changes into `master` triggers `.github/workflows/web-deploy.yml`, which deploys to the existing Cloudflare R2 site and purges its cache. A feature-branch push does not deploy it. npm publication and application deployment are separate operations. Keep
|
|
101
|
+
Merging `site/**` changes into `master` triggers `.github/workflows/web-deploy.yml`, which deploys to the existing Cloudflare R2 site and purges its cache. A feature-branch push does not deploy it. npm publication and application deployment are separate operations. Keep version notices and installation commands accurate. Before announcing a release on the site, verify that the npm registry serves the expected version and test a fresh production-only installation. A successful publish command can precede registry availability while npm processes the package. Update the site and user documentation to match the confirmed release.
|
|
102
102
|
|
|
103
103
|
## Keep the code lean and the boundaries explicit
|
|
104
104
|
|
package/MEMORY.md
CHANGED
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
**Just ask.** Draken automatically searches retained older sessions, sync conversations and saved notes when you ask a text question or talk to it. The separate **Search history** page (`/history`) lets you inspect the same records directly.
|
|
4
4
|
|
|
5
|
-
There is no memory-enable switch,
|
|
5
|
+
There is no memory-enable switch, search-mode selector or wider-history checkbox. An existing sync offers **Prepare history** when its call history is not ready. Historical retrieval does not replace the complete-snapshot summary tree or advance review coverage.
|
|
6
6
|
|
|
7
7
|
## Automatic preparation
|
|
8
8
|
|
|
9
9
|
The first request with eligible retained history downloads approximately **136 MB** of pinned model/tokenizer files from Hugging Face, verifies their SHA-256 checksums and prepares local embeddings. Later requests reuse them and automatically embed new or changed records. Empty history does not require a model download.
|
|
10
10
|
|
|
11
|
-
Search combines meaning and exact keywords every time. It waits for both indexes rather than quietly returning keyword-only results while semantic work is incomplete. First use or a large amount of newly collected history can take minutes. Search, text-reply preparation and call
|
|
11
|
+
Search combines meaning and exact keywords every time. It waits for both indexes rather than quietly returning keyword-only results while semantic work is incomplete. First use or a large amount of newly collected history can take minutes. Search, text-reply preparation and pre-call preparation show the current phase, model-download bytes or completed/total **new or changed unique passages**, unchanged cached work separately, elapsed time and an approximate remaining time once enough passages have been measured. The estimate can change with passage length. Progress is read-only metadata; polling it does not start indexing. **Call Draken stays disabled until both the briefing and searchable history are ready.** Sync preparation includes history preparation; an older or changed sync offers **Prepare history**, with progress and cancellation on the sync page, not inside a call. Call creation checks readiness again and rejects unprepared history without starting a call or building an index. Cancelling or failing preparation leaves the microphone off. Ordinary concurrent requests queue behind one history process, within a fixed bound. Its embedding lanes run bounded batches in parallel; they do not run concurrent database writers. An unchanged index shows **History is up to date**, not a full-archive progress bar.
|
|
12
12
|
|
|
13
13
|
No session text or queries are uploaded for embedding. Text discussion and ChatGPT voice do receive the relevant historical excerpts, just as they receive frozen snapshot context. Those excerpts are dated background—not newly reviewed progress, agreement or permission to execute work.
|
|
14
14
|
|
|
@@ -18,11 +18,31 @@ Opening/reloading a page does not itself download the model, compute embeddings
|
|
|
18
18
|
|
|
19
19
|
**Settings → Automatically index history**, available from the top bar on every page, is off by default. Its explicit, persistent opt-in authorizes local scanning and embedding (including the first-use model download) while the server runs, even with no browser open. It does not run provider summaries, create/extend frozen syncs, transcribe audio or advance review. Agent logs are already text; summary generation still happens on the explicit sync action and remains separately costed.
|
|
20
20
|
|
|
21
|
-
The app's single scheduler checks once a minute when no sync, call or foreground history work is active. A background batch requires at least 64 changed source records, regardless of how long they have waited. There is no timed flush. Smaller pending batches
|
|
21
|
+
The app's single scheduler checks once a minute when no sync, call or foreground history work is active. A background batch requires at least 64 changed source records, regardless of how long they have waited. There is no timed flush. Smaller pending batches wait for a sync, **Prepare history**, or search; that foreground path has no minimum batch size. Background indexing records the same history readiness used by calls. If anything still needs preparation, Call remains disabled—clicking it cannot start a hidden indexing job. Metadata hashes detect additions, edits and removals once per original source entry (or discussion/note record). Session/file bookkeeping does not add records, and frozen aliases coalesce with the original rather than multiplying the count. Actual indexing still reconstructs and verifies admitted source bytes. Unchanged checks do not start an embedding request. Source records and embedding passages are different counts. New sessions from enabled agents retain the collector's included-by-default behavior; per-agent/per-session exclusions and the existing baseline remain respected. Codex and Claude sources require separate explicit opt-in in **Settings → Agents & sessions**, even if background indexing is already enabled. Summarization continues to use pi. See [SOURCES.md](SOURCES.md).
|
|
22
22
|
|
|
23
23
|
Foreground history requests preempt an active background request, waiting for the old child to exit before replacement. Disabling aborts only owned background embedding work; a scan already in progress may finish, but cannot start an embedding batch afterward. Completed vector commits remain reusable. Failures are visible and retry no sooner than five minutes; foreground preemption waits at least one minute. Shutdown awaits the owned scan/work within the existing bounded server shutdown. Reads of settings/progress start no jobs. The preference is a small `sync_settings` entry. A hash-only checkpoint in the derived search database survives restart and advances only after successful unscoped/current-call preparation; a historical or source-filtered search cannot replace it. It is scheduling metadata, not review coverage or a substitute for source verification. Progress remains process-local. An older index without a checkpoint waits for one foreground call preparation or unfiltered history search instead of treating its cached archive as newly changed. Unchanged preparations do not rewrite the checkpoint. There is no original-text copy, new provider, model substitution, vector conversion or timed small-batch flush.
|
|
24
24
|
|
|
25
|
-
A failed preparation/search reports an error. If a session file changed, moved or disappeared, scan sessions again before retrying; stale derived text is not a substitute for a verified source. Otherwise retry the
|
|
25
|
+
A failed preparation/search reports an error. If a session file changed, moved or disappeared, scan sessions again before retrying; stale derived text is not a substitute for a verified source. Otherwise retry the question or **Prepare history**; completed embeddings are reused automatically. Cancel preparation on the sync page to stop that work. Cancelling a search or text reply stops its owned work too. Reloading does not start a call. An older cache without a call-readiness record needs one preparation pass, which reuses its compatible vectors. A completed index over a partial import is not sufficient: foreground call preparation first drains bounded import chunks to captured file ends. Missing, changed or incomplete originals block readiness. Later appends do not force preparation to chase a live stream forever; the call uses its displayed cutoff, and new work waits for another preparation. A ready sync offers **Refresh history** for an explicit local-only update without regenerating its briefing. See [SOURCES.md](SOURCES.md).
|
|
26
|
+
|
|
27
|
+
## Work questions and follow-ups
|
|
28
|
+
|
|
29
|
+
Voice and **Chat instead** work questions prefer original session records, not old Draken replies or repeated questions. Project names in admitted session metadata establish a scope that follows generic follow-ups; an explicit project change updates it. Explicit conversation recall still searches earlier discussion. This is a heuristic, not a guarantee that an ambiguous project name will be understood correctly.
|
|
30
|
+
|
|
31
|
+
Retrieval ranks both keywords and local vectors, deduplicates shared passages before the candidate limit, and gives original agent explanations their own candidate set. Current-status questions include the latest recorded agent explanation and favor recent records. Up to two named topics in a question can be searched separately so one does not crowd out the other. All candidates remain subject to source permissions and the prepared cutoff. Useful negative or historical evidence is not confirmation of a current defect.
|
|
32
|
+
|
|
33
|
+
Voice source packets contain up to four sources within 7,000 UTF-8 bytes. Excerpts keep contiguous explanatory text; tool requests may be omitted with an explicit marker. A later passage can include the beginning of its source for context. The native helper can refine a question or request an H reference (optionally with `offset 2000`); each user turn permits at most three distinct lookups and reuses duplicates. Source IDs are the context supplied for that turn, not verified per-claim citations or a cumulative claim that every earlier source supported the answer. A failed or empty work lookup is not silently replaced by an old conversation.
|
|
34
|
+
|
|
35
|
+
### Separate text chat
|
|
36
|
+
|
|
37
|
+
`/syncs/:id/chat` uses the same project/topic planner and prepared-only source search, with an up-to-32,000-byte historical packet (at most 16 sources). Recent actual user questions in the sync's saved chat and native call transcripts establish follow-up scope; assistant replies cannot select a project. The text model receives qualified recent call transcripts as context, not evidence of hearing or agreement. Source-reference validation checks existence, not per-claim truth.
|
|
38
|
+
|
|
39
|
+
Text status questions additionally check for later related original assistant narratives in the same source session. The bounded lexical pass considers at most 4,096 admitted narratives, four starting threads and two further follow-up generations; it does not run another embedding model or rebuild the corpus. It checks individual pending sub-tasks, favors relevant implementation sections over repeated pending tables, and retains a latest related report. Sequence orders records within a session, not across sessions. Follow-ups can themselves be stale, so a client-completion report that still lists backend jobs as pending is checked against later backend reports. Candidate links are not verified supersession: later plans, contradictory reports, completed foundations and unfinished delivery/acceptance remain distinct.
|
|
40
|
+
|
|
41
|
+
Packets retain contiguous excerpts and, when clipped, separately labelled ending excerpts with original offsets so closing qualifications survive. An earlier linked checkpoint is omitted if its selected follow-ups cannot fit. Omitted candidates/threads are disclosed; no-match never establishes that no later completion record exists. These are language-dependent lexical candidates over admitted projections, not exhaustive whole-log or cross-session semantic verification.
|
|
42
|
+
|
|
43
|
+
If a text answer cites a linked old checkpoint but ignores its supplied follow-ups, including an E/C alias of that same original record, Draken permits **one repair using the same final model and invocation/cancellation budget**. The rejected draft is never saved or shown. A second failure is visible and retains the user question without an assistant answer. **Checking later updates** identifies that repair stage. It can consume one additional final-model request; chat/repair usage remains outside the preparation-only estimate. This citation-consistency check is not proof that every claim is true. The larger packet and repair apply to text replies, **not** streaming native voice, whose separate 7,000-byte lookup budget is unchanged.
|
|
44
|
+
|
|
45
|
+
Chat readiness checks the prepared receipt at its captured cutoff. New chat messages beyond that cutoff are passed directly as recent conversation and do not force an index rebuild on every turn. Original-file identity/import cursors, selection changes, missing originals and edits to already captured records still invalidate readiness. Fresh native-call readiness keeps its stricter current-record check. Both readiness endpoints only read metadata. Refresh is explicit; chat does not silently refresh the corpus, regenerate a briefing or switch providers.
|
|
26
46
|
|
|
27
47
|
## How it works
|
|
28
48
|
|
|
@@ -67,7 +87,7 @@ Back up both current databases before deployment and qualify migration on privat
|
|
|
67
87
|
|
|
68
88
|
Source inclusion, missing-session state, active branches for unsnapshotted entries and the existing history baseline are respected. Frozen evidence remains historical, including superseded branch material. Reviewed records remain searchable. Discarded sync discussion/notes are excluded, while discarded work can still be eligible through an active selected session.
|
|
69
89
|
|
|
70
|
-
|
|
90
|
+
Ordinary search and text discussion prepare the candidates observed at their start. Voice instead uses the history cutoff prepared before the call: it verifies original bytes and queries existing passages, but does not build missing corpus embeddings or download a missing model. Newer records wait for a later preparation and call. Query embeddings still run locally during a call. Exclusions and edits are rechecked after inference; stale or unprepared history fails visibly rather than being quietly rebuilt during the call. This avoids mixing fresh keyword-only records into results described as fully hybrid.
|
|
71
91
|
|
|
72
92
|
Sync discussion is its own retained record: excluding a session does not erase text previously discussed in a sync. Recaps/current briefings are not separately indexed as primary evidence, though preserved discussion can contain historical assistant summaries; attribution remains visible.
|
|
73
93
|
|
|
@@ -93,6 +113,6 @@ The npm package contains code/dependencies, not downloaded weights or private in
|
|
|
93
113
|
|
|
94
114
|
Ordinary tests use synthetic records and deterministic or empty embedding fixtures, with real FTS5/vector tests. They do not download/run the real model. Browser fixtures exercise automatic search and source reading without setup controls, plus no capture on navigation. Existing native-only and review-boundary tests remain.
|
|
95
115
|
|
|
96
|
-
Optional real-model qualification and CPU comparison commands live in [CONTRIBUTING.md](CONTRIBUTING.md#local-model-qualification). Those are isolated test tools, not steps required to use search.
|
|
116
|
+
Optional real-model qualification and CPU comparison commands live in [CONTRIBUTING.md](CONTRIBUTING.md#local-model-qualification). Those are isolated test tools, not steps required to use search. Search and text requests prepare the index automatically; calls require completed preparation first. There is no separate model setup command for users.
|
|
97
117
|
|
|
98
118
|
Synthetic retrieval and throughput checks do not establish exhaustive recall, real-provider answer quality or performance on every machine.
|
package/README.md
CHANGED
|
@@ -8,7 +8,9 @@ A local-first engineering sync across your **pi, Codex CLI and Claude Code sessi
|
|
|
8
8
|
>
|
|
9
9
|
> **Large histories now use a cached summary tree:** cheaper-model parsing and reconciliation, followed by a stronger-model verdict. The old raw-evidence snapshot cutoff is removed. This is still lossy model compression, not independent verification. See [ROADMAP.md](ROADMAP.md) for remaining quality evaluation and community research.
|
|
10
10
|
|
|
11
|
-
**Sync with Draken →
|
|
11
|
+
**Sync with Draken → call or chat → keep a short recap.**
|
|
12
|
+
|
|
13
|
+
**Draken 0.3.0** adds **Chat instead**, complete history preparation and better text-status evidence reconciliation. See [the release notes](CHANGELOG.md#030).
|
|
12
14
|
|
|
13
15
|
The home page is compact history cards. Each sync has its own `/syncs/:id` URL, with the full briefing, conversations, notes and evidence behind it. **Search history** (`/history`) adds local semantic + keyword retrieval across retained older records, with dated source links. It prepares itself automatically—no enable/update buttons or search-mode choices. Progress counts only new or changed passages, with cached history shown separately and a measured time estimate. Local indexing reuses existing vectors and uses up to two embedding lanes/six CPU threads on sufficiently capable machines; smaller machines stay single-lane. Text questions and calls use it by default. See [MEMORY.md](MEMORY.md) for source scope, first-use download and limitations.
|
|
14
16
|
|
|
@@ -20,10 +22,10 @@ Draken remembers which evidence a finished sync covered, what you decided, and w
|
|
|
20
22
|
|
|
21
23
|
Requires Node.js **22.19+** and npm. Session-log indexing and evidence review do not require a model or pi executable. Generated briefings and discussion use **pi 1.4+**. Existing configured pi works unchanged; otherwise **`draken setup`** installs a pinned private runtime and **`draken login`** opens pi’s own authentication interface. See [SETUP.md](SETUP.md) for the full first-run flow, private directories and recovery.
|
|
22
24
|
|
|
23
|
-
> **
|
|
25
|
+
> **Upgrading?** Back up your original agent logs and Draken data first. Versions **0.1.6 and earlier** are the old task dashboard, not this application. See [what changed in 0.3.0](CHANGELOG.md#030).
|
|
24
26
|
|
|
25
27
|
```sh
|
|
26
|
-
npm install -g draken
|
|
28
|
+
npm install -g draken
|
|
27
29
|
draken
|
|
28
30
|
```
|
|
29
31
|
|
|
@@ -50,16 +52,26 @@ Run setup/login as the server’s user with the same environment. `draken status
|
|
|
50
52
|
2. Click **Sync with Draken**. Draken scans, freezes all available entries, summarizes earlier conversations, prepares the briefing, then starts the call on the same visible page. Browser microphone permission may still be required. This is one explicit action, not an automatic call on page load.
|
|
51
53
|
3. Talk. Ending the call requests a short, cached recap; it never saves decisions or marks evidence reviewed.
|
|
52
54
|
4. Return home for compact cards, or open any `/syncs/:id` independently. Reopening/reloading a URL never starts capture. **Call Draken** resumes discussion of that frozen snapshot without collecting later activity.
|
|
53
|
-
5.
|
|
55
|
+
5. Use **Chat instead** for a separate text conversation, or expand the detail sections to inspect the briefing/evidence and explicitly save **Decisions** and **Carry into the next sync**. **Mark reviewed** is separate and optional before starting another sync; only that explicit action advances coverage.
|
|
54
56
|
|
|
55
57
|
**Settings** in the top bar is available on every page. **Settings → Automatically index history** optionally scans and prepares local search in the background while the server is running. It is off by default and survives restarts when enabled. Checks run once a minute while idle; background batches require at least 64 changed source records, with no timed flush. Smaller pending batches are prepared on demand when you sync, start a call or search. Foreground syncs/calls/searches take priority; completed embeddings survive cancellation. This is local scanning/embedding only, not automatic summaries, transcription, new syncs or review. The final aggregation still runs on Sync with Draken. First use may download the pinned search model. New sessions from enabled agents are selected by default; per-agent and per-session exclusions remain respected.
|
|
56
58
|
|
|
57
59
|
**Settings → Agents & sessions** shows each supported agent’s configured directories, recorded sessions, workspace/file paths, last recorded changes, unreviewed counts, inclusion choices and missing-source status. **Scan enabled agents** explicitly refreshes this inventory; opening Settings only reads recorded metadata and directory presence. Readers support **pi v3 JSONL, self-contained Codex CLI rollouts and Claude Code transcripts**. Codex and Claude history require explicit per-agent opt-in; existing pi choices are preserved. The panel shows directory presence separately from recorded sessions, not an installation claim. Summaries still use pi. See [SOURCES.md](SOURCES.md) for paths, supported layouts, migration and limitations. Source selection/scanning lives in this settings panel. A fresh installation includes all indexed history; an existing fixed baseline is preserved. There are no ordinary model/budget controls or extra inference permission checkboxes. Failed preparation keeps its snapshot and cached work; retry explicitly. Opening a link after preparation requires an explicit call click.
|
|
58
60
|
|
|
59
|
-
Closing the browser preserves the running job; reloading reconnects to progress. Restarting the server preserves the snapshot and completed summary nodes, but interrupts an active model call; retry to resume from cache. Discarding a sync leaves its evidence uncovered and retains the conversation in history.
|
|
61
|
+
Closing the browser preserves the running job; reloading reconnects to progress. Restarting the server preserves the snapshot and completed summary nodes, but interrupts an active model call; retry to resume from cache. Discarding a sync leaves its evidence uncovered and retains the conversation in history. Chat retains the sent question even if its reply fails or is stopped; it never fabricates a completed assistant answer or marks anything reviewed. The older discussion API still saves only completed exchanges. Records from the retired local engine retain their original playback qualifications. Live calls retain ordered generated/interrupted transcripts and supplied context sources, without claiming exact playback or agreement. Reload ends the call and never resumes microphone capture automatically.
|
|
60
62
|
|
|
61
63
|
An old capped snapshot must be explicitly **expanded to full history** before generating another briefing. Expansion rescans, preserves decisions/discussion and existing citation IDs, archives the obsolete briefing, and establishes a new snapshot time. It does not invoke models or advance coverage.
|
|
62
64
|
|
|
65
|
+
### Text chat
|
|
66
|
+
|
|
67
|
+
**Chat instead** is available on Home and beside **Call Draken** on a sync. Home prepares a new snapshot; opening chat on an existing sync reuses its briefing. `/syncs/:id/chat` restores the saved conversation and any running reply. Chat needs configured pi, not voice setup, ChatGPT native sign-in, microphone permission, WebRTC or a secure-context audio API. Dashboard authentication and normal transport-security requirements still apply.
|
|
68
|
+
|
|
69
|
+
A square Draken portrait accompanies replies. **Searching your prepared history**, **Draken is thinking** and **Checking later updates** follow actual server job stages; they are status cues, not private model reasoning or streamed draft answers. Enter sends; Shift+Enter inserts a newline. **Stop reply** cancels owned work; retry is explicit. A retried delivery with the same request ID does not repeat generation. A new explicit retry after failure uses a new ID and may consume model quota.
|
|
70
|
+
|
|
71
|
+
Replies use the sync's configured final text model through pi, with the briefing, recent conversation and project-aware original-history retrieval. The prepared archive has a displayed cutoff; new chat messages are supplied directly without rebuilding corpus embeddings after every turn. **Refresh history** admits later work. Changed, excluded or unavailable original sources still block readiness. Chat never opens a native call, implicitly regenerates a ready briefing, saves decisions or marks evidence reviewed. Chat quota/cost is separate from the preparation-only **Est. cost**.
|
|
72
|
+
|
|
73
|
+
For status questions, text chat checks later related original reports before repeating old blockers, including follow-ups to a report that was itself superseded. Client implementation, backend foundations, delivery enablement and device acceptance are kept distinct. If a draft cites a linked old checkpoint without addressing its supplied follow-ups, it gets one bounded same-model repair or fails visibly without saving that draft. Retrieval and citation consistency do not independently verify the agent's claims; see [MEMORY.md](MEMORY.md#separate-text-chat) for bounds and voice differences.
|
|
74
|
+
|
|
63
75
|
### Model integration
|
|
64
76
|
|
|
65
77
|
For briefings, conversation recaps and text discussion, Draken invokes `pi --print` with all tools, extensions, MCP, skills, templates, context-file discovery, and session persistence disabled. It runs outside project checkouts and never resumes or writes to your coding sessions. Credentials stay with the selected pi profile—your existing installation or Draken’s private `pi/agent` directory. Pi owns authentication and refresh; Draken does not copy auth files or implement provider login flows.
|
|
@@ -97,7 +109,7 @@ Each run also retains metadata-only request timings, model/task/stage and repair
|
|
|
97
109
|
|
|
98
110
|
Each sync card and detail page shows **Est. cost** for its preparation: chunk summaries, consolidation, preparation-time prior recaps, final briefing, and retries/rebuilds for that sync. Later questions, voice calls, standalone conversation recaps and local embeddings are excluded. Preparation consumes pi's bounded JSON event stream and saves only numeric usage, returned model names and the catalog-based USD estimate alongside existing metrics—not raw events, prompts, thinking or signatures. Reasoning is a subset of output, not an extra charge; provider cache reads/writes are distinct from Draken cache hits (which make no new request). The total uses prices reported at call time, never today's prices applied to old calls. **This is an API-equivalent estimate, not a subscription charge, quota measurement or provider invoice.** Missing/zero-filled usage or unavailable catalog pricing stays unavailable; mixed or interrupted records show a partial subtotal. Older syncs cannot be honestly backfilled from the padded planning estimates.
|
|
99
111
|
|
|
100
|
-
The final model receives bounded summaries, raw verification excerpts, saved decisions, and recent conversation—not the entire transcript. Questions additionally retrieve up to 16 raw snapshot entries and automatically receive a bounded hybrid-search packet from retained earlier history, with separate global H citations. The
|
|
112
|
+
The final model receives bounded summaries, raw verification excerpts, saved decisions, and recent conversation—not the entire transcript. Questions additionally retrieve up to 16 raw snapshot entries and automatically receive a bounded hybrid-search packet from retained earlier history, with separate global H citations. The separate chat surface requires prepared history and uses its captured cutoff; ordinary standalone search and the older discussion API can prepare the local index as needed. Wider history is not added to the frozen snapshot. Final citation validation checks reference existence and, for text status replies, whether cited checkpoints address their supplied follow-ups. Neither check proves that every claim is actually supported.
|
|
101
113
|
|
|
102
114
|
The manager is a **read-only conversation**, not a worker. Its responses distinguish intent, attempts, agent-reported implementation, and observed validation, with clickable evidence references. Model-generated claims still need human review. Draken does not independently run tests or verify Git/CI/deployment state.
|
|
103
115
|
|
package/SETUP.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Draken uses **pi for summaries, preparation recaps and text discussion**, regardless of which coding agent produced the imported history. It does not implement provider OAuth, translate another agent's credentials, or run Claude/Codex to summarize.
|
|
4
4
|
|
|
5
|
-
>
|
|
5
|
+
> This guide is for **Draken 0.3.0**. Versions **0.1.6 and earlier** are the old task dashboard. Before upgrading, back up your original agent logs and Draken data; see [what changed](CHANGELOG.md#030).
|
|
6
6
|
|
|
7
7
|
## Install and start
|
|
8
8
|
|
|
9
9
|
Install Node.js **22.19+** with npm, then run:
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
|
-
npm install -g draken
|
|
12
|
+
npm install -g draken
|
|
13
13
|
draken
|
|
14
14
|
```
|
|
15
15
|
|
package/SOURCES.md
CHANGED
|
@@ -21,7 +21,7 @@ Open **Settings → Agents & sessions**. Each adapter shows its configured direc
|
|
|
21
21
|
|
|
22
22
|
The overview API retains its old `session_root` field as a read-only pi compatibility field; new consumers use `agents[].roots` and each session's `agent`/`external_id`.
|
|
23
23
|
|
|
24
|
-
Root overrides are server environment settings, not arbitrary filesystem paths supplied by browser requests. The worker receives an explicit per-agent root allowlist, not credentials or the server environment. Directory traversal is bounded to eight levels. Source symlinks are not followed during discovery; record reads verify real-path containment, regular-file identity, header/session identity, raw bytes and hashes.
|
|
24
|
+
Root overrides are server environment settings, not arbitrary filesystem paths supplied by browser requests. The worker receives an explicit per-agent root allowlist, not credentials or the server environment. Directory traversal is bounded to eight levels. Source symlinks are not followed during discovery; record reads verify real-path containment, regular-file identity, header/session identity, raw bytes and hashes. Each import pass reads at most 32 MiB per file; a scan repeats those bounded passes until it reaches that file's captured end. It does not chase later appends. Complete LF-terminated records remain bounded to 8 MiB, and an unfinished final record waits for another scan. Committed chunks survive cancellation, but an interrupted or failed import is not a completed capture. Snapshot routes reject scan warnings rather than freezing a partial import. Pre-call preparation scans before indexing, and readiness requires each admitted source's completed capture marker (`agent_sessions.scanned_bytes`), not just its modification time or imported cursor. Older rows default to `-1` (unverified) and are revalidated from the beginning; `0` marks an incomplete import and a positive value its completed captured size. A failed chunk never advances past malformed records. A persisted scan-completion flag also blocks readiness after cancellation or a discovery error, including errors in new files that have no imported row yet. Later appends can wait for the next preparation; original byte/hash verification still applies at retrieval.
|
|
25
25
|
|
|
26
26
|
## Adapter recipes
|
|
27
27
|
|
package/VOICE.md
CHANGED
|
@@ -23,11 +23,17 @@ The helper and its credentials live under `~/.draken/realtime/`, separate from t
|
|
|
23
23
|
|
|
24
24
|
This uses an experimental native interface, not a stable public embedding API. Successful setup or a connection handshake is not proof that an account can receive usable audio. The opt-in probe tests actual audio separately. Quota, idle accounting, coding-allowance impact and future compatibility are not established.
|
|
25
25
|
|
|
26
|
+
## Chat instead
|
|
27
|
+
|
|
28
|
+
For a keyboard-only conversation, choose **Chat instead** on Home or next to **Call Draken**. This is a separate `/syncs/:id/chat` surface, not a muted call. It uses the configured text model through pi and requires no microphone permission, WebRTC connection or native ChatGPT sign-in. It shows a square Draken portrait, searching/thinking status, saved messages and source links. Its model access/quota is separate from the native voice account. See [the text-chat guide](README.md#text-chat).
|
|
29
|
+
|
|
30
|
+
Choosing chat while a one-click call is still preparing consumes that browser call intent; preparation can finish without opening a microphone. Returning to **Voice & call history** never automatically starts a call. Existing voice history remains preserved and separately labelled.
|
|
31
|
+
|
|
26
32
|
## Start and use a call
|
|
27
33
|
|
|
28
34
|
1. Open Draken on **localhost or trusted HTTPS**. Plain LAN HTTP normally cannot access the microphone.
|
|
29
|
-
2. **Sync with Draken**
|
|
30
|
-
3.
|
|
35
|
+
2. **Sync with Draken** finishes importing each discovered file's captured prefix, prepares the briefing and searchable history, then opens its call. Import errors stop preparation instead of silently freezing an old prefix. On an existing sync, **Call Draken** stays disabled until both are ready. If imported history has changed, use **Prepare history** first. An already-ready sync also offers **Refresh history** to capture later work without rebuilding its frozen briefing.
|
|
36
|
+
3. Any needed history download/indexing happens on the sync page, before a call can start. Progress and **Cancel preparation** are available there; the microphone remains off. Once ready, start the call and allow microphone access. A failed or cancelled preparation does not request permission, and if the page is hidden when preparation finishes, start the call again explicitly. You can also type if microphone permission is unavailable.
|
|
31
37
|
4. Speaker-safe mode pauses input during replies. Use **Stop reply** to speak, or enable **Headphone mode** to allow spoken interruption. Headphones are recommended.
|
|
32
38
|
5. **Mute** releases the microphone tracks. **Stop reply** cuts playback locally and asks the provider to stop; it does not prove immediate remote cancellation. **End call** stops capture/playback and keeps the text history.
|
|
33
39
|
|
|
@@ -35,11 +41,13 @@ Capture follows a transient browser action, never a URL flag. Reloading or openi
|
|
|
35
41
|
|
|
36
42
|
Reply waiting is owned by the server's identified user transcript and pending-answer events. Unkeyed WebRTC user events can arrive late and must not switch an already pending reply back to listening, erase its waiting caption, or restart a settled reply. A lookup acknowledgement such as “I’ll check what’s recorded” is not meant to end the answer. Draken keeps the question pending and can automatically resume ChatGPT speech when its context arrives; you should not need to ask “have you checked?” Quiet captions in the dragon scene show **[Thinking...]**, **[Hmmm...]** and **[Hmmmmmm...]** during a pending reply, including silence after an acknowledgement. They change every five seconds without animation. **[Checking...]** and **[Looking that up...]** are used only while the local history worker reports fresh lookup activity; these labels are not proof of a match or exhaustive search. These are visual waiting cues—not the model’s private thoughts, spoken messages, a percentage or an ETA. They are never saved in the transcript or sent to the model. The separate waiting banner and elapsed-wait timer have been removed. Stop, a newer question, interruption, or ending the call cancels the old pending continuation. There is at most one automatic completion cue per question—not a retry loop or a fabricated user message. A failed lookup must be disclosed; a failed or silent continuation produces a visible notice instead of silently retrying.
|
|
37
43
|
|
|
44
|
+
Work questions use original project evidence and preserve the project across follow-ups; old conversation recall remains available when explicitly requested. History is captured at the displayed preparation cutoff, not observed live. The helper can refine a lookup or read a longer H source. Each turn allows three distinct lookups, with source packets bounded to 7,000 UTF-8 bytes (the native context envelope is bounded to 8 KiB). Supplied source IDs belong to that turn; they are not proof that each generated claim was verified. The larger text-chat reconciliation packet and bounded pi answer-repair pass do not apply to streaming native voice; this call path retains its existing lookup budget. See [MEMORY.md](MEMORY.md) for retrieval limits.
|
|
45
|
+
|
|
38
46
|
One call may be active at a time, with a 30-minute limit, at most 60 user messages and a 90-second disconnect timeout. These are resource limits, not spending guarantees. A new call cannot start until helper cleanup is confirmed. The browser chooses its reservation UUID before sending creation, so End can release a reservation even if the create response is lost. If End overtakes creation, the server retains a bounded cancellation marker for five minutes; an already-created ID can never be reused. Network loss can still require the disconnect timeout or explicit End previous call.
|
|
39
47
|
|
|
40
48
|
## Evidence, records and recap
|
|
41
49
|
|
|
42
|
-
- Voice questions do **not** start pi, local transcription or local synthesis. The call receives a bounded briefing, saved notes and source excerpts. Explicit source/history questions can request more data from the same frozen snapshot. Calls
|
|
50
|
+
- Voice questions do **not** start pi, local transcription or local synthesis. The call receives a bounded briefing, saved notes and source excerpts. Explicit source/history questions can request more data from the same frozen snapshot. Calls use bounded semantic + keyword retrieval across retained older records, using the local index described in [MEMORY.md](MEMORY.md). The local model/index must be prepared before calling is enabled; first preparation may take minutes. During the call, retrieval uses that prepared cutoff and verifies original sources without building new corpus embeddings. Expand **Conversation & details** for the full transcript, sources and any later history progress. Optional **Settings → Automatically index history** prepares that same call/search history in idle batches of at least 64 changed source records; it never starts capture, calls or provider summaries. Smaller batches wait for explicit preparation, and keep Call disabled if history is not ready. This block starts collapsed for every call; its progress polling reads metadata only. Those dated excerpts also go to ChatGPT; they are not new snapshot evidence. The embedding runtime is text-only and is not a replacement speech engine.
|
|
43
51
|
- The read-only lookup service is not a coding model or a general web search. Tool-execution and approval requests are denied. Calls cannot edit files, deploy work, save decisions by model instruction, finish syncs or advance coverage.
|
|
44
52
|
- Speech may paraphrase. **Sources supplied** means context was given to the model, not that every spoken claim was verified. Responses are not held for whole-answer JSON validation before playback.
|
|
45
53
|
- History stores ordered user/assistant messages with generated/interrupted labels. It does not invent question–answer pairs, exact played words, human hearing or agreement. Historical records from the retired engine retain their original playback reports and are labelled separately.
|
package/dist/db/schema.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAQtC,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAID,wBAAgB,KAAK,IAAI,QAAQ,CAAC,QAAQ,CAazC;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AAQtC,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAID,wBAAgB,KAAK,IAAI,QAAQ,CAAC,QAAQ,CAazC;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAuL5D;AAED,wBAAgB,OAAO,IAAI,IAAI,CAG9B"}
|
package/dist/db/schema.js
CHANGED
|
@@ -217,10 +217,16 @@ function initSchema(database) {
|
|
|
217
217
|
const runColumns = new Set(database.prepare('PRAGMA table_info(sync_runs)').all().map(column => column.name));
|
|
218
218
|
if (!runColumns.has('metrics_json'))
|
|
219
219
|
database.exec("ALTER TABLE sync_runs ADD COLUMN metrics_json TEXT NOT NULL DEFAULT '[]'");
|
|
220
|
+
if (!runColumns.has('request_id'))
|
|
221
|
+
database.exec('ALTER TABLE sync_runs ADD COLUMN request_id TEXT');
|
|
222
|
+
database.exec('CREATE UNIQUE INDEX IF NOT EXISTS sync_run_request ON sync_runs(request_id) WHERE request_id IS NOT NULL');
|
|
220
223
|
database.prepare('UPDATE syncs SET snapshot_at = created_at WHERE snapshot_at IS NULL').run();
|
|
221
224
|
(0, pointer_migration_1.migratePointers)(database);
|
|
222
225
|
(0, snapshot_pointers_1.migrateSnapshotPointers)(database);
|
|
223
226
|
(0, agent_migration_1.migrateAgents)(database);
|
|
227
|
+
const sessionColumns = new Set(database.prepare('PRAGMA table_info(agent_sessions)').all().map(column => column.name));
|
|
228
|
+
if (!sessionColumns.has('scanned_bytes'))
|
|
229
|
+
database.exec('ALTER TABLE agent_sessions ADD COLUMN scanned_bytes INTEGER NOT NULL DEFAULT -1');
|
|
224
230
|
})();
|
|
225
231
|
}
|
|
226
232
|
function closeDb() {
|
package/dist/db/schema.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":";;;;;AAQA,gCAEC;AAID,sBAaC;AAED,
|
|
1
|
+
{"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/db/schema.ts"],"names":[],"mappings":";;;;;AAQA,gCAEC;AAID,sBAaC;AAED,gCAuLC;AAED,0BAGC;AAzND,oEAAsC;AACtC,gDAAwB;AACxB,4CAAoB;AACpB,4CAAoB;AACpB,2DAAkE;AAClE,2DAA8D;AAC9D,uDAAqE;AAErE,SAAgB,UAAU;IACxB,OAAO,cAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC;AACzF,CAAC;AAED,IAAI,EAAE,GAA6B,IAAI,CAAC;AAExC,SAAgB,KAAK;IACnB,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;QACzB,YAAE,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACpD,EAAE,GAAG,IAAI,wBAAQ,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC;QAC/C,uFAAuF;QACvF,YAAE,CAAC,SAAS,CAAC,cAAI,CAAC,IAAI,CAAC,GAAG,EAAE,WAAW,CAAC,EAAE,KAAK,CAAC,CAAC;QACjD,EAAE,CAAC,MAAM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AAG,CAAC,eAAe,CAAC;YAAE,QAAQ,CAAC,IAAI,CAAC,iFAAiF,CAAC,CAAC;IAC3I,CAAC,CAAC,EAAE,CAAC;AACP,CAAC;AAED,SAAgB,OAAO;IACrB,EAAE,EAAE,KAAK,EAAE,CAAC;IACZ,EAAE,GAAG,IAAI,CAAC;AACZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automatic.d.ts","sourceRoot":"","sources":["../../src/memory/automatic.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGlD,KAAK,KAAK,GAAG,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,OAAO,CAAC,CAAC;AAClG,UAAU,UAAU;IAClB,OAAO,IAAI,OAAO,CAAC;IAAC,IAAI,IAAI,OAAO,CAAC;IAAC,GAAG,IAAI,MAAM,CAAC;IACnD,IAAI,
|
|
1
|
+
{"version":3,"file":"automatic.d.ts","sourceRoot":"","sources":["../../src/memory/automatic.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAGlD,KAAK,KAAK,GAAG,IAAI,CAAC,iBAAiB,EAAE,OAAO,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,OAAO,CAAC,CAAC;AAClG,UAAU,UAAU;IAClB,OAAO,IAAI,OAAO,CAAC;IAAC,IAAI,IAAI,OAAO,CAAC;IAAC,GAAG,IAAI,MAAM,CAAC;IACnD,IAAI,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC,CAAC;IAC3D,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAC7C,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAGD;;;+EAG+E;AAC/E,cAAM,WAAW;IAMH,OAAO,CAAC,GAAG;IALvB,KAAK,QAAa;IAClB,OAAO,CAAC,QAAQ,CAAC,CAAsB;IACvC,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,IAAI,CAAC,CAAkB;IAC/B,OAAO,CAAC,GAAG,CAAC,CAAgB;gBACR,GAAG,EAAE,UAAU;IAC7B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAS3B,KAAK;IAIC,IAAI;YACI,GAAG;CAqClB;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,eAAkC;AAInF,wBAAgB,uBAAuB,SAOtC;AACD,wBAAsB,sBAAsB,kBAG3C;AACD,wBAAgB,uBAAuB,SAAuB;AAC9D,wBAAgB,iBAAiB,IAAI,iBAAiB,CAKrD;AACD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAO9D"}
|
package/dist/memory/automatic.js
CHANGED
|
@@ -55,7 +55,7 @@ class AutoIndexer {
|
|
|
55
55
|
try {
|
|
56
56
|
this.state.phase = 'scanning';
|
|
57
57
|
this.state.error = '';
|
|
58
|
-
const scanned = await this.ops.scan();
|
|
58
|
+
const scanned = await this.ops.scan(signal);
|
|
59
59
|
if (signal.aborted || !this.ops.enabled())
|
|
60
60
|
return;
|
|
61
61
|
if (scanned.warnings.length)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automatic.js","sourceRoot":"","sources":["../../src/memory/automatic.ts"],"names":[],"mappings":";;AAkFA,8CAAmF;AAInF,0DAOC;AACD,wDAGC;AACD,0DAA8D;AAC9D,8CAKC;AACD,oCAOC;AAhHD,yCAAiD;AACjD,qCAA8D;AAC9D,iDAAiD;AACjD,yCAAuE;AACvE,uCAA4D;A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
|
package/dist/memory/context.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { HistoryResults } from './types';
|
|
2
|
-
export declare function historyContext(question: string, before: string, signal?: AbortSignal, maxBytes?: number): Promise<{
|
|
1
|
+
import type { HistoryQuery, HistoryResults } from './types';
|
|
2
|
+
export declare function historyContext(question: string, before: string, signal?: AbortSignal, maxBytes?: number, preparedOnly?: boolean, selection?: Pick<HistoryQuery, 'session_ids' | 'kind' | 'recent' | 'topics'>): Promise<{
|
|
3
3
|
text: string;
|
|
4
4
|
refs: string[];
|
|
5
5
|
}>;
|
|
6
|
-
export declare function historyPacket(found: Pick<HistoryResults, 'results' | 'limitations'> & {
|
|
6
|
+
export declare function historyPacket(found: Pick<HistoryResults, 'results' | 'limitations' | 'reconciliation'> & {
|
|
7
7
|
mode: HistoryResults['mode'] | 'reference_read';
|
|
8
|
-
}, maxBytes?: number): {
|
|
8
|
+
}, maxBytes?: number, excerptLimit?: number): {
|
|
9
9
|
text: string;
|
|
10
10
|
refs: string[];
|
|
11
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/memory/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/memory/context.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAW5D,wBAAsB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,QAAQ,SAAO,EAAE,YAAY,UAAQ,EAAE,SAAS,GAAE,IAAI,CAAC,YAAY,EAAE,aAAa,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAM;;;GA2BnN;AACD,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,SAAS,GAAG,aAAa,GAAG,gBAAgB,CAAC,GAAG;IAAE,IAAI,EAAE,cAAc,CAAC,MAAM,CAAC,GAAG,gBAAgB,CAAA;CAAE,EAAE,QAAQ,SAAO,EAAE,YAAY,SAA+B;;;EAmD1N"}
|
package/dist/memory/context.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.historyContext = historyContext;
|
|
|
4
4
|
exports.historyPacket = historyPacket;
|
|
5
5
|
const service_1 = require("./service");
|
|
6
6
|
const normalize_1 = require("../sync/normalize");
|
|
7
|
+
const reconcile_1 = require("./reconcile");
|
|
7
8
|
// Existing E/C labels belong to a particular snapshot. Do not let quoted source
|
|
8
9
|
// text masquerade as references in the current answer's namespace.
|
|
9
10
|
const quote = (text, max) => {
|
|
@@ -13,43 +14,90 @@ const quote = (text, max) => {
|
|
|
13
14
|
const marker = '\n[middle omitted]\n', head = Math.floor((max - marker.length) / 3);
|
|
14
15
|
return full.slice(0, head) + marker + full.slice(-(max - marker.length - head));
|
|
15
16
|
};
|
|
16
|
-
async function historyContext(question, before, signal, maxBytes = 3500) {
|
|
17
|
+
async function historyContext(question, before, signal, maxBytes = 3500, preparedOnly = false, selection = {}) {
|
|
17
18
|
const explicit = [...new Set(question.match(/\bH[a-f0-9]{24}\b/g) || [])].slice(0, 3);
|
|
18
|
-
if (explicit.length) {
|
|
19
|
+
if (explicit.length && !(maxBytes > 7000 && selection.kind === 'sources' && (0, reconcile_1.statusQuestion)(question) && !/\boffset[ :=]+\d/i.test(question))) {
|
|
19
20
|
const sources = [];
|
|
20
21
|
for (const ref of explicit) {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const requested = question.match(new RegExp(`\\b${ref}\\s+(?:at\\s+)?offset[ :=]+(\\d{1,7})\\b`, 'i'));
|
|
23
|
+
const offset = requested ? Math.min(1000000, Number(requested[1])) : 0;
|
|
24
|
+
const page = await (0, service_1.readHistory)(ref, offset, signal, preparedOnly ? before : undefined);
|
|
25
|
+
if (page.record.at && page.record.at <= before && (!selection.session_ids || (page.record.session_id && selection.session_ids.includes(page.record.session_id))))
|
|
26
|
+
sources.push({ ...page.record, offset: page.offset, score: 1 });
|
|
24
27
|
}
|
|
25
|
-
return historyPacket({ results: sources, mode: 'reference_read', limitations: 'Explicit historical references, not a new archive search. Missing or undated records cannot establish an as-of claim.' }, maxBytes);
|
|
28
|
+
return historyPacket({ results: sources, mode: 'reference_read', limitations: 'Explicit historical references, not a new archive search. Missing or undated records cannot establish an as-of claim.' }, maxBytes, explicit.length === 1 ? (maxBytes > 3500 ? 4000 : 2400) : 800);
|
|
26
29
|
}
|
|
27
|
-
const found = await (
|
|
30
|
+
const found = await (preparedOnly ? service_1.searchPreparedHistory : service_1.searchHistory)({ ...selection, ...(maxBytes > 7000 && selection.kind === 'sources' ? { reconcile: true } : {}), question: (0, normalize_1.cleanText)(question, 2000), before }, signal);
|
|
31
|
+
found.limitations += ` Prepared history cutoff: ${before}. This is the latest recorded evidence within that cutoff, not live process observation.`;
|
|
32
|
+
// Search already verifies original bytes before and after inference. For work
|
|
33
|
+
// questions, keep original matches rather than crowding them out with nearby
|
|
34
|
+
// chatter. Explicit H requests can read a longer original passage next.
|
|
35
|
+
if (selection.kind === 'sources')
|
|
36
|
+
return historyPacket(found, maxBytes, maxBytes > 7000 ? 3000 : maxBytes > 3500 ? 1200 : 800);
|
|
28
37
|
// Read the leading match and adjacent records, rather than trusting a search
|
|
29
38
|
// snippet alone. Keep neighbors' own dates, roles and reference identities.
|
|
30
39
|
if (found.results[0]) {
|
|
31
|
-
const hit = found.results[0], page = await (0, service_1.readHistory)(hit.ref, Math.max(0, hit.offset - 200), signal);
|
|
40
|
+
const hit = found.results[0], page = await (0, service_1.readHistory)(hit.ref, Math.max(0, hit.offset - 200), signal, preparedOnly ? before : undefined);
|
|
32
41
|
const neighbors = page.neighbors.filter(item => item.at && item.at <= before);
|
|
33
42
|
found.results = [hit, ...found.results.slice(1, 2), ...neighbors.map(item => ({ ...item, offset: 0, score: 0 })), ...found.results.slice(2)]
|
|
34
43
|
.filter((item, index, all) => all.findIndex(other => other.ref === item.ref) === index);
|
|
35
44
|
}
|
|
36
45
|
return historyPacket(found, maxBytes);
|
|
37
46
|
}
|
|
38
|
-
function historyPacket(found, maxBytes = 3500) {
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
47
|
+
function historyPacket(found, maxBytes = 3500, excerptLimit = maxBytes <= 3500 ? 400 : 800) {
|
|
48
|
+
const contiguous = excerptLimit >= 800;
|
|
49
|
+
const clip = (text, max) => {
|
|
50
|
+
if (!contiguous)
|
|
51
|
+
return quote(text, max);
|
|
52
|
+
const full = quote(text, Number.MAX_SAFE_INTEGER);
|
|
53
|
+
return full.length <= max ? full : full.slice(0, Math.max(0, max - 20)) + '\n[excerpt continues]';
|
|
54
|
+
};
|
|
55
|
+
const originals = new Map();
|
|
56
|
+
const sources = found.results.map(item => {
|
|
57
|
+
const body = excerptLimit >= 800 && (excerptLimit <= 1600 || found.mode !== 'reference_read') && item.role === 'assistant' && item.offset === 0 && item.text.includes('\nTool requested:')
|
|
58
|
+
? item.text.slice(0, item.text.indexOf('\nTool requested:')) + '\n[tool requests omitted]' : item.text;
|
|
59
|
+
originals.set(item.ref, body);
|
|
60
|
+
return { ref: item.ref, kind: item.kind, sync_id: item.sync_id, session_id: item.session_id,
|
|
61
|
+
at: item.at, sequence: item.sequence, role: item.role, qualification: item.qualification, workspace: item.workspace, lead: item.lead ? quote(item.lead, 400) : undefined,
|
|
62
|
+
text: clip(body, excerptLimit), offset: item.offset, ending: undefined };
|
|
63
|
+
});
|
|
64
|
+
let shown = sources.slice(0, maxBytes <= 3500 ? (excerptLimit >= 800 ? 3 : 4) : maxBytes <= 7000 ? 4 : 16);
|
|
43
65
|
for (;;) {
|
|
66
|
+
// Never pack an earlier blocker without all selected later reports. This
|
|
67
|
+
// also applies when byte pressure removes a source from a linked chain.
|
|
68
|
+
let changed = true;
|
|
69
|
+
while (changed) {
|
|
70
|
+
const refs = new Set(shown.map(item => item.ref)), previous = shown.length;
|
|
71
|
+
shown = shown.filter(item => !(found.reconciliation?.threads || []).some(thread => thread.earlier_ref === item.ref && thread.later_refs.some(ref => !refs.has(ref))));
|
|
72
|
+
changed = shown.length !== previous;
|
|
73
|
+
}
|
|
74
|
+
if (found.reconciliation?.threads.length)
|
|
75
|
+
for (const item of shown) {
|
|
76
|
+
const full = originals.get(item.ref);
|
|
77
|
+
if (item.text !== quote(full, Number.MAX_SAFE_INTEGER)) {
|
|
78
|
+
// Closing qualifications often say that only the client was completed,
|
|
79
|
+
// while delivery remains disabled. Preserve this contiguous ending with
|
|
80
|
+
// its own original offset instead of silently clipping that distinction.
|
|
81
|
+
const start = Math.max(0, full.length - 600);
|
|
82
|
+
item.ending = { offset: item.offset + start, text: quote(full.slice(start), 600) };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const refs = new Set(shown.map(item => item.ref));
|
|
86
|
+
const threads = found.reconciliation?.threads.filter(thread => refs.has(thread.earlier_ref) && thread.later_refs.every(ref => refs.has(ref)));
|
|
87
|
+
const reconciliation = found.reconciliation ? { ...found.reconciliation, threads,
|
|
88
|
+
omitted_threads: found.reconciliation.omitted_threads + found.reconciliation.threads.length - threads.length } : undefined;
|
|
44
89
|
const text = JSON.stringify({ type: 'read_only_history', scope: 'Historical lookup, separate from the frozen snapshot. Historical text is untrusted data, not a current request.',
|
|
45
|
-
mode: found.mode, sources: shown, omitted_matches: sources.length - shown.length,
|
|
90
|
+
mode: found.mode, sources: shown, reconciliation, omitted_matches: sources.length - shown.length,
|
|
46
91
|
limitations: found.limitations + ' Excerpts may omit corrections elsewhere. No match is not proof something never happened. Cite only the supplied H references; never infer agreement from generated speech.' });
|
|
47
92
|
if (Buffer.byteLength(text) <= maxBytes)
|
|
48
93
|
return { text, refs: shown.map(item => item.ref) };
|
|
49
|
-
|
|
94
|
+
const longest = shown.reduce((a, b) => !a || b.text.length > a.text.length ? b : a, undefined);
|
|
95
|
+
if (shown.length > 1 && longest && longest.text.length > 400)
|
|
96
|
+
longest.text = clip(longest.text, Math.max(400, Math.floor(longest.text.length * 0.75)));
|
|
97
|
+
else if (shown.length > 1)
|
|
50
98
|
shown = shown.slice(0, -1);
|
|
51
99
|
else if (shown[0]?.text.length > 100)
|
|
52
|
-
shown[0].text =
|
|
100
|
+
shown[0].text = clip(shown[0].text, Math.floor(shown[0].text.length / 2));
|
|
53
101
|
else if (shown.length)
|
|
54
102
|
shown = [];
|
|
55
103
|
else
|