@goondocks/myco 0.17.1 → 0.18.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 (208) hide show
  1. package/README.md +15 -23
  2. package/bin/myco-run +15 -2
  3. package/dist/{agent-run-BGW4TY3D.js → agent-run-2NFYMQXW.js} +7 -7
  4. package/dist/{agent-tasks-XUJ6FTPL.js → agent-tasks-MEIYLXGN.js} +7 -7
  5. package/dist/{chunk-FEX6ALLH.js → chunk-2V7HR7HB.js} +29 -3
  6. package/dist/chunk-2V7HR7HB.js.map +1 -0
  7. package/dist/{chunk-XQHL4GMO.js → chunk-55QEICRO.js} +14 -4
  8. package/dist/chunk-55QEICRO.js.map +1 -0
  9. package/dist/chunk-5NFJTZ64.js +14 -0
  10. package/dist/chunk-5NFJTZ64.js.map +1 -0
  11. package/dist/{chunk-CPL76CYD.js → chunk-75AZFBFW.js} +3 -3
  12. package/dist/{chunk-UDBCAFXS.js → chunk-7OYXB2NM.js} +2 -2
  13. package/dist/{chunk-N6JNOSBQ.js → chunk-BUIR3JWM.js} +3 -3
  14. package/dist/{chunk-6SDC6V3N.js → chunk-CKJAWZQE.js} +5 -5
  15. package/dist/chunk-CKJAWZQE.js.map +1 -0
  16. package/dist/{chunk-DKSQMH5X.js → chunk-CML4MCYF.js} +2 -2
  17. package/dist/{chunk-KOTFMGL5.js → chunk-DLFDBKEV.js} +4 -4
  18. package/dist/{chunk-LA7NDX3J.js → chunk-EO2RQW4S.js} +2 -2
  19. package/dist/{chunk-EBIYONNZ.js → chunk-FABWUX5G.js} +20 -2
  20. package/dist/chunk-FABWUX5G.js.map +1 -0
  21. package/dist/{chunk-SODRR3HE.js → chunk-GFR542SM.js} +1 -1
  22. package/dist/chunk-GFR542SM.js.map +1 -0
  23. package/dist/{chunk-YTOD6L6N.js → chunk-JDI4DPWD.js} +210 -118
  24. package/dist/chunk-JDI4DPWD.js.map +1 -0
  25. package/dist/chunk-JMOUFG6Y.js +65 -0
  26. package/dist/chunk-JMOUFG6Y.js.map +1 -0
  27. package/dist/{chunk-QQ7CXA7Q.js → chunk-KWTOCJLB.js} +95 -10
  28. package/dist/{chunk-QQ7CXA7Q.js.map → chunk-KWTOCJLB.js.map} +1 -1
  29. package/dist/{chunk-VQQ57UPG.js → chunk-NI23QCHB.js} +4 -4
  30. package/dist/{chunk-VQQ57UPG.js.map → chunk-NI23QCHB.js.map} +1 -1
  31. package/dist/{chunk-GBYLHPML.js → chunk-NZI7WBZI.js} +2 -2
  32. package/dist/{chunk-KKEMVH6D.js → chunk-O3TRN3RC.js} +2 -2
  33. package/dist/{chunk-OGNEW5CN.js → chunk-OW433Q4C.js} +2 -2
  34. package/dist/{chunk-2WRXLYG6.js → chunk-PFWIPRF6.js} +39 -5
  35. package/dist/chunk-PFWIPRF6.js.map +1 -0
  36. package/dist/{chunk-ZUSTCXHT.js → chunk-RAV5YMRU.js} +3 -3
  37. package/dist/{chunk-2IJ6C63F.js → chunk-U3J2DDSR.js} +2 -2
  38. package/dist/{chunk-VGVRBSLC.js → chunk-U7GJTVSX.js} +2 -2
  39. package/dist/{chunk-KQOII5RU.js → chunk-VOCGURV7.js} +3 -3
  40. package/dist/{chunk-VVGZL2HX.js → chunk-WYOE4IAX.js} +153 -15
  41. package/dist/{chunk-VVGZL2HX.js.map → chunk-WYOE4IAX.js.map} +1 -1
  42. package/dist/{cli-353VNZIY.js → cli-IIMBALPV.js} +40 -40
  43. package/dist/{client-7KJ453V4.js → client-VZCUISHZ.js} +4 -4
  44. package/dist/{config-K3CJEFFO.js → config-DA4IUVFL.js} +4 -4
  45. package/dist/{detect-NJ2OREDP.js → detect-GEM3NVK6.js} +2 -2
  46. package/dist/{detect-providers-OE6HWW3M.js → detect-providers-PSVKXTWE.js} +4 -4
  47. package/dist/{doctor-RYFP7ABA.js → doctor-QYD34X7Q.js} +13 -13
  48. package/dist/doctor-QYD34X7Q.js.map +1 -0
  49. package/dist/{executor-YOKYS7OT.js → executor-NSPRTH4M.js} +29 -110
  50. package/dist/executor-NSPRTH4M.js.map +1 -0
  51. package/dist/{init-XR2JZWY2.js → init-WYYL44KZ.js} +56 -74
  52. package/dist/init-WYYL44KZ.js.map +1 -0
  53. package/dist/{installer-45ZLP2RP.js → installer-BWJED3ED.js} +2 -2
  54. package/dist/{llm-PGETQHZ2.js → llm-KEDHK3TQ.js} +4 -7
  55. package/dist/{loader-AVWL7PNO.js → loader-Q3P3R4UP.js} +3 -3
  56. package/dist/{loader-J56KP27U.js → loader-SKKUMT5C.js} +3 -3
  57. package/dist/{main-6DGPZXRF.js → main-6PY3ITQ5.js} +449 -156
  58. package/dist/main-6PY3ITQ5.js.map +1 -0
  59. package/dist/{open-P7YEH7UJ.js → open-HRFMJDQX.js} +11 -10
  60. package/dist/open-HRFMJDQX.js.map +1 -0
  61. package/dist/open-browser-EBKBAYSM.js +9 -0
  62. package/dist/{post-compact-WPS4SONO.js → post-compact-HT24YMAN.js} +7 -7
  63. package/dist/{post-tool-use-5WLLRGZ5.js → post-tool-use-DENRI5WB.js} +6 -6
  64. package/dist/{post-tool-use-failure-6C6HSBHI.js → post-tool-use-failure-A6SNJX42.js} +7 -7
  65. package/dist/{pre-compact-Z4E4JLAK.js → pre-compact-3Q4BALCL.js} +7 -7
  66. package/dist/{provider-check-CESRPIY5.js → provider-check-AE3L5Z6R.js} +4 -4
  67. package/dist/{registry-SPKP2WLI.js → registry-O2NZLO3V.js} +4 -4
  68. package/dist/{remove-B2PFVQXK.js → remove-YB5A6HY2.js} +9 -9
  69. package/dist/{resolution-events-CLDXZF67.js → resolution-events-XWYLLDRK.js} +4 -4
  70. package/dist/{restart-XAJDOL3E.js → restart-RGDVHELZ.js} +8 -8
  71. package/dist/{search-ERTCTAQ3.js → search-WOHT3G55.js} +8 -8
  72. package/dist/{server-LXUA7XUQ.js → server-6SUNYDV7.js} +4 -4
  73. package/dist/{session-433T6V3C.js → session-W3SKRFRV.js} +9 -9
  74. package/dist/{session-end-4Y5VY4OI.js → session-end-OUTY7AFF.js} +6 -6
  75. package/dist/{session-start-3STH4HFL.js → session-start-5MB3LFOA.js} +24 -13
  76. package/dist/{session-start-3STH4HFL.js.map → session-start-5MB3LFOA.js.map} +1 -1
  77. package/dist/{setup-llm-UBBSQWX5.js → setup-llm-ZMYGIQX5.js} +9 -9
  78. package/dist/src/cli.js +1 -1
  79. package/dist/src/daemon/main.js +1 -1
  80. package/dist/src/hooks/post-tool-use.js +1 -1
  81. package/dist/src/hooks/session-end.js +1 -1
  82. package/dist/src/hooks/session-start.js +1 -1
  83. package/dist/src/hooks/stop.js +1 -1
  84. package/dist/src/hooks/user-prompt-submit.js +1 -1
  85. package/dist/src/mcp/server.js +1 -1
  86. package/dist/src/symbionts/manifests/codex.yaml +47 -0
  87. package/dist/src/symbionts/templates/claude-code/hooks.json +12 -12
  88. package/dist/src/symbionts/templates/claude-code/settings.json +3 -3
  89. package/dist/src/symbionts/templates/codex/hooks.json +4 -4
  90. package/dist/src/symbionts/templates/cursor/hooks.json +9 -9
  91. package/dist/src/symbionts/templates/cursor/settings.json +2 -2
  92. package/dist/src/symbionts/templates/gemini/hooks.json +6 -6
  93. package/dist/src/symbionts/templates/gemini/settings.json +2 -2
  94. package/dist/src/symbionts/templates/myco-run.cjs +44 -0
  95. package/dist/src/symbionts/templates/opencode/settings.json +2 -2
  96. package/dist/src/symbionts/templates/vscode-copilot/hooks.json +7 -7
  97. package/dist/src/symbionts/templates/vscode-copilot/settings.json +2 -2
  98. package/dist/src/symbionts/templates/windsurf/hooks.json +4 -4
  99. package/dist/src/symbionts/templates/windsurf/settings.json +2 -2
  100. package/dist/src/worker/package-lock.json +4338 -0
  101. package/dist/src/worker/package.json +5 -0
  102. package/dist/src/worker/src/index.ts +50 -63
  103. package/dist/src/worker/src/mcp/auth.ts +65 -0
  104. package/dist/src/worker/src/mcp/server.ts +53 -0
  105. package/dist/src/worker/src/mcp/tools/context.ts +13 -0
  106. package/dist/src/worker/src/mcp/tools/get.ts +15 -0
  107. package/dist/src/worker/src/mcp/tools/graph.ts +35 -0
  108. package/dist/src/worker/src/mcp/tools/search.ts +32 -0
  109. package/dist/src/worker/src/mcp/tools/sessions.ts +24 -0
  110. package/dist/src/worker/src/mcp/tools/skills.ts +16 -0
  111. package/dist/src/worker/src/mcp/tools/team.ts +9 -0
  112. package/dist/src/worker/src/schema.ts +3 -1
  113. package/dist/src/worker/src/search-helpers.ts +70 -0
  114. package/dist/src/worker/wrangler.toml +9 -0
  115. package/dist/{stats-3NW7PGQK.js → stats-DGI6B3HX.js} +9 -9
  116. package/dist/{stop-L7BLMHUD.js → stop-YGHODSP7.js} +6 -6
  117. package/dist/{stop-failure-P5MYHGAZ.js → stop-failure-7IJTPJ6W.js} +7 -7
  118. package/dist/{subagent-start-AIEFG4HA.js → subagent-start-ZBQ5PJB5.js} +7 -7
  119. package/dist/{subagent-stop-TZ62BSNI.js → subagent-stop-N2TDQU2D.js} +7 -7
  120. package/dist/{task-completed-ZKVCUBCP.js → task-completed-BDLMRSBB.js} +7 -7
  121. package/dist/{team-WHZW6IFU.js → team-2ZFGTSIN.js} +97 -14
  122. package/dist/team-2ZFGTSIN.js.map +1 -0
  123. package/dist/ui/assets/index-CRmkSi63.css +1 -0
  124. package/dist/ui/assets/index-DtT9_nlT.js +842 -0
  125. package/dist/ui/index.html +2 -2
  126. package/dist/{update-P7GIQLIV.js → update-STLAN7LR.js} +18 -9
  127. package/dist/update-STLAN7LR.js.map +1 -0
  128. package/dist/{user-prompt-submit-4J7ZW6X3.js → user-prompt-submit-4IBFUYQ3.js} +27 -7
  129. package/dist/user-prompt-submit-4IBFUYQ3.js.map +1 -0
  130. package/dist/{verify-PSERIZPF.js → verify-EJYPO7QA.js} +5 -8
  131. package/dist/{verify-PSERIZPF.js.map → verify-EJYPO7QA.js.map} +1 -1
  132. package/dist/{version-OHJ5ZLHX.js → version-YPBIKH77.js} +2 -2
  133. package/package.json +6 -2
  134. package/dist/chunk-2WRXLYG6.js.map +0 -1
  135. package/dist/chunk-6SDC6V3N.js.map +0 -1
  136. package/dist/chunk-EBIYONNZ.js.map +0 -1
  137. package/dist/chunk-FEX6ALLH.js.map +0 -1
  138. package/dist/chunk-KGL5QSDN.js +0 -66
  139. package/dist/chunk-KGL5QSDN.js.map +0 -1
  140. package/dist/chunk-SODRR3HE.js.map +0 -1
  141. package/dist/chunk-U3SSOSIR.js +0 -26
  142. package/dist/chunk-U3SSOSIR.js.map +0 -1
  143. package/dist/chunk-XQHL4GMO.js.map +0 -1
  144. package/dist/chunk-Y7QCKCEJ.js +0 -26
  145. package/dist/chunk-Y7QCKCEJ.js.map +0 -1
  146. package/dist/chunk-YTOD6L6N.js.map +0 -1
  147. package/dist/doctor-RYFP7ABA.js.map +0 -1
  148. package/dist/executor-YOKYS7OT.js.map +0 -1
  149. package/dist/init-XR2JZWY2.js.map +0 -1
  150. package/dist/init-wizard-5CH2FD76.js +0 -294
  151. package/dist/init-wizard-5CH2FD76.js.map +0 -1
  152. package/dist/main-6DGPZXRF.js.map +0 -1
  153. package/dist/open-P7YEH7UJ.js.map +0 -1
  154. package/dist/openai-embeddings-LZKY6RV5.js +0 -14
  155. package/dist/openrouter-UTOZG6Z5.js +0 -14
  156. package/dist/src/symbionts/templates/hook-guard.cjs +0 -19
  157. package/dist/team-WHZW6IFU.js.map +0 -1
  158. package/dist/ui/assets/index-2UyTdjlV.js +0 -842
  159. package/dist/ui/assets/index-Cts1wLEW.css +0 -1
  160. package/dist/update-P7GIQLIV.js.map +0 -1
  161. package/dist/user-prompt-submit-4J7ZW6X3.js.map +0 -1
  162. package/dist/version-OHJ5ZLHX.js.map +0 -1
  163. /package/dist/{agent-run-BGW4TY3D.js.map → agent-run-2NFYMQXW.js.map} +0 -0
  164. /package/dist/{agent-tasks-XUJ6FTPL.js.map → agent-tasks-MEIYLXGN.js.map} +0 -0
  165. /package/dist/{chunk-CPL76CYD.js.map → chunk-75AZFBFW.js.map} +0 -0
  166. /package/dist/{chunk-UDBCAFXS.js.map → chunk-7OYXB2NM.js.map} +0 -0
  167. /package/dist/{chunk-N6JNOSBQ.js.map → chunk-BUIR3JWM.js.map} +0 -0
  168. /package/dist/{chunk-DKSQMH5X.js.map → chunk-CML4MCYF.js.map} +0 -0
  169. /package/dist/{chunk-KOTFMGL5.js.map → chunk-DLFDBKEV.js.map} +0 -0
  170. /package/dist/{chunk-LA7NDX3J.js.map → chunk-EO2RQW4S.js.map} +0 -0
  171. /package/dist/{chunk-GBYLHPML.js.map → chunk-NZI7WBZI.js.map} +0 -0
  172. /package/dist/{chunk-KKEMVH6D.js.map → chunk-O3TRN3RC.js.map} +0 -0
  173. /package/dist/{chunk-OGNEW5CN.js.map → chunk-OW433Q4C.js.map} +0 -0
  174. /package/dist/{chunk-ZUSTCXHT.js.map → chunk-RAV5YMRU.js.map} +0 -0
  175. /package/dist/{chunk-2IJ6C63F.js.map → chunk-U3J2DDSR.js.map} +0 -0
  176. /package/dist/{chunk-VGVRBSLC.js.map → chunk-U7GJTVSX.js.map} +0 -0
  177. /package/dist/{chunk-KQOII5RU.js.map → chunk-VOCGURV7.js.map} +0 -0
  178. /package/dist/{cli-353VNZIY.js.map → cli-IIMBALPV.js.map} +0 -0
  179. /package/dist/{client-7KJ453V4.js.map → client-VZCUISHZ.js.map} +0 -0
  180. /package/dist/{config-K3CJEFFO.js.map → config-DA4IUVFL.js.map} +0 -0
  181. /package/dist/{detect-NJ2OREDP.js.map → detect-GEM3NVK6.js.map} +0 -0
  182. /package/dist/{detect-providers-OE6HWW3M.js.map → detect-providers-PSVKXTWE.js.map} +0 -0
  183. /package/dist/{installer-45ZLP2RP.js.map → installer-BWJED3ED.js.map} +0 -0
  184. /package/dist/{llm-PGETQHZ2.js.map → llm-KEDHK3TQ.js.map} +0 -0
  185. /package/dist/{loader-AVWL7PNO.js.map → loader-Q3P3R4UP.js.map} +0 -0
  186. /package/dist/{loader-J56KP27U.js.map → loader-SKKUMT5C.js.map} +0 -0
  187. /package/dist/{openai-embeddings-LZKY6RV5.js.map → open-browser-EBKBAYSM.js.map} +0 -0
  188. /package/dist/{post-compact-WPS4SONO.js.map → post-compact-HT24YMAN.js.map} +0 -0
  189. /package/dist/{post-tool-use-5WLLRGZ5.js.map → post-tool-use-DENRI5WB.js.map} +0 -0
  190. /package/dist/{post-tool-use-failure-6C6HSBHI.js.map → post-tool-use-failure-A6SNJX42.js.map} +0 -0
  191. /package/dist/{pre-compact-Z4E4JLAK.js.map → pre-compact-3Q4BALCL.js.map} +0 -0
  192. /package/dist/{openrouter-UTOZG6Z5.js.map → provider-check-AE3L5Z6R.js.map} +0 -0
  193. /package/dist/{provider-check-CESRPIY5.js.map → registry-O2NZLO3V.js.map} +0 -0
  194. /package/dist/{remove-B2PFVQXK.js.map → remove-YB5A6HY2.js.map} +0 -0
  195. /package/dist/{registry-SPKP2WLI.js.map → resolution-events-XWYLLDRK.js.map} +0 -0
  196. /package/dist/{restart-XAJDOL3E.js.map → restart-RGDVHELZ.js.map} +0 -0
  197. /package/dist/{search-ERTCTAQ3.js.map → search-WOHT3G55.js.map} +0 -0
  198. /package/dist/{server-LXUA7XUQ.js.map → server-6SUNYDV7.js.map} +0 -0
  199. /package/dist/{session-433T6V3C.js.map → session-W3SKRFRV.js.map} +0 -0
  200. /package/dist/{session-end-4Y5VY4OI.js.map → session-end-OUTY7AFF.js.map} +0 -0
  201. /package/dist/{setup-llm-UBBSQWX5.js.map → setup-llm-ZMYGIQX5.js.map} +0 -0
  202. /package/dist/{stats-3NW7PGQK.js.map → stats-DGI6B3HX.js.map} +0 -0
  203. /package/dist/{stop-L7BLMHUD.js.map → stop-YGHODSP7.js.map} +0 -0
  204. /package/dist/{stop-failure-P5MYHGAZ.js.map → stop-failure-7IJTPJ6W.js.map} +0 -0
  205. /package/dist/{subagent-start-AIEFG4HA.js.map → subagent-start-ZBQ5PJB5.js.map} +0 -0
  206. /package/dist/{subagent-stop-TZ62BSNI.js.map → subagent-stop-N2TDQU2D.js.map} +0 -0
  207. /package/dist/{task-completed-ZKVCUBCP.js.map → task-completed-BDLMRSBB.js.map} +0 -0
  208. /package/dist/{resolution-events-CLDXZF67.js.map → version-YPBIKH77.js.map} +0 -0
@@ -3,6 +3,9 @@ import {
3
3
  DaemonLogger,
4
4
  LEVEL_ORDER
5
5
  } from "./chunk-MVBCON4D.js";
6
+ import {
7
+ withTaskConfig
8
+ } from "./chunk-GFR542SM.js";
6
9
  import {
7
10
  EMBEDDABLE_TABLES,
8
11
  EMBEDDABLE_TEXT_COLUMNS,
@@ -12,7 +15,16 @@ import {
12
15
  getEmbeddingQueueDepth,
13
16
  getUnembedded,
14
17
  markEmbedded
15
- } from "./chunk-KOTFMGL5.js";
18
+ } from "./chunk-DLFDBKEV.js";
19
+ import {
20
+ loadSecrets,
21
+ readSecrets,
22
+ writeSecret
23
+ } from "./chunk-RJMXDUMA.js";
24
+ import {
25
+ Anthropic,
26
+ createEmbeddingProvider
27
+ } from "./chunk-KWTOCJLB.js";
16
28
  import {
17
29
  buildTaskInstruction,
18
30
  closeOpenBatches,
@@ -38,6 +50,7 @@ import {
38
50
  getRun,
39
51
  getSkillRecord,
40
52
  getSkillRecordByName,
53
+ hasConfiguredProvider,
41
54
  incrementActivityCount,
42
55
  incrementSkillUsageCount,
43
56
  insertBatchStateless,
@@ -59,71 +72,57 @@ import {
59
72
  setResponseSummary,
60
73
  updateCandidate,
61
74
  updateNotificationStatus
62
- } from "./chunk-YTOD6L6N.js";
75
+ } from "./chunk-JDI4DPWD.js";
63
76
  import {
64
77
  fullTextSearch,
65
78
  hydrateSearchResults
66
- } from "./chunk-GBYLHPML.js";
67
- import {
68
- cleanupStagedSkill,
69
- listStaleStagingDirs
70
- } from "./chunk-U5EW2VIQ.js";
71
- import {
72
- withTaskConfig
73
- } from "./chunk-SODRR3HE.js";
74
- import {
75
- getMachineId
76
- } from "./chunk-ENWBFX7F.js";
77
- import {
78
- createEmbeddingProvider
79
- } from "./chunk-QQ7CXA7Q.js";
79
+ } from "./chunk-NZI7WBZI.js";
80
80
  import {
81
81
  copyTaskToUser,
82
82
  deleteUserTask,
83
83
  loadAllTasks,
84
84
  validateTaskName,
85
85
  writeUserTask
86
- } from "./chunk-ZUSTCXHT.js";
86
+ } from "./chunk-RAV5YMRU.js";
87
87
  import {
88
88
  AgentTaskSchema,
89
89
  registerAgent,
90
90
  resolveDefinitionsDir,
91
91
  taskFromParsed
92
- } from "./chunk-VQQ57UPG.js";
92
+ } from "./chunk-NI23QCHB.js";
93
93
  import {
94
94
  listTurnsByRun
95
95
  } from "./chunk-QLCD77AN.js";
96
96
  import {
97
- checkLocalProvider
98
- } from "./chunk-CPL76CYD.js";
97
+ cleanupStagedSkill,
98
+ listStaleStagingDirs
99
+ } from "./chunk-U5EW2VIQ.js";
100
+ import {
101
+ getMachineId
102
+ } from "./chunk-ENWBFX7F.js";
99
103
  import {
100
104
  EventBuffer,
101
105
  cleanStaleBuffers,
102
106
  listBufferSessionIds
103
107
  } from "./chunk-V7XG6V6C.js";
104
108
  import "./chunk-IB76KGBY.js";
105
- import "./chunk-U3SSOSIR.js";
106
- import "./chunk-Y7QCKCEJ.js";
107
- import "./chunk-KGL5QSDN.js";
108
- import "./chunk-XQHL4GMO.js";
109
+ import "./chunk-55QEICRO.js";
109
110
  import "./chunk-SAKJMNSR.js";
111
+ import "./chunk-WYOE4IAX.js";
110
112
  import {
111
- loadSecrets,
112
- readSecrets,
113
- writeSecret
114
- } from "./chunk-RJMXDUMA.js";
115
- import "./chunk-VVGZL2HX.js";
113
+ checkLocalProvider
114
+ } from "./chunk-75AZFBFW.js";
116
115
  import {
117
116
  LmStudioBackend,
118
117
  OllamaBackend
119
- } from "./chunk-DKSQMH5X.js";
118
+ } from "./chunk-CML4MCYF.js";
120
119
  import {
121
120
  countSpores,
122
121
  getSpore,
123
122
  insertSpore,
124
123
  listSpores,
125
124
  updateSporeStatus
126
- } from "./chunk-UDBCAFXS.js";
125
+ } from "./chunk-7OYXB2NM.js";
127
126
  import {
128
127
  closeSession,
129
128
  countSessions,
@@ -134,7 +133,7 @@ import {
134
133
  listSessions,
135
134
  updateSession,
136
135
  upsertSession
137
- } from "./chunk-VGVRBSLC.js";
136
+ } from "./chunk-U7GJTVSX.js";
138
137
  import {
139
138
  backfillUnsynced,
140
139
  countDeadLettered,
@@ -150,13 +149,13 @@ import {
150
149
  pruneOld,
151
150
  retryDeadLettered,
152
151
  syncRow
153
- } from "./chunk-KKEMVH6D.js";
152
+ } from "./chunk-O3TRN3RC.js";
154
153
  import {
155
154
  EMBEDDING_DIMENSIONS,
156
155
  REST_SETTABLE_STATUSES,
157
156
  SCHEMA_VERSION,
158
157
  createSchema
159
- } from "./chunk-OGNEW5CN.js";
158
+ } from "./chunk-OW433Q4C.js";
160
159
  import {
161
160
  CONFIG_FILENAME,
162
161
  MycoConfigSchema,
@@ -165,7 +164,7 @@ import {
165
164
  updateBackupConfig,
166
165
  updateConfig,
167
166
  updateTeamConfig
168
- } from "./chunk-FEX6ALLH.js";
167
+ } from "./chunk-2V7HR7HB.js";
169
168
  import {
170
169
  closeDatabase,
171
170
  getDatabase,
@@ -174,13 +173,13 @@ import {
174
173
  } from "./chunk-MYX5NCRH.js";
175
174
  import {
176
175
  resolveCliEntryPath
177
- } from "./chunk-N6JNOSBQ.js";
176
+ } from "./chunk-BUIR3JWM.js";
178
177
  import {
179
178
  getPluginVersion
180
- } from "./chunk-LA7NDX3J.js";
179
+ } from "./chunk-EO2RQW4S.js";
181
180
  import {
182
181
  loadManifests
183
- } from "./chunk-EBIYONNZ.js";
182
+ } from "./chunk-FABWUX5G.js";
184
183
  import {
185
184
  findPackageRoot
186
185
  } from "./chunk-LPUQPDC2.js";
@@ -214,6 +213,7 @@ import {
214
213
  PROMPT_PREVIEW_CHARS,
215
214
  PROMPT_VECTOR_OVER_FETCH,
216
215
  RELEASE_CHANNELS,
216
+ RESTART_REASON_FILENAME,
217
217
  RESTART_RESPONSE_FLUSH_MS,
218
218
  SEARCH_RESULTS_DEFAULT_LIMIT,
219
219
  SEARCH_SIMILARITY_THRESHOLD,
@@ -229,12 +229,13 @@ import {
229
229
  UPDATE_CONFIG_PATH,
230
230
  UPDATE_ERROR_PATH,
231
231
  UPDATE_SCRIPT_DELAY_SECONDS,
232
+ UPDATE_STAMP_FILENAME,
232
233
  USER_AGENT_ID,
233
234
  USER_AGENT_NAME,
234
235
  USER_TASK_SOURCE,
235
236
  epochSeconds,
236
237
  estimateTokens
237
- } from "./chunk-6SDC6V3N.js";
238
+ } from "./chunk-CKJAWZQE.js";
238
239
  import {
239
240
  LOG_KINDS,
240
241
  kindToComponent
@@ -1602,10 +1603,32 @@ async function handleRestart(deps, body) {
1602
1603
  var import_yaml = __toESM(require_dist(), 1);
1603
1604
  import fs8 from "fs";
1604
1605
  import path9 from "path";
1606
+ import { execFileSync } from "child_process";
1605
1607
  import semver from "semver";
1606
1608
  var REGISTRY_FETCH_TIMEOUT_MS = 1e4;
1609
+ var devBuildCliEntry = null;
1610
+ function setDevBuildCliEntry(cliEntry) {
1611
+ devBuildCliEntry = cliEntry;
1612
+ }
1613
+ function resolveMycoBinary() {
1614
+ return devBuildCliEntry ?? "myco";
1615
+ }
1607
1616
  function isUpdateExempt() {
1608
- return Boolean(process.env.MYCO_CMD);
1617
+ return devBuildCliEntry !== null;
1618
+ }
1619
+ function detectDevBuild(globalPrefix, cliEntry, realpath) {
1620
+ if (!globalPrefix) return null;
1621
+ if (!cliEntry) return null;
1622
+ try {
1623
+ const resolvedEntry = realpath(cliEntry);
1624
+ const resolvedPrefix = realpath(globalPrefix);
1625
+ if (resolvedEntry.startsWith(resolvedPrefix + path9.sep) || resolvedEntry === resolvedPrefix) {
1626
+ return null;
1627
+ }
1628
+ return cliEntry;
1629
+ } catch {
1630
+ return null;
1631
+ }
1609
1632
  }
1610
1633
  function defaultUpdateConfig() {
1611
1634
  return {
@@ -1676,6 +1699,25 @@ function buildCheckResult(currentVersion, cache, config, error) {
1676
1699
  error
1677
1700
  };
1678
1701
  }
1702
+ function resolveGlobalPrefix() {
1703
+ return execFileSync("npm", ["prefix", "-g"], { encoding: "utf-8", timeout: 5e3 }).trim();
1704
+ }
1705
+ function getInstalledVersion(globalPrefix) {
1706
+ try {
1707
+ const pkgPath = path9.join(
1708
+ globalPrefix,
1709
+ "lib",
1710
+ "node_modules",
1711
+ NPM_PACKAGE_NAME,
1712
+ "package.json"
1713
+ );
1714
+ const raw = fs8.readFileSync(pkgPath, "utf-8");
1715
+ const pkg = JSON.parse(raw);
1716
+ return pkg.version ?? null;
1717
+ } catch {
1718
+ return null;
1719
+ }
1720
+ }
1679
1721
  async function checkForUpdate(currentVersion) {
1680
1722
  const config = readUpdateConfig();
1681
1723
  const existingCache = readCachedCheck();
@@ -1737,17 +1779,18 @@ import os6 from "os";
1737
1779
  import path10 from "path";
1738
1780
  import { spawn as spawn2 } from "child_process";
1739
1781
  function generateUpdateScript(params) {
1740
- const { targetVersion, projectRoot, vaultDir } = params;
1782
+ const { targetVersion, projectRoot, vaultDir, mycoBinary } = params;
1741
1783
  const packageSpec = `${NPM_PACKAGE_NAME}@${targetVersion}`;
1742
1784
  const quotedProjectRoot = JSON.stringify(projectRoot);
1743
1785
  const quotedVaultDir = JSON.stringify(vaultDir);
1786
+ const quotedMycoBinary = JSON.stringify(mycoBinary);
1744
1787
  const quotedErrorPath = JSON.stringify(UPDATE_ERROR_PATH);
1745
1788
  const errorJson = JSON.stringify(
1746
1789
  JSON.stringify({ error: `npm install failed for ${packageSpec}` })
1747
1790
  );
1748
1791
  return `#!/bin/sh
1749
1792
  set -e
1750
- MYCO="\${MYCO_CMD:-myco}"
1793
+ MYCO=${quotedMycoBinary}
1751
1794
 
1752
1795
  # Wait for daemon to exit cleanly
1753
1796
  sleep ${UPDATE_SCRIPT_DELAY_SECONDS}
@@ -1770,12 +1813,9 @@ fi
1770
1813
  rm -f "$0"
1771
1814
  `;
1772
1815
  }
1773
- function spawnUpdateScript(params) {
1774
- fs9.mkdirSync(MYCO_GLOBAL_DIR, { recursive: true });
1775
- const scriptName = `myco-update-${Date.now()}.sh`;
1776
- const scriptPath = path10.join(os6.tmpdir(), scriptName);
1777
- const script = generateUpdateScript(params);
1778
- fs9.writeFileSync(scriptPath, script, { encoding: "utf-8", mode: 493 });
1816
+ function spawnDetachedScript(namePrefix, content) {
1817
+ const scriptPath = path10.join(os6.tmpdir(), `${namePrefix}-${Date.now()}.sh`);
1818
+ fs9.writeFileSync(scriptPath, content, { encoding: "utf-8", mode: 493 });
1779
1819
  const child = spawn2("/bin/sh", [scriptPath], {
1780
1820
  detached: true,
1781
1821
  stdio: "ignore"
@@ -1783,17 +1823,94 @@ function spawnUpdateScript(params) {
1783
1823
  child.unref();
1784
1824
  return scriptPath;
1785
1825
  }
1826
+ function spawnUpdateScript(params) {
1827
+ fs9.mkdirSync(MYCO_GLOBAL_DIR, { recursive: true });
1828
+ return spawnDetachedScript("myco-update", generateUpdateScript(params));
1829
+ }
1830
+ function generateRestartScript(params) {
1831
+ const { projectRoot, vaultDir, runLocalUpdate, fromVersion, toVersion, mycoBinary } = params;
1832
+ const quotedProjectRoot = JSON.stringify(projectRoot);
1833
+ const quotedVaultDir = JSON.stringify(vaultDir);
1834
+ const quotedMycoBinary = JSON.stringify(mycoBinary);
1835
+ const reasonFile = JSON.stringify(path10.join(vaultDir, RESTART_REASON_FILENAME));
1836
+ const reasonJson = JSON.stringify(JSON.stringify({
1837
+ reason: "version_sync",
1838
+ from_version: fromVersion,
1839
+ to_version: toVersion,
1840
+ local_update_ran: runLocalUpdate
1841
+ }));
1842
+ const updateBlock = runLocalUpdate ? `
1843
+ # Run local project update (hooks, symbionts, gitignore)
1844
+ "$MYCO" update --project ${quotedProjectRoot} || true` : "";
1845
+ return `#!/bin/sh
1846
+ set -e
1847
+ MYCO=${quotedMycoBinary}
1848
+
1849
+ # Wait for daemon to exit cleanly
1850
+ sleep ${UPDATE_SCRIPT_DELAY_SECONDS}
1851
+ ${updateBlock}
1852
+
1853
+ # Write restart reason for the new daemon to pick up
1854
+ echo ${reasonJson} > ${reasonFile}
1855
+
1856
+ # Restart daemon
1857
+ "$MYCO" daemon --vault ${quotedVaultDir} &
1858
+
1859
+ # Clean up this script
1860
+ rm -f "$0"
1861
+ `;
1862
+ }
1863
+ function spawnRestartScript(params) {
1864
+ return spawnDetachedScript("myco-restart", generateRestartScript(params));
1865
+ }
1786
1866
 
1787
1867
  // src/daemon/api/update.ts
1868
+ import semver2 from "semver";
1869
+ import fs10 from "fs";
1870
+ import path11 from "path";
1788
1871
  var ChannelBodySchema = external_exports.object({
1789
1872
  channel: external_exports.enum(RELEASE_CHANNELS)
1790
1873
  });
1791
1874
  function createUpdateHandlers(deps) {
1792
- const { vaultDir, projectRoot, currentVersion, scheduleShutdown } = deps;
1875
+ const { vaultDir, projectRoot, currentVersion, scheduleShutdown, globalPrefix } = deps;
1876
+ let restartInitiated = false;
1877
+ function isStampCurrent() {
1878
+ try {
1879
+ const stampPath = path11.join(vaultDir, UPDATE_STAMP_FILENAME);
1880
+ const stamp = fs10.readFileSync(stampPath, "utf-8").trim();
1881
+ return stamp === currentVersion;
1882
+ } catch {
1883
+ return false;
1884
+ }
1885
+ }
1793
1886
  async function handleUpdateStatus(_req) {
1794
1887
  if (isUpdateExempt()) {
1795
1888
  return { body: { exempt: true, running_version: currentVersion } };
1796
1889
  }
1890
+ if (globalPrefix && !restartInitiated) {
1891
+ const installedVersion = getInstalledVersion(globalPrefix);
1892
+ if (installedVersion && semver2.valid(installedVersion) && semver2.valid(currentVersion) && semver2.gt(installedVersion, currentVersion)) {
1893
+ restartInitiated = true;
1894
+ const runLocalUpdate = !isStampCurrent();
1895
+ spawnRestartScript({
1896
+ projectRoot,
1897
+ vaultDir,
1898
+ runLocalUpdate,
1899
+ fromVersion: currentVersion,
1900
+ toVersion: installedVersion,
1901
+ mycoBinary: resolveMycoBinary()
1902
+ });
1903
+ scheduleShutdown();
1904
+ return {
1905
+ body: {
1906
+ restarting: true,
1907
+ reason: "version_sync",
1908
+ running_version: currentVersion,
1909
+ installed_version: installedVersion
1910
+ }
1911
+ };
1912
+ }
1913
+ }
1797
1914
  const config = readUpdateConfig();
1798
1915
  const cache = readCachedCheck();
1799
1916
  if (isCacheStale(cache, config.check_interval_hours)) {
@@ -1837,7 +1954,12 @@ function createUpdateHandlers(deps) {
1837
1954
  if (!status || !status.update_available) {
1838
1955
  return { status: 400, body: { error: "no_update_available" } };
1839
1956
  }
1840
- spawnUpdateScript({ targetVersion: status.latest_version, projectRoot, vaultDir });
1957
+ spawnUpdateScript({
1958
+ targetVersion: status.latest_version,
1959
+ projectRoot,
1960
+ vaultDir,
1961
+ mycoBinary: resolveMycoBinary()
1962
+ });
1841
1963
  scheduleShutdown();
1842
1964
  return { body: { status: "applying", version: status.latest_version } };
1843
1965
  }
@@ -1878,8 +2000,8 @@ function createUpdateHandlers(deps) {
1878
2000
  }
1879
2001
 
1880
2002
  // src/daemon/backup.ts
1881
- import fs10 from "fs";
1882
- import path11 from "path";
2003
+ import fs11 from "fs";
2004
+ import path12 from "path";
1883
2005
  var BACKUP_TABLES = [
1884
2006
  "sessions",
1885
2007
  "prompt_batches",
@@ -1894,6 +2016,7 @@ var BACKUP_TABLES = [
1894
2016
  "team_members"
1895
2017
  ];
1896
2018
  var BACKUP_EXTENSION = ".sql";
2019
+ var BACKUP_FILENAME_PATTERN = /^[A-Za-z0-9_-]+\.sql$/;
1897
2020
  var BACKUP_HEADER_TEMPLATE = "-- Myco backup";
1898
2021
  function escapeSql(value) {
1899
2022
  return value.replace(/'/g, "''");
@@ -1905,7 +2028,7 @@ function toSqlLiteral(value) {
1905
2028
  return `'${escapeSql(String(value))}'`;
1906
2029
  }
1907
2030
  function createBackup(db, backupDir, machineId) {
1908
- fs10.mkdirSync(backupDir, { recursive: true });
2031
+ fs11.mkdirSync(backupDir, { recursive: true });
1909
2032
  const lines = [];
1910
2033
  const timestamp = epochSeconds();
1911
2034
  lines.push(`${BACKUP_HEADER_TEMPLATE}: machine_id=${machineId}, created_at=${timestamp}`);
@@ -1923,22 +2046,22 @@ function createBackup(db, backupDir, machineId) {
1923
2046
  }
1924
2047
  lines.push("");
1925
2048
  }
1926
- const filePath = path11.join(backupDir, `${machineId}${BACKUP_EXTENSION}`);
1927
- fs10.writeFileSync(filePath, lines.join("\n"), "utf-8");
2049
+ const filePath = path12.join(backupDir, `${machineId}${BACKUP_EXTENSION}`);
2050
+ fs11.writeFileSync(filePath, lines.join("\n"), "utf-8");
1928
2051
  return filePath;
1929
2052
  }
1930
2053
  function listBackups(backupDir) {
1931
2054
  let entries;
1932
2055
  try {
1933
- entries = fs10.readdirSync(backupDir);
2056
+ entries = fs11.readdirSync(backupDir);
1934
2057
  } catch {
1935
2058
  return [];
1936
2059
  }
1937
2060
  const backups = [];
1938
2061
  for (const entry of entries) {
1939
- if (!entry.endsWith(BACKUP_EXTENSION)) continue;
1940
- const filePath = path11.join(backupDir, entry);
1941
- const stat = fs10.statSync(filePath);
2062
+ if (!BACKUP_FILENAME_PATTERN.test(entry)) continue;
2063
+ const filePath = path12.join(backupDir, entry);
2064
+ const stat = fs11.statSync(filePath);
1942
2065
  backups.push({
1943
2066
  machine_id: entry.slice(0, -BACKUP_EXTENSION.length),
1944
2067
  file_name: entry,
@@ -1950,7 +2073,7 @@ function listBackups(backupDir) {
1950
2073
  }
1951
2074
  var INSERT_REGEX = /^INSERT OR IGNORE INTO (\w+)\s+\(([^)]+)\)\s+VALUES\s+\((.+)\);$/;
1952
2075
  function parseBackupFile(backupPath) {
1953
- const content = fs10.readFileSync(backupPath, "utf-8");
2076
+ const content = fs11.readFileSync(backupPath, "utf-8");
1954
2077
  const inserts = [];
1955
2078
  for (const line of content.split("\n")) {
1956
2079
  const match = INSERT_REGEX.exec(line);
@@ -2034,7 +2157,7 @@ function restoreBackup(db, backupPath) {
2034
2157
  }
2035
2158
 
2036
2159
  // src/daemon/api/backup.ts
2037
- import path12 from "path";
2160
+ import path13 from "path";
2038
2161
  function createBackupHandlers(deps) {
2039
2162
  async function handleCreateBackup(_req) {
2040
2163
  const filePath = createBackup(deps.db, deps.backupDir, deps.machineId);
@@ -2093,7 +2216,7 @@ function createBackupConfigHandlers(deps) {
2093
2216
  const { vaultDir } = deps;
2094
2217
  async function handleGetBackupConfig() {
2095
2218
  const cfg = loadConfig(vaultDir);
2096
- return { body: { dir: cfg.backup.dir ?? null, default_dir: path12.resolve(vaultDir, "backups") } };
2219
+ return { body: { dir: cfg.backup.dir ?? null, default_dir: path13.resolve(vaultDir, "backups") } };
2097
2220
  }
2098
2221
  async function handlePutBackupConfig(req) {
2099
2222
  const { dir } = req.body;
@@ -2104,12 +2227,14 @@ function createBackupConfigHandlers(deps) {
2104
2227
  }
2105
2228
 
2106
2229
  // src/daemon/team-sync.ts
2107
- var TeamSyncClient = class {
2230
+ var TeamSyncClient = class _TeamSyncClient {
2108
2231
  workerUrl;
2109
2232
  apiKey;
2110
2233
  machineId;
2111
2234
  syncProtocolVersion;
2112
2235
  fetchFn;
2236
+ mcpToken = null;
2237
+ mcpTokenHash = null;
2113
2238
  constructor(options) {
2114
2239
  this.workerUrl = options.workerUrl.replace(/\/+$/, "");
2115
2240
  this.apiKey = options.apiKey;
@@ -2117,6 +2242,14 @@ var TeamSyncClient = class {
2117
2242
  this.syncProtocolVersion = options.syncProtocolVersion;
2118
2243
  this.fetchFn = options.fetch ?? globalThis.fetch;
2119
2244
  }
2245
+ // Must match getMcpTokenHash() in src/worker/src/mcp/auth.ts
2246
+ static hashToken(token) {
2247
+ let hash = 0;
2248
+ for (let i = 0; i < token.length; i++) {
2249
+ hash = (hash << 5) - hash + token.charCodeAt(i) | 0;
2250
+ }
2251
+ return Math.abs(hash).toString(16).padStart(8, "0").slice(0, 8);
2252
+ }
2120
2253
  /**
2121
2254
  * Register this machine with the team worker.
2122
2255
  */
@@ -2126,7 +2259,12 @@ var TeamSyncClient = class {
2126
2259
  machine_id: this.machineId,
2127
2260
  sync_protocol_version: this.syncProtocolVersion
2128
2261
  });
2129
- return res;
2262
+ const response = res;
2263
+ if (response.mcp_token) {
2264
+ this.mcpToken = response.mcp_token;
2265
+ this.mcpTokenHash = _TeamSyncClient.hashToken(response.mcp_token);
2266
+ }
2267
+ return response;
2130
2268
  }
2131
2269
  /**
2132
2270
  * Push a batch of outbox records to the team worker.
@@ -2192,7 +2330,14 @@ var TeamSyncClient = class {
2192
2330
  if (!res.ok) {
2193
2331
  throw new Error(`Health check failed: ${res.status} ${res.statusText}`);
2194
2332
  }
2195
- return await res.json();
2333
+ const data = await res.json();
2334
+ if (data.mcp_token_hash && data.mcp_token_hash !== this.mcpTokenHash) {
2335
+ try {
2336
+ await this.connect({ machine_id: this.machineId });
2337
+ } catch {
2338
+ }
2339
+ }
2340
+ return data;
2196
2341
  } finally {
2197
2342
  clearTimeout(timer);
2198
2343
  }
@@ -2205,6 +2350,22 @@ var TeamSyncClient = class {
2205
2350
  return res;
2206
2351
  }
2207
2352
  // ---------------------------------------------------------------------------
2353
+ // MCP token accessors
2354
+ // ---------------------------------------------------------------------------
2355
+ getMcpToken() {
2356
+ return this.mcpToken;
2357
+ }
2358
+ getMcpEndpoint() {
2359
+ if (!this.mcpToken) return null;
2360
+ return `${this.workerUrl}/mcp`;
2361
+ }
2362
+ async rotateMcpToken() {
2363
+ const result = await this.request("POST", "/mcp/rotate");
2364
+ this.mcpToken = result.token;
2365
+ this.mcpTokenHash = _TeamSyncClient.hashToken(result.token);
2366
+ return result.token;
2367
+ }
2368
+ // ---------------------------------------------------------------------------
2208
2369
  // Internal
2209
2370
  // ---------------------------------------------------------------------------
2210
2371
  headers() {
@@ -2213,15 +2374,15 @@ var TeamSyncClient = class {
2213
2374
  "Content-Type": "application/json"
2214
2375
  };
2215
2376
  }
2216
- async request(method, path21, body) {
2217
- const res = await this.fetchFn(`${this.workerUrl}${path21}`, {
2377
+ async request(method, path22, body) {
2378
+ const res = await this.fetchFn(`${this.workerUrl}${path22}`, {
2218
2379
  method,
2219
2380
  headers: this.headers(),
2220
2381
  body: body !== void 0 ? JSON.stringify(body) : void 0
2221
2382
  });
2222
2383
  if (!res.ok) {
2223
2384
  const text = await res.text().catch(() => "");
2224
- throw new Error(`Team sync request ${method} ${path21} failed: ${res.status} ${text}`);
2385
+ throw new Error(`Team sync request ${method} ${path22} failed: ${res.status} ${text}`);
2225
2386
  }
2226
2387
  return res.json();
2227
2388
  }
@@ -2229,7 +2390,7 @@ var TeamSyncClient = class {
2229
2390
 
2230
2391
  // src/daemon/api/team-connect.ts
2231
2392
  function createTeamHandlers(deps) {
2232
- const { vaultDir, machineId } = deps;
2393
+ const { vaultDir, machineId, logger } = deps;
2233
2394
  async function handleConnect(req) {
2234
2395
  const { url, api_key } = req.body;
2235
2396
  if (!url || !api_key) {
@@ -2314,7 +2475,9 @@ function createTeamHandlers(deps) {
2314
2475
  deployed_worker_version: config.team.deployed_worker_version ?? null,
2315
2476
  worker_update_available: config.team.enabled ? config.team.deployed_worker_version !== getPluginVersion() : false,
2316
2477
  schema_version: SCHEMA_VERSION,
2317
- sync_protocol_version: SYNC_PROTOCOL_VERSION
2478
+ sync_protocol_version: SYNC_PROTOCOL_VERSION,
2479
+ mcp_token: client?.getMcpToken() ?? null,
2480
+ mcp_endpoint: client?.getMcpEndpoint() ?? null
2318
2481
  }
2319
2482
  };
2320
2483
  }
@@ -2327,11 +2490,17 @@ function createTeamHandlers(deps) {
2327
2490
  return { body: { retried: count } };
2328
2491
  }
2329
2492
  async function handleUpgradeWorker(_req) {
2330
- const { upgradeWorker } = await import("./team-WHZW6IFU.js");
2493
+ const { upgradeWorker } = await import("./team-2ZFGTSIN.js");
2494
+ logger.info("team-sync.upgrade.start", "Starting worker upgrade");
2331
2495
  const result = upgradeWorker(vaultDir);
2332
2496
  if (!result.success) {
2497
+ logger.error("team-sync.upgrade.failed", "Worker upgrade failed", { error: result.error });
2333
2498
  return { status: 500, body: { error: result.error } };
2334
2499
  }
2500
+ logger.info("team-sync.upgrade.complete", "Worker upgrade complete", {
2501
+ worker_url: result.worker_url,
2502
+ version: result.version
2503
+ });
2335
2504
  if (result.worker_url && deps.getTeamClient()) {
2336
2505
  const secrets = readSecrets(vaultDir);
2337
2506
  const apiKey = secrets[TEAM_API_KEY_SECRET];
@@ -2346,7 +2515,28 @@ function createTeamHandlers(deps) {
2346
2515
  }
2347
2516
  return { body: result };
2348
2517
  }
2349
- return { handleConnect, handleDisconnect, handleStatus, handleBackfill, handleRetryFailed, handleUpgradeWorker };
2518
+ async function handleRotateMcpToken(_req) {
2519
+ const client = deps.getTeamClient();
2520
+ if (!client) {
2521
+ return {
2522
+ status: 400,
2523
+ body: { error: "Team sync not connected" }
2524
+ };
2525
+ }
2526
+ try {
2527
+ const token = await client.rotateMcpToken();
2528
+ logger.info("team-sync.mcp-token.rotated", "MCP access token rotated");
2529
+ return { body: { token } };
2530
+ } catch (err) {
2531
+ const message = err instanceof Error ? err.message : String(err);
2532
+ logger.error("team-sync.mcp-token.rotate-failed", "MCP token rotation failed", { error: message });
2533
+ return {
2534
+ status: 500,
2535
+ body: { error: message }
2536
+ };
2537
+ }
2538
+ }
2539
+ return { handleConnect, handleDisconnect, handleStatus, handleBackfill, handleRetryFailed, handleUpgradeWorker, handleRotateMcpToken };
2350
2540
  }
2351
2541
 
2352
2542
  // src/daemon/api/session-lifecycle.ts
@@ -2426,8 +2616,8 @@ function createSessionLifecycleHandlers(deps) {
2426
2616
  }
2427
2617
 
2428
2618
  // src/daemon/api/skills.ts
2429
- import fs11 from "fs";
2430
- import path13 from "path";
2619
+ import fs12 from "fs";
2620
+ import path14 from "path";
2431
2621
 
2432
2622
  // src/db/queries/skill-usage.ts
2433
2623
  var USAGE_COLUMNS = [
@@ -2594,15 +2784,15 @@ function createSkillRecordDeleteHandler(deps) {
2594
2784
  if (result.body?.deleted) {
2595
2785
  const record = result.body;
2596
2786
  if (record.name) {
2597
- const projectRoot = path13.resolve(vaultDir, "..");
2598
- const skillDir = path13.resolve(projectRoot, ".agents", "skills", record.name);
2787
+ const projectRoot = path14.resolve(vaultDir, "..");
2788
+ const skillDir = path14.resolve(projectRoot, ".agents", "skills", record.name);
2599
2789
  try {
2600
- fs11.rmSync(skillDir, { recursive: true, force: true });
2790
+ fs12.rmSync(skillDir, { recursive: true, force: true });
2601
2791
  } catch (err) {
2602
2792
  logger.warn(LOG_KINDS.PROCESSOR_BATCH, "Failed to remove skill directory", { name: record.name, error: String(err) });
2603
2793
  }
2604
2794
  try {
2605
- const { syncSkillSymlinks } = await import("./installer-45ZLP2RP.js");
2795
+ const { syncSkillSymlinks } = await import("./installer-BWJED3ED.js");
2606
2796
  syncSkillSymlinks(projectRoot, record.name, { remove: true });
2607
2797
  } catch (err) {
2608
2798
  logger.warn(LOG_KINDS.PROCESSOR_BATCH, "Failed to remove skill symlinks", { name: record.name, error: String(err) });
@@ -2802,8 +2992,8 @@ async function handleGetProgress(tracker, token) {
2802
2992
  // src/daemon/api/models.ts
2803
2993
  var MODEL_LIST_TIMEOUT_MS = 5e3;
2804
2994
  var ANTHROPIC_MODELS = [
2805
- "claude-opus-4-6",
2806
2995
  "claude-sonnet-4-6",
2996
+ "claude-opus-4-6",
2807
2997
  "claude-haiku-4-5-20251001"
2808
2998
  ];
2809
2999
  var EMBEDDING_PATTERNS = [
@@ -2855,12 +3045,12 @@ async function handleGetModels(req) {
2855
3045
 
2856
3046
  // src/daemon/api/stats.ts
2857
3047
  import { createHash as createHash2 } from "crypto";
2858
- import fs12 from "fs";
2859
- import path14 from "path";
3048
+ import fs13 from "fs";
3049
+ import path15 from "path";
2860
3050
  function computeConfigHash(vaultDir) {
2861
3051
  try {
2862
- const configPath = path14.join(vaultDir, CONFIG_FILENAME);
2863
- const raw = fs12.readFileSync(configPath, "utf-8");
3052
+ const configPath = path15.join(vaultDir, CONFIG_FILENAME);
3053
+ const raw = fs13.readFileSync(configPath, "utf-8");
2864
3054
  return createHash2("md5").update(raw).digest("hex");
2865
3055
  } catch {
2866
3056
  return "";
@@ -4772,17 +4962,17 @@ var SqliteRecordSource = class {
4772
4962
  };
4773
4963
 
4774
4964
  // src/daemon/database/manager.ts
4775
- import fs14 from "fs";
4965
+ import fs15 from "fs";
4776
4966
 
4777
4967
  // src/db/queries/database.ts
4778
- import fs13 from "fs";
4968
+ import fs14 from "fs";
4779
4969
  function pragmaScalar(name) {
4780
4970
  const db = getDatabase();
4781
4971
  return db.pragma(name, { simple: true });
4782
4972
  }
4783
4973
  function safeFileSize(filePath) {
4784
4974
  try {
4785
- return fs13.statSync(filePath).size;
4975
+ return fs14.statSync(filePath).size;
4786
4976
  } catch (err) {
4787
4977
  if (err.code === "ENOENT") return 0;
4788
4978
  throw err;
@@ -5054,7 +5244,7 @@ var DatabaseMaintenanceManager = class {
5054
5244
  }
5055
5245
  async vacuum() {
5056
5246
  const size_before = this.fileSize();
5057
- const stats = await fs14.promises.statfs(this.vaultDir);
5247
+ const stats = await fs15.promises.statfs(this.vaultDir);
5058
5248
  const free_bytes = Number(stats.bavail) * Number(stats.bsize);
5059
5249
  const required_bytes = size_before * VACUUM_FREE_SPACE_MULTIPLIER;
5060
5250
  if (free_bytes < required_bytes) {
@@ -5102,7 +5292,7 @@ var DatabaseMaintenanceManager = class {
5102
5292
  }
5103
5293
  fileSize() {
5104
5294
  try {
5105
- return fs14.statSync(this.dbPath).size;
5295
+ return fs15.statSync(this.dbPath).size;
5106
5296
  } catch {
5107
5297
  return 0;
5108
5298
  }
@@ -5144,6 +5334,13 @@ function registerBuiltinDomains() {
5144
5334
  { id: "mycelium.spore.created", label: "New spore extracted", defaultMode: "summary", defaultLevel: "info" }
5145
5335
  ]
5146
5336
  });
5337
+ register({
5338
+ domain: "daemon",
5339
+ label: "Daemon",
5340
+ types: [
5341
+ { id: "daemon.version_sync", label: "Version sync restart", defaultMode: "banner", defaultLevel: "info" }
5342
+ ]
5343
+ });
5147
5344
  }
5148
5345
 
5149
5346
  // src/daemon/api/notifications.ts
@@ -5406,13 +5603,16 @@ async function handleUpdateTaskConfig(req, vaultDir) {
5406
5603
  }
5407
5604
 
5408
5605
  // src/daemon/api/providers.ts
5606
+ var ANTHROPIC_MODELS_TIMEOUT_MS = 5e3;
5607
+ var ANTHROPIC_MODELS_CACHE_TTL_MS = 10 * 60 * 1e3;
5608
+ var anthropicModelsCache = null;
5409
5609
  var HTTP_OK2 = 200;
5410
5610
  var HTTP_BAD_REQUEST2 = 400;
5411
5611
  async function handleGetProviders() {
5412
5612
  const results = await Promise.allSettled([
5613
+ detectAnthropic(),
5413
5614
  detectLocalProviderInfo("ollama", OllamaBackend.DEFAULT_BASE_URL),
5414
- detectLocalProviderInfo("lmstudio", LmStudioBackend.DEFAULT_BASE_URL),
5415
- detectCloud()
5615
+ detectLocalProviderInfo("lmstudio", LmStudioBackend.DEFAULT_BASE_URL)
5416
5616
  ]);
5417
5617
  const providers = results.map(
5418
5618
  (r) => r.status === "fulfilled" ? r.value : { type: "unknown", available: false, models: [] }
@@ -5422,10 +5622,10 @@ async function handleGetProviders() {
5422
5622
  async function handleTestProvider(req) {
5423
5623
  const body = req.body;
5424
5624
  const type = body?.type;
5425
- if (!type || !["cloud", "ollama", "lmstudio"].includes(type)) {
5625
+ if (!type || !["anthropic", "ollama", "lmstudio"].includes(type)) {
5426
5626
  return {
5427
5627
  status: HTTP_BAD_REQUEST2,
5428
- body: { error: "type is required and must be one of: cloud, ollama, lmstudio" }
5628
+ body: { error: "type is required and must be one of: anthropic, ollama, lmstudio" }
5429
5629
  };
5430
5630
  }
5431
5631
  const baseUrl = body?.baseUrl;
@@ -5437,7 +5637,7 @@ async function handleTestProvider(req) {
5437
5637
  } else if (type === "lmstudio") {
5438
5638
  result = await testLocalProvider(new LmStudioBackend({ base_url: baseUrl }), "LM Studio", LmStudioBackend.DEFAULT_BASE_URL, baseUrl);
5439
5639
  } else {
5440
- result = testCloud();
5640
+ result = testAnthropic();
5441
5641
  }
5442
5642
  } catch (err) {
5443
5643
  result = { ok: false, error: String(err) };
@@ -5449,11 +5649,30 @@ async function handleTestProvider(req) {
5449
5649
  }
5450
5650
  async function detectLocalProviderInfo(type, defaultBaseUrl) {
5451
5651
  const status = await checkLocalProvider(type);
5452
- const models = status.models.filter((m) => !/-ctx\d+/.test(m));
5652
+ const variantFiltered = status.models.filter((m) => !/-ctx\d+/.test(m));
5653
+ const models = filterLlmModels(variantFiltered);
5453
5654
  return { type, available: status.available, baseUrl: defaultBaseUrl, models };
5454
5655
  }
5455
- async function detectCloud() {
5456
- return { type: "cloud", available: true, models: ANTHROPIC_MODELS };
5656
+ async function detectAnthropic() {
5657
+ const now = Date.now();
5658
+ if (anthropicModelsCache && now - anthropicModelsCache.ts < ANTHROPIC_MODELS_CACHE_TTL_MS) {
5659
+ return { type: "anthropic", available: true, models: anthropicModelsCache.models };
5660
+ }
5661
+ let models = ANTHROPIC_MODELS;
5662
+ try {
5663
+ const client = new Anthropic();
5664
+ const response = await client.models.list(
5665
+ { limit: 50 },
5666
+ { timeout: ANTHROPIC_MODELS_TIMEOUT_MS }
5667
+ );
5668
+ const liveModels = response.data.map((m) => m.id).filter((id) => id.startsWith("claude-"));
5669
+ if (liveModels.length > 0) {
5670
+ models = liveModels;
5671
+ }
5672
+ } catch {
5673
+ }
5674
+ anthropicModelsCache = { ts: now, models };
5675
+ return { type: "anthropic", available: true, models };
5457
5676
  }
5458
5677
  async function testLocalProvider(backend, label, defaultBaseUrl, baseUrl) {
5459
5678
  const available = await backend.isAvailable();
@@ -5462,7 +5681,7 @@ async function testLocalProvider(backend, label, defaultBaseUrl, baseUrl) {
5462
5681
  }
5463
5682
  return { ok: true };
5464
5683
  }
5465
- function testCloud() {
5684
+ function testAnthropic() {
5466
5685
  return { ok: true };
5467
5686
  }
5468
5687
 
@@ -5523,7 +5742,7 @@ async function registerScheduledTasks(powerManager, deps) {
5523
5742
  logger.info(LOG_KINDS.AGENT_RUN, "Scheduled agent tasks disabled globally (agent.scheduled_tasks_enabled: false)");
5524
5743
  return;
5525
5744
  }
5526
- const { loadAllTasks: loadAllTasks2 } = await import("./registry-SPKP2WLI.js");
5745
+ const { loadAllTasks: loadAllTasks2 } = await import("./registry-O2NZLO3V.js");
5527
5746
  const allTasks = Array.from(loadAllTasks2(definitionsDir, vaultDir).values());
5528
5747
  const initialLastRuns = {};
5529
5748
  try {
@@ -5545,7 +5764,7 @@ async function registerScheduledTasks(powerManager, deps) {
5545
5764
  else runningTasks.delete(name);
5546
5765
  },
5547
5766
  runTask: async (taskName) => {
5548
- const { runAgent } = await import("./executor-YOKYS7OT.js");
5767
+ const { runAgent } = await import("./executor-NSPRTH4M.js");
5549
5768
  const taskConfig = config.agent.tasks?.[taskName];
5550
5769
  const built = buildTaskInstruction(taskName, taskConfig?.params);
5551
5770
  if (isInstructionRequiredTask(taskName) && !built) {
@@ -5714,7 +5933,7 @@ function createMcpProxyHandlers(deps) {
5714
5933
  name: USER_AGENT_NAME,
5715
5934
  created_at: now
5716
5935
  });
5717
- const { insertResolutionEvent } = await import("./resolution-events-CLDXZF67.js");
5936
+ const { insertResolutionEvent } = await import("./resolution-events-XWYLLDRK.js");
5718
5937
  const resolutionId = `res-${randomBytes(RESOLUTION_ID_RANDOM_BYTES).toString("hex")}`;
5719
5938
  insertResolutionEvent({
5720
5939
  id: resolutionId,
@@ -5806,12 +6025,21 @@ function createAgentRunHandlers(deps) {
5806
6025
  const { vaultDir, embeddingManager, logger } = deps;
5807
6026
  async function handleRun(req) {
5808
6027
  const { task, instruction: rawInstruction, agentId } = AgentRunBody.parse(req.body);
6028
+ const mycoConfig = loadConfig(vaultDir);
6029
+ if (!hasConfiguredProvider(mycoConfig, task)) {
6030
+ return {
6031
+ status: 400,
6032
+ body: {
6033
+ ok: false,
6034
+ error: "No agent provider configured. Configure one in Settings."
6035
+ }
6036
+ };
6037
+ }
5809
6038
  let instruction = rawInstruction;
5810
6039
  let runContext;
5811
6040
  if (task && !instruction) {
5812
6041
  let built;
5813
6042
  try {
5814
- const mycoConfig = loadConfig(vaultDir);
5815
6043
  const taskParams = mycoConfig.agent.tasks?.[task]?.params;
5816
6044
  built = buildTaskInstruction(task, taskParams);
5817
6045
  } catch {
@@ -5830,7 +6058,7 @@ function createAgentRunHandlers(deps) {
5830
6058
  };
5831
6059
  }
5832
6060
  }
5833
- const { runAgent } = await import("./executor-YOKYS7OT.js");
6061
+ const { runAgent } = await import("./executor-NSPRTH4M.js");
5834
6062
  const resultPromise = runAgent(vaultDir, {
5835
6063
  task,
5836
6064
  instruction,
@@ -5899,8 +6127,8 @@ function createAgentRunHandlers(deps) {
5899
6127
  }
5900
6128
 
5901
6129
  // src/daemon/api/attachments.ts
5902
- import fs15 from "fs";
5903
- import path15 from "path";
6130
+ import fs16 from "fs";
6131
+ import path16 from "path";
5904
6132
  var ATTACHMENT_MEDIA_TYPES = {
5905
6133
  png: "image/png",
5906
6134
  jpg: "image/jpeg",
@@ -5920,14 +6148,14 @@ function createAttachmentHandler(deps) {
5920
6148
  const contentType2 = att.media_type ?? "application/octet-stream";
5921
6149
  return { status: 200, headers: { "Content-Type": contentType2 }, body: att.data };
5922
6150
  }
5923
- const filePath = path15.join(vaultDir, "attachments", filename);
6151
+ const filePath = path16.join(vaultDir, "attachments", filename);
5924
6152
  let diskData;
5925
6153
  try {
5926
- diskData = fs15.readFileSync(filePath);
6154
+ diskData = fs16.readFileSync(filePath);
5927
6155
  } catch {
5928
6156
  return { status: 404, body: { error: "not_found" } };
5929
6157
  }
5930
- const ext = path15.extname(filename).slice(1).toLowerCase();
6158
+ const ext = path16.extname(filename).slice(1).toLowerCase();
5931
6159
  const contentType = ATTACHMENT_MEDIA_TYPES[ext] ?? "application/octet-stream";
5932
6160
  return { status: 200, headers: { "Content-Type": contentType }, body: diskData };
5933
6161
  }
@@ -5935,19 +6163,19 @@ function createAttachmentHandler(deps) {
5935
6163
  }
5936
6164
 
5937
6165
  // src/daemon/log-reconcile.ts
5938
- import fs16 from "fs";
5939
- import path16 from "path";
6166
+ import fs17 from "fs";
6167
+ import path17 from "path";
5940
6168
  function reconcileLogBuffer(logDir, sinceTimestamp) {
5941
6169
  let replayed = 0;
5942
6170
  const files = [];
5943
6171
  for (let i = 3; i >= 1; i--) {
5944
- const rotated = path16.join(logDir, `daemon.${i}.log`);
5945
- if (fs16.existsSync(rotated)) files.push(rotated);
6172
+ const rotated = path17.join(logDir, `daemon.${i}.log`);
6173
+ if (fs17.existsSync(rotated)) files.push(rotated);
5946
6174
  }
5947
- const current = path16.join(logDir, "daemon.log");
5948
- if (fs16.existsSync(current)) files.push(current);
6175
+ const current = path17.join(logDir, "daemon.log");
6176
+ if (fs17.existsSync(current)) files.push(current);
5949
6177
  for (const file of files) {
5950
- const content = fs16.readFileSync(file, "utf-8");
6178
+ const content = fs17.readFileSync(file, "utf-8");
5951
6179
  for (const line of content.split("\n")) {
5952
6180
  if (!line.trim()) continue;
5953
6181
  try {
@@ -6226,8 +6454,8 @@ function registerPowerJobs(powerManager, deps) {
6226
6454
  }
6227
6455
 
6228
6456
  // src/daemon/reconciliation.ts
6229
- import fs17 from "fs";
6230
- import path17 from "path";
6457
+ import fs18 from "fs";
6458
+ import path18 from "path";
6231
6459
 
6232
6460
  // src/daemon/event-handlers.ts
6233
6461
  var TOOL_INPUT_STORE_LIMIT = 4e3;
@@ -6396,10 +6624,10 @@ function createReconciler({ bufferDir, logger }) {
6396
6624
  function reconcileSession(sessionId) {
6397
6625
  if (reconciledSessions.has(sessionId)) return;
6398
6626
  reconciledSessions.add(sessionId);
6399
- const bufferPath = path17.join(bufferDir, `${sessionId}.jsonl`);
6627
+ const bufferPath = path18.join(bufferDir, `${sessionId}.jsonl`);
6400
6628
  let content;
6401
6629
  try {
6402
- content = fs17.readFileSync(bufferPath, "utf-8").trim();
6630
+ content = fs18.readFileSync(bufferPath, "utf-8").trim();
6403
6631
  } catch {
6404
6632
  return;
6405
6633
  }
@@ -6468,7 +6696,7 @@ function createReconciler({ bufferDir, logger }) {
6468
6696
  }
6469
6697
 
6470
6698
  // src/daemon/stop-processing.ts
6471
- import fs18 from "fs";
6699
+ import fs19 from "fs";
6472
6700
 
6473
6701
  // src/daemon/capture-images.ts
6474
6702
  var SESSION_SHORT_LEN = 6;
@@ -6574,14 +6802,14 @@ function createStopProcessor(deps) {
6574
6802
  const StopBody = external_exports.object({
6575
6803
  session_id: external_exports.string(),
6576
6804
  user: external_exports.string().optional(),
6577
- transcript_path: external_exports.string().optional(),
6578
- last_assistant_message: external_exports.string().optional()
6805
+ transcript_path: external_exports.string().nullish(),
6806
+ last_assistant_message: external_exports.string().nullish()
6579
6807
  });
6580
6808
  async function triggerTitleSummary(sessionId) {
6581
6809
  if (config.agent.summary_batch_interval <= 0) return;
6582
6810
  if (config.agent.event_tasks_enabled === false) return;
6583
6811
  try {
6584
- const { runAgent } = await import("./executor-YOKYS7OT.js");
6812
+ const { runAgent } = await import("./executor-NSPRTH4M.js");
6585
6813
  runAgent(vaultDir, {
6586
6814
  task: "title-summary",
6587
6815
  instruction: `Process session ${sessionId} only`,
@@ -6671,7 +6899,7 @@ function createStopProcessor(deps) {
6671
6899
  let transcriptText = null;
6672
6900
  if (hookTranscriptPath) {
6673
6901
  try {
6674
- transcriptText = fs18.readFileSync(hookTranscriptPath, "utf-8");
6902
+ transcriptText = fs19.readFileSync(hookTranscriptPath, "utf-8");
6675
6903
  } catch {
6676
6904
  }
6677
6905
  }
@@ -6736,11 +6964,18 @@ function createStopProcessor(deps) {
6736
6964
  }
6737
6965
  const handleStopRoute = async (req) => {
6738
6966
  const { session_id: sessionId, user, transcript_path: hookTranscriptPath, last_assistant_message: lastAssistantMessage } = StopBody.parse(req.body);
6739
- if (!registry.getSession(sessionId)) {
6967
+ const existingSessionMeta = registry.getSession(sessionId);
6968
+ if (!hookTranscriptPath && !existingSessionMeta) {
6969
+ logger.info(LOG_KINDS.HOOKS_STOP, "Stop ignored \u2014 ephemeral sub-invocation", {
6970
+ session_id: sessionId
6971
+ });
6972
+ return { body: { ok: true, ignored: "ephemeral-sub-invocation" } };
6973
+ }
6974
+ if (!existingSessionMeta) {
6740
6975
  registry.register(sessionId, { started_at: (/* @__PURE__ */ new Date()).toISOString() });
6741
6976
  logger.debug(LOG_KINDS.LIFECYCLE_AUTO_REGISTER, "Auto-registered session from stop event", { session_id: sessionId });
6742
6977
  }
6743
- const sessionMeta = registry.getSession(sessionId);
6978
+ const sessionMeta = existingSessionMeta ?? registry.getSession(sessionId);
6744
6979
  logger.info(LOG_KINDS.HOOKS_STOP, "Stop received", {
6745
6980
  session_id: sessionId,
6746
6981
  has_transcript_path: !!hookTranscriptPath,
@@ -6751,7 +6986,9 @@ function createStopProcessor(deps) {
6751
6986
  transcript_path: hookTranscriptPath ?? null,
6752
6987
  last_message_preview: lastAssistantMessage?.slice(0, LOG_MESSAGE_PREVIEW_CHARS) ?? null
6753
6988
  });
6754
- const run = () => processStopEvent(sessionId, user, sessionMeta, hookTranscriptPath, lastAssistantMessage).catch((err) => {
6989
+ const normalizedTranscriptPath = hookTranscriptPath ?? void 0;
6990
+ const normalizedAssistantMessage = lastAssistantMessage ?? void 0;
6991
+ const run = () => processStopEvent(sessionId, user, sessionMeta, normalizedTranscriptPath, normalizedAssistantMessage).catch((err) => {
6755
6992
  logger.error(LOG_KINDS.PROCESSOR_SESSION, "Stop processing failed", { session_id: sessionId, error: err.message });
6756
6993
  });
6757
6994
  const prev = activeStopProcessing ?? Promise.resolve();
@@ -6771,13 +7008,13 @@ function createStopProcessor(deps) {
6771
7008
  }
6772
7009
 
6773
7010
  // src/daemon/event-dispatch.ts
6774
- import fs19 from "fs";
6775
- import path19 from "path";
7011
+ import fs20 from "fs";
7012
+ import path20 from "path";
6776
7013
 
6777
7014
  // src/daemon/plan-capture.ts
6778
7015
  import { createHash as createHash4 } from "crypto";
6779
7016
  import os7 from "os";
6780
- import path18 from "path";
7017
+ import path19 from "path";
6781
7018
  var FILE_WRITE_TOOLS = /* @__PURE__ */ new Set([
6782
7019
  "Write",
6783
7020
  "Edit",
@@ -6790,11 +7027,11 @@ var FILE_WRITE_TOOLS = /* @__PURE__ */ new Set([
6790
7027
  var HEADING_REGEX = /^#\s+(.+)$/m;
6791
7028
  var PLAN_ID_HASH_LENGTH = 16;
6792
7029
  function isInPlanDirectory(filePath, watchDirs, projectRoot) {
6793
- const abs = path18.isAbsolute(filePath) ? filePath : path18.resolve(projectRoot, filePath);
7030
+ const abs = path19.isAbsolute(filePath) ? filePath : path19.resolve(projectRoot, filePath);
6794
7031
  return watchDirs.some((dir) => {
6795
- const expanded = dir.startsWith("~/") ? path18.join(os7.homedir(), dir.slice(2)) : dir;
6796
- const absDir = path18.isAbsolute(expanded) ? expanded : path18.resolve(projectRoot, expanded);
6797
- const prefix = absDir.endsWith(path18.sep) ? absDir : absDir + path18.sep;
7032
+ const expanded = dir.startsWith("~/") ? path19.join(os7.homedir(), dir.slice(2)) : dir;
7033
+ const absDir = path19.isAbsolute(expanded) ? expanded : path19.resolve(projectRoot, expanded);
7034
+ const prefix = absDir.endsWith(path19.sep) ? absDir : absDir + path19.sep;
6798
7035
  return abs === absDir || abs.startsWith(prefix);
6799
7036
  });
6800
7037
  }
@@ -6804,7 +7041,7 @@ function isPlanWriteEvent(toolName, toolInput, config) {
6804
7041
  if (typeof filePath !== "string") return null;
6805
7042
  if (!isInPlanDirectory(filePath, config.watchDirs, config.projectRoot)) return null;
6806
7043
  if (config.extensions?.length) {
6807
- const ext = path18.extname(filePath).toLowerCase();
7044
+ const ext = path19.extname(filePath).toLowerCase();
6808
7045
  if (!config.extensions.includes(ext)) return null;
6809
7046
  }
6810
7047
  return filePath;
@@ -6818,7 +7055,7 @@ function capturePlan(input) {
6818
7055
  const now = Math.floor(Date.now() / 1e3);
6819
7056
  const contentHash = createHash4(CONTENT_HASH_ALGORITHM).update(input.content).digest("hex");
6820
7057
  const id = createHash4("md5").update(input.sourcePath).digest("hex").slice(0, PLAN_ID_HASH_LENGTH);
6821
- const title = parsePlanTitle(input.content, path18.basename(input.sourcePath));
7058
+ const title = parsePlanTitle(input.content, path19.basename(input.sourcePath));
6822
7059
  return upsertPlan({
6823
7060
  id,
6824
7061
  title,
@@ -6872,7 +7109,7 @@ function createEventDispatcher(deps) {
6872
7109
  reconcileSession(event.session_id);
6873
7110
  }
6874
7111
  if (!sessionBuffers.has(event.session_id)) {
6875
- const bufferDir = path19.join(vaultDir, "buffer");
7112
+ const bufferDir = path20.join(vaultDir, "buffer");
6876
7113
  sessionBuffers.set(event.session_id, new EventBuffer(bufferDir, event.session_id));
6877
7114
  }
6878
7115
  sessionBuffers.get(event.session_id).append(event);
@@ -6926,10 +7163,10 @@ function createEventDispatcher(deps) {
6926
7163
  );
6927
7164
  if (planFilePath) {
6928
7165
  const captureSessionId = event.session_id;
6929
- fs19.promises.readFile(planFilePath, "utf-8").then((planContent) => {
7166
+ fs20.promises.readFile(planFilePath, "utf-8").then((planContent) => {
6930
7167
  const latestBatch = getLatestBatch(captureSessionId);
6931
7168
  capturePlan({
6932
- sourcePath: path19.relative(projectRoot, planFilePath),
7169
+ sourcePath: path20.relative(projectRoot, planFilePath),
6933
7170
  content: planContent,
6934
7171
  sessionId: captureSessionId,
6935
7172
  promptBatchId: latestBatch?.id ?? null
@@ -7071,14 +7308,14 @@ function createEventDispatcher(deps) {
7071
7308
  }
7072
7309
 
7073
7310
  // src/daemon/main.ts
7074
- import fs20 from "fs";
7311
+ import fs21 from "fs";
7075
7312
  import os8 from "os";
7076
- import path20 from "path";
7313
+ import path21 from "path";
7077
7314
  function killStaleDaemon(vaultDir, logger) {
7078
- const daemonJsonPath = path20.join(vaultDir, "daemon.json");
7315
+ const daemonJsonPath = path21.join(vaultDir, "daemon.json");
7079
7316
  try {
7080
- if (!fs20.existsSync(daemonJsonPath)) return;
7081
- const info = JSON.parse(fs20.readFileSync(daemonJsonPath, "utf-8"));
7317
+ if (!fs21.existsSync(daemonJsonPath)) return;
7318
+ const info = JSON.parse(fs21.readFileSync(daemonJsonPath, "utf-8"));
7082
7319
  if (!info.pid) return;
7083
7320
  if (info.pid === process.pid) return;
7084
7321
  try {
@@ -7087,7 +7324,7 @@ function killStaleDaemon(vaultDir, logger) {
7087
7324
  logger.info(LOG_KINDS.DAEMON_START, "Killed stale daemon", { pid: info.pid });
7088
7325
  } catch {
7089
7326
  }
7090
- fs20.unlinkSync(daemonJsonPath);
7327
+ fs21.unlinkSync(daemonJsonPath);
7091
7328
  } catch {
7092
7329
  }
7093
7330
  }
@@ -7097,7 +7334,7 @@ async function main() {
7097
7334
  process.stderr.write("Usage: mycod --vault <path>\n");
7098
7335
  process.exit(1);
7099
7336
  }
7100
- const vaultDir = path20.resolve(vaultArg);
7337
+ const vaultDir = path21.resolve(vaultArg);
7101
7338
  loadSecrets(vaultDir);
7102
7339
  const config = loadConfig(vaultDir);
7103
7340
  const manifests = loadManifests();
@@ -7108,7 +7345,7 @@ async function main() {
7108
7345
  projectRoot,
7109
7346
  extensions: config.capture.artifact_extensions
7110
7347
  };
7111
- const logger = new DaemonLogger(path20.join(vaultDir, "logs"), {
7348
+ const logger = new DaemonLogger(path21.join(vaultDir, "logs"), {
7112
7349
  level: config.daemon.log_level
7113
7350
  });
7114
7351
  if (config.daemon.log_level === "debug") {
@@ -7122,10 +7359,63 @@ async function main() {
7122
7359
  logger.info(LOG_KINDS.CAPTURE_PLAN, "Plan watch directories", { dirs: planWatchConfig.watchDirs });
7123
7360
  const machineId = getMachineId(vaultDir);
7124
7361
  logger.info(LOG_KINDS.DAEMON_START, "Machine ID resolved", { machine_id: machineId });
7362
+ let globalPrefix = null;
7363
+ try {
7364
+ globalPrefix = resolveGlobalPrefix();
7365
+ logger.debug(LOG_KINDS.DAEMON_START, "npm global prefix resolved", { prefix: globalPrefix });
7366
+ } catch (err) {
7367
+ logger.warn(LOG_KINDS.DAEMON_START, "Failed to resolve npm global prefix", {
7368
+ error: err.message
7369
+ });
7370
+ }
7371
+ const devCliEntry = detectDevBuild(
7372
+ globalPrefix,
7373
+ process.argv[1],
7374
+ fs21.realpathSync
7375
+ );
7376
+ if (devCliEntry) {
7377
+ setDevBuildCliEntry(devCliEntry);
7378
+ globalPrefix = null;
7379
+ logger.info(LOG_KINDS.DAEMON_START, "Dev build detected; update checks exempted", {
7380
+ cli_entry: devCliEntry
7381
+ });
7382
+ }
7125
7383
  const db = initDatabase(vaultDbPath(vaultDir));
7126
7384
  createSchema(db, machineId);
7127
7385
  registerBuiltinDomains();
7128
7386
  logger.info(LOG_KINDS.DAEMON_START, "SQLite initialized", { vault: vaultDir });
7387
+ {
7388
+ const reasonPath = path21.join(vaultDir, RESTART_REASON_FILENAME);
7389
+ try {
7390
+ if (fs21.existsSync(reasonPath)) {
7391
+ const raw = JSON.parse(fs21.readFileSync(reasonPath, "utf-8"));
7392
+ fs21.unlinkSync(reasonPath);
7393
+ if (raw.reason === "version_sync" && raw.to_version) {
7394
+ const message = raw.local_update_ran ? "Restarted and updated local project hooks." : "Restarted to pick up the latest version.";
7395
+ notify(vaultDir, {
7396
+ domain: "daemon",
7397
+ type: "daemon.version_sync",
7398
+ title: `Updated to v${raw.to_version}`,
7399
+ message,
7400
+ metadata: {
7401
+ from_version: raw.from_version ?? "unknown",
7402
+ to_version: raw.to_version,
7403
+ local_update_ran: raw.local_update_ran ?? false
7404
+ }
7405
+ });
7406
+ logger.info(LOG_KINDS.DAEMON_START, "Version sync restart detected", {
7407
+ from: raw.from_version,
7408
+ to: raw.to_version,
7409
+ local_update: raw.local_update_ran
7410
+ });
7411
+ }
7412
+ }
7413
+ } catch (err) {
7414
+ logger.warn(LOG_KINDS.DAEMON_START, "Failed to read restart-reason file", {
7415
+ error: err.message
7416
+ });
7417
+ }
7418
+ }
7129
7419
  initTeamContext(config.team.enabled, machineId);
7130
7420
  logger.setPersistFn((entry) => {
7131
7421
  const { timestamp, level, kind, component, message, ...rest } = entry;
@@ -7141,13 +7431,13 @@ async function main() {
7141
7431
  });
7142
7432
  const lastLogTimestamp = getMaxTimestamp();
7143
7433
  if (lastLogTimestamp) {
7144
- const logDir = path20.join(vaultDir, "logs");
7434
+ const logDir = path21.join(vaultDir, "logs");
7145
7435
  const replayedCount = reconcileLogBuffer(logDir, lastLogTimestamp);
7146
7436
  if (replayedCount > 0) {
7147
7437
  logger.info(LOG_KINDS.DAEMON_RECONCILE, `Replayed ${replayedCount} log entries from buffer`, { replayed: replayedCount });
7148
7438
  }
7149
7439
  }
7150
- const vectorsDbPath = path20.join(vaultDir, "vectors.db");
7440
+ const vectorsDbPath = path21.join(vaultDir, "vectors.db");
7151
7441
  const vectorStore = new SqliteVecVectorStore(vectorsDbPath);
7152
7442
  const llmProvider = createEmbeddingProvider(config.embedding);
7153
7443
  const embeddingProvider = new EmbeddingProviderAdapter(llmProvider, config.embedding);
@@ -7157,7 +7447,7 @@ async function main() {
7157
7447
  const databaseManager = new DatabaseMaintenanceManager(vaultDbPath(vaultDir), vaultDir, logger);
7158
7448
  let definitionsDir;
7159
7449
  try {
7160
- const { registerBuiltInAgentsAndTasks, resolveDefinitionsDir: resolveDefinitionsDir2 } = await import("./loader-J56KP27U.js");
7450
+ const { registerBuiltInAgentsAndTasks, resolveDefinitionsDir: resolveDefinitionsDir2 } = await import("./loader-SKKUMT5C.js");
7161
7451
  definitionsDir = resolveDefinitionsDir2();
7162
7452
  await registerBuiltInAgentsAndTasks(definitionsDir, vaultDir);
7163
7453
  logger.info(LOG_KINDS.AGENT_TASK, "Built-in agents and tasks registered");
@@ -7183,10 +7473,10 @@ async function main() {
7183
7473
  }
7184
7474
  let uiDir = null;
7185
7475
  {
7186
- const root = findPackageRoot(path20.dirname(new URL(import.meta.url).pathname));
7476
+ const root = findPackageRoot(path21.dirname(new URL(import.meta.url).pathname));
7187
7477
  if (root) {
7188
- const candidate = path20.join(root, "dist", "ui");
7189
- if (fs20.existsSync(candidate)) uiDir = candidate;
7478
+ const candidate = path21.join(root, "dist", "ui");
7479
+ if (fs21.existsSync(candidate)) uiDir = candidate;
7190
7480
  }
7191
7481
  }
7192
7482
  if (uiDir) {
@@ -7219,7 +7509,7 @@ async function main() {
7219
7509
  (p) => createPerProjectAdapter(p, claudeCodeAdapter.parseTurns)
7220
7510
  )
7221
7511
  });
7222
- const bufferDir = path20.join(vaultDir, "buffer");
7512
+ const bufferDir = path21.join(vaultDir, "buffer");
7223
7513
  const sessionBuffers = /* @__PURE__ */ new Map();
7224
7514
  const reconciler = createReconciler({ bufferDir, logger });
7225
7515
  reconciler.runStartupReconciliation();
@@ -7305,11 +7595,12 @@ async function main() {
7305
7595
  server.registerRoute("POST", "/api/log", createLogIngestionHandler(logger));
7306
7596
  server.registerRoute("GET", "/api/models", async (req) => handleGetModels(req));
7307
7597
  server.registerRoute("POST", "/api/restart", async (req) => handleRestart({ vaultDir, progressTracker }, req.body));
7308
- const updateProjectRoot = path20.dirname(vaultDir);
7598
+ const updateProjectRoot = path21.dirname(vaultDir);
7309
7599
  const updateHandlers = createUpdateHandlers({
7310
7600
  vaultDir,
7311
7601
  projectRoot: updateProjectRoot,
7312
7602
  currentVersion: server.version,
7603
+ globalPrefix,
7313
7604
  scheduleShutdown: () => {
7314
7605
  setTimeout(() => {
7315
7606
  process.kill(process.pid, "SIGTERM");
@@ -7369,7 +7660,7 @@ async function main() {
7369
7660
  server.registerRoute("GET", "/api/mcp/sessions", mcpProxy.handleSessions);
7370
7661
  server.registerRoute("GET", "/api/mcp/team", mcpProxy.handleTeam);
7371
7662
  const rawBackupDir = config.backup.dir;
7372
- const backupDir = rawBackupDir ? path20.resolve(rawBackupDir.startsWith("~/") ? path20.join(os8.homedir(), rawBackupDir.slice(2)) : rawBackupDir) : path20.resolve(vaultDir, "backups");
7663
+ const backupDir = rawBackupDir ? path21.resolve(rawBackupDir.startsWith("~/") ? path21.join(os8.homedir(), rawBackupDir.slice(2)) : rawBackupDir) : path21.resolve(vaultDir, "backups");
7373
7664
  const backupHandlers = createBackupHandlers({ db, backupDir, machineId });
7374
7665
  server.registerRoute("POST", "/api/backup", backupHandlers.handleCreateBackup);
7375
7666
  server.registerRoute("GET", "/api/backups", backupHandlers.handleListBackups);
@@ -7382,6 +7673,7 @@ async function main() {
7382
7673
  const teamHandlers = createTeamHandlers({
7383
7674
  vaultDir,
7384
7675
  machineId,
7676
+ logger,
7385
7677
  getTeamClient: teamSync.getTeamClient,
7386
7678
  setTeamClient: teamSync.setTeamClient
7387
7679
  });
@@ -7391,6 +7683,7 @@ async function main() {
7391
7683
  server.registerRoute("POST", "/api/team/backfill", teamHandlers.handleBackfill);
7392
7684
  server.registerRoute("POST", "/api/team/retry-failed", teamHandlers.handleRetryFailed);
7393
7685
  server.registerRoute("POST", "/api/team/upgrade-worker", teamHandlers.handleUpgradeWorker);
7686
+ server.registerRoute("POST", "/api/team/rotate-mcp-token", teamHandlers.handleRotateMcpToken);
7394
7687
  server.registerRoute("GET", "/api/search", createSearchHandler({ embeddingManager, getTeamClient: teamSync.getTeamClient, machineId }));
7395
7688
  server.registerRoute("GET", "/api/activity", handleGetFeed);
7396
7689
  server.registerRoute("GET", "/api/embedding/status", async () => handleGetEmbeddingStatus(vaultDir));
@@ -7463,4 +7756,4 @@ export {
7463
7756
  handleUserPrompt,
7464
7757
  main
7465
7758
  };
7466
- //# sourceMappingURL=main-6DGPZXRF.js.map
7759
+ //# sourceMappingURL=main-6PY3ITQ5.js.map