visionclaw 0.1.219-beta.0 → 0.1.219-dev.codex-issue-2805-worker-runtime.1

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 (520) hide show
  1. package/dist/agent/api-proxy.d.ts +0 -16
  2. package/dist/agent/api-proxy.d.ts.map +1 -1
  3. package/dist/agent/api-proxy.js +9 -8
  4. package/dist/agent/api-proxy.js.map +1 -1
  5. package/dist/agent/browser-launcher.d.ts +3 -0
  6. package/dist/agent/browser-launcher.d.ts.map +1 -1
  7. package/dist/agent/browser-launcher.js +101 -43
  8. package/dist/agent/browser-launcher.js.map +1 -1
  9. package/dist/agent/coding-conventions.d.ts +8 -0
  10. package/dist/agent/coding-conventions.d.ts.map +1 -0
  11. package/dist/agent/coding-conventions.js +19 -0
  12. package/dist/agent/coding-conventions.js.map +1 -0
  13. package/dist/agent/command-handlers.d.ts.map +1 -1
  14. package/dist/agent/command-handlers.js +4 -16
  15. package/dist/agent/command-handlers.js.map +1 -1
  16. package/dist/agent/context-action-restart-fallback.d.ts.map +1 -1
  17. package/dist/agent/context-action-restart-fallback.js +9 -3
  18. package/dist/agent/context-action-restart-fallback.js.map +1 -1
  19. package/dist/agent/context-refresh.d.ts.map +1 -1
  20. package/dist/agent/context-refresh.js +0 -7
  21. package/dist/agent/context-refresh.js.map +1 -1
  22. package/dist/agent/context.d.ts +2 -4
  23. package/dist/agent/context.d.ts.map +1 -1
  24. package/dist/agent/context.js +12 -21
  25. package/dist/agent/context.js.map +1 -1
  26. package/dist/agent/engine-fallback.d.ts +0 -35
  27. package/dist/agent/engine-fallback.d.ts.map +1 -1
  28. package/dist/agent/engine-fallback.js +4 -3
  29. package/dist/agent/engine-fallback.js.map +1 -1
  30. package/dist/agent/engine-switch.d.ts +19 -38
  31. package/dist/agent/engine-switch.d.ts.map +1 -1
  32. package/dist/agent/engine-switch.js +46 -111
  33. package/dist/agent/engine-switch.js.map +1 -1
  34. package/dist/agent/engines/browser-tool-policy.d.ts +12 -1
  35. package/dist/agent/engines/browser-tool-policy.d.ts.map +1 -1
  36. package/dist/agent/engines/browser-tool-policy.js +17 -2
  37. package/dist/agent/engines/browser-tool-policy.js.map +1 -1
  38. package/dist/agent/engines/claude/executor-shell-groups.d.ts +11 -0
  39. package/dist/agent/engines/claude/executor-shell-groups.d.ts.map +1 -0
  40. package/dist/agent/engines/claude/executor-shell-groups.js +22 -0
  41. package/dist/agent/engines/claude/executor-shell-groups.js.map +1 -0
  42. package/dist/agent/engines/claude/session.d.ts +13 -4
  43. package/dist/agent/engines/claude/session.d.ts.map +1 -1
  44. package/dist/agent/engines/claude/session.js +165 -84
  45. package/dist/agent/engines/claude/session.js.map +1 -1
  46. package/dist/agent/engines/pi/shared/usage.d.ts +6 -8
  47. package/dist/agent/engines/pi/shared/usage.d.ts.map +1 -1
  48. package/dist/agent/engines/pi/shared/usage.js +24 -7
  49. package/dist/agent/engines/pi/shared/usage.js.map +1 -1
  50. package/dist/agent/engines/pi/tools.d.ts +3 -10
  51. package/dist/agent/engines/pi/tools.d.ts.map +1 -1
  52. package/dist/agent/engines/pi/tools.js +6 -20
  53. package/dist/agent/engines/pi/tools.js.map +1 -1
  54. package/dist/agent/engines/pi-coding/executor-shell.d.ts +4 -0
  55. package/dist/agent/engines/pi-coding/executor-shell.d.ts.map +1 -0
  56. package/dist/agent/engines/pi-coding/executor-shell.js +175 -0
  57. package/dist/agent/engines/pi-coding/executor-shell.js.map +1 -0
  58. package/dist/agent/engines/pi-coding/session.d.ts +4 -4
  59. package/dist/agent/engines/pi-coding/session.d.ts.map +1 -1
  60. package/dist/agent/engines/pi-coding/session.js +118 -66
  61. package/dist/agent/engines/pi-coding/session.js.map +1 -1
  62. package/dist/agent/engines/pi-coding/tools.d.ts +2 -5
  63. package/dist/agent/engines/pi-coding/tools.d.ts.map +1 -1
  64. package/dist/agent/engines/pi-coding/tools.js +7 -5
  65. package/dist/agent/engines/pi-coding/tools.js.map +1 -1
  66. package/dist/agent/engines/session-types.d.ts +8 -8
  67. package/dist/agent/engines/session-types.d.ts.map +1 -1
  68. package/dist/agent/external-context/interrupt.d.ts +0 -2
  69. package/dist/agent/external-context/interrupt.d.ts.map +1 -1
  70. package/dist/agent/external-context/interrupt.js +0 -1
  71. package/dist/agent/external-context/interrupt.js.map +1 -1
  72. package/dist/agent/external-context/registry.d.ts +0 -2
  73. package/dist/agent/external-context/registry.d.ts.map +1 -1
  74. package/dist/agent/external-context/registry.js +2 -4
  75. package/dist/agent/external-context/registry.js.map +1 -1
  76. package/dist/agent/external-context/runtime.d.ts.map +1 -1
  77. package/dist/agent/external-context/runtime.js +15 -14
  78. package/dist/agent/external-context/runtime.js.map +1 -1
  79. package/dist/agent/external-context/types.d.ts +0 -2
  80. package/dist/agent/external-context/types.d.ts.map +1 -1
  81. package/dist/agent/fast-responder.d.ts +4 -20
  82. package/dist/agent/fast-responder.d.ts.map +1 -1
  83. package/dist/agent/fast-responder.js +28 -42
  84. package/dist/agent/fast-responder.js.map +1 -1
  85. package/dist/agent/interrupt-handler.d.ts +0 -6
  86. package/dist/agent/interrupt-handler.d.ts.map +1 -1
  87. package/dist/agent/interrupt-handler.js +5 -47
  88. package/dist/agent/interrupt-handler.js.map +1 -1
  89. package/dist/agent/lab-run-system-prompt.d.ts.map +1 -1
  90. package/dist/agent/lab-run-system-prompt.js +4 -1
  91. package/dist/agent/lab-run-system-prompt.js.map +1 -1
  92. package/dist/agent/lifecycle-trace.d.ts.map +1 -1
  93. package/dist/agent/lifecycle-trace.js +6 -5
  94. package/dist/agent/lifecycle-trace.js.map +1 -1
  95. package/dist/agent/loop.d.ts +8 -2
  96. package/dist/agent/loop.d.ts.map +1 -1
  97. package/dist/agent/loop.js +287 -156
  98. package/dist/agent/loop.js.map +1 -1
  99. package/dist/agent/memory-protocol.d.ts +2 -2
  100. package/dist/agent/memory-protocol.d.ts.map +1 -1
  101. package/dist/agent/memory-protocol.js +3 -15
  102. package/dist/agent/memory-protocol.js.map +1 -1
  103. package/dist/agent/memory-store.d.ts +58 -0
  104. package/dist/agent/memory-store.d.ts.map +1 -0
  105. package/dist/agent/memory-store.js +152 -0
  106. package/dist/agent/memory-store.js.map +1 -0
  107. package/dist/agent/model-provider.d.ts +18 -5
  108. package/dist/agent/model-provider.d.ts.map +1 -1
  109. package/dist/agent/model-provider.js +58 -18
  110. package/dist/agent/model-provider.js.map +1 -1
  111. package/dist/agent/nightly-maintenance/dreaming-batch.d.ts +184 -0
  112. package/dist/agent/nightly-maintenance/dreaming-batch.d.ts.map +1 -0
  113. package/dist/agent/nightly-maintenance/dreaming-batch.js +192 -0
  114. package/dist/agent/nightly-maintenance/dreaming-batch.js.map +1 -0
  115. package/dist/agent/nightly-maintenance/dreaming-files.d.ts +48 -0
  116. package/dist/agent/nightly-maintenance/dreaming-files.d.ts.map +1 -0
  117. package/dist/agent/nightly-maintenance/dreaming-files.js +109 -0
  118. package/dist/agent/nightly-maintenance/dreaming-files.js.map +1 -0
  119. package/dist/agent/nightly-maintenance/dreaming-ledger.d.ts +62 -0
  120. package/dist/agent/nightly-maintenance/dreaming-ledger.d.ts.map +1 -0
  121. package/dist/agent/nightly-maintenance/dreaming-ledger.js +146 -0
  122. package/dist/agent/nightly-maintenance/dreaming-ledger.js.map +1 -0
  123. package/dist/agent/nightly-maintenance/dreaming-planner.d.ts +86 -0
  124. package/dist/agent/nightly-maintenance/dreaming-planner.d.ts.map +1 -0
  125. package/dist/agent/nightly-maintenance/dreaming-planner.js +304 -0
  126. package/dist/agent/nightly-maintenance/dreaming-planner.js.map +1 -0
  127. package/dist/agent/nightly-maintenance/dreaming-runner.d.ts +93 -0
  128. package/dist/agent/nightly-maintenance/dreaming-runner.d.ts.map +1 -0
  129. package/dist/agent/nightly-maintenance/dreaming-runner.js +156 -0
  130. package/dist/agent/nightly-maintenance/dreaming-runner.js.map +1 -0
  131. package/dist/agent/nightly-maintenance/dreaming-sources.d.ts +115 -0
  132. package/dist/agent/nightly-maintenance/dreaming-sources.d.ts.map +1 -0
  133. package/dist/agent/nightly-maintenance/dreaming-sources.js +270 -0
  134. package/dist/agent/nightly-maintenance/dreaming-sources.js.map +1 -0
  135. package/dist/agent/nightly-maintenance/index.d.ts +28 -8
  136. package/dist/agent/nightly-maintenance/index.d.ts.map +1 -1
  137. package/dist/agent/nightly-maintenance/index.js +42 -15
  138. package/dist/agent/nightly-maintenance/index.js.map +1 -1
  139. package/dist/agent/nightly-maintenance/skill-learning-gate.js +1 -1
  140. package/dist/agent/nightly-maintenance/skill-learning-gate.js.map +1 -1
  141. package/dist/agent/nightly-maintenance/vocabulary-processor.d.ts +1 -1
  142. package/dist/agent/nightly-maintenance/vocabulary-processor.d.ts.map +1 -1
  143. package/dist/agent/product-identity.d.ts +5 -4
  144. package/dist/agent/product-identity.d.ts.map +1 -1
  145. package/dist/agent/product-identity.js +7 -6
  146. package/dist/agent/product-identity.js.map +1 -1
  147. package/dist/agent/public-activity.js +1 -1
  148. package/dist/agent/public-activity.js.map +1 -1
  149. package/dist/agent/runtime-context.d.ts +27 -0
  150. package/dist/agent/runtime-context.d.ts.map +1 -0
  151. package/dist/agent/runtime-context.js +60 -0
  152. package/dist/agent/runtime-context.js.map +1 -0
  153. package/dist/agent/runtime-disclosure-policy.d.ts +6 -0
  154. package/dist/agent/runtime-disclosure-policy.d.ts.map +1 -0
  155. package/dist/agent/runtime-disclosure-policy.js +16 -0
  156. package/dist/agent/runtime-disclosure-policy.js.map +1 -0
  157. package/dist/agent/runtime-surface.d.ts +15 -4
  158. package/dist/agent/runtime-surface.d.ts.map +1 -1
  159. package/dist/agent/runtime-surface.js +0 -1
  160. package/dist/agent/runtime-surface.js.map +1 -1
  161. package/dist/agent/session-manager.d.ts +30 -126
  162. package/dist/agent/session-manager.d.ts.map +1 -1
  163. package/dist/agent/session-manager.js +60 -484
  164. package/dist/agent/session-manager.js.map +1 -1
  165. package/dist/agent/state.d.ts +42 -2
  166. package/dist/agent/state.d.ts.map +1 -1
  167. package/dist/agent/state.js +21 -11
  168. package/dist/agent/state.js.map +1 -1
  169. package/dist/agent/stream-handler.d.ts +6 -13
  170. package/dist/agent/stream-handler.d.ts.map +1 -1
  171. package/dist/agent/stream-handler.js +8 -62
  172. package/dist/agent/stream-handler.js.map +1 -1
  173. package/dist/agent/system-prompt.d.ts +2 -0
  174. package/dist/agent/system-prompt.d.ts.map +1 -1
  175. package/dist/agent/system-prompt.js +21 -20
  176. package/dist/agent/system-prompt.js.map +1 -1
  177. package/dist/agent/tool-usage.d.ts.map +1 -1
  178. package/dist/agent/tool-usage.js +0 -1
  179. package/dist/agent/tool-usage.js.map +1 -1
  180. package/dist/agent/transcript/transcript-backfill.js +3 -3
  181. package/dist/agent/transcript/transcript-backfill.js.map +1 -1
  182. package/dist/agent/transcript/transcript-indexer.d.ts +3 -31
  183. package/dist/agent/transcript/transcript-indexer.d.ts.map +1 -1
  184. package/dist/agent/transcript/transcript-indexer.js +58 -57
  185. package/dist/agent/transcript/transcript-indexer.js.map +1 -1
  186. package/dist/agent/transcript-parsers/trivial-tools.d.ts.map +1 -1
  187. package/dist/agent/transcript-parsers/trivial-tools.js +0 -2
  188. package/dist/agent/transcript-parsers/trivial-tools.js.map +1 -1
  189. package/dist/agent/transcript-parsers/types.d.ts +1 -1
  190. package/dist/agent/transcript-summarizer.d.ts +14 -0
  191. package/dist/agent/transcript-summarizer.d.ts.map +1 -1
  192. package/dist/agent/transcript-summarizer.js +69 -45
  193. package/dist/agent/transcript-summarizer.js.map +1 -1
  194. package/dist/agent/usage/usage-report-queue.d.ts.map +1 -1
  195. package/dist/agent/usage/usage-report-queue.js +53 -52
  196. package/dist/agent/usage/usage-report-queue.js.map +1 -1
  197. package/dist/agent/usage/usage-report-types.d.ts +1 -1
  198. package/dist/agent/usage/usage-report-types.d.ts.map +1 -1
  199. package/dist/agent/vocabulary-glossary.d.ts +3 -3
  200. package/dist/agent/wake-cycle-runner.d.ts +14 -17
  201. package/dist/agent/wake-cycle-runner.d.ts.map +1 -1
  202. package/dist/agent/wake-cycle-runner.js +121 -290
  203. package/dist/agent/wake-cycle-runner.js.map +1 -1
  204. package/dist/builtin-skills/owner-manual/SKILL.md +2 -2
  205. package/dist/calendar/occurrence-ownership.d.ts.map +1 -1
  206. package/dist/calendar/occurrence-ownership.js +6 -5
  207. package/dist/calendar/occurrence-ownership.js.map +1 -1
  208. package/dist/calendar/scheduler.d.ts.map +1 -1
  209. package/dist/calendar/scheduler.js +4 -3
  210. package/dist/calendar/scheduler.js.map +1 -1
  211. package/dist/channels/interface.d.ts +8 -2
  212. package/dist/channels/interface.d.ts.map +1 -1
  213. package/dist/channels/interface.js +8 -1
  214. package/dist/channels/interface.js.map +1 -1
  215. package/dist/channels/manager.d.ts.map +1 -1
  216. package/dist/channels/manager.js +5 -1
  217. package/dist/channels/manager.js.map +1 -1
  218. package/dist/channels/queue.d.ts.map +1 -1
  219. package/dist/channels/queue.js +8 -0
  220. package/dist/channels/queue.js.map +1 -1
  221. package/dist/channels/tui.d.ts +14 -1
  222. package/dist/channels/tui.d.ts.map +1 -1
  223. package/dist/channels/tui.js +64 -2
  224. package/dist/channels/tui.js.map +1 -1
  225. package/dist/cli/index.d.ts +2 -2
  226. package/dist/cli/index.d.ts.map +1 -1
  227. package/dist/cli/index.js +22 -53
  228. package/dist/cli/index.js.map +1 -1
  229. package/dist/config/index.d.ts +13 -7
  230. package/dist/config/index.d.ts.map +1 -1
  231. package/dist/config/index.js +51 -64
  232. package/dist/config/index.js.map +1 -1
  233. package/dist/config/types.d.ts +28 -7
  234. package/dist/config/types.d.ts.map +1 -1
  235. package/dist/config/types.js +22 -20
  236. package/dist/config/types.js.map +1 -1
  237. package/dist/conversations/lazy-runtime.d.ts +5 -0
  238. package/dist/conversations/lazy-runtime.d.ts.map +1 -0
  239. package/dist/conversations/lazy-runtime.js +12 -0
  240. package/dist/conversations/lazy-runtime.js.map +1 -0
  241. package/dist/conversations/runtime.d.ts +17 -0
  242. package/dist/conversations/runtime.d.ts.map +1 -0
  243. package/dist/conversations/runtime.js +92 -0
  244. package/dist/conversations/runtime.js.map +1 -0
  245. package/dist/conversations/scheduler.d.ts +57 -0
  246. package/dist/conversations/scheduler.d.ts.map +1 -0
  247. package/dist/conversations/scheduler.js +175 -0
  248. package/dist/conversations/scheduler.js.map +1 -0
  249. package/dist/data-processing/pipeline.d.ts +0 -2
  250. package/dist/data-processing/pipeline.d.ts.map +1 -1
  251. package/dist/data-processing/pipeline.js +19 -24
  252. package/dist/data-processing/pipeline.js.map +1 -1
  253. package/dist/data-processing/restructure.d.ts +0 -2
  254. package/dist/data-processing/restructure.d.ts.map +1 -1
  255. package/dist/data-processing/restructure.js +6 -9
  256. package/dist/data-processing/restructure.js.map +1 -1
  257. package/dist/data-processing/types.d.ts +2 -9
  258. package/dist/data-processing/types.d.ts.map +1 -1
  259. package/dist/data-processing/types.js +2 -13
  260. package/dist/data-processing/types.js.map +1 -1
  261. package/dist/email/email-route-store.d.ts.map +1 -1
  262. package/dist/email/email-route-store.js +6 -5
  263. package/dist/email/email-route-store.js.map +1 -1
  264. package/dist/i18n/messages.d.ts +26 -2
  265. package/dist/i18n/messages.d.ts.map +1 -1
  266. package/dist/i18n/messages.js +30 -5
  267. package/dist/i18n/messages.js.map +1 -1
  268. package/dist/index.js.map +1 -1
  269. package/dist/logger.d.ts +11 -0
  270. package/dist/logger.d.ts.map +1 -1
  271. package/dist/logger.js +49 -1
  272. package/dist/logger.js.map +1 -1
  273. package/dist/obs/mini-app/status.d.ts.map +1 -1
  274. package/dist/obs/mini-app/status.js +0 -1
  275. package/dist/obs/mini-app/status.js.map +1 -1
  276. package/dist/onboarding/onboarding-service-client.d.ts +1 -0
  277. package/dist/onboarding/onboarding-service-client.d.ts.map +1 -1
  278. package/dist/onboarding/onboarding-service-client.js.map +1 -1
  279. package/dist/onboarding/remote-set-owner.d.ts.map +1 -1
  280. package/dist/onboarding/remote-set-owner.js +0 -1
  281. package/dist/onboarding/remote-set-owner.js.map +1 -1
  282. package/dist/onboarding/set-owner.d.ts +1 -1
  283. package/dist/onboarding/set-owner.d.ts.map +1 -1
  284. package/dist/onboarding/set-owner.js +3 -6
  285. package/dist/onboarding/set-owner.js.map +1 -1
  286. package/dist/reconfigure.d.ts.map +1 -1
  287. package/dist/reconfigure.js +1 -32
  288. package/dist/reconfigure.js.map +1 -1
  289. package/dist/reset.d.ts.map +1 -1
  290. package/dist/reset.js +3 -1
  291. package/dist/reset.js.map +1 -1
  292. package/dist/threads/active-threads-store.d.ts.map +1 -1
  293. package/dist/threads/active-threads-store.js +8 -27
  294. package/dist/threads/active-threads-store.js.map +1 -1
  295. package/dist/threads/dreaming-execution.d.ts +10 -0
  296. package/dist/threads/dreaming-execution.d.ts.map +1 -0
  297. package/dist/threads/dreaming-execution.js +78 -0
  298. package/dist/threads/dreaming-execution.js.map +1 -0
  299. package/dist/threads/execution-authority.d.ts +43 -0
  300. package/dist/threads/execution-authority.d.ts.map +1 -0
  301. package/dist/threads/execution-authority.js +75 -0
  302. package/dist/threads/execution-authority.js.map +1 -0
  303. package/dist/threads/execution-budget.d.ts +107 -0
  304. package/dist/threads/execution-budget.d.ts.map +1 -0
  305. package/dist/threads/execution-budget.js +257 -0
  306. package/dist/threads/execution-budget.js.map +1 -0
  307. package/dist/threads/execution-host.d.ts +17 -0
  308. package/dist/threads/execution-host.d.ts.map +1 -0
  309. package/dist/threads/execution-host.js +66 -0
  310. package/dist/threads/execution-host.js.map +1 -0
  311. package/dist/threads/execution-scheduler.d.ts +162 -0
  312. package/dist/threads/execution-scheduler.d.ts.map +1 -0
  313. package/dist/threads/execution-scheduler.js +413 -0
  314. package/dist/threads/execution-scheduler.js.map +1 -0
  315. package/dist/threads/execution-snapshot.d.ts +91 -0
  316. package/dist/threads/execution-snapshot.d.ts.map +1 -0
  317. package/dist/threads/execution-snapshot.js +146 -0
  318. package/dist/threads/execution-snapshot.js.map +1 -0
  319. package/dist/threads/execution-store.d.ts +374 -0
  320. package/dist/threads/execution-store.d.ts.map +1 -0
  321. package/dist/threads/execution-store.js +910 -0
  322. package/dist/threads/execution-store.js.map +1 -0
  323. package/dist/threads/execution-thread-error.d.ts +9 -0
  324. package/dist/threads/execution-thread-error.d.ts.map +1 -0
  325. package/dist/threads/execution-thread-error.js +12 -0
  326. package/dist/threads/execution-thread-error.js.map +1 -0
  327. package/dist/threads/executor-exit.d.ts +18 -0
  328. package/dist/threads/executor-exit.d.ts.map +1 -0
  329. package/dist/threads/executor-exit.js +21 -0
  330. package/dist/threads/executor-exit.js.map +1 -0
  331. package/dist/threads/foreground-task.d.ts +91 -0
  332. package/dist/threads/foreground-task.d.ts.map +1 -0
  333. package/dist/threads/foreground-task.js +191 -0
  334. package/dist/threads/foreground-task.js.map +1 -0
  335. package/dist/threads/foreman-business.d.ts +9 -0
  336. package/dist/threads/foreman-business.d.ts.map +1 -0
  337. package/dist/threads/foreman-business.js +117 -0
  338. package/dist/threads/foreman-business.js.map +1 -0
  339. package/dist/threads/foreman-client.d.ts +18 -0
  340. package/dist/threads/foreman-client.d.ts.map +1 -0
  341. package/dist/threads/foreman-client.js +51 -0
  342. package/dist/threads/foreman-client.js.map +1 -0
  343. package/dist/threads/foreman-delivery.d.ts +5 -0
  344. package/dist/threads/foreman-delivery.d.ts.map +1 -0
  345. package/dist/threads/foreman-delivery.js +21 -0
  346. package/dist/threads/foreman-delivery.js.map +1 -0
  347. package/dist/threads/foreman-execution.d.ts +32 -0
  348. package/dist/threads/foreman-execution.d.ts.map +1 -0
  349. package/dist/threads/foreman-execution.js +90 -0
  350. package/dist/threads/foreman-execution.js.map +1 -0
  351. package/dist/threads/foreman-host.d.ts +77 -0
  352. package/dist/threads/foreman-host.d.ts.map +1 -0
  353. package/dist/threads/foreman-host.js +891 -0
  354. package/dist/threads/foreman-host.js.map +1 -0
  355. package/dist/threads/foreman-protocol.d.ts +242 -0
  356. package/dist/threads/foreman-protocol.d.ts.map +1 -0
  357. package/dist/threads/foreman-protocol.js +116 -0
  358. package/dist/threads/foreman-protocol.js.map +1 -0
  359. package/dist/threads/foreman-store.d.ts +151 -0
  360. package/dist/threads/foreman-store.d.ts.map +1 -0
  361. package/dist/threads/foreman-store.js +299 -0
  362. package/dist/threads/foreman-store.js.map +1 -0
  363. package/dist/threads/generic-execution.d.ts +25 -0
  364. package/dist/threads/generic-execution.d.ts.map +1 -0
  365. package/dist/threads/generic-execution.js +86 -0
  366. package/dist/threads/generic-execution.js.map +1 -0
  367. package/dist/threads/init-thread-dir.d.ts +2 -2
  368. package/dist/threads/init-thread-dir.d.ts.map +1 -1
  369. package/dist/threads/init-thread-dir.js +6 -6
  370. package/dist/threads/init-thread-dir.js.map +1 -1
  371. package/dist/threads/ipc.d.ts +108 -2
  372. package/dist/threads/ipc.d.ts.map +1 -1
  373. package/dist/threads/ipc.js +14 -2
  374. package/dist/threads/ipc.js.map +1 -1
  375. package/dist/threads/lab-run-thread.d.ts +3 -5
  376. package/dist/threads/lab-run-thread.d.ts.map +1 -1
  377. package/dist/threads/lab-run-thread.js +3 -5
  378. package/dist/threads/lab-run-thread.js.map +1 -1
  379. package/dist/threads/lab-runtime-policy.d.ts +26 -21
  380. package/dist/threads/lab-runtime-policy.d.ts.map +1 -1
  381. package/dist/threads/lab-runtime-policy.js +31 -126
  382. package/dist/threads/lab-runtime-policy.js.map +1 -1
  383. package/dist/threads/process-group.d.ts +41 -0
  384. package/dist/threads/process-group.d.ts.map +1 -0
  385. package/dist/threads/process-group.js +161 -0
  386. package/dist/threads/process-group.js.map +1 -0
  387. package/dist/threads/relay-adapter.d.ts +8 -0
  388. package/dist/threads/relay-adapter.d.ts.map +1 -1
  389. package/dist/threads/relay-adapter.js +26 -1
  390. package/dist/threads/relay-adapter.js.map +1 -1
  391. package/dist/threads/supervisor.d.ts +191 -57
  392. package/dist/threads/supervisor.d.ts.map +1 -1
  393. package/dist/threads/supervisor.js +766 -427
  394. package/dist/threads/supervisor.js.map +1 -1
  395. package/dist/threads/task-workspace.d.ts +8 -0
  396. package/dist/threads/task-workspace.d.ts.map +1 -0
  397. package/dist/threads/task-workspace.js +52 -0
  398. package/dist/threads/task-workspace.js.map +1 -0
  399. package/dist/threads/worker-entry.d.ts.map +1 -1
  400. package/dist/threads/worker-entry.js +314 -34
  401. package/dist/threads/worker-entry.js.map +1 -1
  402. package/dist/threads/worker-execution-runtime.d.ts +75 -0
  403. package/dist/threads/worker-execution-runtime.d.ts.map +1 -0
  404. package/dist/threads/worker-execution-runtime.js +142 -0
  405. package/dist/threads/worker-execution-runtime.js.map +1 -0
  406. package/dist/threads/worker-execution.d.ts +35 -0
  407. package/dist/threads/worker-execution.d.ts.map +1 -0
  408. package/dist/threads/worker-execution.js +2 -0
  409. package/dist/threads/worker-execution.js.map +1 -0
  410. package/dist/threads/worker-runtime-policy.d.ts +42 -0
  411. package/dist/threads/worker-runtime-policy.d.ts.map +1 -0
  412. package/dist/threads/worker-runtime-policy.js +98 -0
  413. package/dist/threads/worker-runtime-policy.js.map +1 -0
  414. package/dist/tools/adapter-tool.d.ts +12 -0
  415. package/dist/tools/adapter-tool.d.ts.map +1 -0
  416. package/dist/tools/adapter-tool.js +2 -0
  417. package/dist/tools/adapter-tool.js.map +1 -0
  418. package/dist/tools/data-service.d.ts +2 -2
  419. package/dist/tools/delegation.d.ts +121 -0
  420. package/dist/tools/delegation.d.ts.map +1 -0
  421. package/dist/tools/delegation.js +106 -0
  422. package/dist/tools/delegation.js.map +1 -0
  423. package/dist/tools/dream-memory.d.ts +122 -0
  424. package/dist/tools/dream-memory.d.ts.map +1 -0
  425. package/dist/tools/dream-memory.js +513 -0
  426. package/dist/tools/dream-memory.js.map +1 -0
  427. package/dist/tools/email.d.ts +1 -1
  428. package/dist/tools/execution-control.d.ts +31 -0
  429. package/dist/tools/execution-control.d.ts.map +1 -0
  430. package/dist/tools/execution-control.js +71 -0
  431. package/dist/tools/execution-control.js.map +1 -0
  432. package/dist/tools/index.d.ts +5 -7
  433. package/dist/tools/index.d.ts.map +1 -1
  434. package/dist/tools/index.js +7 -13
  435. package/dist/tools/index.js.map +1 -1
  436. package/dist/tools/mcp-manager.d.ts +1 -1
  437. package/dist/tools/memory.d.ts +1 -1
  438. package/dist/tools/memory.d.ts.map +1 -1
  439. package/dist/tools/memory.js +69 -45
  440. package/dist/tools/memory.js.map +1 -1
  441. package/dist/tools/notify.d.ts +5 -0
  442. package/dist/tools/notify.d.ts.map +1 -1
  443. package/dist/tools/notify.js +45 -10
  444. package/dist/tools/notify.js.map +1 -1
  445. package/dist/tools/skill.d.ts +1 -1
  446. package/dist/tools/totp.d.ts +1 -1
  447. package/dist/tui/client.d.ts +1 -16
  448. package/dist/tui/client.d.ts.map +1 -1
  449. package/dist/tui/client.js +0 -4
  450. package/dist/tui/client.js.map +1 -1
  451. package/dist/tui/index.d.ts.map +1 -1
  452. package/dist/tui/index.js +0 -41
  453. package/dist/tui/index.js.map +1 -1
  454. package/dist/tui/protocol.d.ts +2 -1
  455. package/dist/tui/protocol.d.ts.map +1 -1
  456. package/dist/tui/protocol.js +2 -1
  457. package/dist/tui/protocol.js.map +1 -1
  458. package/dist/tui/renderer.d.ts.map +1 -1
  459. package/dist/tui/renderer.js +0 -5
  460. package/dist/tui/renderer.js.map +1 -1
  461. package/dist/tui/request-store.d.ts +1 -1
  462. package/dist/tui/request-store.d.ts.map +1 -1
  463. package/dist/tui/request-store.js +2 -2
  464. package/dist/tui/request-store.js.map +1 -1
  465. package/dist/tui/server.d.ts.map +1 -1
  466. package/dist/tui/server.js +137 -25
  467. package/dist/tui/server.js.map +1 -1
  468. package/dist/utils/claude-transcripts.d.ts +6 -0
  469. package/dist/utils/claude-transcripts.d.ts.map +1 -1
  470. package/dist/utils/claude-transcripts.js +8 -2
  471. package/dist/utils/claude-transcripts.js.map +1 -1
  472. package/dist/utils/restart.d.ts.map +1 -1
  473. package/dist/utils/restart.js +6 -0
  474. package/dist/utils/restart.js.map +1 -1
  475. package/dist-agent/bundle.cjs +2 -2
  476. package/package.json +1 -1
  477. package/dist/agent/mailbox.d.ts +0 -50
  478. package/dist/agent/mailbox.d.ts.map +0 -1
  479. package/dist/agent/mailbox.js +0 -124
  480. package/dist/agent/mailbox.js.map +0 -1
  481. package/dist/agent/nightly-maintenance/memory-dreaming-sweep.d.ts +0 -77
  482. package/dist/agent/nightly-maintenance/memory-dreaming-sweep.d.ts.map +0 -1
  483. package/dist/agent/nightly-maintenance/memory-dreaming-sweep.js +0 -158
  484. package/dist/agent/nightly-maintenance/memory-dreaming-sweep.js.map +0 -1
  485. package/dist/agent/nightly-maintenance/memory-dreaming.d.ts +0 -116
  486. package/dist/agent/nightly-maintenance/memory-dreaming.d.ts.map +0 -1
  487. package/dist/agent/nightly-maintenance/memory-dreaming.js +0 -458
  488. package/dist/agent/nightly-maintenance/memory-dreaming.js.map +0 -1
  489. package/dist/threads/task-contracts.d.ts +0 -194
  490. package/dist/threads/task-contracts.d.ts.map +0 -1
  491. package/dist/threads/task-contracts.js +0 -82
  492. package/dist/threads/task-contracts.js.map +0 -1
  493. package/dist/threads/task-sidecar.d.ts +0 -145
  494. package/dist/threads/task-sidecar.d.ts.map +0 -1
  495. package/dist/threads/task-sidecar.js +0 -311
  496. package/dist/threads/task-sidecar.js.map +0 -1
  497. package/dist/threads/task-store.d.ts +0 -172
  498. package/dist/threads/task-store.d.ts.map +0 -1
  499. package/dist/threads/task-store.js +0 -599
  500. package/dist/threads/task-store.js.map +0 -1
  501. package/dist/threads/thread-task-context.d.ts +0 -40
  502. package/dist/threads/thread-task-context.d.ts.map +0 -1
  503. package/dist/threads/thread-task-context.js +0 -160
  504. package/dist/threads/thread-task-context.js.map +0 -1
  505. package/dist/threads/thread-task-controller.d.ts +0 -122
  506. package/dist/threads/thread-task-controller.d.ts.map +0 -1
  507. package/dist/threads/thread-task-controller.js +0 -276
  508. package/dist/threads/thread-task-controller.js.map +0 -1
  509. package/dist/threads/thread-task-runtime.d.ts +0 -354
  510. package/dist/threads/thread-task-runtime.d.ts.map +0 -1
  511. package/dist/threads/thread-task-runtime.js +0 -917
  512. package/dist/threads/thread-task-runtime.js.map +0 -1
  513. package/dist/tools/switch-session.d.ts +0 -15
  514. package/dist/tools/switch-session.d.ts.map +0 -1
  515. package/dist/tools/switch-session.js +0 -88
  516. package/dist/tools/switch-session.js.map +0 -1
  517. package/dist/tools/thread-tasks.d.ts +0 -23
  518. package/dist/tools/thread-tasks.d.ts.map +0 -1
  519. package/dist/tools/thread-tasks.js +0 -122
  520. package/dist/tools/thread-tasks.js.map +0 -1
@@ -1,131 +1,24 @@
1
- import { isThreadTasksEnabled, isWorkspaceEnabled } from "../config/types.js";
2
1
  import { ClaudeAgentSession } from "./engines/claude/session.js";
3
2
  import { PiCodingAgentSession } from "./engines/pi-coding/session.js";
4
3
  import { getAgentEngine } from "./engines/engine-factory.js";
5
- import { loadOwnerConfig, rotateSessionId } from "../config/index.js";
6
- import { describeEffectiveBrowserSelection } from "./browser-selection.js";
7
- import { loadMailbox, setActiveSession, addMemo, consumeMemosFor, ackMemos, updateCodingSessionInfo, } from "./mailbox.js";
4
+ import { rotateSessionId } from "../config/index.js";
8
5
  import { logger } from "../logger.js";
9
- import { getAgentState } from "./state.js";
10
- import { buildMemoryProtocolSection } from "./memory-protocol.js";
11
- import { resolveWorkspaceCwd, sameWorkspaceCwd } from "./workspace-cwd.js";
12
- export function buildGeneralSessionAddendum(config) {
13
- const workspaceTasks = isWorkspaceEnabled(config)
14
- ? "- Status checks, scheduling, calendar tasks, and email\n"
15
- : "- Status checks and tasks using independently connected integrations when available\n";
16
- const codingWorkspaceHint = getAgentEngine(config) === "pi-coding"
17
- ? "When switching to the coding session for a task that involves a specific project or repository, pass the project's absolute path as the `cwd` parameter (e.g. `switch_session(target=\"coding\", cwd=\"/Users/jessica/myproject\", memo=\"...\")`). This sets the Pi SDK coding session's working directory so Bash commands default to the project root."
18
- : "The optional `cwd` parameter is ignored by Claude coding sessions and when switching back to general.";
19
- return `
20
- ## Session-Specific Instructions (General Session)
21
-
22
- You are currently in the **general session**. This session handles:
23
- - Conversations and quick questions from the owner
24
- ${workspaceTasks}- Simple one-off tasks (look something up, summarize information, etc.)
25
- - Monitoring and proactive behavior during heartbeats
26
-
27
- If the owner asks for a complex, multi-step coding task (refactoring, debugging, multi-file feature work), use \`switch_session(target="coding", memo="<task and known constraints>")\` to hand it off. Do NOT attempt sustained coding work in this session — it will pollute your context.
28
-
29
- ${codingWorkspaceHint}
30
-
31
- When the coding session is active or paused, you can tell the owner its status. If they send a message related to that task (e.g. "actually use a different approach"), forward it via \`switch_session(target="coding", memo="<the new instruction>")\` and do not continue the coding work yourself.
32
-
33
- When you receive a memo marked \`[Coding task complete — owner notification required]\`, \`notify_user\` with \`purpose="completion"\` and a concise human-language summary, then \`finish\`. The memo is internal working text — never paste it into chat. If you do not notify, the runtime still sends a short generic ping so the completion is not silently dropped.`;
34
- }
35
- export function buildCodingSessionAddendum(config, runtimeSurface) {
36
- const ownerConfig = loadOwnerConfig();
37
- const agentLabel = config.displayName ?? config.agentName;
38
- const workspaceIdentity = isWorkspaceEnabled(config)
39
- ? `- **Your email**: ${config.gmail}`
40
- : `- **Managed Workspace**: unavailable; independently connected MCP${runtimeSurface.browser.available ? "/browser" : ""} accounts may still be used, but they do not enable built-in Workspace tools or channels.`;
41
- // Claude coding uses the claude_code preset, so this addendum is the only
42
- // VisionClaw Memory Protocol that session sees. Pi already concatenates the
43
- // full owner prompt — do not duplicate the section there.
44
- const includeMemoryProtocol = getAgentEngine(config) === "claude";
45
- const extraTools = [
46
- runtimeSurface.browser.available ? "browser (Playwright MCP)" : null,
47
- runtimeSurface.desktop.available ? "desktop (computer_use_* tools)" : null,
48
- ].filter((part) => part !== null);
49
- const extraToolsClause = extraTools.length > 0
50
- ? ` ${extraTools[0][0].toUpperCase()}${extraTools.join(" and ").slice(1)} ${extraTools.length === 1 ? "is" : "are"} available if the task needs them — do not drift into unrelated desktop or browser work.`
51
- : "";
52
- const browserEngineLine = `- Browser engine: ${describeEffectiveBrowserSelection(runtimeSurface.browserSelection)}`;
53
- const memorySection = includeMemoryProtocol
54
- ? `\n\n${buildMemoryProtocolSection(isThreadTasksEnabled(config)).trimEnd()}`
55
- : "";
56
- return `
57
- ## VisionClaw Context
58
-
59
- You are **${agentLabel}**, the **coding session** of a dual-session VisionClaw agent on ${runtimeSurface.hostCapabilities.platformLabel}.
60
-
61
- ${workspaceIdentity}
62
- - **Owner**: ${ownerConfig.ownerName}${ownerConfig.ownerEmail ? ` <${ownerConfig.ownerEmail}>` : ""}
63
- ${browserEngineLine}
64
-
65
- Prefer terminal and filesystem tools for this session.${extraToolsClause} Custom VisionClaw tools include \`notify_user\`, \`memory\`, \`manage_skills\`, and \`switch_session\`.
66
-
67
- ## Communicating with the Owner (CRITICAL)
68
-
69
- Plain assistant text is process narration. Telegram and Fin-App put it on the progress card and do not post it as a chat bubble. TUI still shows it. It is not a substitute for \`notify_user\`.
70
-
71
- Use \`notify_user\` for:
72
- - Questions or blockers that need the owner (omit \`purpose\`)
73
- - Attachments / screenshots
74
- - The final result of this coding task: \`notify_user\` with \`purpose="completion"\`, then \`switch_session(target="general", reason="complete", memo="Task completed: <summary>")\`. The completion purpose prevents the general session from sending the same result again.
75
-
76
- ## Session-Specific Instructions (Coding Session)
77
-
78
- This session is reserved for focused, multi-step coding. Stay on the current task. If an unrelated message arrives (chat, question, non-coding request), \`switch_session(target="general", reason="handoff")\` with enough memo for general to reply. Use provider-specific coding or delegation tools when they help; keep orchestration here.
79
-
80
- ## Repository State (check before your first edit)
81
-
82
- This session resumes in whatever worktree and branch the previous task left behind. Before editing a git repository, run \`git status --short --branch\` (and \`git worktree list\` when there is more than one checkout).
83
-
84
- Decide which case you are in. Do not \`notify_user\` with git status unless you need the owner to decide:
85
- - **Continuing work that already has a branch** — stay on that branch.
86
- - **Starting a new task** — do not build on top of the previous task's branch. Begin from a freshly fetched main: \`git fetch origin\`, then \`git switch -c <branch> refs/remotes/origin/main\`. Skipping the fetch branches you off a stale main, which is the usual reason a diff fills up with changes that are not yours.
87
- - **Uncommitted changes you did not make** — ask the owner before committing, stashing, or discarding them.
88
-
89
- If your diff ends up carrying files or commits unrelated to the task, the base is wrong. Fix the base rather than explaining the noise in the PR.${memorySection}`;
90
- }
91
6
  /**
92
- * Manages two AgentSessions (general + coding) with cooperative switching.
7
+ * Owns the agent's single conversation session.
93
8
  *
94
- * Only one session is active at a time. The agent decides when to switch
95
- * by calling the switch_session tool. The manager handles suspending the
96
- * current session and resuming the target.
9
+ * Builds the engine-specific session object, exposes the runtime surface
10
+ * resolved at startup, and handles stop, reset, summary injection and MCP
11
+ * teardown for it.
97
12
  */
98
13
  export class SessionManager {
99
14
  config;
100
15
  buildBaseSystemPrompt;
101
16
  /** Resolved runtime tool and external MCP surface for this model/provider pair. */
102
17
  runtimeSurface;
103
- _requestedDualSessionEnabled;
104
- generalSession;
105
- codingSession = null;
106
- _activeMode = "general";
18
+ session;
107
19
  _managerStopRequested = false;
108
- /** Set after a switch_session tool call is detected in the stream. */
109
- _pendingSwitch = null;
110
- /** Propagated to all sessions for auto-screenshot after Playwright tools. */
111
- _screenshotInjector = null;
112
- buildCodingSystemPrompt() {
113
- if (getAgentEngine(this.config) !== "claude") {
114
- return this.buildBaseSystemPrompt() + buildCodingSessionAddendum(this.config, this.runtimeSurface);
115
- }
116
- return {
117
- type: "preset",
118
- preset: "claude_code",
119
- append: buildCodingSessionAddendum(this.config, this.runtimeSurface),
120
- // The addendum is rebuilt for each wake so runtime/config changes are
121
- // visible when the SDK resumes an existing transcript.
122
- snapshot: false,
123
- };
124
- }
125
- buildGeneralSystemPrompt() {
126
- const prompt = this.dualSessionEnabled
127
- ? this.buildBaseSystemPrompt() + buildGeneralSessionAddendum(this.config)
128
- : this.buildBaseSystemPrompt();
20
+ buildSystemPrompt() {
21
+ const prompt = this.buildBaseSystemPrompt();
129
22
  return getAgentEngine(this.config) === "claude"
130
23
  ? {
131
24
  type: "custom",
@@ -135,77 +28,32 @@ export class SessionManager {
135
28
  }
136
29
  : prompt;
137
30
  }
138
- buildSessionContext(mode) {
139
- return {
140
- mode,
141
- getDualSessionEnabled: () => this.dualSessionEnabled,
142
- };
143
- }
144
- createSession(buildPrompt, mode, workspaceCwd) {
145
- const engine = getAgentEngine(this.config);
146
- const effectiveWorkspaceCwd = workspaceCwd && (this.runtimeSurface.labRuntimePolicy || (mode === "coding" && engine === "pi-coding")) ? workspaceCwd : undefined;
31
+ createSession(workspaceCwd) {
147
32
  const args = {
148
33
  config: this.config,
149
- buildSystemPrompt: buildPrompt,
34
+ buildSystemPrompt: () => this.buildSystemPrompt(),
150
35
  runtimeSurface: this.runtimeSurface,
151
- sessionContext: this.buildSessionContext(mode),
152
- ...(effectiveWorkspaceCwd ? { workspaceCwd: effectiveWorkspaceCwd } : {}),
36
+ ...(workspaceCwd ? { workspaceCwd } : {}),
153
37
  };
154
- return engine === "pi-coding"
38
+ return getAgentEngine(this.config) === "pi-coding"
155
39
  ? new PiCodingAgentSession(args)
156
40
  : new ClaudeAgentSession(args);
157
41
  }
158
- codingWorkspaceCwd() {
159
- const cwd = loadMailbox().codingSession.cwd;
160
- if (!cwd)
161
- return undefined;
162
- try {
163
- return resolveWorkspaceCwd(cwd);
164
- }
165
- catch (error) {
166
- const detail = error instanceof Error ? error.message : String(error);
167
- logger.system(`Persisted coding workspace is unavailable; pausing coding and returning to general: ${detail}`);
168
- rotateSessionId("coding");
169
- updateCodingSessionInfo({ status: "paused", cwd: undefined });
170
- setActiveSession("general");
171
- return undefined;
172
- }
173
- }
174
- constructor(config, buildSystemPrompt, runtimeSurface, options) {
42
+ constructor(config, buildSystemPrompt, runtimeSurface, options = {}) {
175
43
  this.config = config;
176
44
  this.buildBaseSystemPrompt = buildSystemPrompt;
177
- this._requestedDualSessionEnabled = options.dualSessionEnabled;
178
45
  this.runtimeSurface = runtimeSurface;
179
46
  const engine = getAgentEngine(config);
180
- if (runtimeSurface.labRuntimePolicy && engine === "pi-coding" && !options.workspaceCwd) {
181
- throw new Error("Pi policy-isolated Lab sessions require a workspace cwd");
47
+ if (runtimeSurface.workerRuntimePolicy && engine === "pi-coding" && !options.workspaceCwd) {
48
+ throw new Error("Pi policy-isolated worker sessions require a workspace cwd");
182
49
  }
183
- if (runtimeSurface.labRuntimePolicy && engine !== "pi-coding" && options.workspaceCwd) {
184
- throw new Error("Workspace cwd overrides are supported only for Pi Lab sessions");
50
+ if (runtimeSurface.workerRuntimePolicy && engine !== "pi-coding" && options.workspaceCwd) {
51
+ throw new Error("Workspace cwd overrides are supported only for Pi worker sessions");
185
52
  }
186
- if (!runtimeSurface.labRuntimePolicy && options.workspaceCwd) {
187
- throw new Error("Startup workspace cwd overrides are supported only for Pi Lab workers");
53
+ if (!runtimeSurface.workerRuntimePolicy && options.workspaceCwd) {
54
+ throw new Error("Startup workspace cwd overrides are supported only for Pi workers");
188
55
  }
189
- this.generalSession = this.createSession(() => this.buildGeneralSystemPrompt(), "general", runtimeSurface.labRuntimePolicy ? options.workspaceCwd : undefined);
190
- if (this.dualSessionEnabled) {
191
- let mailbox = loadMailbox();
192
- if (mailbox.codingSession.status === "in_progress" || mailbox.codingSession.status === "paused") {
193
- const workspaceCwd = runtimeSurface.labRuntimePolicy
194
- ? options.workspaceCwd
195
- : engine === "pi-coding"
196
- ? this.codingWorkspaceCwd()
197
- : undefined;
198
- // Reload because stale-cwd recovery updates the durable mailbox.
199
- mailbox = loadMailbox();
200
- this.codingSession = this.createSession(() => this.buildCodingSystemPrompt(), "coding", workspaceCwd);
201
- }
202
- this._activeMode = mailbox.activeSession;
203
- }
204
- }
205
- get dualSessionEnabled() {
206
- return !this.runtimeSurface.labRuntimePolicy
207
- && this._requestedDualSessionEnabled
208
- && this.runtimeSurface.visionClawToolTransport.supportsSwitchSessionTool;
56
+ this.session = this.createSession(options.workspaceCwd);
209
57
  }
210
58
  /** Browser backend resolved at startup (see {@link RuntimeSurface}). */
211
59
  get resolvedBrowserBackend() {
@@ -226,355 +74,83 @@ export class SessionManager {
226
74
  get hostCapabilities() {
227
75
  return this.runtimeSurface.hostCapabilities;
228
76
  }
229
- /**
230
- * Toggle dual-session mode at runtime. Takes effect on the next wake cycle
231
- * because each query() call rebuilds its tool surface.
232
- */
233
- setDualSessionEnabled(enabled) {
234
- this._requestedDualSessionEnabled = enabled;
235
- if (!this.dualSessionEnabled && this._activeMode === "coding") {
236
- this._activeMode = "general";
237
- setActiveSession("general");
238
- logger.system("Dual session disabled — forced switch to general");
239
- }
240
- }
241
77
  /**
242
78
  * Set the screenshot injector that auto-injects screenshots after
243
- * Playwright tool calls. Propagated to all existing sessions.
79
+ * Playwright tool calls.
244
80
  */
245
81
  setScreenshotInjector(injector) {
246
- this._screenshotInjector = injector;
247
- this.generalSession.screenshotInjector = injector;
248
- if (this.codingSession) {
249
- this.codingSession.screenshotInjector = injector;
250
- }
251
- }
252
- get activeMode() {
253
- return this._activeMode;
82
+ this.session.screenshotInjector = injector;
254
83
  }
255
84
  get activeSession() {
256
- if (this._activeMode === "coding" && this.codingSession) {
257
- return this.codingSession;
258
- }
259
- return this.generalSession;
260
- }
261
- get pendingSwitch() {
262
- return this._pendingSwitch;
263
- }
264
- getActiveCodingTaskStartedAt() {
265
- return loadMailbox().codingSession.startedAt;
266
- }
267
- hasCompletionReceiptForActiveTask() {
268
- try {
269
- const taskStartedAt = this.getActiveCodingTaskStartedAt();
270
- return Boolean(taskStartedAt && getAgentState().codingCompletionTaskStartedAt === taskStartedAt);
271
- }
272
- catch {
273
- // Agent state is absent in isolated session-manager tests.
274
- return false;
275
- }
276
- }
277
- /**
278
- * Record a switch request detected from the stream.
279
- * The main loop should check this after each stream ends and act on it.
280
- */
281
- setSwitchRequest(req) {
282
- const { cwd: requestedCwd, ...requestWithoutCwd } = req;
283
- let cwd;
284
- if (req.target === "coding" && requestedCwd && getAgentEngine(this.config) === "pi-coding") {
285
- try {
286
- cwd = resolveWorkspaceCwd(requestedCwd);
287
- }
288
- catch (error) {
289
- logger.warn(`Ignoring unavailable coding workspace cwd and continuing with fallback: ${error instanceof Error ? error.message : String(error)}`);
290
- }
291
- }
292
- this._pendingSwitch = cwd
293
- ? { ...requestWithoutCwd, cwd }
294
- : requestWithoutCwd;
295
- }
296
- /**
297
- * Execute a pending session switch.
298
- * - Writes the memo to the mailbox
299
- * - Creates the coding session if it doesn't exist
300
- * - Updates the active mode
301
- * Returns the forwarded message content to send to the new session.
302
- */
303
- executePendingSwitch() {
304
- if (!this.dualSessionEnabled)
305
- return null;
306
- const req = this._pendingSwitch;
307
- if (!req)
308
- return null;
309
- this._pendingSwitch = null;
310
- const currentMode = this._activeMode;
311
- let workspaceNotice;
312
- const isCodingCompletion = currentMode === "coding" && req.target === "general" && req.reason === "complete";
313
- // The stream handler captures completionDelivered when it sees the
314
- // switch_session tool_use. If notify_user ran in the same assistant
315
- // message, its send resolves after that capture, so re-check the receipt
316
- // here (after the stream ended) before asking general to notify again.
317
- const completionDelivered = isCodingCompletion
318
- && (req.completionDelivered === true || this.hasCompletionReceiptForActiveTask());
319
- // A delivered coding completion needs no cross-session memo. Required
320
- // completions remain durable so general / runtime last-resort can still ping.
321
- if (req.memo && !completionDelivered) {
322
- const memo = isCodingCompletion
323
- ? [
324
- "[Coding task complete — owner notification required]",
325
- req.memo,
326
- "",
327
- "`notify_user` with purpose=`completion` and a concise, human-language summary (outcome, files changed, validation, caveats). Never paste this memo into chat. If you do not notify, the runtime still sends a short generic ping so the completion is not silently dropped.",
328
- ].join("\n")
329
- : req.memo;
330
- addMemo(currentMode, req.target, memo);
331
- }
332
- if (req.target === "coding") {
333
- const supportsWorkspaceCwd = getAgentEngine(this.config) === "pi-coding";
334
- const currentCwd = supportsWorkspaceCwd ? loadMailbox().codingSession.cwd : undefined;
335
- const requestedCwd = supportsWorkspaceCwd ? req.cwd ?? currentCwd : undefined;
336
- let workspaceCwd;
337
- let workspaceFallback = false;
338
- if (requestedCwd) {
339
- try {
340
- workspaceCwd = resolveWorkspaceCwd(requestedCwd);
341
- }
342
- catch (error) {
343
- workspaceFallback = true;
344
- workspaceNotice = "The persisted coding workspace is unavailable; continuing in the profile workspace fallback. The original project directory may need to be restored before making project changes.";
345
- logger.system(`Coding workspace is unavailable; falling back to the profile workspace: ${error instanceof Error ? error.message : String(error)}`);
346
- updateCodingSessionInfo({ cwd: undefined });
347
- this.codingSession?.requestStop();
348
- this.discardCodingSession();
349
- rotateSessionId("coding");
350
- }
351
- }
352
- if (!workspaceFallback && supportsWorkspaceCwd && req.cwd && (!currentCwd || !sameWorkspaceCwd(currentCwd, workspaceCwd ?? ""))) {
353
- this.codingSession?.requestStop();
354
- this.discardCodingSession();
355
- rotateSessionId("coding");
356
- logger.system(`Coding workspace changed: ${currentCwd ?? "(default)"} → ${workspaceCwd}; starting a fresh session`);
357
- }
358
- this.codingSession ??= this.createSession(() => this.buildCodingSystemPrompt(), "coding", workspaceCwd);
359
- if (this._screenshotInjector) {
360
- this.codingSession.screenshotInjector = this._screenshotInjector;
361
- }
362
- updateCodingSessionInfo({
363
- status: "in_progress",
364
- taskSummary: req.memo || "Coding task in progress",
365
- startedAt: new Date().toISOString(),
366
- ...(supportsWorkspaceCwd && workspaceCwd ? { cwd: workspaceCwd } : {}),
367
- });
368
- }
369
- else if (currentMode === "coding") {
370
- if (req.reason === "complete") {
371
- updateCodingSessionInfo({ status: "completed" });
372
- }
373
- else {
374
- updateCodingSessionInfo({ status: "paused" });
375
- }
376
- }
377
- this._activeMode = req.target;
378
- setActiveSession(req.target);
379
- logger.system(`Session switch: ${currentMode} → ${req.target}`);
380
- return {
381
- target: req.target,
382
- reason: req.reason,
383
- forwardMessage: req.forwardMessage,
384
- ...(workspaceNotice ? { workspaceNotice } : {}),
385
- ...(isCodingCompletion
386
- ? {
387
- completionMemo: req.memo,
388
- ownerNotificationRequired: !completionDelivered,
389
- }
390
- : {}),
391
- };
392
- }
393
- /**
394
- * Get any unread memos for the currently active session.
395
- * Call this before sending a message to the active session so
396
- * the memos can be prepended to the context.
397
- */
398
- consumeMemosForActive() {
399
- if (!this.dualSessionEnabled)
400
- return null;
401
- const memos = consumeMemosFor(this._activeMode);
402
- if (memos.length === 0)
403
- return null;
404
- const lines = ["## Messages from the other session"];
405
- for (const m of memos) {
406
- lines.push(`[${m.from} session at ${m.timestamp}]: ${m.content}`);
407
- }
408
- return lines.join("\n");
409
- }
410
- /**
411
- * Acknowledge that consumed memos for the active session have been
412
- * successfully injected. Removes them from the mailbox on disk.
413
- */
414
- ackMemosForActive() {
415
- if (!this.dualSessionEnabled)
416
- return;
417
- ackMemos(this._activeMode);
418
- }
419
- /**
420
- * End the coding session (task complete or abandoned).
421
- * Switches back to general mode.
422
- */
423
- endCodingSession(summary) {
424
- updateCodingSessionInfo({ status: "completed", taskSummary: summary });
425
- if (this._activeMode === "coding") {
426
- addMemo("coding", "general", `Coding task completed: ${summary}`);
427
- this._activeMode = "general";
428
- setActiveSession("general");
429
- logger.system("Coding session ended, switched to general");
430
- }
85
+ return this.session;
431
86
  }
432
87
  /**
433
- * Finalize a coding task when the coding session used the generic `finish`
434
- * lifecycle tool after already delivering its completion notification.
435
- *
436
- * `finish` normally ends only the current wake cycle. The wake runner calls
437
- * this method only when it has an exact, task-bound completion receipt, so a
438
- * progress notification followed by `finish` still leaves the task active.
439
- */
440
- finalizeCodingCompletionAfterFinish() {
441
- if (!this.dualSessionEnabled || this._activeMode !== "coding")
442
- return false;
443
- const codingSession = loadMailbox().codingSession;
444
- if (codingSession.status !== "in_progress" && codingSession.status !== "paused") {
445
- return false;
446
- }
447
- updateCodingSessionInfo({ status: "completed" });
448
- this._activeMode = "general";
449
- setActiveSession("general");
450
- logger.system("Coding completion delivered before finish — finalized task and switched to general");
451
- return true;
452
- }
453
- /**
454
- * Discard pre-warmed subprocesses on every session so the next turn
455
- * rebuilds them from the current `config`. Use after mutating provider-
456
- * bound state (e.g. client-side provider fallback) — without this, the
457
- * Claude warm subprocess can silently keep using the previous provider
458
- * for one more turn.
88
+ * Discard the pre-warmed subprocess so the next turn rebuilds it from the
89
+ * current `config`. Use after mutating provider-bound state (e.g.
90
+ * client-side provider fallback) — without this, the Claude warm
91
+ * subprocess can silently keep using the previous provider for one more
92
+ * turn.
459
93
  */
460
94
  discardAllWarmQueries() {
461
- this.generalSession.discardWarmQuery();
462
- this.codingSession?.discardWarmQuery();
95
+ this.session.discardWarmQuery();
463
96
  }
464
- /** Releases still running for coding session objects this manager already discarded. */
465
- pendingReleases = new Set();
466
- /**
467
- * Close MCP stdio children for every session: the live general and coding
468
- * sessions plus any discarded coding session whose teardown is still in
469
- * flight. Sessions are independent, so release them in parallel and never
470
- * let one failure skip another.
471
- */
97
+ /** Close the session's MCP stdio children. A failure is logged, never thrown. */
472
98
  async releaseMcpResources() {
473
- const results = await Promise.allSettled([
474
- this.generalSession.releaseMcpResources(),
475
- ...(this.codingSession ? [this.codingSession.releaseMcpResources()] : []),
476
- ...this.pendingReleases,
477
- ]);
478
- for (const result of results) {
479
- if (result.status !== "rejected")
480
- continue;
481
- const reason = result.reason;
482
- logger.warn(`Failed to release session MCP resources: ${reason instanceof Error ? reason.message : String(reason)}`);
99
+ try {
100
+ await this.session.releaseMcpResources();
101
+ }
102
+ catch (err) {
103
+ logger.warn(`Failed to release session MCP resources: ${err instanceof Error ? err.message : String(err)}`);
483
104
  }
484
- }
485
- discardCodingSession() {
486
- const previous = this.codingSession;
487
- this.codingSession = null;
488
- if (!previous)
489
- return;
490
- // releaseMcpResources() subsumes discardWarmQuery() on every engine.
491
- const release = previous.releaseMcpResources().catch((err) => {
492
- logger.warn(`Failed to release coding session MCP resources: ${err instanceof Error ? err.message : String(err)}`);
493
- });
494
- this.pendingReleases.add(release);
495
- void release.then(() => this.pendingReleases.delete(release));
496
105
  }
497
106
  requestStop() {
498
107
  this._managerStopRequested = true;
499
- this.activeSession.requestStop();
108
+ this.session.requestStop();
500
109
  }
501
110
  clearStop() {
502
111
  this._managerStopRequested = false;
503
- this.activeSession.clearStop();
112
+ this.session.clearStop();
504
113
  }
505
114
  isStopRequested() {
506
- return this._managerStopRequested || this.activeSession.isStopRequested();
115
+ return this._managerStopRequested || this.session.isStopRequested();
507
116
  }
508
- /** Machine-readable task state, separate from the owner-facing status text. */
509
- getCodingSessionState() {
510
- if (!this.dualSessionEnabled)
511
- return null;
512
- return loadMailbox().codingSession.status;
513
- }
514
- getCodingSessionStatus() {
515
- if (!this.dualSessionEnabled)
516
- return null;
517
- const mailbox = loadMailbox();
518
- const cs = mailbox.codingSession;
519
- if (!cs.taskSummary)
520
- return null;
521
- if (cs.status === "in_progress")
522
- return `Coding session is active: ${cs.taskSummary}`;
523
- if (cs.status === "paused")
524
- return `Coding session is paused: ${cs.taskSummary}`;
525
- return null;
117
+ /**
118
+ * True only when the active engine has confirmed it will not continue.
119
+ * An engine that cannot prove this leaves the host entry unconfirmed.
120
+ */
121
+ executionBarrierConfirmed() {
122
+ return this.session.executionBarrierConfirmed?.() ?? false;
526
123
  }
527
124
  /**
528
- * Reset the active session: rotates the current session ID to
125
+ * Reset the session: rotates the current session ID to
529
126
  * `previousSessionIds`, clears the active session ID, and passes the
530
127
  * summary to the session object for injection into the next turn.
531
128
  *
532
129
  * The next `sendAndStream` will create a brand-new SDK session.
533
130
  */
534
131
  resetActiveSession(summary) {
535
- // Reset the session object returned by activeSession, even if mailbox
536
- // state is temporarily inconsistent (for example coding is marked active
537
- // before its lazy session has been constructed).
538
- const effectiveMode = this._activeMode === "coding" && this.codingSession ? "coding" : "general";
539
- this.resetSession(effectiveMode, summary);
132
+ this.resetSession(summary);
540
133
  }
541
134
  /**
542
- * Mode-aware variant of {@link resetActiveSession}. Rotates the
543
- * mode's persisted session id into `previousSessionIds`, then hands
544
- * `summary` to the corresponding session object so it is prepended to
545
- * the next turn as priority context.
546
- *
547
- * Used by `/refresh` (via {@link resetActiveSession}, which targets the
548
- * currently-active mode).
549
- *
550
- * No-op when the target session has not been constructed (the coding
551
- * session is lazy-created when the mailbox marks it active).
135
+ * Rotate the persisted session id into `previousSessionIds`, then hand
136
+ * `summary` to the session object so it is prepended to the next turn as
137
+ * priority context. Used by `/refresh` (via {@link resetActiveSession}).
552
138
  */
553
- resetSession(mode, summary) {
554
- const target = mode === "coding" ? this.codingSession : this.generalSession;
555
- if (!target)
556
- return;
557
- rotateSessionId(mode);
558
- target.resetForNewSession(summary);
559
- logger.system(`Session reset (mode=${mode}), summary ${summary.length} chars`);
139
+ resetSession(summary) {
140
+ rotateSessionId();
141
+ this.session.resetForNewSession(summary);
142
+ logger.system(`Session reset, summary ${summary.length} chars`);
560
143
  }
561
144
  /**
562
- * Inject a summary into a session WITHOUT rotating its session id.
563
- *
564
- * Used by the startup engine-switch boundary: rotation and mailbox
565
- * clearing happen *before* `SessionManager` is constructed (so the
566
- * manager sees the post-collapse world), and then this method just
567
- * threads the combined summary into the freshly created session's
568
- * first turn.
145
+ * Inject a summary into the session WITHOUT rotating its session id.
569
146
  *
570
- * No-op when the target session has not been constructed.
147
+ * Used by the startup engine-switch boundary: rotation happens *before*
148
+ * `SessionManager` is constructed, and then this method just threads the
149
+ * combined summary into the freshly created session's first turn.
571
150
  */
572
- injectSummary(mode, summary) {
573
- const target = mode === "coding" ? this.codingSession : this.generalSession;
574
- if (!target)
575
- return;
576
- target.injectSummary(summary);
577
- logger.system(`[session-manager] Injected summary into ${mode} session (${summary.length} chars)`);
151
+ injectSummary(summary) {
152
+ this.session.injectSummary(summary);
153
+ logger.system(`[session-manager] Injected summary into session (${summary.length} chars)`);
578
154
  }
579
155
  }
580
156
  //# sourceMappingURL=session-manager.js.map