switchroom 0.19.24 → 0.19.25

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 (34) hide show
  1. package/dist/agent-scheduler/index.js +15 -6
  2. package/dist/auth-broker/index.js +85 -27
  3. package/dist/cli/autoaccept-poll.js +0 -1
  4. package/dist/cli/drive-write-pretool.mjs +5 -0
  5. package/dist/cli/ms-365-write-pretool.mjs +5 -0
  6. package/dist/cli/notion-write-pretool.mjs +15 -5
  7. package/dist/cli/switchroom.js +2690 -1415
  8. package/dist/host-control/main.js +84 -28
  9. package/dist/vault/approvals/kernel-server.js +83 -27
  10. package/dist/vault/broker/server.js +249 -70
  11. package/examples/switchroom.yaml +1 -1
  12. package/package.json +1 -1
  13. package/profiles/_base/start.sh.hbs +52 -13
  14. package/skills/switchroom-health/SKILL.md +19 -0
  15. package/skills/switchroom-status/SKILL.md +1 -1
  16. package/telegram-plugin/auth-snapshot-format.ts +9 -2
  17. package/telegram-plugin/dist/gateway/gateway.js +5757 -5689
  18. package/telegram-plugin/quota-bar-format.ts +4 -1
  19. package/telegram-plugin/tests/auth-snapshot-format.test.ts +42 -0
  20. package/telegram-plugin/tests/quota-bar-format.test.ts +50 -0
  21. package/telegram-plugin/tests/secret-detect-false-positives.test.ts +1 -1
  22. package/vendor/hindsight-memory/scripts/lib/config.py +61 -19
  23. package/vendor/hindsight-memory/scripts/lib/content.py +376 -1
  24. package/vendor/hindsight-memory/scripts/lib/english_words.txt +10799 -0
  25. package/vendor/hindsight-memory/scripts/recall.py +503 -252
  26. package/vendor/hindsight-memory/scripts/tests/test_recall_bank_slots.py +509 -0
  27. package/vendor/hindsight-memory/scripts/tests/test_recall_envelope_strip_telemetry.py +22 -5
  28. package/vendor/hindsight-memory/scripts/tests/test_recall_error_text.py +147 -0
  29. package/vendor/hindsight-memory/scripts/tests/test_recall_hook_budget.py +266 -0
  30. package/vendor/hindsight-memory/scripts/tests/test_recall_integration.py +0 -401
  31. package/vendor/hindsight-memory/scripts/tests/test_recall_no_lexical_gate.py +261 -0
  32. package/vendor/hindsight-memory/scripts/tests/test_recall_query_shaping.py +473 -0
  33. package/vendor/hindsight-memory/scripts/tests/test_recall_transcript_fallback.py +25 -8
  34. package/vendor/hindsight-memory/tests/test_content.py +218 -0
@@ -19221,7 +19221,11 @@ var AgentMemorySchema = exports_external.object({
19221
19221
  recall: exports_external.object({
19222
19222
  max_memories: exports_external.number().int().min(0).optional().describe("Cap on the number of memories injected into the prompt by " + "auto-recall, regardless of token budget. Plugin default is 12. " + "0 disables the cap (all memories Hindsight returns are injected)."),
19223
19223
  cache_ttl_secs: exports_external.number().int().min(0).optional().describe("Per-session recall cache TTL in seconds. When > 0, identical " + "(prompt, bank) within the same session reuse the cached recall " + "result instead of round-tripping to Hindsight. 0 disables. " + "Default is 600 (10 min) for switchroom-managed agents."),
19224
- min_overlap: exports_external.number().min(0).max(1).optional().describe("Minimum containment token overlap [0.0–1.0] between the user " + "prompt and a memory's text for the memory to be injected. " + "A cheap FLOOR that removes candidates with (near-)zero lexical " + "relationship to the prompt — NOT a precision control: at the " + "recommended 0.10 the gate is near-passthrough, and the " + "effective precision control is the engine rerank plus the " + "max_memories head-slice. 0.0 disables (default — current " + "behaviour). Use 0.10; values at or above 0.20 measurably " + "starve recall — on production replay 0.20 leaves ~41.9% of " + "turns with NO memories at all, re-creating the bug #3541 " + "fixed. Observe the `overlap_dropped` field via " + "`switchroom memory recall-log`."),
19224
+ query_max_tokens: exports_external.number().int().min(0).optional().describe("Cap on the number of DISTINCT BM25 terms the recall hook may " + "put on the wire. `recallMaxQueryChars` bounds characters, which " + "is not the cost driver: Hindsight OR-joins every query token " + "into one tsquery and Postgres native FTS ranks the entire " + "matched set before the top-60 heapsort, so cost tracks TERMS. " + "An 800-char composed query is ~96 distinct terms and matched " + "119,510 of 135,565 rows on the `overlord` bank (14.0s for the " + "3-arm " + "BM25 UNION), past the per-bank timeout — 96.8% of that agent's " + "own-bank recalls returned nothing. Plugin default is 24 " + "(measured 48,433 rows / 2.7s on the same bank). Terms are " + "chosen recency-first (the latest turn beats prior context), " + "then by selectivity. 0 disables shaping (rollback lever)."),
19225
+ query_stop_terms: exports_external.array(exports_external.string().min(1).regex(/^[\w./-]+$/)).optional().describe("Extra terms dropped from the BM25 recall query, on top of the " + "built-in English stopword list. For BANK-SPECIFIC " + "high-document-frequency words a generic stoplist cannot know " + "about: on `overlord`, `switchroom` matches 20% of the bank and " + "`agent` another 20%, purely because that is what the corpus is " + "about, and each such term drags tens of thousands of rows into " + "the ranking. Defaults to []."),
19226
+ request_timeout_seconds: exports_external.number().int().min(1).optional().describe("Per-bank HTTP read timeout, in seconds, for one recall " + "request. Plugin default is 12, matching the UserPromptSubmit " + "hook ceiling; the shared `recallParallelDeadlineSeconds` (10) " + "is the tighter outer guard in the default configuration, so " + "this is a per-request safety net. Was a hardcoded 8 in the " + "plugin before #3757."),
19227
+ 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."),
19228
+ 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`."),
19225
19229
  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)."),
19226
19230
  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 an 8s timeout 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)."),
19227
19231
  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`."),
@@ -19446,7 +19450,7 @@ var HindsightConfigSchema = exports_external.object({
19446
19450
  reflect: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `reflect` LLM op (synthesis / mental-model " + "refresh). Emits `HINDSIGHT_API_REFLECT_LLM_*`. Absent → uses global."),
19447
19451
  consolidation: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `consolidation` LLM op (background memory " + "merge). Emits `HINDSIGHT_API_CONSOLIDATION_LLM_*`. Absent → global.")
19448
19452
  }).optional().describe("LLM knob for the hindsight container. The flat `provider`/`model` set " + "the global default (backward-compatible); optional `retain`/`reflect`/" + "`consolidation` blocks override individual ops. All fields optional; " + "unset fields fall back to the hard-coded defaults."),
19449
- env: exports_external.record(exports_external.union([exports_external.string(), exports_external.number(), exports_external.boolean()])).optional().describe("Operator overrides for switchroom's capability-gated Hindsight " + "performance defaults. Only the keys switchroom actually manages are " + "honoured (`HINDSIGHT_PERF_ENV_KEYS` in " + "src/setup/hindsight-perf-defaults.ts: RERANKER_LOCAL_FP16, " + "RERANKER_LOCAL_BATCH_SIZE, LLM_MAX_CONCURRENT, " + "RETAIN/CONSOLIDATION_LLM_MAX_CONCURRENT, LLM_STRICT_SCHEMA, " + "LLM_MAX_RETRIES, CONSOLIDATION_LLM_PARALLELISM, " + "RECALL_MAX_CANDIDATES_PER_SOURCE, LINK_EXPANSION_PER_ENTITY_LIMIT, " + "LINK_EXPANSION_TIMEOUT, LLM_REASONING_EFFORT), the override-only keys " + "switchroom manages but ships NO default for " + "(`HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS`: " + "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY — a per-deployment " + "`bank-pattern:priority,...` map; unset means upstream's flat " + "created_at FIFO across banks), plus the " + "embedded-PostgreSQL (pg0) sizing keys switchroom manages in " + "src/setup/hindsight-pg-defaults.ts (`HINDSIGHT_PG_ENV_KEYS`: " + "SWITCHROOM_HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE, " + "SWITCHROOM_HINDSIGHT_PG_SHARED_BUFFERS — a postgres size string such " + "as `4GB`, or the sentinel `off` to leave pg0's own default for that " + "one knob). A value set here " + "REPLACES switchroom's default and is emitted even when the gating " + "capability is absent, so an operator can always force a knob. Other " + "`HINDSIGHT_API_*` keys are deliberately IGNORED — a blanket " + "passthrough would collide with the vars startHindsight() derives " + "itself (HINDSIGHT_API_PORT, the retain token/deadline budget).")
19453
+ env: exports_external.record(exports_external.union([exports_external.string(), exports_external.number(), exports_external.boolean()])).optional().describe("Operator overrides for switchroom's capability-gated Hindsight " + "performance defaults. Only the keys switchroom actually manages are " + "honoured (`HINDSIGHT_PERF_ENV_KEYS` in " + "src/setup/hindsight-perf-defaults.ts: RERANKER_LOCAL_FP16, " + "RERANKER_LOCAL_BATCH_SIZE, LLM_MAX_CONCURRENT, " + "RETAIN/CONSOLIDATION_LLM_MAX_CONCURRENT, LLM_STRICT_SCHEMA, " + "LLM_MAX_RETRIES, CONSOLIDATION_LLM_PARALLELISM, " + "MAX_OBSERVATIONS_PER_SCOPE, " + "RECALL_MAX_CANDIDATES_PER_SOURCE, LINK_EXPANSION_PER_ENTITY_LIMIT, " + "LINK_EXPANSION_TIMEOUT, LLM_REASONING_EFFORT, " + "RERANKER_LOCAL_BUCKET_BATCHING, RERANKER_MAX_CANDIDATES, " + "RERANKER_LOCAL_MAX_CONCURRENT, RECALL_MAX_CONCURRENT, " + "REFLECT_WALL_TIMEOUT, WORKER_CONSOLIDATION_MAX_SLOTS, " + "WORKER_CONSOLIDATION_SLOT_LIMIT, " + "CONSOLIDATION_MAX_MEMORIES_PER_ROUND), the override-only keys " + "switchroom manages but ships NO default for " + "(`HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS`: " + "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY — a per-deployment " + "`bank-pattern:priority,...` map; unset means upstream's flat " + "created_at FIFO across banks; and " + "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP — the rollback knob for " + "switchroom's CE-saturation damping patch, a float; >= ~0.65 backs the " + "damping out entirely, unset means the patch's own derived gap), plus the " + "embedded-PostgreSQL (pg0) sizing keys switchroom manages in " + "src/setup/hindsight-pg-defaults.ts (`HINDSIGHT_PG_ENV_KEYS`: " + "SWITCHROOM_HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE, " + "SWITCHROOM_HINDSIGHT_PG_SHARED_BUFFERS — a postgres size string such " + "as `4GB`, or the sentinel `off` to leave pg0's own default for that " + "one knob). A value set here " + "REPLACES switchroom's default and is emitted even when the gating " + "capability is absent, so an operator can always force a knob. Other " + "`HINDSIGHT_API_*` keys are deliberately IGNORED — a blanket " + "passthrough would collide with the vars startHindsight() derives " + "itself (HINDSIGHT_API_PORT, the retain token/deadline budget).")
19450
19454
  });
19451
19455
  var MicrosoftWorkspaceConfigSchema = exports_external.object({
19452
19456
  microsoft_client_id: exports_external.string().min(1).optional().describe("Microsoft OAuth application (client) ID from Entra portal " + "(literal string or vault reference e.g. " + "'vault:microsoft-oauth-client-id'). OPTIONAL — omit it to use " + "switchroom's shipped default Microsoft app (zero-config). " + "Set it only to bring your own Entra app (BYO)."),
@@ -19582,7 +19586,11 @@ var profileFields = {
19582
19586
  recall: exports_external.object({
19583
19587
  max_memories: exports_external.number().int().min(0).optional(),
19584
19588
  cache_ttl_secs: exports_external.number().int().min(0).optional(),
19585
- min_overlap: exports_external.number().min(0).max(1).optional(),
19589
+ query_max_tokens: exports_external.number().int().min(0).optional(),
19590
+ query_stop_terms: exports_external.array(exports_external.string().min(1).regex(/^[\w./-]+$/)).optional(),
19591
+ request_timeout_seconds: exports_external.number().int().min(1).optional(),
19592
+ own_bank_min_slots: exports_external.number().int().min(0).optional(),
19593
+ additional_bank_min_slots: exports_external.number().int().min(0).optional(),
19586
19594
  additional_banks: exports_external.array(exports_external.string()).optional(),
19587
19595
  sender_banks: exports_external.record(exports_external.string(), exports_external.string()).optional()
19588
19596
  }).optional()
@@ -19616,7 +19624,8 @@ var profileFields = {
19616
19624
  memory: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/, "memory must be a Docker size string like '6g', '512m', '1.5g'").optional().describe("Hard memory cap (Docker `mem_limit` → cgroup memory.max). When the " + "container exceeds this, the kernel OOM-kills processes in the cgroup. " + "Format: '6g', '1.5g', '512m'. When unset at every cascade layer the " + "compose generator falls back to the hard-coded per-profile defaults " + "in src/agents/compose.ts (klanker 6g, coding 2g, conversational 1.5g, " + "lightweight 1g, default 1.5g)."),
19617
19625
  memory_reservation: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/, "memory_reservation must be a Docker size string like '4g', '256m'").optional().describe("Soft memory floor (Docker `mem_reservation` → cgroup memory.low). " + "Under host-wide memory pressure, the kernel protects at least this " + "much from being reclaimed from the cgroup. Must be ≤ memory. Use to " + "keep an agent RAM-resident when the host has other tenants that " + "might push the box (Coolify apps, build jobs). Default: unset."),
19618
19626
  pids_limit: exports_external.number().int().positive().optional().describe("Max processes the cgroup can spawn (cgroup pids.max). Prevents " + "fork bombs and runaway test runners. Counts every process in the " + "cgroup including bash subprocesses, claude itself, sidecars, and " + "any test/build worker. A typical agent at idle uses ~30 PIDs; " + "`npm test`-style workloads can spike to 200+. Set generously " + "(2000 is a comfortable cap for test-running agents). Default: " + "unset (no cgroup pid cap)."),
19619
- cpus: exports_external.number().positive().optional().describe("CPU quota (Docker `cpus`). Fractional values OK (e.g. 0.5, 2.0). " + "When unset at every cascade layer the compose generator falls " + "back to the per-profile default (klanker/coding 2.0, default 1.0, " + "lightweight 0.5).")
19627
+ cpus: exports_external.number().positive().optional().describe("CPU quota (Docker `cpus`). Fractional values OK (e.g. 0.5, 2.0). " + "When unset at every cascade layer the compose generator falls " + "back to the per-profile default (klanker/coding 2.0, default 1.0, " + "lightweight 0.5)."),
19628
+ tmp_size: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/, "tmp_size must be a Docker size string like '1g', '4g', '512m'").refine((v) => parseFloat(v) > 0, "tmp_size must be greater than zero").optional().describe("Size of the agent container's RAM-backed `/tmp` (Docker " + "`tmpfs: - /tmp:size=<this>,mode=1777`). The container root FS is " + "read-only, so /tmp is the only scratch space the agent and its " + "sub-agents get for repo clones and toolchain caches (bunx/npx/pip) " + "— a fan-out of several sub-agents exhausts the 1g default. A tmpfs " + "only consumes host RAM for the pages actually written, so raising " + "the ceiling costs nothing until it is used; those pages are still " + "charged to the container's `memory` cap, so raise both together. " + "Format: '1g', '4g', '512m'. Default when unset at every cascade " + "layer: '1g'.")
19620
19629
  }).optional().describe("Per-agent resource limits. Cascades through defaults → profile → " + "per-agent with per-field merge (agent wins on each field independently). " + "Any field left unset at every layer falls back to the hard-coded " + "per-profile defaults in src/agents/compose.ts."),
19621
19630
  experimental: exports_external.object({
19622
19631
  legacy_pty: exports_external.boolean().optional().describe("Opt out of the default tmux supervisor (#725) and run the agent under " + "the legacy PTY supervisor instead. Default: false (tmux is the default)."),
@@ -19709,7 +19718,8 @@ var AgentSchema = exports_external.object({
19709
19718
  memory: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/).optional(),
19710
19719
  memory_reservation: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/).optional(),
19711
19720
  pids_limit: exports_external.number().int().positive().optional(),
19712
- cpus: exports_external.number().positive().optional()
19721
+ cpus: exports_external.number().positive().optional(),
19722
+ tmp_size: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/, "tmp_size must be a Docker size string like '1g', '4g', '512m'").refine((v) => parseFloat(v) > 0, "tmp_size must be greater than zero").optional()
19713
19723
  }).optional()
19714
19724
  }).superRefine((agent, ctx) => {
19715
19725
  if (agent.dm_only !== true)
@@ -21123,7 +21133,7 @@ function allocateAgentUid(name) {
21123
21133
  }
21124
21134
 
21125
21135
  // src/build-info.ts
21126
- var VERSION = "0.19.24";
21136
+ var VERSION = "0.19.25";
21127
21137
 
21128
21138
  // src/cli/agent-config.ts
21129
21139
  import { join as join2 } from "node:path";
@@ -21216,6 +21226,27 @@ function assertPositive(value, label) {
21216
21226
  }
21217
21227
  }
21218
21228
 
21229
+ // src/setup/hindsight-pg-defaults.ts
21230
+ var HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION = 8 * 1024;
21231
+ var HINDSIGHT_PG_APP_ANON_MIB = 2560;
21232
+ var HINDSIGHT_PG_PAGE_CACHE_FLOOR_MIB = 2048;
21233
+ var HINDSIGHT_PG_SHARED_BUFFERS_BUDGET_MIB = HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION - HINDSIGHT_PG_APP_ANON_MIB - HINDSIGHT_PG_PAGE_CACHE_FLOOR_MIB;
21234
+ var HINDSIGHT_PG_DEFAULT_SHARED_BUFFERS_MIB = 1536;
21235
+ var HINDSIGHT_PG_DEFAULT_EFFECTIVE_CACHE_SIZE_MIB = 4096;
21236
+ function pgMib(mib) {
21237
+ return `${mib}MB`;
21238
+ }
21239
+ var HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE_ENV = "SWITCHROOM_HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE";
21240
+ var HINDSIGHT_PG_SHARED_BUFFERS_ENV = "SWITCHROOM_HINDSIGHT_PG_SHARED_BUFFERS";
21241
+ var HINDSIGHT_PG_DEFAULTS = [
21242
+ [
21243
+ HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE_ENV,
21244
+ pgMib(HINDSIGHT_PG_DEFAULT_EFFECTIVE_CACHE_SIZE_MIB)
21245
+ ],
21246
+ [HINDSIGHT_PG_SHARED_BUFFERS_ENV, pgMib(HINDSIGHT_PG_DEFAULT_SHARED_BUFFERS_MIB)]
21247
+ ];
21248
+ var HINDSIGHT_PG_ENV_KEYS = new Set(HINDSIGHT_PG_DEFAULTS.map(([k]) => k));
21249
+
21219
21250
  // src/setup/hindsight-perf-defaults.ts
21220
21251
  var HINDSIGHT_RERANKER_MAX_CANDIDATES_FOR_DERIVATION = 150;
21221
21252
  var HINDSIGHT_DEFAULT_RECALL_MAX_CANDIDATES_PER_SOURCE = Math.ceil(HINDSIGHT_RERANKER_MAX_CANDIDATES_FOR_DERIVATION * 0.4);
@@ -21230,6 +21261,15 @@ var HINDSIGHT_DEFAULT_RERANKER_LOCAL_BATCH_SIZE = 128;
21230
21261
  var HINDSIGHT_DEFAULT_LLM_STRICT_SCHEMA = "true";
21231
21262
  var HINDSIGHT_DEFAULT_LLM_MAX_RETRIES = 2;
21232
21263
  var HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_PARALLELISM = 2;
21264
+ var HINDSIGHT_DEFAULT_MAX_OBSERVATIONS_PER_SCOPE = 1000;
21265
+ var HINDSIGHT_DEFAULT_RERANKER_BUCKET_BATCHING = "true";
21266
+ var HINDSIGHT_DEFAULT_RERANKER_MAX_CANDIDATES = 150;
21267
+ var HINDSIGHT_DEFAULT_RERANKER_LOCAL_MAX_CONCURRENT = 4;
21268
+ var HINDSIGHT_DEFAULT_RECALL_MAX_CONCURRENT = 8;
21269
+ var HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S = 600;
21270
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND = 500;
21271
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_SLOT_LIMIT = 6;
21272
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS = 1;
21233
21273
  var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
21234
21274
  [
21235
21275
  "HINDSIGHT_API_RECALL_MAX_CANDIDATES_PER_SOURCE",
@@ -21247,6 +21287,42 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
21247
21287
  [
21248
21288
  "HINDSIGHT_API_CONSOLIDATION_LLM_PARALLELISM",
21249
21289
  String(HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_PARALLELISM)
21290
+ ],
21291
+ [
21292
+ "HINDSIGHT_API_MAX_OBSERVATIONS_PER_SCOPE",
21293
+ String(HINDSIGHT_DEFAULT_MAX_OBSERVATIONS_PER_SCOPE)
21294
+ ],
21295
+ [
21296
+ "HINDSIGHT_API_RERANKER_LOCAL_BUCKET_BATCHING",
21297
+ HINDSIGHT_DEFAULT_RERANKER_BUCKET_BATCHING
21298
+ ],
21299
+ [
21300
+ "HINDSIGHT_API_RERANKER_MAX_CANDIDATES",
21301
+ String(HINDSIGHT_DEFAULT_RERANKER_MAX_CANDIDATES)
21302
+ ],
21303
+ [
21304
+ "HINDSIGHT_API_RERANKER_LOCAL_MAX_CONCURRENT",
21305
+ String(HINDSIGHT_DEFAULT_RERANKER_LOCAL_MAX_CONCURRENT)
21306
+ ],
21307
+ [
21308
+ "HINDSIGHT_API_RECALL_MAX_CONCURRENT",
21309
+ String(HINDSIGHT_DEFAULT_RECALL_MAX_CONCURRENT)
21310
+ ],
21311
+ [
21312
+ "HINDSIGHT_API_REFLECT_WALL_TIMEOUT",
21313
+ String(HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S)
21314
+ ],
21315
+ [
21316
+ "HINDSIGHT_API_WORKER_CONSOLIDATION_MAX_SLOTS",
21317
+ String(HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS)
21318
+ ],
21319
+ [
21320
+ "HINDSIGHT_API_WORKER_CONSOLIDATION_SLOT_LIMIT",
21321
+ String(HINDSIGHT_DEFAULT_CONSOLIDATION_SLOT_LIMIT)
21322
+ ],
21323
+ [
21324
+ "HINDSIGHT_API_CONSOLIDATION_MAX_MEMORIES_PER_ROUND",
21325
+ String(HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND)
21250
21326
  ]
21251
21327
  ];
21252
21328
  var HINDSIGHT_PERF_DEFAULTS_GPU = [
@@ -21270,7 +21346,8 @@ var HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM = [
21270
21346
  ["HINDSIGHT_API_LLM_MAX_RETRIES", String(HINDSIGHT_DEFAULT_LLM_MAX_RETRIES)]
21271
21347
  ];
21272
21348
  var HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS = new Set([
21273
- "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY"
21349
+ "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY",
21350
+ "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP"
21274
21351
  ]);
21275
21352
  var HINDSIGHT_PERF_ENV_KEYS = new Set([
21276
21353
  ...[
@@ -21281,27 +21358,6 @@ var HINDSIGHT_PERF_ENV_KEYS = new Set([
21281
21358
  ...HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS
21282
21359
  ]);
21283
21360
 
21284
- // src/setup/hindsight-pg-defaults.ts
21285
- var HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION = 8 * 1024;
21286
- var HINDSIGHT_PG_APP_ANON_MIB = 2560;
21287
- var HINDSIGHT_PG_PAGE_CACHE_FLOOR_MIB = 2048;
21288
- var HINDSIGHT_PG_SHARED_BUFFERS_BUDGET_MIB = HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION - HINDSIGHT_PG_APP_ANON_MIB - HINDSIGHT_PG_PAGE_CACHE_FLOOR_MIB;
21289
- var HINDSIGHT_PG_DEFAULT_SHARED_BUFFERS_MIB = 1536;
21290
- var HINDSIGHT_PG_DEFAULT_EFFECTIVE_CACHE_SIZE_MIB = 4096;
21291
- function pgMib(mib) {
21292
- return `${mib}MB`;
21293
- }
21294
- var HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE_ENV = "SWITCHROOM_HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE";
21295
- var HINDSIGHT_PG_SHARED_BUFFERS_ENV = "SWITCHROOM_HINDSIGHT_PG_SHARED_BUFFERS";
21296
- var HINDSIGHT_PG_DEFAULTS = [
21297
- [
21298
- HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE_ENV,
21299
- pgMib(HINDSIGHT_PG_DEFAULT_EFFECTIVE_CACHE_SIZE_MIB)
21300
- ],
21301
- [HINDSIGHT_PG_SHARED_BUFFERS_ENV, pgMib(HINDSIGHT_PG_DEFAULT_SHARED_BUFFERS_MIB)]
21302
- ];
21303
- var HINDSIGHT_PG_ENV_KEYS = new Set(HINDSIGHT_PG_DEFAULTS.map(([k]) => k));
21304
-
21305
21361
  // src/setup/hindsight-context-budget.ts
21306
21362
  var HINDSIGHT_UPSTREAM_RETAIN_CHUNK_SIZE = 3000;
21307
21363
  var HINDSIGHT_RETAIN_MAX_COMPLETION_FLOOR = HINDSIGHT_UPSTREAM_RETAIN_CHUNK_SIZE + 72;
@@ -4164,7 +4164,11 @@ var init_schema = __esm(() => {
4164
4164
  recall: exports_external.object({
4165
4165
  max_memories: exports_external.number().int().min(0).optional().describe("Cap on the number of memories injected into the prompt by " + "auto-recall, regardless of token budget. Plugin default is 12. " + "0 disables the cap (all memories Hindsight returns are injected)."),
4166
4166
  cache_ttl_secs: exports_external.number().int().min(0).optional().describe("Per-session recall cache TTL in seconds. When > 0, identical " + "(prompt, bank) within the same session reuse the cached recall " + "result instead of round-tripping to Hindsight. 0 disables. " + "Default is 600 (10 min) for switchroom-managed agents."),
4167
- min_overlap: exports_external.number().min(0).max(1).optional().describe("Minimum containment token overlap [0.0–1.0] between the user " + "prompt and a memory's text for the memory to be injected. " + "A cheap FLOOR that removes candidates with (near-)zero lexical " + "relationship to the prompt — NOT a precision control: at the " + "recommended 0.10 the gate is near-passthrough, and the " + "effective precision control is the engine rerank plus the " + "max_memories head-slice. 0.0 disables (default — current " + "behaviour). Use 0.10; values at or above 0.20 measurably " + "starve recall — on production replay 0.20 leaves ~41.9% of " + "turns with NO memories at all, re-creating the bug #3541 " + "fixed. Observe the `overlap_dropped` field via " + "`switchroom memory recall-log`."),
4167
+ query_max_tokens: exports_external.number().int().min(0).optional().describe("Cap on the number of DISTINCT BM25 terms the recall hook may " + "put on the wire. `recallMaxQueryChars` bounds characters, which " + "is not the cost driver: Hindsight OR-joins every query token " + "into one tsquery and Postgres native FTS ranks the entire " + "matched set before the top-60 heapsort, so cost tracks TERMS. " + "An 800-char composed query is ~96 distinct terms and matched " + "119,510 of 135,565 rows on the `overlord` bank (14.0s for the " + "3-arm " + "BM25 UNION), past the per-bank timeout — 96.8% of that agent's " + "own-bank recalls returned nothing. Plugin default is 24 " + "(measured 48,433 rows / 2.7s on the same bank). Terms are " + "chosen recency-first (the latest turn beats prior context), " + "then by selectivity. 0 disables shaping (rollback lever)."),
4168
+ query_stop_terms: exports_external.array(exports_external.string().min(1).regex(/^[\w./-]+$/)).optional().describe("Extra terms dropped from the BM25 recall query, on top of the " + "built-in English stopword list. For BANK-SPECIFIC " + "high-document-frequency words a generic stoplist cannot know " + "about: on `overlord`, `switchroom` matches 20% of the bank and " + "`agent` another 20%, purely because that is what the corpus is " + "about, and each such term drags tens of thousands of rows into " + "the ranking. Defaults to []."),
4169
+ request_timeout_seconds: exports_external.number().int().min(1).optional().describe("Per-bank HTTP read timeout, in seconds, for one recall " + "request. Plugin default is 12, matching the UserPromptSubmit " + "hook ceiling; the shared `recallParallelDeadlineSeconds` (10) " + "is the tighter outer guard in the default configuration, so " + "this is a per-request safety net. Was a hardcoded 8 in the " + "plugin before #3757."),
4170
+ 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."),
4171
+ 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`."),
4168
4172
  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)."),
4169
4173
  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 an 8s timeout 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)."),
4170
4174
  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`."),
@@ -4389,7 +4393,7 @@ var init_schema = __esm(() => {
4389
4393
  reflect: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `reflect` LLM op (synthesis / mental-model " + "refresh). Emits `HINDSIGHT_API_REFLECT_LLM_*`. Absent → uses global."),
4390
4394
  consolidation: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `consolidation` LLM op (background memory " + "merge). Emits `HINDSIGHT_API_CONSOLIDATION_LLM_*`. Absent → global.")
4391
4395
  }).optional().describe("LLM knob for the hindsight container. The flat `provider`/`model` set " + "the global default (backward-compatible); optional `retain`/`reflect`/" + "`consolidation` blocks override individual ops. All fields optional; " + "unset fields fall back to the hard-coded defaults."),
4392
- env: exports_external.record(exports_external.union([exports_external.string(), exports_external.number(), exports_external.boolean()])).optional().describe("Operator overrides for switchroom's capability-gated Hindsight " + "performance defaults. Only the keys switchroom actually manages are " + "honoured (`HINDSIGHT_PERF_ENV_KEYS` in " + "src/setup/hindsight-perf-defaults.ts: RERANKER_LOCAL_FP16, " + "RERANKER_LOCAL_BATCH_SIZE, LLM_MAX_CONCURRENT, " + "RETAIN/CONSOLIDATION_LLM_MAX_CONCURRENT, LLM_STRICT_SCHEMA, " + "LLM_MAX_RETRIES, CONSOLIDATION_LLM_PARALLELISM, " + "RECALL_MAX_CANDIDATES_PER_SOURCE, LINK_EXPANSION_PER_ENTITY_LIMIT, " + "LINK_EXPANSION_TIMEOUT, LLM_REASONING_EFFORT), the override-only keys " + "switchroom manages but ships NO default for " + "(`HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS`: " + "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY — a per-deployment " + "`bank-pattern:priority,...` map; unset means upstream's flat " + "created_at FIFO across banks), plus the " + "embedded-PostgreSQL (pg0) sizing keys switchroom manages in " + "src/setup/hindsight-pg-defaults.ts (`HINDSIGHT_PG_ENV_KEYS`: " + "SWITCHROOM_HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE, " + "SWITCHROOM_HINDSIGHT_PG_SHARED_BUFFERS — a postgres size string such " + "as `4GB`, or the sentinel `off` to leave pg0's own default for that " + "one knob). A value set here " + "REPLACES switchroom's default and is emitted even when the gating " + "capability is absent, so an operator can always force a knob. Other " + "`HINDSIGHT_API_*` keys are deliberately IGNORED — a blanket " + "passthrough would collide with the vars startHindsight() derives " + "itself (HINDSIGHT_API_PORT, the retain token/deadline budget).")
4396
+ env: exports_external.record(exports_external.union([exports_external.string(), exports_external.number(), exports_external.boolean()])).optional().describe("Operator overrides for switchroom's capability-gated Hindsight " + "performance defaults. Only the keys switchroom actually manages are " + "honoured (`HINDSIGHT_PERF_ENV_KEYS` in " + "src/setup/hindsight-perf-defaults.ts: RERANKER_LOCAL_FP16, " + "RERANKER_LOCAL_BATCH_SIZE, LLM_MAX_CONCURRENT, " + "RETAIN/CONSOLIDATION_LLM_MAX_CONCURRENT, LLM_STRICT_SCHEMA, " + "LLM_MAX_RETRIES, CONSOLIDATION_LLM_PARALLELISM, " + "MAX_OBSERVATIONS_PER_SCOPE, " + "RECALL_MAX_CANDIDATES_PER_SOURCE, LINK_EXPANSION_PER_ENTITY_LIMIT, " + "LINK_EXPANSION_TIMEOUT, LLM_REASONING_EFFORT, " + "RERANKER_LOCAL_BUCKET_BATCHING, RERANKER_MAX_CANDIDATES, " + "RERANKER_LOCAL_MAX_CONCURRENT, RECALL_MAX_CONCURRENT, " + "REFLECT_WALL_TIMEOUT, WORKER_CONSOLIDATION_MAX_SLOTS, " + "WORKER_CONSOLIDATION_SLOT_LIMIT, " + "CONSOLIDATION_MAX_MEMORIES_PER_ROUND), the override-only keys " + "switchroom manages but ships NO default for " + "(`HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS`: " + "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY — a per-deployment " + "`bank-pattern:priority,...` map; unset means upstream's flat " + "created_at FIFO across banks; and " + "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP — the rollback knob for " + "switchroom's CE-saturation damping patch, a float; >= ~0.65 backs the " + "damping out entirely, unset means the patch's own derived gap), plus the " + "embedded-PostgreSQL (pg0) sizing keys switchroom manages in " + "src/setup/hindsight-pg-defaults.ts (`HINDSIGHT_PG_ENV_KEYS`: " + "SWITCHROOM_HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE, " + "SWITCHROOM_HINDSIGHT_PG_SHARED_BUFFERS — a postgres size string such " + "as `4GB`, or the sentinel `off` to leave pg0's own default for that " + "one knob). A value set here " + "REPLACES switchroom's default and is emitted even when the gating " + "capability is absent, so an operator can always force a knob. Other " + "`HINDSIGHT_API_*` keys are deliberately IGNORED — a blanket " + "passthrough would collide with the vars startHindsight() derives " + "itself (HINDSIGHT_API_PORT, the retain token/deadline budget).")
4393
4397
  });
4394
4398
  MicrosoftWorkspaceConfigSchema = exports_external.object({
4395
4399
  microsoft_client_id: exports_external.string().min(1).optional().describe("Microsoft OAuth application (client) ID from Entra portal " + "(literal string or vault reference e.g. " + "'vault:microsoft-oauth-client-id'). OPTIONAL — omit it to use " + "switchroom's shipped default Microsoft app (zero-config). " + "Set it only to bring your own Entra app (BYO)."),
@@ -4525,7 +4529,11 @@ var init_schema = __esm(() => {
4525
4529
  recall: exports_external.object({
4526
4530
  max_memories: exports_external.number().int().min(0).optional(),
4527
4531
  cache_ttl_secs: exports_external.number().int().min(0).optional(),
4528
- min_overlap: exports_external.number().min(0).max(1).optional(),
4532
+ query_max_tokens: exports_external.number().int().min(0).optional(),
4533
+ query_stop_terms: exports_external.array(exports_external.string().min(1).regex(/^[\w./-]+$/)).optional(),
4534
+ request_timeout_seconds: exports_external.number().int().min(1).optional(),
4535
+ own_bank_min_slots: exports_external.number().int().min(0).optional(),
4536
+ additional_bank_min_slots: exports_external.number().int().min(0).optional(),
4529
4537
  additional_banks: exports_external.array(exports_external.string()).optional(),
4530
4538
  sender_banks: exports_external.record(exports_external.string(), exports_external.string()).optional()
4531
4539
  }).optional()
@@ -4559,7 +4567,8 @@ var init_schema = __esm(() => {
4559
4567
  memory: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/, "memory must be a Docker size string like '6g', '512m', '1.5g'").optional().describe("Hard memory cap (Docker `mem_limit` → cgroup memory.max). When the " + "container exceeds this, the kernel OOM-kills processes in the cgroup. " + "Format: '6g', '1.5g', '512m'. When unset at every cascade layer the " + "compose generator falls back to the hard-coded per-profile defaults " + "in src/agents/compose.ts (klanker 6g, coding 2g, conversational 1.5g, " + "lightweight 1g, default 1.5g)."),
4560
4568
  memory_reservation: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/, "memory_reservation must be a Docker size string like '4g', '256m'").optional().describe("Soft memory floor (Docker `mem_reservation` → cgroup memory.low). " + "Under host-wide memory pressure, the kernel protects at least this " + "much from being reclaimed from the cgroup. Must be ≤ memory. Use to " + "keep an agent RAM-resident when the host has other tenants that " + "might push the box (Coolify apps, build jobs). Default: unset."),
4561
4569
  pids_limit: exports_external.number().int().positive().optional().describe("Max processes the cgroup can spawn (cgroup pids.max). Prevents " + "fork bombs and runaway test runners. Counts every process in the " + "cgroup including bash subprocesses, claude itself, sidecars, and " + "any test/build worker. A typical agent at idle uses ~30 PIDs; " + "`npm test`-style workloads can spike to 200+. Set generously " + "(2000 is a comfortable cap for test-running agents). Default: " + "unset (no cgroup pid cap)."),
4562
- cpus: exports_external.number().positive().optional().describe("CPU quota (Docker `cpus`). Fractional values OK (e.g. 0.5, 2.0). " + "When unset at every cascade layer the compose generator falls " + "back to the per-profile default (klanker/coding 2.0, default 1.0, " + "lightweight 0.5).")
4570
+ cpus: exports_external.number().positive().optional().describe("CPU quota (Docker `cpus`). Fractional values OK (e.g. 0.5, 2.0). " + "When unset at every cascade layer the compose generator falls " + "back to the per-profile default (klanker/coding 2.0, default 1.0, " + "lightweight 0.5)."),
4571
+ tmp_size: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/, "tmp_size must be a Docker size string like '1g', '4g', '512m'").refine((v) => parseFloat(v) > 0, "tmp_size must be greater than zero").optional().describe("Size of the agent container's RAM-backed `/tmp` (Docker " + "`tmpfs: - /tmp:size=<this>,mode=1777`). The container root FS is " + "read-only, so /tmp is the only scratch space the agent and its " + "sub-agents get for repo clones and toolchain caches (bunx/npx/pip) " + "— a fan-out of several sub-agents exhausts the 1g default. A tmpfs " + "only consumes host RAM for the pages actually written, so raising " + "the ceiling costs nothing until it is used; those pages are still " + "charged to the container's `memory` cap, so raise both together. " + "Format: '1g', '4g', '512m'. Default when unset at every cascade " + "layer: '1g'.")
4563
4572
  }).optional().describe("Per-agent resource limits. Cascades through defaults → profile → " + "per-agent with per-field merge (agent wins on each field independently). " + "Any field left unset at every layer falls back to the hard-coded " + "per-profile defaults in src/agents/compose.ts."),
4564
4573
  experimental: exports_external.object({
4565
4574
  legacy_pty: exports_external.boolean().optional().describe("Opt out of the default tmux supervisor (#725) and run the agent under " + "the legacy PTY supervisor instead. Default: false (tmux is the default)."),
@@ -4652,7 +4661,8 @@ var init_schema = __esm(() => {
4652
4661
  memory: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/).optional(),
4653
4662
  memory_reservation: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/).optional(),
4654
4663
  pids_limit: exports_external.number().int().positive().optional(),
4655
- cpus: exports_external.number().positive().optional()
4664
+ cpus: exports_external.number().positive().optional(),
4665
+ tmp_size: exports_external.string().regex(/^\d+(\.\d+)?[kmgKMG]?$/, "tmp_size must be a Docker size string like '1g', '4g', '512m'").refine((v) => parseFloat(v) > 0, "tmp_size must be greater than zero").optional()
4656
4666
  }).optional()
4657
4667
  }).superRefine((agent, ctx) => {
4658
4668
  if (agent.dm_only !== true)
@@ -19194,6 +19204,27 @@ function assertPositive(value, label) {
19194
19204
  // src/setup/host-capabilities.ts
19195
19205
  init_paths();
19196
19206
 
19207
+ // src/setup/hindsight-pg-defaults.ts
19208
+ var HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION = 8 * 1024;
19209
+ var HINDSIGHT_PG_APP_ANON_MIB = 2560;
19210
+ var HINDSIGHT_PG_PAGE_CACHE_FLOOR_MIB = 2048;
19211
+ var HINDSIGHT_PG_SHARED_BUFFERS_BUDGET_MIB = HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION - HINDSIGHT_PG_APP_ANON_MIB - HINDSIGHT_PG_PAGE_CACHE_FLOOR_MIB;
19212
+ var HINDSIGHT_PG_DEFAULT_SHARED_BUFFERS_MIB = 1536;
19213
+ var HINDSIGHT_PG_DEFAULT_EFFECTIVE_CACHE_SIZE_MIB = 4096;
19214
+ function pgMib(mib) {
19215
+ return `${mib}MB`;
19216
+ }
19217
+ var HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE_ENV = "SWITCHROOM_HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE";
19218
+ var HINDSIGHT_PG_SHARED_BUFFERS_ENV = "SWITCHROOM_HINDSIGHT_PG_SHARED_BUFFERS";
19219
+ var HINDSIGHT_PG_DEFAULTS = [
19220
+ [
19221
+ HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE_ENV,
19222
+ pgMib(HINDSIGHT_PG_DEFAULT_EFFECTIVE_CACHE_SIZE_MIB)
19223
+ ],
19224
+ [HINDSIGHT_PG_SHARED_BUFFERS_ENV, pgMib(HINDSIGHT_PG_DEFAULT_SHARED_BUFFERS_MIB)]
19225
+ ];
19226
+ var HINDSIGHT_PG_ENV_KEYS = new Set(HINDSIGHT_PG_DEFAULTS.map(([k]) => k));
19227
+
19197
19228
  // src/setup/hindsight-perf-defaults.ts
19198
19229
  var HINDSIGHT_RERANKER_MAX_CANDIDATES_FOR_DERIVATION = 150;
19199
19230
  var HINDSIGHT_DEFAULT_RECALL_MAX_CANDIDATES_PER_SOURCE = Math.ceil(HINDSIGHT_RERANKER_MAX_CANDIDATES_FOR_DERIVATION * 0.4);
@@ -19208,6 +19239,15 @@ var HINDSIGHT_DEFAULT_RERANKER_LOCAL_BATCH_SIZE = 128;
19208
19239
  var HINDSIGHT_DEFAULT_LLM_STRICT_SCHEMA = "true";
19209
19240
  var HINDSIGHT_DEFAULT_LLM_MAX_RETRIES = 2;
19210
19241
  var HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_PARALLELISM = 2;
19242
+ var HINDSIGHT_DEFAULT_MAX_OBSERVATIONS_PER_SCOPE = 1000;
19243
+ var HINDSIGHT_DEFAULT_RERANKER_BUCKET_BATCHING = "true";
19244
+ var HINDSIGHT_DEFAULT_RERANKER_MAX_CANDIDATES = 150;
19245
+ var HINDSIGHT_DEFAULT_RERANKER_LOCAL_MAX_CONCURRENT = 4;
19246
+ var HINDSIGHT_DEFAULT_RECALL_MAX_CONCURRENT = 8;
19247
+ var HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S = 600;
19248
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND = 500;
19249
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_SLOT_LIMIT = 6;
19250
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS = 1;
19211
19251
  var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
19212
19252
  [
19213
19253
  "HINDSIGHT_API_RECALL_MAX_CANDIDATES_PER_SOURCE",
@@ -19225,6 +19265,42 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
19225
19265
  [
19226
19266
  "HINDSIGHT_API_CONSOLIDATION_LLM_PARALLELISM",
19227
19267
  String(HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_PARALLELISM)
19268
+ ],
19269
+ [
19270
+ "HINDSIGHT_API_MAX_OBSERVATIONS_PER_SCOPE",
19271
+ String(HINDSIGHT_DEFAULT_MAX_OBSERVATIONS_PER_SCOPE)
19272
+ ],
19273
+ [
19274
+ "HINDSIGHT_API_RERANKER_LOCAL_BUCKET_BATCHING",
19275
+ HINDSIGHT_DEFAULT_RERANKER_BUCKET_BATCHING
19276
+ ],
19277
+ [
19278
+ "HINDSIGHT_API_RERANKER_MAX_CANDIDATES",
19279
+ String(HINDSIGHT_DEFAULT_RERANKER_MAX_CANDIDATES)
19280
+ ],
19281
+ [
19282
+ "HINDSIGHT_API_RERANKER_LOCAL_MAX_CONCURRENT",
19283
+ String(HINDSIGHT_DEFAULT_RERANKER_LOCAL_MAX_CONCURRENT)
19284
+ ],
19285
+ [
19286
+ "HINDSIGHT_API_RECALL_MAX_CONCURRENT",
19287
+ String(HINDSIGHT_DEFAULT_RECALL_MAX_CONCURRENT)
19288
+ ],
19289
+ [
19290
+ "HINDSIGHT_API_REFLECT_WALL_TIMEOUT",
19291
+ String(HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S)
19292
+ ],
19293
+ [
19294
+ "HINDSIGHT_API_WORKER_CONSOLIDATION_MAX_SLOTS",
19295
+ String(HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS)
19296
+ ],
19297
+ [
19298
+ "HINDSIGHT_API_WORKER_CONSOLIDATION_SLOT_LIMIT",
19299
+ String(HINDSIGHT_DEFAULT_CONSOLIDATION_SLOT_LIMIT)
19300
+ ],
19301
+ [
19302
+ "HINDSIGHT_API_CONSOLIDATION_MAX_MEMORIES_PER_ROUND",
19303
+ String(HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND)
19228
19304
  ]
19229
19305
  ];
19230
19306
  var HINDSIGHT_PERF_DEFAULTS_GPU = [
@@ -19248,7 +19324,8 @@ var HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM = [
19248
19324
  ["HINDSIGHT_API_LLM_MAX_RETRIES", String(HINDSIGHT_DEFAULT_LLM_MAX_RETRIES)]
19249
19325
  ];
19250
19326
  var HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS = new Set([
19251
- "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY"
19327
+ "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY",
19328
+ "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP"
19252
19329
  ]);
19253
19330
  var HINDSIGHT_PERF_ENV_KEYS = new Set([
19254
19331
  ...[
@@ -19259,27 +19336,6 @@ var HINDSIGHT_PERF_ENV_KEYS = new Set([
19259
19336
  ...HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS
19260
19337
  ]);
19261
19338
 
19262
- // src/setup/hindsight-pg-defaults.ts
19263
- var HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION = 8 * 1024;
19264
- var HINDSIGHT_PG_APP_ANON_MIB = 2560;
19265
- var HINDSIGHT_PG_PAGE_CACHE_FLOOR_MIB = 2048;
19266
- var HINDSIGHT_PG_SHARED_BUFFERS_BUDGET_MIB = HINDSIGHT_PG_MEM_LIMIT_MIB_FOR_DERIVATION - HINDSIGHT_PG_APP_ANON_MIB - HINDSIGHT_PG_PAGE_CACHE_FLOOR_MIB;
19267
- var HINDSIGHT_PG_DEFAULT_SHARED_BUFFERS_MIB = 1536;
19268
- var HINDSIGHT_PG_DEFAULT_EFFECTIVE_CACHE_SIZE_MIB = 4096;
19269
- function pgMib(mib) {
19270
- return `${mib}MB`;
19271
- }
19272
- var HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE_ENV = "SWITCHROOM_HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE";
19273
- var HINDSIGHT_PG_SHARED_BUFFERS_ENV = "SWITCHROOM_HINDSIGHT_PG_SHARED_BUFFERS";
19274
- var HINDSIGHT_PG_DEFAULTS = [
19275
- [
19276
- HINDSIGHT_PG_EFFECTIVE_CACHE_SIZE_ENV,
19277
- pgMib(HINDSIGHT_PG_DEFAULT_EFFECTIVE_CACHE_SIZE_MIB)
19278
- ],
19279
- [HINDSIGHT_PG_SHARED_BUFFERS_ENV, pgMib(HINDSIGHT_PG_DEFAULT_SHARED_BUFFERS_MIB)]
19280
- ];
19281
- var HINDSIGHT_PG_ENV_KEYS = new Set(HINDSIGHT_PG_DEFAULTS.map(([k]) => k));
19282
-
19283
19339
  // src/setup/hindsight-context-budget.ts
19284
19340
  var HINDSIGHT_UPSTREAM_RETAIN_CHUNK_SIZE = 3000;
19285
19341
  var HINDSIGHT_RETAIN_MAX_COMPLETION_FLOOR = HINDSIGHT_UPSTREAM_RETAIN_CHUNK_SIZE + 72;