@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
package/docs/worker.md CHANGED
@@ -59,69 +59,62 @@ main session (Anthropic) workers (configured provider)
59
59
 
60
60
  ## Config
61
61
 
62
- `~/.config/pai/config.json`, `workers` section:
63
-
64
- ```json
65
- {
66
- "workers": {
67
- "enabled": true,
68
- "active": "glm",
69
- "providers": {
70
- "glm": {
71
- "baseUrl": "https://api.z.ai/api/anthropic",
72
- "keyFile": "~/.config/zai/api_key",
73
- "models": { "default": "glm-5.3", "fast": "glm-5.3-flash" },
74
- "env": { "API_TIMEOUT_MS": "3000000" },
75
- "contextWindow": 200000,
76
- "costTier": 2,
77
- "tags": ["code", "long-context"]
78
- },
79
- "oai": {
80
- "protocol": "openai",
81
- "upstreamUrl": "https://api.openai.com/v1",
82
- "keyFile": "~/.config/pai/keys/oai",
83
- "models": { "default": "gpt-5.2", "fast": "gpt-5.2-mini" },
84
- "costTier": 4,
85
- "tags": ["reasoning", "vision"]
86
- },
87
- "codexprov": {
88
- "engine": "codex",
89
- "models": { "default": "gpt-5.2-codex" }
90
- }
91
- },
92
- "classes": {
93
- "implement": "glm",
94
- "research": { "maxCostTier": 2, "requireTags": ["long-context"] },
95
- "spotcheck": "glm/fast",
96
- "docs": { "provider": "glm", "mcp": ["office"] }
97
- },
98
- "mcpSets": {
99
- "office": ["memory", "github"],
100
- "tiny": ["fetcher"]
101
- },
102
- "pane": { "enabled": true, "fontSize": 13, "autoExitSecs": 60 },
103
- "logDir": "~/.claude/logs/workers",
104
- "routing": { "order": [], "cooldownMinutes": 30, "retryOnQuota": true }
105
- }
106
- }
62
+ Providers, model roles, class routing and MCP sets live in one hand-editable
63
+ file, `~/.claude/pai/workers.yaml` (per-user state, kept 0600, never
64
+ committed — `PAI_WORKERS_YAML` overrides it, `PAI_HOME` moves the whole
65
+ namespace) — see **docs/workers-config.md** for the full reference (the
66
+ annotated example, how to add a provider, the load order, and
67
+ `pai worker config migrate` for configs still on the old JSON shape or an
68
+ old `workers.yaml` location). Everything else worker-related (pane, log
69
+ dir, routing cooldown, cache-keepalive cadence, fallback) stays in
70
+ `~/.claude/pai/config.json`'s `workers` section.
71
+
72
+ Quick summary of workers.yaml:
73
+
74
+ ```yaml
75
+ active: glm
76
+
77
+ providers:
78
+ anthropic:
79
+ builtin: true
80
+ models:
81
+ default: claude-sonnet-5
82
+ fast: claude-haiku-4-5-20251001
83
+ glm:
84
+ url: https://api.z.ai/api/anthropic
85
+ key: "sk-…" # or key_file: ~/.config/zai/api_key
86
+ tier: 2
87
+ models:
88
+ default: glm-5.3
89
+ fast: glm-5.3-flash
90
+
91
+ classes:
92
+ implement: glm
93
+ spotcheck: glm/fast
94
+
95
+ mcp_sets:
96
+ office: [memory, github]
107
97
  ```
108
98
 
109
- - `keyFile` holds the API token (chmod 600). Keys never go into the config.
110
- - `active` is one provider name, or `"auto"` to walk `routing.order`.
111
- - `protocol: "openai"` routes the provider through the built-in proxy (next
112
- section); it needs `upstreamUrl`, the Chat Completions base.
113
- - `engine: "codex"` runs the provider on the Codex CLI instead of Claude
114
- Code (see below).
115
- - `contextWindow` overrides the context-meter window when the endpoint's
116
- init event does not announce one (default 200 000).
117
- - `costTier` (1 cheapest … 5 most expensive, default 3) and `tags` (from:
118
- `code`, `vision`, `image-gen`, `long-context`, `fast`, `reasoning`) describe
119
- a provider; classes use them to constrain routing (next section).
120
- - A class target is `"provider[/model]"` or an object with `provider` and a
121
- `mcp` allowlist applied on top of `--mcp`, or an object with only routing
122
- constraints (`maxCostTier`, `requireTags`, `order`).
123
-
124
- Or add one from the CLI:
99
+ - `key` holds the API token inline (quoted; wins over `key_file` when both
100
+ are set). `key_file` points at a 0600 file holding it instead, if you'd
101
+ rather keep the secret out of this file. Either way it is never printed
102
+ back — `pai worker providers`/`config check` show `key ****`+ last 4.
103
+ - `active` is one provider name, `"auto"` to walk `routing.order` (still in
104
+ the JSON config), or the built-in `anthropic`.
105
+ - `protocol: openai` (plus `upstream_url`) routes the provider through the
106
+ built-in proxy (next section); `engine: codex` runs it on the Codex CLI
107
+ instead of Claude Code. `tier` (1 cheapest … 5 most expensive, default 3)
108
+ and `tags` describe a provider for routing constraints. These, and a
109
+ provider's `env`/`note`/`quota_probe`/`context_window`/`model_tiers`, are
110
+ optional advanced fields not shown in the starter — docs/workers-config.md
111
+ lists them all.
112
+ - A class target is `provider[/role]`; the object form (`provider` + `mcp`
113
+ allowlist, or routing-only constraints `maxCostTier`/`requireTags`/`order`)
114
+ is still supported for advanced routing.
115
+
116
+ Or add a provider from the CLI (writes workers.yaml once it exists, else the
117
+ JSON `workers` section):
125
118
 
126
119
  ```
127
120
  pai worker providers add glm \
@@ -132,7 +125,7 @@ pai worker providers add glm \
132
125
  --cost-tier 2 --tags code,long-context
133
126
  pai worker providers add oai \
134
127
  --upstream-url https://api.openai.com/v1 \
135
- --key-file ~/.config/pai/keys/oai --model gpt-5.2
128
+ --key-file ~/.claude/pai/keys/oai --model gpt-5.2
136
129
  pai worker providers update glm --cost-tier 1 # tiers/tags change later
137
130
  ```
138
131
 
@@ -234,7 +227,9 @@ pai worker ps # this session's workers
234
227
  pai worker follow [id] # live transcript (type to talk to it)
235
228
  pai worker replay <id> # transcript of one worker
236
229
  pai worker say <id> "<text>" # message a running worker
230
+ pai worker goal <id> "<text>" # re-goal a running worker (ps/pane label), no message sent
237
231
  pai worker resume <id> "<text>" # continue a finished one, context intact
232
+ pai worker kill <id> # SIGTERM a running worker
238
233
  pai worker mcp list # MCP servers + sets usable in --mcp
239
234
  pai worker proxy [--port N|stop] # the translating proxy, by hand
240
235
  pai worker log [all|tail|<id>] # raw streams + routing ledger
@@ -323,7 +318,7 @@ What `on` does:
323
318
  `CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1`.
324
319
  - Pins the top-level `model` key to the provider's default model.
325
320
  - Saves the replaced values under `workers.fallback.saved` in
326
- `~/.config/pai/config.json` and writes a `FALLBACK-ACTIVE.md` note into the
321
+ `~/.claude/pai/config.json` and writes a `FALLBACK-ACTIVE.md` note into the
327
322
  workers log dir telling running sessions what to do.
328
323
 
329
324
  Notes:
@@ -368,6 +363,17 @@ Notes:
368
363
 
369
364
  ### The worker contract
370
365
 
366
+ A worker owns its task: it finishes the work itself in its own process,
367
+ never hands the whole thing to a single child and steps back. Children exist
368
+ for two things only — parallelising independent parts of the task (each a
369
+ self-contained spec), or cheaper bounded sub-tasks (probes, renders, test
370
+ runs, lookups) run one tier down with `--class spotcheck`/`simple`. A worker
371
+ owns its children's results too: run them in the foreground or poll until
372
+ each finishes, verify, fold into the report — ending the parent's turn ends
373
+ the run and kills any child still going, so nothing is ever left running
374
+ unattended. `WORKER_CONTRACT_PROMPT` in `src/workers/report.ts` is the exact
375
+ text appended to every headless run's system prompt.
376
+
371
377
  Headless runs append a system prompt that fixes the shape of the final
372
378
  answer: act, verify, then stop with ONE JSON message
373
379
 
@@ -531,6 +537,13 @@ on top. An unknown name fails fast, listing what exists;
531
537
  `pai worker mcp list` shows servers and sets. A caller-provided
532
538
  `--mcp-config` always wins; MCP is chosen at launch, not mid-run.
533
539
 
540
+ `claude-in-chrome` is not an MCP server — it rides the Chrome native-host
541
+ bridge, which no config file loads and which is off in a spawned worker
542
+ until `--chrome` is passed. Allowlisting any
543
+ `mcp__claude-in-chrome__<tool>` (or the bare name) in `--allowedTools`
544
+ appends `--chrome` automatically; a `--chrome` passed by hand is kept
545
+ rather than duplicated.
546
+
534
547
  ## Scoping (who sees whose workers)
535
548
 
536
549
  `ps`/`follow`/status line show the workers of the asking terminal:
@@ -584,6 +597,21 @@ background instead. Decisions are ledgered (`DENIED-ANTHROPIC-AGENT`,
584
597
  - `pai worker off` — Agent subagents run on Anthropic again.
585
598
  - `ALLOW_ANTHROPIC_AGENTS=1` — bypass for one session.
586
599
 
600
+ ## Whisper rules: `@orchestrator` / `@worker` tags
601
+
602
+ Whisper rules are injected into every claude process, spawned workers
603
+ included, but some rules only make sense for one side — "delegate to
604
+ workers" means nothing inside a worker that cannot spawn more workers past
605
+ the tree cap. A comment line `# @orchestrator` in whisper-rules.md marks
606
+ every rule that follows as orchestrator-only, `# @worker` marks worker-only,
607
+ and the next section header (`# N. TITLE`) resets to untagged (reaches
608
+ both); a section's own header/divider box does not count as that reset. A
609
+ process tells which side it is on from `PAI_WORKER=1` in its environment —
610
+ set by the worker runner on every spawn (see "What a worker is" above) and
611
+ absent on the interactive orchestrating session. Manage tags with the
612
+ Whisper skill (`/whisper`); the parsing lives in
613
+ `src/hooks/ts/user-prompt/whisper-rules.ts`.
614
+
587
615
  ## MCP tools
588
616
 
589
617
  `worker_status`, `worker_providers`
@@ -595,29 +623,54 @@ worker or chain from chat, returns the id immediately), `worker_toggle`,
595
623
  worker: send a proposal/question/blocker up to its parent) — the same library
596
624
  the CLI calls.
597
625
  `worker_providers add` accepts a raw `key`, parks it in
598
- `~/.config/pai/keys/<name>` (mode 0600) and stores only the path.
626
+ `~/.claude/pai/keys/<name>` (mode 0600) and stores only the path.
599
627
 
600
628
  ## Status line
601
629
 
602
- Line 4 of the statusline is the worker bar: the provider and running-worker
603
- count, one row per running spawned worker, and today's ✓/✗ tally. It prefers
604
- the standalone `~/.claude/worker-status-line.mjs` (plain node, built by
605
- `bun run build`) and falls back to `pai worker status-line`.
630
+ Line 4 of the statusline is the worker bar, prefixed 🐝: a summary of every
631
+ running worker plus today's ✓/✗ tally, never one row per worker — three
632
+ workers used to spell out three goals, three ages and three models on one
633
+ line and none of it fit. It prefers the standalone
634
+ `~/.claude/worker-status-line.mjs` (plain node, built by `bun run build`)
635
+ and falls back to `pai worker status-line`.
636
+
637
+ Example: `anthropic ▶3 · sonnet-5 ×2 · haiku-4.5 · oldest 7m ✓35 ✗11 today`
638
+
639
+ Segment by segment (`renderStatusLine` in `src/workers/render.ts`):
640
+
641
+ - head (`anthropic`) — the live routing choice (`workers.active`) when it
642
+ names one provider; else the chat pane's provider; else `workers` when
643
+ several providers are running and there is no tracked chat pane
644
+ - `▶3` — this terminal's running spawned workers: `state=running` **and** a
645
+ live pid **and** not the chat pane; nothing at zero, so an idle terminal
646
+ shows just the head
647
+ - `sonnet-5 ×2 · haiku-4.5` — distinct short model names of the running
648
+ workers, most-populous first, each suffixed `×N` past one; a legacy
649
+ status with no recorded model counts under `?` rather than vanishing;
650
+ this segment alone shrinks to fit known terminal width, so the head, the
651
+ `▶N` count and the today tally never get cut
652
+ - `oldest 7m` — age of the longest-running worker
653
+ - `✓35 ✗11 today` — today's finished workers: done vs failed
606
654
 
607
- Example: `glm ▶2 | fix black buttons · 6m · grep … | spotcheck login · 1m · Edit: button.ts ✓75 ✗4 today`
608
-
609
- Segment by segment:
655
+ The chat pane itself contributes only its provider — its age, state and
656
+ inbox live in `pai worker ps`, never in the bar. The per-worker detail that
657
+ used to live in the bar — goal, age, current tool — moved to each worker's
658
+ own pane bottom line and to `pai worker ps`:
610
659
 
611
- - provider tag (`glm`) — the chat pane's provider; `workers` when there is no tracked chat pane and the running workers are mixed
612
- - `▶2` — this terminal's running spawned workers: `state=running` **and** a live pid **and** not the chat pane; nothing at zero, so an idle terminal shows just `glm`
613
- - row `name · age · step` — the worker's `--label` (else the first 70 chars of the prompt, `unlabeled` when the run had neither), time since it started, and the verb of what it is doing; `#id` (the short form `pai worker ps` shows) joins the name only when two running workers share a label
614
- - step (`grep …`) — the current tool trimmed to its verb: no `Bash:` prefix, no flags, no quotes, ≤24 chars; file tools keep their `Edit: button.ts` shape
615
- - `✓75 ✗4 today` — today's finished workers: done vs failed
660
+ ```
661
+ <goal> · <model> · started HH:MM · <age>
662
+ ```
616
663
 
617
- The chat pane itself contributes only its provider — its age, state and
618
- inbox live in `pai worker ps`, never in the bar. Rows are flat and
619
- oldest-first; the worker forest (`↳` depth) and `◆N` inbox marks are `ps`
620
- territory too. A status file from before the `origin` flag (a running entry
621
- with no origin, the unlabeled placeholder and zero turns) is treated as the
622
- chat pane so it does not render as a phantom worker — that shim goes away
623
- once every pane runs code that writes `origin`.
664
+ `paneStatusRow` in `src/workers/render.ts` renders it; the goal is the
665
+ worker's `--label` (else the first chars of the prompt, `unlabeled` when
666
+ the run had neither), shrunk first when the pane is narrow so the fixed
667
+ `model · started · age` tail always survives. Re-goal a running worker
668
+ without sending it a message — `pai worker goal <id> "<text>"` — or relabel
669
+ and message it in one call with `pai worker say --goal "<text>" <id>
670
+ "<message>"`. Both update the row in `ps`, the pane, and the bar's tally.
671
+
672
+ The worker forest (`↳` depth) and `◆N` inbox marks are `ps` territory too.
673
+ A status file from before the `origin` flag (a running entry with no
674
+ origin, the unlabeled placeholder and zero turns) is treated as the chat
675
+ pane so it does not render as a phantom worker — that shim goes away once
676
+ every pane runs code that writes `origin`.