draken 0.3.0 → 0.4.1
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 +2 -2
- package/CHANGELOG.md +56 -0
- package/MEMORY.md +9 -5
- package/README.md +14 -6
- package/SETUP.md +1 -1
- package/VOICE.md +6 -2
- package/dist/memory/automatic.d.ts +11 -5
- package/dist/memory/automatic.d.ts.map +1 -1
- package/dist/memory/automatic.js +64 -20
- package/dist/memory/automatic.js.map +1 -1
- package/dist/memory/context.d.ts +1 -0
- package/dist/memory/context.d.ts.map +1 -1
- package/dist/memory/context.js +4 -0
- package/dist/memory/context.js.map +1 -1
- package/dist/routes/live-voice.d.ts.map +1 -1
- package/dist/routes/live-voice.js +7 -1
- package/dist/routes/live-voice.js.map +1 -1
- package/dist/routes/memory.d.ts.map +1 -1
- package/dist/routes/memory.js +12 -2
- package/dist/routes/memory.js.map +1 -1
- package/dist/routes/sync.d.ts.map +1 -1
- package/dist/routes/sync.js +23 -7
- package/dist/routes/sync.js.map +1 -1
- package/dist/sync/answer-references.d.ts +10 -0
- package/dist/sync/answer-references.d.ts.map +1 -0
- package/dist/sync/answer-references.js +47 -0
- package/dist/sync/answer-references.js.map +1 -0
- package/dist/sync/automatic.d.ts +7 -0
- package/dist/sync/automatic.d.ts.map +1 -0
- package/dist/sync/automatic.js +56 -0
- package/dist/sync/automatic.js.map +1 -0
- package/dist/sync/cost.d.ts +2 -1
- package/dist/sync/cost.d.ts.map +1 -1
- package/dist/sync/cost.js +10 -6
- package/dist/sync/cost.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 +34 -33
- package/dist/sync/manager.js.map +1 -1
- package/dist/sync/store.d.ts +8 -1
- package/dist/sync/store.d.ts.map +1 -1
- package/dist/sync/store.js +50 -4
- package/dist/sync/store.js.map +1 -1
- package/dist/sync/tree.d.ts.map +1 -1
- package/dist/sync/tree.js +13 -7
- package/dist/sync/tree.js.map +1 -1
- package/dist/sync/usage.d.ts +6 -0
- package/dist/sync/usage.d.ts.map +1 -0
- package/dist/sync/usage.js +91 -0
- package/dist/sync/usage.js.map +1 -0
- package/dist/types.d.ts +37 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/voice/continuation.d.ts.map +1 -1
- package/dist/voice/continuation.js +7 -2
- package/dist/voice/continuation.js.map +1 -1
- package/dist/voice/history-delivery.d.ts +19 -0
- package/dist/voice/history-delivery.d.ts.map +1 -0
- package/dist/voice/history-delivery.js +57 -0
- package/dist/voice/history-delivery.js.map +1 -0
- package/dist/voice/history-focus.d.ts +4 -0
- package/dist/voice/history-focus.d.ts.map +1 -1
- package/dist/voice/history-focus.js +15 -0
- package/dist/voice/history-focus.js.map +1 -1
- 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 +2 -1
- package/dist/voice/live-context.js.map +1 -1
- package/dist/voice/live.d.ts.map +1 -1
- package/dist/voice/live.js +62 -28
- package/dist/voice/live.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-D79D-rxm.css +1 -0
- package/public/assets/index-DYX9neRz.js +131 -0
- package/public/assets/{persona-BVIfx5k8.js → persona-CsDA3JtF.js} +1 -1
- package/public/index.html +3 -3
- package/public/persona.html +3 -3
- package/public/assets/index-CYCbTSh1.js +0 -131
- package/public/assets/index-DntUQtGK.css +0 -1
- /package/public/assets/{index-BQFBaSKm.js → index-B13h0MjX.js} +0 -0
package/ACCEPTANCE.md
CHANGED
|
@@ -15,8 +15,8 @@ The release workflow requires a strict stable version already committed consiste
|
|
|
15
15
|
Use disposable histories first. Real-provider checks below require the operator's explicit sign-in and consent.
|
|
16
16
|
|
|
17
17
|
- [ ] **Useful, qualified briefing:** distinguish what was proposed, attempted, tested, deployed, and still unresolved. Inspect original evidence and a late correction; verify the summary preserves chronology and qualifications rather than sounding more certain.
|
|
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.
|
|
19
|
-
- [ ] **
|
|
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. The single indexing-and-briefing permission is separate from agent-source permission; legacy local-only opt-in alone cannot start paid preparation.
|
|
19
|
+
- [ ] **Automatic preparation and restart:** an already indexed backlog of 64 waiting entries still gets a briefing. Smaller new tails wait unless a 64-source-change batch is due; unfinished owned preparation resumes from cache. Session bookkeeping and aliases do not multiply the change count. Joining an unchanged ready batch makes no new briefing call. Foreground tails get a new immutable snapshot. Model failure pauses paid retries until an explicit action, including across restart. Review and notes remain untouched.
|
|
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
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.
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,61 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.4.1
|
|
4
|
+
|
|
5
|
+
This release improves audio recall, makes preparation charts easier to read, and explains automatic compaction and cost tracking on Home and the public website.
|
|
6
|
+
|
|
7
|
+
### Audio evidence and continuity
|
|
8
|
+
|
|
9
|
+
- Native voice now uses the same bounded archive selection and later-report checking as chat: up to sixteen sources in a 32,000-byte historical packet. Original source permissions, captured cutoffs and qualifications are retained.
|
|
10
|
+
- New calls inherit project focus from actual saved user turns, not generated replies. Explicit switches still win. Questions about old historical or frozen checkpoints check later reports instead of merely repeating the old state.
|
|
11
|
+
- Larger evidence travels losslessly through bounded native context messages; the small handoff returns a completion receipt. Partial transfers are never marked ready, repeated lookups reuse delivery, and Stop/new turns prevent old transfers from continuing.
|
|
12
|
+
- Spoken answers keep the existing concise target. No extra pi generation or replacement voice engine is introduced. More input context is not a guarantee of unchanged native quota use.
|
|
13
|
+
- Native speech is not post-validated or retractable like text's citation-repair pass. Protocol tests and matching evidence packets do not establish physical-audio acceptance or exhaustive answer accuracy.
|
|
14
|
+
|
|
15
|
+
### Readable preparation costs and clearer guidance
|
|
16
|
+
|
|
17
|
+
- Add labelled USD/whole-batch Y-axes and gridlines, with matching rounded bar scales and readable mobile labels. Handle zero, tiny, large and unavailable costs without inventing prices.
|
|
18
|
+
- Explain automatic preparation/compaction and preparation spending estimates on the app Home page, README and public homepage. Compaction produces cached summaries; it does not modify or delete original logs.
|
|
19
|
+
- Keep cost boundaries explicit: recorded preparation estimates include retries and failures, but exclude chat, native voice, standalone post-conversation recaps and local machine/network costs. They are not invoices, total spending or quota balances.
|
|
20
|
+
- Opening the explanatory panel or dashboard does not enable automatic mode, start inference, capture audio or mark work reviewed.
|
|
21
|
+
|
|
22
|
+
### Upgrading from 0.4.0
|
|
23
|
+
|
|
24
|
+
- No schema migrations or dependency changes. Existing histories, notes, conversations, coverage, cached summaries and compatible vectors remain intact.
|
|
25
|
+
- Node.js 22.19+ and npm remain required. Back up original logs and Draken data, wait for active work to finish, stop the server, upgrade and restart. Existing automatic-preparation consent remains unchanged.
|
|
26
|
+
|
|
27
|
+
## 0.4.0
|
|
28
|
+
|
|
29
|
+
This release prepares conversations in the background, makes preparation usage visible, and improves text-answer reference handling.
|
|
30
|
+
|
|
31
|
+
### One automatic preparation mode
|
|
32
|
+
|
|
33
|
+
- **Automatically prepare conversations** combines source discovery, local search indexing, summary batches and the next briefing. Home shows the actual stage, entry progress, model invocations, errors and last completion.
|
|
34
|
+
- Start a batch at 64 source changes or waiting entries, resume interrupted owned work from cache, and reuse an untouched ready briefing when you join. Small new tails wait for foreground preparation or a full batch; there is no timed flush.
|
|
35
|
+
- Foreground work takes priority. Provider failures require an explicit retry rather than an endless paid loop. Existing conversations, notes and frozen snapshots are not rewritten.
|
|
36
|
+
- This mode uses the configured pi summary/final models and their quota or API billing within the saved invocation limit. Existing local-index-only permission does **not** authorize it: enable the replacement switch explicitly. Agent/session exclusions remain independent. No automatic microphone, call, user question, note saving or review.
|
|
37
|
+
|
|
38
|
+
### Preparation usage in Settings
|
|
39
|
+
|
|
40
|
+
- A wider, responsive Settings dialog shows completed batches, entries, model requests, active preparation and estimated cost, with charts and bucket details.
|
|
41
|
+
- Look back 6 hours, 1 day, 7 days or 14 days, grouped into 1-hour, 6-hour or 24-hour UTC buckets. The dashboard refreshes every 15 seconds only while Settings is open.
|
|
42
|
+
- Include automatic and manual preparation, retries, failed work and discarded snapshots. Count a snapshot's first successful briefing preparation once; rebuilding it adds cost without another completed batch.
|
|
43
|
+
- New requests receive durable timestamps and a pending accounting record. Older timing is labelled approximate; missing pricing remains unavailable or a partial subtotal, never a guessed zero.
|
|
44
|
+
- Costs are recorded API-price estimates, not invoices, subscription charges or quota balances. Chat, native voice, post-conversation recaps and local machine/network costs are excluded. Opening the dashboard reads metadata only; it does not start preparation.
|
|
45
|
+
|
|
46
|
+
### More reliable text-answer references
|
|
47
|
+
|
|
48
|
+
- Give the final model short, stable per-answer labels and map them back to admitted original-source references before saving an answer. Historical citations inside quoted text do not authorize new references.
|
|
49
|
+
- Handle bad/missing citations and ignored later reports in one bounded correction through the same final model and invocation/cancellation budget. Unknown references are not guessed or silently removed; rejected drafts are not saved.
|
|
50
|
+
- Show the actual source-reference correction stage. Error wording describes validation failure rather than asserting that a reference was invented. Citation checks still do not independently verify every claim, and native voice retains its separate lookup path.
|
|
51
|
+
|
|
52
|
+
### Upgrading from 0.3.0
|
|
53
|
+
|
|
54
|
+
- **No new database tables, columns or schema migration.** Existing SQLite run records, JSON metrics and settings storage are reused. No dependency changes.
|
|
55
|
+
- Existing histories, conversations, notes, review state, cached summaries and compatible search vectors are retained. Older usage records are not rewritten or backfilled from current prices.
|
|
56
|
+
- Node.js 22.19+ and npm remain required. Back up original logs and Draken data, wait for active work to finish, stop the server, upgrade and restart. No automatic boot startup or hot reload is added.
|
|
57
|
+
- Automated qualification does not establish exhaustive real-model answer quality, future account quota or physical-device voice acceptance.
|
|
58
|
+
|
|
3
59
|
## 0.3.0
|
|
4
60
|
|
|
5
61
|
This release adds a separate text-chat experience and improves how Draken prepares history and checks later updates.
|
package/MEMORY.md
CHANGED
|
@@ -16,11 +16,13 @@ Opening/reloading a page does not itself download the model, compute embeddings
|
|
|
16
16
|
|
|
17
17
|
### Optional background indexing
|
|
18
18
|
|
|
19
|
-
**Settings → Automatically
|
|
19
|
+
**Settings → Automatically prepare conversations** is the single opt-in for scanning, local indexing, summary batches and the final briefing. It is off by default and works while the server runs, even without a browser. It uses the configured pi summary/final models and their quota or API billing within the saved per-run invocation limit, and may download the pinned local embedding model on first use. It creates new immutable sync snapshots; existing snapshots, discussions and notes are not rewritten. It never starts audio, a call or review. Earlier local-index-only permission is not silently upgraded to paid model permission: the replacement switch records the combined scope.
|
|
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
|
|
21
|
+
The app's single scheduler checks once a minute when no sync, call or foreground history work is active. A new background batch requires at least 64 changed source records or 64 entries waiting for a briefing, regardless of elapsed time; unfinished owned batches resume from their cached work. An already indexed backlog still receives its briefing. 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
|
-
Foreground
|
|
23
|
+
Foreground requests preempt and await the owned automatic job, including its provider call. Disabling cancels only that automatic job; completed vectors and summary nodes remain reusable. A provider/briefing failure is durably paused until explicit retry, rather than repeating paid calls on a timer. Local preparation failures retry no sooner than five minutes; foreground preemption waits at least one minute. Shutdown awaits owned work. Settings/progress GETs remain metadata-only. Home shows the same combined pipeline as Settings, including actual summary counts and model-call budget; last completion and unfinished snapshot ownership survive restart. A ready untouched automatic snapshot is claimed once by the Home conversation action, preserving delivery idempotency and avoiding another briefing call. New arrivals belong to a new snapshot; earlier batches come along as qualified, lossy recaps, with originals available through retrieval.
|
|
24
|
+
|
|
25
|
+
The hash-only search checkpoint still advances only after successful global preparation. Missing older checkpoints can be established by the combined opt-in's preparation pass, reusing compatible vectors. Snapshot ownership uses private `auto:` request IDs until a foreground request claims the batch; it is not review coverage. Existing user conversations are not adopted as unfinished background jobs. No source-text copy, provider substitution, vector conversion or timed small-batch flush is introduced.
|
|
24
26
|
|
|
25
27
|
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
28
|
|
|
@@ -30,7 +32,9 @@ Voice and **Chat instead** work questions prefer original session records, not o
|
|
|
30
32
|
|
|
31
33
|
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
34
|
|
|
33
|
-
Voice source
|
|
35
|
+
Voice uses the same up-to-32,000-byte, sixteen-source historical selection and later-report graph as text chat. An explicit E/C status question also carries its requested frozen excerpt (up to 3,500 bytes, combined envelope at most 36,000 bytes); it no longer bypasses archive update checking. Frozen source session/sequence metadata permits comparison with historical aliases without inferring chronology across sessions. Excerpts retain implementation details and closing qualifications; tool requests may be omitted with an explicit marker. A later passage can include its source's beginning for context. Native context appends remain bounded to 8,192 UTF-8 bytes: a larger evidence document travels losslessly as ordered, JSON-quoted fragments followed by a completion record, not a truncated handoff or another model-generated summary. There are at most twelve fragments plus one completion record; transport quoting adds overhead to the selection budget. Sources are published and continuation becomes eligible only after complete delivery. A failed transfer ends the call; Stop/new turns prevent further old fragments, completion and continuation. The helper's small handoff response carries only a completion receipt after the full context has been delivered.
|
|
36
|
+
|
|
37
|
+
New calls reconstruct project focus from the same bounded actual-user-turn history as chat; generated answers and retrieved instructions cannot select a project. Explicit project switches still win. The helper can refine a question or request an H reference (optionally with `offset 2000`); each user turn permits at most three distinct archive lookups and reuses both duplicate results and their delivery. Source IDs are supplied context for that turn, not verified per-claim citations or evidence of hearing/agreement. A failed or empty work lookup is not silently replaced by an old conversation. More native input context does not add pi calls or lengthen the spoken-answer target; it is not a guarantee of unchanged provider quota usage.
|
|
34
38
|
|
|
35
39
|
### Separate text chat
|
|
36
40
|
|
|
@@ -40,7 +44,7 @@ Text status questions additionally check for later related original assistant na
|
|
|
40
44
|
|
|
41
45
|
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
46
|
|
|
43
|
-
If a text answer cites a linked old checkpoint
|
|
47
|
+
Final answers use a stable per-request `R1`, `R2`, … label catalog, mapped by Draken to the admitted E/C/H source references before validation and persistence. Source excerpts, earlier briefings and discussion are quoted data: their embedded citation syntax does not create labels. Explicit source requests are mapped into the same catalog. Unknown labels are neither guessed nor dropped. If a text answer has missing/out-of-catalog citations or cites a linked old checkpoint while ignoring supplied later reports (including E/C aliases), Draken permits **one combined correction 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 source references** or **Checking later updates** identifies the actual correction 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. Native voice shares the larger evidence selection and deterministic later-report checking, but **not the pi answer-repair pass**: already-streamed speech cannot be retracted or certified by this citation guard. Its prompt keeps the same concise delivery target, including necessary caveats. Shared evidence does not establish identical generated answers or exhaustive recall.
|
|
44
48
|
|
|
45
49
|
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.
|
|
46
50
|
|
package/README.md
CHANGED
|
@@ -10,7 +10,11 @@ A local-first engineering sync across your **pi, Codex CLI and Claude Code sessi
|
|
|
10
10
|
|
|
11
11
|
**Sync with Draken → call or chat → keep a short recap.**
|
|
12
12
|
|
|
13
|
-
**Draken 0.
|
|
13
|
+
**Draken 0.4.1** improves audio evidence and project continuity, adds readable chart value axes, and makes preparation and cost tracking easier to find. See [the release notes](CHANGELOG.md#041).
|
|
14
|
+
|
|
15
|
+
**Automatic preparation and compaction:** opt in through **Settings → Automatically prepare conversations** to index history, summarize new work and prepare a briefing while the server runs. Compaction means cached, derived summaries—not editing or deleting your original agent logs. Matching summaries and ready briefings are reused. This mode is off by default and uses your configured models within the saved invocation limit; it never starts a call or marks work reviewed.
|
|
16
|
+
|
|
17
|
+
**Track preparation spending estimates:** **Settings → Preparation usage** shows estimated USD cost, completed batches and model requests over time, with labelled cost/batch axes and exact bucket details. It includes manual/automatic preparation, retries and failed work. Missing prices stay unavailable or partial. This is **not total spending, a provider invoice or account quota**: chat, voice, standalone post-conversation recaps and local machine/network costs are excluded. Opening the dashboard only reads metadata.
|
|
14
18
|
|
|
15
19
|
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.
|
|
16
20
|
|
|
@@ -22,7 +26,7 @@ Draken remembers which evidence a finished sync covered, what you decided, and w
|
|
|
22
26
|
|
|
23
27
|
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.
|
|
24
28
|
|
|
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.
|
|
29
|
+
> **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.4.1](CHANGELOG.md#041).
|
|
26
30
|
|
|
27
31
|
```sh
|
|
28
32
|
npm install -g draken
|
|
@@ -54,7 +58,9 @@ Run setup/login as the server’s user with the same environment. `draken status
|
|
|
54
58
|
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.
|
|
55
59
|
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.
|
|
56
60
|
|
|
57
|
-
**Settings
|
|
61
|
+
**Settings → Automatically prepare conversations** is one mode for the whole preparation pipeline: scan history, update local search, summarize new entries and prepare the opening briefing before you arrive. It is off by default and persists across restarts. Checks run once a minute while idle; 64 changed source records or waiting entries trigger a batch, and interrupted batches resume from cache. Smaller new tails wait for foreground preparation, with no timed flush. Home and Settings show the current stage, summary progress and last completed batch. Joining an unchanged prepared batch reuses its snapshot and briefing; later entries get a new snapshot with the earlier preparation as historical context. Existing conversations, notes and frozen evidence are never rewritten or marked reviewed. Calls and foreground work take priority.
|
|
62
|
+
|
|
63
|
+
This single opt-in authorizes **configured pi summary/final model use**, including account quota or API billing, bounded by each snapshot's saved invocation limit (120 by default). Provider failures pause automatic retries until an explicit retry; completed work is retained. There is no microphone capture or automatic call. An older local-index-only opt-in does not silently authorize this wider scope: enable the replacement switch once after upgrading. First use may download the pinned local search model. Agent/session exclusions remain respected; enabling other agents still requires their own source consent.
|
|
58
64
|
|
|
59
65
|
**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.
|
|
60
66
|
|
|
@@ -70,7 +76,7 @@ A square Draken portrait accompanies replies. **Searching your prepared history*
|
|
|
70
76
|
|
|
71
77
|
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
78
|
|
|
73
|
-
For status questions,
|
|
79
|
+
For status questions, chat and native voice use the same bounded original-evidence selection and check later related reports before repeating old blockers, including follow-ups to a report that was itself superseded. New calls inherit project focus from actual saved user turns. Voice delivers the larger evidence packet through bounded native context parts while keeping spoken answers concise; it does not add a pi generation step. The following answer-repair check remains text-only; streamed speech is not post-validated. Client implementation, backend foundations, delivery enablement and device acceptance are kept distinct. The final model uses short per-answer reference labels, which Draken maps back to admitted original links; quoted historical citations never authorize new references. Bad/missing citations and ignored later follow-ups share one bounded same-model correction, with the same label catalog in both calls. A second validation failure remains visible without saving an unsupported 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
80
|
|
|
75
81
|
### Model integration
|
|
76
82
|
|
|
@@ -109,6 +115,8 @@ Each run also retains metadata-only request timings, model/task/stage and repair
|
|
|
109
115
|
|
|
110
116
|
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.
|
|
111
117
|
|
|
118
|
+
Settings includes a **Preparation usage** dashboard with 6-hour, 1-day, 7-day and 14-day lookbacks, and 1-hour, 6-hour or 24-hour UTC buckets. It shows completed briefing batches, model requests and their recorded API-price estimate, across automatic and manual preparation—including retries, failed work and discarded snapshots. A batch is a snapshot's first successful briefing preparation; rebuilds add cost without counting it again. It is not proof of review or current call readiness. Request costs are placed at their start time, and completed batches at their completion time. New requests have durable timestamps, including pending/interrupted requests; older metrics use the run start and are explicitly approximate. Missing usage/pricing is unavailable or a partial subtotal, never a fabricated zero or a backfill from today's prices. These are estimates, not invoices or subscription/quota balances. Chat, native voice, post-conversation recaps and local machine/network costs are excluded. Opening Settings and changing the time range only read accounting metadata; polling stops when it closes.
|
|
119
|
+
|
|
112
120
|
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.
|
|
113
121
|
|
|
114
122
|
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.
|
|
@@ -117,7 +125,7 @@ The manager is a **read-only conversation**, not a worker. Its responses disting
|
|
|
117
125
|
|
|
118
126
|
The new workflow freezes the three most recent non-discarded syncs' briefing, discussion and explicit notes at snapshot creation. Their full supplied text passes through cached bounded map/reduce recap jobs; it does not silently select only the final messages. This remains **lossy summarization**, not exhaustive recall or independent verification. Recaps are 1–5 short lines (at most 600 characters), labelled historical summaries rather than agreement. Old source IDs are not treated as this snapshot's citations. Original histories remain available at their own URLs.
|
|
119
127
|
|
|
120
|
-
The card shows a short recap, or an explicitly labelled briefing preview until one exists, with its body clamped to three visual lines. A changed conversation marks an older recap as stale. Closing the call UI requests an asynchronous recap using the cheap model (maximum 32 invocations, also bounded by the sync's saved ceiling); interrupted browser exits cannot guarantee that request. **Make recap / Refresh recap** retries explicitly, and the next sync recomputes changed prior inputs from cache. Recaps never change notes, source snapshots or coverage.
|
|
128
|
+
The card shows a short recap, or an explicitly labelled briefing preview until one exists, with its body clamped to three visual lines. A changed conversation marks an older recap as stale. Closing the call UI requests an asynchronous recap using the cheap model (maximum 32 invocations, also bounded by the sync's saved ceiling); interrupted browser exits cannot guarantee that request. **Make recap / Refresh recap** retries explicitly, and the next sync recomputes changed prior inputs from cache. Recaps never change notes, source snapshots or coverage. The single automatic-preparation opt-in also permits these preparation recaps and briefing model calls in the background; merely browsing does not. Native recall can reuse these prior-sync recaps, but cannot quote original words from them; historical lookup automatically retrieves retained original excerpts across sessions and syncs through the local hybrid index, separately from frozen discussion and recaps; see [MEMORY.md](MEMORY.md).
|
|
121
129
|
|
|
122
130
|
The migration adds presentation/recap-cache tables and removes the single-open-sync index without rewriting original rows. Once multiple open snapshots exist, do not blindly downgrade to the old one-open-sync schema. ChatGPT is the only voice engine. Removing the old engine does not remove its historical records, and updating the app does not require restoring an old database.
|
|
123
131
|
|
|
@@ -155,7 +163,7 @@ Current limits: discovery is eight directories deep; each scan reads up to 32 Mi
|
|
|
155
163
|
|
|
156
164
|
Session logs can contain private source code, prompts, command output, and credentials.
|
|
157
165
|
|
|
158
|
-
- **Provider-model use starts through
|
|
166
|
+
- **Provider-model use starts through conversation/preparation actions or the explicitly enabled combined automatic-preparation mode.** The combined action prepares previous recaps and a new briefing before calling; closing the call UI requests a derived recap. Voice turns do not invoke pi. Calls open a persistent OpenAI audio session at call start; idle/quota accounting is not established. There is no separate permission checkbox. Scanning and reading evidence stay local. History lookup automatically prepares/updates a local embedding index when needed; first use downloads pinned public weights. Text questions and calls receive relevant historical excerpts by default through their existing model. Merely opening a page performs no embedding inference; the explicitly enabled automatic-preparation schedule runs independently of browsing and can also use the configured summary/final models.
|
|
159
167
|
- Thinking blocks, system prompts, images, and opaque signatures are not indexed. Tool-call arguments are minimized; common secret patterns are redacted. **This is best-effort, not a guarantee that the remaining text is safe to share.** Inspect evidence and exclude sensitive sessions before calling a provider.
|
|
160
168
|
- SQLite contains verified live-session and frozen-snapshot pointers, cached summaries, run metadata, decisions and conversations—not copies of original agent entry bodies. It lives outside the checkout in `~/.draken/draken.db` by default. **Original agent JSONL files are the authoritative archive, including for old snapshots.** Back up both those files and Draken's private state. Missing/changed originals are labelled unavailable; discussion and notes remain accessible, but generating replies, calling or reviewing that snapshot requires restoring its evidence. Search stores passage hashes, unique vectors, source links and contentless keyword postings, not passage bodies. See [MEMORY.md](MEMORY.md) for migration and storage details. There is no in-app retention/purge UI yet.
|
|
161
169
|
- The server defaults to loopback with **no dashboard login**. Explicitly configured credentials (or `DRAKEN_NO_AUTH=false`) retain authentication even on loopback. Local API access still rejects cross-origin requests and unexpected Host headers.
|
package/SETUP.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
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
|
-
> This guide is for **Draken 0.
|
|
5
|
+
> This guide is for **Draken 0.4.1**. 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#041).
|
|
6
6
|
|
|
7
7
|
## Install and start
|
|
8
8
|
|
package/VOICE.md
CHANGED
|
@@ -41,13 +41,17 @@ Capture follows a transient browser action, never a URL flag. Reloading or openi
|
|
|
41
41
|
|
|
42
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.
|
|
43
43
|
|
|
44
|
-
Work questions use original
|
|
44
|
+
Work questions use the same original-project evidence selection and deterministic later-report checking as chat: up to sixteen sources in a 32,000-byte historical packet per lookup. A new call inherits project focus from actual saved user turns, not generated answers; explicit switches and follow-ups retain the same scope rules as chat. Old conversation recall remains available when requested. History is captured at the displayed preparation cutoff, not observed live.
|
|
45
|
+
|
|
46
|
+
The native context envelope remains bounded to 8 KiB. Larger evidence is delivered losslessly in ordered, JSON-quoted parts with a final completion record; the helper's small handoff returns a receipt rather than truncating evidence. Interrupted/failed transfers are not marked complete, and old-turn parts cannot restart speech after Stop. Three distinct archive lookups per turn and duplicate-result/delivery reuse remain. This sends more evidence without another pi call, changing voice engine or raising the concise speaking target. Native quota use is not guaranteed unchanged.
|
|
47
|
+
|
|
48
|
+
Supplied IDs and later-report candidates do not prove that each spoken claim was verified, heard or agreed with. The bounded pi answer-repair pass remains text-only; streamed speech is not post-validated or retractable. Protocol tests and evidence-packet comparisons are not physical-audio or exhaustive answer-quality acceptance. See [MEMORY.md](MEMORY.md) for retrieval limits.
|
|
45
49
|
|
|
46
50
|
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.
|
|
47
51
|
|
|
48
52
|
## Evidence, records and recap
|
|
49
53
|
|
|
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
|
|
54
|
+
- 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 prepare conversations** prepares both that history and a new briefing in one idle pipeline, starting new batches at 64 source changes or waiting entries and resuming incomplete owned batches. It uses the configured pi summary/final models before the conversation, but never starts capture, calls or review. 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.
|
|
51
55
|
- 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.
|
|
52
56
|
- 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.
|
|
53
57
|
- 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.
|
|
@@ -10,11 +10,16 @@ interface Operations {
|
|
|
10
10
|
stamp(before: string): Map<string, string>;
|
|
11
11
|
baseline?(): Map<string, string> | undefined;
|
|
12
12
|
prepare(before: string, signal: AbortSignal): Promise<void>;
|
|
13
|
+
waiting?(): number;
|
|
14
|
+
unfinished?(): boolean;
|
|
15
|
+
briefing?(signal: AbortSignal): Promise<void>;
|
|
16
|
+
problem?(): string;
|
|
17
|
+
completed?(at: string): void;
|
|
13
18
|
}
|
|
14
|
-
/**
|
|
15
|
-
*
|
|
16
|
-
* Smaller tails wait for
|
|
17
|
-
*
|
|
19
|
+
/** One opted-in pipeline: source discovery, local search and a ready briefing.
|
|
20
|
+
* Full batches start at 64 changes or waiting entries; interrupted work resumes.
|
|
21
|
+
* Smaller new tails wait for foreground preparation, with no timed flush.
|
|
22
|
+
* Provider failures require explicit retry; cancellation retains cached work. */
|
|
18
23
|
declare class AutoIndexer {
|
|
19
24
|
private ops;
|
|
20
25
|
state: State;
|
|
@@ -26,12 +31,13 @@ declare class AutoIndexer {
|
|
|
26
31
|
tick(): Promise<void>;
|
|
27
32
|
pause(): void;
|
|
28
33
|
stop(): Promise<void>;
|
|
34
|
+
retry(): void;
|
|
29
35
|
private run;
|
|
30
36
|
}
|
|
31
37
|
export declare function createAutoIndexer(ops: Operations): AutoIndexer;
|
|
32
38
|
export declare function startBackgroundIndexing(): void;
|
|
33
39
|
export declare function stopBackgroundIndexing(): Promise<void>;
|
|
34
|
-
export declare function yieldBackgroundIndexing(): void
|
|
40
|
+
export declare function yieldBackgroundIndexing(): Promise<void>;
|
|
35
41
|
export declare function autoIndexSettings(): AutoIndexSettings;
|
|
36
42
|
export declare function setAutoIndex(value: unknown): AutoIndexSettings;
|
|
37
43
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automatic.d.ts","sourceRoot":"","sources":["../../src/memory/automatic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"automatic.d.ts","sourceRoot":"","sources":["../../src/memory/automatic.ts"],"names":[],"mappings":"AAMA,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;IAC5D,OAAO,CAAC,IAAI,MAAM,CAAC;IACnB,UAAU,CAAC,IAAI,OAAO,CAAC;IACvB,QAAQ,CAAC,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,OAAO,CAAC,IAAI,MAAM,CAAC;IACnB,SAAS,CAAC,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAGD;;;iFAGiF;AACjF,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;IAW3B,KAAK;IAIC,IAAI;IACV,KAAK;YACS,GAAG;CAmDlB;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,UAAU,eAAkC;AAMnF,wBAAgB,uBAAuB,SAStC;AACD,wBAAsB,sBAAsB,kBAG3C;AACD,wBAAsB,uBAAuB,kBAA4B;AACzE,wBAAgB,iBAAiB,IAAI,iBAAiB,CAUrD;AACD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,iBAAiB,CAW9D"}
|
package/dist/memory/automatic.js
CHANGED
|
@@ -10,13 +10,14 @@ const schema_1 = require("../db/schema");
|
|
|
10
10
|
const stamps_1 = require("./stamps");
|
|
11
11
|
const collector_1 = require("../sync/collector");
|
|
12
12
|
const store_1 = require("../sync/store");
|
|
13
|
+
const automatic_1 = require("../sync/automatic");
|
|
13
14
|
const service_1 = require("./service");
|
|
14
15
|
const CHECK_MS = 60_000, RETRY_MS = 5 * 60_000, BATCH = 64;
|
|
15
16
|
const initial = () => ({ phase: 'off', pending_records: 0, last_completed_at: null, error: '' });
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* Smaller tails wait for
|
|
19
|
-
*
|
|
17
|
+
/** One opted-in pipeline: source discovery, local search and a ready briefing.
|
|
18
|
+
* Full batches start at 64 changes or waiting entries; interrupted work resumes.
|
|
19
|
+
* Smaller new tails wait for foreground preparation, with no timed flush.
|
|
20
|
+
* Provider failures require explicit retry; cancellation retains cached work. */
|
|
20
21
|
class AutoIndexer {
|
|
21
22
|
ops;
|
|
22
23
|
state = initial();
|
|
@@ -38,6 +39,12 @@ class AutoIndexer {
|
|
|
38
39
|
this.state.phase = 'paused';
|
|
39
40
|
return Promise.resolve();
|
|
40
41
|
}
|
|
42
|
+
const problem = this.ops.problem?.();
|
|
43
|
+
if (problem) {
|
|
44
|
+
this.state.phase = 'error';
|
|
45
|
+
this.state.error = problem;
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
41
48
|
if (this.ops.now() < this.retryAt)
|
|
42
49
|
return Promise.resolve();
|
|
43
50
|
const life = new AbortController();
|
|
@@ -51,6 +58,8 @@ class AutoIndexer {
|
|
|
51
58
|
this.state.phase = this.life ? 'stopping' : this.ops.enabled() ? 'paused' : 'off';
|
|
52
59
|
}
|
|
53
60
|
async stop() { this.pause(); await this.job; }
|
|
61
|
+
retry() { this.retryAt = 0; this.state.error = ''; if (!this.job)
|
|
62
|
+
this.state.phase = this.ops.enabled() ? 'waiting' : 'off'; }
|
|
54
63
|
async run(signal) {
|
|
55
64
|
try {
|
|
56
65
|
this.state.phase = 'scanning';
|
|
@@ -62,7 +71,7 @@ class AutoIndexer {
|
|
|
62
71
|
throw new Error('Scan incomplete');
|
|
63
72
|
const before = new Date(this.ops.now()).toISOString();
|
|
64
73
|
const baseline = this.ops.baseline ? this.ops.baseline() : this.baseline;
|
|
65
|
-
if (this.ops.baseline && !baseline) {
|
|
74
|
+
if (this.ops.baseline && !baseline && !this.ops.briefing) {
|
|
66
75
|
this.state.phase = 'waiting';
|
|
67
76
|
this.state.pending_records = 0;
|
|
68
77
|
this.state.error = 'Prepare history once with a foreground call or unfiltered history search to establish the background checkpoint for this older index.';
|
|
@@ -77,8 +86,9 @@ class AutoIndexer {
|
|
|
77
86
|
for (const key of baseline.keys())
|
|
78
87
|
if (!current.has(key))
|
|
79
88
|
changed++;
|
|
80
|
-
this.
|
|
81
|
-
|
|
89
|
+
const waiting = this.ops.waiting?.() || 0, unfinished = this.ops.unfinished?.() || false;
|
|
90
|
+
this.state.pending_records = Math.max(changed, waiting);
|
|
91
|
+
if (changed < BATCH && waiting < BATCH && !unfinished) {
|
|
82
92
|
this.state.phase = 'waiting';
|
|
83
93
|
return;
|
|
84
94
|
}
|
|
@@ -86,21 +96,38 @@ class AutoIndexer {
|
|
|
86
96
|
this.state.phase = 'paused';
|
|
87
97
|
return;
|
|
88
98
|
}
|
|
89
|
-
|
|
90
|
-
|
|
99
|
+
if (changed >= BATCH || !baseline) {
|
|
100
|
+
this.state.phase = 'indexing';
|
|
101
|
+
await this.ops.prepare(before, signal);
|
|
102
|
+
this.baseline = current;
|
|
103
|
+
}
|
|
104
|
+
if (signal.aborted || !this.ops.enabled())
|
|
105
|
+
return;
|
|
106
|
+
if (this.ops.briefing && (waiting > 0 || unfinished)) {
|
|
107
|
+
if (!this.ops.idle())
|
|
108
|
+
throw new store_1.HttpError(409, 'Foreground work has priority');
|
|
109
|
+
this.state.phase = 'briefing';
|
|
110
|
+
await this.ops.briefing(signal);
|
|
111
|
+
}
|
|
91
112
|
if (signal.aborted || !this.ops.enabled())
|
|
92
113
|
return;
|
|
93
|
-
|
|
94
|
-
this.
|
|
114
|
+
const completed = new Date(this.ops.now()).toISOString();
|
|
115
|
+
this.ops.completed?.(completed);
|
|
116
|
+
this.state = { phase: 'waiting', pending_records: 0, last_completed_at: completed, error: '' };
|
|
95
117
|
}
|
|
96
118
|
catch (error) {
|
|
97
|
-
|
|
119
|
+
const problem = this.ops.problem?.();
|
|
120
|
+
if (!signal.aborted && problem) {
|
|
121
|
+
this.state.phase = 'error';
|
|
122
|
+
this.state.error = problem;
|
|
123
|
+
}
|
|
124
|
+
else if (!signal.aborted && error instanceof store_1.HttpError && error.status === 409) {
|
|
98
125
|
this.state.phase = 'paused';
|
|
99
126
|
this.retryAt = this.ops.now() + CHECK_MS;
|
|
100
127
|
}
|
|
101
128
|
else if (!signal.aborted) {
|
|
102
129
|
this.state.phase = 'error';
|
|
103
|
-
this.state.error = '
|
|
130
|
+
this.state.error = 'Automatic preparation could not finish. Check session sources and model availability. Completed work is retained; local preparation retries in five minutes.';
|
|
104
131
|
this.retryAt = this.ops.now() + RETRY_MS;
|
|
105
132
|
}
|
|
106
133
|
}
|
|
@@ -111,13 +138,17 @@ class AutoIndexer {
|
|
|
111
138
|
}
|
|
112
139
|
}
|
|
113
140
|
function createAutoIndexer(ops) { return new AutoIndexer(ops); }
|
|
114
|
-
|
|
141
|
+
// Old local-index-only consent must not silently become paid model consent on
|
|
142
|
+
// another installation. The same single switch records the new combined scope.
|
|
143
|
+
const enabled = () => (0, schema_1.getDb)().prepare("SELECT value FROM sync_settings WHERE key='auto_prepare_conversations'").get()?.value === 'true';
|
|
115
144
|
let worker, timer;
|
|
116
145
|
function startBackgroundIndexing() {
|
|
117
146
|
if (timer)
|
|
118
147
|
return;
|
|
119
148
|
worker = createAutoIndexer({ enabled, idle: () => !store_1.busySyncs.size && !store_1.activeVoiceSyncs.size && !(0, service_1.historyProgress)().active && !(0, service_1.historyProgress)().queued,
|
|
120
|
-
now: Date.now, scan: collector_1.scanSessions, stamp: before => (0, stamps_1.sourceStamps)((0, schema_1.getDb)(), before), baseline: () => (0, stamps_1.loadSourceCheckpoint)((0, schema_1.getDataDir)()), prepare: (before, signal) => (0, service_1.prepareHistory)(before, signal, true)
|
|
149
|
+
now: Date.now, scan: collector_1.scanSessions, stamp: before => (0, stamps_1.sourceStamps)((0, schema_1.getDb)(), before), baseline: () => (0, stamps_1.loadSourceCheckpoint)((0, schema_1.getDataDir)()), prepare: (before, signal) => (0, service_1.prepareHistory)(before, signal, true),
|
|
150
|
+
waiting: store_1.availableCount, unfinished: () => (0, automatic_1.pendingAutomaticBriefing)() !== undefined, briefing: automatic_1.prepareAutomaticBriefing, problem: automatic_1.automaticBriefingError,
|
|
151
|
+
completed: at => { (0, schema_1.getDb)().prepare("INSERT INTO sync_settings(key,value) VALUES ('auto_last_completed',?) ON CONFLICT(key) DO UPDATE SET value=excluded.value").run(at); } });
|
|
121
152
|
timer = setInterval(() => {
|
|
122
153
|
void worker?.tick().catch(() => {
|
|
123
154
|
if (worker) {
|
|
@@ -135,20 +166,33 @@ async function stopBackgroundIndexing() {
|
|
|
135
166
|
worker = undefined;
|
|
136
167
|
await prior?.stop();
|
|
137
168
|
}
|
|
138
|
-
function yieldBackgroundIndexing() { worker?.
|
|
169
|
+
async function yieldBackgroundIndexing() { await worker?.stop(); }
|
|
139
170
|
function autoIndexSettings() {
|
|
140
|
-
const on = enabled();
|
|
171
|
+
const on = enabled(), syncId = [...store_1.backgroundSyncs][0] ?? (0, automatic_1.pendingAutomaticBriefing)() ?? null;
|
|
172
|
+
const progress = syncId === null ? null : (0, schema_1.getDb)().prepare('SELECT stage,processed_entries AS completed,total_entries AS total,invocations,max_invocations FROM sync_runs WHERE sync_id=? ORDER BY id DESC LIMIT 1').get(syncId);
|
|
173
|
+
const prepared = (0, store_1.automaticSyncId)(true), problem = on ? (0, automatic_1.automaticBriefingError)() : '';
|
|
174
|
+
const last = (0, schema_1.getDb)().prepare("SELECT value FROM sync_settings WHERE key='auto_last_completed'").get();
|
|
141
175
|
return { enabled: on, check_seconds: CHECK_MS / 1000, batch_records: BATCH,
|
|
142
|
-
|
|
143
|
-
|
|
176
|
+
pending_entries: (0, store_1.availableCount)(), sync_id: syncId, ready_sync_id: prepared !== undefined && (0, service_1.historyReadiness)(true).ready ? prepared : null, progress: progress || null,
|
|
177
|
+
...(worker?.state || initial()), last_completed_at: worker?.state.last_completed_at || last?.value || null, ...(!on && worker?.state.phase !== 'stopping' ? { phase: 'off' }
|
|
178
|
+
: on && (!worker || worker.state.phase === 'off') ? { phase: 'waiting' } : {}),
|
|
179
|
+
...(problem ? { phase: 'error', error: problem } : {}) };
|
|
144
180
|
}
|
|
145
181
|
function setAutoIndex(value) {
|
|
146
182
|
if (typeof value !== 'boolean')
|
|
147
183
|
throw new store_1.HttpError(400, 'enabled must be a boolean');
|
|
148
|
-
(0, schema_1.getDb)().
|
|
184
|
+
(0, schema_1.getDb)().transaction(() => {
|
|
185
|
+
const save = (0, schema_1.getDb)().prepare('INSERT INTO sync_settings(key,value) VALUES (?,?) ON CONFLICT(key) DO UPDATE SET value=excluded.value');
|
|
186
|
+
for (const key of ['auto_index', 'auto_prepare_conversations'])
|
|
187
|
+
save.run(key, String(value));
|
|
188
|
+
})();
|
|
149
189
|
startBackgroundIndexing();
|
|
150
190
|
if (!value)
|
|
151
191
|
worker.pause();
|
|
192
|
+
else {
|
|
193
|
+
(0, automatic_1.retryAutomaticBriefing)();
|
|
194
|
+
worker.retry();
|
|
195
|
+
}
|
|
152
196
|
// The periodic server timer owns work; neither GET nor rendering starts a job.
|
|
153
197
|
return autoIndexSettings();
|
|
154
198
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automatic.js","sourceRoot":"","sources":["../../src/memory/automatic.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"automatic.js","sourceRoot":"","sources":["../../src/memory/automatic.ts"],"names":[],"mappings":";;AAyGA,8CAAmF;AAMnF,0DASC;AACD,wDAGC;AACD,0DAAyE;AACzE,8CAUC;AACD,oCAWC;AApJD,yCAAiD;AACjD,qCAA8D;AAC9D,iDAAiD;AACjD,yCAAyH;AACzH,iDAAuI;AACvI,uCAA8E;AAG9E,MAAM,QAAQ,GAAG,MAAM,EAAE,QAAQ,GAAG,CAAC,GAAG,MAAM,EAAE,KAAK,GAAG,EAAE,CAAC;AAc3D,MAAM,OAAO,GAAG,GAAU,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,eAAe,EAAE,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAAC;AAExG;;;iFAGiF;AACjF,MAAM,WAAW;IAMK;IALpB,KAAK,GAAG,OAAO,EAAE,CAAC;IACV,QAAQ,CAAuB;IAC/B,OAAO,GAAG,CAAC,CAAC;IACZ,IAAI,CAAmB;IACvB,GAAG,CAAiB;IAC5B,YAAoB,GAAe;QAAf,QAAG,GAAH,GAAG,CAAY;IAAG,CAAC;IACvC,K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I,KAAK,MAAM,GAAG,IAAI,CAAC,YAAY,EAAE,4BAA4B,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/F,CAAC,CAAC,EAAE,CAAC;IACL,uBAAuB,EAAE,CAAC;IAC1B,IAAI,CAAC,KAAK;QAAE,MAAO,CAAC,KAAK,EAAE,CAAC;SACvB,CAAC;QAAC,IAAA,kCAAsB,GAAE,CAAC;QAAC,MAAO,CAAC,KAAK,EAAE,CAAC;IAAC,CAAC;IACnD,+EAA+E;IAC/E,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC"}
|
package/dist/memory/context.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HistoryQuery, HistoryResults } from './types';
|
|
2
|
+
export declare const DISCUSSION_HISTORY_BYTES = 32000;
|
|
2
3
|
export declare function historyContext(question: string, before: string, signal?: AbortSignal, maxBytes?: number, preparedOnly?: boolean, selection?: Pick<HistoryQuery, 'session_ids' | 'kind' | 'recent' | 'topics'>): Promise<{
|
|
3
4
|
text: string;
|
|
4
5
|
refs: string[];
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAK5D,eAAO,MAAM,wBAAwB,QAAQ,CAAC;AAU9C,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
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DISCUSSION_HISTORY_BYTES = void 0;
|
|
3
4
|
exports.historyContext = historyContext;
|
|
4
5
|
exports.historyPacket = historyPacket;
|
|
5
6
|
const service_1 = require("./service");
|
|
6
7
|
const normalize_1 = require("../sync/normalize");
|
|
7
8
|
const reconcile_1 = require("./reconcile");
|
|
9
|
+
// Shared evidence selection budget. Voice transports this same bounded packet
|
|
10
|
+
// in acknowledged context parts; speech length is independent of evidence size.
|
|
11
|
+
exports.DISCUSSION_HISTORY_BYTES = 32000;
|
|
8
12
|
// Existing E/C labels belong to a particular snapshot. Do not let quoted source
|
|
9
13
|
// text masquerade as references in the current answer's namespace.
|
|
10
14
|
const quote = (text, max) => {
|