switchroom 0.19.42 → 0.19.43

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 (72) hide show
  1. package/dist/agent-scheduler/index.js +1 -1
  2. package/dist/auth-broker/index.js +32 -7
  3. package/dist/cli/notion-write-pretool.mjs +1 -1
  4. package/dist/cli/switchroom.js +1187 -669
  5. package/dist/host-control/main.js +205 -28
  6. package/dist/vault/approvals/kernel-server.js +32 -7
  7. package/dist/vault/broker/server.js +32 -7
  8. package/package.json +3 -3
  9. package/profiles/_base/start.sh.hbs +82 -4
  10. package/telegram-plugin/bridge/bridge.ts +1 -1
  11. package/telegram-plugin/card-layout.ts +63 -1
  12. package/telegram-plugin/dist/bridge/bridge.js +4 -1
  13. package/telegram-plugin/dist/gateway/gateway.js +1225 -614
  14. package/telegram-plugin/dist/server.js +5 -2
  15. package/telegram-plugin/flood-429-ledger.ts +5 -3
  16. package/telegram-plugin/flood-circuit-breaker.ts +11 -3
  17. package/telegram-plugin/format.ts +223 -13
  18. package/telegram-plugin/gateway/boot-card.ts +7 -2
  19. package/telegram-plugin/gateway/flood-reply-queue.ts +5 -0
  20. package/telegram-plugin/gateway/gateway.ts +49 -51
  21. package/telegram-plugin/gateway/handback-orphan-recovery.ts +69 -0
  22. package/telegram-plugin/gateway/handback-preturn-signal.ts +170 -32
  23. package/telegram-plugin/gateway/ipc-protocol.ts +31 -3
  24. package/telegram-plugin/gateway/ipc-server.ts +13 -4
  25. package/telegram-plugin/gateway/obligation-store.ts +55 -0
  26. package/telegram-plugin/gateway/outbound-send-path.ts +127 -11
  27. package/telegram-plugin/gateway/outbox-sweep.ts +371 -61
  28. package/telegram-plugin/gateway/rollout-status-edit.ts +175 -0
  29. package/telegram-plugin/gateway/stream-render.ts +5 -0
  30. package/telegram-plugin/gateway/update-announce.ts +11 -4
  31. package/telegram-plugin/hooks/audience-classify.d.mts +50 -0
  32. package/telegram-plugin/hooks/audience-classify.mjs +364 -0
  33. package/telegram-plugin/hooks/silent-end-interrupt-stop.mjs +86 -3
  34. package/telegram-plugin/hooks/silent-end-scan.mjs +80 -4
  35. package/telegram-plugin/outbox.ts +103 -2
  36. package/telegram-plugin/render/rich-render.ts +10 -2
  37. package/telegram-plugin/reply-quote.ts +150 -0
  38. package/telegram-plugin/retry-api-call.ts +254 -11
  39. package/telegram-plugin/shared/bot-runtime.ts +69 -34
  40. package/telegram-plugin/shared/gw-trace-gate.ts +14 -2
  41. package/telegram-plugin/silent-end.ts +34 -2
  42. package/telegram-plugin/status-no-truncate.ts +31 -16
  43. package/telegram-plugin/stream-controller.ts +44 -9
  44. package/telegram-plugin/stream-reply-handler.ts +5 -3
  45. package/telegram-plugin/tests/boot-card-render.test.ts +2 -1
  46. package/telegram-plugin/tests/card-budget-never-overflows.test.ts +165 -0
  47. package/telegram-plugin/tests/card-hard-truncate-entity-safe.test.ts +153 -0
  48. package/telegram-plugin/tests/card-variants.golden.txt +9 -9
  49. package/telegram-plugin/tests/flood-reply-queue.test.ts +89 -4
  50. package/telegram-plugin/tests/format-consistency.test.ts +160 -14
  51. package/telegram-plugin/tests/handback-orphan-recovery.test.ts +131 -0
  52. package/telegram-plugin/tests/handback-preturn-signal.test.ts +212 -17
  53. package/telegram-plugin/tests/nested-indent-idiom.test.ts +162 -0
  54. package/telegram-plugin/tests/nested-prefix-indent.test.ts +115 -0
  55. package/telegram-plugin/tests/no-robust-api-call-factory.test.ts +62 -0
  56. package/telegram-plugin/tests/obligation-store.test.ts +51 -0
  57. package/telegram-plugin/tests/outbox-audience-3865.test.ts +579 -0
  58. package/telegram-plugin/tests/outbox-provenance-4141.test.ts +1126 -0
  59. package/telegram-plugin/tests/outbox-sweep-single-flight.test.ts +138 -0
  60. package/telegram-plugin/tests/pinned-card-collapse.test.ts +12 -10
  61. package/telegram-plugin/tests/plain-fallback-4096-cap.test.ts +509 -0
  62. package/telegram-plugin/tests/reply-quote-wire.test.ts +433 -0
  63. package/telegram-plugin/tests/retry-grammy-http-error.test.ts +404 -0
  64. package/telegram-plugin/tests/rollout-narration-edit-socket.test.ts +170 -0
  65. package/telegram-plugin/tests/rollout-status-edit-retry-policy.test.ts +366 -0
  66. package/telegram-plugin/tests/rollout-status-edit.test.ts +140 -0
  67. package/telegram-plugin/tests/rollout-status-wiring.test.ts +40 -7
  68. package/telegram-plugin/tests/tg-post-logger-error-shape.test.ts +4 -0
  69. package/telegram-plugin/tests/tg-post-retry-attribution.test.ts +196 -0
  70. package/telegram-plugin/tests/tool-activity-summary.test.ts +23 -17
  71. package/telegram-plugin/tool-activity-summary.ts +58 -30
  72. package/telegram-plugin/uat/scenarios/jtbd-foreground-subagent-activity-dm.test.ts +3 -2
@@ -11416,7 +11416,7 @@ var init_schema = __esm(() => {
11416
11416
  reflect: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `reflect` LLM op (synthesis / mental-model " + "refresh). Emits `HINDSIGHT_API_REFLECT_LLM_*`. Absent → uses global."),
11417
11417
  consolidation: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `consolidation` LLM op (background memory " + "merge). Emits `HINDSIGHT_API_CONSOLIDATION_LLM_*`. Absent → global.")
11418
11418
  }).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."),
11419
- 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; and " + "HINDSIGHT_API_WORKER_RETAIN_MAX_SLOTS — the reserved slot FLOOR for the " + "retain (memory write) lane, carved from that same total; unset means " + "upstream's own 0, i.e. no floor and retain competes for the shared " + "pool), 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).")
11419
+ 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_RESERVED_SLOTS, " + "WORKER_CONSOLIDATION_SLOT_LIMIT, " + "CONSOLIDATION_MAX_MEMORIES_PER_ROUND, GRAPH_SEED_MIN_SIMILARITY, " + "LLM_SUPPORTS_MAX_ITEMS, 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_RESERVED_SLOTS reserves out of; " + "unset means upstream's own default; and " + "HINDSIGHT_API_WORKER_RETAIN_RESERVED_SLOTS — the reserved slot FLOOR for the " + "retain (memory write) lane, carved from that same total; unset means " + "upstream's own 0, i.e. no floor and retain competes for the shared " + "pool; and " + "the pre-0.8.6 name HINDSIGHT_API_WORKER_<TYPE>_MAX_SLOTS is still " + "accepted for every operation type and normalised to " + "..._RESERVED_SLOTS on the way in, because setting both names for " + "one type is a hard boot failure in the engine and switchroom " + "therefore emits only the canonical name; and " + "HINDSIGHT_API_SEMANTIC_MIN_SIMILARITY — the cosine-similarity floor a " + "candidate must reach to be returned by the semantic retrieval arm at " + "all (0..1); unset means upstream's own 0.3, and where it should sit " + "depends on the bank's embedding model and phrasing diversity, so " + "switchroom ships no opinion; and " + "HINDSIGHT_MCP_RECALL_BUDGET_MODE — the rollback knob for switchroom's " + "mcp-recall-token-budget image patch; `legacy` restores upstream's " + "exact pre-patch recall returns, anything else or unset is the " + "honest-envelope mode; and " + "HINDSIGHT_API_LLM_TEMPERATURE_REFLECT — upstream's own per-op reflect " + "temperature knob, made live by switchroom's reflect-temperature image " + "patch; a float, or `none` to omit the kwarg (provider default, " + "upstream's accidental pre-patch behaviour); unset means the image's " + "baked default 0.1), 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).")
11420
11420
  });
11421
11421
  MicrosoftWorkspaceConfigSchema = exports_external.object({
11422
11422
  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)."),
@@ -21342,7 +21342,7 @@ function allocateAgentUid(name) {
21342
21342
  }
21343
21343
 
21344
21344
  // src/build-info.ts
21345
- var VERSION = "0.19.42";
21345
+ var VERSION = "0.19.43";
21346
21346
 
21347
21347
  // src/setup/hindsight-recall-tunables.ts
21348
21348
  var RECALL_DEADLINE_HEADROOM_SECONDS = 2;
@@ -21518,7 +21518,9 @@ var HINDSIGHT_DEFAULT_RECALL_MAX_CONCURRENT = 8;
21518
21518
  var HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S = 600;
21519
21519
  var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND = 250;
21520
21520
  var HINDSIGHT_DEFAULT_CONSOLIDATION_SLOT_LIMIT = 6;
21521
- var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS = 1;
21521
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_RESERVED_SLOTS = 1;
21522
+ var HINDSIGHT_DEFAULT_GRAPH_SEED_MIN_SIMILARITY = 0.3;
21523
+ var HINDSIGHT_DEFAULT_LLM_SUPPORTS_MAX_ITEMS = "false";
21522
21524
  var HINDSIGHT_DEFAULT_RECENCY_DECAY_FUNCTION = "exponential";
21523
21525
  var HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS = 30;
21524
21526
  var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
@@ -21564,8 +21566,8 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
21564
21566
  String(HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S)
21565
21567
  ],
21566
21568
  [
21567
- "HINDSIGHT_API_WORKER_CONSOLIDATION_MAX_SLOTS",
21568
- String(HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS)
21569
+ "HINDSIGHT_API_WORKER_CONSOLIDATION_RESERVED_SLOTS",
21570
+ String(HINDSIGHT_DEFAULT_CONSOLIDATION_RESERVED_SLOTS)
21569
21571
  ],
21570
21572
  [
21571
21573
  "HINDSIGHT_API_WORKER_CONSOLIDATION_SLOT_LIMIT",
@@ -21582,6 +21584,10 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
21582
21584
  [
21583
21585
  "HINDSIGHT_API_RECENCY_DECAY_HALFLIFE_DAYS",
21584
21586
  String(HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS)
21587
+ ],
21588
+ [
21589
+ "HINDSIGHT_API_GRAPH_SEED_MIN_SIMILARITY",
21590
+ String(HINDSIGHT_DEFAULT_GRAPH_SEED_MIN_SIMILARITY)
21585
21591
  ]
21586
21592
  ];
21587
21593
  var HINDSIGHT_PERF_DEFAULTS_GPU = [
@@ -21602,22 +21608,41 @@ var HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM = [
21602
21608
  String(HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_MAX_CONCURRENT)
21603
21609
  ],
21604
21610
  ["HINDSIGHT_API_LLM_STRICT_SCHEMA", HINDSIGHT_DEFAULT_LLM_STRICT_SCHEMA],
21605
- ["HINDSIGHT_API_LLM_MAX_RETRIES", String(HINDSIGHT_DEFAULT_LLM_MAX_RETRIES)]
21611
+ ["HINDSIGHT_API_LLM_MAX_RETRIES", String(HINDSIGHT_DEFAULT_LLM_MAX_RETRIES)],
21612
+ ["HINDSIGHT_API_LLM_SUPPORTS_MAX_ITEMS", HINDSIGHT_DEFAULT_LLM_SUPPORTS_MAX_ITEMS]
21606
21613
  ];
21607
21614
  var HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS = new Set([
21608
21615
  "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY",
21609
21616
  "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP",
21610
21617
  "HINDSIGHT_API_RECENCY_DECAY_LINEAR_WINDOW_DAYS",
21611
21618
  "HINDSIGHT_API_WORKER_MAX_SLOTS",
21612
- "HINDSIGHT_API_WORKER_RETAIN_MAX_SLOTS"
21619
+ "HINDSIGHT_API_WORKER_RETAIN_RESERVED_SLOTS",
21620
+ "HINDSIGHT_API_SEMANTIC_MIN_SIMILARITY",
21621
+ "HINDSIGHT_MCP_RECALL_BUDGET_MODE",
21622
+ "HINDSIGHT_API_LLM_TEMPERATURE_REFLECT",
21623
+ "HINDSIGHT_API_RETAIN_WALL_TIMEOUT"
21613
21624
  ]);
21625
+ var HINDSIGHT_WORKER_SLOT_TYPES = [
21626
+ "consolidation",
21627
+ "file_convert_retain",
21628
+ "graph_maintenance",
21629
+ "import_documents",
21630
+ "refresh_mental_model",
21631
+ "retain"
21632
+ ];
21633
+ var HINDSIGHT_WORKER_RESERVED_SLOT_ALIASES = new Map(HINDSIGHT_WORKER_SLOT_TYPES.map((type) => [
21634
+ `HINDSIGHT_API_WORKER_${type.toUpperCase()}_MAX_SLOTS`,
21635
+ `HINDSIGHT_API_WORKER_${type.toUpperCase()}_RESERVED_SLOTS`
21636
+ ]));
21614
21637
  var HINDSIGHT_PERF_ENV_KEYS = new Set([
21615
21638
  ...[
21616
21639
  ...HINDSIGHT_PERF_DEFAULTS_UNGATED,
21617
21640
  ...HINDSIGHT_PERF_DEFAULTS_GPU,
21618
21641
  ...HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM
21619
21642
  ].map(([k]) => k),
21620
- ...HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS
21643
+ ...HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS,
21644
+ ...HINDSIGHT_WORKER_RESERVED_SLOT_ALIASES.keys(),
21645
+ ...HINDSIGHT_WORKER_RESERVED_SLOT_ALIASES.values()
21621
21646
  ]);
21622
21647
 
21623
21648
  // src/setup/hindsight-context-budget.ts
@@ -29543,6 +29568,17 @@ function deferredLines(target) {
29543
29568
  `- hostd template regen (only if the release changed hostd mounts/env) — \`switchroom hostd install --tag ${target}\``
29544
29569
  ];
29545
29570
  }
29571
+ function warningLines(warnings) {
29572
+ if (!warnings || warnings.length === 0)
29573
+ return [];
29574
+ const MAX_SHOWN = 8;
29575
+ const shown = warnings.slice(0, MAX_SHOWN);
29576
+ const lines = ["**Warnings:**", ...shown.map((w) => `- ⚠️ ${w}`)];
29577
+ if (warnings.length > MAX_SHOWN) {
29578
+ lines.push(`- …and ${warnings.length - MAX_SHOWN} more (see \`get_status\`).`);
29579
+ }
29580
+ return lines;
29581
+ }
29546
29582
  var MAX_RENDER_CHARS = 3800;
29547
29583
  function rolledList(rolled, compact) {
29548
29584
  if (rolled.length === 0)
@@ -29556,6 +29592,7 @@ function renderWith(s, compact) {
29556
29592
  const rolledCount = rolled.length;
29557
29593
  const checklist = checklistLines(s, compact);
29558
29594
  const singletons = singletonLines(s);
29595
+ const warnings = warningLines(s.warnings);
29559
29596
  const elapsedMs = s.elapsedMs ?? (s.startedAtMs !== undefined && s.nowMs !== undefined ? s.nowMs - s.startedAtMs : undefined);
29560
29597
  if (s.terminal === "completed") {
29561
29598
  const parts2 = [headerLine(s, "✅")];
@@ -29568,6 +29605,8 @@ function renderWith(s, compact) {
29568
29605
  parts2.push("", ...checklist);
29569
29606
  if (singletons.length > 0)
29570
29607
  parts2.push("", ...singletons);
29608
+ if (warnings.length > 0)
29609
+ parts2.push("", ...warnings);
29571
29610
  if (s.deferred !== false)
29572
29611
  parts2.push("", ...deferredLines(s.target));
29573
29612
  return parts2.join(`
@@ -29587,6 +29626,8 @@ function renderWith(s, compact) {
29587
29626
  parts2.push("", ...checklist);
29588
29627
  if (singletons.length > 0)
29589
29628
  parts2.push("", ...singletons);
29629
+ if (warnings.length > 0)
29630
+ parts2.push("", ...warnings);
29590
29631
  return parts2.join(`
29591
29632
  `);
29592
29633
  }
@@ -29602,6 +29643,8 @@ function renderWith(s, compact) {
29602
29643
  parts2.push("", ...checklist);
29603
29644
  if (singletons.length > 0)
29604
29645
  parts2.push("", ...singletons);
29646
+ if (warnings.length > 0)
29647
+ parts2.push("", ...warnings);
29605
29648
  return parts2.join(`
29606
29649
  `);
29607
29650
  }
@@ -31487,6 +31530,9 @@ ${output.recovery.stderr}` : "";
31487
31530
  if (parsed.drifted && parsed.drifted.length > 0) {
31488
31531
  entry.drifted = parsed.drifted;
31489
31532
  }
31533
+ if (parsed.warnings && parsed.warnings.length > 0) {
31534
+ entry.warnings = parsed.warnings;
31535
+ }
31490
31536
  if (parsed.got !== undefined)
31491
31537
  entry.got = parsed.got;
31492
31538
  if (parsed.timedOut)
@@ -31629,7 +31675,8 @@ ${pinNote}`.trim();
31629
31675
  ...entry.failed_step ? { failedStep: entry.failed_step } : {},
31630
31676
  ...entry.failed_agent ? { failedAgent: entry.failed_agent } : {},
31631
31677
  ...entry.got !== undefined ? { got: entry.got } : {},
31632
- ...entry.drifted && entry.drifted.length > 0 ? { drifted: entry.drifted } : {}
31678
+ ...entry.drifted && entry.drifted.length > 0 ? { drifted: entry.drifted } : {},
31679
+ ...entry.warnings && entry.warnings.length > 0 ? { warnings: entry.warnings } : {}
31633
31680
  });
31634
31681
  this.opts.rolloutRelay.postTerminal({
31635
31682
  requestId: entry.request_id,
@@ -31712,7 +31759,7 @@ ${pinNote}`.trim();
31712
31759
  };
31713
31760
  }
31714
31761
  statusEntryToResponse(request_id, entry) {
31715
- const rolloutPayload = entry.op === "rollout" && (entry.rolled !== undefined || entry.failed_step !== undefined || entry.failed_agent !== undefined || entry.current_phase !== undefined) ? JSON.stringify({
31762
+ const rolloutPayload = entry.op === "rollout" && (entry.rolled !== undefined || entry.failed_step !== undefined || entry.failed_agent !== undefined || entry.warnings !== undefined && entry.warnings.length > 0 || entry.current_phase !== undefined) ? JSON.stringify({
31716
31763
  rolled: entry.rolled ?? [],
31717
31764
  ...entry.current_phase ? { phase: entry.current_phase } : {},
31718
31765
  ...entry.phase_n !== undefined ? { n: entry.phase_n } : {},
@@ -31722,6 +31769,7 @@ ${pinNote}`.trim();
31722
31769
  ...entry.failed_agent ? { failedAgent: entry.failed_agent } : {},
31723
31770
  ...entry.got !== undefined ? { got: entry.got } : {},
31724
31771
  ...entry.drifted && entry.drifted.length > 0 ? { drifted: entry.drifted } : {},
31772
+ ...entry.warnings && entry.warnings.length > 0 ? { warnings: entry.warnings } : {},
31725
31773
  ...entry.pin ? { pin: entry.pin } : {},
31726
31774
  ...entry.prior_pin ? { prior_pin: entry.prior_pin } : {}
31727
31775
  }) : undefined;
@@ -32285,6 +32333,7 @@ class SocketRolloutRelay {
32285
32333
  // src/host-control/rollout-narration-relay.ts
32286
32334
  import { connect as connect4 } from "node:net";
32287
32335
  var DEFAULT_POST_REPLY_TIMEOUT_MS = 5000;
32336
+ var DEFAULT_EDIT_REPLY_TIMEOUT_MS = 5000;
32288
32337
 
32289
32338
  class SocketRolloutNarrationRelay {
32290
32339
  opts;
@@ -32382,18 +32431,40 @@ class SocketRolloutNarrationRelay {
32382
32431
  sockPath = this.opts.resolveGatewaySocket(args.agentName);
32383
32432
  } catch (e) {
32384
32433
  log(`narration edit resolveGatewaySocket threw: ${e.message}`);
32385
- return;
32434
+ return Promise.resolve({
32435
+ ok: false,
32436
+ gone: false,
32437
+ reason: `resolveGatewaySocket threw: ${e.message}`
32438
+ });
32386
32439
  }
32387
- if (sockPath === null)
32388
- return;
32389
- try {
32390
- const client2 = connect4({ path: sockPath });
32391
- client2.setTimeout(5000);
32392
- const done = () => {
32440
+ if (sockPath === null) {
32441
+ return Promise.resolve({
32442
+ ok: false,
32443
+ gone: false,
32444
+ reason: "no reachable gateway"
32445
+ });
32446
+ }
32447
+ return new Promise((resolve10) => {
32448
+ let settled = false;
32449
+ let client2;
32450
+ const finish = (outcome) => {
32451
+ if (settled)
32452
+ return;
32453
+ settled = true;
32393
32454
  try {
32394
32455
  client2.destroy();
32395
32456
  } catch {}
32457
+ resolve10(outcome);
32396
32458
  };
32459
+ try {
32460
+ client2 = connect4({ path: sockPath });
32461
+ } catch (e) {
32462
+ log(`narration edit connect threw: ${e.message}`);
32463
+ resolve10({ ok: false, gone: false, reason: e.message });
32464
+ return;
32465
+ }
32466
+ client2.setTimeout(this.opts.editReplyTimeoutMs ?? DEFAULT_EDIT_REPLY_TIMEOUT_MS);
32467
+ let buffer = "";
32397
32468
  client2.on("connect", () => {
32398
32469
  try {
32399
32470
  client2.write(JSON.stringify({
@@ -32404,21 +32475,46 @@ class SocketRolloutNarrationRelay {
32404
32475
  text: args.text
32405
32476
  }) + `
32406
32477
  `);
32407
- client2.end();
32408
32478
  } catch (e) {
32409
32479
  log(`narration edit write failed: ${e.message}`);
32410
- done();
32480
+ finish({ ok: false, gone: false, reason: e.message });
32481
+ }
32482
+ });
32483
+ client2.on("data", (chunk2) => {
32484
+ buffer += chunk2.toString("utf8");
32485
+ const lines = buffer.split(`
32486
+ `);
32487
+ buffer = lines.pop() ?? "";
32488
+ for (const line of lines) {
32489
+ if (!line.trim())
32490
+ continue;
32491
+ let obj;
32492
+ try {
32493
+ obj = JSON.parse(line);
32494
+ } catch {
32495
+ continue;
32496
+ }
32497
+ if (obj.type === "rollout_status_edited" && obj.requestId === args.requestId) {
32498
+ if (obj.ok === true) {
32499
+ finish({ ok: true });
32500
+ } else {
32501
+ finish({
32502
+ ok: false,
32503
+ gone: obj.gone === true,
32504
+ ...typeof obj.reason === "string" ? { reason: obj.reason } : {}
32505
+ });
32506
+ }
32507
+ return;
32508
+ }
32411
32509
  }
32412
32510
  });
32413
- client2.on("timeout", done);
32511
+ client2.on("timeout", () => finish({ ok: false, gone: false, reason: "edit reply timed out" }));
32414
32512
  client2.on("error", (e) => {
32415
32513
  log(`narration edit socket error: ${e.message}`);
32416
- done();
32514
+ finish({ ok: false, gone: false, reason: e.message });
32417
32515
  });
32418
- client2.on("close", () => {});
32419
- } catch (e) {
32420
- log(`narration edit connect threw: ${e.message}`);
32421
- }
32516
+ client2.on("close", () => finish({ ok: false, gone: false, reason: "no edit reply" }));
32517
+ });
32422
32518
  }
32423
32519
  }
32424
32520
 
@@ -32731,9 +32827,62 @@ class LogTailRolloutNarrator {
32731
32827
  singletons: initialSingletons(),
32732
32828
  frozen: false,
32733
32829
  timer: null,
32734
- pendingEditAfterPost: false
32830
+ pendingEditAfterPost: false,
32831
+ goneRepostUsed: false,
32832
+ goneRepostForMessageId: null
32735
32833
  };
32736
32834
  }
32835
+ escalateCard(esc) {
32836
+ try {
32837
+ if (this.opts.escalate) {
32838
+ this.opts.escalate(esc);
32839
+ return;
32840
+ }
32841
+ this.opts.log?.(`rollout card escalation request=${esc.requestId} agent=${esc.agentName} ` + `staleMessageId=${esc.staleMessageId} reason=${esc.reason}` + `${esc.detail !== undefined ? ` detail=${esc.detail}` : ""} ` + `— card could not be restored, no operator card issued (get_status remains the record)`);
32842
+ } catch {}
32843
+ }
32844
+ onEditOutcome(requestId, editedMessageId, outcome) {
32845
+ if (outcome.ok)
32846
+ return;
32847
+ const st = this.states.get(requestId);
32848
+ if (!st)
32849
+ return;
32850
+ if (!outcome.gone) {
32851
+ this.opts.log?.(`rollout narration edit failed (transient, requestId=${requestId}): ${outcome.reason ?? "unknown"}`);
32852
+ return;
32853
+ }
32854
+ if (st.messageId !== editedMessageId)
32855
+ return;
32856
+ if (st.goneRepostUsed) {
32857
+ this.escalateCard({
32858
+ requestId,
32859
+ agentName: st.agentName,
32860
+ staleMessageId: editedMessageId,
32861
+ reason: "gone-again",
32862
+ detail: outcome.reason
32863
+ });
32864
+ return;
32865
+ }
32866
+ st.goneRepostUsed = true;
32867
+ st.messageId = null;
32868
+ st.postFailed = false;
32869
+ st.goneRepostForMessageId = editedMessageId;
32870
+ if (st.timer) {
32871
+ clearTimeout(st.timer);
32872
+ st.timer = null;
32873
+ }
32874
+ this.opts.log?.(`rollout narration card ${editedMessageId} is gone (requestId=${requestId}); re-posting once`);
32875
+ if (!this.tryPost(requestId, true)) {
32876
+ st.goneRepostForMessageId = null;
32877
+ this.escalateCard({
32878
+ requestId,
32879
+ agentName: st.agentName,
32880
+ staleMessageId: editedMessageId,
32881
+ reason: "repost-unavailable",
32882
+ detail: "post-attempt cap reached"
32883
+ });
32884
+ }
32885
+ }
32737
32886
  ensureState(entry) {
32738
32887
  let st = this.states.get(entry.request_id);
32739
32888
  if (!st) {
@@ -32797,10 +32946,22 @@ class LogTailRolloutNarrator {
32797
32946
  if (mid === null) {
32798
32947
  st.postFailed = true;
32799
32948
  this.opts.log?.(`rollout narration post returned no message_id (requestId=${requestId}); backing off re-posts`);
32949
+ if (st.goneRepostForMessageId !== null) {
32950
+ const stale = st.goneRepostForMessageId;
32951
+ st.goneRepostForMessageId = null;
32952
+ this.escalateCard({
32953
+ requestId,
32954
+ agentName: st.agentName,
32955
+ staleMessageId: stale,
32956
+ reason: "repost-failed",
32957
+ detail: "post returned no message_id"
32958
+ });
32959
+ }
32800
32960
  return;
32801
32961
  }
32802
32962
  st.messageId = mid;
32803
32963
  st.postFailed = false;
32964
+ st.goneRepostForMessageId = null;
32804
32965
  try {
32805
32966
  this.opts.onMessageId?.(requestId, mid);
32806
32967
  } catch (e) {
@@ -32814,6 +32975,17 @@ class LogTailRolloutNarrator {
32814
32975
  st.posting = false;
32815
32976
  st.postFailed = true;
32816
32977
  this.opts.log?.(`rollout narration post failed (non-fatal): ${e.message}`);
32978
+ if (st.goneRepostForMessageId !== null) {
32979
+ const stale = st.goneRepostForMessageId;
32980
+ st.goneRepostForMessageId = null;
32981
+ this.escalateCard({
32982
+ requestId,
32983
+ agentName: st.agentName,
32984
+ staleMessageId: stale,
32985
+ reason: "repost-failed",
32986
+ detail: e.message
32987
+ });
32988
+ }
32817
32989
  });
32818
32990
  return true;
32819
32991
  }
@@ -32849,11 +33021,14 @@ class LogTailRolloutNarrator {
32849
33021
  return;
32850
33022
  }
32851
33023
  const text = renderRolloutStatus({ ...st.render, nowMs: this.now() });
33024
+ const editedMessageId = st.messageId;
32852
33025
  this.relay.edit({
32853
33026
  requestId,
32854
33027
  agentName: st.agentName,
32855
- messageId: st.messageId,
33028
+ messageId: editedMessageId,
32856
33029
  text
33030
+ }).then((outcome) => this.onEditOutcome(requestId, editedMessageId, outcome)).catch((e) => {
33031
+ this.opts.log?.(`rollout narration edit relay rejected (non-fatal): ${e.message}`);
32857
33032
  });
32858
33033
  }
32859
33034
  }
@@ -33453,7 +33628,9 @@ async function main() {
33453
33628
  }), {
33454
33629
  log: (m) => process.stderr.write(`hostd: rollout-narration — ${m}
33455
33630
  `),
33456
- onMessageId: (rid, mid) => server?.persistNarrationMessageId(rid, mid)
33631
+ onMessageId: (rid, mid) => server?.persistNarrationMessageId(rid, mid),
33632
+ escalate: (esc) => process.stderr.write(`hostd: rollout card escalation request=${esc.requestId} agent=${esc.agentName} ` + `staleMessageId=${esc.staleMessageId} reason=${esc.reason}` + `${esc.detail !== undefined ? ` detail=${esc.detail}` : ""} ` + `— card could not be restored, no operator card issued
33633
+ `)
33457
33634
  });
33458
33635
  const server = new HostdServer({
33459
33636
  homeDir: homedir8(),
@@ -4856,7 +4856,7 @@ var init_schema = __esm(() => {
4856
4856
  reflect: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `reflect` LLM op (synthesis / mental-model " + "refresh). Emits `HINDSIGHT_API_REFLECT_LLM_*`. Absent → uses global."),
4857
4857
  consolidation: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `consolidation` LLM op (background memory " + "merge). Emits `HINDSIGHT_API_CONSOLIDATION_LLM_*`. Absent → global.")
4858
4858
  }).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."),
4859
- 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; and " + "HINDSIGHT_API_WORKER_RETAIN_MAX_SLOTS — the reserved slot FLOOR for the " + "retain (memory write) lane, carved from that same total; unset means " + "upstream's own 0, i.e. no floor and retain competes for the shared " + "pool), 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).")
4859
+ 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_RESERVED_SLOTS, " + "WORKER_CONSOLIDATION_SLOT_LIMIT, " + "CONSOLIDATION_MAX_MEMORIES_PER_ROUND, GRAPH_SEED_MIN_SIMILARITY, " + "LLM_SUPPORTS_MAX_ITEMS, 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_RESERVED_SLOTS reserves out of; " + "unset means upstream's own default; and " + "HINDSIGHT_API_WORKER_RETAIN_RESERVED_SLOTS — the reserved slot FLOOR for the " + "retain (memory write) lane, carved from that same total; unset means " + "upstream's own 0, i.e. no floor and retain competes for the shared " + "pool; and " + "the pre-0.8.6 name HINDSIGHT_API_WORKER_<TYPE>_MAX_SLOTS is still " + "accepted for every operation type and normalised to " + "..._RESERVED_SLOTS on the way in, because setting both names for " + "one type is a hard boot failure in the engine and switchroom " + "therefore emits only the canonical name; and " + "HINDSIGHT_API_SEMANTIC_MIN_SIMILARITY — the cosine-similarity floor a " + "candidate must reach to be returned by the semantic retrieval arm at " + "all (0..1); unset means upstream's own 0.3, and where it should sit " + "depends on the bank's embedding model and phrasing diversity, so " + "switchroom ships no opinion; and " + "HINDSIGHT_MCP_RECALL_BUDGET_MODE — the rollback knob for switchroom's " + "mcp-recall-token-budget image patch; `legacy` restores upstream's " + "exact pre-patch recall returns, anything else or unset is the " + "honest-envelope mode; and " + "HINDSIGHT_API_LLM_TEMPERATURE_REFLECT — upstream's own per-op reflect " + "temperature knob, made live by switchroom's reflect-temperature image " + "patch; a float, or `none` to omit the kwarg (provider default, " + "upstream's accidental pre-patch behaviour); unset means the image's " + "baked default 0.1), 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).")
4860
4860
  });
4861
4861
  MicrosoftWorkspaceConfigSchema = exports_external.object({
4862
4862
  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)."),
@@ -19413,7 +19413,9 @@ var HINDSIGHT_DEFAULT_RECALL_MAX_CONCURRENT = 8;
19413
19413
  var HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S = 600;
19414
19414
  var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND = 250;
19415
19415
  var HINDSIGHT_DEFAULT_CONSOLIDATION_SLOT_LIMIT = 6;
19416
- var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS = 1;
19416
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_RESERVED_SLOTS = 1;
19417
+ var HINDSIGHT_DEFAULT_GRAPH_SEED_MIN_SIMILARITY = 0.3;
19418
+ var HINDSIGHT_DEFAULT_LLM_SUPPORTS_MAX_ITEMS = "false";
19417
19419
  var HINDSIGHT_DEFAULT_RECENCY_DECAY_FUNCTION = "exponential";
19418
19420
  var HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS = 30;
19419
19421
  var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
@@ -19459,8 +19461,8 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
19459
19461
  String(HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S)
19460
19462
  ],
19461
19463
  [
19462
- "HINDSIGHT_API_WORKER_CONSOLIDATION_MAX_SLOTS",
19463
- String(HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS)
19464
+ "HINDSIGHT_API_WORKER_CONSOLIDATION_RESERVED_SLOTS",
19465
+ String(HINDSIGHT_DEFAULT_CONSOLIDATION_RESERVED_SLOTS)
19464
19466
  ],
19465
19467
  [
19466
19468
  "HINDSIGHT_API_WORKER_CONSOLIDATION_SLOT_LIMIT",
@@ -19477,6 +19479,10 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
19477
19479
  [
19478
19480
  "HINDSIGHT_API_RECENCY_DECAY_HALFLIFE_DAYS",
19479
19481
  String(HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS)
19482
+ ],
19483
+ [
19484
+ "HINDSIGHT_API_GRAPH_SEED_MIN_SIMILARITY",
19485
+ String(HINDSIGHT_DEFAULT_GRAPH_SEED_MIN_SIMILARITY)
19480
19486
  ]
19481
19487
  ];
19482
19488
  var HINDSIGHT_PERF_DEFAULTS_GPU = [
@@ -19497,22 +19503,41 @@ var HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM = [
19497
19503
  String(HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_MAX_CONCURRENT)
19498
19504
  ],
19499
19505
  ["HINDSIGHT_API_LLM_STRICT_SCHEMA", HINDSIGHT_DEFAULT_LLM_STRICT_SCHEMA],
19500
- ["HINDSIGHT_API_LLM_MAX_RETRIES", String(HINDSIGHT_DEFAULT_LLM_MAX_RETRIES)]
19506
+ ["HINDSIGHT_API_LLM_MAX_RETRIES", String(HINDSIGHT_DEFAULT_LLM_MAX_RETRIES)],
19507
+ ["HINDSIGHT_API_LLM_SUPPORTS_MAX_ITEMS", HINDSIGHT_DEFAULT_LLM_SUPPORTS_MAX_ITEMS]
19501
19508
  ];
19502
19509
  var HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS = new Set([
19503
19510
  "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY",
19504
19511
  "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP",
19505
19512
  "HINDSIGHT_API_RECENCY_DECAY_LINEAR_WINDOW_DAYS",
19506
19513
  "HINDSIGHT_API_WORKER_MAX_SLOTS",
19507
- "HINDSIGHT_API_WORKER_RETAIN_MAX_SLOTS"
19514
+ "HINDSIGHT_API_WORKER_RETAIN_RESERVED_SLOTS",
19515
+ "HINDSIGHT_API_SEMANTIC_MIN_SIMILARITY",
19516
+ "HINDSIGHT_MCP_RECALL_BUDGET_MODE",
19517
+ "HINDSIGHT_API_LLM_TEMPERATURE_REFLECT",
19518
+ "HINDSIGHT_API_RETAIN_WALL_TIMEOUT"
19508
19519
  ]);
19520
+ var HINDSIGHT_WORKER_SLOT_TYPES = [
19521
+ "consolidation",
19522
+ "file_convert_retain",
19523
+ "graph_maintenance",
19524
+ "import_documents",
19525
+ "refresh_mental_model",
19526
+ "retain"
19527
+ ];
19528
+ var HINDSIGHT_WORKER_RESERVED_SLOT_ALIASES = new Map(HINDSIGHT_WORKER_SLOT_TYPES.map((type) => [
19529
+ `HINDSIGHT_API_WORKER_${type.toUpperCase()}_MAX_SLOTS`,
19530
+ `HINDSIGHT_API_WORKER_${type.toUpperCase()}_RESERVED_SLOTS`
19531
+ ]));
19509
19532
  var HINDSIGHT_PERF_ENV_KEYS = new Set([
19510
19533
  ...[
19511
19534
  ...HINDSIGHT_PERF_DEFAULTS_UNGATED,
19512
19535
  ...HINDSIGHT_PERF_DEFAULTS_GPU,
19513
19536
  ...HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM
19514
19537
  ].map(([k]) => k),
19515
- ...HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS
19538
+ ...HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS,
19539
+ ...HINDSIGHT_WORKER_RESERVED_SLOT_ALIASES.keys(),
19540
+ ...HINDSIGHT_WORKER_RESERVED_SLOT_ALIASES.values()
19516
19541
  ]);
19517
19542
 
19518
19543
  // src/setup/hindsight-context-budget.ts
@@ -4452,7 +4452,7 @@ var init_schema = __esm(() => {
4452
4452
  reflect: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `reflect` LLM op (synthesis / mental-model " + "refresh). Emits `HINDSIGHT_API_REFLECT_LLM_*`. Absent → uses global."),
4453
4453
  consolidation: HindsightPerOpLlmSchema.optional().describe("Per-op override for the `consolidation` LLM op (background memory " + "merge). Emits `HINDSIGHT_API_CONSOLIDATION_LLM_*`. Absent → global.")
4454
4454
  }).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."),
4455
- 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; and " + "HINDSIGHT_API_WORKER_RETAIN_MAX_SLOTS — the reserved slot FLOOR for the " + "retain (memory write) lane, carved from that same total; unset means " + "upstream's own 0, i.e. no floor and retain competes for the shared " + "pool), 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).")
4455
+ 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_RESERVED_SLOTS, " + "WORKER_CONSOLIDATION_SLOT_LIMIT, " + "CONSOLIDATION_MAX_MEMORIES_PER_ROUND, GRAPH_SEED_MIN_SIMILARITY, " + "LLM_SUPPORTS_MAX_ITEMS, 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_RESERVED_SLOTS reserves out of; " + "unset means upstream's own default; and " + "HINDSIGHT_API_WORKER_RETAIN_RESERVED_SLOTS — the reserved slot FLOOR for the " + "retain (memory write) lane, carved from that same total; unset means " + "upstream's own 0, i.e. no floor and retain competes for the shared " + "pool; and " + "the pre-0.8.6 name HINDSIGHT_API_WORKER_<TYPE>_MAX_SLOTS is still " + "accepted for every operation type and normalised to " + "..._RESERVED_SLOTS on the way in, because setting both names for " + "one type is a hard boot failure in the engine and switchroom " + "therefore emits only the canonical name; and " + "HINDSIGHT_API_SEMANTIC_MIN_SIMILARITY — the cosine-similarity floor a " + "candidate must reach to be returned by the semantic retrieval arm at " + "all (0..1); unset means upstream's own 0.3, and where it should sit " + "depends on the bank's embedding model and phrasing diversity, so " + "switchroom ships no opinion; and " + "HINDSIGHT_MCP_RECALL_BUDGET_MODE — the rollback knob for switchroom's " + "mcp-recall-token-budget image patch; `legacy` restores upstream's " + "exact pre-patch recall returns, anything else or unset is the " + "honest-envelope mode; and " + "HINDSIGHT_API_LLM_TEMPERATURE_REFLECT — upstream's own per-op reflect " + "temperature knob, made live by switchroom's reflect-temperature image " + "patch; a float, or `none` to omit the kwarg (provider default, " + "upstream's accidental pre-patch behaviour); unset means the image's " + "baked default 0.1), 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).")
4456
4456
  });
4457
4457
  MicrosoftWorkspaceConfigSchema = exports_external.object({
4458
4458
  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)."),
@@ -19826,7 +19826,9 @@ var HINDSIGHT_DEFAULT_RECALL_MAX_CONCURRENT = 8;
19826
19826
  var HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S = 600;
19827
19827
  var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_MEMORIES_PER_ROUND = 250;
19828
19828
  var HINDSIGHT_DEFAULT_CONSOLIDATION_SLOT_LIMIT = 6;
19829
- var HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS = 1;
19829
+ var HINDSIGHT_DEFAULT_CONSOLIDATION_RESERVED_SLOTS = 1;
19830
+ var HINDSIGHT_DEFAULT_GRAPH_SEED_MIN_SIMILARITY = 0.3;
19831
+ var HINDSIGHT_DEFAULT_LLM_SUPPORTS_MAX_ITEMS = "false";
19830
19832
  var HINDSIGHT_DEFAULT_RECENCY_DECAY_FUNCTION = "exponential";
19831
19833
  var HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS = 30;
19832
19834
  var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
@@ -19872,8 +19874,8 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
19872
19874
  String(HINDSIGHT_DEFAULT_REFLECT_WALL_TIMEOUT_S)
19873
19875
  ],
19874
19876
  [
19875
- "HINDSIGHT_API_WORKER_CONSOLIDATION_MAX_SLOTS",
19876
- String(HINDSIGHT_DEFAULT_CONSOLIDATION_MAX_SLOTS)
19877
+ "HINDSIGHT_API_WORKER_CONSOLIDATION_RESERVED_SLOTS",
19878
+ String(HINDSIGHT_DEFAULT_CONSOLIDATION_RESERVED_SLOTS)
19877
19879
  ],
19878
19880
  [
19879
19881
  "HINDSIGHT_API_WORKER_CONSOLIDATION_SLOT_LIMIT",
@@ -19890,6 +19892,10 @@ var HINDSIGHT_PERF_DEFAULTS_UNGATED = [
19890
19892
  [
19891
19893
  "HINDSIGHT_API_RECENCY_DECAY_HALFLIFE_DAYS",
19892
19894
  String(HINDSIGHT_DEFAULT_RECENCY_DECAY_HALFLIFE_DAYS)
19895
+ ],
19896
+ [
19897
+ "HINDSIGHT_API_GRAPH_SEED_MIN_SIMILARITY",
19898
+ String(HINDSIGHT_DEFAULT_GRAPH_SEED_MIN_SIMILARITY)
19893
19899
  ]
19894
19900
  ];
19895
19901
  var HINDSIGHT_PERF_DEFAULTS_GPU = [
@@ -19910,22 +19916,41 @@ var HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM = [
19910
19916
  String(HINDSIGHT_DEFAULT_CONSOLIDATION_LLM_MAX_CONCURRENT)
19911
19917
  ],
19912
19918
  ["HINDSIGHT_API_LLM_STRICT_SCHEMA", HINDSIGHT_DEFAULT_LLM_STRICT_SCHEMA],
19913
- ["HINDSIGHT_API_LLM_MAX_RETRIES", String(HINDSIGHT_DEFAULT_LLM_MAX_RETRIES)]
19919
+ ["HINDSIGHT_API_LLM_MAX_RETRIES", String(HINDSIGHT_DEFAULT_LLM_MAX_RETRIES)],
19920
+ ["HINDSIGHT_API_LLM_SUPPORTS_MAX_ITEMS", HINDSIGHT_DEFAULT_LLM_SUPPORTS_MAX_ITEMS]
19914
19921
  ];
19915
19922
  var HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS = new Set([
19916
19923
  "HINDSIGHT_API_WORKER_CONSOLIDATION_BANK_PRIORITY",
19917
19924
  "HINDSIGHT_CE_DECISIVE_RELATIVE_GAP",
19918
19925
  "HINDSIGHT_API_RECENCY_DECAY_LINEAR_WINDOW_DAYS",
19919
19926
  "HINDSIGHT_API_WORKER_MAX_SLOTS",
19920
- "HINDSIGHT_API_WORKER_RETAIN_MAX_SLOTS"
19927
+ "HINDSIGHT_API_WORKER_RETAIN_RESERVED_SLOTS",
19928
+ "HINDSIGHT_API_SEMANTIC_MIN_SIMILARITY",
19929
+ "HINDSIGHT_MCP_RECALL_BUDGET_MODE",
19930
+ "HINDSIGHT_API_LLM_TEMPERATURE_REFLECT",
19931
+ "HINDSIGHT_API_RETAIN_WALL_TIMEOUT"
19921
19932
  ]);
19933
+ var HINDSIGHT_WORKER_SLOT_TYPES = [
19934
+ "consolidation",
19935
+ "file_convert_retain",
19936
+ "graph_maintenance",
19937
+ "import_documents",
19938
+ "refresh_mental_model",
19939
+ "retain"
19940
+ ];
19941
+ var HINDSIGHT_WORKER_RESERVED_SLOT_ALIASES = new Map(HINDSIGHT_WORKER_SLOT_TYPES.map((type) => [
19942
+ `HINDSIGHT_API_WORKER_${type.toUpperCase()}_MAX_SLOTS`,
19943
+ `HINDSIGHT_API_WORKER_${type.toUpperCase()}_RESERVED_SLOTS`
19944
+ ]));
19922
19945
  var HINDSIGHT_PERF_ENV_KEYS = new Set([
19923
19946
  ...[
19924
19947
  ...HINDSIGHT_PERF_DEFAULTS_UNGATED,
19925
19948
  ...HINDSIGHT_PERF_DEFAULTS_GPU,
19926
19949
  ...HINDSIGHT_PERF_DEFAULTS_LOCAL_LLM
19927
19950
  ].map(([k]) => k),
19928
- ...HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS
19951
+ ...HINDSIGHT_PERF_OVERRIDE_ONLY_KEYS,
19952
+ ...HINDSIGHT_WORKER_RESERVED_SLOT_ALIASES.keys(),
19953
+ ...HINDSIGHT_WORKER_RESERVED_SLOT_ALIASES.values()
19929
19954
  ]);
19930
19955
 
19931
19956
  // src/setup/hindsight-context-budget.ts