switchroom 0.21.7 → 0.21.9

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 (59) hide show
  1. package/bin/tmp-reaper.sh +234 -0
  2. package/dist/agent-scheduler/index.js +1 -1
  3. package/dist/auth-broker/index.js +2 -2
  4. package/dist/cli/notion-write-pretool.mjs +1 -1
  5. package/dist/cli/switchroom.js +3520 -2782
  6. package/dist/host-control/main.js +177 -13
  7. package/dist/vault/approvals/kernel-server.js +2 -2
  8. package/dist/vault/broker/server.js +2 -2
  9. package/package.json +6 -5
  10. package/profiles/_base/start.sh.hbs +115 -0
  11. package/profiles/_shared/local-time.md.hbs +6 -0
  12. package/profiles/default/CLAUDE.md.hbs +0 -12
  13. package/skills/switchroom-architecture/telegram.md +12 -10
  14. package/skills/switchroom-cli/SKILL.md +1 -1
  15. package/telegram-plugin/README.md +3 -1
  16. package/telegram-plugin/dist/gateway/gateway.js +1164 -547
  17. package/telegram-plugin/format.ts +12 -4
  18. package/telegram-plugin/gateway/agent-process-liveness.ts +558 -0
  19. package/telegram-plugin/gateway/approval-hold.ts +32 -1
  20. package/telegram-plugin/gateway/approval-outcome-sources.ts +274 -0
  21. package/telegram-plugin/gateway/bridge-dead-watchdog.ts +21 -9
  22. package/telegram-plugin/gateway/callback-query-handlers.ts +87 -15
  23. package/telegram-plugin/gateway/eval-case-proposal-inbound-builders.ts +197 -0
  24. package/telegram-plugin/gateway/gateway.ts +12 -10
  25. package/telegram-plugin/gateway/pending-inbound-buffer.ts +167 -11
  26. package/telegram-plugin/gateway/self-improve-proposal-wiring.test.ts +333 -0
  27. package/telegram-plugin/gateway/self-improve-proposal-wiring.ts +152 -3
  28. package/telegram-plugin/gateway/subagent-handback-marker.ts +19 -0
  29. package/telegram-plugin/package.json +1 -1
  30. package/telegram-plugin/render/code-segments.ts +38 -4
  31. package/telegram-plugin/render/dollar-math-guard.ts +16 -1
  32. package/telegram-plugin/render/ir.ts +53 -3
  33. package/telegram-plugin/render/parse.ts +73 -14
  34. package/telegram-plugin/render/render.ts +53 -15
  35. package/telegram-plugin/render/unsupported-token-guard.ts +45 -80
  36. package/telegram-plugin/rich-send.ts +22 -7
  37. package/telegram-plugin/shared/bot-runtime.ts +3 -2
  38. package/telegram-plugin/telegraph.ts +6 -4
  39. package/telegram-plugin/tests/agent-process-liveness.test.ts +406 -0
  40. package/telegram-plugin/tests/approval-hold-record.test.ts +21 -8
  41. package/telegram-plugin/tests/boot-resume-gateway-only-respawn.test.ts +752 -0
  42. package/telegram-plugin/tests/boot-resume-guard-wiring.test.ts +203 -0
  43. package/telegram-plugin/tests/callback-query-handlers.test.ts +143 -1
  44. package/telegram-plugin/tests/eval-case-proposal-inbound-builders.test.ts +144 -0
  45. package/telegram-plugin/tests/grammy-rich-message-types.test.ts +199 -0
  46. package/telegram-plugin/tests/hermes-messages-paging.test.ts +149 -0
  47. package/telegram-plugin/tests/hermes-session-search.test.ts +146 -0
  48. package/telegram-plugin/tests/pending-inbound-buffer.test.ts +443 -2
  49. package/telegram-plugin/tests/render/dollar-math-guard.test.ts +43 -0
  50. package/telegram-plugin/tests/render/guard-composition.test.ts +102 -0
  51. package/telegram-plugin/tests/render/parse.test.ts +30 -5
  52. package/telegram-plugin/tests/render/render.test.ts +9 -4
  53. package/telegram-plugin/tests/render/rich-render.test.ts +46 -5
  54. package/telegram-plugin/tests/render/tg-entity.test.ts +242 -0
  55. package/telegram-plugin/tests/render/unsupported-token-guard.test.ts +66 -66
  56. package/telegram-plugin/tests/sent-text-capture.test.ts +3 -3
  57. package/telegram-plugin/tests/subagent-handback-marker.test.ts +14 -0
  58. package/telegram-plugin/tests/telegraph.test.ts +1 -1
  59. package/telegram-plugin/uat/scenarios/jtbd-rich-formatting-render-dm.test.ts +17 -8
@@ -128,17 +128,30 @@ describe('blocked-approval record — the off-Telegram surface', () => {
128
128
  // meant the whole feature was a silent no-op in production.
129
129
  it('falls back to the agent\'s own state dir when the shared dir is not writable', () => {
130
130
  // Simulate the production failure: Docker auto-created the bind source as
131
- // root:root, so this agent's uid can neither create the dir nor chmod it.
132
- // Modelled as a read-only PARENT — the store can't mkdir the shared dir
133
- // inside it, and can't chmod its way out either.
134
- const readOnlyParent = join(root, 'root-owned')
135
- mkdirSync(readOnlyParent, { recursive: true })
136
- chmodSync(readOnlyParent, 0o555) // r-xr-xr-x
137
- const unwritable = join(readOnlyParent, 'blocked-approvals') // cannot be created
131
+ // root:root, so this agent's uid cannot write inside it.
132
+ //
133
+ // This used to be modelled as a read-only PARENT (`chmod 0555`). uid 0
134
+ // IGNORES file modes, so under root the shared write SUCCEEDED, the fallback
135
+ // branch was never taken, and this test went red for the wrong reason (the
136
+ // suite runs as root in the fleet's debug container). Inject the EACCES
137
+ // instead — deterministic for every uid, and every branch of the real
138
+ // `write()` still runs.
139
+ const unwritable = join(root, 'root-owned', 'blocked-approvals')
138
140
  const ownDir = join(root, 'agent-state')
139
141
  mkdirSync(ownDir, { recursive: true })
140
142
 
141
- const store = createBlockedApprovalStore(unwritable, 'overlord', ownDir)
143
+ const store = createBlockedApprovalStore(unwritable, 'overlord', ownDir, {
144
+ writeFileSync: ((file, data, opts) => {
145
+ if (String(file).startsWith(unwritable)) {
146
+ const e: NodeJS.ErrnoException = new Error(
147
+ `EACCES: permission denied, open '${String(file)}'`,
148
+ )
149
+ e.code = 'EACCES'
150
+ throw e
151
+ }
152
+ return writeFileSync(file, data, opts)
153
+ }) as typeof writeFileSync,
154
+ })
142
155
  store.write(REC)
143
156
 
144
157
  // The record MUST exist somewhere — never silently lost.