switchroom 0.15.45 → 0.16.5

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 (150) hide show
  1. package/dist/agent-scheduler/index.js +56 -15
  2. package/dist/auth-broker/index.js +383 -97
  3. package/dist/cli/autoaccept-poll.js +4842 -35
  4. package/dist/cli/drive-write-pretool.mjs +7 -4
  5. package/dist/cli/notion-write-pretool.mjs +35 -4
  6. package/dist/cli/self-improve-apply-guard-pretool.mjs +626 -0
  7. package/dist/cli/self-improve-stop.mjs +428 -0
  8. package/dist/cli/switchroom.js +2894 -841
  9. package/dist/host-control/main.js +2685 -207
  10. package/dist/vault/approvals/kernel-server.js +7453 -7413
  11. package/dist/vault/broker/server.js +11428 -11388
  12. package/examples/minimal.yaml +1 -0
  13. package/examples/switchroom.yaml +1 -0
  14. package/package.json +3 -3
  15. package/profiles/_base/start.sh.hbs +97 -1
  16. package/profiles/_shared/execution-discipline.md.hbs +18 -0
  17. package/profiles/default/CLAUDE.md.hbs +0 -19
  18. package/telegram-plugin/.claude-plugin/plugin.json +2 -2
  19. package/telegram-plugin/answer-stream-flag.ts +12 -49
  20. package/telegram-plugin/answer-stream.ts +5 -150
  21. package/telegram-plugin/auth-snapshot-format.ts +280 -48
  22. package/telegram-plugin/auto-fallback-fleet.ts +44 -1
  23. package/telegram-plugin/context-exhaustion.ts +12 -0
  24. package/telegram-plugin/demo-mask.ts +154 -0
  25. package/telegram-plugin/dist/bridge/bridge.js +55 -12
  26. package/telegram-plugin/dist/gateway/gateway.js +2938 -977
  27. package/telegram-plugin/dist/server.js +55 -12
  28. package/telegram-plugin/docs/waiting-ux-spec.md +2 -2
  29. package/telegram-plugin/draft-stream.ts +47 -410
  30. package/telegram-plugin/final-answer-detect.ts +17 -12
  31. package/telegram-plugin/fleet-fallback-resume.ts +131 -0
  32. package/telegram-plugin/format.ts +56 -19
  33. package/telegram-plugin/gateway/auth-add-flow.ts +332 -127
  34. package/telegram-plugin/gateway/auth-broker-client.ts +2 -2
  35. package/telegram-plugin/gateway/auth-command.ts +70 -14
  36. package/telegram-plugin/gateway/clean-shutdown-marker.ts +44 -0
  37. package/telegram-plugin/gateway/config-approval-handler.test.ts +91 -4
  38. package/telegram-plugin/gateway/config-approval-handler.ts +94 -13
  39. package/telegram-plugin/gateway/current-turn-map.ts +188 -0
  40. package/telegram-plugin/gateway/disconnect-flush.ts +3 -1
  41. package/telegram-plugin/gateway/effort-command.ts +8 -3
  42. package/telegram-plugin/gateway/emission-authority.ts +369 -0
  43. package/telegram-plugin/gateway/feed-open-gate.ts +292 -0
  44. package/telegram-plugin/gateway/gateway.ts +1857 -292
  45. package/telegram-plugin/gateway/inject-handler.test.ts +2 -1
  46. package/telegram-plugin/gateway/model-command.ts +115 -4
  47. package/telegram-plugin/gateway/ms365-write-approval.test.ts +4 -4
  48. package/telegram-plugin/gateway/represent-guard.ts +72 -0
  49. package/telegram-plugin/gateway/status-surface-log.test.ts +5 -4
  50. package/telegram-plugin/gateway/status-surface-log.ts +14 -3
  51. package/telegram-plugin/history.ts +33 -11
  52. package/telegram-plugin/hooks/repo-context-pretool.mjs +26 -0
  53. package/telegram-plugin/hooks/subagent-tracker-posttool.mjs +5 -0
  54. package/telegram-plugin/hooks/subagent-tracker-pretool.mjs +8 -0
  55. package/telegram-plugin/hooks/tool-label-pretool.mjs +39 -15
  56. package/telegram-plugin/issues-card.ts +4 -0
  57. package/telegram-plugin/model-unavailable.ts +124 -0
  58. package/telegram-plugin/narrative-dedup.ts +69 -0
  59. package/telegram-plugin/over-ping-safety-net.ts +70 -4
  60. package/telegram-plugin/package.json +3 -3
  61. package/telegram-plugin/pending-work-progress.ts +12 -0
  62. package/telegram-plugin/permission-rule.ts +32 -5
  63. package/telegram-plugin/permission-title.ts +152 -9
  64. package/telegram-plugin/quota-check.ts +13 -0
  65. package/telegram-plugin/quota-watch.ts +135 -7
  66. package/telegram-plugin/registry/turns-schema.test.ts +24 -0
  67. package/telegram-plugin/registry/turns-schema.ts +9 -0
  68. package/telegram-plugin/runtime-metrics.ts +13 -0
  69. package/telegram-plugin/session-tail.ts +96 -11
  70. package/telegram-plugin/silence-poke.ts +170 -24
  71. package/telegram-plugin/slot-banner-driver.ts +3 -0
  72. package/telegram-plugin/status-no-truncate.ts +44 -0
  73. package/telegram-plugin/status-reactions.ts +20 -3
  74. package/telegram-plugin/stream-controller.ts +4 -23
  75. package/telegram-plugin/stream-reply-handler.ts +6 -24
  76. package/telegram-plugin/streaming-metrics.ts +91 -0
  77. package/telegram-plugin/subagent-watcher.ts +212 -66
  78. package/telegram-plugin/tests/activity-ever-opened-sticky.test.ts +47 -0
  79. package/telegram-plugin/tests/answer-stream-dedup.test.ts +9 -26
  80. package/telegram-plugin/tests/answer-stream-flag.test.ts +25 -58
  81. package/telegram-plugin/tests/answer-stream-silent-markers.test.ts +41 -51
  82. package/telegram-plugin/tests/answer-stream.test.ts +2 -411
  83. package/telegram-plugin/tests/auth-add-flow.test.ts +488 -253
  84. package/telegram-plugin/tests/auth-command-format2.test.ts +71 -1
  85. package/telegram-plugin/tests/auth-snapshot-format.test.ts +376 -6
  86. package/telegram-plugin/tests/auto-fallback-fleet.test.ts +120 -0
  87. package/telegram-plugin/tests/cross-turn-card-gate.test.ts +424 -0
  88. package/telegram-plugin/tests/demo-mask.test.ts +127 -0
  89. package/telegram-plugin/tests/draft-stream.test.ts +0 -827
  90. package/telegram-plugin/tests/emission-authority-card-drain-gate.test.ts +236 -0
  91. package/telegram-plugin/tests/emission-authority-facade.test.ts +488 -0
  92. package/telegram-plugin/tests/emission-authority-open-gate.test.ts +179 -0
  93. package/telegram-plugin/tests/emission-authority-ping-gate.test.ts +395 -0
  94. package/telegram-plugin/tests/emission-determinism-wiring.test.ts +177 -0
  95. package/telegram-plugin/tests/feed-heartbeat-liveness-open.test.ts +146 -0
  96. package/telegram-plugin/tests/feed-open-gate.test.ts +259 -0
  97. package/telegram-plugin/tests/feed-survival.test.ts +526 -0
  98. package/telegram-plugin/tests/fleet-fallback-resume.test.ts +197 -0
  99. package/telegram-plugin/tests/gateway-clean-shutdown-marker.test.ts +117 -0
  100. package/telegram-plugin/tests/gateway-no-reply-single-emit.test.ts +4 -11
  101. package/telegram-plugin/tests/history.test.ts +60 -0
  102. package/telegram-plugin/tests/model-command.test.ts +134 -0
  103. package/telegram-plugin/tests/model-unavailable.test.ts +118 -0
  104. package/telegram-plugin/tests/narrative-dedup.test.ts +118 -0
  105. package/telegram-plugin/tests/orphaned-reply-rearm.test.ts +285 -0
  106. package/telegram-plugin/tests/over-ping-final-answer-decoupling.test.ts +194 -0
  107. package/telegram-plugin/tests/over-ping-safety-net.test.ts +2 -2
  108. package/telegram-plugin/tests/per-topic-current-turn.test.ts +373 -0
  109. package/telegram-plugin/tests/permission-card-origin-kill-switch.test.ts +42 -0
  110. package/telegram-plugin/tests/permission-rule.test.ts +17 -0
  111. package/telegram-plugin/tests/permission-title.test.ts +206 -17
  112. package/telegram-plugin/tests/quota-watch.test.ts +252 -9
  113. package/telegram-plugin/tests/reply-terminal-reaction.test.ts +6 -1
  114. package/telegram-plugin/tests/repo-context-pretool.test.ts +62 -0
  115. package/telegram-plugin/tests/represent-guard.test.ts +162 -0
  116. package/telegram-plugin/tests/session-tail.test.ts +147 -3
  117. package/telegram-plugin/tests/silence-liveness-wiring.test.ts +18 -0
  118. package/telegram-plugin/tests/status-card-budget-parity.test.ts +72 -0
  119. package/telegram-plugin/tests/status-surface-log.test.ts +146 -0
  120. package/telegram-plugin/tests/subagent-watcher-clip-narrative.test.ts +58 -0
  121. package/telegram-plugin/tests/subagent-watcher-parent-turn-key.test.ts +102 -0
  122. package/telegram-plugin/tests/subagent-watcher-workflow-visibility.test.ts +225 -0
  123. package/telegram-plugin/tests/subagent-watcher.test.ts +147 -0
  124. package/telegram-plugin/tests/telegram-activity-visibility-integration.test.ts +597 -0
  125. package/telegram-plugin/tests/telegram-format.test.ts +101 -6
  126. package/telegram-plugin/tests/tool-activity-summary.test.ts +550 -15
  127. package/telegram-plugin/tests/tool-label-pretool.test.ts +73 -0
  128. package/telegram-plugin/tests/tool-label-sidecar.test.ts +44 -0
  129. package/telegram-plugin/tests/tool-labels.test.ts +67 -0
  130. package/telegram-plugin/tests/turn-liveness-floor.test.ts +196 -0
  131. package/telegram-plugin/tests/turn-liveness-invariant.test.ts +340 -0
  132. package/telegram-plugin/tests/welcome-text.test.ts +32 -3
  133. package/telegram-plugin/tests/worker-activity-feed.test.ts +470 -22
  134. package/telegram-plugin/tool-activity-summary.ts +375 -58
  135. package/telegram-plugin/turn-liveness-floor.ts +240 -0
  136. package/telegram-plugin/uat/assertions.ts +115 -0
  137. package/telegram-plugin/uat/driver.ts +68 -0
  138. package/telegram-plugin/uat/scenarios/bg-sub-agent-dispatch-dm.test.ts +119 -133
  139. package/telegram-plugin/uat/scenarios/jtbd-answer-pings.test.ts +94 -0
  140. package/telegram-plugin/uat/scenarios/jtbd-cross-turn-card-dm.test.ts +109 -0
  141. package/telegram-plugin/uat/scenarios/jtbd-foreground-feed-thinkgap-dm.test.ts +478 -0
  142. package/telegram-plugin/uat/scenarios/jtbd-foreground-feed-visibility-dm.test.ts +396 -0
  143. package/telegram-plugin/uat/scenarios/jtbd-liveness-feed-open-dm.test.ts +202 -0
  144. package/telegram-plugin/uat/scenarios/jtbd-reply-is-last-dm.test.ts +202 -0
  145. package/telegram-plugin/uat/scenarios/reactions-dm.test.ts +93 -87
  146. package/telegram-plugin/welcome-text.ts +13 -1
  147. package/telegram-plugin/worker-activity-feed.ts +157 -82
  148. package/telegram-plugin/draft-transport.ts +0 -122
  149. package/telegram-plugin/tests/draft-retirement-wiring.test.ts +0 -82
  150. package/telegram-plugin/tests/draft-transport.test.ts +0 -211
@@ -17237,6 +17237,23 @@ function extractToolResultErrorText(content) {
17237
17237
  }
17238
17238
  return "";
17239
17239
  }
17240
+ function projectAssistantTextBlocks(content, make) {
17241
+ const out = new Map;
17242
+ let lastToolUseIdx = -1;
17243
+ content.forEach((c, i) => {
17244
+ if (c.type === "tool_use")
17245
+ lastToolUseIdx = i;
17246
+ });
17247
+ content.forEach((c, i) => {
17248
+ if (c.type !== "text")
17249
+ return;
17250
+ const text = c.text ?? "";
17251
+ if (text.trim().length === 0)
17252
+ return;
17253
+ out.set(i, make(text, i, i > lastToolUseIdx));
17254
+ });
17255
+ return out;
17256
+ }
17240
17257
  function projectTranscriptLine(line) {
17241
17258
  if (line.length > MAX_JSONL_LINE_BYTES)
17242
17259
  return [];
@@ -17267,7 +17284,8 @@ function projectTranscriptLine(line) {
17267
17284
  if (!Array.isArray(content))
17268
17285
  return [];
17269
17286
  const events = [];
17270
- for (const c of content) {
17287
+ const textEvents = projectAssistantTextBlocks(content, (text, blockIndex, lastInMessage) => ({ kind: "text", text, blockIndex, lastInMessage }));
17288
+ content.forEach((c, i) => {
17271
17289
  const ct = c.type;
17272
17290
  if (ct === "thinking") {
17273
17291
  events.push({ kind: "thinking" });
@@ -17280,10 +17298,11 @@ function projectTranscriptLine(line) {
17280
17298
  input: input && typeof input === "object" ? input : undefined
17281
17299
  });
17282
17300
  } else if (ct === "text") {
17283
- const text = c.text ?? "";
17284
- events.push({ kind: "text", text });
17301
+ const ev = textEvents.get(i);
17302
+ if (ev != null)
17303
+ events.push(ev);
17285
17304
  }
17286
- }
17305
+ });
17287
17306
  return events;
17288
17307
  }
17289
17308
  if (type === "user") {
@@ -17367,7 +17386,14 @@ function projectSubagentLine(line, agentId, state) {
17367
17386
  if (!Array.isArray(content))
17368
17387
  return [];
17369
17388
  const events = [];
17370
- for (const c of content) {
17389
+ const textEvents = projectAssistantTextBlocks(content, (text, blockIndex, lastInMessage) => ({
17390
+ kind: "sub_agent_text",
17391
+ agentId,
17392
+ text,
17393
+ blockIndex,
17394
+ lastInMessage
17395
+ }));
17396
+ content.forEach((c, i) => {
17371
17397
  const ct = c.type;
17372
17398
  if (ct === "tool_use") {
17373
17399
  const name = c.name ?? "";
@@ -17383,10 +17409,11 @@ function projectSubagentLine(line, agentId, state) {
17383
17409
  });
17384
17410
  }
17385
17411
  } else if (ct === "text") {
17386
- const text = c.text ?? "";
17387
- events.push({ kind: "sub_agent_text", agentId, text });
17412
+ const ev = textEvents.get(i);
17413
+ if (ev != null)
17414
+ events.push(ev);
17388
17415
  }
17389
- }
17416
+ });
17390
17417
  const stopReason = message?.stop_reason;
17391
17418
  if (stopReason === "end_turn") {
17392
17419
  events.push({ kind: "sub_agent_turn_end", agentId });
@@ -24074,10 +24101,26 @@ import { basename as basename2 } from "node:path";
24074
24101
  function resolveSkillName(input) {
24075
24102
  return readString(input, "skill") ?? readString(input, "skill_name") ?? readString(input, "skillName") ?? readString(input, "name") ?? skillBasenameFromPath(input);
24076
24103
  }
24077
- function filePathFrom(input) {
24078
- if (!input)
24104
+ function filePathFrom(input, rawPreview) {
24105
+ if (input) {
24106
+ const p = readString(input, "file_path") ?? readString(input, "notebook_path");
24107
+ if (p)
24108
+ return p;
24109
+ }
24110
+ if (rawPreview)
24111
+ return extractFilePathFromRaw(rawPreview);
24112
+ return null;
24113
+ }
24114
+ function extractFilePathFromRaw(raw) {
24115
+ const m = /"(?:file_path|notebook_path)"\s*:\s*"((?:[^"\\]|\\.)*)"/.exec(raw);
24116
+ if (!m)
24079
24117
  return null;
24080
- return readString(input, "file_path") ?? readString(input, "notebook_path");
24118
+ try {
24119
+ const value = JSON.parse(`"${m[1]}"`);
24120
+ return typeof value === "string" && value.length > 0 ? value : null;
24121
+ } catch {
24122
+ return null;
24123
+ }
24081
24124
  }
24082
24125
  function bashFirstToken(command) {
24083
24126
  const m = /^\s*([^\s|&;<>()`$]+)/.exec(command);
@@ -24142,7 +24185,7 @@ function matchesAllowRule(rule, toolName, inputPreview) {
24142
24185
  return bashFirstToken(cmd) === m[1];
24143
24186
  }
24144
24187
  if (FILE_TOOLS.has(ruleTool)) {
24145
- return filePathFrom(input) === arg;
24188
+ return filePathFrom(input, inputPreview) === arg;
24146
24189
  }
24147
24190
  return false;
24148
24191
  }
@@ -1,7 +1,7 @@
1
1
  # Waiting-for-reply UX — v2 spec (three-class contract)
2
2
 
3
- Tracks: [#545](https://github.com/mekenthompson/switchroom/issues/545),
4
- [#553](https://github.com/mekenthompson/switchroom/issues/553) (PR series),
3
+ Tracks: [#545](https://github.com/switchroom/switchroom/issues/545),
4
+ [#553](https://github.com/switchroom/switchroom/issues/553) (PR series),
5
5
  [#1713](https://github.com/switchroom/switchroom/issues/1713)
6
6
  (reflective status-reaction restoration)
7
7