@tekmidian/pai 0.42.5 → 0.43.0

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 (297) hide show
  1. package/ARCHITECTURE.md +9 -9
  2. package/README.md +26 -8
  3. package/dist/{aibroker-client-BP74gGwD.mjs → aibroker-client-Bn9SnGMa.mjs} +3 -3
  4. package/dist/{aibroker-client-BP74gGwD.mjs.map → aibroker-client-Bn9SnGMa.mjs.map} +1 -1
  5. package/dist/{aibroker-client-C6m71p6O.mjs → aibroker-client-D5NT0S1N.mjs} +1 -1
  6. package/dist/{auto-route-_5zzJz5q.mjs → auto-route-CcD0OWWB.mjs} +4 -4
  7. package/dist/{auto-route-_5zzJz5q.mjs.map → auto-route-CcD0OWWB.mjs.map} +1 -1
  8. package/dist/{chain-DTII7xeL.mjs → chain-CEC1a5mX.mjs} +5 -4
  9. package/dist/{chain-DTII7xeL.mjs.map → chain-CEC1a5mX.mjs.map} +1 -1
  10. package/dist/cli/index.mjs +23 -21
  11. package/dist/cli/index.mjs.map +1 -1
  12. package/dist/cli/program.d.mts.map +1 -1
  13. package/dist/cli/program.mjs +23 -21
  14. package/dist/{clusters-j0ZuNYp9.mjs → clusters-Cw_P6lO-.mjs} +2 -2
  15. package/dist/{clusters-j0ZuNYp9.mjs.map → clusters-Cw_P6lO-.mjs.map} +1 -1
  16. package/dist/{config-B64vFg14.mjs → config-DCu8THKi.mjs} +41 -9
  17. package/dist/{config-B64vFg14.mjs.map → config-DCu8THKi.mjs.map} +1 -1
  18. package/dist/config-DeqFqa1N.mjs +3 -0
  19. package/dist/config-DxMZjpvY.mjs +1289 -0
  20. package/dist/config-DxMZjpvY.mjs.map +1 -0
  21. package/dist/context-handover-cache-B9NKSjwR.mjs +3242 -0
  22. package/dist/context-handover-cache-B9NKSjwR.mjs.map +1 -0
  23. package/dist/daemon/index.mjs +23 -22
  24. package/dist/daemon/index.mjs.map +1 -1
  25. package/dist/{daemon-B8N1egl0.mjs → daemon-BhldpFvO.mjs} +52 -38
  26. package/dist/daemon-BhldpFvO.mjs.map +1 -0
  27. package/dist/daemon-QIvCXB5f.mjs +24 -0
  28. package/dist/daemon-mcp/index.mjs +144 -117
  29. package/dist/daemon-mcp/index.mjs.map +1 -1
  30. package/dist/db-BOBfewFH.mjs +3 -0
  31. package/dist/{db-a1ixZQjr.mjs → db-DJ8rk0VM.mjs} +15 -6
  32. package/dist/{db-a1ixZQjr.mjs.map → db-DJ8rk0VM.mjs.map} +1 -1
  33. package/dist/db-DbY2O8QO.mjs +3 -0
  34. package/dist/{db-Ca5qfsMC.mjs → db-Ddns80yf.mjs} +15 -6
  35. package/dist/{db-Ca5qfsMC.mjs.map → db-Ddns80yf.mjs.map} +1 -1
  36. package/dist/{detect-CdaA48EI.mjs → detect-Bf2z-oKB.mjs} +1 -1
  37. package/dist/{detect-CdaA48EI.mjs.map → detect-Bf2z-oKB.mjs.map} +1 -1
  38. package/dist/detector-CkwkXuGh.mjs +5 -0
  39. package/dist/{detector-C73Nxm94.mjs → detector-DWXkeTlk.mjs} +2 -2
  40. package/dist/{detector-C73Nxm94.mjs.map → detector-DWXkeTlk.mjs.map} +1 -1
  41. package/dist/{embeddings-CEBGrzwu.mjs → embeddings-ClqKtLZ8.mjs} +1 -1
  42. package/dist/{embeddings-DOLZnT1X.mjs → embeddings-DvRKcQyt.mjs} +1 -1
  43. package/dist/{embeddings-DOLZnT1X.mjs.map → embeddings-DvRKcQyt.mjs.map} +1 -1
  44. package/dist/factory-47Qf_df7.mjs +3 -0
  45. package/dist/{factory-DEb9NmHJ.mjs → factory-DNYAqjH0.mjs} +8 -8
  46. package/dist/{factory-DEb9NmHJ.mjs.map → factory-DNYAqjH0.mjs.map} +1 -1
  47. package/dist/{fallback-oJl3BaIN.mjs → fallback-BQJ8PbCK.mjs} +185 -123
  48. package/dist/fallback-BQJ8PbCK.mjs.map +1 -0
  49. package/dist/{helpers-IjZkXBhj.mjs → helpers-crDEr6S2.mjs} +1 -1
  50. package/dist/{helpers-IjZkXBhj.mjs.map → helpers-crDEr6S2.mjs.map} +1 -1
  51. package/dist/hooks/capture-all-events.mjs +117 -34
  52. package/dist/hooks/capture-all-events.mjs.map +4 -4
  53. package/dist/hooks/capture-session-summary.mjs +110 -33
  54. package/dist/hooks/capture-session-summary.mjs.map +4 -4
  55. package/dist/hooks/capture-tool-output.mjs +105 -28
  56. package/dist/hooks/capture-tool-output.mjs.map +4 -4
  57. package/dist/hooks/cleanup-session-files.mjs +54 -13
  58. package/dist/hooks/cleanup-session-files.mjs.map +2 -2
  59. package/dist/hooks/context-compression-hook.mjs +7565 -122
  60. package/dist/hooks/context-compression-hook.mjs.map +4 -4
  61. package/dist/hooks/initialize-session.mjs +55 -14
  62. package/dist/hooks/initialize-session.mjs.map +2 -2
  63. package/dist/hooks/inject-observations.mjs +79 -18
  64. package/dist/hooks/inject-observations.mjs.map +3 -3
  65. package/dist/hooks/load-core-context.mjs +55 -14
  66. package/dist/hooks/load-core-context.mjs.map +2 -2
  67. package/dist/hooks/load-project-context.mjs +207 -122
  68. package/dist/hooks/load-project-context.mjs.map +4 -4
  69. package/dist/hooks/mcp-deferred-gate.mjs +54 -13
  70. package/dist/hooks/mcp-deferred-gate.mjs.map +2 -2
  71. package/dist/hooks/mcp-deferred-reminder.mjs +9 -0
  72. package/dist/hooks/mcp-deferred-reminder.mjs.map +3 -3
  73. package/dist/hooks/observe.mjs +54 -13
  74. package/dist/hooks/observe.mjs.map +2 -2
  75. package/dist/hooks/post-compact-inject.mjs +7419 -16
  76. package/dist/hooks/post-compact-inject.mjs.map +4 -4
  77. package/dist/hooks/route-agents-to-worker.mjs +7778 -171
  78. package/dist/hooks/route-agents-to-worker.mjs.map +4 -4
  79. package/dist/hooks/route-edits-to-worker.mjs +90 -0
  80. package/dist/hooks/route-edits-to-worker.mjs.map +7 -0
  81. package/dist/hooks/security-validator.mjs +147 -6
  82. package/dist/hooks/security-validator.mjs.map +4 -4
  83. package/dist/hooks/session-commands.mjs +9 -0
  84. package/dist/hooks/session-commands.mjs.map +3 -3
  85. package/dist/hooks/stop-hook.mjs +182 -105
  86. package/dist/hooks/stop-hook.mjs.map +4 -4
  87. package/dist/hooks/subagent-stop-hook.mjs +3 -0
  88. package/dist/hooks/subagent-stop-hook.mjs.map +1 -1
  89. package/dist/hooks/sync-todo-to-md.mjs +54 -13
  90. package/dist/hooks/sync-todo-to-md.mjs.map +2 -2
  91. package/dist/hooks/update-tab-on-action.mjs +3 -0
  92. package/dist/hooks/update-tab-on-action.mjs.map +1 -1
  93. package/dist/hooks/update-tab-titles.mjs +3 -0
  94. package/dist/hooks/update-tab-titles.mjs.map +1 -1
  95. package/dist/hooks/whisper-reinject.mjs +11 -0
  96. package/dist/hooks/whisper-reinject.mjs.map +3 -3
  97. package/dist/hooks/whisper-rules.mjs +134 -29
  98. package/dist/hooks/whisper-rules.mjs.map +4 -4
  99. package/dist/hooks/worker-proxy.mjs +7737 -117
  100. package/dist/hooks/worker-proxy.mjs.map +4 -4
  101. package/dist/hooks/worker-status-line.mjs +7883 -169
  102. package/dist/hooks/worker-status-line.mjs.map +4 -4
  103. package/dist/hooks/worker-supervision.mjs +7721 -115
  104. package/dist/hooks/worker-supervision.mjs.map +4 -4
  105. package/dist/index.d.mts +4 -2
  106. package/dist/index.d.mts.map +1 -1
  107. package/dist/index.mjs +10 -10
  108. package/dist/{indexer-backend-BPTzKFZU.mjs → indexer-backend-CdvCJCkD.mjs} +3 -3
  109. package/dist/{indexer-backend-BPTzKFZU.mjs.map → indexer-backend-CdvCJCkD.mjs.map} +1 -1
  110. package/dist/{ipc-client-BmypMNYk.mjs → ipc-client-C6NryMMb.mjs} +2 -2
  111. package/dist/{ipc-client-BmypMNYk.mjs.map → ipc-client-C6NryMMb.mjs.map} +1 -1
  112. package/dist/{kg-entity-r8duqhi9.mjs → kg-entity-BSjM5xZh.mjs} +1 -1
  113. package/dist/{kg-entity-r8duqhi9.mjs.map → kg-entity-BSjM5xZh.mjs.map} +1 -1
  114. package/dist/{latent-ideas-CtSca4qG.mjs → latent-ideas-BfL4nCQ3.mjs} +4 -4
  115. package/dist/{latent-ideas-CtSca4qG.mjs.map → latent-ideas-BfL4nCQ3.mjs.map} +1 -1
  116. package/dist/{link-boost-Bucnz3n8.mjs → link-boost-C5PaNdzm.mjs} +1 -1
  117. package/dist/{link-boost-Bucnz3n8.mjs.map → link-boost-C5PaNdzm.mjs.map} +1 -1
  118. package/dist/main-resolver-CnfnWa8C.mjs +7 -0
  119. package/dist/{main-resolver-DnkxPYkr.mjs → main-resolver-DvYu9jbl.mjs} +21 -11
  120. package/dist/main-resolver-DvYu9jbl.mjs.map +1 -0
  121. package/dist/{migrate-Cjzeefn9.mjs → migrate-CfERwXhY.mjs} +2 -2
  122. package/dist/{migrate-Cjzeefn9.mjs.map → migrate-CfERwXhY.mjs.map} +1 -1
  123. package/dist/{neighborhood-CM7Jgb51.mjs → neighborhood-CETR_P4y.mjs} +2 -2
  124. package/dist/{neighborhood-CM7Jgb51.mjs.map → neighborhood-CETR_P4y.mjs.map} +1 -1
  125. package/dist/{note-context-DCwE2A-M.mjs → note-context-DCcRWBoN.mjs} +1 -1
  126. package/dist/{note-context-DCwE2A-M.mjs.map → note-context-DCcRWBoN.mjs.map} +1 -1
  127. package/dist/pai-home-ChAOupZc.mjs +164 -0
  128. package/dist/pai-home-ChAOupZc.mjs.map +1 -0
  129. package/dist/{pai-marker-CHtbJMwJ.mjs → pai-marker-B20KqhA8.mjs} +1 -1
  130. package/dist/{pai-marker-CHtbJMwJ.mjs.map → pai-marker-B20KqhA8.mjs.map} +1 -1
  131. package/dist/{planner-D5Ui7DAm.mjs → planner-BlKGgpWI.mjs} +7 -6
  132. package/dist/{planner-D5Ui7DAm.mjs.map → planner-BlKGgpWI.mjs.map} +1 -1
  133. package/dist/{postgres-CtOzfoQU.mjs → postgres-CUSXWgTG.mjs} +2 -2
  134. package/dist/{postgres-CtOzfoQU.mjs.map → postgres-CUSXWgTG.mjs.map} +1 -1
  135. package/dist/{program-zpoYnJGz.mjs → program-C5jRQ1kg.mjs} +8880 -5913
  136. package/dist/program-C5jRQ1kg.mjs.map +1 -0
  137. package/dist/query-feedback-C7rSfiXU.mjs +3 -0
  138. package/dist/{query-feedback-Dqz-HC__.mjs → query-feedback-CYyOGi3y.mjs} +20 -6
  139. package/dist/query-feedback-CYyOGi3y.mjs.map +1 -0
  140. package/dist/{reranker-CwTCNsgA.mjs → reranker-B5qUTamW.mjs} +1 -1
  141. package/dist/{reranker-xPm04PXx.mjs → reranker-HHmhZk6v.mjs} +1 -1
  142. package/dist/{reranker-xPm04PXx.mjs.map → reranker-HHmhZk6v.mjs.map} +1 -1
  143. package/dist/router-CremHKTI.mjs +3 -0
  144. package/dist/{router-DD6D4j31.mjs → router-DBAZfE7X.mjs} +2 -2
  145. package/dist/{router-DD6D4j31.mjs.map → router-DBAZfE7X.mjs.map} +1 -1
  146. package/dist/{run-D7K5UALn.mjs → run-ByBKowN5.mjs} +980 -247
  147. package/dist/run-ByBKowN5.mjs.map +1 -0
  148. package/dist/{runtime-paths-rni52zHX.mjs → runtime-paths-B0P1TvUr.mjs} +1 -1
  149. package/dist/{runtime-paths-rni52zHX.mjs.map → runtime-paths-B0P1TvUr.mjs.map} +1 -1
  150. package/dist/{search-Rpk1cSBC.mjs → search-B69cQwDB.mjs} +3 -3
  151. package/dist/{search-Rpk1cSBC.mjs.map → search-B69cQwDB.mjs.map} +1 -1
  152. package/dist/{search-CfPpJAWQ.mjs → search-fb-5ovj4.mjs} +2 -2
  153. package/dist/{server-D4vAieF4.mjs → server-Ch99xt5K.mjs} +15 -14
  154. package/dist/server-Ch99xt5K.mjs.map +1 -0
  155. package/dist/skills/Advisor/SKILL.md +3 -3
  156. package/dist/skills/Providers/SKILL.md +30 -0
  157. package/dist/skills/Reconstruct/SKILL.md +1 -1
  158. package/dist/skills/VaultContext/SKILL.md +1 -1
  159. package/dist/skills/Whisper/SKILL.md +3 -3
  160. package/dist/skills/Worker/SKILL.md +1 -1
  161. package/dist/{sources-CS43CpuS.mjs → sources-KBGEA_E6.mjs} +2 -2
  162. package/dist/{sources-CS43CpuS.mjs.map → sources-KBGEA_E6.mjs.map} +1 -1
  163. package/dist/{sqlite-Cq3gJcq9.mjs → sqlite-By6r2YhZ.mjs} +3 -3
  164. package/dist/{sqlite-Cq3gJcq9.mjs.map → sqlite-By6r2YhZ.mjs.map} +1 -1
  165. package/dist/{state-CY6I-Hnc.mjs → state-DnYGRmS7.mjs} +1 -1
  166. package/dist/{state-BRdB-Bf1.mjs → state-PJrgfDLW.mjs} +1 -1
  167. package/dist/{state-BRdB-Bf1.mjs.map → state-PJrgfDLW.mjs.map} +1 -1
  168. package/dist/{stop-words-Hfu8u22w.mjs → stop-words-BaMEGVeY.mjs} +1 -1
  169. package/dist/{stop-words-Hfu8u22w.mjs.map → stop-words-BaMEGVeY.mjs.map} +1 -1
  170. package/dist/{sync-BWbe8JTg.mjs → sync-Btcb6xA4.mjs} +3 -3
  171. package/dist/{sync-BWbe8JTg.mjs.map → sync-Btcb6xA4.mjs.map} +1 -1
  172. package/dist/{themes-B7h9YDiy.mjs → themes-BVoAnLZj.mjs} +3 -3
  173. package/dist/{themes-B7h9YDiy.mjs.map → themes-BVoAnLZj.mjs.map} +1 -1
  174. package/dist/{tools-BW3NLMPk.mjs → tools-CAG2sUjf.mjs} +4 -3
  175. package/dist/{tools-LlzcV_eK.mjs → tools-DiRC5glA.mjs} +30 -233
  176. package/dist/tools-DiRC5glA.mjs.map +1 -0
  177. package/dist/{trace-u4hT-pLD.mjs → trace-Cy8quQTm.mjs} +1 -1
  178. package/dist/{trace-u4hT-pLD.mjs.map → trace-Cy8quQTm.mjs.map} +1 -1
  179. package/dist/{utils-DhMex3Ox.mjs → utils-BD8g8oSf.mjs} +1 -1
  180. package/dist/{utils-9Err2RBW.mjs → utils-CJymHkYm.mjs} +1 -1
  181. package/dist/{utils-9Err2RBW.mjs.map → utils-CJymHkYm.mjs.map} +1 -1
  182. package/dist/{vault-indexer-mata9S7b.mjs → vault-indexer-C5i-OAyr.mjs} +2 -2
  183. package/dist/{vault-indexer-mata9S7b.mjs.map → vault-indexer-C5i-OAyr.mjs.map} +1 -1
  184. package/dist/wakeup-BfElduEU.mjs +231 -0
  185. package/dist/wakeup-BfElduEU.mjs.map +1 -0
  186. package/dist/work-queue-worker-BA5IDBwQ.mjs +567 -0
  187. package/dist/work-queue-worker-BA5IDBwQ.mjs.map +1 -0
  188. package/dist/work-queue-worker-DLM2wlqM.mjs +14 -0
  189. package/dist/{zettelkasten-F0D_XfQ4.mjs → zettelkasten-BBjA7GcP.mjs} +4 -4
  190. package/dist/{zettelkasten-F0D_XfQ4.mjs.map → zettelkasten-BBjA7GcP.mjs.map} +1 -1
  191. package/docs/commands/README.md +32 -3
  192. package/docs/commands/audit.md +113 -0
  193. package/docs/commands/backup.md +2 -2
  194. package/docs/commands/clear-names.md +1 -1
  195. package/docs/commands/config.md +59 -0
  196. package/docs/commands/daemon.md +1 -1
  197. package/docs/commands/db.md +1 -1
  198. package/docs/commands/end.md +1 -1
  199. package/docs/commands/help.md +1 -1
  200. package/docs/commands/identity.md +1 -1
  201. package/docs/commands/kg.md +1 -1
  202. package/docs/commands/launch.md +45 -0
  203. package/docs/commands/mcp.md +1 -1
  204. package/docs/commands/memory.md +3 -3
  205. package/docs/commands/notify.md +1 -1
  206. package/docs/commands/observation.md +1 -1
  207. package/docs/commands/obsidian.md +1 -1
  208. package/docs/commands/pause.md +1 -1
  209. package/docs/commands/project.md +46 -1
  210. package/docs/commands/projects.md +46 -1
  211. package/docs/commands/registry.md +1 -1
  212. package/docs/commands/restore.md +1 -1
  213. package/docs/commands/session.md +1 -1
  214. package/docs/commands/sessions.md +1 -1
  215. package/docs/commands/setup.md +1 -1
  216. package/docs/commands/shell-init.md +1 -1
  217. package/docs/commands/skill.md +1 -1
  218. package/docs/commands/task.md +1 -1
  219. package/docs/commands/topic.md +1 -1
  220. package/docs/commands/update.md +1 -1
  221. package/docs/commands/worker.md +97 -6
  222. package/docs/commands/zettel.md +1 -1
  223. package/docs/provider-abstraction.md +1 -1
  224. package/docs/provider-independence-details.md +8 -5
  225. package/docs/task-bus.md +1 -1
  226. package/docs/worker.md +136 -83
  227. package/docs/workers-config.md +446 -0
  228. package/package.json +4 -2
  229. package/scripts/build-hooks.mjs +58 -3
  230. package/src/hooks/pre-compact.sh +5 -2
  231. package/src/hooks/session-stop.sh +29 -4
  232. package/src/hooks/ts/capture-all-events.ts +3 -3
  233. package/src/hooks/ts/lib/advisor-budget.test.ts +98 -0
  234. package/src/hooks/ts/lib/advisor-budget.ts +90 -0
  235. package/src/hooks/ts/lib/agent-gate.test.ts +101 -0
  236. package/src/hooks/ts/lib/agent-gate.ts +112 -0
  237. package/src/hooks/ts/lib/context-fill.ts +2 -2
  238. package/src/hooks/ts/lib/edit-gate.test.ts +52 -0
  239. package/src/hooks/ts/lib/edit-gate.ts +51 -0
  240. package/src/hooks/ts/lib/mcp-deferred-reminder.test.ts +8 -0
  241. package/src/hooks/ts/lib/pai-paths.test.ts +93 -0
  242. package/src/hooks/ts/lib/pai-paths.ts +168 -24
  243. package/src/hooks/ts/lib/project-utils/index.ts +1 -0
  244. package/src/hooks/ts/lib/project-utils/paths.ts +5 -4
  245. package/src/hooks/ts/lib/project-utils.ts +1 -0
  246. package/src/hooks/ts/post-tool-use/capture-tool-output.ts +2 -2
  247. package/src/hooks/ts/post-tool-use/whisper-reinject.test.ts +55 -0
  248. package/src/hooks/ts/post-tool-use/whisper-reinject.ts +3 -0
  249. package/src/hooks/ts/pre-compact/context-compression-hook.ts +1 -1
  250. package/src/hooks/ts/pre-tool-use/route-agents-to-worker.ts +46 -99
  251. package/src/hooks/ts/pre-tool-use/route-edits-to-worker.test.ts +47 -0
  252. package/src/hooks/ts/pre-tool-use/route-edits-to-worker.ts +96 -0
  253. package/src/hooks/ts/pre-tool-use/security-validator.ts +2 -1
  254. package/src/hooks/ts/session-end/capture-session-summary.ts +4 -4
  255. package/src/hooks/ts/session-start/initialize-session.ts +3 -3
  256. package/src/hooks/ts/session-start/inject-observations.test.ts +56 -0
  257. package/src/hooks/ts/session-start/inject-observations.ts +28 -8
  258. package/src/hooks/ts/session-start/load-core-context.ts +4 -4
  259. package/src/hooks/ts/session-start/load-project-context.ts +2 -2
  260. package/src/hooks/ts/session-start/mcp-deferred-reminder.ts +2 -0
  261. package/src/hooks/ts/session-start/session-commands.ts +4 -0
  262. package/src/hooks/ts/session-start/session-start-worker-guard.test.ts +36 -0
  263. package/src/hooks/ts/stop/stop-hook.ts +6 -11
  264. package/src/hooks/ts/user-prompt/whisper-rules.test.ts +49 -0
  265. package/src/hooks/ts/user-prompt/whisper-rules.ts +88 -47
  266. package/src/hooks/ztk-auto.sh +28 -0
  267. package/src/hooks/ztk-auto.test.ts +72 -0
  268. package/src/hooks/ztk-passthrough.mjs +71 -0
  269. package/statusline-command.sh +277 -116
  270. package/templates/agent-prefs.example.md +8 -8
  271. package/templates/claude-md.template.md +1 -1
  272. package/templates/voices.example.json +3 -3
  273. package/dist/config-C_ErGddD.mjs +0 -3
  274. package/dist/config-_lQI_W08.mjs +0 -640
  275. package/dist/config-_lQI_W08.mjs.map +0 -1
  276. package/dist/context-handover-cache-pNFdBNrU.mjs +0 -1548
  277. package/dist/context-handover-cache-pNFdBNrU.mjs.map +0 -1
  278. package/dist/daemon-B8N1egl0.mjs.map +0 -1
  279. package/dist/daemon-DHfyoTlk.mjs +0 -23
  280. package/dist/db-O-cyAPfS.mjs +0 -3
  281. package/dist/db-XEwJbuGO.mjs +0 -3
  282. package/dist/detector-C-7KRi42.mjs +0 -5
  283. package/dist/factory-Dbo8yNPi.mjs +0 -3
  284. package/dist/fallback-oJl3BaIN.mjs.map +0 -1
  285. package/dist/main-resolver-BAfOMppW.mjs +0 -7
  286. package/dist/main-resolver-DnkxPYkr.mjs.map +0 -1
  287. package/dist/program-zpoYnJGz.mjs.map +0 -1
  288. package/dist/query-feedback-DGoVRaWD.mjs +0 -3
  289. package/dist/query-feedback-Dqz-HC__.mjs.map +0 -1
  290. package/dist/router-BTIGZR2_.mjs +0 -3
  291. package/dist/run-D7K5UALn.mjs.map +0 -1
  292. package/dist/server-D4vAieF4.mjs.map +0 -1
  293. package/dist/tools-LlzcV_eK.mjs.map +0 -1
  294. package/dist/work-queue-worker-AEmfVE0F.mjs +0 -14
  295. package/dist/work-queue-worker-DIT-VLSh.mjs +0 -2136
  296. package/dist/work-queue-worker-DIT-VLSh.mjs.map +0 -1
  297. /package/dist/{indexer-D7MvSQPY.mjs → indexer-C5Le7XE7.mjs} +0 -0
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import { t as PaiClient } from "../ipc-client-BmypMNYk.mjs";
3
- import { o as loadConfig } from "../config-B64vFg14.mjs";
4
- import { _ as readWorkersSection, r as MODEL_CAPABILITIES } from "../config-_lQI_W08.mjs";
5
- import { _ as workersLogDir, m as ledgerPath } from "../server-D4vAieF4.mjs";
6
- import { C as alive, D as loadStatus, N as ledgerSummary, O as loadStatuses, d as sayToWorker, l as handoffFromInside, n as runWorker, r as testProvider, u as readInbox } from "../run-D7K5UALn.mjs";
7
- import { t as runChain } from "../chain-DTII7xeL.mjs";
8
- import { _ as updateProvider, a as addProvider, b as psOutput, c as describeProviders, d as resolveProviderName, f as setClass, g as unsetClass, h as setWorkersEnabled, i as fallbackStatusText, l as modelPrefsText, m as setProviderModel, n as fallbackOn, o as classTargetText, p as setProviderEnabled, r as fallbackStatus, s as describeModels, t as fallbackOff, u as removeProvider, v as useProvider, x as replayOutput } from "../fallback-oJl3BaIN.mjs";
2
+ import "../db-Ddns80yf.mjs";
3
+ import { o as loadConfig } from "../config-DCu8THKi.mjs";
4
+ import { r as MODEL_CAPABILITIES, v as readWorkersSection } from "../config-DxMZjpvY.mjs";
5
+ import { A as loadStatuses, P as setWorkerLabel, S as ledgerSummary, T as alive, d as sayToWorker, k as loadStatus, l as handoffFromInside, n as runWorker, r as testProvider, u as readInbox } from "../run-ByBKowN5.mjs";
6
+ import { t as PaiClient } from "../ipc-client-C6NryMMb.mjs";
7
+ import { _ as workersLogDir, m as ledgerPath } from "../server-Ch99xt5K.mjs";
8
+ import { t as runChain } from "../chain-CEC1a5mX.mjs";
9
+ import { C as readSpecPrompt, _ as updateProvider, a as addProvider, b as psOutput, c as describeProviders, d as resolveProviderName, f as setClass, g as unsetClass, h as setWorkersEnabled, i as fallbackStatusText, l as modelPrefsText, m as setProviderModel, n as fallbackOn, o as classTargetText, p as setProviderEnabled, r as fallbackStatus, s as describeModels, t as fallbackOff, u as removeProvider, v as useProvider, w as resolveSpecPath, x as replayOutput } from "../fallback-BQJ8PbCK.mjs";
9
10
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
11
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
11
12
 
@@ -3415,79 +3416,35 @@ const meta = meta$1;
3415
3416
  //#region src/daemon-mcp/instructions.ts
3416
3417
  const PAI_INSTRUCTIONS = `## PAI — Personal AI Infrastructure
3417
3418
 
3418
- Federated memory, project registry, session management, and skill workflows.
3419
-
3420
- ### PAI-First Search Protocol
3421
-
3422
- Before answering questions about past work, decisions, people, or project status:
3423
- use memory_search. Use project_detect at session start to identify the current project.
3424
-
3425
- ### Session Commands
3426
-
3427
- - go / continue / weiter → read TODO.md, look for ## Continue section, resume from there
3428
- - pause session → summarize state, update TODO.md with ## Continue section at top, stop
3429
- - end session → pause procedure + rename session note (NEVER leave as "New Session")
3430
- - cpp → git add . && git commit -m "type: ..." && git push (no AI signatures)
3431
-
3432
- ### Response Modes
3433
-
3434
- Classify every request before responding:
3435
- - MINIMAL: greetings, acks, simple yes/no → 1-3 sentences, no structure
3436
- - STANDARD: single-step tasks, quick lookups → direct answer only
3437
- - FULL: multi-step work, research, implementation → SUMMARY / ANALYSIS / ACTIONS / RESULTS / STATUS / NEXT / COMPLETED
3438
-
3439
- ### Skill Routing
3440
-
3441
- Fetch the full skill instructions with: prompts/get { name: "<skill-name>" }
3442
-
3443
- | When user says | Fetch prompt |
3444
- |----------------|--------------|
3445
- | review, weekly review, what did I do, recap | review |
3446
- | journal, note to self, capture this thought | journal |
3447
- | plan, what should I focus on, priorities | plan |
3448
- | share on linkedin, post about, tweet this | share |
3449
- | list sessions, where was I working | sessions |
3450
- | route, what project is this | route |
3451
- | search history, find past, when did we | search-history |
3452
- | /name, name this session | name |
3453
- | observability, monitor agents, show dashboard | observability |
3454
- | research, extract wisdom, analyze content | research |
3455
- | visualize, create diagram, flowchart, image | art |
3456
- | create skill, validate skill, update skill | createskill |
3457
- | /story, story explanation, explain as story | story-explanation |
3458
- | load vault context, morning briefing | vault-context |
3459
- | connect X and Y, how does X relate to Y | vault-connect |
3460
- | what's emerging, find patterns in vault | vault-emerge |
3461
- | find orphans, orphaned notes | vault-orphans |
3462
- | trace idea, how did X evolve | vault-trace |
3463
- | run a worker, check workers, worker providers | worker |
3464
-
3465
- ### Reference Resources
3466
-
3467
- Fetch with: resources/read { uri: "pai://<name>" }
3468
-
3469
- | Resource | URI |
3470
- |----------|-----|
3471
- | Aesthetic guide (visual style) | pai://aesthetic |
3472
- | Constitution (philosophy, architecture, directory structure) | pai://constitution |
3473
- | Prompt engineering standards | pai://prompting |
3474
- | Voice prosody guide | pai://prosody-guide |
3475
- | Prosody agent template | pai://prosody-agent-template |
3476
- | Voice system reference | pai://voice |
3477
- | Skill system spec (TitleCase, SKILL.md structure) | pai://skill-system |
3478
- | Hook system reference (events, patterns) | pai://hook-system |
3479
- | History system — UOCS (capture, directories) | pai://history-system |
3480
- | Terminal tab title system | pai://terminal-tabs |
3481
- | MCP development guide (three-tier architecture) | pai://mcp-dev-guide |
3482
-
3483
- ### Core Rules
3484
-
3485
- - Git commits: NO AI signatures, NO Co-Authored-By lines, format: type: description
3486
- - Stack: TypeScript > Python, bun for JS/TS, uv for Python
3487
- - Security: run git remote -v before every push; never commit private data
3488
- - Fact-checking: mark unverified AI claims with ⚠️ Unverified
3489
- - History lookup: search \${PAI_DIR}/History/ before answering about past work
3490
- - WhatsApp routing: [Whazaa] prefix → reply via whatsapp_send; [Whazaa:voice] → whatsapp_tts
3419
+ Federated memory, project registry, session management, skills.
3420
+
3421
+ ### Search first
3422
+
3423
+ Before answering about past work, decisions, people, or project status: use memory_search.
3424
+ Run project_detect at session start.
3425
+
3426
+ ### Session commands
3427
+
3428
+ - go / continue / weiter → read TODO.md "## Continue" section, resume there
3429
+ - pause session → update TODO.md "## Continue" section, stop
3430
+ - end session → pause procedure + rename session note (never leave as "New Session")
3431
+ - cpp → release order is in CLAUDE.md
3432
+
3433
+ ### Skills
3434
+
3435
+ Fetch full instructions with prompts/get { name }. Skills are already listed with USE WHEN descriptions.
3436
+
3437
+ ### Reference resources
3438
+
3439
+ Fetch with resources/read { uri }. Available: pai://aesthetic, pai://constitution, pai://prompting,
3440
+ pai://prosody-guide, pai://prosody-agent-template, pai://voice, pai://skill-system, pai://hook-system,
3441
+ pai://history-system, pai://terminal-tabs, pai://mcp-dev-guide
3442
+
3443
+ ### Core rules
3444
+
3445
+ Git: no AI signatures, commit format "type: description", run git remote -v before pushing, never commit
3446
+ private data. Stack: TypeScript > Python (bun/uv). Mark unverified AI claims with ⚠️ Unverified.
3447
+ WhatsApp: [Whazaa] → whatsapp_send; [Whazaa:voice] → whatsapp_tts.
3491
3448
  `;
3492
3449
 
3493
3450
  //#endregion
@@ -3882,7 +3839,7 @@ USE WHEN user says 'load vault context', 'brief me from Obsidian', 'morning brie
3882
3839
 
3883
3840
  Reads: daily note → open TODOs → PAI index (active projects) → HOME.md (focus areas) → recent insights. Synthesizes into morning briefing with Suggested First Action.
3884
3841
 
3885
- All vault skills work with the vault configured in \`~/.config/pai/config.json\` (\`vaultPath\` key).`
3842
+ All vault skills work with the vault configured in \`~/.claude/pai/config.json\` (\`vaultPath\` key).`
3886
3843
  };
3887
3844
 
3888
3845
  //#endregion
@@ -4178,7 +4135,7 @@ For each reconstructed note, call \`kg_add\` to store key facts. Examples of fac
4178
4135
  - Maximum **15 triples per note** — pick the most important.
4179
4136
  - Never invent project names, versions, or paths. Copy them verbatim.
4180
4137
 
4181
- **Alternative (batch mode):** If reconstructing many notes at once, instead of calling \`kg_add\` interactively you may run \`pai kg backfill --project <slug>\` from the terminal after the notes are written. The backfill walks every note in \`Notes/YYYY/MM/\`, runs the same extractor the session-summary-worker uses, and is idempotent (state file at \`~/.config/pai/kg-backfill-state.json\`).
4138
+ **Alternative (batch mode):** If reconstructing many notes at once, instead of calling \`kg_add\` interactively you may run \`pai kg backfill --project <slug>\` from the terminal after the notes are written. The backfill walks every note in \`Notes/YYYY/MM/\`, runs the same extractor the session-summary-worker uses, and is idempotent (state file at \`~/.claude/pai/kg-backfill-state.json\`).
4182
4139
 
4183
4140
  After extraction, append a one-line note to the summary output:
4184
4141
  \`\`\`
@@ -4208,7 +4165,7 @@ USE WHEN user says 'whisper', 'add whisper rule', 'remove whisper rule', 'list w
4208
4165
 
4209
4166
  Manage the rules that PAI injects into every prompt via the whisper-rules hook.
4210
4167
 
4211
- Rules are stored in \`~/.claude/whisper-rules.md\` — one rule per line, plain text.
4168
+ Rules are stored in \`~/.claude/pai/whisper-rules.md\` — one rule per line, plain text.
4212
4169
  The hook reads this file on every UserPromptSubmit and injects it as a \`<system-reminder>\`.
4213
4170
  Rules survive compaction, /clear, and session restarts.
4214
4171
 
@@ -4223,11 +4180,11 @@ Rules survive compaction, /clear, and session restarts.
4223
4180
  ### Workflow
4224
4181
 
4225
4182
  **Show current rules:**
4226
- Read \`~/.claude/whisper-rules.md\` and display each rule with a line number.
4183
+ Read \`~/.claude/pai/whisper-rules.md\` and display each rule with a line number.
4227
4184
  If the file doesn't exist, say "No whisper rules configured."
4228
4185
 
4229
4186
  **Add a rule:**
4230
- Append the rule as a new line to \`~/.claude/whisper-rules.md\`.
4187
+ Append the rule as a new line to \`~/.claude/pai/whisper-rules.md\`.
4231
4188
  Create the file if it doesn't exist.
4232
4189
  Do NOT add duplicate rules — check if a similar rule already exists.
4233
4190
 
@@ -4357,13 +4314,13 @@ ALSO USE WHEN user says plain-language budget/mode phrases like:
4357
4314
  - "go full power", "use whatever model", "no budget constraints", "normal mode", "unrestricted" → set mode to normal
4358
4315
  - "back to auto", "reset advisor", "let the budget decide" → set mode to auto
4359
4316
 
4360
- When you detect these, write the appropriate mode to \`~/.claude/advisor-mode.json\` and confirm what you did.
4317
+ When you detect these, write the appropriate mode to \`~/.claude/pai/advisor-mode.json\` and confirm what you did.
4361
4318
 
4362
4319
  Advisor mode controls which models subagents use, based on weekly budget consumption.
4363
4320
 
4364
4321
  ### Configuration
4365
4322
 
4366
- The config file is at \`~/.claude/advisor-mode.json\`:
4323
+ The config file is at \`~/.claude/pai/advisor-mode.json\`:
4367
4324
  \`\`\`json
4368
4325
  {
4369
4326
  "weeklyBudgetPercent": 90,
@@ -4393,7 +4350,7 @@ The config file is at \`~/.claude/advisor-mode.json\`:
4393
4350
  ### Workflow
4394
4351
 
4395
4352
  **Show current status:**
4396
- Read \`~/.claude/advisor-mode.json\`. Display the mode, budget percentage, and what model constraints are active.
4353
+ Read \`~/.claude/pai/advisor-mode.json\`. Display the mode, budget percentage, and what model constraints are active.
4397
4354
 
4398
4355
  **Update budget percentage:**
4399
4356
  The user reads their weekly budget from the statusline (e.g., "7d: 63% → Fr. 08:00").
@@ -4595,7 +4552,7 @@ pai worker run --label "short task label" --class research \\
4595
4552
  - \`worker_status\` — on/off, active provider, providers, run tally.
4596
4553
  - \`worker_providers\` — list/add/update/remove/use/enable/disable/test. Adding
4597
4554
  needs name, base_url, model and a key (key file path, or a raw key which is
4598
- parked in ~/.config/pai/keys/<name>, mode 0600). update changes cost_tier
4555
+ parked in ~/.claude/pai/keys/<name>, mode 0600). update changes cost_tier
4599
4556
  (1 cheapest … 5 most expensive) and tags (code, vision, image-gen,
4600
4557
  long-context, fast, reasoning).
4601
4558
  - \`worker_classes\` — list/set/unset class → provider[/<capability>], or constraints
@@ -4634,6 +4591,37 @@ pai worker run --label "short task label" --class research \\
4634
4591
  - Never tell the user to edit a config file — the tools do it.`
4635
4592
  };
4636
4593
 
4594
+ //#endregion
4595
+ //#region src/daemon-mcp/prompts/providers.ts
4596
+ const providers = {
4597
+ description: "List every configured provider and model, mark the one this session runs on, and explain how to switch",
4598
+ content: `## Providers Skill
4599
+
4600
+ USE WHEN user says /providers, /models, /provider, what providers exist, which models are configured, show providers, what model this session is on, switch provider, OR asks which provider or model this session or the harness is currently running on.
4601
+
4602
+ ### The constraint that matters
4603
+
4604
+ A running \`claude\` process cannot switch provider — its base URL and auth are fixed for the life of the process. Claude Code's own \`/model\` command only ever lists the models of whatever endpoint THIS process was started against (plain Anthropic if started plainly, a provider's models if started through it). Switching provider always means starting a NEW session, with \`pai launch\`.
4605
+
4606
+ ### Procedure
4607
+
4608
+ 1. Run:
4609
+
4610
+ \`\`\`bash
4611
+ pai launch --list --current
4612
+ \`\`\`
4613
+
4614
+ 2. Print its output to the user **verbatim** — it already lists every enabled provider (built-in \`anthropic\` first) with its default/fast/image models, numbered, marks the workers.yaml \`active\` provider, marks the row matching THIS session own provider/model when it can be determined (falls back to (session default) rather than guessing), and ends with a line explaining how to switch.
4615
+
4616
+ 3. Do not add a summary of the table — the command output is the answer.
4617
+
4618
+ ### Notes
4619
+
4620
+ - Provider/model detection is env-based (\`ANTHROPIC_BASE_URL\` against workers.yaml, and \`ANTHROPIC_DEFAULT_SONNET_MODEL\` when set) — a best-effort read of THIS process own environment, not a live API call.
4621
+ - To actually start on a different provider: \`pai launch --provider <name> --model <model>\` (model defaults to that provider default). \`pai launch\` alone, in a terminal, offers a numbered picker instead.
4622
+ - \`pai worker providers\` is the config-management surface (add, remove, enable, disable, use) — this skill is read-only, for what is configured and what this session is on.`
4623
+ };
4624
+
4637
4625
  //#endregion
4638
4626
  //#region src/daemon-mcp/resources/aesthetic.ts
4639
4627
  const aesthetic = {
@@ -4700,7 +4688,7 @@ The foundational philosophy, architecture, and operations of PAI (Personal AI In
4700
4688
  4. **Skills as Containers** — Each skill is a self-contained unit with SKILL.md, workflows/, and tools/.
4701
4689
  5. **CLI-First** — Every capability should be accessible from the command line before being wrapped in prompts.
4702
4690
  6. **Two-Tier MCP** — Thin routing shim (daemon-mcp) + full capability daemon. Never merge them.
4703
- 7. **History as Memory** — All work is captured automatically to \${PAI_DIR}/History/. Work normally, docs handle themselves.
4691
+ 7. **History as Memory** — All work is captured automatically to \${PAI_HOME}/History/. Work normally, docs handle themselves.
4704
4692
  8. **Fail Gracefully** — Hooks and automations must never block the AI. Always exit 0.
4705
4693
 
4706
4694
  ## Architecture Layers
@@ -4720,8 +4708,8 @@ User
4720
4708
  |-----------|----------|---------|
4721
4709
  | Memory | \${PAI_DIR}/projects/*/Notes/ | Session notes, todos |
4722
4710
  | Skills | ~/.claude/Skills/ | Workflow instructions |
4723
- | History | \${PAI_DIR}/History/ | Automated capture |
4724
- | Config | ~/.config/pai/ | Agent preferences, voices |
4711
+ | History | \${PAI_HOME}/History/ | Automated capture |
4712
+ | Config | ~/.claude/pai/ | Agent preferences (config.json, workers.yaml) |
4725
4713
 
4726
4714
  ## Two-Tier MCP Strategy
4727
4715
 
@@ -5117,7 +5105,7 @@ Automated documentation of ALL work performed by PAI and specialized agents.
5117
5105
  ## Directory Structure
5118
5106
 
5119
5107
  \`\`\`
5120
- \${PAI_DIR}/History/
5108
+ \${PAI_HOME}/History/
5121
5109
  ├── Sessions/YYYY-MM/ # Session summaries
5122
5110
  ├── Learnings/YYYY-MM/ # Problem-solving narratives
5123
5111
  ├── Research/YYYY-MM/ # Investigation reports
@@ -5146,13 +5134,13 @@ YYYY-MM-DD-HHMMSS_[PROJECT]_[TYPE]_[HIERARCHY]_[DESCRIPTION].md
5146
5134
 
5147
5135
  \`\`\`bash
5148
5136
  # Quick keyword search
5149
- rg -i "keyword" \${PAI_DIR}/History/
5137
+ rg -i "keyword" \${PAI_HOME}/History/
5150
5138
 
5151
5139
  # Search sessions
5152
- rg -i "keyword" \${PAI_DIR}/History/sessions/
5140
+ rg -i "keyword" \${PAI_HOME}/History/sessions/
5153
5141
 
5154
5142
  # Recent files
5155
- ls -lt \${PAI_DIR}/History/sessions/\$(date +%Y-%m)/ | head -20
5143
+ ls -lt \${PAI_HOME}/History/sessions/\$(date +%Y-%m)/ | head -20
5156
5144
  \`\`\`
5157
5145
  `
5158
5146
  };
@@ -5442,6 +5430,37 @@ At 200 message sessions, that is 1.3MB of context saved — equivalent to 5-10 e
5442
5430
  `
5443
5431
  };
5444
5432
 
5433
+ //#endregion
5434
+ //#region src/daemon-mcp/tools/worker-run-args.ts
5435
+ /**
5436
+ * worker_run's input schema and prompt resolution, extracted so both can be
5437
+ * imported and tested without starting the shim's stdio transport.
5438
+ */
5439
+ const workerRunShape = {
5440
+ prompt: string().min(1).optional().describe("The task (the -p value). Mutually exclusive with specPath."),
5441
+ specPath: string().min(1).optional().describe("Path to a file (or \"-\" for stdin) whose contents become the prompt. Mutually exclusive with prompt."),
5442
+ chain: string().optional().describe("Comma-separated stages, e.g. draft,implement or draft,implement,review."),
5443
+ class: string().optional().describe("Task class (draft, implement, review, research, spotcheck, simple, complex, image)."),
5444
+ label: string().min(1).describe("Short task label shown in worker_ps / the status line and worker pane."),
5445
+ cwd: string().optional().describe("Working directory (default: here)."),
5446
+ allowed_tools: string().optional().describe("Comma-separated tool allowlist passed to the worker."),
5447
+ mcp: string().optional().describe("MCP servers/sets the worker may use (comma-separated).")
5448
+ };
5449
+ /**
5450
+ * The prompt text and resolved --spec path (for status recording) a
5451
+ * worker_run call resolves to. Throws when prompt/specPath are both given or
5452
+ * both missing (mutually exclusive, exactly one required) — the same rule
5453
+ * `pai worker run` enforces between -p and --spec.
5454
+ */
5455
+ function resolveWorkerRunPrompt(args, cwd) {
5456
+ if (Boolean(args.prompt) === Boolean(args.specPath)) throw new Error("exactly one of prompt or specPath is required (they are mutually exclusive)");
5457
+ if (args.specPath) return {
5458
+ promptText: readSpecPrompt(args.specPath, cwd),
5459
+ specPath: resolveSpecPath(args.specPath, cwd)
5460
+ };
5461
+ return { promptText: args.prompt };
5462
+ }
5463
+
5445
5464
  //#endregion
5446
5465
  //#region src/daemon-mcp/tools/worker-model.ts
5447
5466
  /**
@@ -5569,7 +5588,8 @@ async function startShim() {
5569
5588
  "consolidate": consolidate,
5570
5589
  "advisor": advisor,
5571
5590
  "tasks": tasks,
5572
- "worker": worker
5591
+ "worker": worker,
5592
+ "providers": providers
5573
5593
  };
5574
5594
  for (const [promptName, skill] of Object.entries(SKILL_PROMPTS)) server.prompt(promptName, skill.description, () => ({ messages: [{
5575
5595
  role: "user",
@@ -5616,7 +5636,7 @@ async function startShim() {
5616
5636
  "",
5617
5637
  "Recency boost optionally down-weights older results (recency_boost=90 means scores halve every 90 days).",
5618
5638
  "",
5619
- "Defaults come from ~/.config/pai/config.json (search section). Per-call parameters override config defaults.",
5639
+ "Defaults come from ~/.claude/pai/config.json (search section). Per-call parameters override config defaults.",
5620
5640
  "",
5621
5641
  "Returns ranked snippets with project slug, file path, line range, and score.",
5622
5642
  "Higher score = more relevant.",
@@ -5877,7 +5897,7 @@ async function startShim() {
5877
5897
  "action=add needs name, model — and either key_file or key, plus:",
5878
5898
  " base_url (anthropic protocol) or upstream_url (protocol=openai, runs",
5879
5899
  " through the local PAI proxy). A raw key is written to",
5880
- " ~/.config/pai/keys/<name> (mode 0600); only the path lands in the config.",
5900
+ " ~/.claude/pai/keys/<name> (mode 0600); only the path lands in the config.",
5881
5901
  " engine=codex runs the Codex CLI instead of Claude Code.",
5882
5902
  "action=update changes cost_tier / tags of an existing provider.",
5883
5903
  "action=test runs a one-word pong probe through the provider",
@@ -5900,7 +5920,7 @@ async function startShim() {
5900
5920
  engine: _enum(["claude", "codex"]).optional().describe("Runner engine (add). Default: claude."),
5901
5921
  context_window: number().int().positive().optional().describe("Context window for the meter (add). No default: unset hides the meter unless the init event announces one."),
5902
5922
  key_file: string().optional().describe("File holding the API token, 0600 (add)."),
5903
- key: string().optional().describe("Raw API token (add) — parked in ~/.config/pai/keys/<name>."),
5923
+ key: string().optional().describe("Raw API token (add) — parked in ~/.claude/pai/keys/<name>."),
5904
5924
  model: string().optional().describe("Default model id (add)."),
5905
5925
  fast_model: string().optional().describe("Cheaper model for spotchecks (add, optional)."),
5906
5926
  env: record(string(), string()).optional().describe("Extra env for runs (add, optional)."),
@@ -6077,23 +6097,25 @@ async function startShim() {
6077
6097
  server.tool("worker_run", [
6078
6098
  "Start a worker (or a chain) and return its id immediately.",
6079
6099
  "",
6080
- "This is the chat-side face of `pai worker run`: prompt is required,",
6081
- "chain (e.g. \"draft,implement\") runs spec-first stages, class picks the",
6082
- "provider (default: active). Check on it with worker_ps / worker_replay,",
6083
- "talk to it with worker_say."
6084
- ].join("\n"), {
6085
- prompt: string().min(1).describe("The task (the -p value)."),
6086
- chain: string().optional().describe("Comma-separated stages, e.g. draft,implement or draft,implement,review."),
6087
- class: string().optional().describe("Task class (draft, implement, review, research, spotcheck, simple, complex, image)."),
6088
- label: string().optional().describe("Short task label shown in worker_ps."),
6089
- cwd: string().optional().describe("Working directory (default: here)."),
6090
- allowed_tools: string().optional().describe("Comma-separated tool allowlist passed to the worker."),
6091
- mcp: string().optional().describe("MCP servers/sets the worker may use (comma-separated).")
6092
- }, async (args) => {
6100
+ "This is the chat-side face of `pai worker run`: label is required, and",
6101
+ "exactly one of prompt/specPath (the -p value, or a file/stdin '-' to read",
6102
+ "it from — avoids quoting long prompts through JSON-RPC). chain (e.g.",
6103
+ "\"draft,implement\") runs spec-first stages, class picks the provider",
6104
+ "(default: active). Check on it with worker_ps / worker_replay, talk to",
6105
+ "it with worker_say."
6106
+ ].join("\n"), workerRunShape, async (args) => {
6093
6107
  try {
6108
+ const cwd = args.cwd ?? process.cwd();
6109
+ let promptText;
6110
+ let specPath;
6111
+ try {
6112
+ ({promptText, specPath} = resolveWorkerRunPrompt(args, cwd));
6113
+ } catch (e) {
6114
+ return workerError(e);
6115
+ }
6094
6116
  const claudeArgs = [
6095
6117
  "-p",
6096
- args.prompt,
6118
+ promptText,
6097
6119
  ...args.allowed_tools ? ["--allowedTools", args.allowed_tools] : []
6098
6120
  ];
6099
6121
  let startedIdResolve;
@@ -6108,7 +6130,8 @@ async function startShim() {
6108
6130
  label: args.label,
6109
6131
  noPane: false,
6110
6132
  mcpFlag: args.mcp,
6111
- brief: args.prompt,
6133
+ specPath,
6134
+ brief: promptText,
6112
6135
  claudeArgs,
6113
6136
  ...args.cwd ? { cwd: args.cwd } : {},
6114
6137
  onChainStart: (id) => startedIdResolve(id),
@@ -6119,6 +6142,7 @@ async function startShim() {
6119
6142
  label: args.label,
6120
6143
  noPane: false,
6121
6144
  mcpFlag: args.mcp,
6145
+ specPath,
6122
6146
  claudeArgs,
6123
6147
  ...args.cwd ? { cwd: args.cwd } : {},
6124
6148
  onWorkerStart: (wid) => startedIdResolve(wid),
@@ -6210,11 +6234,14 @@ async function startShim() {
6210
6234
  "worker_resume (or `pai worker resume <id> \"text\"`) instead."
6211
6235
  ].join("\n"), {
6212
6236
  id: string().describe("Worker id (as shown by worker_ps)."),
6213
- text: string().min(1).describe("The message to send (one line).")
6237
+ text: string().min(1).describe("The message to send (one line)."),
6238
+ goal: string().optional().describe("Relabel the worker (its ps / pane goal) before sending the message.")
6214
6239
  }, async (args) => {
6215
6240
  try {
6216
6241
  const { workers } = readWorkersSection();
6217
- await sayToWorker(workersLogDir(workers), args.id, args.text);
6242
+ const logDir = workersLogDir(workers);
6243
+ if (args.goal !== void 0) setWorkerLabel(logDir, args.id, args.goal);
6244
+ await sayToWorker(logDir, args.id, args.text);
6218
6245
  return workerText(`sent to ${args.id}`);
6219
6246
  } catch (e) {
6220
6247
  return workerError(e);