@tekmidian/pai 1.0.0 → 1.0.3

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 (219) hide show
  1. package/.claude-plugin/plugin.json +1 -1
  2. package/README.md +67 -5
  3. package/dist/aibroker-client-BxzeEHPF.mjs +3 -0
  4. package/dist/{aibroker-client-CXEYBzbf.mjs → aibroker-client-CQPGqLxL.mjs} +1 -1
  5. package/dist/atomic-file-BorMa4T3.mjs +21 -0
  6. package/dist/{auto-route-D5SXrMpB.mjs → auto-route-B7Yu6Uam.mjs} +3 -3
  7. package/dist/auto-route-CjjQqU1o.mjs +11 -0
  8. package/dist/budget-Dod6rnA9.mjs +15 -0
  9. package/dist/{caller-identity-CVTuiLSs.mjs → caller-identity-yLFb7CKq.mjs} +6 -5
  10. package/dist/{capacity-DaXrVj3J.mjs → capacity-DEveQdFV.mjs} +3 -3
  11. package/dist/{chain-BcQlIlEd.mjs → chain-7n9Gx56r.mjs} +5 -5
  12. package/dist/cli/index.mjs +1628 -370
  13. package/dist/{cockpit-actions-ODmt8yF9.mjs → cockpit-actions-BBHeyEZI.mjs} +84 -42
  14. package/dist/cockpit-actions-DR9X514g.mjs +20 -0
  15. package/dist/cockpit-memory--dnShXBA.mjs +20 -0
  16. package/dist/{config-BSXKyeJ1.mjs → config-Bu1_vbY8.mjs} +42 -3
  17. package/dist/{config-B955yYmo.mjs → config-Cxi-aBf4.mjs} +2 -2
  18. package/dist/{config-TaWmdTLx.mjs → config-DtENJ6cL.mjs} +1 -1
  19. package/dist/{config-D5chi2LO.mjs → config-XpZWOYOG.mjs} +2 -2
  20. package/dist/{controls-BGkK_Bdi.mjs → controls-CPoeudou.mjs} +37 -22
  21. package/dist/daemon/index.mjs +43 -42
  22. package/dist/daemon-DKdBNKfa.mjs +45 -0
  23. package/dist/{daemon-CorGh6Ub.mjs → daemon-DPAo6WTa.mjs} +103 -55
  24. package/dist/daemon-mcp/index.mjs +40 -39
  25. package/dist/{define-DGFu-sCf.mjs → define-CjJsmq-6.mjs} +1 -1
  26. package/dist/{detect-C1d5cUkT.mjs → detect-9CZNO0yf.mjs} +2 -2
  27. package/dist/detect-D1ziFFfA.mjs +10 -0
  28. package/dist/{embed-pass-CeQD8kRE.mjs → embed-pass-DIWjA68P.mjs} +5 -5
  29. package/dist/{embedding-gate-BHuBsgHD.mjs → embedding-gate-6rZrWRXa.mjs} +5 -5
  30. package/dist/{embedding-gate-Z7CJSOJk.mjs → embedding-gate-Cnk4YCyX.mjs} +3 -3
  31. package/dist/{embeddings-D4t6L-EH.mjs → embeddings-BVq3esBF.mjs} +1 -1
  32. package/dist/{embeddings-OF9Pt4by.mjs → embeddings-CIkJBKd-.mjs} +1 -1
  33. package/dist/{endreason-x1KOSrcO.mjs → endreason-C577xIQz.mjs} +7 -6
  34. package/dist/{env-DArqGq-Z.mjs → env-BE8mrsxr.mjs} +1 -1
  35. package/dist/factory-Bsib-qDG.mjs +9 -0
  36. package/dist/{factory-BtjbQ0np.mjs → factory-DjAAsqr_.mjs} +15 -13
  37. package/dist/{fallback-BIyEpPsQ.mjs → fallback-DFlItw1Z.mjs} +5 -5
  38. package/dist/{fmt-age-BiSHrTKN.mjs → fmt-age-ByDkvkoU.mjs} +1 -1
  39. package/dist/{health-C6jZWvRG.mjs → health-Dnym-qcT.mjs} +4 -4
  40. package/dist/{helpers-DFmYRCOa.mjs → helpers-BD6V-p9w.mjs} +2 -2
  41. package/dist/helpers-CMGjy_0N.mjs +10 -0
  42. package/dist/{helpers-CJpb_MNB.mjs → helpers-CRuBUas3.mjs} +87 -38
  43. package/dist/hooks/capture-all-events.mjs +52 -11
  44. package/dist/hooks/capture-session-summary.mjs +64 -47
  45. package/dist/hooks/capture-tool-output.mjs +49 -8
  46. package/dist/hooks/context-compression-hook.mjs +30 -10
  47. package/dist/hooks/initialize-session.mjs +1 -0
  48. package/dist/hooks/load-core-context.mjs +1 -1
  49. package/dist/hooks/load-project-context.mjs +32 -29
  50. package/dist/hooks/security-validator.mjs +45 -13
  51. package/dist/hooks/stop-hook.mjs +54 -16
  52. package/dist/hooks/supervision-banner.mjs +9 -0
  53. package/dist/hooks/sync-todo-to-md.mjs +147 -113
  54. package/dist/hooks/worker-edit-repair.mjs +2 -1
  55. package/dist/hooks/worker-guard.mjs +40 -16
  56. package/dist/hooks/worker-note.mjs +12 -5
  57. package/dist/hooks/worker-path-repair.mjs +1 -1
  58. package/dist/hooks/worker-pool-host.mjs +329 -231
  59. package/dist/hooks/worker-status-line.mjs +195 -114
  60. package/dist/index.d.mts +18 -0
  61. package/dist/index.mjs +12 -12
  62. package/dist/{indexer-backend-BM2CUSu8.mjs → indexer-backend-Cll7le4P.mjs} +149 -96
  63. package/dist/{ipc-client-BMqWw_gv.mjs → ipc-client-CaiGJnSM.mjs} +1 -1
  64. package/dist/{ipc-client-YYDD6zzU.mjs → ipc-client-ZRmDKd5Z.mjs} +1 -1
  65. package/dist/kill-tree-BG7dRVtp.mjs +10 -0
  66. package/dist/{kill-tree-BjYz5BxK.mjs → kill-tree-EWYaEk5v.mjs} +8 -8
  67. package/dist/{launch-CLp0OJxV.mjs → launch-CXVlZjHt.mjs} +8 -8
  68. package/dist/{launch-DgqQdAjI.mjs → launch-Jh5NVeNe.mjs} +3 -3
  69. package/dist/local-candidate-DLdwQt0s.mjs +112 -0
  70. package/dist/local-instances-DOxSgT_L.mjs +210 -0
  71. package/dist/local-instances-ZeRkkuS5.mjs +6 -0
  72. package/dist/{local-tiers-DPZYqv9m.mjs → local-tiers-BE4jGaMa.mjs} +2 -2
  73. package/dist/{local-tiers-DnBIAkbK.mjs → local-tiers-DNMI5W86.mjs} +3 -3
  74. package/dist/{main-config-ops-C0SflOWk.mjs → main-config-ops-BEMpuhDz.mjs} +3 -3
  75. package/dist/{main-resolver-DVPpSWVy.mjs → main-resolver-3Ns1HPmS.mjs} +18 -17
  76. package/dist/{migrate-BUJHadA8.mjs → migrate-DrA_OwlZ.mjs} +45 -14
  77. package/dist/min-max-DrSRUaWQ.mjs +16 -0
  78. package/dist/{model-inventory-Dasber3S.mjs → model-inventory-BFVSNFT3.mjs} +13 -12
  79. package/dist/{models-add-Bt7aUHDs.mjs → models-add-C1QIc1DA.mjs} +39 -38
  80. package/dist/operator-BTqvTIc8.mjs +7 -0
  81. package/dist/{operator-DZxcP-g8.mjs → operator-CyuB3aVw.mjs} +3 -3
  82. package/dist/{pai-marker-kIYuNt3c.mjs → pai-marker-BcZyJguM.mjs} +7 -6
  83. package/dist/{pane-audit-OGYrOAik.mjs → pane-audit-DKQt71s4.mjs} +7 -7
  84. package/dist/{paths-DoRuFc60.mjs → paths-CFHTloSe.mjs} +3 -3
  85. package/dist/{paths-DoIyRnhx.mjs → paths-CHifubDh.mjs} +3 -3
  86. package/dist/{planner-DLGOYlVb.mjs → planner-BmFACdLa.mjs} +31 -30
  87. package/dist/{pool-CZ5MZaXg.mjs → pool-Dh-q3iJi.mjs} +45 -6
  88. package/dist/{pool-cli-BxNSPzzY.mjs → pool-cli-BggU8GRp.mjs} +5 -5
  89. package/dist/{pool-cli-CbJfl37y.mjs → pool-cli-DQ6OzRy2.mjs} +6 -6
  90. package/dist/postgres-BdBNkL_l.mjs +7 -0
  91. package/dist/{postgres-CDnd_k5f.mjs → postgres-C6ti4haA.mjs} +55 -34
  92. package/dist/{project-setup-DM4npnL3.mjs → project-setup-jvfONJTQ.mjs} +131 -74
  93. package/dist/providers-BeDiVEb-.mjs +16 -0
  94. package/dist/{providers-UsKtLcUR.mjs → providers-CblTFrhz.mjs} +6 -6
  95. package/dist/{query-feedback-I-txSnld.mjs → query-feedback-BRfPtqki.mjs} +2 -2
  96. package/dist/registrable-BzH4TObg.mjs +9 -0
  97. package/dist/{registrable-LrRIVYQc.mjs → registrable-DpyTtajg.mjs} +4 -4
  98. package/dist/{render-BDbb4CF-.mjs → render-BYmQkuLd.mjs} +8 -8
  99. package/dist/render-CoMvwMPs.mjs +13 -0
  100. package/dist/{reranker-B4r4vykM.mjs → reranker-8g6xMwP7.mjs} +1 -1
  101. package/dist/{reranker-DxxMCtA0.mjs → reranker-CqCbpGnX.mjs} +1 -1
  102. package/dist/root-FtJsxYnm.mjs +36 -0
  103. package/dist/{root-BMeJuHOb.mjs → root-Xglu0OPD.mjs} +11 -11
  104. package/dist/route-table-B7zpoypi.mjs +15 -0
  105. package/dist/{router-L8Nu-OHF.mjs → router-CQSc3lk3.mjs} +17 -7
  106. package/dist/{router-D6Ec6Fid.mjs → router-DwHJRgG9.mjs} +1 -1
  107. package/dist/{routing-CUyiglfu.mjs → routing-BAAST9vT.mjs} +27 -308
  108. package/dist/{routing-ZuGlc0ge.mjs → routing-CENt4HH1.mjs} +13 -12
  109. package/dist/{run-ulAi5dFD.mjs → run-CSC7mgPf.mjs} +35 -33
  110. package/dist/{scan-B7I0gPe-.mjs → scan-C_Y5W9py.mjs} +6 -6
  111. package/dist/{local-candidate-jOjTNlOL.mjs → scheduler-CtUyWJ3O.mjs} +7 -109
  112. package/dist/scheduler-dmHXoRvm.mjs +3 -0
  113. package/dist/{scope-D5VSQxe4.mjs → scope-D-h6F6DN.mjs} +4 -4
  114. package/dist/{search-CPoE0830.mjs → search-RSyeQqj1.mjs} +18 -18
  115. package/dist/{session-CNXF6DLP.mjs → session-8iqQDkqb.mjs} +55 -31
  116. package/dist/session-BeqAbNPd.mjs +35 -0
  117. package/dist/session-scan-BJI_ZO8M.mjs +9 -0
  118. package/dist/{session-scan-BDLEc4w1.mjs → session-scan-W-gbwJHM.mjs} +6 -6
  119. package/dist/{sources-CjhUKKtO.mjs → sources-ESUkZaWv.mjs} +1 -1
  120. package/dist/{status-DYydKQUI.mjs → status-Dm4dYciN.mjs} +4 -4
  121. package/dist/{status-CvVi9cDf.mjs → status-ggJ7lgVg.mjs} +17 -9
  122. package/dist/{stop-words-SdSL1WKH.mjs → stop-words-DSEYQdNe.mjs} +1 -1
  123. package/dist/{test-isolation-CoDeOVXb.mjs → test-isolation-lqSmYxr0.mjs} +1 -1
  124. package/dist/{timeouts-OwEONmc8.mjs → timeouts-1MLooEBB.mjs} +1 -1
  125. package/dist/{tool-errors-AeRQuG3Y.mjs → tool-errors-7E13StWd.mjs} +4 -3
  126. package/dist/{tool-errors-R5E0fCgf.mjs → tool-errors-CJWODvlo.mjs} +6 -6
  127. package/dist/viewer-CqozWW39.mjs +22 -0
  128. package/dist/{viewer-DtWj5Vti.mjs → viewer-mDXUNHNy.mjs} +15 -15
  129. package/dist/{wait-BMUR-U-U.mjs → wait-ByV0OyMZ.mjs} +3 -3
  130. package/dist/{worker-config-BLqa1yiD.mjs → worker-config-CJhEMk19.mjs} +294 -92
  131. package/dist/worker-config-DESkIjMF.mjs +41 -0
  132. package/dist/{workers-config-DEI9lrV4.mjs → workers-config-f8KrkY4L.mjs} +2 -2
  133. package/dist/{worktree-zmRf556h.mjs → worktree-CRs2gyg0.mjs} +37 -7
  134. package/dist/{zettelkasten-nigq7fqs.mjs → zettelkasten-B_rRRRvD.mjs} +5 -5
  135. package/dist/{zettelkasten-Cr_Xj0mG.mjs → zettelkasten-BzMm8REH.mjs} +29 -19
  136. package/docs/README.md +2 -0
  137. package/docs/cockpit.md +10 -4
  138. package/docs/commands/README.md +4 -4
  139. package/docs/commands/backup.md +2 -0
  140. package/docs/commands/install.md +29 -4
  141. package/docs/commands/providers.md +1 -1
  142. package/docs/commands/restore.md +4 -0
  143. package/docs/commands/setup.md +29 -4
  144. package/docs/commands/worker.md +1 -1
  145. package/docs/config.md +2 -0
  146. package/docs/features.md +299 -0
  147. package/docs/images/architecture.drawio +51 -0
  148. package/docs/images/architecture.png +0 -0
  149. package/docs/images/architecture.svg +3 -0
  150. package/docs/images/cockpit-01-system-tokens.jpg +0 -0
  151. package/docs/images/cockpit-02-totals-cache.jpg +0 -0
  152. package/docs/images/cockpit-03-local-servers-models-pool.jpg +0 -0
  153. package/docs/images/cockpit-04-workers-memory.jpg +0 -0
  154. package/docs/images/cockpit-05-performance.jpg +0 -0
  155. package/docs/images/cockpit-06-runs-speed-routing.jpg +0 -0
  156. package/docs/images/cockpit-07-settings-registry.jpg +0 -0
  157. package/docs/install/index.md +29 -0
  158. package/docs/three-tier-coding.md +1 -1
  159. package/gemini-extension.json +1 -1
  160. package/package.json +1 -5
  161. package/pai-plugin.json +1 -1
  162. package/plugins/context-preservation/plugin.json +1 -1
  163. package/plugins/core/plugin.json +1 -1
  164. package/plugins/core/skills/setup/SKILL.md +41 -9
  165. package/plugins/creative/plugin.json +1 -1
  166. package/plugins/observability/plugin.json +1 -1
  167. package/plugins/productivity/plugin.json +1 -1
  168. package/plugins/semantic-search/plugin.json +1 -1
  169. package/plugins/ui/plugin.json +1 -1
  170. package/plugins/zettelkasten/plugin.json +1 -1
  171. package/src/hooks/session-autosave.sh +8 -1
  172. package/src/hooks/session-stop.sh +8 -1
  173. package/src/hooks/ts/capture-all-events.ts +7 -12
  174. package/src/hooks/ts/lib/context-fill.ts +2 -1
  175. package/src/hooks/ts/lib/path-repair.ts +1 -1
  176. package/src/hooks/ts/lib/project-utils/notify.ts +1 -0
  177. package/src/hooks/ts/lib/project-utils/session-notes.ts +23 -6
  178. package/src/hooks/ts/lib/raw-capture.ts +36 -0
  179. package/src/hooks/ts/lib/session-summary.ts +129 -0
  180. package/src/hooks/ts/lib/todo-sync.ts +120 -0
  181. package/src/hooks/ts/lib/worker-git-guard.ts +1 -1
  182. package/src/hooks/ts/post-tool-use/capture-tool-output.ts +6 -10
  183. package/src/hooks/ts/post-tool-use/sync-todo-to-md.ts +5 -105
  184. package/src/hooks/ts/pre-compact/context-compression-hook.ts +1 -1
  185. package/src/hooks/ts/pre-tool-use/security-validator.ts +35 -14
  186. package/src/hooks/ts/session-end/capture-session-summary.ts +20 -128
  187. package/src/hooks/ts/session-start/load-core-context.ts +3 -3
  188. package/src/hooks/ts/session-start/load-project-context.ts +18 -22
  189. package/src/hooks/ts/stop/stop-hook.ts +13 -5
  190. package/src/hooks/ztk-auto.sh +7 -2
  191. package/dist/aibroker-client-JjE74jo0.mjs +0 -3
  192. package/dist/auto-route-BRk8NEFv.mjs +0 -11
  193. package/dist/budget-DuhQ2zzG.mjs +0 -14
  194. package/dist/cockpit-actions-DcQ-ucU8.mjs +0 -19
  195. package/dist/cockpit-memory-KV45PPO2.mjs +0 -19
  196. package/dist/daemon-C7yt_ptC.mjs +0 -44
  197. package/dist/detect-DRUkmHnb.mjs +0 -10
  198. package/dist/factory-DAGG9_n8.mjs +0 -9
  199. package/dist/helpers-DPJEHPq6.mjs +0 -10
  200. package/dist/kill-tree-LV0Q7Mte.mjs +0 -10
  201. package/dist/operator-CfL0HiBK.mjs +0 -7
  202. package/dist/postgres-DgqWyqhN.mjs +0 -7
  203. package/dist/providers-CTu2s1z2.mjs +0 -15
  204. package/dist/registrable-D9aNZOTh.mjs +0 -9
  205. package/dist/render-BSfVlYHj.mjs +0 -13
  206. package/dist/root-xI9DqVIe.mjs +0 -35
  207. package/dist/route-table-HjvnLVEU.mjs +0 -14
  208. package/dist/session-BJHzmUg2.mjs +0 -34
  209. package/dist/session-scan-YORKE1NO.mjs +0 -9
  210. package/dist/viewer-B8709jDN.mjs +0 -22
  211. package/dist/worker-config-D8tRuvo7.mjs +0 -40
  212. package/docs/images/cockpit-limits-routing.jpg +0 -0
  213. package/docs/images/cockpit-models.jpg +0 -0
  214. package/docs/images/cockpit-usage.jpg +0 -0
  215. package/docs/images/cockpit-workers-system.jpg +0 -0
  216. package/scripts/build-docs.mjs +0 -41
  217. package/scripts/build-hooks.mjs +0 -311
  218. package/scripts/build-skill-stubs.mjs +0 -216
  219. package/scripts/copy-defaults.mjs +0 -46
@@ -0,0 +1,45 @@
1
+ import "./utils-J2b9y8PC.mjs";
2
+ import "./migrate-DrA_OwlZ.mjs";
3
+ import "./config-XpZWOYOG.mjs";
4
+ import "./config-Bu1_vbY8.mjs";
5
+ import "./paths-CHifubDh.mjs";
6
+ import "./worktree-CRs2gyg0.mjs";
7
+ import "./status-ggJ7lgVg.mjs";
8
+ import "./pool-Dh-q3iJi.mjs";
9
+ import "./registrable-DpyTtajg.mjs";
10
+ import "./pai-marker-BcZyJguM.mjs";
11
+ import "./helpers-CRuBUas3.mjs";
12
+ import "./reranker-CqCbpGnX.mjs";
13
+ import "./scope-D-h6F6DN.mjs";
14
+ import "./routing-BAAST9vT.mjs";
15
+ import "./tool-errors-7E13StWd.mjs";
16
+ import "./wait-ByV0OyMZ.mjs";
17
+ import "./local-tiers-BE4jGaMa.mjs";
18
+ import "./caller-identity-yLFb7CKq.mjs";
19
+ import "./capacity-DEveQdFV.mjs";
20
+ import "./local-instances-DOxSgT_L.mjs";
21
+ import "./local-candidate-DLdwQt0s.mjs";
22
+ import "./factory-DjAAsqr_.mjs";
23
+ import "./postgres-C6ti4haA.mjs";
24
+ import "./embedding-gate-6rZrWRXa.mjs";
25
+ import "./embeddings-BVq3esBF.mjs";
26
+ import "./router-CQSc3lk3.mjs";
27
+ import "./detect-9CZNO0yf.mjs";
28
+ import "./scan-C_Y5W9py.mjs";
29
+ import "./launch-Jh5NVeNe.mjs";
30
+ import "./run-CSC7mgPf.mjs";
31
+ import "./controls-CPoeudou.mjs";
32
+ import "./endreason-C577xIQz.mjs";
33
+ import "./render-BYmQkuLd.mjs";
34
+ import "./operator-CyuB3aVw.mjs";
35
+ import "./kill-tree-EWYaEk5v.mjs";
36
+ import "./pool-cli-BggU8GRp.mjs";
37
+ import "./pane-audit-DKQt71s4.mjs";
38
+ import "./ipc-client-CaiGJnSM.mjs";
39
+ import "./embed-pass-DIWjA68P.mjs";
40
+ import "./indexer-backend-Cll7le4P.mjs";
41
+ import { t as serve } from "./daemon-DPAo6WTa.mjs";
42
+ import "./auto-route-B7Yu6Uam.mjs";
43
+ import "./zettelkasten-BzMm8REH.mjs";
44
+
45
+ export { serve };
@@ -1,37 +1,39 @@
1
1
  import { g as paiHomePath } from "./runtime-paths-WsO9sJFc.mjs";
2
- import { j as readWorkersSection, t as ANTHROPIC_NATIVE, wt as appendLedger } from "./config-D5chi2LO.mjs";
3
- import { f as readMainConfigRaw, i as defaults, p as writeMainConfigRaw, y as shippedMainDefaults } from "./config-BSXKyeJ1.mjs";
4
- import { c as slotCurrentPath, i as ledgerPath, r as eventsPath, u as workersLogDir } from "./paths-DoIyRnhx.mjs";
5
- import { f as gcWorktreesThrottled, w as worktreesDir } from "./worktree-zmRf556h.mjs";
6
- import { B as loadStatusConfig, C as nowStamp, G as writeSectionToForge, I as PROJECT_CONFIG_REL, L as formatStale, b as loadStatusesCached, h as isChatPane, k as saveStatus, s as alive, v as loadStatus, z as listStale } from "./status-CvVi9cDf.mjs";
7
- import { a as unregistrableReason } from "./registrable-LrRIVYQc.mjs";
8
- import { c as yieldToEventLoop, f as fileContentHash, l as buildOutline, n as chunkId, u as chunkMarkdown } from "./helpers-CJpb_MNB.mjs";
9
- import { n as TITLE_STOP_WORDS, t as STOP_WORDS } from "./stop-words-SdSL1WKH.mjs";
10
- import { i as populateSlugs, t as applyRecencyBoost } from "./search-CPoE0830.mjs";
11
- import { n as rerankResults } from "./reranker-DxxMCtA0.mjs";
12
- import { i as itermUuid, r as itermForClaudeSession } from "./scope-D5VSQxe4.mjs";
13
- import { st as startInventoryRefresh, xn as startLocalStatusRefresh } from "./routing-CUyiglfu.mjs";
14
- import { C as toolErrorSigTag, S as summarizeToolInput, T as toolErrorText, a as SAME_WORKER_WINDOW_MS, b as readToolErrors, c as classifyToolError, d as detectToolErrors, s as benignNote, u as detectRunningWorkerErrors, w as toolErrorSummary } from "./tool-errors-AeRQuG3Y.mjs";
15
- import { b as killProcessTree } from "./wait-BMUR-U-U.mjs";
16
- import { c as listBuildsSync, i as buildsDir, l as patchTicket, s as listBuilds, y as stallMinutes } from "./caller-identity-CVTuiLSs.mjs";
17
- import { t as LOCAL_PROBE_TIMEOUT_MS } from "./timeouts-OwEONmc8.mjs";
18
- import { d as getBackendOutage, n as createRegistryBackend, r as createStorageBackend } from "./factory-BtjbQ0np.mjs";
19
- import { c as resolveFromModule, n as embedChunksWithBackend } from "./postgres-CDnd_k5f.mjs";
20
- import { a as requireQueryEmbedding, c as getConfiguredBackend, h as mismatchReason, m as bindingMatches, n as embedQuery } from "./embedding-gate-BHuBsgHD.mjs";
21
- import { i as deserializeEmbedding, n as configureEmbeddingModel, r as cosineSimilarity$1 } from "./embeddings-D4t6L-EH.mjs";
22
- import { n as routeNotification } from "./router-L8Nu-OHF.mjs";
23
- import { r as formatDetectionJson, t as detectProject } from "./detect-C1d5cUkT.mjs";
24
- import { i as performScan } from "./scan-B7I0gPe-.mjs";
25
- import { r as sendToSession, t as callAiBroker } from "./aibroker-client-CXEYBzbf.mjs";
26
- import { E as probeRouter, F as startHandover, M as routerSwapArgs, N as runRouterTick, O as routerIsStale, P as spawnRouter, j as routerRunningPid, l as runMessenger, t as runWorker } from "./run-ulAi5dFD.mjs";
27
- import { a as localIdleTick, et as closeEndedPanes, g as sweepRuns, gt as workerEnded, pt as paneMayClose, st as loadRegistry, xt as truncateLines } from "./controls-BGkK_Bdi.mjs";
28
- import { l as isPaneRunId, n as auditTick, r as closeFinishedPanes } from "./pane-audit-OGYrOAik.mjs";
29
- import { a as EMBED_PASS_BATCH_SIZE, c as liveYieldCheck, d as runEmbedCycle, i as DEFAULT_EMBED_RESUME_MINUTES, n as DEFAULT_EMBED_MAX_LOAD, r as DEFAULT_EMBED_MAX_MINUTES, t as DEFAULT_EMBED_CYCLE_MAX_MINUTES, u as recordEmbedPass } from "./embed-pass-CeQD8kRE.mjs";
30
- import { $ as setStartTime, A as indexSchedulerTimer, B as setDaemonConfig, Ct as runSessionKeepaliveTick, D as embedInProgress, Dt as deferIfQuiet, E as daemonConfig, F as lastVaultIndexTime, Ft as removeDaemonPidfile, G as setLastEmbedPass, Gt as restartRouter, H as setEmbedSchedulerTimer, I as notificationConfig, J as setLastIndexTime, K as setLastEmbedTime, L as passFailures, Lt as writeDaemonPidfile, M as lastEmbedTime, Mt as startQuietWatcher, N as lastIndexPass, O as embedSchedulerTimer, P as lastIndexTime, Q as setShutdownRequested, R as registryBackend, Rt as readContextHandoverCache, S as handleSessionSummary, T as cacheKeepaliveTimer, U as setIndexInProgress, V as setEmbedInProgress, W as setIndexSchedulerTimer, X as setNotificationConfig, Y as setLastVaultIndexTime, Z as setRegistryBackend, _ as markFailed, _t as buildWakeupContext, a as runPassChild, at as vaultIndexInProgress, b as findLatestJsonl, c as NonRetryableError, ct as addWorkToSessionNote, d as enqueue, dt as getCurrentNotePath, et as setStorageBackend, f as enqueueCoalesced, ft as archiveSessionFilesToSessionsDir, g as markCompleted, gt as vaultIndexEnabled, h as loadQueue, ht as obsidianEnabled, it as storageBackend, j as lastEmbedPass, jt as registerQuietRunner, k as indexInProgress, l as cleanup, lt as appendCheckpoint, m as hasPendingOrProcessingOfType, n as buildPassCommand, nt as shutdownRequested, o as backfillKgFromNotes, ot as sessionIdFromTranscript, p as getStats, pt as findNotesDir, q as setLastIndexPass, r as cliEntry, rt as startTime, st as updateTodoContinue, t as PassSpawnError, tt as setVaultIndexInProgress, u as dequeue, ut as finalizeSessionNote, w as spawnSummarizer, x as getGitContext, xt as sweepOrphans, y as contentToText$2, z as setCacheKeepaliveTimer, zt as writeContextHandoverCache } from "./indexer-backend-BM2CUSu8.mjs";
31
- import { r as saveQueryResult } from "./query-feedback-I-txSnld.mjs";
32
- import { n as formatAutoRouteJson, r as detectTopicShift, t as autoRoute } from "./auto-route-D5SXrMpB.mjs";
33
- import { a as zettelThemes, c as zettelExplore, i as zettelHealth, n as zettelGodNotes, o as zettelConverse, r as zettelSuggest, s as zettelSurprise, t as zettelCommunities } from "./zettelkasten-Cr_Xj0mG.mjs";
34
- import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, renameSync, statSync, unlinkSync, utimesSync, writeFileSync } from "node:fs";
2
+ import { t as writeFileAtomic } from "./atomic-file-BorMa4T3.mjs";
3
+ import { j as readWorkersSection, t as ANTHROPIC_NATIVE, wt as appendLedger } from "./config-XpZWOYOG.mjs";
4
+ import { f as readMainConfigRaw, i as defaults, p as writeMainConfigRaw, u as paiConfigFilePath, y as shippedMainDefaults } from "./config-Bu1_vbY8.mjs";
5
+ import { c as slotCurrentPath, i as ledgerPath, r as eventsPath, u as workersLogDir } from "./paths-CHifubDh.mjs";
6
+ import { f as gcWorktreesThrottled, w as worktreesDir } from "./worktree-CRs2gyg0.mjs";
7
+ import { B as loadStatusConfig, C as nowStamp, G as writeSectionToForge, I as PROJECT_CONFIG_REL, L as formatStale, b as loadStatusesCached, h as isChatPane, k as saveStatus, s as alive, v as loadStatus, z as listStale } from "./status-ggJ7lgVg.mjs";
8
+ import { a as unregistrableReason } from "./registrable-DpyTtajg.mjs";
9
+ import { c as yieldToEventLoop, f as fileContentHash, l as buildOutline, n as chunkId, u as chunkMarkdown } from "./helpers-CRuBUas3.mjs";
10
+ import { n as TITLE_STOP_WORDS, t as STOP_WORDS } from "./stop-words-DSEYQdNe.mjs";
11
+ import { i as populateSlugs, t as applyRecencyBoost } from "./search-RSyeQqj1.mjs";
12
+ import { n as rerankResults } from "./reranker-CqCbpGnX.mjs";
13
+ import { i as itermUuid, r as itermForClaudeSession } from "./scope-D-h6F6DN.mjs";
14
+ import { Sn as startLocalStatusRefresh, st as startInventoryRefresh } from "./routing-BAAST9vT.mjs";
15
+ import { n as minOf, t as maxOf } from "./min-max-DrSRUaWQ.mjs";
16
+ import { C as toolErrorSigTag, S as summarizeToolInput, T as toolErrorText, a as SAME_WORKER_WINDOW_MS, b as readToolErrors, c as classifyToolError, d as detectToolErrors, s as benignNote, u as detectRunningWorkerErrors, w as toolErrorSummary } from "./tool-errors-7E13StWd.mjs";
17
+ import { b as killProcessTree } from "./wait-ByV0OyMZ.mjs";
18
+ import { a as buildsDir, b as stallMinutes, c as listBuilds, l as listBuildsSync, u as patchTicket } from "./caller-identity-yLFb7CKq.mjs";
19
+ import { t as LOCAL_PROBE_TIMEOUT_MS } from "./timeouts-1MLooEBB.mjs";
20
+ import { d as getBackendOutage, n as createRegistryBackend, r as createStorageBackend } from "./factory-DjAAsqr_.mjs";
21
+ import { c as resolveFromModule, n as embedChunksWithBackend } from "./postgres-C6ti4haA.mjs";
22
+ import { a as requireQueryEmbedding, c as getConfiguredBackend, h as mismatchReason, m as bindingMatches, n as embedQuery } from "./embedding-gate-6rZrWRXa.mjs";
23
+ import { i as deserializeEmbedding, n as configureEmbeddingModel, r as cosineSimilarity$1 } from "./embeddings-BVq3esBF.mjs";
24
+ import { n as routeNotification } from "./router-CQSc3lk3.mjs";
25
+ import { r as formatDetectionJson, t as detectProject } from "./detect-9CZNO0yf.mjs";
26
+ import { i as performScan } from "./scan-C_Y5W9py.mjs";
27
+ import { r as sendToSession, t as callAiBroker } from "./aibroker-client-CQPGqLxL.mjs";
28
+ import { E as probeRouter, F as startHandover, M as routerSwapArgs, N as runRouterTick, O as routerIsStale, P as spawnRouter, j as routerRunningPid, l as runMessenger, t as runWorker } from "./run-CSC7mgPf.mjs";
29
+ import { a as localIdleTick, et as closeEndedPanes, g as sweepRuns, gt as workerEnded, pt as paneMayClose, st as loadRegistry, xt as truncateLines } from "./controls-CPoeudou.mjs";
30
+ import { l as isPaneRunId, n as auditTick, r as closeFinishedPanes } from "./pane-audit-DKQt71s4.mjs";
31
+ import { a as EMBED_PASS_BATCH_SIZE, c as liveYieldCheck, d as runEmbedCycle, i as DEFAULT_EMBED_RESUME_MINUTES, n as DEFAULT_EMBED_MAX_LOAD, r as DEFAULT_EMBED_MAX_MINUTES, t as DEFAULT_EMBED_CYCLE_MAX_MINUTES, u as recordEmbedPass } from "./embed-pass-DIWjA68P.mjs";
32
+ import { $ as setStartTime, A as indexSchedulerTimer, B as setDaemonConfig, Ct as runSessionKeepaliveTick, D as embedInProgress, Dt as deferIfQuiet, E as daemonConfig, F as lastVaultIndexTime, Ft as removeDaemonPidfile, G as setLastEmbedPass, Gt as restartRouter, H as setEmbedSchedulerTimer, I as notificationConfig, J as setLastIndexTime, K as setLastEmbedTime, L as passFailures, Lt as writeDaemonPidfile, M as lastEmbedTime, Mt as startQuietWatcher, N as lastIndexPass, O as embedSchedulerTimer, P as lastIndexTime, Q as setShutdownRequested, R as registryBackend, Rt as readContextHandoverCache, S as handleSessionSummary, T as cacheKeepaliveTimer, U as setIndexInProgress, V as setEmbedInProgress, W as setIndexSchedulerTimer, X as setNotificationConfig, Y as setLastVaultIndexTime, Z as setRegistryBackend, _ as markFailed, _t as buildWakeupContext, a as runPassChild, at as vaultIndexInProgress, b as findLatestJsonl, c as NonRetryableError, ct as addWorkToSessionNote, d as enqueue, dt as getCurrentNotePath, et as setStorageBackend, f as enqueueCoalesced, ft as archiveSessionFilesToSessionsDir, g as markCompleted, gt as vaultIndexEnabled, h as loadQueue, ht as obsidianEnabled, it as storageBackend, j as lastEmbedPass, jt as registerQuietRunner, k as indexInProgress, l as cleanup, lt as appendCheckpoint, m as hasPendingOrProcessingOfType, n as buildPassCommand, nt as shutdownRequested, o as backfillKgFromNotes, ot as sessionIdFromTranscript, p as getStats, pt as findNotesDir, q as setLastIndexPass, r as cliEntry, rt as startTime, st as updateTodoContinue, t as PassSpawnError, tt as setVaultIndexInProgress, u as dequeue, ut as finalizeSessionNote, w as spawnSummarizer, x as getGitContext, xt as sweepOrphans, y as contentToText$2, z as setCacheKeepaliveTimer, zt as writeContextHandoverCache } from "./indexer-backend-Cll7le4P.mjs";
33
+ import { r as saveQueryResult } from "./query-feedback-BRfPtqki.mjs";
34
+ import { n as formatAutoRouteJson, r as detectTopicShift, t as autoRoute } from "./auto-route-B7Yu6Uam.mjs";
35
+ import { a as zettelThemes, c as zettelExplore, i as zettelHealth, n as zettelGodNotes, o as zettelConverse, r as zettelSuggest, s as zettelSurprise, t as zettelCommunities } from "./zettelkasten-BzMm8REH.mjs";
36
+ import { appendFileSync, chmodSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, realpathSync, statSync, unlinkSync, utimesSync, writeFileSync } from "node:fs";
35
37
  import { basename, dirname, isAbsolute, join, normalize, relative, resolve, sep } from "node:path";
36
38
  import { setPriority } from "node:os";
37
39
  import { execFileSync, spawn, spawnSync } from "node:child_process";
@@ -89,12 +91,10 @@ function loadNotificationConfig() {
89
91
  * CONFIG_FILE. Creates the file if it does not exist.
90
92
  */
91
93
  function saveNotificationConfig(config) {
92
- let full = {};
93
- try {
94
- full = readMainConfigRaw();
95
- } catch {}
94
+ const configPath = paiConfigFilePath();
95
+ const full = readMainConfigRaw(configPath);
96
96
  full["notifications"] = config;
97
- writeMainConfigRaw(full);
97
+ writeMainConfigRaw(full, configPath);
98
98
  }
99
99
  /**
100
100
  * Apply a partial update to the current notification config and persist it.
@@ -734,12 +734,12 @@ async function checkLoops(logDir, statuses, sent, deps = {}) {
734
734
  throw err;
735
735
  }
736
736
  }, say = async (logDir, id, text) => {
737
- const { sayToWorker } = await import("./operator-CfL0HiBK.mjs");
737
+ const { sayToWorker } = await import("./operator-BTqvTIc8.mjs");
738
738
  return sayToWorker(logDir, id, text);
739
739
  }, kill = (pid) => {
740
740
  process.kill(pid, "SIGTERM");
741
741
  }, killChildren = async (logDir, id) => {
742
- const { killTree } = await import("./kill-tree-LV0Q7Mte.mjs");
742
+ const { killTree } = await import("./kill-tree-BG7dRVtp.mjs");
743
743
  return killTree(logDir, id, {
744
744
  skipRoot: true,
745
745
  by: "loop-guard",
@@ -1018,11 +1018,7 @@ function loadSupervisionState(path) {
1018
1018
  };
1019
1019
  }
1020
1020
  function saveSupervisionState(path, state) {
1021
- const dir = dirname(path);
1022
- if (!existsSync(dir)) mkdirSync(dir, { recursive: true });
1023
- const tmp = `${path}.tmp`;
1024
- writeFileSync(tmp, JSON.stringify(state), "utf8");
1025
- renameSync(tmp, path);
1021
+ writeFileAtomic(path, JSON.stringify(state));
1026
1022
  }
1027
1023
  /**
1028
1024
  * Drop the delivered ids of workers the ledger no longer lists (absent means
@@ -1952,6 +1948,10 @@ function commonPrefixLength(a, b) {
1952
1948
  */
1953
1949
  /** Number of files to process before yielding to the event loop. */
1954
1950
  const VAULT_YIELD_EVERY = 1;
1951
+ /** Prune refuses a stale set above this share of indexed files... */
1952
+ const VAULT_PRUNE_MAX_RATIO = .2;
1953
+ /** ...or above this absolute count. */
1954
+ const VAULT_PRUNE_MAX_FILES = 500;
1955
1955
  /**
1956
1956
  * Index an entire Obsidian vault (or markdown knowledge base) using the
1957
1957
  * async StorageBackend interface.
@@ -1977,8 +1977,9 @@ const VAULT_YIELD_EVERY = 1;
1977
1977
  * @param backend StorageBackend to write to.
1978
1978
  * @param vaultProjectId Registry project ID for the vault "project".
1979
1979
  * @param vaultRoot Absolute path to the vault root directory.
1980
+ * @param opts.forcePrune Prune even when the stale set exceeds the safety limits.
1980
1981
  */
1981
- async function indexVault(backend, vaultProjectId, vaultRoot) {
1982
+ async function indexVault(backend, vaultProjectId, vaultRoot, opts = {}) {
1982
1983
  const startTime = Date.now();
1983
1984
  const result = {
1984
1985
  filesIndexed: 0,
@@ -2049,6 +2050,17 @@ async function indexVault(backend, vaultProjectId, vaultRoot) {
2049
2050
  result.filesIndexed++;
2050
2051
  result.chunksCreated += chunks.length;
2051
2052
  }
2053
+ if (allFiles.length > 0 && existsSync(vaultRoot)) {
2054
+ await yieldToEventLoop();
2055
+ const livePaths = new Set(inodeGroups.map((g) => g.canonical.vaultRelPath));
2056
+ const dbPaths = await backend.getAllVaultFilePaths();
2057
+ const stalePaths = dbPaths.filter((p) => !livePaths.has(p));
2058
+ if (!opts.forcePrune && (stalePaths.length > dbPaths.length * VAULT_PRUNE_MAX_RATIO || stalePaths.length > VAULT_PRUNE_MAX_FILES)) console.warn(`[vault] prune skipped: ${stalePaths.length} of ${dbPaths.length} indexed files look stale (possible partial scan)`);
2059
+ else for (const stale of stalePaths) {
2060
+ await backend.deleteChunksForFile(vaultProjectId, stale);
2061
+ await backend.deleteVaultFile(stale);
2062
+ }
2063
+ }
2052
2064
  await yieldToEventLoop();
2053
2065
  const allAliases = [];
2054
2066
  for (const group of inodeGroups) for (const alias of group.aliases) {
@@ -2101,9 +2113,15 @@ async function indexVault(backend, vaultProjectId, vaultRoot) {
2101
2113
  }
2102
2114
  }
2103
2115
  const LINK_BATCH_SIZE = 500;
2116
+ const linksBySource = /* @__PURE__ */ new Map();
2117
+ for (const r of linkRows) {
2118
+ const list = linksBySource.get(r.sourcePath);
2119
+ if (list) list.push(r);
2120
+ else linksBySource.set(r.sourcePath, [r]);
2121
+ }
2104
2122
  for (let i = 0; i < allSourcePaths.length; i += LINK_BATCH_SIZE) {
2105
2123
  const batchSources = allSourcePaths.slice(i, i + LINK_BATCH_SIZE);
2106
- const batchLinks = linkRows.filter((r) => batchSources.includes(r.sourcePath));
2124
+ const batchLinks = batchSources.flatMap((src) => linksBySource.get(src) ?? []);
2107
2125
  await backend.replaceLinksForSources(batchSources, batchLinks);
2108
2126
  await yieldToEventLoop();
2109
2127
  }
@@ -3833,7 +3851,7 @@ function applyLinkBoost(results, edges, opts) {
3833
3851
  inbound.set(e.targetPath, (inbound.get(e.targetPath) ?? 0) + 1);
3834
3852
  }
3835
3853
  if (inbound.size === 0) return [...results];
3836
- const maxInbound = Math.max(...inbound.values());
3854
+ const maxInbound = maxOf(inbound.values());
3837
3855
  return results.map((r) => {
3838
3856
  const links = inbound.get(r.path) ?? 0;
3839
3857
  if (links === 0) return { ...r };
@@ -3969,12 +3987,15 @@ async function resolveProjectFile(registry, projectSlug, requestedPath) {
3969
3987
  if (projectId == null) return fail(`Project not found: ${projectSlug}`);
3970
3988
  const project = await registry.getProjectById(projectId);
3971
3989
  if (!project) return fail(`Project not found: ${projectSlug}`);
3972
- if (requestedPath.includes("..") || isAbsolute(requestedPath)) return fail(`Invalid path: ${requestedPath} (must be a relative path within the project root, no ../ allowed)`);
3990
+ if (requestedPath.split(/[\\/]/).includes("..") || isAbsolute(requestedPath)) return fail(`Invalid path: ${requestedPath} (must be a relative path within the project root, no ../ allowed)`);
3973
3991
  const fullPath = join(project.root_path, requestedPath);
3974
3992
  const resolvedFull = resolve(fullPath);
3975
3993
  const resolvedRoot = resolve(project.root_path);
3976
3994
  if (!resolvedFull.startsWith(resolvedRoot + "/") && resolvedFull !== resolvedRoot) return fail(`Path traversal blocked: ${requestedPath}`);
3977
3995
  if (!existsSync(fullPath)) return fail(`File not found: ${requestedPath} (project: ${projectSlug})`);
3996
+ const realFull = realpathSync(fullPath);
3997
+ const realRoot = realpathSync(project.root_path);
3998
+ if (realFull !== realRoot && !realFull.startsWith(realRoot + sep)) return fail(`Path traversal blocked: ${requestedPath}`);
3978
3999
  const stat = statSync(fullPath);
3979
4000
  if (stat.size > 5 * 1024 * 1024) return { content: [{
3980
4001
  type: "text",
@@ -3989,7 +4010,7 @@ async function toolMemoryGet(registry, params) {
3989
4010
  const { fullPath } = resolved;
3990
4011
  const requestedPath = params.path;
3991
4012
  const allLines = readFileSync(fullPath, "utf8").split("\n");
3992
- const fromLine = (params.from ?? 1) - 1;
4013
+ const fromLine = Math.max(1, params.from ?? 1) - 1;
3993
4014
  const toLine = params.lines != null ? Math.min(fromLine + params.lines, allLines.length) : allLines.length;
3994
4015
  const text = allLines.slice(fromLine, toLine).join("\n");
3995
4016
  return { content: [{
@@ -5779,8 +5800,8 @@ async function handleGraphTrace(backend, params) {
5779
5800
  entries,
5780
5801
  connections,
5781
5802
  time_span: {
5782
- from: timestamps.length > 0 ? Math.min(...timestamps) : 0,
5783
- to: timestamps.length > 0 ? Math.max(...timestamps) : 0
5803
+ from: timestamps.length > 0 ? minOf(timestamps) : 0,
5804
+ to: timestamps.length > 0 ? maxOf(timestamps) : 0
5784
5805
  }
5785
5806
  };
5786
5807
  }
@@ -5938,8 +5959,16 @@ function handleIdeaMaterialize(params, vaultPath) {
5938
5959
  const fileName = `${title.replace(/[/\\:*?"<>|]/g, "-")}.md`;
5939
5960
  const relFolder = folder.replace(/^\/+|\/+$/g, "");
5940
5961
  const vault_path = relFolder ? `${relFolder}/${fileName}` : fileName;
5941
- const absPath = join(vaultPath, vault_path);
5962
+ const absPath = resolve(vaultPath, vault_path);
5942
5963
  const absDir = dirname(absPath);
5964
+ const vaultReal = realpathSync(vaultPath);
5965
+ const lexRel = relative(resolve(vaultPath), absPath);
5966
+ if (lexRel === "" || lexRel.startsWith("..") || isAbsolute(lexRel)) throw new Error(`idea_materialize: folder "${folder}" escapes the vault`);
5967
+ let probe = absDir;
5968
+ while (!existsSync(probe)) probe = dirname(probe);
5969
+ const probeRel = relative(vaultReal, realpathSync(probe));
5970
+ if (probeRel === ".." || probeRel.startsWith(".." + sep) || isAbsolute(probeRel)) throw new Error(`idea_materialize: folder "${folder}" escapes the vault`);
5971
+ if (existsSync(absPath)) throw new Error(`idea_materialize: note already exists: ${vault_path}`);
5943
5972
  const wikilinks = source_paths.map((p) => {
5944
5973
  return `- [[${p.split("/").pop()?.replace(/\.md$/i, "") ?? p}]]`;
5945
5974
  }).join("\n");
@@ -5960,7 +5989,10 @@ function handleIdeaMaterialize(params, vaultPath) {
5960
5989
  ""
5961
5990
  ].join("\n");
5962
5991
  mkdirSync(absDir, { recursive: true });
5963
- writeFileSync(absPath, content, "utf-8");
5992
+ writeFileSync(absPath, content, {
5993
+ encoding: "utf-8",
5994
+ flag: "wx"
5995
+ });
5964
5996
  return {
5965
5997
  vault_path,
5966
5998
  content,
@@ -6671,6 +6703,8 @@ function isSocketLive(path) {
6671
6703
  });
6672
6704
  });
6673
6705
  }
6706
+ /** Longest accepted IPC request line; a client exceeding it is disconnected. */
6707
+ const MAX_IPC_LINE_BYTES = 4 * 1024 * 1024;
6674
6708
  /**
6675
6709
  * Start the Unix Domain Socket IPC server.
6676
6710
  */
@@ -6686,6 +6720,15 @@ async function startIpcServer(socketPath) {
6686
6720
  let buffer = "";
6687
6721
  socket.on("data", (chunk) => {
6688
6722
  buffer += chunk.toString();
6723
+ if (buffer.length > MAX_IPC_LINE_BYTES && buffer.indexOf("\n") === -1) {
6724
+ sendResponse(socket, {
6725
+ id: "?",
6726
+ ok: false,
6727
+ error: "Request line too long"
6728
+ });
6729
+ socket.destroy();
6730
+ return;
6731
+ }
6689
6732
  let nl;
6690
6733
  while ((nl = buffer.indexOf("\n")) !== -1) {
6691
6734
  const line = buffer.slice(0, nl);
@@ -6720,6 +6763,11 @@ async function startIpcServer(socketPath) {
6720
6763
  process.stderr.write(`[pai-daemon] IPC server error: ${e}\n`);
6721
6764
  });
6722
6765
  server.listen(socketPath, () => {
6766
+ try {
6767
+ chmodSync(socketPath, 384);
6768
+ } catch (e) {
6769
+ process.stderr.write(`[pai-daemon] Could not chmod socket: ${e}\n`);
6770
+ }
6723
6771
  process.stderr.write(`[pai-daemon] IPC server listening on ${socketPath}\n`);
6724
6772
  });
6725
6773
  return server;
@@ -6816,4 +6864,4 @@ async function serve(config) {
6816
6864
 
6817
6865
  //#endregion
6818
6866
  export { serve as t };
6819
- //# sourceMappingURL=daemon-CorGh6Ub.mjs.map
6867
+ //# sourceMappingURL=daemon-DPAo6WTa.mjs.map
@@ -1,43 +1,44 @@
1
1
  #!/usr/bin/env node
2
2
  import "../utils-J2b9y8PC.mjs";
3
3
  import { g as paiHomePath } from "../runtime-paths-WsO9sJFc.mjs";
4
- import { Tt as ledgerSummary, a as MODEL_CAPABILITIES, f as escalationCloud, j as readWorkersSection, m as isLocalProvider, n as CAPABILITY_NAME_RE, p as getProviderOrNative } from "../config-D5chi2LO.mjs";
5
- import { S as MainConfigError, c as loadConfig, n as CONFIG_FILE } from "../config-BSXKyeJ1.mjs";
6
- import { i as ledgerPath, u as workersLogDir } from "../paths-DoIyRnhx.mjs";
7
- import "../worktree-zmRf556h.mjs";
8
- import { A as setWorkerLabel, C as nowStamp, O as reconcileStatuses, g as isLive, o as ageOf, v as loadStatus, y as loadStatuses } from "../status-CvVi9cDf.mjs";
9
- import "../pool-CZ5MZaXg.mjs";
10
- import "../helpers-CJpb_MNB.mjs";
11
- import { t as dropItermBundleId } from "../env-DArqGq-Z.mjs";
12
- import "../scope-D5VSQxe4.mjs";
13
- import { Ht as sessionRoutesPatch, J as inventoryRows, W as currentInventory, _n as probeLoopback, cn as profilesPath, in as detectSessionName, jt as clearSessionRoute, pn as currentLocalStatus, sn as getProfile, un as updateProfile, z as INVENTORY_HEADERS } from "../routing-CUyiglfu.mjs";
14
- import "../tool-errors-AeRQuG3Y.mjs";
15
- import "../wait-BMUR-U-U.mjs";
16
- import "../local-tiers-DPZYqv9m.mjs";
17
- import { _ as poolSlots, f as renderBuildQueue, i as buildsDir, r as buildNext, s as listBuilds } from "../caller-identity-CVTuiLSs.mjs";
18
- import { a as localStatusReport } from "../local-candidate-jOjTNlOL.mjs";
19
- import { i as effectiveCap, l as reorderQueue, s as queueRows } from "../capacity-DaXrVj3J.mjs";
20
- import "../factory-BtjbQ0np.mjs";
21
- import "../postgres-CDnd_k5f.mjs";
22
- import "../embedding-gate-BHuBsgHD.mjs";
23
- import "../embeddings-D4t6L-EH.mjs";
24
- import "../router-L8Nu-OHF.mjs";
25
- import "../launch-DgqQdAjI.mjs";
26
- import { H as testProvider, a as resolveWorkers, c as reportOriginWithHost, f as dirtyPaths, i as liveResolveCtx, t as runWorker, u as startDetached } from "../run-ulAi5dFD.mjs";
27
- import { A as tail, B as loadPlanStatus, C as readRunLog, D as resumeState, E as requestPlanStop, F as runLogPath, G as planRunId, Gt as handoffFromInside, J as queueLockPath, L as fmtElapsed, M as dirtyConflicts, P as loadPlan, S as planStopPath, X as sinceText, Y as readRunLock, b as idleText, j as PlanError, q as planLockPath, qt as readInbox, w as renderSchedule, x as planStatus } from "../controls-BGkK_Bdi.mjs";
28
- import { a as endLabel } from "../endreason-x1KOSrcO.mjs";
29
- import { D as deadlineLabel } from "../render-BDbb4CF-.mjs";
30
- import { r as sayToWorker } from "../operator-DZxcP-g8.mjs";
31
- import "../kill-tree-BjYz5BxK.mjs";
32
- import "../pool-cli-BxNSPzzY.mjs";
33
- import { t as runChain } from "../chain-BcQlIlEd.mjs";
34
- import { C as schedulerLines, E as resolveSpecPath, S as withTarget, T as readSpecPrompt, _ as issueClaims, a as branchDiff, d as loadSettings, f as move, g as issueClaim, i as projectChecks, l as QueueStore, n as initProject, o as realQueueDeps, p as queueStatePath, r as isGitProject, s as acceptItems, t as formatCheck, u as again, v as issueStale, w as schedulerView, x as resolveTarget, y as providerCaps } from "../project-setup-DM4npnL3.mjs";
35
- import "../pane-audit-OGYrOAik.mjs";
36
- import { d as psOutput, f as replayOutput } from "../viewer-DtWj5Vti.mjs";
37
- import { _ as unsetCapabilityPreference, a as describeCapabilities, b as useProvider, c as modelPrefsText, d as setCapabilityPreference, f as setClass, g as setWorkersEnabled, h as setProviderModel, l as removeProvider, m as setProviderEnabled, o as describeModels, p as setProviderCap, r as classTargetText, s as describeProviders, t as addProvider, u as resolveProviderName, v as unsetClass, y as updateProvider } from "../providers-UsKtLcUR.mjs";
38
- import { a as listConfigOp, i as getConfigValueOp, o as setConfigValueOp, s as unsetConfigValueOp, t as MainConfigOpsError } from "../main-config-ops-C0SflOWk.mjs";
39
- import { n as PaiClient } from "../ipc-client-BMqWw_gv.mjs";
40
- import { i as fallbackStatusText, n as fallbackOn, r as fallbackStatus, t as fallbackOff } from "../fallback-BIyEpPsQ.mjs";
4
+ import { Tt as ledgerSummary, a as MODEL_CAPABILITIES, f as escalationCloud, j as readWorkersSection, m as isLocalProvider, n as CAPABILITY_NAME_RE, p as getProviderOrNative } from "../config-XpZWOYOG.mjs";
5
+ import { S as MainConfigError, c as loadConfig, n as CONFIG_FILE } from "../config-Bu1_vbY8.mjs";
6
+ import { i as ledgerPath, u as workersLogDir } from "../paths-CHifubDh.mjs";
7
+ import "../worktree-CRs2gyg0.mjs";
8
+ import { A as setWorkerLabel, C as nowStamp, O as reconcileStatuses, g as isLive, o as ageOf, v as loadStatus, y as loadStatuses } from "../status-ggJ7lgVg.mjs";
9
+ import "../pool-Dh-q3iJi.mjs";
10
+ import "../helpers-CRuBUas3.mjs";
11
+ import { t as dropItermBundleId } from "../env-BE8mrsxr.mjs";
12
+ import "../scope-D-h6F6DN.mjs";
13
+ import { J as inventoryRows, Mt as clearSessionRoute, Ut as sessionRoutesPatch, W as currentInventory, an as detectSessionName, cn as getProfile, dn as updateProfile, ln as profilesPath, mn as currentLocalStatus, vn as probeLoopback, z as INVENTORY_HEADERS } from "../routing-BAAST9vT.mjs";
14
+ import "../tool-errors-7E13StWd.mjs";
15
+ import "../wait-ByV0OyMZ.mjs";
16
+ import "../local-tiers-BE4jGaMa.mjs";
17
+ import { a as buildsDir, c as listBuilds, i as buildNext, p as renderBuildQueue, v as poolSlots } from "../caller-identity-yLFb7CKq.mjs";
18
+ import { i as effectiveCap, l as reorderQueue, s as queueRows } from "../capacity-DEveQdFV.mjs";
19
+ import "../local-instances-DOxSgT_L.mjs";
20
+ import { a as localStatusReport } from "../local-candidate-DLdwQt0s.mjs";
21
+ import "../factory-DjAAsqr_.mjs";
22
+ import "../postgres-C6ti4haA.mjs";
23
+ import "../embedding-gate-6rZrWRXa.mjs";
24
+ import "../embeddings-BVq3esBF.mjs";
25
+ import "../router-CQSc3lk3.mjs";
26
+ import "../launch-Jh5NVeNe.mjs";
27
+ import { H as testProvider, a as resolveWorkers, c as reportOriginWithHost, f as dirtyPaths, i as liveResolveCtx, t as runWorker, u as startDetached } from "../run-CSC7mgPf.mjs";
28
+ import { A as tail, B as loadPlanStatus, C as readRunLog, D as resumeState, E as requestPlanStop, F as runLogPath, G as planRunId, Gt as handoffFromInside, J as queueLockPath, L as fmtElapsed, M as dirtyConflicts, P as loadPlan, S as planStopPath, X as sinceText, Y as readRunLock, b as idleText, j as PlanError, q as planLockPath, qt as readInbox, w as renderSchedule, x as planStatus } from "../controls-CPoeudou.mjs";
29
+ import { a as endLabel } from "../endreason-C577xIQz.mjs";
30
+ import { D as deadlineLabel } from "../render-BYmQkuLd.mjs";
31
+ import { r as sayToWorker } from "../operator-CyuB3aVw.mjs";
32
+ import "../kill-tree-EWYaEk5v.mjs";
33
+ import "../pool-cli-BggU8GRp.mjs";
34
+ import { t as runChain } from "../chain-7n9Gx56r.mjs";
35
+ import { C as schedulerLines, E as resolveSpecPath, S as withTarget, T as readSpecPrompt, _ as issueClaims, a as branchDiff, d as loadSettings, f as move, g as issueClaim, i as projectChecks, l as QueueStore, n as initProject, o as realQueueDeps, p as queueStatePath, r as isGitProject, s as acceptItems, t as formatCheck, u as again, v as issueStale, w as schedulerView, x as resolveTarget, y as providerCaps } from "../project-setup-jvfONJTQ.mjs";
36
+ import "../pane-audit-DKQt71s4.mjs";
37
+ import { d as psOutput, f as replayOutput } from "../viewer-mDXUNHNy.mjs";
38
+ import { _ as unsetCapabilityPreference, a as describeCapabilities, b as useProvider, c as modelPrefsText, d as setCapabilityPreference, f as setClass, g as setWorkersEnabled, h as setProviderModel, l as removeProvider, m as setProviderEnabled, o as describeModels, p as setProviderCap, r as classTargetText, s as describeProviders, t as addProvider, u as resolveProviderName, v as unsetClass, y as updateProvider } from "../providers-CblTFrhz.mjs";
39
+ import { a as listConfigOp, i as getConfigValueOp, o as setConfigValueOp, s as unsetConfigValueOp, t as MainConfigOpsError } from "../main-config-ops-BEMpuhDz.mjs";
40
+ import { n as PaiClient } from "../ipc-client-CaiGJnSM.mjs";
41
+ import { i as fallbackStatusText, n as fallbackOn, r as fallbackStatus, t as fallbackOff } from "../fallback-DFlItw1Z.mjs";
41
42
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
42
43
  import { basename, dirname, join, resolve } from "node:path";
43
44
  import { stringify } from "yaml";
@@ -6309,7 +6310,7 @@ function workerModel(args, configPath) {
6309
6310
  * into the session's own terminal through AIBroker.
6310
6311
  */
6311
6312
  async function realSessionProfileDeps() {
6312
- const { sendToSession } = await import("../aibroker-client-JjE74jo0.mjs");
6313
+ const { sendToSession } = await import("../aibroker-client-BxzeEHPF.mjs");
6313
6314
  return {
6314
6315
  path: profilesPath(),
6315
6316
  env: process.env,
@@ -6581,7 +6582,7 @@ function realDelegationDeps() {
6581
6582
  return {
6582
6583
  async resolveProject(project) {
6583
6584
  if (existsSync(project)) return resolve(project);
6584
- const { getProject } = await import("../helpers-DPJEHPq6.mjs");
6585
+ const { getProject } = await import("../helpers-CMGjy_0N.mjs");
6585
6586
  const row = await getProject(project);
6586
6587
  if (!row) throw new Error(`no project "${project}" is registered`);
6587
6588
  return row.root_path;
@@ -43,4 +43,4 @@ const OPT = {
43
43
 
44
44
  //#endregion
45
45
  export { OPT as n, CliError as t };
46
- //# sourceMappingURL=define-DGFu-sCf.mjs.map
46
+ //# sourceMappingURL=define-CjJsmq-6.mjs.map
@@ -1,4 +1,4 @@
1
- import { i as getRegistryBackend } from "./factory-BtjbQ0np.mjs";
1
+ import { i as getRegistryBackend } from "./factory-DjAAsqr_.mjs";
2
2
  import { resolve } from "node:path";
3
3
 
4
4
  //#region src/cli/impl/detect.ts
@@ -92,4 +92,4 @@ function formatDetectionJson(d) {
92
92
 
93
93
  //#endregion
94
94
  export { formatDetection as n, formatDetectionJson as r, detectProject as t };
95
- //# sourceMappingURL=detect-C1d5cUkT.mjs.map
95
+ //# sourceMappingURL=detect-9CZNO0yf.mjs.map
@@ -0,0 +1,10 @@
1
+ import "./config-Bu1_vbY8.mjs";
2
+ import "./helpers-CRuBUas3.mjs";
3
+ import "./factory-DjAAsqr_.mjs";
4
+ import "./postgres-C6ti4haA.mjs";
5
+ import "./embedding-gate-6rZrWRXa.mjs";
6
+ import "./embeddings-BVq3esBF.mjs";
7
+ import "./router-CQSc3lk3.mjs";
8
+ import { n as formatDetection, r as formatDetectionJson, t as detectProject } from "./detect-9CZNO0yf.mjs";
9
+
10
+ export { detectProject };
@@ -1,8 +1,8 @@
1
1
  import { g as paiHomePath } from "./runtime-paths-WsO9sJFc.mjs";
2
- import { j as readWorkersSection, m as isLocalProvider } from "./config-D5chi2LO.mjs";
3
- import { u as workersLogDir } from "./paths-DoIyRnhx.mjs";
4
- import { g as isLive, y as loadStatuses } from "./status-CvVi9cDf.mjs";
5
- import { ir as writeFileAtomic } from "./routing-CUyiglfu.mjs";
2
+ import { t as writeFileAtomic } from "./atomic-file-BorMa4T3.mjs";
3
+ import { j as readWorkersSection, m as isLocalProvider } from "./config-XpZWOYOG.mjs";
4
+ import { u as workersLogDir } from "./paths-CHifubDh.mjs";
5
+ import { g as isLive, y as loadStatuses } from "./status-ggJ7lgVg.mjs";
6
6
  import { readFileSync } from "node:fs";
7
7
  import { loadavg } from "node:os";
8
8
 
@@ -161,4 +161,4 @@ async function runEmbedCycle(d) {
161
161
 
162
162
  //#endregion
163
163
  export { EMBED_PASS_BATCH_SIZE as a, liveYieldCheck as c, runEmbedCycle as d, DEFAULT_EMBED_RESUME_MINUTES as i, readEmbedPasses as l, DEFAULT_EMBED_MAX_LOAD as n, formatEmbedStatus as o, DEFAULT_EMBED_MAX_MINUTES as r, lastRecordedEmbedPass as s, DEFAULT_EMBED_CYCLE_MAX_MINUTES as t, recordEmbedPass as u };
164
- //# sourceMappingURL=embed-pass-CeQD8kRE.mjs.map
164
+ //# sourceMappingURL=embed-pass-DIWjA68P.mjs.map
@@ -1,11 +1,11 @@
1
1
  import { g as paiHomePath } from "./runtime-paths-WsO9sJFc.mjs";
2
- import { c as loadConfig, i as defaults } from "./config-BSXKyeJ1.mjs";
3
- import { t as LOCAL_PROBE_TIMEOUT_MS } from "./timeouts-OwEONmc8.mjs";
4
- import { n as configureEmbeddingModel, o as generateEmbeddings, t as EMBEDDING_DIM } from "./embeddings-D4t6L-EH.mjs";
2
+ import { c as loadConfig, i as defaults } from "./config-Bu1_vbY8.mjs";
3
+ import { t as LOCAL_PROBE_TIMEOUT_MS } from "./timeouts-1MLooEBB.mjs";
4
+ import { n as configureEmbeddingModel, o as generateEmbeddings, t as EMBEDDING_DIM } from "./embeddings-BVq3esBF.mjs";
5
5
  import { createReadStream, createWriteStream, existsSync, mkdirSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
6
+ import { createHash } from "node:crypto";
6
7
  import { join } from "node:path";
7
8
  import { execFileSync } from "node:child_process";
8
- import { createHash } from "node:crypto";
9
9
  import { Readable } from "node:stream";
10
10
  import { pipeline } from "node:stream/promises";
11
11
 
@@ -420,4 +420,4 @@ async function measureThroughput(backend, texts) {
420
420
 
421
421
  //#endregion
422
422
  export { requireQueryEmbedding as a, getConfiguredBackend as c, OLLAMA_ID as d, ollamaDefaultUrl as f, mismatchReason as h, measureThroughput as i, provisionOllama as l, bindingMatches as m, embedQuery as n, createBackend as o, LEGACY_EMBEDDING_BINDING as p, gateBackend as r, detectBackends as s, QUERY_PREFIX as t, OLLAMA_DEFAULT_MODEL as u };
423
- //# sourceMappingURL=embedding-gate-BHuBsgHD.mjs.map
423
+ //# sourceMappingURL=embedding-gate-6rZrWRXa.mjs.map
@@ -1,5 +1,5 @@
1
- import "./config-BSXKyeJ1.mjs";
2
- import { a as requireQueryEmbedding, i as measureThroughput, n as embedQuery, r as gateBackend, t as QUERY_PREFIX } from "./embedding-gate-BHuBsgHD.mjs";
3
- import "./embeddings-D4t6L-EH.mjs";
1
+ import "./config-Bu1_vbY8.mjs";
2
+ import { a as requireQueryEmbedding, i as measureThroughput, n as embedQuery, r as gateBackend, t as QUERY_PREFIX } from "./embedding-gate-6rZrWRXa.mjs";
3
+ import "./embeddings-BVq3esBF.mjs";
4
4
 
5
5
  export { embedQuery, gateBackend };
@@ -129,4 +129,4 @@ function cosineSimilarity(a, b) {
129
129
 
130
130
  //#endregion
131
131
  export { generateEmbedding as a, deserializeEmbedding as i, configureEmbeddingModel as n, generateEmbeddings as o, cosineSimilarity as r, serializeEmbedding as s, EMBEDDING_DIM as t };
132
- //# sourceMappingURL=embeddings-D4t6L-EH.mjs.map
132
+ //# sourceMappingURL=embeddings-BVq3esBF.mjs.map
@@ -1,3 +1,3 @@
1
- import { a as generateEmbedding, i as deserializeEmbedding, n as configureEmbeddingModel, o as generateEmbeddings, r as cosineSimilarity, s as serializeEmbedding, t as EMBEDDING_DIM } from "./embeddings-D4t6L-EH.mjs";
1
+ import { a as generateEmbedding, i as deserializeEmbedding, n as configureEmbeddingModel, o as generateEmbeddings, r as cosineSimilarity, s as serializeEmbedding, t as EMBEDDING_DIM } from "./embeddings-BVq3esBF.mjs";
2
2
 
3
3
  export { serializeEmbedding };
@@ -1,7 +1,8 @@
1
- import { wt as appendLedger } from "./config-D5chi2LO.mjs";
2
- import { r as eventsPath } from "./paths-DoIyRnhx.mjs";
3
- import { D as pidAlive } from "./status-CvVi9cDf.mjs";
4
- import { appendFileSync, existsSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
1
+ import { t as writeFileAtomic } from "./atomic-file-BorMa4T3.mjs";
2
+ import { wt as appendLedger } from "./config-XpZWOYOG.mjs";
3
+ import { r as eventsPath } from "./paths-CHifubDh.mjs";
4
+ import { D as pidAlive } from "./status-ggJ7lgVg.mjs";
5
+ import { appendFileSync, existsSync, readFileSync, unlinkSync } from "node:fs";
5
6
  import { join } from "node:path";
6
7
  import { execFileSync } from "node:child_process";
7
8
 
@@ -31,7 +32,7 @@ function requestKill(logDir, ledger, id, by = callerDescription(), forced = fals
31
32
  ...forced ? { forced } : {},
32
33
  ...reason ? { reason } : {}
33
34
  };
34
- writeFileSync(killMarkerPath(logDir, id), JSON.stringify(req));
35
+ writeFileAtomic(killMarkerPath(logDir, id), JSON.stringify(req));
35
36
  appendLedger(ledger, "WORKER-KILL", {
36
37
  id,
37
38
  by,
@@ -136,4 +137,4 @@ function appendStopEvent(logDir, id, stop) {
136
137
 
137
138
  //#endregion
138
139
  export { endLabel as a, endFields as i, callerDescription as n, parentInfo as o, decideEndReason as r, requestKill as s, appendStopEvent as t };
139
- //# sourceMappingURL=endreason-x1KOSrcO.mjs.map
140
+ //# sourceMappingURL=endreason-C577xIQz.mjs.map
@@ -11,4 +11,4 @@ function dropItermBundleId(env = process.env, platform = process.platform) {
11
11
 
12
12
  //#endregion
13
13
  export { dropItermBundleId as t };
14
- //# sourceMappingURL=env-DArqGq-Z.mjs.map
14
+ //# sourceMappingURL=env-BE8mrsxr.mjs.map
@@ -0,0 +1,9 @@
1
+ import "./config-Bu1_vbY8.mjs";
2
+ import "./helpers-CRuBUas3.mjs";
3
+ import { a as getStorageBackend, i as getRegistryBackend, n as createRegistryBackend, r as createStorageBackend, t as closeStorage } from "./factory-DjAAsqr_.mjs";
4
+ import "./postgres-C6ti4haA.mjs";
5
+ import "./embedding-gate-6rZrWRXa.mjs";
6
+ import "./embeddings-BVq3esBF.mjs";
7
+ import "./router-CQSc3lk3.mjs";
8
+
9
+ export { createStorageBackend, getRegistryBackend };