switchroom 0.19.26 → 0.19.27

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.
Files changed (77) hide show
  1. package/bin/git-agent-attribution-hook.sh +144 -0
  2. package/dist/agent-scheduler/index.js +55 -0
  3. package/dist/auth-broker/index.js +116 -6
  4. package/dist/cli/notion-write-pretool.mjs +55 -0
  5. package/dist/cli/switchroom.js +2055 -1193
  6. package/dist/host-control/main.js +117 -7
  7. package/dist/vault/approvals/kernel-server.js +114 -6
  8. package/dist/vault/broker/server.js +114 -6
  9. package/package.json +6 -2
  10. package/profiles/_base/cron-session.sh.hbs +8 -0
  11. package/profiles/_base/start.sh.hbs +105 -0
  12. package/telegram-plugin/card-layout.ts +328 -0
  13. package/telegram-plugin/dist/bridge/bridge.js +93 -1
  14. package/telegram-plugin/dist/gateway/gateway.js +2009 -1166
  15. package/telegram-plugin/dist/server.js +96 -1
  16. package/telegram-plugin/edit-flood-fuse.ts +637 -56
  17. package/telegram-plugin/flood-429-ledger.ts +526 -0
  18. package/telegram-plugin/flood-circuit-breaker.ts +18 -0
  19. package/telegram-plugin/gateway/flood-reply-queue.ts +168 -0
  20. package/telegram-plugin/gateway/gateway.ts +58 -68
  21. package/telegram-plugin/gateway/narrative-lane.ts +14 -0
  22. package/telegram-plugin/gateway/outbound-send-path.ts +36 -0
  23. package/telegram-plugin/gateway/outbox-sweep.ts +183 -6
  24. package/telegram-plugin/gateway/pinned-message-handler.ts +12 -16
  25. package/telegram-plugin/gateway/status-pin-retarget.ts +72 -36
  26. package/telegram-plugin/gateway/status-pin-store.ts +58 -9
  27. package/telegram-plugin/gateway/worker-pin-reaper.ts +56 -7
  28. package/telegram-plugin/llm-error-present.ts +61 -2
  29. package/telegram-plugin/model-unavailable.ts +8 -0
  30. package/telegram-plugin/operator-events.ts +72 -5
  31. package/telegram-plugin/outbound-class.ts +81 -0
  32. package/telegram-plugin/provider-credit.ts +237 -0
  33. package/telegram-plugin/scripts/bun-test-ci.sh +36 -6
  34. package/telegram-plugin/send-gate.ts +24 -2
  35. package/telegram-plugin/status-no-truncate.ts +10 -48
  36. package/telegram-plugin/status-pin-driver.ts +33 -45
  37. package/telegram-plugin/status-pin.ts +18 -1
  38. package/telegram-plugin/tests/card-golden.test.ts +69 -0
  39. package/telegram-plugin/tests/card-lifecycle-render.test.ts +362 -0
  40. package/telegram-plugin/tests/card-type-distinguishability.test.ts +187 -164
  41. package/telegram-plugin/tests/card-variants.golden.txt +211 -0
  42. package/telegram-plugin/tests/card-variants.ts +366 -0
  43. package/telegram-plugin/tests/edit-flood-fuse-ban-awareness.test.ts +316 -0
  44. package/telegram-plugin/tests/edit-flood-fuse-default-deny.test.ts +319 -0
  45. package/telegram-plugin/tests/edit-flood-fuse.test.ts +11 -2
  46. package/telegram-plugin/tests/feed-edit-rate-ceiling.test.ts +462 -0
  47. package/telegram-plugin/tests/fixtures/real-429-stream.ts +220 -0
  48. package/telegram-plugin/tests/flood-429-ledger.test.ts +278 -0
  49. package/telegram-plugin/tests/flood-429-recorder-wiring.test.ts +128 -0
  50. package/telegram-plugin/tests/flood-reply-queue.test.ts +418 -0
  51. package/telegram-plugin/tests/outbox-sweep-flood-breaker.test.ts +221 -0
  52. package/telegram-plugin/tests/pinned-card-collapse.test.ts +19 -24
  53. package/telegram-plugin/tests/pinned-message-handler.test.ts +15 -15
  54. package/telegram-plugin/tests/provider-credit-402.test.ts +243 -0
  55. package/telegram-plugin/tests/status-pin-api.test.ts +11 -11
  56. package/telegram-plugin/tests/status-pin-boot-recovery.test.ts +36 -37
  57. package/telegram-plugin/tests/status-pin-lifecycle.test.ts +602 -0
  58. package/telegram-plugin/tests/status-pin-retarget.test.ts +90 -62
  59. package/telegram-plugin/tests/status-pin-service-message-suppression.test.ts +7 -3
  60. package/telegram-plugin/tests/status-pin-store.test.ts +109 -60
  61. package/telegram-plugin/tests/status-pin.test.ts +56 -5
  62. package/telegram-plugin/tests/test-runner-coverage.test.ts +133 -0
  63. package/telegram-plugin/tests/worker-activity-feed.test.ts +12 -10
  64. package/telegram-plugin/tests/worker-feed-coalesce.test.ts +23 -29
  65. package/telegram-plugin/tests/worker-feed-pin-persistence.test.ts +56 -59
  66. package/telegram-plugin/tests/worker-feed-terminal-edit-class.test.ts +335 -0
  67. package/telegram-plugin/tests/worker-visibility-prose-silent-harness.test.ts +1 -1
  68. package/telegram-plugin/tool-activity-summary.ts +239 -365
  69. package/telegram-plugin/uat/assertions.ts +22 -11
  70. package/telegram-plugin/uat/feed-matcher.test.ts +24 -17
  71. package/telegram-plugin/worker-activity-feed.ts +105 -47
  72. package/vendor/hindsight-memory/CLAUDE.md +45 -0
  73. package/vendor/hindsight-memory/scripts/lib/config.py +33 -0
  74. package/vendor/hindsight-memory/scripts/recall.py +176 -7
  75. package/vendor/hindsight-memory/scripts/tests/test_config_recall_passthrough_env.py +170 -0
  76. package/vendor/hindsight-memory/scripts/tests/test_recall_min_score.py +464 -0
  77. package/vendor/hindsight-memory/settings.json +1 -1
@@ -19228,10 +19228,37 @@ var AgentMemorySchema = exports_external.object({
19228
19228
  request_timeout_seconds: exports_external.number().int().min(1).optional().describe("Per-bank HTTP read timeout, in seconds, for one recall " + "request. Even parallelised, each bank carries its own deadline " + "so ONE hung bank returns empty instead of consuming the shared " + "deadline and starving its siblings. The plugin default is 12 " + "(raised from a hardcoded 8 in #3757, which fired on 96.8% of " + "one agent's own-bank recalls). Switchroom defaults it to the " + "effective `parallel_deadline_seconds` instead — 10 at the " + "shipped ceiling — because the shared fan-out deadline is " + "already the tighter outer guard, so a per-bank value above it " + "can never bind. An explicitly configured value above the " + "effective deadline is clamped down to it, and the clamp is " + "reported."),
19229
19229
  own_bank_min_slots: exports_external.number().int().min(0).optional().describe("Slots inside `max_memories` reserved as a FLOOR for the agent's " + "own bank when recall fans out to more than one bank. The merged " + "set is sorted globally by relevance and head-sliced, which is " + "winner-take-all across banks: when both banks return more " + "candidates than the cap, one bank's score distribution can fill " + "every slot and the agent gets a dossier about its operator with " + "none of its own session memory. A floor, not a quota: at most " + "this many slots, only if the own bank returned that many, and " + "only up to HALF the cap shared with `additional_bank_min_slots` " + "— the rest is always won on pure relevance, so composition still " + "moves with the scores. Fixes score-based crowd-out only; a " + "timed-out bank returns no candidates and reservation is a no-op " + "there. 0 disables (default). Switchroom-managed agents use 2 " + "against the fleet-deployed cap of 6."),
19230
19230
  additional_bank_min_slots: exports_external.number().int().min(0).optional().describe("Slots inside `max_memories` reserved as a FLOOR for the " + "additional (profile / shared / sender) banks. Symmetric with " + "`own_bank_min_slots` — same floor-not-quota semantics, and the " + "two share the same half-of-cap reservation budget. When they sum " + "above that budget the own-bank floor is honoured first. 0 " + "disables (default). Switchroom-managed agents use 1 against the " + "fleet-deployed cap of 6. Observe `injected_own_bank_count` / " + "`injected_additional_bank_count` via " + "`switchroom memory recall-log`."),
19231
+ min_score: exports_external.number().min(0).optional().describe("Absolute floor on a memory's engine relevance score " + "(`scores.final`) for it to be injected. 0 disables (default, " + "and the shipped fleet behaviour). Exists for one measured " + "failure: when the agent's own bank times out, recall still " + "injects side-bank residue under the banner 'Relevant memories " + "from past conversations' — 98.4% of degraded turns have a best " + "injected score below 0.01, against 28.4% of healthy ones. Six " + "noise memories are worse than none, because the agent cannot " + "tell them apart. Below-floor results are dropped BEFORE " + "rendering, and when the floor empties the set the turn says so " + "rather than going silent. Do NOT read this as a general " + "precision control: `scores.final` is not calibrated across " + "queries, and #3761 measured that an unconditional 0.01 floor " + "empties ~28% of HEALTHY recalls — which is why " + "`min_score_scope` defaults to degraded turns only. Observe " + "`dropped_below_min_score` via `switchroom memory recall-log`."),
19232
+ min_score_scope: exports_external.enum(["degraded", "all"]).optional().describe('Which turns `min_score` binds on. "degraded" (default) — only ' + "turns where the agent's OWN bank timed out or was unreachable, " + "the population where a below-floor score actually predicts " + "noise and where the agent already receives the degraded-recall " + 'disclosure. "all" — every turn; only for an operator who has ' + "measured their own bank's score distribution, since it " + "re-creates the empty-recall failure of #3541 at any floor " + "calibrated on degraded data. No effect while `min_score` is 0."),
19231
19233
  types: exports_external.array(exports_external.string()).optional().describe("Hindsight fact types to recall. Switchroom default is " + '["world", "experience", "observation"] — the synthesized ' + "`observation` tier is on by default. Set to " + '["world", "experience"] to opt out of observation-backed ' + "recall for this agent (or fleet-wide under defaults)."),
19232
19234
  additional_banks: exports_external.array(exports_external.string()).optional().describe("Extra Hindsight banks to recall from on every turn, merged into " + "the agent's own bank results — e.g. a shared operator/household " + "profile bank authored via `switchroom memory profile`. Each is " + "recalled with the `request_timeout_seconds` per-bank timeout " + "(defaults to the effective `parallel_deadline_seconds`, 10s at " + "the shipped ceiling) and is non-fatal on failure. Stays " + "within the single tenant: all banks are the operator's data, in " + "the operator's Hindsight instance (see the `single-tenant` " + "invariant). Defaults to [] (no extra banks)."),
19233
19235
  sender_banks: exports_external.record(exports_external.string(), exports_external.string()).optional().describe("Per-speaker recall routing: a map of Telegram sender → extra " + "recall bank. When a message arrives, the agent also recalls the " + "speaker's bank (matched by Telegram username — a leading @ is " + "optional — or numeric user_id), merged " + "into its own results — so each trusted user gets their own " + "profile context. Additive recall scoping within the single " + "tenant: never an access boundary (who may drive an agent stays " + "the per-agent user assignment in `access.allowFrom`). Author the " + "banks via `switchroom memory profile`."),
19234
19236
  skip_trivial: exports_external.boolean().optional().describe("Skip recall on plausibly-stateless trivial turns (time/date/" + "greeting). Switchroom default true — saves the recall arm + " + "injected tokens on turns that never need memory, guarded so it " + "never skips a turn that references user/project/session state. " + "Set false to always run recall."),
19237
+ budget: exports_external.enum(["low", "mid", "high"]).optional().describe('How hard Hindsight searches. "low" (switchroom default) = ' + 'vector retrieval only, ~1-2s. "mid" adds the LLM rerank pass ' + "and measured ~5s of hook latency on real fleet turns — the " + "second-largest contributor to perceived dead air after model " + 'TTFT. "high" is thorough and slower still. Raise it for an ' + "agent whose recall quality matters more than its reply latency " + "(a research or audit role); leave it at low for chat."),
19238
+ max_tokens: exports_external.number().int().min(1).optional().describe("Token budget for the injected memory block. Default 1024. This " + "is the TOKEN bound; `max_memories` is the separate COUNT bound " + "and the tighter of the two wins. Raise it only alongside " + "`max_memories` — on its own it buys nothing once the count cap " + "binds."),
19239
+ prefer_observations: exports_external.boolean().optional().describe("Bias recall toward the synthesized `observation` tier, " + "backfilling the slots freed by superseded raw facts for denser " + "coverage inside the same budget. Default true. Set false to " + "rank raw `world`/`experience` facts on equal footing — useful " + "when auditing what the consolidation engine actually stored, or " + "if a bank's observations are stale."),
19240
+ context_turns: exports_external.number().int().min(1).optional().describe("How many recent human turns are composed into the recall query. " + 'Default 2, so a bare follow-up ("and the port?") embeds with ' + "its antecedent instead of recalling on the pronoun alone. 1 = " + "the latest turn only. Raising it costs BM25 terms, which is the " + "real recall cost driver — `query_max_tokens` still bounds the " + "result, so a large value mostly shifts which terms survive."),
19241
+ roles: exports_external.array(exports_external.string().min(1)).min(1).optional().describe("Transcript roles the multi-turn composition may draw from. " + 'Default ["user", "assistant"]. Set ["user"] to compose ' + "the query from the human's words only — worth trying when an " + "agent's own verbose replies are dominating the query terms. No " + "effect while `context_turns` is 1."),
19242
+ prompt_preamble: exports_external.string().min(1).optional().describe("The banner rendered above injected memories. The agent reads " + "this line as the instruction for how to treat the block, so it " + "is a behaviour knob, not cosmetics. Default tells the model to " + "prioritise recent memories on conflict and ignore irrelevant " + "ones. Override to tighten that framing for a specialised agent."),
19243
+ tags: exports_external.array(exports_external.string().min(1)).optional().describe("Restrict recall to memories carrying these tags. Default [] = " + "no filter (match everything). This is a HARD filter applied " + "server-side — a memory without the tags cannot surface at any " + "score — so it is for a genuinely scoped agent, not for " + "ranking. Use `tag_weights` when you want a preference rather " + "than an exclusion."),
19244
+ tags_match: exports_external.enum(["any", "all", "any_strict", "all_strict"]).optional().describe('How `tags` combine. "any" (default) = at least one; ' + '"all" = every tag. The `_strict` forms additionally require ' + "the memory to actually carry the tags rather than merely rank " + "for them. No effect while `tags` and `tag_groups` are empty."),
19245
+ tag_groups: exports_external.union([
19246
+ exports_external.array(exports_external.array(exports_external.string().min(1))),
19247
+ exports_external.record(exports_external.string(), exports_external.array(exports_external.string().min(1)))
19248
+ ]).optional().describe("Tag filtering with grouping — either an OR-of-ANDs list " + '([["a","b"],["c"]] = (a AND b) OR c) or a named ' + "{group: [tags]} map. Default unset (no grouping). Use when a " + "flat `tags` + `tags_match` cannot express the scope you need."),
19249
+ tag_weights: exports_external.record(exports_external.string(), exports_external.number().min(0)).optional().describe("Per-tag multipliers applied to `scores.final` just before the " + "final sort — a DEMOTION/PROMOTION, never a drop, so a " + "down-weighted memory still surfaces when it is the only " + "relevant hit. MERGED over switchroom's seed " + '({"sidechain": 0.8}, which ranks delegated sub-agent ' + "process-memories just under first-party ones), so setting one " + "unrelated weight does not silently undo it; pass " + "`sidechain: 1.0` to neutralise the seed. Reach for this when " + "recall_log shows one class of memory crowding the block."),
19250
+ additional_bank_filters: exports_external.record(exports_external.string(), exports_external.object({
19251
+ tags: exports_external.array(exports_external.string().min(1)).optional(),
19252
+ tags_match: exports_external.enum(["any", "all", "any_strict", "all_strict"]).optional(),
19253
+ tag_groups: exports_external.union([
19254
+ exports_external.array(exports_external.array(exports_external.string().min(1))),
19255
+ exports_external.record(exports_external.string(), exports_external.array(exports_external.string().min(1)))
19256
+ ]).optional()
19257
+ }).strict()).optional().describe("Per-bank overrides of the tag filters above, keyed by bank id " + "(applies to `additional_banks` AND to sender banks). Default " + "{} = every extra bank inherits the global filters. Use it to " + "scope a shared bank — e.g. recall only `profile`-tagged " + "memories from the operator's profile bank while leaving the " + "agent's own bank unfiltered."),
19258
+ transcript_fallback: exports_external.boolean().optional().describe("When every bank returns zero results AND no bank hit its " + "deadline, grep the current session's transcript tail for turns " + "matching the query and inject them as a clearly-labelled " + "lower-confidence block. Default true — it covers the window " + "between an abrupt kill and the next boot reconciliation, where " + "the fact layer was never told about the lost turns. Set false " + "if you never want un-consolidated transcript text in context."),
19259
+ transcript_tail_bytes: exports_external.number().int().min(0).optional().describe("Bytes of the session transcript read from the tail for the " + "multi-turn query composition. Default 262144 (256 KiB), which " + "keeps the per-turn read O(1) on a session log that can grow to " + "many MB. 0 = read the whole file (the pre-bound behaviour, and " + "the rollback lever if a composition ever needs older turns)."),
19260
+ max_query_chars: exports_external.number().int().min(1).optional().describe("Character bound on the composed recall query, applied before " + "`query_max_tokens` shapes it. Default 800. Truncation preserves " + "the latest turn and drops the oldest context first. Lower it " + "for an agent whose turns are long pasted payloads."),
19261
+ parallel: exports_external.boolean().optional().describe("Run the directives fetch and every bank recall concurrently " + "under one shared deadline, so total latency is the SLOWEST slot " + "rather than their SUM. Default true. false restores the serial " + "path — the rollback lever if the parallel path ever misbehaves; " + "expect multi-bank recall latency to add up."),
19235
19262
  topic_filter_mode: exports_external.enum(["soft-preamble", "hard-filter"]).optional().describe("Supergroup-mode cross-topic memory behaviour. Default " + "(unset) → soft-preamble: recall returns memories from all " + "topics, and a 'Current topic: …' preamble tells the model " + "to self-scope. hard-filter: drop any recalled memory whose " + "metadata.thread_id differs from the active inbound's topic. " + "Flip to hard-filter when the recall_log shows binding " + "failures (model surfacing the right memory but applying " + "it to the wrong topic).")
19236
19263
  }).optional().describe("Auto-recall tuning knobs"),
19237
19264
  retain: exports_external.object({
@@ -19444,6 +19471,7 @@ var HindsightPerOpLlmSchema = exports_external.object({
19444
19471
  context_window: exports_external.number().int().positive().optional().describe("Context window (tokens) of the backend serving THIS op. NOT an " + "upstream env var — switchroom derives the op's token budget " + "(consolidation batch size / max-completion caps / reflect " + "max-context cap) from it so a single call can never overflow the " + "window. Absent → inherit " + "`hindsight.llm.context_window`, else a per-provider default " + "(conservative for non-`claude-code` providers, which usually mean " + "a local llama.cpp/Ollama slot; a self-hosted `base_url` — loopback, " + "RFC1918, `.local`/`.internal` — forces the conservative default too, " + "regardless of the provider NAME, since the endpoint is where the " + "traffic actually terminates). All three lanes (`retain`, " + "`reflect`, `consolidation`) are budgeted independently.")
19445
19472
  }).describe("Per-operation LLM override. Every field optional; an unset field (or " + "an omitted op block) inherits the global `hindsight.llm.*`, which is " + "already the engine's fallback — switchroom emits only the vars set.");
19446
19473
  var HindsightConfigSchema = exports_external.object({
19474
+ gpu: exports_external.boolean().optional().describe("Force GPU passthrough for the hindsight container on (`true`) or off " + "(`false`), overriding host autodetection in BOTH directions. Absent " + "(the default) → autodetect from the persisted host-capabilities " + "verdict (`~/.switchroom/host-capabilities.json`), which enables " + "`--gpus all` only when that file proves BOTH a GPU and the nvidia " + "container toolkit. Set `true` when that verdict is wrong or unreadable " + "and you know the host has a working toolkit — switchroom cannot verify " + "it for you, and `docker run --gpus all` hard-fails container create on " + "a host without one. Set `false` to pin the container to CPU on a GPU " + "host. This is also the declarative opt-out for the recreate-time GPU " + "drop guard (`switchroom memory setup --recreate` refuses to silently " + "turn a GPU container into a CPU one). `--gpu`/`--no-gpu` on `memory " + "setup` override this for a single run."),
19447
19475
  llm: exports_external.object({
19448
19476
  provider: exports_external.string().min(1).optional().describe("Hindsight LLM provider (upstream `HINDSIGHT_API_LLM_PROVIDER`). " + "Defaults to `claude-code` (subscription-honest, broker-fed OAuth). " + "Any litellm-routable provider the upstream image supports is valid. " + "Serves as the GLOBAL default for every op absent a per-op override."),
19449
19477
  model: exports_external.string().min(1).optional().describe("Hindsight LLM model (upstream `HINDSIGHT_API_LLM_MODEL`). Defaults " + "to HINDSIGHT_DEFAULT_MODEL. Any model your LiteLLM proxy can route " + "is valid, e.g. `openrouter/z-ai/glm-5.2` when routing through the " + "fleet proxy. With provider=claude-code this value is ALSO exported " + "as `ANTHROPIC_MODEL` to the claude subprocess. Serves as the GLOBAL " + "default for every op absent a per-op override."),
@@ -19595,6 +19623,33 @@ var profileFields = {
19595
19623
  request_timeout_seconds: exports_external.number().int().min(1).optional(),
19596
19624
  own_bank_min_slots: exports_external.number().int().min(0).optional(),
19597
19625
  additional_bank_min_slots: exports_external.number().int().min(0).optional(),
19626
+ min_score: exports_external.number().min(0).optional(),
19627
+ min_score_scope: exports_external.enum(["degraded", "all"]).optional(),
19628
+ budget: exports_external.enum(["low", "mid", "high"]).optional(),
19629
+ max_tokens: exports_external.number().int().min(1).optional(),
19630
+ prefer_observations: exports_external.boolean().optional(),
19631
+ context_turns: exports_external.number().int().min(1).optional(),
19632
+ roles: exports_external.array(exports_external.string().min(1)).min(1).optional(),
19633
+ prompt_preamble: exports_external.string().min(1).optional(),
19634
+ tags: exports_external.array(exports_external.string().min(1)).optional(),
19635
+ tags_match: exports_external.enum(["any", "all", "any_strict", "all_strict"]).optional(),
19636
+ tag_groups: exports_external.union([
19637
+ exports_external.array(exports_external.array(exports_external.string().min(1))),
19638
+ exports_external.record(exports_external.string(), exports_external.array(exports_external.string().min(1)))
19639
+ ]).optional(),
19640
+ tag_weights: exports_external.record(exports_external.string(), exports_external.number().min(0)).optional(),
19641
+ additional_bank_filters: exports_external.record(exports_external.string(), exports_external.object({
19642
+ tags: exports_external.array(exports_external.string().min(1)).optional(),
19643
+ tags_match: exports_external.enum(["any", "all", "any_strict", "all_strict"]).optional(),
19644
+ tag_groups: exports_external.union([
19645
+ exports_external.array(exports_external.array(exports_external.string().min(1))),
19646
+ exports_external.record(exports_external.string(), exports_external.array(exports_external.string().min(1)))
19647
+ ]).optional()
19648
+ }).strict()).optional(),
19649
+ transcript_fallback: exports_external.boolean().optional(),
19650
+ transcript_tail_bytes: exports_external.number().int().min(0).optional(),
19651
+ max_query_chars: exports_external.number().int().min(1).optional(),
19652
+ parallel: exports_external.boolean().optional(),
19598
19653
  additional_banks: exports_external.array(exports_external.string()).optional(),
19599
19654
  sender_banks: exports_external.record(exports_external.string(), exports_external.string()).optional()
19600
19655
  }).optional()
@@ -21137,7 +21192,7 @@ function allocateAgentUid(name) {
21137
21192
  }
21138
21193
 
21139
21194
  // src/build-info.ts
21140
- var VERSION = "0.19.26";
21195
+ var VERSION = "0.19.27";
21141
21196
 
21142
21197
  // src/setup/hindsight-recall-tunables.ts
21143
21198
  var RECALL_DEADLINE_HEADROOM_SECONDS = 2;
@@ -21233,6 +21288,9 @@ function assertPositive(value, label) {
21233
21288
  }
21234
21289
  }
21235
21290
 
21291
+ // src/setup/host-capabilities.ts
21292
+ var _warnedReads = new Set;
21293
+
21236
21294
  // src/setup/hindsight-pg-defaults.ts
21237
21295
  var HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION = 8 * 1024;
21238
21296
  var HINDSIGHT_PG_APP_ANON_MIB = 2560;
@@ -21395,7 +21453,42 @@ var HINDSIGHT_HEALTHCHECK_CMD = `python3 -c '${HINDSIGHT_HEALTHCHECK_PY}'`;
21395
21453
  var DOCKER_PROBE_TIMEOUT_MS = 60 * 1000;
21396
21454
 
21397
21455
  // src/memory/hindsight.ts
21398
- var DEFAULT_RETAIN_MISSION = "Extract durable facts that will still be true and useful weeks from now: " + "user preferences and standing rules, ongoing projects and recurring " + "commitments, technical and architectural decisions with their rationale, " + "and people/tool relationships. A preference revealed by a request is " + "durable — record the preference (what the user likes, wants, or always " + `does), not the request itself.
21456
+ var DEFAULT_RETAIN_MISSION = `Extract durable facts that will still be true and useful weeks from now: user preferences and standing rules, ongoing projects and recurring commitments, technical and architectural decisions with their rationale, and people/tool relationships. A preference revealed by a request is durable — record the preference (what the user likes, wants, or always does), not the request itself.
21457
+ ` + `
21458
+ ` + `A TOOL RESULT IS NOT A FACT. Before extracting, ask: is the subject of this
21459
+ ` + `candidate a file path, a command/process/agent/session id, a temp directory, or
21460
+ ` + `the location where some output was written? If yes, drop it — it is transcript
21461
+ ` + `exhaust, not memory.
21462
+ ` + `
21463
+ ` + `NEVER extract:
21464
+ ` + `- Tool results verbatim or paraphrased. Concretely, never produce a fact whose
21465
+ ` + ` text resembles any of these: "File created successfully at /path/to/file",
21466
+ ` + ` "A background command with ID bctz4yskm is running, and its output will be
21467
+ ` + ` written to /tmp/...", "Async agent a745598ba84e71df1 was launched successfully
21468
+ ` + ` and is running in the background", "User executed a Bash command to sleep for
21469
+ ` + ` 200 seconds", "The assistant used grep to locate 'truncateSync' in src/foo.ts".
21470
+ ` + `- Anything mentioning a path under /tmp, a scratchpad directory, or a .tmp file.
21471
+ ` + `- Agent tool-use traces or narration of what the assistant did (e.g. "the
21472
+ ` + ` assistant used X to query Y", "ran a search", "sent the message").
21473
+ ` + `- In-flight workflow/process narration (a sub-task started, paused, or is still
21474
+ ` + ` running) — retain the outcome only once the task completes or a decision is made.
21475
+ ` + `- Operation, request, batch, agent, command or session IDs, UUIDs, hashes, or error codes.
21476
+ ` + `- Slash commands the user typed and their effects (e.g. "User issued /clear to
21477
+ ` + ` reset assistant state").
21478
+ ` + `- Hindsight's own errors, retries, backlogs, or internal state — the memory
21479
+ ` + ` system's self-reports are not memories.
21480
+ ` + `- Restatements of the user's current request or the task in progress.
21481
+ ` + `- Transient state (unread counts, build status, what is running right now) unless
21482
+ ` + ` the fact is explicitly dated, in which case record it as a dated observation.
21483
+ ` + `- Greetings, acknowledgements, and routine operational chatter.
21484
+ ` + `
21485
+ ` + `If a candidate fact matches an exclusion, drop it rather than rewording it. If
21486
+ ` + "nothing durable remains, return an empty facts list.";
21487
+ var SUPERSEDED_RETAIN_MISSIONS = [
21488
+ "Extract technical decisions, architectural choices, user preferences, project context, and people/tool relationships. Ignore routine greetings and transient operational details.",
21489
+ "Extract user preferences, ongoing projects, recurring commitments, " + "important context, and durable facts that should help across future " + "conversations. Skip one-off chatter and temporary task noise.",
21490
+ "Extract user preferences, ongoing projects, recurring commitments, " + "important context, and durable facts that should help across future " + "conversations. Skip one-off chatter and temporary task noise, " + "including in-flight workflow/process narration (a sub-task started, " + "paused, or is still running) — only retain the outcome once a task " + "actually completes or a decision is made.",
21491
+ "Extract durable facts that will still be true and useful weeks from now: " + "user preferences and standing rules, ongoing projects and recurring " + "commitments, technical and architectural decisions with their rationale, " + "and people/tool relationships. A preference revealed by a request is " + "durable — record the preference (what the user likes, wants, or always " + `does), not the request itself.
21399
21492
 
21400
21493
  ` + `NEVER extract:
21401
21494
  ` + "- Agent tool-use traces or narration of what the assistant did (e.g. " + `"the assistant used X to query Y", "ran a search", "sent the message").
@@ -21406,11 +21499,7 @@ var DEFAULT_RETAIN_MISSION = "Extract durable facts that will still be true and
21406
21499
  ` + "- Transient state (unread counts, build status, what is running right now) " + "unless the fact is explicitly dated, in which case record it as a dated " + `observation.
21407
21500
  ` + `- Greetings, acknowledgements, and routine operational chatter.
21408
21501
 
21409
- ` + "If a candidate fact matches an exclusion, drop it rather than rewording " + "it. If nothing durable remains, return an empty facts list.";
21410
- var SUPERSEDED_RETAIN_MISSIONS = [
21411
- "Extract technical decisions, architectural choices, user preferences, project context, and people/tool relationships. Ignore routine greetings and transient operational details.",
21412
- "Extract user preferences, ongoing projects, recurring commitments, " + "important context, and durable facts that should help across future " + "conversations. Skip one-off chatter and temporary task noise.",
21413
- "Extract user preferences, ongoing projects, recurring commitments, " + "important context, and durable facts that should help across future " + "conversations. Skip one-off chatter and temporary task noise, " + "including in-flight workflow/process narration (a sub-task started, " + "paused, or is still running) — only retain the outcome once a task " + "actually completes or a decision is made."
21502
+ ` + "If a candidate fact matches an exclusion, drop it rather than rewording " + "it. If nothing durable remains, return an empty facts list."
21414
21503
  ];
21415
21504
  var PROFILE_MEMORY_DEFAULTS = {
21416
21505
  "health-coach": {
@@ -21492,6 +21581,27 @@ var SCRYPT_MAXMEM = 128 * 1024 * 1024;
21492
21581
  init_client();
21493
21582
  var materializedDirs = new Set;
21494
21583
 
21584
+ // src/setup/hindsight-recall-passthrough.ts
21585
+ var HINDSIGHT_RECALL_TAG_WEIGHT_SEED = Object.freeze({ sidechain: 0.8 });
21586
+ var HINDSIGHT_RECALL_PROMPT_PREAMBLE_DEFAULT = "Relevant memories from past conversations (prioritize recent when " + "conflicting). Only use memories that are directly useful to continue " + "this conversation; ignore the rest:";
21587
+ var RECALL_PASSTHROUGH_DEFAULTS = Object.freeze({
21588
+ budget: "low",
21589
+ maxTokens: 1024,
21590
+ preferObservations: true,
21591
+ contextTurns: 2,
21592
+ roles: ["user", "assistant"],
21593
+ promptPreamble: HINDSIGHT_RECALL_PROMPT_PREAMBLE_DEFAULT,
21594
+ tags: [],
21595
+ tagsMatch: "any",
21596
+ tagGroups: {},
21597
+ tagWeights: HINDSIGHT_RECALL_TAG_WEIGHT_SEED,
21598
+ additionalBankFilters: {},
21599
+ transcriptFallback: true,
21600
+ transcriptTailBytes: 262144,
21601
+ maxQueryChars: 800,
21602
+ parallel: true
21603
+ });
21604
+
21495
21605
  // src/agents/scaffold.ts
21496
21606
  var REPO_ROOT = resolve5(import.meta.dirname, "../..");
21497
21607
  var CLAUDE_MD_YOURS_PLACEHOLDER = "This space is yours. Add per-agent rules, exceptions, or context the " + "Switchroom template doesn't capture. Everything above the marker line is " + "regenerated on every apply; this section is preserved.";
@@ -4171,10 +4171,37 @@ var init_schema = __esm(() => {
4171
4171
  request_timeout_seconds: exports_external.number().int().min(1).optional().describe("Per-bank HTTP read timeout, in seconds, for one recall " + "request. Even parallelised, each bank carries its own deadline " + "so ONE hung bank returns empty instead of consuming the shared " + "deadline and starving its siblings. The plugin default is 12 " + "(raised from a hardcoded 8 in #3757, which fired on 96.8% of " + "one agent's own-bank recalls). Switchroom defaults it to the " + "effective `parallel_deadline_seconds` instead — 10 at the " + "shipped ceiling — because the shared fan-out deadline is " + "already the tighter outer guard, so a per-bank value above it " + "can never bind. An explicitly configured value above the " + "effective deadline is clamped down to it, and the clamp is " + "reported."),
4172
4172
  own_bank_min_slots: exports_external.number().int().min(0).optional().describe("Slots inside `max_memories` reserved as a FLOOR for the agent's " + "own bank when recall fans out to more than one bank. The merged " + "set is sorted globally by relevance and head-sliced, which is " + "winner-take-all across banks: when both banks return more " + "candidates than the cap, one bank's score distribution can fill " + "every slot and the agent gets a dossier about its operator with " + "none of its own session memory. A floor, not a quota: at most " + "this many slots, only if the own bank returned that many, and " + "only up to HALF the cap shared with `additional_bank_min_slots` " + "— the rest is always won on pure relevance, so composition still " + "moves with the scores. Fixes score-based crowd-out only; a " + "timed-out bank returns no candidates and reservation is a no-op " + "there. 0 disables (default). Switchroom-managed agents use 2 " + "against the fleet-deployed cap of 6."),
4173
4173
  additional_bank_min_slots: exports_external.number().int().min(0).optional().describe("Slots inside `max_memories` reserved as a FLOOR for the " + "additional (profile / shared / sender) banks. Symmetric with " + "`own_bank_min_slots` — same floor-not-quota semantics, and the " + "two share the same half-of-cap reservation budget. When they sum " + "above that budget the own-bank floor is honoured first. 0 " + "disables (default). Switchroom-managed agents use 1 against the " + "fleet-deployed cap of 6. Observe `injected_own_bank_count` / " + "`injected_additional_bank_count` via " + "`switchroom memory recall-log`."),
4174
+ min_score: exports_external.number().min(0).optional().describe("Absolute floor on a memory's engine relevance score " + "(`scores.final`) for it to be injected. 0 disables (default, " + "and the shipped fleet behaviour). Exists for one measured " + "failure: when the agent's own bank times out, recall still " + "injects side-bank residue under the banner 'Relevant memories " + "from past conversations' — 98.4% of degraded turns have a best " + "injected score below 0.01, against 28.4% of healthy ones. Six " + "noise memories are worse than none, because the agent cannot " + "tell them apart. Below-floor results are dropped BEFORE " + "rendering, and when the floor empties the set the turn says so " + "rather than going silent. Do NOT read this as a general " + "precision control: `scores.final` is not calibrated across " + "queries, and #3761 measured that an unconditional 0.01 floor " + "empties ~28% of HEALTHY recalls — which is why " + "`min_score_scope` defaults to degraded turns only. Observe " + "`dropped_below_min_score` via `switchroom memory recall-log`."),
4175
+ min_score_scope: exports_external.enum(["degraded", "all"]).optional().describe('Which turns `min_score` binds on. "degraded" (default) — only ' + "turns where the agent's OWN bank timed out or was unreachable, " + "the population where a below-floor score actually predicts " + "noise and where the agent already receives the degraded-recall " + 'disclosure. "all" — every turn; only for an operator who has ' + "measured their own bank's score distribution, since it " + "re-creates the empty-recall failure of #3541 at any floor " + "calibrated on degraded data. No effect while `min_score` is 0."),
4174
4176
  types: exports_external.array(exports_external.string()).optional().describe("Hindsight fact types to recall. Switchroom default is " + '["world", "experience", "observation"] — the synthesized ' + "`observation` tier is on by default. Set to " + '["world", "experience"] to opt out of observation-backed ' + "recall for this agent (or fleet-wide under defaults)."),
4175
4177
  additional_banks: exports_external.array(exports_external.string()).optional().describe("Extra Hindsight banks to recall from on every turn, merged into " + "the agent's own bank results — e.g. a shared operator/household " + "profile bank authored via `switchroom memory profile`. Each is " + "recalled with the `request_timeout_seconds` per-bank timeout " + "(defaults to the effective `parallel_deadline_seconds`, 10s at " + "the shipped ceiling) and is non-fatal on failure. Stays " + "within the single tenant: all banks are the operator's data, in " + "the operator's Hindsight instance (see the `single-tenant` " + "invariant). Defaults to [] (no extra banks)."),
4176
4178
  sender_banks: exports_external.record(exports_external.string(), exports_external.string()).optional().describe("Per-speaker recall routing: a map of Telegram sender → extra " + "recall bank. When a message arrives, the agent also recalls the " + "speaker's bank (matched by Telegram username — a leading @ is " + "optional — or numeric user_id), merged " + "into its own results — so each trusted user gets their own " + "profile context. Additive recall scoping within the single " + "tenant: never an access boundary (who may drive an agent stays " + "the per-agent user assignment in `access.allowFrom`). Author the " + "banks via `switchroom memory profile`."),
4177
4179
  skip_trivial: exports_external.boolean().optional().describe("Skip recall on plausibly-stateless trivial turns (time/date/" + "greeting). Switchroom default true — saves the recall arm + " + "injected tokens on turns that never need memory, guarded so it " + "never skips a turn that references user/project/session state. " + "Set false to always run recall."),
4180
+ budget: exports_external.enum(["low", "mid", "high"]).optional().describe('How hard Hindsight searches. "low" (switchroom default) = ' + 'vector retrieval only, ~1-2s. "mid" adds the LLM rerank pass ' + "and measured ~5s of hook latency on real fleet turns — the " + "second-largest contributor to perceived dead air after model " + 'TTFT. "high" is thorough and slower still. Raise it for an ' + "agent whose recall quality matters more than its reply latency " + "(a research or audit role); leave it at low for chat."),
4181
+ max_tokens: exports_external.number().int().min(1).optional().describe("Token budget for the injected memory block. Default 1024. This " + "is the TOKEN bound; `max_memories` is the separate COUNT bound " + "and the tighter of the two wins. Raise it only alongside " + "`max_memories` — on its own it buys nothing once the count cap " + "binds."),
4182
+ prefer_observations: exports_external.boolean().optional().describe("Bias recall toward the synthesized `observation` tier, " + "backfilling the slots freed by superseded raw facts for denser " + "coverage inside the same budget. Default true. Set false to " + "rank raw `world`/`experience` facts on equal footing — useful " + "when auditing what the consolidation engine actually stored, or " + "if a bank's observations are stale."),
4183
+ context_turns: exports_external.number().int().min(1).optional().describe("How many recent human turns are composed into the recall query. " + 'Default 2, so a bare follow-up ("and the port?") embeds with ' + "its antecedent instead of recalling on the pronoun alone. 1 = " + "the latest turn only. Raising it costs BM25 terms, which is the " + "real recall cost driver — `query_max_tokens` still bounds the " + "result, so a large value mostly shifts which terms survive."),
4184
+ roles: exports_external.array(exports_external.string().min(1)).min(1).optional().describe("Transcript roles the multi-turn composition may draw from. " + 'Default ["user", "assistant"]. Set ["user"] to compose ' + "the query from the human's words only — worth trying when an " + "agent's own verbose replies are dominating the query terms. No " + "effect while `context_turns` is 1."),
4185
+ prompt_preamble: exports_external.string().min(1).optional().describe("The banner rendered above injected memories. The agent reads " + "this line as the instruction for how to treat the block, so it " + "is a behaviour knob, not cosmetics. Default tells the model to " + "prioritise recent memories on conflict and ignore irrelevant " + "ones. Override to tighten that framing for a specialised agent."),
4186
+ tags: exports_external.array(exports_external.string().min(1)).optional().describe("Restrict recall to memories carrying these tags. Default [] = " + "no filter (match everything). This is a HARD filter applied " + "server-side — a memory without the tags cannot surface at any " + "score — so it is for a genuinely scoped agent, not for " + "ranking. Use `tag_weights` when you want a preference rather " + "than an exclusion."),
4187
+ tags_match: exports_external.enum(["any", "all", "any_strict", "all_strict"]).optional().describe('How `tags` combine. "any" (default) = at least one; ' + '"all" = every tag. The `_strict` forms additionally require ' + "the memory to actually carry the tags rather than merely rank " + "for them. No effect while `tags` and `tag_groups` are empty."),
4188
+ tag_groups: exports_external.union([
4189
+ exports_external.array(exports_external.array(exports_external.string().min(1))),
4190
+ exports_external.record(exports_external.string(), exports_external.array(exports_external.string().min(1)))
4191
+ ]).optional().describe("Tag filtering with grouping — either an OR-of-ANDs list " + '([["a","b"],["c"]] = (a AND b) OR c) or a named ' + "{group: [tags]} map. Default unset (no grouping). Use when a " + "flat `tags` + `tags_match` cannot express the scope you need."),
4192
+ tag_weights: exports_external.record(exports_external.string(), exports_external.number().min(0)).optional().describe("Per-tag multipliers applied to `scores.final` just before the " + "final sort — a DEMOTION/PROMOTION, never a drop, so a " + "down-weighted memory still surfaces when it is the only " + "relevant hit. MERGED over switchroom's seed " + '({"sidechain": 0.8}, which ranks delegated sub-agent ' + "process-memories just under first-party ones), so setting one " + "unrelated weight does not silently undo it; pass " + "`sidechain: 1.0` to neutralise the seed. Reach for this when " + "recall_log shows one class of memory crowding the block."),
4193
+ additional_bank_filters: exports_external.record(exports_external.string(), exports_external.object({
4194
+ tags: exports_external.array(exports_external.string().min(1)).optional(),
4195
+ tags_match: exports_external.enum(["any", "all", "any_strict", "all_strict"]).optional(),
4196
+ tag_groups: exports_external.union([
4197
+ exports_external.array(exports_external.array(exports_external.string().min(1))),
4198
+ exports_external.record(exports_external.string(), exports_external.array(exports_external.string().min(1)))
4199
+ ]).optional()
4200
+ }).strict()).optional().describe("Per-bank overrides of the tag filters above, keyed by bank id " + "(applies to `additional_banks` AND to sender banks). Default " + "{} = every extra bank inherits the global filters. Use it to " + "scope a shared bank — e.g. recall only `profile`-tagged " + "memories from the operator's profile bank while leaving the " + "agent's own bank unfiltered."),
4201
+ transcript_fallback: exports_external.boolean().optional().describe("When every bank returns zero results AND no bank hit its " + "deadline, grep the current session's transcript tail for turns " + "matching the query and inject them as a clearly-labelled " + "lower-confidence block. Default true — it covers the window " + "between an abrupt kill and the next boot reconciliation, where " + "the fact layer was never told about the lost turns. Set false " + "if you never want un-consolidated transcript text in context."),
4202
+ transcript_tail_bytes: exports_external.number().int().min(0).optional().describe("Bytes of the session transcript read from the tail for the " + "multi-turn query composition. Default 262144 (256 KiB), which " + "keeps the per-turn read O(1) on a session log that can grow to " + "many MB. 0 = read the whole file (the pre-bound behaviour, and " + "the rollback lever if a composition ever needs older turns)."),
4203
+ max_query_chars: exports_external.number().int().min(1).optional().describe("Character bound on the composed recall query, applied before " + "`query_max_tokens` shapes it. Default 800. Truncation preserves " + "the latest turn and drops the oldest context first. Lower it " + "for an agent whose turns are long pasted payloads."),
4204
+ parallel: exports_external.boolean().optional().describe("Run the directives fetch and every bank recall concurrently " + "under one shared deadline, so total latency is the SLOWEST slot " + "rather than their SUM. Default true. false restores the serial " + "path — the rollback lever if the parallel path ever misbehaves; " + "expect multi-bank recall latency to add up."),
4178
4205
  topic_filter_mode: exports_external.enum(["soft-preamble", "hard-filter"]).optional().describe("Supergroup-mode cross-topic memory behaviour. Default " + "(unset) → soft-preamble: recall returns memories from all " + "topics, and a 'Current topic: …' preamble tells the model " + "to self-scope. hard-filter: drop any recalled memory whose " + "metadata.thread_id differs from the active inbound's topic. " + "Flip to hard-filter when the recall_log shows binding " + "failures (model surfacing the right memory but applying " + "it to the wrong topic).")
4179
4206
  }).optional().describe("Auto-recall tuning knobs"),
4180
4207
  retain: exports_external.object({
@@ -4387,6 +4414,7 @@ var init_schema = __esm(() => {
4387
4414
  context_window: exports_external.number().int().positive().optional().describe("Context window (tokens) of the backend serving THIS op. NOT an " + "upstream env var — switchroom derives the op's token budget " + "(consolidation batch size / max-completion caps / reflect " + "max-context cap) from it so a single call can never overflow the " + "window. Absent → inherit " + "`hindsight.llm.context_window`, else a per-provider default " + "(conservative for non-`claude-code` providers, which usually mean " + "a local llama.cpp/Ollama slot; a self-hosted `base_url` — loopback, " + "RFC1918, `.local`/`.internal` — forces the conservative default too, " + "regardless of the provider NAME, since the endpoint is where the " + "traffic actually terminates). All three lanes (`retain`, " + "`reflect`, `consolidation`) are budgeted independently.")
4388
4415
  }).describe("Per-operation LLM override. Every field optional; an unset field (or " + "an omitted op block) inherits the global `hindsight.llm.*`, which is " + "already the engine's fallback — switchroom emits only the vars set.");
4389
4416
  HindsightConfigSchema = exports_external.object({
4417
+ gpu: exports_external.boolean().optional().describe("Force GPU passthrough for the hindsight container on (`true`) or off " + "(`false`), overriding host autodetection in BOTH directions. Absent " + "(the default) → autodetect from the persisted host-capabilities " + "verdict (`~/.switchroom/host-capabilities.json`), which enables " + "`--gpus all` only when that file proves BOTH a GPU and the nvidia " + "container toolkit. Set `true` when that verdict is wrong or unreadable " + "and you know the host has a working toolkit — switchroom cannot verify " + "it for you, and `docker run --gpus all` hard-fails container create on " + "a host without one. Set `false` to pin the container to CPU on a GPU " + "host. This is also the declarative opt-out for the recreate-time GPU " + "drop guard (`switchroom memory setup --recreate` refuses to silently " + "turn a GPU container into a CPU one). `--gpu`/`--no-gpu` on `memory " + "setup` override this for a single run."),
4390
4418
  llm: exports_external.object({
4391
4419
  provider: exports_external.string().min(1).optional().describe("Hindsight LLM provider (upstream `HINDSIGHT_API_LLM_PROVIDER`). " + "Defaults to `claude-code` (subscription-honest, broker-fed OAuth). " + "Any litellm-routable provider the upstream image supports is valid. " + "Serves as the GLOBAL default for every op absent a per-op override."),
4392
4420
  model: exports_external.string().min(1).optional().describe("Hindsight LLM model (upstream `HINDSIGHT_API_LLM_MODEL`). Defaults " + "to HINDSIGHT_DEFAULT_MODEL. Any model your LiteLLM proxy can route " + "is valid, e.g. `openrouter/z-ai/glm-5.2` when routing through the " + "fleet proxy. With provider=claude-code this value is ALSO exported " + "as `ANTHROPIC_MODEL` to the claude subprocess. Serves as the GLOBAL " + "default for every op absent a per-op override."),
@@ -4538,6 +4566,33 @@ var init_schema = __esm(() => {
4538
4566
  request_timeout_seconds: exports_external.number().int().min(1).optional(),
4539
4567
  own_bank_min_slots: exports_external.number().int().min(0).optional(),
4540
4568
  additional_bank_min_slots: exports_external.number().int().min(0).optional(),
4569
+ min_score: exports_external.number().min(0).optional(),
4570
+ min_score_scope: exports_external.enum(["degraded", "all"]).optional(),
4571
+ budget: exports_external.enum(["low", "mid", "high"]).optional(),
4572
+ max_tokens: exports_external.number().int().min(1).optional(),
4573
+ prefer_observations: exports_external.boolean().optional(),
4574
+ context_turns: exports_external.number().int().min(1).optional(),
4575
+ roles: exports_external.array(exports_external.string().min(1)).min(1).optional(),
4576
+ prompt_preamble: exports_external.string().min(1).optional(),
4577
+ tags: exports_external.array(exports_external.string().min(1)).optional(),
4578
+ tags_match: exports_external.enum(["any", "all", "any_strict", "all_strict"]).optional(),
4579
+ tag_groups: exports_external.union([
4580
+ exports_external.array(exports_external.array(exports_external.string().min(1))),
4581
+ exports_external.record(exports_external.string(), exports_external.array(exports_external.string().min(1)))
4582
+ ]).optional(),
4583
+ tag_weights: exports_external.record(exports_external.string(), exports_external.number().min(0)).optional(),
4584
+ additional_bank_filters: exports_external.record(exports_external.string(), exports_external.object({
4585
+ tags: exports_external.array(exports_external.string().min(1)).optional(),
4586
+ tags_match: exports_external.enum(["any", "all", "any_strict", "all_strict"]).optional(),
4587
+ tag_groups: exports_external.union([
4588
+ exports_external.array(exports_external.array(exports_external.string().min(1))),
4589
+ exports_external.record(exports_external.string(), exports_external.array(exports_external.string().min(1)))
4590
+ ]).optional()
4591
+ }).strict()).optional(),
4592
+ transcript_fallback: exports_external.boolean().optional(),
4593
+ transcript_tail_bytes: exports_external.number().int().min(0).optional(),
4594
+ max_query_chars: exports_external.number().int().min(1).optional(),
4595
+ parallel: exports_external.boolean().optional(),
4541
4596
  additional_banks: exports_external.array(exports_external.string()).optional(),
4542
4597
  sender_banks: exports_external.record(exports_external.string(), exports_external.string()).optional()
4543
4598
  }).optional()
@@ -19211,6 +19266,7 @@ function assertPositive(value, label) {
19211
19266
 
19212
19267
  // src/setup/host-capabilities.ts
19213
19268
  init_paths();
19269
+ var _warnedReads = new Set;
19214
19270
 
19215
19271
  // src/setup/hindsight-pg-defaults.ts
19216
19272
  var HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION = 8 * 1024;
@@ -19374,7 +19430,42 @@ var HINDSIGHT_HEALTHCHECK_CMD = `python3 -c '${HINDSIGHT_HEALTHCHECK_PY}'`;
19374
19430
  var DOCKER_PROBE_TIMEOUT_MS = 60 * 1000;
19375
19431
 
19376
19432
  // src/memory/hindsight.ts
19377
- var DEFAULT_RETAIN_MISSION = "Extract durable facts that will still be true and useful weeks from now: " + "user preferences and standing rules, ongoing projects and recurring " + "commitments, technical and architectural decisions with their rationale, " + "and people/tool relationships. A preference revealed by a request is " + "durable — record the preference (what the user likes, wants, or always " + `does), not the request itself.
19433
+ var DEFAULT_RETAIN_MISSION = `Extract durable facts that will still be true and useful weeks from now: user preferences and standing rules, ongoing projects and recurring commitments, technical and architectural decisions with their rationale, and people/tool relationships. A preference revealed by a request is durable — record the preference (what the user likes, wants, or always does), not the request itself.
19434
+ ` + `
19435
+ ` + `A TOOL RESULT IS NOT A FACT. Before extracting, ask: is the subject of this
19436
+ ` + `candidate a file path, a command/process/agent/session id, a temp directory, or
19437
+ ` + `the location where some output was written? If yes, drop it — it is transcript
19438
+ ` + `exhaust, not memory.
19439
+ ` + `
19440
+ ` + `NEVER extract:
19441
+ ` + `- Tool results verbatim or paraphrased. Concretely, never produce a fact whose
19442
+ ` + ` text resembles any of these: "File created successfully at /path/to/file",
19443
+ ` + ` "A background command with ID bctz4yskm is running, and its output will be
19444
+ ` + ` written to /tmp/...", "Async agent a745598ba84e71df1 was launched successfully
19445
+ ` + ` and is running in the background", "User executed a Bash command to sleep for
19446
+ ` + ` 200 seconds", "The assistant used grep to locate 'truncateSync' in src/foo.ts".
19447
+ ` + `- Anything mentioning a path under /tmp, a scratchpad directory, or a .tmp file.
19448
+ ` + `- Agent tool-use traces or narration of what the assistant did (e.g. "the
19449
+ ` + ` assistant used X to query Y", "ran a search", "sent the message").
19450
+ ` + `- In-flight workflow/process narration (a sub-task started, paused, or is still
19451
+ ` + ` running) — retain the outcome only once the task completes or a decision is made.
19452
+ ` + `- Operation, request, batch, agent, command or session IDs, UUIDs, hashes, or error codes.
19453
+ ` + `- Slash commands the user typed and their effects (e.g. "User issued /clear to
19454
+ ` + ` reset assistant state").
19455
+ ` + `- Hindsight's own errors, retries, backlogs, or internal state — the memory
19456
+ ` + ` system's self-reports are not memories.
19457
+ ` + `- Restatements of the user's current request or the task in progress.
19458
+ ` + `- Transient state (unread counts, build status, what is running right now) unless
19459
+ ` + ` the fact is explicitly dated, in which case record it as a dated observation.
19460
+ ` + `- Greetings, acknowledgements, and routine operational chatter.
19461
+ ` + `
19462
+ ` + `If a candidate fact matches an exclusion, drop it rather than rewording it. If
19463
+ ` + "nothing durable remains, return an empty facts list.";
19464
+ var SUPERSEDED_RETAIN_MISSIONS = [
19465
+ "Extract technical decisions, architectural choices, user preferences, project context, and people/tool relationships. Ignore routine greetings and transient operational details.",
19466
+ "Extract user preferences, ongoing projects, recurring commitments, " + "important context, and durable facts that should help across future " + "conversations. Skip one-off chatter and temporary task noise.",
19467
+ "Extract user preferences, ongoing projects, recurring commitments, " + "important context, and durable facts that should help across future " + "conversations. Skip one-off chatter and temporary task noise, " + "including in-flight workflow/process narration (a sub-task started, " + "paused, or is still running) — only retain the outcome once a task " + "actually completes or a decision is made.",
19468
+ "Extract durable facts that will still be true and useful weeks from now: " + "user preferences and standing rules, ongoing projects and recurring " + "commitments, technical and architectural decisions with their rationale, " + "and people/tool relationships. A preference revealed by a request is " + "durable — record the preference (what the user likes, wants, or always " + `does), not the request itself.
19378
19469
 
19379
19470
  ` + `NEVER extract:
19380
19471
  ` + "- Agent tool-use traces or narration of what the assistant did (e.g. " + `"the assistant used X to query Y", "ran a search", "sent the message").
@@ -19385,11 +19476,7 @@ var DEFAULT_RETAIN_MISSION = "Extract durable facts that will still be true and
19385
19476
  ` + "- Transient state (unread counts, build status, what is running right now) " + "unless the fact is explicitly dated, in which case record it as a dated " + `observation.
19386
19477
  ` + `- Greetings, acknowledgements, and routine operational chatter.
19387
19478
 
19388
- ` + "If a candidate fact matches an exclusion, drop it rather than rewording " + "it. If nothing durable remains, return an empty facts list.";
19389
- var SUPERSEDED_RETAIN_MISSIONS = [
19390
- "Extract technical decisions, architectural choices, user preferences, project context, and people/tool relationships. Ignore routine greetings and transient operational details.",
19391
- "Extract user preferences, ongoing projects, recurring commitments, " + "important context, and durable facts that should help across future " + "conversations. Skip one-off chatter and temporary task noise.",
19392
- "Extract user preferences, ongoing projects, recurring commitments, " + "important context, and durable facts that should help across future " + "conversations. Skip one-off chatter and temporary task noise, " + "including in-flight workflow/process narration (a sub-task started, " + "paused, or is still running) — only retain the outcome once a task " + "actually completes or a decision is made."
19479
+ ` + "If a candidate fact matches an exclusion, drop it rather than rewording " + "it. If nothing durable remains, return an empty facts list."
19393
19480
  ];
19394
19481
  var PROFILE_MEMORY_DEFAULTS = {
19395
19482
  "health-coach": {
@@ -19439,6 +19526,27 @@ var materializedDirs = new Set;
19439
19526
  // src/setup/onboarding.ts
19440
19527
  init_paths();
19441
19528
 
19529
+ // src/setup/hindsight-recall-passthrough.ts
19530
+ var HINDSIGHT_RECALL_TAG_WEIGHT_SEED = Object.freeze({ sidechain: 0.8 });
19531
+ var HINDSIGHT_RECALL_PROMPT_PREAMBLE_DEFAULT = "Relevant memories from past conversations (prioritize recent when " + "conflicting). Only use memories that are directly useful to continue " + "this conversation; ignore the rest:";
19532
+ var RECALL_PASSTHROUGH_DEFAULTS = Object.freeze({
19533
+ budget: "low",
19534
+ maxTokens: 1024,
19535
+ preferObservations: true,
19536
+ contextTurns: 2,
19537
+ roles: ["user", "assistant"],
19538
+ promptPreamble: HINDSIGHT_RECALL_PROMPT_PREAMBLE_DEFAULT,
19539
+ tags: [],
19540
+ tagsMatch: "any",
19541
+ tagGroups: {},
19542
+ tagWeights: HINDSIGHT_RECALL_TAG_WEIGHT_SEED,
19543
+ additionalBankFilters: {},
19544
+ transcriptFallback: true,
19545
+ transcriptTailBytes: 262144,
19546
+ maxQueryChars: 800,
19547
+ parallel: true
19548
+ });
19549
+
19442
19550
  // src/repos/bare-clone.ts
19443
19551
  init_paths();
19444
19552