@goondocks/myco 0.17.2 → 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 (182) hide show
  1. package/README.md +14 -22
  2. package/bin/myco-run +15 -2
  3. package/dist/{agent-run-7AYHXIEF.js → agent-run-2NFYMQXW.js} +7 -7
  4. package/dist/{agent-tasks-UUIFKBD4.js → agent-tasks-MEIYLXGN.js} +7 -7
  5. package/dist/{chunk-XD3NEN3Q.js → chunk-2V7HR7HB.js} +2 -2
  6. package/dist/{chunk-CTF7TQMJ.js → chunk-55QEICRO.js} +14 -4
  7. package/dist/chunk-55QEICRO.js.map +1 -0
  8. package/dist/{chunk-DT42247G.js → chunk-75AZFBFW.js} +3 -3
  9. package/dist/{chunk-ZSJPI5MS.js → chunk-7OYXB2NM.js} +2 -2
  10. package/dist/{chunk-XZWFMMJR.js → chunk-BUIR3JWM.js} +3 -3
  11. package/dist/{chunk-7DAH5GLC.js → chunk-CKJAWZQE.js} +5 -1
  12. package/dist/chunk-CKJAWZQE.js.map +1 -0
  13. package/dist/{chunk-ML6GTPZU.js → chunk-CML4MCYF.js} +2 -2
  14. package/dist/{chunk-BZDZORVP.js → chunk-DLFDBKEV.js} +4 -4
  15. package/dist/{chunk-SI5BBQAT.js → chunk-EO2RQW4S.js} +2 -2
  16. package/dist/{chunk-EBIYONNZ.js → chunk-FABWUX5G.js} +20 -2
  17. package/dist/chunk-FABWUX5G.js.map +1 -0
  18. package/dist/{chunk-RMJPQZGF.js → chunk-JDI4DPWD.js} +127 -125
  19. package/dist/chunk-JDI4DPWD.js.map +1 -0
  20. package/dist/chunk-JMOUFG6Y.js +65 -0
  21. package/dist/chunk-JMOUFG6Y.js.map +1 -0
  22. package/dist/{chunk-HPZ7YAMA.js → chunk-KWTOCJLB.js} +3 -3
  23. package/dist/{chunk-F6C4IC6R.js → chunk-NI23QCHB.js} +3 -3
  24. package/dist/{chunk-IGBHLFV5.js → chunk-NZI7WBZI.js} +2 -2
  25. package/dist/{chunk-C3C5QVLK.js → chunk-O3TRN3RC.js} +2 -2
  26. package/dist/{chunk-UTLWSKDV.js → chunk-OW433Q4C.js} +2 -2
  27. package/dist/{chunk-5ZISXCDC.js → chunk-PFWIPRF6.js} +39 -5
  28. package/dist/chunk-PFWIPRF6.js.map +1 -0
  29. package/dist/{chunk-3NCVCGUZ.js → chunk-RAV5YMRU.js} +3 -3
  30. package/dist/{chunk-RKPTMHED.js → chunk-U3J2DDSR.js} +2 -2
  31. package/dist/{chunk-25WHTV4N.js → chunk-U7GJTVSX.js} +2 -2
  32. package/dist/{chunk-NUSTG3BH.js → chunk-VOCGURV7.js} +3 -3
  33. package/dist/{chunk-VVGZL2HX.js → chunk-WYOE4IAX.js} +153 -15
  34. package/dist/{chunk-VVGZL2HX.js.map → chunk-WYOE4IAX.js.map} +1 -1
  35. package/dist/{cli-WJVYP2QT.js → cli-IIMBALPV.js} +40 -40
  36. package/dist/{client-LZ3ZR4HC.js → client-VZCUISHZ.js} +4 -4
  37. package/dist/{config-ZQIMG3FB.js → config-DA4IUVFL.js} +3 -3
  38. package/dist/{detect-NJ2OREDP.js → detect-GEM3NVK6.js} +2 -2
  39. package/dist/{detect-providers-C64L3QET.js → detect-providers-PSVKXTWE.js} +4 -4
  40. package/dist/{doctor-XEPBNHM3.js → doctor-QYD34X7Q.js} +12 -12
  41. package/dist/{executor-NXKJU5KW.js → executor-NSPRTH4M.js} +17 -17
  42. package/dist/{init-BHVQAQ27.js → init-WYYL44KZ.js} +13 -13
  43. package/dist/{installer-45ZLP2RP.js → installer-BWJED3ED.js} +2 -2
  44. package/dist/{llm-KTD6SR55.js → llm-KEDHK3TQ.js} +4 -4
  45. package/dist/{loader-SHRKUKOS.js → loader-Q3P3R4UP.js} +3 -3
  46. package/dist/{loader-NEX3UF6U.js → loader-SKKUMT5C.js} +3 -3
  47. package/dist/{main-YFVBIRRK.js → main-6PY3ITQ5.js} +388 -125
  48. package/dist/main-6PY3ITQ5.js.map +1 -0
  49. package/dist/{open-2U7ZRGA3.js → open-HRFMJDQX.js} +7 -7
  50. package/dist/{post-compact-QIBMEWL3.js → post-compact-HT24YMAN.js} +7 -7
  51. package/dist/{post-tool-use-ICGFXDVY.js → post-tool-use-DENRI5WB.js} +6 -6
  52. package/dist/{post-tool-use-failure-C7TLH3XQ.js → post-tool-use-failure-A6SNJX42.js} +7 -7
  53. package/dist/{pre-compact-IF7K4TQK.js → pre-compact-3Q4BALCL.js} +7 -7
  54. package/dist/{provider-check-LTLQ6BUZ.js → provider-check-AE3L5Z6R.js} +4 -4
  55. package/dist/{registry-TFQ22Z7N.js → registry-O2NZLO3V.js} +4 -4
  56. package/dist/{remove-FBGM2QVJ.js → remove-YB5A6HY2.js} +9 -9
  57. package/dist/{resolution-events-HGKIJOTA.js → resolution-events-XWYLLDRK.js} +4 -4
  58. package/dist/{restart-TQEECRNW.js → restart-RGDVHELZ.js} +8 -8
  59. package/dist/{search-NN5FC4Z6.js → search-WOHT3G55.js} +8 -8
  60. package/dist/{server-XMWJ4GF7.js → server-6SUNYDV7.js} +4 -4
  61. package/dist/{session-GLPAFYPO.js → session-W3SKRFRV.js} +9 -9
  62. package/dist/{session-end-TI3ILRBC.js → session-end-OUTY7AFF.js} +6 -6
  63. package/dist/{session-start-PJLJDVJJ.js → session-start-5MB3LFOA.js} +24 -13
  64. package/dist/{session-start-PJLJDVJJ.js.map → session-start-5MB3LFOA.js.map} +1 -1
  65. package/dist/{setup-llm-AQSWLXCZ.js → setup-llm-ZMYGIQX5.js} +8 -8
  66. package/dist/src/cli.js +1 -1
  67. package/dist/src/daemon/main.js +1 -1
  68. package/dist/src/hooks/post-tool-use.js +1 -1
  69. package/dist/src/hooks/session-end.js +1 -1
  70. package/dist/src/hooks/session-start.js +1 -1
  71. package/dist/src/hooks/stop.js +1 -1
  72. package/dist/src/hooks/user-prompt-submit.js +1 -1
  73. package/dist/src/mcp/server.js +1 -1
  74. package/dist/src/symbionts/manifests/codex.yaml +47 -0
  75. package/dist/src/symbionts/templates/claude-code/hooks.json +12 -12
  76. package/dist/src/symbionts/templates/claude-code/settings.json +3 -3
  77. package/dist/src/symbionts/templates/codex/hooks.json +4 -4
  78. package/dist/src/symbionts/templates/cursor/hooks.json +9 -9
  79. package/dist/src/symbionts/templates/cursor/settings.json +2 -2
  80. package/dist/src/symbionts/templates/gemini/hooks.json +6 -6
  81. package/dist/src/symbionts/templates/gemini/settings.json +2 -2
  82. package/dist/src/symbionts/templates/myco-run.cjs +44 -0
  83. package/dist/src/symbionts/templates/opencode/settings.json +2 -2
  84. package/dist/src/symbionts/templates/vscode-copilot/hooks.json +7 -7
  85. package/dist/src/symbionts/templates/vscode-copilot/settings.json +2 -2
  86. package/dist/src/symbionts/templates/windsurf/hooks.json +4 -4
  87. package/dist/src/symbionts/templates/windsurf/settings.json +2 -2
  88. package/dist/src/worker/package-lock.json +4338 -0
  89. package/dist/src/worker/package.json +5 -0
  90. package/dist/src/worker/src/index.ts +50 -63
  91. package/dist/src/worker/src/mcp/auth.ts +65 -0
  92. package/dist/src/worker/src/mcp/server.ts +53 -0
  93. package/dist/src/worker/src/mcp/tools/context.ts +13 -0
  94. package/dist/src/worker/src/mcp/tools/get.ts +15 -0
  95. package/dist/src/worker/src/mcp/tools/graph.ts +35 -0
  96. package/dist/src/worker/src/mcp/tools/search.ts +32 -0
  97. package/dist/src/worker/src/mcp/tools/sessions.ts +24 -0
  98. package/dist/src/worker/src/mcp/tools/skills.ts +16 -0
  99. package/dist/src/worker/src/mcp/tools/team.ts +9 -0
  100. package/dist/src/worker/src/schema.ts +3 -1
  101. package/dist/src/worker/src/search-helpers.ts +70 -0
  102. package/dist/src/worker/wrangler.toml +9 -0
  103. package/dist/{stats-BISBIBXZ.js → stats-DGI6B3HX.js} +9 -9
  104. package/dist/{stop-47BJ42EO.js → stop-YGHODSP7.js} +6 -6
  105. package/dist/{stop-failure-VU5BTLWX.js → stop-failure-7IJTPJ6W.js} +7 -7
  106. package/dist/{subagent-start-SPTKQRHU.js → subagent-start-ZBQ5PJB5.js} +7 -7
  107. package/dist/{subagent-stop-UU75BYLC.js → subagent-stop-N2TDQU2D.js} +7 -7
  108. package/dist/{task-completed-MVDO7TZF.js → task-completed-BDLMRSBB.js} +7 -7
  109. package/dist/{team-7X64J4Y6.js → team-2ZFGTSIN.js} +97 -14
  110. package/dist/team-2ZFGTSIN.js.map +1 -0
  111. package/dist/ui/assets/{index-rpmSpJpm.js → index-DtT9_nlT.js} +120 -120
  112. package/dist/ui/index.html +1 -1
  113. package/dist/{update-DA7VEXOS.js → update-STLAN7LR.js} +18 -9
  114. package/dist/update-STLAN7LR.js.map +1 -0
  115. package/dist/{user-prompt-submit-ADZ4NTVO.js → user-prompt-submit-4IBFUYQ3.js} +27 -7
  116. package/dist/user-prompt-submit-4IBFUYQ3.js.map +1 -0
  117. package/dist/{verify-QYSERHF7.js → verify-EJYPO7QA.js} +5 -5
  118. package/dist/{version-A72TAL2J.js → version-YPBIKH77.js} +2 -2
  119. package/package.json +1 -1
  120. package/dist/chunk-5ZISXCDC.js.map +0 -1
  121. package/dist/chunk-7DAH5GLC.js.map +0 -1
  122. package/dist/chunk-CTF7TQMJ.js.map +0 -1
  123. package/dist/chunk-EBIYONNZ.js.map +0 -1
  124. package/dist/chunk-RMJPQZGF.js.map +0 -1
  125. package/dist/main-YFVBIRRK.js.map +0 -1
  126. package/dist/src/symbionts/templates/hook-guard.cjs +0 -19
  127. package/dist/team-7X64J4Y6.js.map +0 -1
  128. package/dist/update-DA7VEXOS.js.map +0 -1
  129. package/dist/user-prompt-submit-ADZ4NTVO.js.map +0 -1
  130. /package/dist/{agent-run-7AYHXIEF.js.map → agent-run-2NFYMQXW.js.map} +0 -0
  131. /package/dist/{agent-tasks-UUIFKBD4.js.map → agent-tasks-MEIYLXGN.js.map} +0 -0
  132. /package/dist/{chunk-XD3NEN3Q.js.map → chunk-2V7HR7HB.js.map} +0 -0
  133. /package/dist/{chunk-DT42247G.js.map → chunk-75AZFBFW.js.map} +0 -0
  134. /package/dist/{chunk-ZSJPI5MS.js.map → chunk-7OYXB2NM.js.map} +0 -0
  135. /package/dist/{chunk-XZWFMMJR.js.map → chunk-BUIR3JWM.js.map} +0 -0
  136. /package/dist/{chunk-ML6GTPZU.js.map → chunk-CML4MCYF.js.map} +0 -0
  137. /package/dist/{chunk-BZDZORVP.js.map → chunk-DLFDBKEV.js.map} +0 -0
  138. /package/dist/{chunk-SI5BBQAT.js.map → chunk-EO2RQW4S.js.map} +0 -0
  139. /package/dist/{chunk-HPZ7YAMA.js.map → chunk-KWTOCJLB.js.map} +0 -0
  140. /package/dist/{chunk-F6C4IC6R.js.map → chunk-NI23QCHB.js.map} +0 -0
  141. /package/dist/{chunk-IGBHLFV5.js.map → chunk-NZI7WBZI.js.map} +0 -0
  142. /package/dist/{chunk-C3C5QVLK.js.map → chunk-O3TRN3RC.js.map} +0 -0
  143. /package/dist/{chunk-UTLWSKDV.js.map → chunk-OW433Q4C.js.map} +0 -0
  144. /package/dist/{chunk-3NCVCGUZ.js.map → chunk-RAV5YMRU.js.map} +0 -0
  145. /package/dist/{chunk-RKPTMHED.js.map → chunk-U3J2DDSR.js.map} +0 -0
  146. /package/dist/{chunk-25WHTV4N.js.map → chunk-U7GJTVSX.js.map} +0 -0
  147. /package/dist/{chunk-NUSTG3BH.js.map → chunk-VOCGURV7.js.map} +0 -0
  148. /package/dist/{cli-WJVYP2QT.js.map → cli-IIMBALPV.js.map} +0 -0
  149. /package/dist/{client-LZ3ZR4HC.js.map → client-VZCUISHZ.js.map} +0 -0
  150. /package/dist/{config-ZQIMG3FB.js.map → config-DA4IUVFL.js.map} +0 -0
  151. /package/dist/{detect-NJ2OREDP.js.map → detect-GEM3NVK6.js.map} +0 -0
  152. /package/dist/{detect-providers-C64L3QET.js.map → detect-providers-PSVKXTWE.js.map} +0 -0
  153. /package/dist/{doctor-XEPBNHM3.js.map → doctor-QYD34X7Q.js.map} +0 -0
  154. /package/dist/{executor-NXKJU5KW.js.map → executor-NSPRTH4M.js.map} +0 -0
  155. /package/dist/{init-BHVQAQ27.js.map → init-WYYL44KZ.js.map} +0 -0
  156. /package/dist/{installer-45ZLP2RP.js.map → installer-BWJED3ED.js.map} +0 -0
  157. /package/dist/{llm-KTD6SR55.js.map → llm-KEDHK3TQ.js.map} +0 -0
  158. /package/dist/{loader-NEX3UF6U.js.map → loader-Q3P3R4UP.js.map} +0 -0
  159. /package/dist/{loader-SHRKUKOS.js.map → loader-SKKUMT5C.js.map} +0 -0
  160. /package/dist/{open-2U7ZRGA3.js.map → open-HRFMJDQX.js.map} +0 -0
  161. /package/dist/{post-compact-QIBMEWL3.js.map → post-compact-HT24YMAN.js.map} +0 -0
  162. /package/dist/{post-tool-use-ICGFXDVY.js.map → post-tool-use-DENRI5WB.js.map} +0 -0
  163. /package/dist/{post-tool-use-failure-C7TLH3XQ.js.map → post-tool-use-failure-A6SNJX42.js.map} +0 -0
  164. /package/dist/{pre-compact-IF7K4TQK.js.map → pre-compact-3Q4BALCL.js.map} +0 -0
  165. /package/dist/{provider-check-LTLQ6BUZ.js.map → provider-check-AE3L5Z6R.js.map} +0 -0
  166. /package/dist/{registry-TFQ22Z7N.js.map → registry-O2NZLO3V.js.map} +0 -0
  167. /package/dist/{remove-FBGM2QVJ.js.map → remove-YB5A6HY2.js.map} +0 -0
  168. /package/dist/{resolution-events-HGKIJOTA.js.map → resolution-events-XWYLLDRK.js.map} +0 -0
  169. /package/dist/{restart-TQEECRNW.js.map → restart-RGDVHELZ.js.map} +0 -0
  170. /package/dist/{search-NN5FC4Z6.js.map → search-WOHT3G55.js.map} +0 -0
  171. /package/dist/{server-XMWJ4GF7.js.map → server-6SUNYDV7.js.map} +0 -0
  172. /package/dist/{session-GLPAFYPO.js.map → session-W3SKRFRV.js.map} +0 -0
  173. /package/dist/{session-end-TI3ILRBC.js.map → session-end-OUTY7AFF.js.map} +0 -0
  174. /package/dist/{setup-llm-AQSWLXCZ.js.map → setup-llm-ZMYGIQX5.js.map} +0 -0
  175. /package/dist/{stats-BISBIBXZ.js.map → stats-DGI6B3HX.js.map} +0 -0
  176. /package/dist/{stop-47BJ42EO.js.map → stop-YGHODSP7.js.map} +0 -0
  177. /package/dist/{stop-failure-VU5BTLWX.js.map → stop-failure-7IJTPJ6W.js.map} +0 -0
  178. /package/dist/{subagent-start-SPTKQRHU.js.map → subagent-start-ZBQ5PJB5.js.map} +0 -0
  179. /package/dist/{subagent-stop-UU75BYLC.js.map → subagent-stop-N2TDQU2D.js.map} +0 -0
  180. /package/dist/{task-completed-MVDO7TZF.js.map → task-completed-BDLMRSBB.js.map} +0 -0
  181. /package/dist/{verify-QYSERHF7.js.map → verify-EJYPO7QA.js.map} +0 -0
  182. /package/dist/{version-A72TAL2J.js.map → version-YPBIKH77.js.map} +0 -0
@@ -15,7 +15,7 @@ import {
15
15
  getEmbeddingQueueDepth,
16
16
  getUnembedded,
17
17
  markEmbedded
18
- } from "./chunk-BZDZORVP.js";
18
+ } from "./chunk-DLFDBKEV.js";
19
19
  import {
20
20
  loadSecrets,
21
21
  readSecrets,
@@ -24,7 +24,7 @@ import {
24
24
  import {
25
25
  Anthropic,
26
26
  createEmbeddingProvider
27
- } from "./chunk-HPZ7YAMA.js";
27
+ } from "./chunk-KWTOCJLB.js";
28
28
  import {
29
29
  buildTaskInstruction,
30
30
  closeOpenBatches,
@@ -72,24 +72,24 @@ import {
72
72
  setResponseSummary,
73
73
  updateCandidate,
74
74
  updateNotificationStatus
75
- } from "./chunk-RMJPQZGF.js";
75
+ } from "./chunk-JDI4DPWD.js";
76
76
  import {
77
77
  fullTextSearch,
78
78
  hydrateSearchResults
79
- } from "./chunk-IGBHLFV5.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-3NCVCGUZ.js";
86
+ } from "./chunk-RAV5YMRU.js";
87
87
  import {
88
88
  AgentTaskSchema,
89
89
  registerAgent,
90
90
  resolveDefinitionsDir,
91
91
  taskFromParsed
92
- } from "./chunk-F6C4IC6R.js";
92
+ } from "./chunk-NI23QCHB.js";
93
93
  import {
94
94
  listTurnsByRun
95
95
  } from "./chunk-QLCD77AN.js";
@@ -106,23 +106,23 @@ import {
106
106
  listBufferSessionIds
107
107
  } from "./chunk-V7XG6V6C.js";
108
108
  import "./chunk-IB76KGBY.js";
109
- import "./chunk-CTF7TQMJ.js";
109
+ import "./chunk-55QEICRO.js";
110
110
  import "./chunk-SAKJMNSR.js";
111
- import "./chunk-VVGZL2HX.js";
111
+ import "./chunk-WYOE4IAX.js";
112
112
  import {
113
113
  checkLocalProvider
114
- } from "./chunk-DT42247G.js";
114
+ } from "./chunk-75AZFBFW.js";
115
115
  import {
116
116
  LmStudioBackend,
117
117
  OllamaBackend
118
- } from "./chunk-ML6GTPZU.js";
118
+ } from "./chunk-CML4MCYF.js";
119
119
  import {
120
120
  countSpores,
121
121
  getSpore,
122
122
  insertSpore,
123
123
  listSpores,
124
124
  updateSporeStatus
125
- } from "./chunk-ZSJPI5MS.js";
125
+ } from "./chunk-7OYXB2NM.js";
126
126
  import {
127
127
  closeSession,
128
128
  countSessions,
@@ -133,7 +133,7 @@ import {
133
133
  listSessions,
134
134
  updateSession,
135
135
  upsertSession
136
- } from "./chunk-25WHTV4N.js";
136
+ } from "./chunk-U7GJTVSX.js";
137
137
  import {
138
138
  backfillUnsynced,
139
139
  countDeadLettered,
@@ -149,13 +149,13 @@ import {
149
149
  pruneOld,
150
150
  retryDeadLettered,
151
151
  syncRow
152
- } from "./chunk-C3C5QVLK.js";
152
+ } from "./chunk-O3TRN3RC.js";
153
153
  import {
154
154
  EMBEDDING_DIMENSIONS,
155
155
  REST_SETTABLE_STATUSES,
156
156
  SCHEMA_VERSION,
157
157
  createSchema
158
- } from "./chunk-UTLWSKDV.js";
158
+ } from "./chunk-OW433Q4C.js";
159
159
  import {
160
160
  CONFIG_FILENAME,
161
161
  MycoConfigSchema,
@@ -164,7 +164,7 @@ import {
164
164
  updateBackupConfig,
165
165
  updateConfig,
166
166
  updateTeamConfig
167
- } from "./chunk-XD3NEN3Q.js";
167
+ } from "./chunk-2V7HR7HB.js";
168
168
  import {
169
169
  closeDatabase,
170
170
  getDatabase,
@@ -173,13 +173,13 @@ import {
173
173
  } from "./chunk-MYX5NCRH.js";
174
174
  import {
175
175
  resolveCliEntryPath
176
- } from "./chunk-XZWFMMJR.js";
176
+ } from "./chunk-BUIR3JWM.js";
177
177
  import {
178
178
  getPluginVersion
179
- } from "./chunk-SI5BBQAT.js";
179
+ } from "./chunk-EO2RQW4S.js";
180
180
  import {
181
181
  loadManifests
182
- } from "./chunk-EBIYONNZ.js";
182
+ } from "./chunk-FABWUX5G.js";
183
183
  import {
184
184
  findPackageRoot
185
185
  } from "./chunk-LPUQPDC2.js";
@@ -213,6 +213,7 @@ import {
213
213
  PROMPT_PREVIEW_CHARS,
214
214
  PROMPT_VECTOR_OVER_FETCH,
215
215
  RELEASE_CHANNELS,
216
+ RESTART_REASON_FILENAME,
216
217
  RESTART_RESPONSE_FLUSH_MS,
217
218
  SEARCH_RESULTS_DEFAULT_LIMIT,
218
219
  SEARCH_SIMILARITY_THRESHOLD,
@@ -228,12 +229,13 @@ import {
228
229
  UPDATE_CONFIG_PATH,
229
230
  UPDATE_ERROR_PATH,
230
231
  UPDATE_SCRIPT_DELAY_SECONDS,
232
+ UPDATE_STAMP_FILENAME,
231
233
  USER_AGENT_ID,
232
234
  USER_AGENT_NAME,
233
235
  USER_TASK_SOURCE,
234
236
  epochSeconds,
235
237
  estimateTokens
236
- } from "./chunk-7DAH5GLC.js";
238
+ } from "./chunk-CKJAWZQE.js";
237
239
  import {
238
240
  LOG_KINDS,
239
241
  kindToComponent
@@ -1601,10 +1603,32 @@ async function handleRestart(deps, body) {
1601
1603
  var import_yaml = __toESM(require_dist(), 1);
1602
1604
  import fs8 from "fs";
1603
1605
  import path9 from "path";
1606
+ import { execFileSync } from "child_process";
1604
1607
  import semver from "semver";
1605
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
+ }
1606
1616
  function isUpdateExempt() {
1607
- 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
+ }
1608
1632
  }
1609
1633
  function defaultUpdateConfig() {
1610
1634
  return {
@@ -1675,6 +1699,25 @@ function buildCheckResult(currentVersion, cache, config, error) {
1675
1699
  error
1676
1700
  };
1677
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
+ }
1678
1721
  async function checkForUpdate(currentVersion) {
1679
1722
  const config = readUpdateConfig();
1680
1723
  const existingCache = readCachedCheck();
@@ -1736,17 +1779,18 @@ import os6 from "os";
1736
1779
  import path10 from "path";
1737
1780
  import { spawn as spawn2 } from "child_process";
1738
1781
  function generateUpdateScript(params) {
1739
- const { targetVersion, projectRoot, vaultDir } = params;
1782
+ const { targetVersion, projectRoot, vaultDir, mycoBinary } = params;
1740
1783
  const packageSpec = `${NPM_PACKAGE_NAME}@${targetVersion}`;
1741
1784
  const quotedProjectRoot = JSON.stringify(projectRoot);
1742
1785
  const quotedVaultDir = JSON.stringify(vaultDir);
1786
+ const quotedMycoBinary = JSON.stringify(mycoBinary);
1743
1787
  const quotedErrorPath = JSON.stringify(UPDATE_ERROR_PATH);
1744
1788
  const errorJson = JSON.stringify(
1745
1789
  JSON.stringify({ error: `npm install failed for ${packageSpec}` })
1746
1790
  );
1747
1791
  return `#!/bin/sh
1748
1792
  set -e
1749
- MYCO="\${MYCO_CMD:-myco}"
1793
+ MYCO=${quotedMycoBinary}
1750
1794
 
1751
1795
  # Wait for daemon to exit cleanly
1752
1796
  sleep ${UPDATE_SCRIPT_DELAY_SECONDS}
@@ -1769,12 +1813,9 @@ fi
1769
1813
  rm -f "$0"
1770
1814
  `;
1771
1815
  }
1772
- function spawnUpdateScript(params) {
1773
- fs9.mkdirSync(MYCO_GLOBAL_DIR, { recursive: true });
1774
- const scriptName = `myco-update-${Date.now()}.sh`;
1775
- const scriptPath = path10.join(os6.tmpdir(), scriptName);
1776
- const script = generateUpdateScript(params);
1777
- 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 });
1778
1819
  const child = spawn2("/bin/sh", [scriptPath], {
1779
1820
  detached: true,
1780
1821
  stdio: "ignore"
@@ -1782,17 +1823,94 @@ function spawnUpdateScript(params) {
1782
1823
  child.unref();
1783
1824
  return scriptPath;
1784
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
+ }
1785
1866
 
1786
1867
  // src/daemon/api/update.ts
1868
+ import semver2 from "semver";
1869
+ import fs10 from "fs";
1870
+ import path11 from "path";
1787
1871
  var ChannelBodySchema = external_exports.object({
1788
1872
  channel: external_exports.enum(RELEASE_CHANNELS)
1789
1873
  });
1790
1874
  function createUpdateHandlers(deps) {
1791
- 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
+ }
1792
1886
  async function handleUpdateStatus(_req) {
1793
1887
  if (isUpdateExempt()) {
1794
1888
  return { body: { exempt: true, running_version: currentVersion } };
1795
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
+ }
1796
1914
  const config = readUpdateConfig();
1797
1915
  const cache = readCachedCheck();
1798
1916
  if (isCacheStale(cache, config.check_interval_hours)) {
@@ -1836,7 +1954,12 @@ function createUpdateHandlers(deps) {
1836
1954
  if (!status || !status.update_available) {
1837
1955
  return { status: 400, body: { error: "no_update_available" } };
1838
1956
  }
1839
- spawnUpdateScript({ targetVersion: status.latest_version, projectRoot, vaultDir });
1957
+ spawnUpdateScript({
1958
+ targetVersion: status.latest_version,
1959
+ projectRoot,
1960
+ vaultDir,
1961
+ mycoBinary: resolveMycoBinary()
1962
+ });
1840
1963
  scheduleShutdown();
1841
1964
  return { body: { status: "applying", version: status.latest_version } };
1842
1965
  }
@@ -1877,8 +2000,8 @@ function createUpdateHandlers(deps) {
1877
2000
  }
1878
2001
 
1879
2002
  // src/daemon/backup.ts
1880
- import fs10 from "fs";
1881
- import path11 from "path";
2003
+ import fs11 from "fs";
2004
+ import path12 from "path";
1882
2005
  var BACKUP_TABLES = [
1883
2006
  "sessions",
1884
2007
  "prompt_batches",
@@ -1893,6 +2016,7 @@ var BACKUP_TABLES = [
1893
2016
  "team_members"
1894
2017
  ];
1895
2018
  var BACKUP_EXTENSION = ".sql";
2019
+ var BACKUP_FILENAME_PATTERN = /^[A-Za-z0-9_-]+\.sql$/;
1896
2020
  var BACKUP_HEADER_TEMPLATE = "-- Myco backup";
1897
2021
  function escapeSql(value) {
1898
2022
  return value.replace(/'/g, "''");
@@ -1904,7 +2028,7 @@ function toSqlLiteral(value) {
1904
2028
  return `'${escapeSql(String(value))}'`;
1905
2029
  }
1906
2030
  function createBackup(db, backupDir, machineId) {
1907
- fs10.mkdirSync(backupDir, { recursive: true });
2031
+ fs11.mkdirSync(backupDir, { recursive: true });
1908
2032
  const lines = [];
1909
2033
  const timestamp = epochSeconds();
1910
2034
  lines.push(`${BACKUP_HEADER_TEMPLATE}: machine_id=${machineId}, created_at=${timestamp}`);
@@ -1922,22 +2046,22 @@ function createBackup(db, backupDir, machineId) {
1922
2046
  }
1923
2047
  lines.push("");
1924
2048
  }
1925
- const filePath = path11.join(backupDir, `${machineId}${BACKUP_EXTENSION}`);
1926
- 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");
1927
2051
  return filePath;
1928
2052
  }
1929
2053
  function listBackups(backupDir) {
1930
2054
  let entries;
1931
2055
  try {
1932
- entries = fs10.readdirSync(backupDir);
2056
+ entries = fs11.readdirSync(backupDir);
1933
2057
  } catch {
1934
2058
  return [];
1935
2059
  }
1936
2060
  const backups = [];
1937
2061
  for (const entry of entries) {
1938
- if (!entry.endsWith(BACKUP_EXTENSION)) continue;
1939
- const filePath = path11.join(backupDir, entry);
1940
- 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);
1941
2065
  backups.push({
1942
2066
  machine_id: entry.slice(0, -BACKUP_EXTENSION.length),
1943
2067
  file_name: entry,
@@ -1949,7 +2073,7 @@ function listBackups(backupDir) {
1949
2073
  }
1950
2074
  var INSERT_REGEX = /^INSERT OR IGNORE INTO (\w+)\s+\(([^)]+)\)\s+VALUES\s+\((.+)\);$/;
1951
2075
  function parseBackupFile(backupPath) {
1952
- const content = fs10.readFileSync(backupPath, "utf-8");
2076
+ const content = fs11.readFileSync(backupPath, "utf-8");
1953
2077
  const inserts = [];
1954
2078
  for (const line of content.split("\n")) {
1955
2079
  const match = INSERT_REGEX.exec(line);
@@ -2033,7 +2157,7 @@ function restoreBackup(db, backupPath) {
2033
2157
  }
2034
2158
 
2035
2159
  // src/daemon/api/backup.ts
2036
- import path12 from "path";
2160
+ import path13 from "path";
2037
2161
  function createBackupHandlers(deps) {
2038
2162
  async function handleCreateBackup(_req) {
2039
2163
  const filePath = createBackup(deps.db, deps.backupDir, deps.machineId);
@@ -2092,7 +2216,7 @@ function createBackupConfigHandlers(deps) {
2092
2216
  const { vaultDir } = deps;
2093
2217
  async function handleGetBackupConfig() {
2094
2218
  const cfg = loadConfig(vaultDir);
2095
- 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") } };
2096
2220
  }
2097
2221
  async function handlePutBackupConfig(req) {
2098
2222
  const { dir } = req.body;
@@ -2103,12 +2227,14 @@ function createBackupConfigHandlers(deps) {
2103
2227
  }
2104
2228
 
2105
2229
  // src/daemon/team-sync.ts
2106
- var TeamSyncClient = class {
2230
+ var TeamSyncClient = class _TeamSyncClient {
2107
2231
  workerUrl;
2108
2232
  apiKey;
2109
2233
  machineId;
2110
2234
  syncProtocolVersion;
2111
2235
  fetchFn;
2236
+ mcpToken = null;
2237
+ mcpTokenHash = null;
2112
2238
  constructor(options) {
2113
2239
  this.workerUrl = options.workerUrl.replace(/\/+$/, "");
2114
2240
  this.apiKey = options.apiKey;
@@ -2116,6 +2242,14 @@ var TeamSyncClient = class {
2116
2242
  this.syncProtocolVersion = options.syncProtocolVersion;
2117
2243
  this.fetchFn = options.fetch ?? globalThis.fetch;
2118
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
+ }
2119
2253
  /**
2120
2254
  * Register this machine with the team worker.
2121
2255
  */
@@ -2125,7 +2259,12 @@ var TeamSyncClient = class {
2125
2259
  machine_id: this.machineId,
2126
2260
  sync_protocol_version: this.syncProtocolVersion
2127
2261
  });
2128
- 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;
2129
2268
  }
2130
2269
  /**
2131
2270
  * Push a batch of outbox records to the team worker.
@@ -2191,7 +2330,14 @@ var TeamSyncClient = class {
2191
2330
  if (!res.ok) {
2192
2331
  throw new Error(`Health check failed: ${res.status} ${res.statusText}`);
2193
2332
  }
2194
- 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;
2195
2341
  } finally {
2196
2342
  clearTimeout(timer);
2197
2343
  }
@@ -2204,6 +2350,22 @@ var TeamSyncClient = class {
2204
2350
  return res;
2205
2351
  }
2206
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
+ // ---------------------------------------------------------------------------
2207
2369
  // Internal
2208
2370
  // ---------------------------------------------------------------------------
2209
2371
  headers() {
@@ -2212,15 +2374,15 @@ var TeamSyncClient = class {
2212
2374
  "Content-Type": "application/json"
2213
2375
  };
2214
2376
  }
2215
- async request(method, path21, body) {
2216
- const res = await this.fetchFn(`${this.workerUrl}${path21}`, {
2377
+ async request(method, path22, body) {
2378
+ const res = await this.fetchFn(`${this.workerUrl}${path22}`, {
2217
2379
  method,
2218
2380
  headers: this.headers(),
2219
2381
  body: body !== void 0 ? JSON.stringify(body) : void 0
2220
2382
  });
2221
2383
  if (!res.ok) {
2222
2384
  const text = await res.text().catch(() => "");
2223
- 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}`);
2224
2386
  }
2225
2387
  return res.json();
2226
2388
  }
@@ -2228,7 +2390,7 @@ var TeamSyncClient = class {
2228
2390
 
2229
2391
  // src/daemon/api/team-connect.ts
2230
2392
  function createTeamHandlers(deps) {
2231
- const { vaultDir, machineId } = deps;
2393
+ const { vaultDir, machineId, logger } = deps;
2232
2394
  async function handleConnect(req) {
2233
2395
  const { url, api_key } = req.body;
2234
2396
  if (!url || !api_key) {
@@ -2313,7 +2475,9 @@ function createTeamHandlers(deps) {
2313
2475
  deployed_worker_version: config.team.deployed_worker_version ?? null,
2314
2476
  worker_update_available: config.team.enabled ? config.team.deployed_worker_version !== getPluginVersion() : false,
2315
2477
  schema_version: SCHEMA_VERSION,
2316
- 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
2317
2481
  }
2318
2482
  };
2319
2483
  }
@@ -2326,11 +2490,17 @@ function createTeamHandlers(deps) {
2326
2490
  return { body: { retried: count } };
2327
2491
  }
2328
2492
  async function handleUpgradeWorker(_req) {
2329
- const { upgradeWorker } = await import("./team-7X64J4Y6.js");
2493
+ const { upgradeWorker } = await import("./team-2ZFGTSIN.js");
2494
+ logger.info("team-sync.upgrade.start", "Starting worker upgrade");
2330
2495
  const result = upgradeWorker(vaultDir);
2331
2496
  if (!result.success) {
2497
+ logger.error("team-sync.upgrade.failed", "Worker upgrade failed", { error: result.error });
2332
2498
  return { status: 500, body: { error: result.error } };
2333
2499
  }
2500
+ logger.info("team-sync.upgrade.complete", "Worker upgrade complete", {
2501
+ worker_url: result.worker_url,
2502
+ version: result.version
2503
+ });
2334
2504
  if (result.worker_url && deps.getTeamClient()) {
2335
2505
  const secrets = readSecrets(vaultDir);
2336
2506
  const apiKey = secrets[TEAM_API_KEY_SECRET];
@@ -2345,7 +2515,28 @@ function createTeamHandlers(deps) {
2345
2515
  }
2346
2516
  return { body: result };
2347
2517
  }
2348
- 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 };
2349
2540
  }
2350
2541
 
2351
2542
  // src/daemon/api/session-lifecycle.ts
@@ -2425,8 +2616,8 @@ function createSessionLifecycleHandlers(deps) {
2425
2616
  }
2426
2617
 
2427
2618
  // src/daemon/api/skills.ts
2428
- import fs11 from "fs";
2429
- import path13 from "path";
2619
+ import fs12 from "fs";
2620
+ import path14 from "path";
2430
2621
 
2431
2622
  // src/db/queries/skill-usage.ts
2432
2623
  var USAGE_COLUMNS = [
@@ -2593,15 +2784,15 @@ function createSkillRecordDeleteHandler(deps) {
2593
2784
  if (result.body?.deleted) {
2594
2785
  const record = result.body;
2595
2786
  if (record.name) {
2596
- const projectRoot = path13.resolve(vaultDir, "..");
2597
- 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);
2598
2789
  try {
2599
- fs11.rmSync(skillDir, { recursive: true, force: true });
2790
+ fs12.rmSync(skillDir, { recursive: true, force: true });
2600
2791
  } catch (err) {
2601
2792
  logger.warn(LOG_KINDS.PROCESSOR_BATCH, "Failed to remove skill directory", { name: record.name, error: String(err) });
2602
2793
  }
2603
2794
  try {
2604
- const { syncSkillSymlinks } = await import("./installer-45ZLP2RP.js");
2795
+ const { syncSkillSymlinks } = await import("./installer-BWJED3ED.js");
2605
2796
  syncSkillSymlinks(projectRoot, record.name, { remove: true });
2606
2797
  } catch (err) {
2607
2798
  logger.warn(LOG_KINDS.PROCESSOR_BATCH, "Failed to remove skill symlinks", { name: record.name, error: String(err) });
@@ -2854,12 +3045,12 @@ async function handleGetModels(req) {
2854
3045
 
2855
3046
  // src/daemon/api/stats.ts
2856
3047
  import { createHash as createHash2 } from "crypto";
2857
- import fs12 from "fs";
2858
- import path14 from "path";
3048
+ import fs13 from "fs";
3049
+ import path15 from "path";
2859
3050
  function computeConfigHash(vaultDir) {
2860
3051
  try {
2861
- const configPath = path14.join(vaultDir, CONFIG_FILENAME);
2862
- const raw = fs12.readFileSync(configPath, "utf-8");
3052
+ const configPath = path15.join(vaultDir, CONFIG_FILENAME);
3053
+ const raw = fs13.readFileSync(configPath, "utf-8");
2863
3054
  return createHash2("md5").update(raw).digest("hex");
2864
3055
  } catch {
2865
3056
  return "";
@@ -4771,17 +4962,17 @@ var SqliteRecordSource = class {
4771
4962
  };
4772
4963
 
4773
4964
  // src/daemon/database/manager.ts
4774
- import fs14 from "fs";
4965
+ import fs15 from "fs";
4775
4966
 
4776
4967
  // src/db/queries/database.ts
4777
- import fs13 from "fs";
4968
+ import fs14 from "fs";
4778
4969
  function pragmaScalar(name) {
4779
4970
  const db = getDatabase();
4780
4971
  return db.pragma(name, { simple: true });
4781
4972
  }
4782
4973
  function safeFileSize(filePath) {
4783
4974
  try {
4784
- return fs13.statSync(filePath).size;
4975
+ return fs14.statSync(filePath).size;
4785
4976
  } catch (err) {
4786
4977
  if (err.code === "ENOENT") return 0;
4787
4978
  throw err;
@@ -5053,7 +5244,7 @@ var DatabaseMaintenanceManager = class {
5053
5244
  }
5054
5245
  async vacuum() {
5055
5246
  const size_before = this.fileSize();
5056
- const stats = await fs14.promises.statfs(this.vaultDir);
5247
+ const stats = await fs15.promises.statfs(this.vaultDir);
5057
5248
  const free_bytes = Number(stats.bavail) * Number(stats.bsize);
5058
5249
  const required_bytes = size_before * VACUUM_FREE_SPACE_MULTIPLIER;
5059
5250
  if (free_bytes < required_bytes) {
@@ -5101,7 +5292,7 @@ var DatabaseMaintenanceManager = class {
5101
5292
  }
5102
5293
  fileSize() {
5103
5294
  try {
5104
- return fs14.statSync(this.dbPath).size;
5295
+ return fs15.statSync(this.dbPath).size;
5105
5296
  } catch {
5106
5297
  return 0;
5107
5298
  }
@@ -5143,6 +5334,13 @@ function registerBuiltinDomains() {
5143
5334
  { id: "mycelium.spore.created", label: "New spore extracted", defaultMode: "summary", defaultLevel: "info" }
5144
5335
  ]
5145
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
+ });
5146
5344
  }
5147
5345
 
5148
5346
  // src/daemon/api/notifications.ts
@@ -5544,7 +5742,7 @@ async function registerScheduledTasks(powerManager, deps) {
5544
5742
  logger.info(LOG_KINDS.AGENT_RUN, "Scheduled agent tasks disabled globally (agent.scheduled_tasks_enabled: false)");
5545
5743
  return;
5546
5744
  }
5547
- const { loadAllTasks: loadAllTasks2 } = await import("./registry-TFQ22Z7N.js");
5745
+ const { loadAllTasks: loadAllTasks2 } = await import("./registry-O2NZLO3V.js");
5548
5746
  const allTasks = Array.from(loadAllTasks2(definitionsDir, vaultDir).values());
5549
5747
  const initialLastRuns = {};
5550
5748
  try {
@@ -5566,7 +5764,7 @@ async function registerScheduledTasks(powerManager, deps) {
5566
5764
  else runningTasks.delete(name);
5567
5765
  },
5568
5766
  runTask: async (taskName) => {
5569
- const { runAgent } = await import("./executor-NXKJU5KW.js");
5767
+ const { runAgent } = await import("./executor-NSPRTH4M.js");
5570
5768
  const taskConfig = config.agent.tasks?.[taskName];
5571
5769
  const built = buildTaskInstruction(taskName, taskConfig?.params);
5572
5770
  if (isInstructionRequiredTask(taskName) && !built) {
@@ -5735,7 +5933,7 @@ function createMcpProxyHandlers(deps) {
5735
5933
  name: USER_AGENT_NAME,
5736
5934
  created_at: now
5737
5935
  });
5738
- const { insertResolutionEvent } = await import("./resolution-events-HGKIJOTA.js");
5936
+ const { insertResolutionEvent } = await import("./resolution-events-XWYLLDRK.js");
5739
5937
  const resolutionId = `res-${randomBytes(RESOLUTION_ID_RANDOM_BYTES).toString("hex")}`;
5740
5938
  insertResolutionEvent({
5741
5939
  id: resolutionId,
@@ -5860,7 +6058,7 @@ function createAgentRunHandlers(deps) {
5860
6058
  };
5861
6059
  }
5862
6060
  }
5863
- const { runAgent } = await import("./executor-NXKJU5KW.js");
6061
+ const { runAgent } = await import("./executor-NSPRTH4M.js");
5864
6062
  const resultPromise = runAgent(vaultDir, {
5865
6063
  task,
5866
6064
  instruction,
@@ -5929,8 +6127,8 @@ function createAgentRunHandlers(deps) {
5929
6127
  }
5930
6128
 
5931
6129
  // src/daemon/api/attachments.ts
5932
- import fs15 from "fs";
5933
- import path15 from "path";
6130
+ import fs16 from "fs";
6131
+ import path16 from "path";
5934
6132
  var ATTACHMENT_MEDIA_TYPES = {
5935
6133
  png: "image/png",
5936
6134
  jpg: "image/jpeg",
@@ -5950,14 +6148,14 @@ function createAttachmentHandler(deps) {
5950
6148
  const contentType2 = att.media_type ?? "application/octet-stream";
5951
6149
  return { status: 200, headers: { "Content-Type": contentType2 }, body: att.data };
5952
6150
  }
5953
- const filePath = path15.join(vaultDir, "attachments", filename);
6151
+ const filePath = path16.join(vaultDir, "attachments", filename);
5954
6152
  let diskData;
5955
6153
  try {
5956
- diskData = fs15.readFileSync(filePath);
6154
+ diskData = fs16.readFileSync(filePath);
5957
6155
  } catch {
5958
6156
  return { status: 404, body: { error: "not_found" } };
5959
6157
  }
5960
- const ext = path15.extname(filename).slice(1).toLowerCase();
6158
+ const ext = path16.extname(filename).slice(1).toLowerCase();
5961
6159
  const contentType = ATTACHMENT_MEDIA_TYPES[ext] ?? "application/octet-stream";
5962
6160
  return { status: 200, headers: { "Content-Type": contentType }, body: diskData };
5963
6161
  }
@@ -5965,19 +6163,19 @@ function createAttachmentHandler(deps) {
5965
6163
  }
5966
6164
 
5967
6165
  // src/daemon/log-reconcile.ts
5968
- import fs16 from "fs";
5969
- import path16 from "path";
6166
+ import fs17 from "fs";
6167
+ import path17 from "path";
5970
6168
  function reconcileLogBuffer(logDir, sinceTimestamp) {
5971
6169
  let replayed = 0;
5972
6170
  const files = [];
5973
6171
  for (let i = 3; i >= 1; i--) {
5974
- const rotated = path16.join(logDir, `daemon.${i}.log`);
5975
- if (fs16.existsSync(rotated)) files.push(rotated);
6172
+ const rotated = path17.join(logDir, `daemon.${i}.log`);
6173
+ if (fs17.existsSync(rotated)) files.push(rotated);
5976
6174
  }
5977
- const current = path16.join(logDir, "daemon.log");
5978
- if (fs16.existsSync(current)) files.push(current);
6175
+ const current = path17.join(logDir, "daemon.log");
6176
+ if (fs17.existsSync(current)) files.push(current);
5979
6177
  for (const file of files) {
5980
- const content = fs16.readFileSync(file, "utf-8");
6178
+ const content = fs17.readFileSync(file, "utf-8");
5981
6179
  for (const line of content.split("\n")) {
5982
6180
  if (!line.trim()) continue;
5983
6181
  try {
@@ -6256,8 +6454,8 @@ function registerPowerJobs(powerManager, deps) {
6256
6454
  }
6257
6455
 
6258
6456
  // src/daemon/reconciliation.ts
6259
- import fs17 from "fs";
6260
- import path17 from "path";
6457
+ import fs18 from "fs";
6458
+ import path18 from "path";
6261
6459
 
6262
6460
  // src/daemon/event-handlers.ts
6263
6461
  var TOOL_INPUT_STORE_LIMIT = 4e3;
@@ -6426,10 +6624,10 @@ function createReconciler({ bufferDir, logger }) {
6426
6624
  function reconcileSession(sessionId) {
6427
6625
  if (reconciledSessions.has(sessionId)) return;
6428
6626
  reconciledSessions.add(sessionId);
6429
- const bufferPath = path17.join(bufferDir, `${sessionId}.jsonl`);
6627
+ const bufferPath = path18.join(bufferDir, `${sessionId}.jsonl`);
6430
6628
  let content;
6431
6629
  try {
6432
- content = fs17.readFileSync(bufferPath, "utf-8").trim();
6630
+ content = fs18.readFileSync(bufferPath, "utf-8").trim();
6433
6631
  } catch {
6434
6632
  return;
6435
6633
  }
@@ -6498,7 +6696,7 @@ function createReconciler({ bufferDir, logger }) {
6498
6696
  }
6499
6697
 
6500
6698
  // src/daemon/stop-processing.ts
6501
- import fs18 from "fs";
6699
+ import fs19 from "fs";
6502
6700
 
6503
6701
  // src/daemon/capture-images.ts
6504
6702
  var SESSION_SHORT_LEN = 6;
@@ -6604,14 +6802,14 @@ function createStopProcessor(deps) {
6604
6802
  const StopBody = external_exports.object({
6605
6803
  session_id: external_exports.string(),
6606
6804
  user: external_exports.string().optional(),
6607
- transcript_path: external_exports.string().optional(),
6608
- last_assistant_message: external_exports.string().optional()
6805
+ transcript_path: external_exports.string().nullish(),
6806
+ last_assistant_message: external_exports.string().nullish()
6609
6807
  });
6610
6808
  async function triggerTitleSummary(sessionId) {
6611
6809
  if (config.agent.summary_batch_interval <= 0) return;
6612
6810
  if (config.agent.event_tasks_enabled === false) return;
6613
6811
  try {
6614
- const { runAgent } = await import("./executor-NXKJU5KW.js");
6812
+ const { runAgent } = await import("./executor-NSPRTH4M.js");
6615
6813
  runAgent(vaultDir, {
6616
6814
  task: "title-summary",
6617
6815
  instruction: `Process session ${sessionId} only`,
@@ -6701,7 +6899,7 @@ function createStopProcessor(deps) {
6701
6899
  let transcriptText = null;
6702
6900
  if (hookTranscriptPath) {
6703
6901
  try {
6704
- transcriptText = fs18.readFileSync(hookTranscriptPath, "utf-8");
6902
+ transcriptText = fs19.readFileSync(hookTranscriptPath, "utf-8");
6705
6903
  } catch {
6706
6904
  }
6707
6905
  }
@@ -6766,11 +6964,18 @@ function createStopProcessor(deps) {
6766
6964
  }
6767
6965
  const handleStopRoute = async (req) => {
6768
6966
  const { session_id: sessionId, user, transcript_path: hookTranscriptPath, last_assistant_message: lastAssistantMessage } = StopBody.parse(req.body);
6769
- 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) {
6770
6975
  registry.register(sessionId, { started_at: (/* @__PURE__ */ new Date()).toISOString() });
6771
6976
  logger.debug(LOG_KINDS.LIFECYCLE_AUTO_REGISTER, "Auto-registered session from stop event", { session_id: sessionId });
6772
6977
  }
6773
- const sessionMeta = registry.getSession(sessionId);
6978
+ const sessionMeta = existingSessionMeta ?? registry.getSession(sessionId);
6774
6979
  logger.info(LOG_KINDS.HOOKS_STOP, "Stop received", {
6775
6980
  session_id: sessionId,
6776
6981
  has_transcript_path: !!hookTranscriptPath,
@@ -6781,7 +6986,9 @@ function createStopProcessor(deps) {
6781
6986
  transcript_path: hookTranscriptPath ?? null,
6782
6987
  last_message_preview: lastAssistantMessage?.slice(0, LOG_MESSAGE_PREVIEW_CHARS) ?? null
6783
6988
  });
6784
- 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) => {
6785
6992
  logger.error(LOG_KINDS.PROCESSOR_SESSION, "Stop processing failed", { session_id: sessionId, error: err.message });
6786
6993
  });
6787
6994
  const prev = activeStopProcessing ?? Promise.resolve();
@@ -6801,13 +7008,13 @@ function createStopProcessor(deps) {
6801
7008
  }
6802
7009
 
6803
7010
  // src/daemon/event-dispatch.ts
6804
- import fs19 from "fs";
6805
- import path19 from "path";
7011
+ import fs20 from "fs";
7012
+ import path20 from "path";
6806
7013
 
6807
7014
  // src/daemon/plan-capture.ts
6808
7015
  import { createHash as createHash4 } from "crypto";
6809
7016
  import os7 from "os";
6810
- import path18 from "path";
7017
+ import path19 from "path";
6811
7018
  var FILE_WRITE_TOOLS = /* @__PURE__ */ new Set([
6812
7019
  "Write",
6813
7020
  "Edit",
@@ -6820,11 +7027,11 @@ var FILE_WRITE_TOOLS = /* @__PURE__ */ new Set([
6820
7027
  var HEADING_REGEX = /^#\s+(.+)$/m;
6821
7028
  var PLAN_ID_HASH_LENGTH = 16;
6822
7029
  function isInPlanDirectory(filePath, watchDirs, projectRoot) {
6823
- const abs = path18.isAbsolute(filePath) ? filePath : path18.resolve(projectRoot, filePath);
7030
+ const abs = path19.isAbsolute(filePath) ? filePath : path19.resolve(projectRoot, filePath);
6824
7031
  return watchDirs.some((dir) => {
6825
- const expanded = dir.startsWith("~/") ? path18.join(os7.homedir(), dir.slice(2)) : dir;
6826
- const absDir = path18.isAbsolute(expanded) ? expanded : path18.resolve(projectRoot, expanded);
6827
- 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;
6828
7035
  return abs === absDir || abs.startsWith(prefix);
6829
7036
  });
6830
7037
  }
@@ -6834,7 +7041,7 @@ function isPlanWriteEvent(toolName, toolInput, config) {
6834
7041
  if (typeof filePath !== "string") return null;
6835
7042
  if (!isInPlanDirectory(filePath, config.watchDirs, config.projectRoot)) return null;
6836
7043
  if (config.extensions?.length) {
6837
- const ext = path18.extname(filePath).toLowerCase();
7044
+ const ext = path19.extname(filePath).toLowerCase();
6838
7045
  if (!config.extensions.includes(ext)) return null;
6839
7046
  }
6840
7047
  return filePath;
@@ -6848,7 +7055,7 @@ function capturePlan(input) {
6848
7055
  const now = Math.floor(Date.now() / 1e3);
6849
7056
  const contentHash = createHash4(CONTENT_HASH_ALGORITHM).update(input.content).digest("hex");
6850
7057
  const id = createHash4("md5").update(input.sourcePath).digest("hex").slice(0, PLAN_ID_HASH_LENGTH);
6851
- const title = parsePlanTitle(input.content, path18.basename(input.sourcePath));
7058
+ const title = parsePlanTitle(input.content, path19.basename(input.sourcePath));
6852
7059
  return upsertPlan({
6853
7060
  id,
6854
7061
  title,
@@ -6902,7 +7109,7 @@ function createEventDispatcher(deps) {
6902
7109
  reconcileSession(event.session_id);
6903
7110
  }
6904
7111
  if (!sessionBuffers.has(event.session_id)) {
6905
- const bufferDir = path19.join(vaultDir, "buffer");
7112
+ const bufferDir = path20.join(vaultDir, "buffer");
6906
7113
  sessionBuffers.set(event.session_id, new EventBuffer(bufferDir, event.session_id));
6907
7114
  }
6908
7115
  sessionBuffers.get(event.session_id).append(event);
@@ -6956,10 +7163,10 @@ function createEventDispatcher(deps) {
6956
7163
  );
6957
7164
  if (planFilePath) {
6958
7165
  const captureSessionId = event.session_id;
6959
- fs19.promises.readFile(planFilePath, "utf-8").then((planContent) => {
7166
+ fs20.promises.readFile(planFilePath, "utf-8").then((planContent) => {
6960
7167
  const latestBatch = getLatestBatch(captureSessionId);
6961
7168
  capturePlan({
6962
- sourcePath: path19.relative(projectRoot, planFilePath),
7169
+ sourcePath: path20.relative(projectRoot, planFilePath),
6963
7170
  content: planContent,
6964
7171
  sessionId: captureSessionId,
6965
7172
  promptBatchId: latestBatch?.id ?? null
@@ -7101,14 +7308,14 @@ function createEventDispatcher(deps) {
7101
7308
  }
7102
7309
 
7103
7310
  // src/daemon/main.ts
7104
- import fs20 from "fs";
7311
+ import fs21 from "fs";
7105
7312
  import os8 from "os";
7106
- import path20 from "path";
7313
+ import path21 from "path";
7107
7314
  function killStaleDaemon(vaultDir, logger) {
7108
- const daemonJsonPath = path20.join(vaultDir, "daemon.json");
7315
+ const daemonJsonPath = path21.join(vaultDir, "daemon.json");
7109
7316
  try {
7110
- if (!fs20.existsSync(daemonJsonPath)) return;
7111
- 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"));
7112
7319
  if (!info.pid) return;
7113
7320
  if (info.pid === process.pid) return;
7114
7321
  try {
@@ -7117,7 +7324,7 @@ function killStaleDaemon(vaultDir, logger) {
7117
7324
  logger.info(LOG_KINDS.DAEMON_START, "Killed stale daemon", { pid: info.pid });
7118
7325
  } catch {
7119
7326
  }
7120
- fs20.unlinkSync(daemonJsonPath);
7327
+ fs21.unlinkSync(daemonJsonPath);
7121
7328
  } catch {
7122
7329
  }
7123
7330
  }
@@ -7127,7 +7334,7 @@ async function main() {
7127
7334
  process.stderr.write("Usage: mycod --vault <path>\n");
7128
7335
  process.exit(1);
7129
7336
  }
7130
- const vaultDir = path20.resolve(vaultArg);
7337
+ const vaultDir = path21.resolve(vaultArg);
7131
7338
  loadSecrets(vaultDir);
7132
7339
  const config = loadConfig(vaultDir);
7133
7340
  const manifests = loadManifests();
@@ -7138,7 +7345,7 @@ async function main() {
7138
7345
  projectRoot,
7139
7346
  extensions: config.capture.artifact_extensions
7140
7347
  };
7141
- const logger = new DaemonLogger(path20.join(vaultDir, "logs"), {
7348
+ const logger = new DaemonLogger(path21.join(vaultDir, "logs"), {
7142
7349
  level: config.daemon.log_level
7143
7350
  });
7144
7351
  if (config.daemon.log_level === "debug") {
@@ -7152,10 +7359,63 @@ async function main() {
7152
7359
  logger.info(LOG_KINDS.CAPTURE_PLAN, "Plan watch directories", { dirs: planWatchConfig.watchDirs });
7153
7360
  const machineId = getMachineId(vaultDir);
7154
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
+ }
7155
7383
  const db = initDatabase(vaultDbPath(vaultDir));
7156
7384
  createSchema(db, machineId);
7157
7385
  registerBuiltinDomains();
7158
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
+ }
7159
7419
  initTeamContext(config.team.enabled, machineId);
7160
7420
  logger.setPersistFn((entry) => {
7161
7421
  const { timestamp, level, kind, component, message, ...rest } = entry;
@@ -7171,13 +7431,13 @@ async function main() {
7171
7431
  });
7172
7432
  const lastLogTimestamp = getMaxTimestamp();
7173
7433
  if (lastLogTimestamp) {
7174
- const logDir = path20.join(vaultDir, "logs");
7434
+ const logDir = path21.join(vaultDir, "logs");
7175
7435
  const replayedCount = reconcileLogBuffer(logDir, lastLogTimestamp);
7176
7436
  if (replayedCount > 0) {
7177
7437
  logger.info(LOG_KINDS.DAEMON_RECONCILE, `Replayed ${replayedCount} log entries from buffer`, { replayed: replayedCount });
7178
7438
  }
7179
7439
  }
7180
- const vectorsDbPath = path20.join(vaultDir, "vectors.db");
7440
+ const vectorsDbPath = path21.join(vaultDir, "vectors.db");
7181
7441
  const vectorStore = new SqliteVecVectorStore(vectorsDbPath);
7182
7442
  const llmProvider = createEmbeddingProvider(config.embedding);
7183
7443
  const embeddingProvider = new EmbeddingProviderAdapter(llmProvider, config.embedding);
@@ -7187,7 +7447,7 @@ async function main() {
7187
7447
  const databaseManager = new DatabaseMaintenanceManager(vaultDbPath(vaultDir), vaultDir, logger);
7188
7448
  let definitionsDir;
7189
7449
  try {
7190
- const { registerBuiltInAgentsAndTasks, resolveDefinitionsDir: resolveDefinitionsDir2 } = await import("./loader-NEX3UF6U.js");
7450
+ const { registerBuiltInAgentsAndTasks, resolveDefinitionsDir: resolveDefinitionsDir2 } = await import("./loader-SKKUMT5C.js");
7191
7451
  definitionsDir = resolveDefinitionsDir2();
7192
7452
  await registerBuiltInAgentsAndTasks(definitionsDir, vaultDir);
7193
7453
  logger.info(LOG_KINDS.AGENT_TASK, "Built-in agents and tasks registered");
@@ -7213,10 +7473,10 @@ async function main() {
7213
7473
  }
7214
7474
  let uiDir = null;
7215
7475
  {
7216
- const root = findPackageRoot(path20.dirname(new URL(import.meta.url).pathname));
7476
+ const root = findPackageRoot(path21.dirname(new URL(import.meta.url).pathname));
7217
7477
  if (root) {
7218
- const candidate = path20.join(root, "dist", "ui");
7219
- if (fs20.existsSync(candidate)) uiDir = candidate;
7478
+ const candidate = path21.join(root, "dist", "ui");
7479
+ if (fs21.existsSync(candidate)) uiDir = candidate;
7220
7480
  }
7221
7481
  }
7222
7482
  if (uiDir) {
@@ -7249,7 +7509,7 @@ async function main() {
7249
7509
  (p) => createPerProjectAdapter(p, claudeCodeAdapter.parseTurns)
7250
7510
  )
7251
7511
  });
7252
- const bufferDir = path20.join(vaultDir, "buffer");
7512
+ const bufferDir = path21.join(vaultDir, "buffer");
7253
7513
  const sessionBuffers = /* @__PURE__ */ new Map();
7254
7514
  const reconciler = createReconciler({ bufferDir, logger });
7255
7515
  reconciler.runStartupReconciliation();
@@ -7335,11 +7595,12 @@ async function main() {
7335
7595
  server.registerRoute("POST", "/api/log", createLogIngestionHandler(logger));
7336
7596
  server.registerRoute("GET", "/api/models", async (req) => handleGetModels(req));
7337
7597
  server.registerRoute("POST", "/api/restart", async (req) => handleRestart({ vaultDir, progressTracker }, req.body));
7338
- const updateProjectRoot = path20.dirname(vaultDir);
7598
+ const updateProjectRoot = path21.dirname(vaultDir);
7339
7599
  const updateHandlers = createUpdateHandlers({
7340
7600
  vaultDir,
7341
7601
  projectRoot: updateProjectRoot,
7342
7602
  currentVersion: server.version,
7603
+ globalPrefix,
7343
7604
  scheduleShutdown: () => {
7344
7605
  setTimeout(() => {
7345
7606
  process.kill(process.pid, "SIGTERM");
@@ -7399,7 +7660,7 @@ async function main() {
7399
7660
  server.registerRoute("GET", "/api/mcp/sessions", mcpProxy.handleSessions);
7400
7661
  server.registerRoute("GET", "/api/mcp/team", mcpProxy.handleTeam);
7401
7662
  const rawBackupDir = config.backup.dir;
7402
- 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");
7403
7664
  const backupHandlers = createBackupHandlers({ db, backupDir, machineId });
7404
7665
  server.registerRoute("POST", "/api/backup", backupHandlers.handleCreateBackup);
7405
7666
  server.registerRoute("GET", "/api/backups", backupHandlers.handleListBackups);
@@ -7412,6 +7673,7 @@ async function main() {
7412
7673
  const teamHandlers = createTeamHandlers({
7413
7674
  vaultDir,
7414
7675
  machineId,
7676
+ logger,
7415
7677
  getTeamClient: teamSync.getTeamClient,
7416
7678
  setTeamClient: teamSync.setTeamClient
7417
7679
  });
@@ -7421,6 +7683,7 @@ async function main() {
7421
7683
  server.registerRoute("POST", "/api/team/backfill", teamHandlers.handleBackfill);
7422
7684
  server.registerRoute("POST", "/api/team/retry-failed", teamHandlers.handleRetryFailed);
7423
7685
  server.registerRoute("POST", "/api/team/upgrade-worker", teamHandlers.handleUpgradeWorker);
7686
+ server.registerRoute("POST", "/api/team/rotate-mcp-token", teamHandlers.handleRotateMcpToken);
7424
7687
  server.registerRoute("GET", "/api/search", createSearchHandler({ embeddingManager, getTeamClient: teamSync.getTeamClient, machineId }));
7425
7688
  server.registerRoute("GET", "/api/activity", handleGetFeed);
7426
7689
  server.registerRoute("GET", "/api/embedding/status", async () => handleGetEmbeddingStatus(vaultDir));
@@ -7493,4 +7756,4 @@ export {
7493
7756
  handleUserPrompt,
7494
7757
  main
7495
7758
  };
7496
- //# sourceMappingURL=main-YFVBIRRK.js.map
7759
+ //# sourceMappingURL=main-6PY3ITQ5.js.map