switchroom 0.19.27 → 0.19.28

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 (32) hide show
  1. package/dist/agent-scheduler/index.js +5 -2
  2. package/dist/auth-broker/index.js +129 -8
  3. package/dist/cli/autoaccept-poll.js +225 -17
  4. package/dist/cli/notion-write-pretool.mjs +5 -2
  5. package/dist/cli/switchroom.js +796 -35
  6. package/dist/host-control/main.js +130 -9
  7. package/dist/vault/approvals/kernel-server.js +129 -8
  8. package/dist/vault/broker/server.js +129 -8
  9. package/package.json +3 -2
  10. package/profiles/_base/start.sh.hbs +70 -15
  11. package/telegram-plugin/dist/bridge/bridge.js +1 -0
  12. package/telegram-plugin/dist/gateway/gateway.js +568 -49
  13. package/telegram-plugin/dist/server.js +1 -0
  14. package/telegram-plugin/edit-flood-fuse.ts +230 -27
  15. package/telegram-plugin/gateway/callback-query-handlers.ts +6 -0
  16. package/telegram-plugin/gateway/gateway.ts +9 -2
  17. package/telegram-plugin/gateway/mcp-failure-hook.ts +74 -0
  18. package/telegram-plugin/inline-keyboard-callbacks.ts +202 -21
  19. package/telegram-plugin/mcp-credential-failure.ts +459 -0
  20. package/telegram-plugin/operator-events.ts +38 -0
  21. package/telegram-plugin/tests/edit-flood-fuse-ban-awareness.test.ts +58 -1
  22. package/telegram-plugin/tests/edit-flood-fuse-reply-reserve.test.ts +340 -0
  23. package/telegram-plugin/tests/finalize-callback-flood-policy.test.ts +298 -0
  24. package/telegram-plugin/tests/finalize-callback.test.ts +41 -8
  25. package/telegram-plugin/tests/mcp-credential-failure.test.ts +310 -0
  26. package/vendor/hindsight-memory/scripts/drain_pending.py +433 -11
  27. package/vendor/hindsight-memory/scripts/lib/pending.py +193 -28
  28. package/vendor/hindsight-memory/scripts/tests/test_drain_circuit_breaker.py +401 -0
  29. package/vendor/hindsight-memory/scripts/tests/test_drain_serialisation.py +286 -0
  30. package/vendor/hindsight-memory/scripts/tests/test_pending_drops.py +817 -8
  31. package/vendor/hindsight-memory/settings.json +1 -1
  32. package/vendor/hindsight-memory/tests/test_hooks.py +11 -2
@@ -19461,7 +19461,10 @@ var LiteLLMConfigSchema = exports_external.object({
19461
19461
  admin_key: exports_external.string().optional().describe("LiteLLM master/admin key used at apply time to provision the team + " + "virtual key. Supports a vault reference (e.g. " + "'vault:litellm/master-key') — resolution happens at apply time via " + "the vault-broker. Never injected into the agent container."),
19462
19462
  team: exports_external.string().optional().describe("LiteLLM team alias the per-agent key is created under. Defaults to " + "'switchroom' (applied in code, not as a schema default)."),
19463
19463
  small_fast_model: exports_external.string().optional().describe("Model id exported as ANTHROPIC_SMALL_FAST_MODEL for the claude CLI's " + "background/fast lane, e.g. 'claude-haiku-4-5-20251001'."),
19464
- tags: exports_external.record(exports_external.string(), exports_external.string()).optional().describe("Extra key/value metadata tags attached to the provisioned LiteLLM " + "virtual key. Merged per-key across cascade layers (agent wins).")
19464
+ tags: exports_external.record(exports_external.string(), exports_external.string()).optional().describe("Extra key/value metadata tags attached to the provisioned LiteLLM " + "virtual key. Merged per-key across cascade layers (agent wins)."),
19465
+ max_budget: exports_external.number().positive().optional().describe("HARD spend cap in USD for this agent's virtual key over one " + "`budget_duration` window. LiteLLM refuses the request once the key's " + "tracked spend exceeds it, so a runaway loop costs at most this much " + "before it is stopped. Defaults to " + "DEFAULT_KEY_MAX_BUDGET_USD (see src/litellm/budget.ts) — deliberately " + "conservative; raise it per-agent rather than removing it. Set 0 or " + "omit `budget_duration` at your own risk: an uncapped key is only as " + "bounded as the upstream account balance."),
19466
+ soft_budget: exports_external.number().positive().optional().describe("ADVISORY spend threshold in USD. LiteLLM keeps serving past it and " + "raises a budget alert instead. Must be < max_budget. NOTE: LiteLLM " + "accepts soft_budget only on POST /key/generate (GenerateKeyRequest); " + "UpdateKeyRequest does NOT carry it, so changing this value only takes " + "effect on a key that is (re)generated, not on an existing one."),
19467
+ budget_duration: exports_external.string().regex(/^\d+(s|m|h|d|mo)$/, "budget_duration must be a LiteLLM duration like '30d', '24h', '1mo'").optional().describe("Rolling window the budget resets on, in LiteLLM duration syntax " + "('30d', '24h', '1mo'). Defaults to DEFAULT_KEY_BUDGET_DURATION. " + "WITHOUT a duration LiteLLM treats max_budget as a LIFETIME cap that " + "never resets — the key silently dies for good once it is hit.")
19465
19468
  }).optional().describe("LiteLLM routing config — opt-in per-agent virtual-key auto-provisioning " + "+ routing env. Default OFF. See LiteLLMConfigSchema doc for the full flow.");
19466
19469
  var HindsightPerOpLlmSchema = exports_external.object({
19467
19470
  model: exports_external.string().min(1).optional().describe("Per-op model (upstream `HINDSIGHT_API_<OP>_LLM_MODEL`). Absent → " + "inherit the global `hindsight.llm.model`."),
@@ -19480,7 +19483,7 @@ var HindsightConfigSchema = exports_external.object({
19480
19483
  reflect: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `reflect` LLM op (synthesis / mental-model " + "refresh). Emits `HINDSIGHT_API_REFLECT_LLM_*`. Absent → uses global."),
19481
19484
  consolidation: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `consolidation` LLM op (background memory " + "merge). Emits `HINDSIGHT_API_CONSOLIDATION_LLM_*`. Absent → global.")
19482
19485
  }).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."),
19483
- 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).")
19486
+ 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, RECENCY_DECAY_FUNCTION, " + "RECENCY_DECAY_HALFLIFE_DAYS — switchroom defaults recall's recency " + "curve to `exponential` with a 30-day half-life so a fact retained " + "today outranks a stale one, instead of upstream's near-flat " + "linear/365-day window), 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; and " + "HINDSIGHT_API_RECENCY_DECAY_LINEAR_WINDOW_DAYS — only read when the " + "decay function is `linear`, so switchroom ships no default for it but " + "still honours an operator who flips the function back; and " + "HINDSIGHT_API_WORKER_MAX_SLOTS — the worker poller's TOTAL in-flight " + "task budget, the pool WORKER_CONSOLIDATION_MAX_SLOTS reserves out of; " + "unset means upstream's own default), 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).")
19484
19487
  });
19485
19488
  var MicrosoftWorkspaceConfigSchema = exports_external.object({
19486
19489
  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)."),
@@ -21192,7 +21195,7 @@ function allocateAgentUid(name) {
21192
21195
  }
21193
21196
 
21194
21197
  // src/build-info.ts
21195
- var VERSION = "0.19.27";
21198
+ var VERSION = "0.19.28";
21196
21199
 
21197
21200
  // src/setup/hindsight-recall-tunables.ts
21198
21201
  var RECALL_DEADLINE_HEADROOM_SECONDS = 2;
@@ -21320,7 +21323,13 @@ var HINDSIGHT_DEFAULT_LINK_EXPANSION_TIMEOUT_S = 2;
21320
21323
  var HINDSIGHT_DEFAULT_LLM_REASONING_EFFORT = "low";
21321
21324
  var HINDSIGHT_DEFAULT_LLM_MAX_CONCURRENT = 4;
21322
21325
  var HINDSIGHT_DEFAULT_RETAIN_LLM_MAX_CONCURRENT = 1;
21323
- var HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_MAX_CONCURRENT = 1;
21326
+ function hindsightConsolidationLlmMaxConcurrentDefault(globalMaxConcurrent = HINDSIGHT_DEFAULT_LLM_MAX_CONCURRENT, retainMaxConcurrent = HINDSIGHT_DEFAULT_RETAIN_LLM_MAX_CONCURRENT) {
21327
+ const globalCap = Number.isFinite(globalMaxConcurrent) && globalMaxConcurrent >= 1 ? Math.floor(globalMaxConcurrent) : HINDSIGHT_DEFAULT_LLM_MAX_CONCURRENT;
21328
+ const retainCap = Number.isFinite(retainMaxConcurrent) && retainMaxConcurrent >= 0 ? Math.floor(retainMaxConcurrent) : HINDSIGHT_DEFAULT_RETAIN_LLM_MAX_CONCURRENT;
21329
+ const headroomBound = Math.max(1, globalCap - 1);
21330
+ return Math.min(headroomBound, Math.max(1, globalCap - retainCap - 1));
21331
+ }
21332
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_MAX_CONCURRENT = hindsightConsolidationLlmMaxConcurrentDefault();
21324
21333
  var HINDSIGHT_DEFAULT_RERANKER_LOCAL_FP16 = "true";
21325
21334
  var HINDSIGHT_DEFAULT_RERANKER_LOCAL_BATCH_SIZE = 128;
21326
21335
  var HINDSIGHT_DEFAULT_LLM_STRICT_SCHEMA = "true";
@@ -21335,6 +21344,8 @@ var HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S = 600;
21335
21344
  var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND = 500;
21336
21345
  var HINDSIGHT_DEFAULT_CONSOLIDATION_SLOT_LIMIT = 6;
21337
21346
  var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS = 1;
21347
+ var HINDSIGHT_DEFAULT_RECENCY_DECAY_FUNCTION = "exponential";
21348
+ var HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS = 30;
21338
21349
  var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
21339
21350
  [
21340
21351
  "HINDSIGHT_API_RECALL_MAX_CANDIDATES_PER_SOURCE",
@@ -21388,6 +21399,14 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
21388
21399
  [
21389
21400
  "HINDSIGHT_API_CONSOLIDATION_MAX_MEMORIES_PER_ROUND",
21390
21401
  String(HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND)
21402
+ ],
21403
+ [
21404
+ "HINDSIGHT_API_RECENCY_DECAY_FUNCTION",
21405
+ HINDSIGHT_DEFAULT_RECENCY_DECAY_FUNCTION
21406
+ ],
21407
+ [
21408
+ "HINDSIGHT_API_RECENCY_DECAY_HALFLIFE_DAYS",
21409
+ String(HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS)
21391
21410
  ]
21392
21411
  ];
21393
21412
  var HINDSIGHT_PERF_DEFAULTS_GPU = [
@@ -21412,7 +21431,9 @@ var HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM = [
21412
21431
  ];
21413
21432
  var HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS = new Set([
21414
21433
  "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY",
21415
- "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP"
21434
+ "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP",
21435
+ "HINDSIGHT_API_RECENCY_DECAY_LINEAR_WINDOW_DAYS",
21436
+ "HINDSIGHT_API_WORKER_MAX_SLOTS"
21416
21437
  ]);
21417
21438
  var HINDSIGHT_PERF_ENV_KEYS = new Set([
21418
21439
  ...[
@@ -21478,6 +21499,16 @@ var DEFAULT_RETAIN_MISSION = `Extract durable facts that will still be true and
21478
21499
  ` + `- Hindsight's own errors, retries, backlogs, or internal state — the memory
21479
21500
  ` + ` system's self-reports are not memories.
21480
21501
  ` + `- Restatements of the user's current request or the task in progress.
21502
+ ` + `- Volatile state written as a timeless assertion. A version, count, size,
21503
+ ` + ` backlog, status, or any "X is running Y" / "X is at Y" / "X is currently Y"
21504
+ ` + ` claim is true only at the instant it was said. Concretely, never produce a
21505
+ ` + ` fact whose text resembles any of these: "Switchroom fleet is running image
21506
+ ` + ` version v0.18.19", "The switchroom repo is at /path/to/fleet, version
21507
+ ` + ` v0.19.5", "Bank overlord has 43155 pending consolidations", "The build is
21508
+ ` + ` currently green". If the claim is worth keeping, put the date INSIDE the
21509
+ ` + ` fact text ("As of 2026-07-19 the fleet was running v0.18.19"); if you
21510
+ ` + ` cannot date it, drop it. An undated one is recalled forever as though it
21511
+ ` + ` were still true, which is worse than not remembering it at all.
21481
21512
  ` + `- Transient state (unread counts, build status, what is running right now) unless
21482
21513
  ` + ` the fact is explicitly dated, in which case record it as a dated observation.
21483
21514
  ` + `- Greetings, acknowledgements, and routine operational chatter.
@@ -21499,18 +21530,108 @@ var SUPERSEDED_RETAIN_MISSIONS = [
21499
21530
  ` + "- 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.
21500
21531
  ` + `- Greetings, acknowledgements, and routine operational chatter.
21501
21532
 
21502
- ` + "If a candidate fact matches an exclusion, drop it rather than rewording " + "it. If nothing durable remains, return an empty facts list."
21533
+ ` + "If a candidate fact matches an exclusion, drop it rather than rewording " + "it. If nothing durable remains, return an empty facts list.",
21534
+ `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.
21535
+ ` + `
21536
+ ` + `A TOOL RESULT IS NOT A FACT. Before extracting, ask: is the subject of this
21537
+ ` + `candidate a file path, a command/process/agent/session id, a temp directory, or
21538
+ ` + `the location where some output was written? If yes, drop it — it is transcript
21539
+ ` + `exhaust, not memory.
21540
+ ` + `
21541
+ ` + `NEVER extract:
21542
+ ` + `- Tool results verbatim or paraphrased. Concretely, never produce a fact whose
21543
+ ` + ` text resembles any of these: "File created successfully at /path/to/file",
21544
+ ` + ` "A background command with ID bctz4yskm is running, and its output will be
21545
+ ` + ` written to /tmp/...", "Async agent a745598ba84e71df1 was launched successfully
21546
+ ` + ` and is running in the background", "User executed a Bash command to sleep for
21547
+ ` + ` 200 seconds", "The assistant used grep to locate 'truncateSync' in src/foo.ts".
21548
+ ` + `- Anything mentioning a path under /tmp, a scratchpad directory, or a .tmp file.
21549
+ ` + `- Agent tool-use traces or narration of what the assistant did (e.g. "the
21550
+ ` + ` assistant used X to query Y", "ran a search", "sent the message").
21551
+ ` + `- In-flight workflow/process narration (a sub-task started, paused, or is still
21552
+ ` + ` running) — retain the outcome only once the task completes or a decision is made.
21553
+ ` + `- Operation, request, batch, agent, command or session IDs, UUIDs, hashes, or error codes.
21554
+ ` + `- Slash commands the user typed and their effects (e.g. "User issued /clear to
21555
+ ` + ` reset assistant state").
21556
+ ` + `- Hindsight's own errors, retries, backlogs, or internal state — the memory
21557
+ ` + ` system's self-reports are not memories.
21558
+ ` + `- Restatements of the user's current request or the task in progress.
21559
+ ` + `- Transient state (unread counts, build status, what is running right now) unless
21560
+ ` + ` the fact is explicitly dated, in which case record it as a dated observation.
21561
+ ` + `- Greetings, acknowledgements, and routine operational chatter.
21562
+ ` + `
21563
+ ` + `If a candidate fact matches an exclusion, drop it rather than rewording it. If
21564
+ ` + "nothing durable remains, return an empty facts list."
21565
+ ];
21566
+ var DEFAULT_OBSERVATIONS_MISSION = `Synthesise durable, standing knowledge about the people, projects, and systems this agent works with: preferences and standing rules, roles and relationships, skills and recurring patterns, technical and operational decisions with their rationale, and the state of long-running work once it lands.
21567
+ ` + `
21568
+ ` + `The test is durability, not notability: an observation must still be worth reading weeks from now. A single dated event belongs in an observation only when it establishes or changes a standing fact.
21569
+ ` + `
21570
+ ` + `Do NOT synthesise observations from:
21571
+ ` + `- Transcript exhaust — tool calls and their results, file paths, temp or scratchpad directories, where some output was written, or narration of what an assistant did.
21572
+ ` + `- Identifiers with no standing meaning: session, agent, request, batch or command IDs, UUIDs, hashes, error codes.
21573
+ ` + `- In-flight process narration — a task started, paused, or still running. Record the outcome once it lands, not the running state.
21574
+ ` + `- The memory system's own errors, retries, backlogs, or internal state.
21575
+ ` + `- Transient state (what is running right now, unread counts, build status) unless the fact is explicitly dated, in which case record it as dated.
21576
+ ` + `
21577
+ ` + "If the new facts contain nothing durable, record nothing rather than synthesising a weak observation.";
21578
+ var SUPERSEDED_OBSERVATIONS_MISSIONS = [
21579
+ "Synthesise the person's wellbeing patterns, motivations, and emotional " + "context — how habits, setbacks, and encouragement connect over time."
21503
21580
  ];
21504
21581
  var PROFILE_MEMORY_DEFAULTS = {
21505
21582
  "health-coach": {
21506
21583
  disposition: { skepticism: 2, literalism: 2, empathy: 5 },
21507
- observations_mission: "Synthesise the person's wellbeing patterns, motivations, and emotional " + "context — how habits, setbacks, and encouragement connect over time."
21584
+ observations_mission: `You consolidate the memory of a health and fitness coach working with one person. This bank records how that person actually lives and trains.
21585
+ ` + `
21586
+ ` + `Synthesise into durable observations:
21587
+ ` + `- Goals, targets, and the plan currently in force, with the reasoning behind each.
21588
+ ` + `- Training, nutrition, sleep, and alcohol patterns as they hold over weeks — what the person reliably does, not what they did once.
21589
+ ` + `- Constraints that shape the plan: injuries, medical guidance, schedule, equipment, foods and sessions they refuse.
21590
+ ` + `- Motivations, and what actually helps or backfires when they slip.
21591
+ ` + `- Trends in the numbers: direction and range over time, not any single reading.
21592
+ ` + `- Corrections to earlier beliefs, recorded explicitly as corrections.
21593
+ ` + `
21594
+ ` + `A single day's log, weight reading, or session is evidence, not an observation. Record one only when it establishes or changes a standing pattern, target, or constraint — then fold it into the observation for that pattern and say what changed and roughly when.
21595
+ ` + `
21596
+ ` + `Granularity: one observation per habit, target, constraint, or trend. Aggregate repeated daily evidence into the observation for that pattern rather than creating one per day, and keep training, nutrition, and sleep as separate observations.
21597
+ ` + `
21598
+ ` + "Word observations as the person's own pattern and framing, never as a verdict on them."
21508
21599
  },
21509
21600
  "executive-assistant": {
21510
- disposition: { skepticism: 4, literalism: 4, empathy: 3 }
21601
+ disposition: { skepticism: 4, literalism: 4, empathy: 3 },
21602
+ observations_mission: `You consolidate the memory of an executive assistant working for one person. This bank records that person's commitments, people, and standing arrangements.
21603
+ ` + `
21604
+ ` + `Synthesise into durable observations:
21605
+ ` + `- Standing rules and preferences: how they want things scheduled, written, and filed, and when they want to be interrupted.
21606
+ ` + `- People and organisations, and the relationship: who they are, what they are involved in, how to reach them.
21607
+ ` + `- Recurring commitments and routines, and the constraints around them.
21608
+ ` + `- Obligations and their state: what was promised to whom, the deadline, and what is still outstanding.
21609
+ ` + `- Decisions made and decisions deferred, with the reasoning and the trade accepted.
21610
+ ` + `- Corrections to earlier beliefs, recorded explicitly as corrections.
21611
+ ` + `
21612
+ ` + `Live commitment state IS durable knowledge here, not ephemeral chatter. An outstanding obligation, a travel window, an unanswered request, a "currently X" arrangement — these are precisely what this agent must recall later. Keep them, and embed the date inside the observation text so a later reader can judge staleness. Do not drop them as ephemeral.
21613
+ ` + `
21614
+ ` + `Granularity: one observation per person, arrangement, or obligation. Aggregate repeated mentions into that observation rather than creating siblings; never merge two different people or two different commitments into one.
21615
+ ` + `
21616
+ ` + "Do not synthesise from transcript exhaust: tool calls and their results, message or event identifiers, or narration of what the assistant did."
21511
21617
  },
21512
21618
  coding: {
21513
- disposition: { skepticism: 4, literalism: 5, empathy: 2 }
21619
+ disposition: { skepticism: 4, literalism: 5, empathy: 2 },
21620
+ observations_mission: `You consolidate the memory of a software-engineering agent. This bank records real work on real codebases.
21621
+ ` + `
21622
+ ` + `Synthesise into durable observations:
21623
+ ` + `- Architecture and design decisions, each with its rationale and the trade accepted.
21624
+ ` + `- Root causes, with the evidence chain, and negative results — what was ruled out matters as much as what was found.
21625
+ ` + `- How the repository works: build, test, and lint commands, conventions, CI gates, and where things live.
21626
+ ` + `- Outcomes of code work: issue and PR numbers, what changed, whether it merged, what review found.
21627
+ ` + `- The user's standing rules, preferences, and corrections to this agent's behaviour.
21628
+ ` + `- Corrections to earlier beliefs, recorded explicitly as corrections.
21629
+ ` + `
21630
+ ` + `Repository and service state IS durable knowledge here, not ephemeral chatter. Versions, a failing gate, an open PR, a measured number, a "currently X" claim — these are precisely what this agent must recall later. Keep them, and embed the date inside the observation text so a later reader can judge staleness. Do not drop them as ephemeral.
21631
+ ` + `
21632
+ ` + `Granularity: one observation per distinct decision, cause, convention, or work item. Aggregate repeated evidence about the same one into that observation rather than creating siblings; never merge two separate decisions into a single summary.
21633
+ ` + `
21634
+ ` + "Do not synthesise from transcript exhaust: tool calls and their results, scratch paths, session or request identifiers, or narration of what the agent did. Prefer specific and falsifiable — naming the file, the number, the commit, or the decision beats summarising the topic."
21514
21635
  }
21515
21636
  };
21516
21637
 
@@ -4404,7 +4404,10 @@ var init_schema = __esm(() => {
4404
4404
  admin_key: exports_external.string().optional().describe("LiteLLM master/admin key used at apply time to provision the team + " + "virtual key. Supports a vault reference (e.g. " + "'vault:litellm/master-key') — resolution happens at apply time via " + "the vault-broker. Never injected into the agent container."),
4405
4405
  team: exports_external.string().optional().describe("LiteLLM team alias the per-agent key is created under. Defaults to " + "'switchroom' (applied in code, not as a schema default)."),
4406
4406
  small_fast_model: exports_external.string().optional().describe("Model id exported as ANTHROPIC_SMALL_FAST_MODEL for the claude CLI's " + "background/fast lane, e.g. 'claude-haiku-4-5-20251001'."),
4407
- tags: exports_external.record(exports_external.string(), exports_external.string()).optional().describe("Extra key/value metadata tags attached to the provisioned LiteLLM " + "virtual key. Merged per-key across cascade layers (agent wins).")
4407
+ tags: exports_external.record(exports_external.string(), exports_external.string()).optional().describe("Extra key/value metadata tags attached to the provisioned LiteLLM " + "virtual key. Merged per-key across cascade layers (agent wins)."),
4408
+ max_budget: exports_external.number().positive().optional().describe("HARD spend cap in USD for this agent's virtual key over one " + "`budget_duration` window. LiteLLM refuses the request once the key's " + "tracked spend exceeds it, so a runaway loop costs at most this much " + "before it is stopped. Defaults to " + "DEFAULT_KEY_MAX_BUDGET_USD (see src/litellm/budget.ts) — deliberately " + "conservative; raise it per-agent rather than removing it. Set 0 or " + "omit `budget_duration` at your own risk: an uncapped key is only as " + "bounded as the upstream account balance."),
4409
+ soft_budget: exports_external.number().positive().optional().describe("ADVISORY spend threshold in USD. LiteLLM keeps serving past it and " + "raises a budget alert instead. Must be < max_budget. NOTE: LiteLLM " + "accepts soft_budget only on POST /key/generate (GenerateKeyRequest); " + "UpdateKeyRequest does NOT carry it, so changing this value only takes " + "effect on a key that is (re)generated, not on an existing one."),
4410
+ budget_duration: exports_external.string().regex(/^\d+(s|m|h|d|mo)$/, "budget_duration must be a LiteLLM duration like '30d', '24h', '1mo'").optional().describe("Rolling window the budget resets on, in LiteLLM duration syntax " + "('30d', '24h', '1mo'). Defaults to DEFAULT_KEY_BUDGET_DURATION. " + "WITHOUT a duration LiteLLM treats max_budget as a LIFETIME cap that " + "never resets — the key silently dies for good once it is hit.")
4408
4411
  }).optional().describe("LiteLLM routing config — opt-in per-agent virtual-key auto-provisioning " + "+ routing env. Default OFF. See LiteLLMConfigSchema doc for the full flow.");
4409
4412
  HindsightPerOpLlmSchema = exports_external.object({
4410
4413
  model: exports_external.string().min(1).optional().describe("Per-op model (upstream `HINDSIGHT_API_<OP>_LLM_MODEL`). Absent → " + "inherit the global `hindsight.llm.model`."),
@@ -4423,7 +4426,7 @@ var init_schema = __esm(() => {
4423
4426
  reflect: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `reflect` LLM op (synthesis / mental-model " + "refresh). Emits `HINDSIGHT_API_REFLECT_LLM_*`. Absent → uses global."),
4424
4427
  consolidation: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `consolidation` LLM op (background memory " + "merge). Emits `HINDSIGHT_API_CONSOLIDATION_LLM_*`. Absent → global.")
4425
4428
  }).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."),
4426
- 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).")
4429
+ 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, RECENCY_DECAY_FUNCTION, " + "RECENCY_DECAY_HALFLIFE_DAYS — switchroom defaults recall's recency " + "curve to `exponential` with a 30-day half-life so a fact retained " + "today outranks a stale one, instead of upstream's near-flat " + "linear/365-day window), 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; and " + "HINDSIGHT_API_RECENCY_DECAY_LINEAR_WINDOW_DAYS — only read when the " + "decay function is `linear`, so switchroom ships no default for it but " + "still honours an operator who flips the function back; and " + "HINDSIGHT_API_WORKER_MAX_SLOTS — the worker poller's TOTAL in-flight " + "task budget, the pool WORKER_CONSOLIDATION_MAX_SLOTS reserves out of; " + "unset means upstream's own default), 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).")
4427
4430
  });
4428
4431
  MicrosoftWorkspaceConfigSchema = exports_external.object({
4429
4432
  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)."),
@@ -19297,7 +19300,13 @@ var HINDSIGHT_DEFAULT_LINK_EXPANSION_TIMEOUT_S = 2;
19297
19300
  var HINDSIGHT_DEFAULT_LLM_REASONING_EFFORT = "low";
19298
19301
  var HINDSIGHT_DEFAULT_LLM_MAX_CONCURRENT = 4;
19299
19302
  var HINDSIGHT_DEFAULT_RETAIN_LLM_MAX_CONCURRENT = 1;
19300
- var HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_MAX_CONCURRENT = 1;
19303
+ function hindsightConsolidationLlmMaxConcurrentDefault(globalMaxConcurrent = HINDSIGHT_DEFAULT_LLM_MAX_CONCURRENT, retainMaxConcurrent = HINDSIGHT_DEFAULT_RETAIN_LLM_MAX_CONCURRENT) {
19304
+ const globalCap = Number.isFinite(globalMaxConcurrent) && globalMaxConcurrent >= 1 ? Math.floor(globalMaxConcurrent) : HINDSIGHT_DEFAULT_LLM_MAX_CONCURRENT;
19305
+ const retainCap = Number.isFinite(retainMaxConcurrent) && retainMaxConcurrent >= 0 ? Math.floor(retainMaxConcurrent) : HINDSIGHT_DEFAULT_RETAIN_LLM_MAX_CONCURRENT;
19306
+ const headroomBound = Math.max(1, globalCap - 1);
19307
+ return Math.min(headroomBound, Math.max(1, globalCap - retainCap - 1));
19308
+ }
19309
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_MAX_CONCURRENT = hindsightConsolidationLlmMaxConcurrentDefault();
19301
19310
  var HINDSIGHT_DEFAULT_RERANKER_LOCAL_FP16 = "true";
19302
19311
  var HINDSIGHT_DEFAULT_RERANKER_LOCAL_BATCH_SIZE = 128;
19303
19312
  var HINDSIGHT_DEFAULT_LLM_STRICT_SCHEMA = "true";
@@ -19312,6 +19321,8 @@ var HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S = 600;
19312
19321
  var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND = 500;
19313
19322
  var HINDSIGHT_DEFAULT_CONSOLIDATION_SLOT_LIMIT = 6;
19314
19323
  var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS = 1;
19324
+ var HINDSIGHT_DEFAULT_RECENCY_DECAY_FUNCTION = "exponential";
19325
+ var HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS = 30;
19315
19326
  var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
19316
19327
  [
19317
19328
  "HINDSIGHT_API_RECALL_MAX_CANDIDATES_PER_SOURCE",
@@ -19365,6 +19376,14 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
19365
19376
  [
19366
19377
  "HINDSIGHT_API_CONSOLIDATION_MAX_MEMORIES_PER_ROUND",
19367
19378
  String(HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND)
19379
+ ],
19380
+ [
19381
+ "HINDSIGHT_API_RECENCY_DECAY_FUNCTION",
19382
+ HINDSIGHT_DEFAULT_RECENCY_DECAY_FUNCTION
19383
+ ],
19384
+ [
19385
+ "HINDSIGHT_API_RECENCY_DECAY_HALFLIFE_DAYS",
19386
+ String(HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS)
19368
19387
  ]
19369
19388
  ];
19370
19389
  var HINDSIGHT_PERF_DEFAULTS_GPU = [
@@ -19389,7 +19408,9 @@ var HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM = [
19389
19408
  ];
19390
19409
  var HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS = new Set([
19391
19410
  "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY",
19392
- "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP"
19411
+ "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP",
19412
+ "HINDSIGHT_API_RECENCY_DECAY_LINEAR_WINDOW_DAYS",
19413
+ "HINDSIGHT_API_WORKER_MAX_SLOTS"
19393
19414
  ]);
19394
19415
  var HINDSIGHT_PERF_ENV_KEYS = new Set([
19395
19416
  ...[
@@ -19455,6 +19476,16 @@ var DEFAULT_RETAIN_MISSION = `Extract durable facts that will still be true and
19455
19476
  ` + `- Hindsight's own errors, retries, backlogs, or internal state — the memory
19456
19477
  ` + ` system's self-reports are not memories.
19457
19478
  ` + `- Restatements of the user's current request or the task in progress.
19479
+ ` + `- Volatile state written as a timeless assertion. A version, count, size,
19480
+ ` + ` backlog, status, or any "X is running Y" / "X is at Y" / "X is currently Y"
19481
+ ` + ` claim is true only at the instant it was said. Concretely, never produce a
19482
+ ` + ` fact whose text resembles any of these: "Switchroom fleet is running image
19483
+ ` + ` version v0.18.19", "The switchroom repo is at /path/to/fleet, version
19484
+ ` + ` v0.19.5", "Bank overlord has 43155 pending consolidations", "The build is
19485
+ ` + ` currently green". If the claim is worth keeping, put the date INSIDE the
19486
+ ` + ` fact text ("As of 2026-07-19 the fleet was running v0.18.19"); if you
19487
+ ` + ` cannot date it, drop it. An undated one is recalled forever as though it
19488
+ ` + ` were still true, which is worse than not remembering it at all.
19458
19489
  ` + `- Transient state (unread counts, build status, what is running right now) unless
19459
19490
  ` + ` the fact is explicitly dated, in which case record it as a dated observation.
19460
19491
  ` + `- Greetings, acknowledgements, and routine operational chatter.
@@ -19476,18 +19507,108 @@ var SUPERSEDED_RETAIN_MISSIONS = [
19476
19507
  ` + "- 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.
19477
19508
  ` + `- Greetings, acknowledgements, and routine operational chatter.
19478
19509
 
19479
- ` + "If a candidate fact matches an exclusion, drop it rather than rewording " + "it. If nothing durable remains, return an empty facts list."
19510
+ ` + "If a candidate fact matches an exclusion, drop it rather than rewording " + "it. If nothing durable remains, return an empty facts list.",
19511
+ `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.
19512
+ ` + `
19513
+ ` + `A TOOL RESULT IS NOT A FACT. Before extracting, ask: is the subject of this
19514
+ ` + `candidate a file path, a command/process/agent/session id, a temp directory, or
19515
+ ` + `the location where some output was written? If yes, drop it — it is transcript
19516
+ ` + `exhaust, not memory.
19517
+ ` + `
19518
+ ` + `NEVER extract:
19519
+ ` + `- Tool results verbatim or paraphrased. Concretely, never produce a fact whose
19520
+ ` + ` text resembles any of these: "File created successfully at /path/to/file",
19521
+ ` + ` "A background command with ID bctz4yskm is running, and its output will be
19522
+ ` + ` written to /tmp/...", "Async agent a745598ba84e71df1 was launched successfully
19523
+ ` + ` and is running in the background", "User executed a Bash command to sleep for
19524
+ ` + ` 200 seconds", "The assistant used grep to locate 'truncateSync' in src/foo.ts".
19525
+ ` + `- Anything mentioning a path under /tmp, a scratchpad directory, or a .tmp file.
19526
+ ` + `- Agent tool-use traces or narration of what the assistant did (e.g. "the
19527
+ ` + ` assistant used X to query Y", "ran a search", "sent the message").
19528
+ ` + `- In-flight workflow/process narration (a sub-task started, paused, or is still
19529
+ ` + ` running) — retain the outcome only once the task completes or a decision is made.
19530
+ ` + `- Operation, request, batch, agent, command or session IDs, UUIDs, hashes, or error codes.
19531
+ ` + `- Slash commands the user typed and their effects (e.g. "User issued /clear to
19532
+ ` + ` reset assistant state").
19533
+ ` + `- Hindsight's own errors, retries, backlogs, or internal state — the memory
19534
+ ` + ` system's self-reports are not memories.
19535
+ ` + `- Restatements of the user's current request or the task in progress.
19536
+ ` + `- Transient state (unread counts, build status, what is running right now) unless
19537
+ ` + ` the fact is explicitly dated, in which case record it as a dated observation.
19538
+ ` + `- Greetings, acknowledgements, and routine operational chatter.
19539
+ ` + `
19540
+ ` + `If a candidate fact matches an exclusion, drop it rather than rewording it. If
19541
+ ` + "nothing durable remains, return an empty facts list."
19542
+ ];
19543
+ var DEFAULT_OBSERVATIONS_MISSION = `Synthesise durable, standing knowledge about the people, projects, and systems this agent works with: preferences and standing rules, roles and relationships, skills and recurring patterns, technical and operational decisions with their rationale, and the state of long-running work once it lands.
19544
+ ` + `
19545
+ ` + `The test is durability, not notability: an observation must still be worth reading weeks from now. A single dated event belongs in an observation only when it establishes or changes a standing fact.
19546
+ ` + `
19547
+ ` + `Do NOT synthesise observations from:
19548
+ ` + `- Transcript exhaust — tool calls and their results, file paths, temp or scratchpad directories, where some output was written, or narration of what an assistant did.
19549
+ ` + `- Identifiers with no standing meaning: session, agent, request, batch or command IDs, UUIDs, hashes, error codes.
19550
+ ` + `- In-flight process narration — a task started, paused, or still running. Record the outcome once it lands, not the running state.
19551
+ ` + `- The memory system's own errors, retries, backlogs, or internal state.
19552
+ ` + `- Transient state (what is running right now, unread counts, build status) unless the fact is explicitly dated, in which case record it as dated.
19553
+ ` + `
19554
+ ` + "If the new facts contain nothing durable, record nothing rather than synthesising a weak observation.";
19555
+ var SUPERSEDED_OBSERVATIONS_MISSIONS = [
19556
+ "Synthesise the person's wellbeing patterns, motivations, and emotional " + "context — how habits, setbacks, and encouragement connect over time."
19480
19557
  ];
19481
19558
  var PROFILE_MEMORY_DEFAULTS = {
19482
19559
  "health-coach": {
19483
19560
  disposition: { skepticism: 2, literalism: 2, empathy: 5 },
19484
- observations_mission: "Synthesise the person's wellbeing patterns, motivations, and emotional " + "context — how habits, setbacks, and encouragement connect over time."
19561
+ observations_mission: `You consolidate the memory of a health and fitness coach working with one person. This bank records how that person actually lives and trains.
19562
+ ` + `
19563
+ ` + `Synthesise into durable observations:
19564
+ ` + `- Goals, targets, and the plan currently in force, with the reasoning behind each.
19565
+ ` + `- Training, nutrition, sleep, and alcohol patterns as they hold over weeks — what the person reliably does, not what they did once.
19566
+ ` + `- Constraints that shape the plan: injuries, medical guidance, schedule, equipment, foods and sessions they refuse.
19567
+ ` + `- Motivations, and what actually helps or backfires when they slip.
19568
+ ` + `- Trends in the numbers: direction and range over time, not any single reading.
19569
+ ` + `- Corrections to earlier beliefs, recorded explicitly as corrections.
19570
+ ` + `
19571
+ ` + `A single day's log, weight reading, or session is evidence, not an observation. Record one only when it establishes or changes a standing pattern, target, or constraint — then fold it into the observation for that pattern and say what changed and roughly when.
19572
+ ` + `
19573
+ ` + `Granularity: one observation per habit, target, constraint, or trend. Aggregate repeated daily evidence into the observation for that pattern rather than creating one per day, and keep training, nutrition, and sleep as separate observations.
19574
+ ` + `
19575
+ ` + "Word observations as the person's own pattern and framing, never as a verdict on them."
19485
19576
  },
19486
19577
  "executive-assistant": {
19487
- disposition: { skepticism: 4, literalism: 4, empathy: 3 }
19578
+ disposition: { skepticism: 4, literalism: 4, empathy: 3 },
19579
+ observations_mission: `You consolidate the memory of an executive assistant working for one person. This bank records that person's commitments, people, and standing arrangements.
19580
+ ` + `
19581
+ ` + `Synthesise into durable observations:
19582
+ ` + `- Standing rules and preferences: how they want things scheduled, written, and filed, and when they want to be interrupted.
19583
+ ` + `- People and organisations, and the relationship: who they are, what they are involved in, how to reach them.
19584
+ ` + `- Recurring commitments and routines, and the constraints around them.
19585
+ ` + `- Obligations and their state: what was promised to whom, the deadline, and what is still outstanding.
19586
+ ` + `- Decisions made and decisions deferred, with the reasoning and the trade accepted.
19587
+ ` + `- Corrections to earlier beliefs, recorded explicitly as corrections.
19588
+ ` + `
19589
+ ` + `Live commitment state IS durable knowledge here, not ephemeral chatter. An outstanding obligation, a travel window, an unanswered request, a "currently X" arrangement — these are precisely what this agent must recall later. Keep them, and embed the date inside the observation text so a later reader can judge staleness. Do not drop them as ephemeral.
19590
+ ` + `
19591
+ ` + `Granularity: one observation per person, arrangement, or obligation. Aggregate repeated mentions into that observation rather than creating siblings; never merge two different people or two different commitments into one.
19592
+ ` + `
19593
+ ` + "Do not synthesise from transcript exhaust: tool calls and their results, message or event identifiers, or narration of what the assistant did."
19488
19594
  },
19489
19595
  coding: {
19490
- disposition: { skepticism: 4, literalism: 5, empathy: 2 }
19596
+ disposition: { skepticism: 4, literalism: 5, empathy: 2 },
19597
+ observations_mission: `You consolidate the memory of a software-engineering agent. This bank records real work on real codebases.
19598
+ ` + `
19599
+ ` + `Synthesise into durable observations:
19600
+ ` + `- Architecture and design decisions, each with its rationale and the trade accepted.
19601
+ ` + `- Root causes, with the evidence chain, and negative results — what was ruled out matters as much as what was found.
19602
+ ` + `- How the repository works: build, test, and lint commands, conventions, CI gates, and where things live.
19603
+ ` + `- Outcomes of code work: issue and PR numbers, what changed, whether it merged, what review found.
19604
+ ` + `- The user's standing rules, preferences, and corrections to this agent's behaviour.
19605
+ ` + `- Corrections to earlier beliefs, recorded explicitly as corrections.
19606
+ ` + `
19607
+ ` + `Repository and service state IS durable knowledge here, not ephemeral chatter. Versions, a failing gate, an open PR, a measured number, a "currently X" claim — these are precisely what this agent must recall later. Keep them, and embed the date inside the observation text so a later reader can judge staleness. Do not drop them as ephemeral.
19608
+ ` + `
19609
+ ` + `Granularity: one observation per distinct decision, cause, convention, or work item. Aggregate repeated evidence about the same one into that observation rather than creating siblings; never merge two separate decisions into a single summary.
19610
+ ` + `
19611
+ ` + "Do not synthesise from transcript exhaust: tool calls and their results, scratch paths, session or request identifiers, or narration of what the agent did. Prefer specific and falsifiable — naming the file, the number, the commit, or the decision beats summarising the topic."
19491
19612
  }
19492
19613
  };
19493
19614
  // src/agents/reconcile-default-skills.ts