@goondocks/myco 0.11.0 → 0.12.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 (146) hide show
  1. package/CONTRIBUTING.md +0 -1
  2. package/README.md +5 -1
  3. package/dist/{agent-run-CGM75RS6.js → agent-run-5KYQJQTY.js} +6 -6
  4. package/dist/{agent-tasks-3RQKPRSW.js → agent-tasks-N7BDYKGB.js} +6 -6
  5. package/dist/{chunk-XLY3REL3.js → chunk-4VSNNMEU.js} +2 -2
  6. package/dist/{chunk-ZAHDA2PQ.js → chunk-7NBDELZB.js} +3 -3
  7. package/dist/{chunk-6LL2MQHP.js → chunk-D4ESHOOJ.js} +3 -3
  8. package/dist/{chunk-W6HI4CCS.js → chunk-D4M2AV65.js} +5 -4
  9. package/dist/chunk-D4M2AV65.js.map +1 -0
  10. package/dist/{chunk-YKOEMLJJ.js → chunk-DPJVKNNP.js} +3 -3
  11. package/dist/{chunk-IXOHLPH7.js → chunk-HAG2YDH6.js} +3 -3
  12. package/dist/{chunk-AEJS57ZK.js → chunk-J3L2RTYK.js} +2 -2
  13. package/dist/{chunk-MKKXCCQ5.js → chunk-JHLALJPB.js} +5 -5
  14. package/dist/{chunk-CUDM5YJY.js → chunk-JROOQQH6.js} +3 -3
  15. package/dist/{chunk-D6DXYAFK.js → chunk-LGPBVBFY.js} +3 -3
  16. package/dist/{chunk-5SDH75YC.js → chunk-LUQBT2Y4.js} +2 -2
  17. package/dist/{chunk-76ZO5RGT.js → chunk-PIRWYDOH.js} +30 -2
  18. package/dist/chunk-PIRWYDOH.js.map +1 -0
  19. package/dist/{chunk-WZZH3YXJ.js → chunk-PW5QVY44.js} +2 -2
  20. package/dist/{chunk-U7UUJ4FD.js → chunk-Q2AYS2QE.js} +3 -3
  21. package/dist/{chunk-FPMEIN2W.js → chunk-QL2RBFIC.js} +2 -2
  22. package/dist/{chunk-CHG652UO.js → chunk-RGRPAKEY.js} +3 -3
  23. package/dist/{chunk-K2UZNK25.js → chunk-RR75ZKEV.js} +2 -2
  24. package/dist/{chunk-5QERXFH7.js → chunk-SW62AX75.js} +2 -2
  25. package/dist/{chunk-FFQES5MC.js → chunk-TCGOSLW6.js} +3 -3
  26. package/dist/{chunk-JYXMRW3T.js → chunk-TY7A5OZ5.js} +2 -2
  27. package/dist/{chunk-LYFDTF7G.js → chunk-YRHSTVCZ.js} +3 -3
  28. package/dist/{chunk-C3AEZ3BZ.js → chunk-YRUJ5KGV.js} +3 -3
  29. package/dist/{cli-FL754H6S.js → cli-Y5QZJAHX.js} +37 -37
  30. package/dist/{client-4NP7ZMLV.js → client-UGM6MG55.js} +4 -4
  31. package/dist/{detect-providers-AZ6DEQU7.js → detect-providers-JFE3QLJI.js} +4 -4
  32. package/dist/{doctor-OFGWOYBC.js → doctor-NFWPX75B.js} +8 -8
  33. package/dist/{executor-SWXSN7ZC.js → executor-ESRLUCGU.js} +14 -14
  34. package/dist/executor-ESRLUCGU.js.map +1 -0
  35. package/dist/{init-JZJJKC4G.js → init-NMSG24BY.js} +11 -11
  36. package/dist/{init-wizard-4VHNOYFO.js → init-wizard-WIUCR4JE.js} +7 -7
  37. package/dist/{llm-XJFHRFHB.js → llm-O46QYWEM.js} +7 -7
  38. package/dist/{loader-DGWP4EFB.js → loader-BQ4X4K3F.js} +3 -3
  39. package/dist/{main-UBUZTMGV.js → main-3NTAT7ZD.js} +379 -75
  40. package/dist/main-3NTAT7ZD.js.map +1 -0
  41. package/dist/{openai-embeddings-ST3B6GW7.js → openai-embeddings-HWAKOGUM.js} +4 -4
  42. package/dist/{openrouter-HJHOO3EO.js → openrouter-GXZK7JXR.js} +4 -4
  43. package/dist/{post-compact-O7HMEFKP.js → post-compact-3DDK3OVZ.js} +6 -6
  44. package/dist/{post-tool-use-OVNMZ3UG.js → post-tool-use-LSG6N3W5.js} +5 -5
  45. package/dist/{post-tool-use-failure-HPXTFYBY.js → post-tool-use-failure-5V3OCLI6.js} +6 -6
  46. package/dist/{pre-compact-JD3D4PBB.js → pre-compact-F7Y7SDSZ.js} +6 -6
  47. package/dist/{provider-check-SOTDYLJE.js → provider-check-CKZW3GQX.js} +4 -4
  48. package/dist/{registry-33MEKDHT.js → registry-ZHUVXGPO.js} +4 -4
  49. package/dist/{remove-XDFMOYUL.js → remove-VCWRNG54.js} +6 -6
  50. package/dist/{resolution-events-UPHJJLDQ.js → resolution-events-WZHPQQMN.js} +4 -4
  51. package/dist/{restart-JBAMRKRJ.js → restart-YYJ7SH4K.js} +7 -7
  52. package/dist/{search-43TS5RGA.js → search-L7KTBURJ.js} +7 -7
  53. package/dist/{server-UBU7NALJ.js → server-GMRVF2PB.js} +4 -4
  54. package/dist/{session-CPBLMD7M.js → session-V3SNFG7J.js} +8 -8
  55. package/dist/{session-end-DUHUYE6J.js → session-end-V3V3GMP2.js} +5 -5
  56. package/dist/{session-start-I7XM3CME.js → session-start-OH7SBUIA.js} +9 -9
  57. package/dist/{setup-llm-TTHEUWDA.js → setup-llm-5AMWEAJ5.js} +6 -6
  58. package/dist/src/agent/definitions/tasks/full-intelligence.yaml +0 -1
  59. package/dist/src/agent/prompts/agent.md +1 -1
  60. package/dist/src/cli.js +1 -1
  61. package/dist/src/daemon/main.js +1 -1
  62. package/dist/src/hooks/post-tool-use.js +1 -1
  63. package/dist/src/hooks/session-end.js +1 -1
  64. package/dist/src/hooks/session-start.js +1 -1
  65. package/dist/src/hooks/stop.js +1 -1
  66. package/dist/src/hooks/user-prompt-submit.js +1 -1
  67. package/dist/src/mcp/server.js +1 -1
  68. package/dist/{stats-7CE6GEWE.js → stats-B2V7P45Y.js} +7 -7
  69. package/dist/{stop-BF3AWA7S.js → stop-D6L2KRHZ.js} +5 -5
  70. package/dist/{stop-failure-7Q2LQF2R.js → stop-failure-7OM2AYRX.js} +6 -6
  71. package/dist/{subagent-start-QG2J3AN4.js → subagent-start-MKL5I54S.js} +6 -6
  72. package/dist/{subagent-stop-WVA7RDIM.js → subagent-stop-2E7VKZW2.js} +6 -6
  73. package/dist/{task-completed-AQVQ7GFL.js → task-completed-5QHIT773.js} +6 -6
  74. package/dist/{team-LC3K7UXD.js → team-TBS5OILG.js} +2 -2
  75. package/dist/ui/assets/index-aMc07Ym5.js +804 -0
  76. package/dist/ui/index.html +1 -1
  77. package/dist/{update-3EKXZF3H.js → update-4NVFET56.js} +15 -10
  78. package/dist/update-4NVFET56.js.map +1 -0
  79. package/dist/{user-prompt-submit-22YQD4XM.js → user-prompt-submit-X4BCPMZ4.js} +5 -5
  80. package/dist/{verify-DVIWHZXA.js → verify-D7EDVXO5.js} +7 -7
  81. package/dist/{version-VPI6ERF7.js → version-GTFCEIJ2.js} +2 -2
  82. package/package.json +3 -2
  83. package/dist/chunk-76ZO5RGT.js.map +0 -1
  84. package/dist/chunk-W6HI4CCS.js.map +0 -1
  85. package/dist/executor-SWXSN7ZC.js.map +0 -1
  86. package/dist/main-UBUZTMGV.js.map +0 -1
  87. package/dist/ui/assets/index-UFE9l-Hb.js +0 -794
  88. package/dist/update-3EKXZF3H.js.map +0 -1
  89. package/hooks/hooks.json +0 -137
  90. /package/dist/{agent-run-CGM75RS6.js.map → agent-run-5KYQJQTY.js.map} +0 -0
  91. /package/dist/{agent-tasks-3RQKPRSW.js.map → agent-tasks-N7BDYKGB.js.map} +0 -0
  92. /package/dist/{chunk-XLY3REL3.js.map → chunk-4VSNNMEU.js.map} +0 -0
  93. /package/dist/{chunk-ZAHDA2PQ.js.map → chunk-7NBDELZB.js.map} +0 -0
  94. /package/dist/{chunk-6LL2MQHP.js.map → chunk-D4ESHOOJ.js.map} +0 -0
  95. /package/dist/{chunk-YKOEMLJJ.js.map → chunk-DPJVKNNP.js.map} +0 -0
  96. /package/dist/{chunk-IXOHLPH7.js.map → chunk-HAG2YDH6.js.map} +0 -0
  97. /package/dist/{chunk-AEJS57ZK.js.map → chunk-J3L2RTYK.js.map} +0 -0
  98. /package/dist/{chunk-MKKXCCQ5.js.map → chunk-JHLALJPB.js.map} +0 -0
  99. /package/dist/{chunk-CUDM5YJY.js.map → chunk-JROOQQH6.js.map} +0 -0
  100. /package/dist/{chunk-D6DXYAFK.js.map → chunk-LGPBVBFY.js.map} +0 -0
  101. /package/dist/{chunk-5SDH75YC.js.map → chunk-LUQBT2Y4.js.map} +0 -0
  102. /package/dist/{chunk-WZZH3YXJ.js.map → chunk-PW5QVY44.js.map} +0 -0
  103. /package/dist/{chunk-U7UUJ4FD.js.map → chunk-Q2AYS2QE.js.map} +0 -0
  104. /package/dist/{chunk-FPMEIN2W.js.map → chunk-QL2RBFIC.js.map} +0 -0
  105. /package/dist/{chunk-CHG652UO.js.map → chunk-RGRPAKEY.js.map} +0 -0
  106. /package/dist/{chunk-K2UZNK25.js.map → chunk-RR75ZKEV.js.map} +0 -0
  107. /package/dist/{chunk-5QERXFH7.js.map → chunk-SW62AX75.js.map} +0 -0
  108. /package/dist/{chunk-FFQES5MC.js.map → chunk-TCGOSLW6.js.map} +0 -0
  109. /package/dist/{chunk-JYXMRW3T.js.map → chunk-TY7A5OZ5.js.map} +0 -0
  110. /package/dist/{chunk-LYFDTF7G.js.map → chunk-YRHSTVCZ.js.map} +0 -0
  111. /package/dist/{chunk-C3AEZ3BZ.js.map → chunk-YRUJ5KGV.js.map} +0 -0
  112. /package/dist/{cli-FL754H6S.js.map → cli-Y5QZJAHX.js.map} +0 -0
  113. /package/dist/{client-4NP7ZMLV.js.map → client-UGM6MG55.js.map} +0 -0
  114. /package/dist/{detect-providers-AZ6DEQU7.js.map → detect-providers-JFE3QLJI.js.map} +0 -0
  115. /package/dist/{doctor-OFGWOYBC.js.map → doctor-NFWPX75B.js.map} +0 -0
  116. /package/dist/{init-JZJJKC4G.js.map → init-NMSG24BY.js.map} +0 -0
  117. /package/dist/{init-wizard-4VHNOYFO.js.map → init-wizard-WIUCR4JE.js.map} +0 -0
  118. /package/dist/{llm-XJFHRFHB.js.map → llm-O46QYWEM.js.map} +0 -0
  119. /package/dist/{loader-DGWP4EFB.js.map → loader-BQ4X4K3F.js.map} +0 -0
  120. /package/dist/{openai-embeddings-ST3B6GW7.js.map → openai-embeddings-HWAKOGUM.js.map} +0 -0
  121. /package/dist/{openrouter-HJHOO3EO.js.map → openrouter-GXZK7JXR.js.map} +0 -0
  122. /package/dist/{post-compact-O7HMEFKP.js.map → post-compact-3DDK3OVZ.js.map} +0 -0
  123. /package/dist/{post-tool-use-OVNMZ3UG.js.map → post-tool-use-LSG6N3W5.js.map} +0 -0
  124. /package/dist/{post-tool-use-failure-HPXTFYBY.js.map → post-tool-use-failure-5V3OCLI6.js.map} +0 -0
  125. /package/dist/{pre-compact-JD3D4PBB.js.map → pre-compact-F7Y7SDSZ.js.map} +0 -0
  126. /package/dist/{provider-check-SOTDYLJE.js.map → provider-check-CKZW3GQX.js.map} +0 -0
  127. /package/dist/{registry-33MEKDHT.js.map → registry-ZHUVXGPO.js.map} +0 -0
  128. /package/dist/{remove-XDFMOYUL.js.map → remove-VCWRNG54.js.map} +0 -0
  129. /package/dist/{resolution-events-UPHJJLDQ.js.map → resolution-events-WZHPQQMN.js.map} +0 -0
  130. /package/dist/{restart-JBAMRKRJ.js.map → restart-YYJ7SH4K.js.map} +0 -0
  131. /package/dist/{search-43TS5RGA.js.map → search-L7KTBURJ.js.map} +0 -0
  132. /package/dist/{server-UBU7NALJ.js.map → server-GMRVF2PB.js.map} +0 -0
  133. /package/dist/{session-CPBLMD7M.js.map → session-V3SNFG7J.js.map} +0 -0
  134. /package/dist/{session-end-DUHUYE6J.js.map → session-end-V3V3GMP2.js.map} +0 -0
  135. /package/dist/{session-start-I7XM3CME.js.map → session-start-OH7SBUIA.js.map} +0 -0
  136. /package/dist/{setup-llm-TTHEUWDA.js.map → setup-llm-5AMWEAJ5.js.map} +0 -0
  137. /package/dist/{stats-7CE6GEWE.js.map → stats-B2V7P45Y.js.map} +0 -0
  138. /package/dist/{stop-BF3AWA7S.js.map → stop-D6L2KRHZ.js.map} +0 -0
  139. /package/dist/{stop-failure-7Q2LQF2R.js.map → stop-failure-7OM2AYRX.js.map} +0 -0
  140. /package/dist/{subagent-start-QG2J3AN4.js.map → subagent-start-MKL5I54S.js.map} +0 -0
  141. /package/dist/{subagent-stop-WVA7RDIM.js.map → subagent-stop-2E7VKZW2.js.map} +0 -0
  142. /package/dist/{task-completed-AQVQ7GFL.js.map → task-completed-5QHIT773.js.map} +0 -0
  143. /package/dist/{team-LC3K7UXD.js.map → team-TBS5OILG.js.map} +0 -0
  144. /package/dist/{user-prompt-submit-22YQD4XM.js.map → user-prompt-submit-X4BCPMZ4.js.map} +0 -0
  145. /package/dist/{verify-DVIWHZXA.js.map → verify-D7EDVXO5.js.map} +0 -0
  146. /package/dist/{version-VPI6ERF7.js.map → version-GTFCEIJ2.js.map} +0 -0
@@ -15,13 +15,13 @@ import {
15
15
  getEmbeddingQueueDepth,
16
16
  getUnembedded,
17
17
  markEmbedded
18
- } from "./chunk-CHG652UO.js";
18
+ } from "./chunk-RGRPAKEY.js";
19
19
  import {
20
20
  getMachineId
21
21
  } from "./chunk-ENWBFX7F.js";
22
22
  import {
23
23
  createEmbeddingProvider
24
- } from "./chunk-MKKXCCQ5.js";
24
+ } from "./chunk-JHLALJPB.js";
25
25
  import {
26
26
  closeOpenBatches,
27
27
  countRuns,
@@ -44,54 +44,54 @@ import {
44
44
  listTurnsByRun,
45
45
  populateBatchResponses,
46
46
  setResponseSummary
47
- } from "./chunk-FFQES5MC.js";
47
+ } from "./chunk-TCGOSLW6.js";
48
48
  import {
49
49
  fullTextSearch,
50
50
  hydrateSearchResults
51
- } from "./chunk-W6HI4CCS.js";
51
+ } from "./chunk-D4M2AV65.js";
52
52
  import {
53
53
  copyTaskToUser,
54
54
  deleteUserTask,
55
55
  loadAllTasks,
56
56
  validateTaskName,
57
57
  writeUserTask
58
- } from "./chunk-6LL2MQHP.js";
58
+ } from "./chunk-D4ESHOOJ.js";
59
59
  import {
60
60
  AgentTaskSchema,
61
61
  registerAgent,
62
62
  resolveDefinitionsDir,
63
63
  taskFromParsed
64
- } from "./chunk-ZAHDA2PQ.js";
64
+ } from "./chunk-7NBDELZB.js";
65
65
  import {
66
66
  checkLocalProvider
67
- } from "./chunk-C3AEZ3BZ.js";
67
+ } from "./chunk-YRUJ5KGV.js";
68
68
  import {
69
69
  EventBuffer,
70
70
  cleanStaleBuffers,
71
71
  listBufferSessionIds
72
72
  } from "./chunk-V7XG6V6C.js";
73
73
  import "./chunk-IB76KGBY.js";
74
- import "./chunk-AEJS57ZK.js";
75
- import "./chunk-5QERXFH7.js";
76
- import "./chunk-FPMEIN2W.js";
74
+ import "./chunk-J3L2RTYK.js";
75
+ import "./chunk-SW62AX75.js";
76
+ import "./chunk-QL2RBFIC.js";
77
77
  import {
78
78
  loadSecrets,
79
79
  readSecrets,
80
80
  writeSecret
81
81
  } from "./chunk-RJMXDUMA.js";
82
- import "./chunk-LYFDTF7G.js";
82
+ import "./chunk-YRHSTVCZ.js";
83
83
  import "./chunk-SAKJMNSR.js";
84
84
  import {
85
85
  LmStudioBackend,
86
86
  OllamaBackend
87
- } from "./chunk-5SDH75YC.js";
87
+ } from "./chunk-LUQBT2Y4.js";
88
88
  import {
89
89
  countSpores,
90
90
  getSpore,
91
91
  insertSpore,
92
92
  listSpores,
93
93
  updateSporeStatus
94
- } from "./chunk-U7UUJ4FD.js";
94
+ } from "./chunk-Q2AYS2QE.js";
95
95
  import {
96
96
  closeSession,
97
97
  countSessions,
@@ -101,7 +101,7 @@ import {
101
101
  listSessions,
102
102
  updateSession,
103
103
  upsertSession
104
- } from "./chunk-CUDM5YJY.js";
104
+ } from "./chunk-JROOQQH6.js";
105
105
  import {
106
106
  backfillUnsynced,
107
107
  countPending,
@@ -110,12 +110,12 @@ import {
110
110
  markSent,
111
111
  pruneOld,
112
112
  syncRow
113
- } from "./chunk-XLY3REL3.js";
113
+ } from "./chunk-4VSNNMEU.js";
114
114
  import {
115
115
  EMBEDDING_DIMENSIONS,
116
116
  SCHEMA_VERSION,
117
117
  createSchema
118
- } from "./chunk-WZZH3YXJ.js";
118
+ } from "./chunk-PW5QVY44.js";
119
119
  import {
120
120
  CONFIG_FILENAME,
121
121
  MycoConfigSchema,
@@ -132,7 +132,7 @@ import {
132
132
  } from "./chunk-MYX5NCRH.js";
133
133
  import {
134
134
  resolveCliEntryPath
135
- } from "./chunk-YKOEMLJJ.js";
135
+ } from "./chunk-DPJVKNNP.js";
136
136
  import {
137
137
  CONTENT_HASH_ALGORITHM,
138
138
  DAEMON_EVICT_POLL_MS,
@@ -140,6 +140,7 @@ import {
140
140
  DEAD_SESSION_MAX_PROMPTS,
141
141
  DEFAULT_AGENT_ID,
142
142
  DEFAULT_MACHINE_ID,
143
+ DEFAULT_RELEASE_CHANNEL,
143
144
  EMBEDDING_BATCH_SIZE,
144
145
  EXCLUDED_SPORE_STATUSES,
145
146
  FEED_DEFAULT_LIMIT,
@@ -147,7 +148,11 @@ import {
147
148
  LOG_MESSAGE_PREVIEW_CHARS,
148
149
  LOG_PROMPT_PREVIEW_CHARS,
149
150
  MS_PER_DAY,
151
+ MS_PER_HOUR,
150
152
  MS_PER_SECOND,
153
+ MYCO_GLOBAL_DIR,
154
+ NPM_PACKAGE_NAME,
155
+ NPM_REGISTRY_URL,
151
156
  POWER_ACTIVE_INTERVAL_MS,
152
157
  POWER_DEEP_SLEEP_THRESHOLD_MS,
153
158
  POWER_IDLE_THRESHOLD_MS,
@@ -158,6 +163,8 @@ import {
158
163
  PROMPT_CONTEXT_MIN_SIMILARITY,
159
164
  PROMPT_PREVIEW_CHARS,
160
165
  PROMPT_VECTOR_OVER_FETCH,
166
+ RELEASE_CHANNELS,
167
+ RESTART_RESPONSE_FLUSH_MS,
161
168
  SEARCH_RESULTS_DEFAULT_LIMIT,
162
169
  SEARCH_SIMILARITY_THRESHOLD,
163
170
  STALE_BUFFER_MAX_AGE_MS,
@@ -167,19 +174,24 @@ import {
167
174
  TEAM_HEALTH_TIMEOUT_MS,
168
175
  TEAM_SEARCH_TIMEOUT_MS,
169
176
  TEAM_SOURCE_PREFIX,
177
+ UPDATE_CHECK_CACHE_PATH,
178
+ UPDATE_CHECK_INTERVAL_HOURS,
179
+ UPDATE_CONFIG_PATH,
180
+ UPDATE_ERROR_PATH,
181
+ UPDATE_SCRIPT_DELAY_SECONDS,
170
182
  USER_AGENT_ID,
171
183
  USER_AGENT_NAME,
172
184
  USER_TASK_SOURCE,
173
185
  epochSeconds,
174
186
  estimateTokens
175
- } from "./chunk-76ZO5RGT.js";
187
+ } from "./chunk-PIRWYDOH.js";
176
188
  import {
177
189
  LOG_KINDS,
178
190
  kindToComponent
179
191
  } from "./chunk-S6I62FAH.js";
180
192
  import {
181
193
  getPluginVersion
182
- } from "./chunk-JYXMRW3T.js";
194
+ } from "./chunk-TY7A5OZ5.js";
183
195
  import {
184
196
  loadManifests
185
197
  } from "./chunk-QFMBZ72S.js";
@@ -1634,7 +1646,6 @@ import { spawn } from "child_process";
1634
1646
  var RestartBodySchema = external_exports.object({
1635
1647
  force: external_exports.boolean().optional()
1636
1648
  }).optional();
1637
- var RESTART_RESPONSE_FLUSH_MS = 500;
1638
1649
  var RESTART_CHILD_DELAY_SECONDS = 3;
1639
1650
  async function handleRestart(deps, body) {
1640
1651
  const parsed = RestartBodySchema.safeParse(body);
@@ -1658,9 +1669,287 @@ async function handleRestart(deps, body) {
1658
1669
  return { body: { status: "restarting" } };
1659
1670
  }
1660
1671
 
1661
- // src/daemon/backup.ts
1672
+ // src/daemon/update-checker.ts
1673
+ var import_yaml = __toESM(require_dist(), 1);
1662
1674
  import fs8 from "fs";
1663
1675
  import path10 from "path";
1676
+ import semver from "semver";
1677
+ var REGISTRY_FETCH_TIMEOUT_MS = 1e4;
1678
+ function isUpdateExempt() {
1679
+ return Boolean(process.env.MYCO_CMD);
1680
+ }
1681
+ function defaultUpdateConfig() {
1682
+ return {
1683
+ channel: DEFAULT_RELEASE_CHANNEL,
1684
+ check_interval_hours: UPDATE_CHECK_INTERVAL_HOURS
1685
+ };
1686
+ }
1687
+ function readUpdateConfig() {
1688
+ try {
1689
+ const raw = fs8.readFileSync(UPDATE_CONFIG_PATH, "utf-8");
1690
+ const parsed = import_yaml.default.parse(raw);
1691
+ const channel = RELEASE_CHANNELS.includes(parsed?.channel) ? parsed.channel : DEFAULT_RELEASE_CHANNEL;
1692
+ const check_interval_hours = typeof parsed?.check_interval_hours === "number" && parsed.check_interval_hours > 0 ? parsed.check_interval_hours : UPDATE_CHECK_INTERVAL_HOURS;
1693
+ return { channel, check_interval_hours };
1694
+ } catch {
1695
+ return defaultUpdateConfig();
1696
+ }
1697
+ }
1698
+ function writeUpdateConfig(config) {
1699
+ fs8.mkdirSync(MYCO_GLOBAL_DIR, { recursive: true });
1700
+ fs8.writeFileSync(UPDATE_CONFIG_PATH, import_yaml.default.stringify(config), "utf-8");
1701
+ }
1702
+ function readCachedCheck() {
1703
+ try {
1704
+ const raw = fs8.readFileSync(UPDATE_CHECK_CACHE_PATH, "utf-8");
1705
+ return JSON.parse(raw);
1706
+ } catch {
1707
+ return null;
1708
+ }
1709
+ }
1710
+ function clearCachedCheck() {
1711
+ try {
1712
+ fs8.unlinkSync(UPDATE_CHECK_CACHE_PATH);
1713
+ } catch {
1714
+ }
1715
+ }
1716
+ function isCacheStale(cache, intervalHours) {
1717
+ if (cache === null) return true;
1718
+ const checkedAt = new Date(cache.checked_at).getTime();
1719
+ if (isNaN(checkedAt)) return true;
1720
+ const ageMs = Date.now() - checkedAt;
1721
+ return ageMs > intervalHours * MS_PER_HOUR;
1722
+ }
1723
+ function resolveTargetVersion(distTags, channel) {
1724
+ const stable = distTags.latest;
1725
+ const beta = distTags.beta ?? null;
1726
+ if (channel === "stable" || beta === null) {
1727
+ return stable;
1728
+ }
1729
+ const higher = semver.gt(beta, stable) ? beta : stable;
1730
+ return higher;
1731
+ }
1732
+ function buildCheckResult(currentVersion, cache, config, error) {
1733
+ const targetVersion = resolveTargetVersion(
1734
+ { latest: cache.latest_stable, beta: cache.latest_beta ?? void 0 },
1735
+ cache.channel
1736
+ );
1737
+ const update_available = semver.valid(currentVersion) !== null && semver.valid(targetVersion) !== null && semver.gt(targetVersion, currentVersion);
1738
+ return {
1739
+ update_available,
1740
+ running_version: currentVersion,
1741
+ latest_version: targetVersion,
1742
+ latest_stable: cache.latest_stable,
1743
+ latest_beta: cache.latest_beta,
1744
+ channel: cache.channel,
1745
+ check_interval_hours: config.check_interval_hours,
1746
+ last_check: cache.checked_at,
1747
+ error
1748
+ };
1749
+ }
1750
+ async function checkForUpdate(currentVersion) {
1751
+ const config = readUpdateConfig();
1752
+ const existingCache = readCachedCheck();
1753
+ let distTags;
1754
+ let fetchError = null;
1755
+ try {
1756
+ const response = await fetch(NPM_REGISTRY_URL, {
1757
+ signal: AbortSignal.timeout(REGISTRY_FETCH_TIMEOUT_MS)
1758
+ });
1759
+ if (!response.ok) {
1760
+ throw new Error(`Registry responded with ${response.status}`);
1761
+ }
1762
+ const data = await response.json();
1763
+ distTags = data["dist-tags"];
1764
+ } catch (err) {
1765
+ fetchError = err instanceof Error ? err.message : String(err);
1766
+ if (existingCache !== null) {
1767
+ return buildCheckResult(currentVersion, existingCache, config, fetchError);
1768
+ }
1769
+ return {
1770
+ update_available: false,
1771
+ running_version: currentVersion,
1772
+ latest_version: currentVersion,
1773
+ latest_stable: currentVersion,
1774
+ latest_beta: null,
1775
+ channel: config.channel,
1776
+ check_interval_hours: config.check_interval_hours,
1777
+ last_check: (/* @__PURE__ */ new Date()).toISOString(),
1778
+ error: fetchError
1779
+ };
1780
+ }
1781
+ const latestStable = distTags.latest;
1782
+ const latestBeta = distTags.beta ?? null;
1783
+ const targetVersion = resolveTargetVersion(distTags, config.channel);
1784
+ const freshCache = {
1785
+ checked_at: (/* @__PURE__ */ new Date()).toISOString(),
1786
+ current_version: currentVersion,
1787
+ latest_stable: latestStable,
1788
+ latest_beta: latestBeta,
1789
+ channel: config.channel
1790
+ };
1791
+ try {
1792
+ fs8.mkdirSync(path10.dirname(UPDATE_CHECK_CACHE_PATH), { recursive: true });
1793
+ fs8.writeFileSync(UPDATE_CHECK_CACHE_PATH, JSON.stringify(freshCache, null, 2), "utf-8");
1794
+ } catch {
1795
+ }
1796
+ return buildCheckResult(currentVersion, freshCache, config, null);
1797
+ }
1798
+ function statusFromCache(currentVersion, cache, config) {
1799
+ const resolvedCache = cache !== void 0 ? cache : readCachedCheck();
1800
+ if (resolvedCache === null) return null;
1801
+ const resolvedConfig = config !== void 0 ? config : readUpdateConfig();
1802
+ return buildCheckResult(currentVersion, resolvedCache, resolvedConfig, null);
1803
+ }
1804
+
1805
+ // src/daemon/update-installer.ts
1806
+ import fs9 from "fs";
1807
+ import os7 from "os";
1808
+ import path11 from "path";
1809
+ import { spawn as spawn2 } from "child_process";
1810
+ function generateUpdateScript(params) {
1811
+ const { targetVersion, projectRoot, vaultDir } = params;
1812
+ const packageSpec = `${NPM_PACKAGE_NAME}@${targetVersion}`;
1813
+ const quotedProjectRoot = JSON.stringify(projectRoot);
1814
+ const quotedVaultDir = JSON.stringify(vaultDir);
1815
+ const quotedErrorPath = JSON.stringify(UPDATE_ERROR_PATH);
1816
+ const errorJson = JSON.stringify(
1817
+ JSON.stringify({ error: `npm install failed for ${packageSpec}` })
1818
+ );
1819
+ return `#!/bin/sh
1820
+ set -e
1821
+
1822
+ # Wait for daemon to exit cleanly
1823
+ sleep ${UPDATE_SCRIPT_DELAY_SECONDS}
1824
+
1825
+ # Attempt the update
1826
+ if npm install -g ${packageSpec} 2>&1; then
1827
+ # Sync project files (gitignore, symbiont registration)
1828
+ myco update --project ${quotedProjectRoot} || true
1829
+ # Clear any previous error
1830
+ rm -f ${quotedErrorPath}
1831
+ else
1832
+ # Write error and attempt restart with old version
1833
+ echo ${errorJson} > ${quotedErrorPath}
1834
+ fi
1835
+
1836
+ # Restart daemon (works whether install succeeded or failed)
1837
+ myco daemon --vault ${quotedVaultDir} &
1838
+
1839
+ # Clean up this script
1840
+ rm -f "$0"
1841
+ `;
1842
+ }
1843
+ function spawnUpdateScript(params) {
1844
+ fs9.mkdirSync(MYCO_GLOBAL_DIR, { recursive: true });
1845
+ const scriptName = `myco-update-${Date.now()}.sh`;
1846
+ const scriptPath = path11.join(os7.tmpdir(), scriptName);
1847
+ const script = generateUpdateScript(params);
1848
+ fs9.writeFileSync(scriptPath, script, { encoding: "utf-8", mode: 493 });
1849
+ const child = spawn2("/bin/sh", [scriptPath], {
1850
+ detached: true,
1851
+ stdio: "ignore"
1852
+ });
1853
+ child.unref();
1854
+ return scriptPath;
1855
+ }
1856
+
1857
+ // src/daemon/api/update.ts
1858
+ var ChannelBodySchema = external_exports.object({
1859
+ channel: external_exports.enum(RELEASE_CHANNELS)
1860
+ });
1861
+ function createUpdateHandlers(deps) {
1862
+ const { vaultDir, projectRoot, currentVersion, scheduleShutdown } = deps;
1863
+ async function handleUpdateStatus(_req) {
1864
+ if (isUpdateExempt()) {
1865
+ return { body: { exempt: true, running_version: currentVersion } };
1866
+ }
1867
+ const config = readUpdateConfig();
1868
+ const cache = readCachedCheck();
1869
+ if (isCacheStale(cache, config.check_interval_hours)) {
1870
+ checkForUpdate(currentVersion).catch(() => {
1871
+ });
1872
+ }
1873
+ const status = statusFromCache(currentVersion, cache, config);
1874
+ if (!status) {
1875
+ return {
1876
+ body: {
1877
+ exempt: false,
1878
+ update_available: false,
1879
+ running_version: currentVersion,
1880
+ latest_version: currentVersion,
1881
+ latest_stable: currentVersion,
1882
+ latest_beta: null,
1883
+ channel: config.channel,
1884
+ check_interval_hours: config.check_interval_hours,
1885
+ last_check: "",
1886
+ error: null
1887
+ }
1888
+ };
1889
+ }
1890
+ return { body: { exempt: false, ...status } };
1891
+ }
1892
+ async function handleUpdateCheck(_req) {
1893
+ if (isUpdateExempt()) {
1894
+ return {
1895
+ status: 400,
1896
+ body: { error: "update_exempt", message: "Updates disabled in dev mode" }
1897
+ };
1898
+ }
1899
+ const result = await checkForUpdate(currentVersion);
1900
+ return { body: { exempt: false, ...result } };
1901
+ }
1902
+ async function handleUpdateApply(_req) {
1903
+ if (isUpdateExempt()) {
1904
+ return { status: 400, body: { error: "update_exempt" } };
1905
+ }
1906
+ const status = statusFromCache(currentVersion);
1907
+ if (!status || !status.update_available) {
1908
+ return { status: 400, body: { error: "no_update_available" } };
1909
+ }
1910
+ spawnUpdateScript({ targetVersion: status.latest_version, projectRoot, vaultDir });
1911
+ scheduleShutdown();
1912
+ return { body: { status: "applying", version: status.latest_version } };
1913
+ }
1914
+ async function handleUpdateChannel(req) {
1915
+ const parsed = ChannelBodySchema.safeParse(req.body);
1916
+ if (!parsed.success) {
1917
+ return { status: 400, body: { error: "invalid_channel" } };
1918
+ }
1919
+ const { channel } = parsed.data;
1920
+ const config = readUpdateConfig();
1921
+ writeUpdateConfig({ ...config, channel });
1922
+ clearCachedCheck();
1923
+ const channelStatus = statusFromCache(currentVersion);
1924
+ if (!channelStatus) {
1925
+ return {
1926
+ body: {
1927
+ exempt: false,
1928
+ update_available: false,
1929
+ running_version: currentVersion,
1930
+ latest_version: currentVersion,
1931
+ latest_stable: currentVersion,
1932
+ latest_beta: null,
1933
+ channel,
1934
+ check_interval_hours: config.check_interval_hours,
1935
+ last_check: "",
1936
+ error: null
1937
+ }
1938
+ };
1939
+ }
1940
+ return { body: { exempt: false, ...channelStatus } };
1941
+ }
1942
+ return {
1943
+ handleUpdateStatus,
1944
+ handleUpdateCheck,
1945
+ handleUpdateApply,
1946
+ handleUpdateChannel
1947
+ };
1948
+ }
1949
+
1950
+ // src/daemon/backup.ts
1951
+ import fs10 from "fs";
1952
+ import path12 from "path";
1664
1953
  var BACKUP_TABLES = [
1665
1954
  "sessions",
1666
1955
  "prompt_batches",
@@ -1686,7 +1975,7 @@ function toSqlLiteral(value) {
1686
1975
  return `'${escapeSql(String(value))}'`;
1687
1976
  }
1688
1977
  function createBackup(db, backupDir, machineId) {
1689
- fs8.mkdirSync(backupDir, { recursive: true });
1978
+ fs10.mkdirSync(backupDir, { recursive: true });
1690
1979
  const lines = [];
1691
1980
  const timestamp = epochSeconds();
1692
1981
  lines.push(`${BACKUP_HEADER_TEMPLATE}: machine_id=${machineId}, created_at=${timestamp}`);
@@ -1704,22 +1993,22 @@ function createBackup(db, backupDir, machineId) {
1704
1993
  }
1705
1994
  lines.push("");
1706
1995
  }
1707
- const filePath = path10.join(backupDir, `${machineId}${BACKUP_EXTENSION}`);
1708
- fs8.writeFileSync(filePath, lines.join("\n"), "utf-8");
1996
+ const filePath = path12.join(backupDir, `${machineId}${BACKUP_EXTENSION}`);
1997
+ fs10.writeFileSync(filePath, lines.join("\n"), "utf-8");
1709
1998
  return filePath;
1710
1999
  }
1711
2000
  function listBackups(backupDir) {
1712
2001
  let entries;
1713
2002
  try {
1714
- entries = fs8.readdirSync(backupDir);
2003
+ entries = fs10.readdirSync(backupDir);
1715
2004
  } catch {
1716
2005
  return [];
1717
2006
  }
1718
2007
  const backups = [];
1719
2008
  for (const entry of entries) {
1720
2009
  if (!entry.endsWith(BACKUP_EXTENSION)) continue;
1721
- const filePath = path10.join(backupDir, entry);
1722
- const stat = fs8.statSync(filePath);
2010
+ const filePath = path12.join(backupDir, entry);
2011
+ const stat = fs10.statSync(filePath);
1723
2012
  backups.push({
1724
2013
  machine_id: entry.slice(0, -BACKUP_EXTENSION.length),
1725
2014
  file_name: entry,
@@ -1731,7 +2020,7 @@ function listBackups(backupDir) {
1731
2020
  }
1732
2021
  var INSERT_REGEX = /^INSERT OR IGNORE INTO (\w+)\s+\(([^)]+)\)\s+VALUES\s+\((.+)\);$/;
1733
2022
  function parseBackupFile(backupPath) {
1734
- const content = fs8.readFileSync(backupPath, "utf-8");
2023
+ const content = fs10.readFileSync(backupPath, "utf-8");
1735
2024
  const inserts = [];
1736
2025
  for (const line of content.split("\n")) {
1737
2026
  const match = INSERT_REGEX.exec(line);
@@ -1980,15 +2269,15 @@ var TeamSyncClient = class {
1980
2269
  "Content-Type": "application/json"
1981
2270
  };
1982
2271
  }
1983
- async request(method, path14, body) {
1984
- const res = await this.fetchFn(`${this.workerUrl}${path14}`, {
2272
+ async request(method, path16, body) {
2273
+ const res = await this.fetchFn(`${this.workerUrl}${path16}`, {
1985
2274
  method,
1986
2275
  headers: this.headers(),
1987
2276
  body: body !== void 0 ? JSON.stringify(body) : void 0
1988
2277
  });
1989
2278
  if (!res.ok) {
1990
2279
  const text = await res.text().catch(() => "");
1991
- throw new Error(`Team sync request ${method} ${path14} failed: ${res.status} ${text}`);
2280
+ throw new Error(`Team sync request ${method} ${path16} failed: ${res.status} ${text}`);
1992
2281
  }
1993
2282
  return res.json();
1994
2283
  }
@@ -2224,12 +2513,12 @@ async function handleGetModels(req) {
2224
2513
 
2225
2514
  // src/daemon/api/stats.ts
2226
2515
  import { createHash as createHash3 } from "crypto";
2227
- import fs9 from "fs";
2228
- import path11 from "path";
2516
+ import fs11 from "fs";
2517
+ import path13 from "path";
2229
2518
  function computeConfigHash(vaultDir) {
2230
2519
  try {
2231
- const configPath = path11.join(vaultDir, CONFIG_FILENAME);
2232
- const raw = fs9.readFileSync(configPath, "utf-8");
2520
+ const configPath = path13.join(vaultDir, CONFIG_FILENAME);
2521
+ const raw = fs11.readFileSync(configPath, "utf-8");
2233
2522
  return createHash3("md5").update(raw).digest("hex");
2234
2523
  } catch {
2235
2524
  return "";
@@ -3825,7 +4114,7 @@ var SqliteRecordSource = class {
3825
4114
  };
3826
4115
 
3827
4116
  // src/daemon/api/agent-tasks.ts
3828
- var import_yaml = __toESM(require_dist(), 1);
4117
+ var import_yaml2 = __toESM(require_dist(), 1);
3829
4118
  var HTTP_OK = 200;
3830
4119
  var HTTP_CREATED = 201;
3831
4120
  var HTTP_BAD_REQUEST = 400;
@@ -3913,7 +4202,7 @@ async function handleGetTaskYaml(req, vaultDir) {
3913
4202
  return { status: HTTP_NOT_FOUND, body: { error: "task_not_found", name: taskName } };
3914
4203
  }
3915
4204
  const { isBuiltin: _ib, source: _src, ...serializable } = task;
3916
- const yaml = (0, import_yaml.stringify)(serializable);
4205
+ const yaml = (0, import_yaml2.stringify)(serializable);
3917
4206
  return { status: HTTP_OK, body: { yaml, source: task.source } };
3918
4207
  }
3919
4208
  async function handleUpdateTask(req, vaultDir) {
@@ -3933,7 +4222,7 @@ async function handleUpdateTask(req, vaultDir) {
3933
4222
  return { status: HTTP_BAD_REQUEST, body: { error: "missing_yaml_field" } };
3934
4223
  }
3935
4224
  try {
3936
- const parsed = AgentTaskSchema.parse((0, import_yaml.parse)(yamlContent));
4225
+ const parsed = AgentTaskSchema.parse((0, import_yaml2.parse)(yamlContent));
3937
4226
  const task = { ...taskFromParsed(parsed), isBuiltin: false, source: USER_TASK_SOURCE };
3938
4227
  if (task.name !== taskName) {
3939
4228
  return { status: HTTP_BAD_REQUEST, body: { error: "name_mismatch", expected: taskName, got: task.name } };
@@ -4046,19 +4335,19 @@ function testCloud() {
4046
4335
  }
4047
4336
 
4048
4337
  // src/daemon/log-reconcile.ts
4049
- import fs10 from "fs";
4050
- import path12 from "path";
4338
+ import fs12 from "fs";
4339
+ import path14 from "path";
4051
4340
  function reconcileLogBuffer(logDir, sinceTimestamp) {
4052
4341
  let replayed = 0;
4053
4342
  const files = [];
4054
4343
  for (let i = 3; i >= 1; i--) {
4055
- const rotated = path12.join(logDir, `daemon.${i}.log`);
4056
- if (fs10.existsSync(rotated)) files.push(rotated);
4344
+ const rotated = path14.join(logDir, `daemon.${i}.log`);
4345
+ if (fs12.existsSync(rotated)) files.push(rotated);
4057
4346
  }
4058
- const current = path12.join(logDir, "daemon.log");
4059
- if (fs10.existsSync(current)) files.push(current);
4347
+ const current = path14.join(logDir, "daemon.log");
4348
+ if (fs12.existsSync(current)) files.push(current);
4060
4349
  for (const file of files) {
4061
- const content = fs10.readFileSync(file, "utf-8");
4350
+ const content = fs12.readFileSync(file, "utf-8");
4062
4351
  for (const line of content.split("\n")) {
4063
4352
  if (!line.trim()) continue;
4064
4353
  try {
@@ -4274,8 +4563,8 @@ async function runSessionMaintenance(deps) {
4274
4563
  }
4275
4564
 
4276
4565
  // src/daemon/main.ts
4277
- import fs11 from "fs";
4278
- import path13 from "path";
4566
+ import fs13 from "fs";
4567
+ import path15 from "path";
4279
4568
  var AGENT_RUNS_DEFAULT_LIMIT = 50;
4280
4569
  var TOOL_INPUT_STORE_LIMIT = 4e3;
4281
4570
  var TOOL_OUTPUT_STORE_LIMIT = 2e3;
@@ -4401,10 +4690,10 @@ function handleCompact(sessionId, phase, trigger, compactSummary) {
4401
4690
  });
4402
4691
  }
4403
4692
  function killStaleDaemon(vaultDir, logger) {
4404
- const daemonJsonPath = path13.join(vaultDir, "daemon.json");
4693
+ const daemonJsonPath = path15.join(vaultDir, "daemon.json");
4405
4694
  try {
4406
- if (!fs11.existsSync(daemonJsonPath)) return;
4407
- const info = JSON.parse(fs11.readFileSync(daemonJsonPath, "utf-8"));
4695
+ if (!fs13.existsSync(daemonJsonPath)) return;
4696
+ const info = JSON.parse(fs13.readFileSync(daemonJsonPath, "utf-8"));
4408
4697
  if (!info.pid) return;
4409
4698
  if (info.pid === process.pid) return;
4410
4699
  try {
@@ -4413,7 +4702,7 @@ function killStaleDaemon(vaultDir, logger) {
4413
4702
  logger.info(LOG_KINDS.DAEMON_START, "Killed stale daemon", { pid: info.pid });
4414
4703
  } catch {
4415
4704
  }
4416
- fs11.unlinkSync(daemonJsonPath);
4705
+ fs13.unlinkSync(daemonJsonPath);
4417
4706
  } catch {
4418
4707
  }
4419
4708
  }
@@ -4423,7 +4712,7 @@ async function main() {
4423
4712
  process.stderr.write("Usage: mycod --vault <path>\n");
4424
4713
  process.exit(1);
4425
4714
  }
4426
- const vaultDir = path13.resolve(vaultArg);
4715
+ const vaultDir = path15.resolve(vaultArg);
4427
4716
  loadSecrets(vaultDir);
4428
4717
  const config = loadConfig(vaultDir);
4429
4718
  const manifests = loadManifests();
@@ -4434,7 +4723,7 @@ async function main() {
4434
4723
  projectRoot,
4435
4724
  extensions: config.capture.artifact_extensions
4436
4725
  };
4437
- const logger = new DaemonLogger(path13.join(vaultDir, "logs"), {
4726
+ const logger = new DaemonLogger(path15.join(vaultDir, "logs"), {
4438
4727
  level: config.daemon.log_level
4439
4728
  });
4440
4729
  killStaleDaemon(vaultDir, logger);
@@ -4463,13 +4752,13 @@ async function main() {
4463
4752
  });
4464
4753
  const lastLogTimestamp = getMaxTimestamp();
4465
4754
  if (lastLogTimestamp) {
4466
- const logDir = path13.join(vaultDir, "logs");
4755
+ const logDir = path15.join(vaultDir, "logs");
4467
4756
  const replayedCount = reconcileLogBuffer(logDir, lastLogTimestamp);
4468
4757
  if (replayedCount > 0) {
4469
4758
  logger.info(LOG_KINDS.DAEMON_RECONCILE, `Replayed ${replayedCount} log entries from buffer`, { replayed: replayedCount });
4470
4759
  }
4471
4760
  }
4472
- const vectorsDbPath = path13.join(vaultDir, "vectors.db");
4761
+ const vectorsDbPath = path15.join(vaultDir, "vectors.db");
4473
4762
  const vectorStore = new SqliteVecVectorStore(vectorsDbPath);
4474
4763
  const llmProvider = createEmbeddingProvider(config.embedding);
4475
4764
  const embeddingProvider = new EmbeddingProviderAdapter(llmProvider, config.embedding);
@@ -4477,7 +4766,7 @@ async function main() {
4477
4766
  const embeddingManager = new EmbeddingManager(vectorStore, embeddingProvider, recordSource, logger);
4478
4767
  logger.info(LOG_KINDS.EMBEDDING_EMBED, "EmbeddingManager initialized", { vectors_db: vectorsDbPath });
4479
4768
  try {
4480
- const { registerBuiltInAgentsAndTasks, resolveDefinitionsDir: resolveDefinitionsDir2 } = await import("./loader-DGWP4EFB.js");
4769
+ const { registerBuiltInAgentsAndTasks, resolveDefinitionsDir: resolveDefinitionsDir2 } = await import("./loader-BQ4X4K3F.js");
4481
4770
  const definitionsDir = resolveDefinitionsDir2();
4482
4771
  await registerBuiltInAgentsAndTasks(definitionsDir, vaultDir);
4483
4772
  logger.info(LOG_KINDS.AGENT_TASK, "Built-in agents and tasks registered");
@@ -4503,10 +4792,10 @@ async function main() {
4503
4792
  }
4504
4793
  let uiDir = null;
4505
4794
  {
4506
- const root = findPackageRoot(path13.dirname(new URL(import.meta.url).pathname));
4795
+ const root = findPackageRoot(path15.dirname(new URL(import.meta.url).pathname));
4507
4796
  if (root) {
4508
- const candidate = path13.join(root, "dist", "ui");
4509
- if (fs11.existsSync(candidate)) uiDir = candidate;
4797
+ const candidate = path15.join(root, "dist", "ui");
4798
+ if (fs13.existsSync(candidate)) uiDir = candidate;
4510
4799
  }
4511
4800
  }
4512
4801
  if (uiDir) {
@@ -4543,7 +4832,7 @@ async function main() {
4543
4832
  const running = getRunningRun(DEFAULT_AGENT_ID);
4544
4833
  if (running) return;
4545
4834
  try {
4546
- const { runAgent } = await import("./executor-SWXSN7ZC.js");
4835
+ const { runAgent } = await import("./executor-ESRLUCGU.js");
4547
4836
  runAgent(vaultDir, {
4548
4837
  task: "title-summary",
4549
4838
  instruction: `Process session ${sessionId} only`,
@@ -4552,7 +4841,7 @@ async function main() {
4552
4841
  } catch {
4553
4842
  }
4554
4843
  }
4555
- const bufferDir = path13.join(vaultDir, "buffer");
4844
+ const bufferDir = path15.join(vaultDir, "buffer");
4556
4845
  const sessionBuffers = /* @__PURE__ */ new Map();
4557
4846
  const startupCleanedCount = cleanStaleBuffers(bufferDir, STALE_BUFFER_MAX_AGE_MS);
4558
4847
  if (startupCleanedCount > 0) {
@@ -4596,9 +4885,9 @@ async function main() {
4596
4885
  function reconcileSession(sessionId) {
4597
4886
  if (reconciledSessions.has(sessionId)) return;
4598
4887
  reconciledSessions.add(sessionId);
4599
- const bufferPath = path13.join(bufferDir, `${sessionId}.jsonl`);
4600
- if (!fs11.existsSync(bufferPath)) return;
4601
- const content = fs11.readFileSync(bufferPath, "utf-8").trim();
4888
+ const bufferPath = path15.join(bufferDir, `${sessionId}.jsonl`);
4889
+ if (!fs13.existsSync(bufferPath)) return;
4890
+ const content = fs13.readFileSync(bufferPath, "utf-8").trim();
4602
4891
  if (!content) return;
4603
4892
  if (!getSession(sessionId)) {
4604
4893
  logger.debug(LOG_KINDS.LIFECYCLE_RECONCILE, "Skipping reconciliation for deleted session", { session_id: sessionId });
@@ -4753,10 +5042,10 @@ async function main() {
4753
5042
  );
4754
5043
  if (planFilePath) {
4755
5044
  const captureSessionId = event.session_id;
4756
- fs11.promises.readFile(planFilePath, "utf-8").then((planContent) => {
5045
+ fs13.promises.readFile(planFilePath, "utf-8").then((planContent) => {
4757
5046
  const latestBatch = getLatestBatch(captureSessionId);
4758
5047
  capturePlan({
4759
- sourcePath: path13.relative(projectRoot, planFilePath),
5048
+ sourcePath: path15.relative(projectRoot, planFilePath),
4760
5049
  content: planContent,
4761
5050
  sessionId: captureSessionId,
4762
5051
  promptBatchId: latestBatch?.id ?? null
@@ -5142,6 +5431,21 @@ async function main() {
5142
5431
  });
5143
5432
  server.registerRoute("GET", "/api/models", async (req) => handleGetModels(req));
5144
5433
  server.registerRoute("POST", "/api/restart", async (req) => handleRestart({ vaultDir, progressTracker }, req.body));
5434
+ const updateProjectRoot = path15.dirname(vaultDir);
5435
+ const updateHandlers = createUpdateHandlers({
5436
+ vaultDir,
5437
+ projectRoot: updateProjectRoot,
5438
+ currentVersion: server.version,
5439
+ scheduleShutdown: () => {
5440
+ setTimeout(() => {
5441
+ process.kill(process.pid, "SIGTERM");
5442
+ }, RESTART_RESPONSE_FLUSH_MS);
5443
+ }
5444
+ });
5445
+ server.registerRoute("GET", "/api/update/status", async (req) => updateHandlers.handleUpdateStatus(req));
5446
+ server.registerRoute("POST", "/api/update/check", async (req) => updateHandlers.handleUpdateCheck(req));
5447
+ server.registerRoute("POST", "/api/update/apply", async (req) => updateHandlers.handleUpdateApply(req));
5448
+ server.registerRoute("PUT", "/api/update/channel", async (req) => updateHandlers.handleUpdateChannel(req));
5145
5449
  server.registerRoute("GET", "/api/progress/:token", async (req) => handleGetProgress(progressTracker, req.params.token));
5146
5450
  server.registerRoute("GET", "/api/sessions", handleListSessions);
5147
5451
  server.registerRoute("GET", "/api/sessions/:id", handleGetSession);
@@ -5191,14 +5495,14 @@ async function main() {
5191
5495
  const contentType2 = att.media_type ?? "application/octet-stream";
5192
5496
  return { status: 200, headers: { "Content-Type": contentType2 }, body: att.data };
5193
5497
  }
5194
- const filePath = path13.join(vaultDir, "attachments", filename);
5498
+ const filePath = path15.join(vaultDir, "attachments", filename);
5195
5499
  let diskData;
5196
5500
  try {
5197
- diskData = fs11.readFileSync(filePath);
5501
+ diskData = fs13.readFileSync(filePath);
5198
5502
  } catch {
5199
5503
  return { status: 404, body: { error: "not_found" } };
5200
5504
  }
5201
- const ext = path13.extname(filename).slice(1).toLowerCase();
5505
+ const ext = path15.extname(filename).slice(1).toLowerCase();
5202
5506
  const contentType = ATTACHMENT_MEDIA_TYPES[ext] ?? "application/octet-stream";
5203
5507
  return { status: 200, headers: { "Content-Type": contentType }, body: diskData };
5204
5508
  });
@@ -5209,7 +5513,7 @@ async function main() {
5209
5513
  });
5210
5514
  server.registerRoute("POST", "/api/agent/run", async (req) => {
5211
5515
  const { task, instruction, agentId } = AgentRunBody.parse(req.body);
5212
- const { runAgent } = await import("./executor-SWXSN7ZC.js");
5516
+ const { runAgent } = await import("./executor-ESRLUCGU.js");
5213
5517
  const resultPromise = runAgent(vaultDir, { task, instruction, agentId, embeddingManager });
5214
5518
  const effectiveAgentId = agentId ?? "myco-agent";
5215
5519
  const latestRun = getRunningRun(effectiveAgentId);
@@ -5390,7 +5694,7 @@ async function main() {
5390
5694
  name: USER_AGENT_NAME,
5391
5695
  created_at: now
5392
5696
  });
5393
- const { insertResolutionEvent } = await import("./resolution-events-UPHJJLDQ.js");
5697
+ const { insertResolutionEvent } = await import("./resolution-events-WZHPQQMN.js");
5394
5698
  const resolutionId = `res-${randomBytes(RESOLUTION_ID_RANDOM_BYTES).toString("hex")}`;
5395
5699
  insertResolutionEvent({
5396
5700
  id: resolutionId,
@@ -5409,7 +5713,7 @@ async function main() {
5409
5713
  }
5410
5714
  };
5411
5715
  });
5412
- const backupDir = config.backup.dir ? path13.resolve(config.backup.dir) : path13.resolve(vaultDir, "backups");
5716
+ const backupDir = config.backup.dir ? path15.resolve(config.backup.dir) : path15.resolve(vaultDir, "backups");
5413
5717
  const backupHandlers = createBackupHandlers({ db, backupDir, machineId });
5414
5718
  server.registerRoute("POST", "/api/backup", backupHandlers.handleCreateBackup);
5415
5719
  server.registerRoute("GET", "/api/backups", backupHandlers.handleListBackups);
@@ -5417,7 +5721,7 @@ async function main() {
5417
5721
  server.registerRoute("POST", "/api/restore", backupHandlers.handleRestore);
5418
5722
  server.registerRoute("GET", "/api/backup/config", async () => {
5419
5723
  const cfg = loadConfig(vaultDir);
5420
- return { body: { dir: cfg.backup.dir ?? null, default_dir: path13.resolve(vaultDir, "backups") } };
5724
+ return { body: { dir: cfg.backup.dir ?? null, default_dir: path15.resolve(vaultDir, "backups") } };
5421
5725
  });
5422
5726
  server.registerRoute("PUT", "/api/backup/config", async (req) => {
5423
5727
  const { dir } = req.body;
@@ -5545,7 +5849,7 @@ async function main() {
5545
5849
  lastAgentRun = Date.now();
5546
5850
  try {
5547
5851
  logger.info(LOG_KINDS.AGENT_AUTO_RUN, "Unprocessed batches found, starting agent", { count });
5548
- const { runAgent } = await import("./executor-SWXSN7ZC.js");
5852
+ const { runAgent } = await import("./executor-ESRLUCGU.js");
5549
5853
  const runResult = await runAgent(vaultDir, { embeddingManager });
5550
5854
  logger.info(LOG_KINDS.AGENT_RUN, "Agent run completed", { status: runResult.status, runId: runResult.runId });
5551
5855
  } catch (err) {
@@ -5650,4 +5954,4 @@ export {
5650
5954
  handleUserPrompt,
5651
5955
  main
5652
5956
  };
5653
- //# sourceMappingURL=main-UBUZTMGV.js.map
5957
+ //# sourceMappingURL=main-3NTAT7ZD.js.map