@mastra/code-sdk 0.0.0-esbuild-bundle-worker-20260807173433

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 (491) hide show
  1. package/CHANGELOG.md +1349 -0
  2. package/LICENSE.md +30 -0
  3. package/README.md +70 -0
  4. package/dist/acp/agent.d.ts +35 -0
  5. package/dist/acp/agent.d.ts.map +1 -0
  6. package/dist/acp/agent.js +161 -0
  7. package/dist/acp/agent.js.map +1 -0
  8. package/dist/acp/event-mapper.d.ts +22 -0
  9. package/dist/acp/event-mapper.d.ts.map +1 -0
  10. package/dist/acp/event-mapper.js +214 -0
  11. package/dist/acp/event-mapper.js.map +1 -0
  12. package/dist/acp/index.d.ts +8 -0
  13. package/dist/acp/index.d.ts.map +1 -0
  14. package/dist/acp/index.js +65 -0
  15. package/dist/acp/index.js.map +1 -0
  16. package/dist/acp/server.d.ts +7 -0
  17. package/dist/acp/server.d.ts.map +1 -0
  18. package/dist/acp/server.js +35 -0
  19. package/dist/acp/server.js.map +1 -0
  20. package/dist/acp.d.ts +2 -0
  21. package/dist/acp.d.ts.map +1 -0
  22. package/dist/acp.js +2 -0
  23. package/dist/agents/credential-resolver.d.ts +51 -0
  24. package/dist/agents/credential-resolver.d.ts.map +1 -0
  25. package/dist/agents/credential-resolver.js +52 -0
  26. package/dist/agents/credential-resolver.js.map +1 -0
  27. package/dist/agents/custom-provider-source.d.ts +35 -0
  28. package/dist/agents/custom-provider-source.d.ts.map +1 -0
  29. package/dist/agents/custom-provider-source.js +25 -0
  30. package/dist/agents/custom-provider-source.js.map +1 -0
  31. package/dist/agents/instructions.d.ts +6 -0
  32. package/dist/agents/instructions.d.ts.map +1 -0
  33. package/dist/agents/instructions.js +32 -0
  34. package/dist/agents/instructions.js.map +1 -0
  35. package/dist/agents/mastracode-gateway.d.ts +74 -0
  36. package/dist/agents/mastracode-gateway.d.ts.map +1 -0
  37. package/dist/agents/mastracode-gateway.js +400 -0
  38. package/dist/agents/mastracode-gateway.js.map +1 -0
  39. package/dist/agents/memory.d.ts +13 -0
  40. package/dist/agents/memory.d.ts.map +1 -0
  41. package/dist/agents/memory.js +116 -0
  42. package/dist/agents/memory.js.map +1 -0
  43. package/dist/agents/model.d.ts +59 -0
  44. package/dist/agents/model.d.ts.map +1 -0
  45. package/dist/agents/model.js +132 -0
  46. package/dist/agents/model.js.map +1 -0
  47. package/dist/agents/modes/build.d.ts +10 -0
  48. package/dist/agents/modes/build.d.ts.map +1 -0
  49. package/dist/agents/modes/build.js +44 -0
  50. package/dist/agents/modes/build.js.map +1 -0
  51. package/dist/agents/modes/explore.d.ts +10 -0
  52. package/dist/agents/modes/explore.d.ts.map +1 -0
  53. package/dist/agents/modes/explore.js +39 -0
  54. package/dist/agents/modes/explore.js.map +1 -0
  55. package/dist/agents/modes/plan.d.ts +6 -0
  56. package/dist/agents/modes/plan.d.ts.map +1 -0
  57. package/dist/agents/modes/plan.js +37 -0
  58. package/dist/agents/modes/plan.js.map +1 -0
  59. package/dist/agents/prompts/agent-instructions.d.ts +61 -0
  60. package/dist/agents/prompts/agent-instructions.d.ts.map +1 -0
  61. package/dist/agents/prompts/agent-instructions.js +201 -0
  62. package/dist/agents/prompts/agent-instructions.js.map +1 -0
  63. package/dist/agents/prompts/build.d.ts +12 -0
  64. package/dist/agents/prompts/build.d.ts.map +1 -0
  65. package/dist/agents/prompts/build.js +76 -0
  66. package/dist/agents/prompts/build.js.map +1 -0
  67. package/dist/agents/prompts/fast.d.ts +5 -0
  68. package/dist/agents/prompts/fast.d.ts.map +1 -0
  69. package/dist/agents/prompts/fast.js +26 -0
  70. package/dist/agents/prompts/fast.js.map +1 -0
  71. package/dist/agents/prompts/index.d.ts +19 -0
  72. package/dist/agents/prompts/index.d.ts.map +1 -0
  73. package/dist/agents/prompts/index.js +65 -0
  74. package/dist/agents/prompts/index.js.map +1 -0
  75. package/dist/agents/prompts/model.d.ts +5 -0
  76. package/dist/agents/prompts/model.d.ts.map +1 -0
  77. package/dist/agents/prompts/model.js +23 -0
  78. package/dist/agents/prompts/model.js.map +1 -0
  79. package/dist/agents/prompts/plan.d.ts +6 -0
  80. package/dist/agents/prompts/plan.d.ts.map +1 -0
  81. package/dist/agents/prompts/plan.js +111 -0
  82. package/dist/agents/prompts/plan.js.map +1 -0
  83. package/dist/agents/prompts/tool-guidance.d.ts +13 -0
  84. package/dist/agents/prompts/tool-guidance.d.ts.map +1 -0
  85. package/dist/agents/prompts/tool-guidance.js +149 -0
  86. package/dist/agents/prompts/tool-guidance.js.map +1 -0
  87. package/dist/agents/sandbox-filesystem.d.ts +99 -0
  88. package/dist/agents/sandbox-filesystem.d.ts.map +1 -0
  89. package/dist/agents/sandbox-filesystem.js +328 -0
  90. package/dist/agents/sandbox-filesystem.js.map +1 -0
  91. package/dist/agents/sandbox-reattach.d.ts +19 -0
  92. package/dist/agents/sandbox-reattach.d.ts.map +1 -0
  93. package/dist/agents/sandbox-reattach.js +15 -0
  94. package/dist/agents/sandbox-reattach.js.map +1 -0
  95. package/dist/agents/thread-caveman-state.d.ts +17 -0
  96. package/dist/agents/thread-caveman-state.d.ts.map +1 -0
  97. package/dist/agents/thread-caveman-state.js +107 -0
  98. package/dist/agents/thread-caveman-state.js.map +1 -0
  99. package/dist/agents/tool-availability.d.ts +10 -0
  100. package/dist/agents/tool-availability.d.ts.map +1 -0
  101. package/dist/agents/tool-availability.js +87 -0
  102. package/dist/agents/tool-availability.js.map +1 -0
  103. package/dist/agents/tools.d.ts +19 -0
  104. package/dist/agents/tools.d.ts.map +1 -0
  105. package/dist/agents/tools.js +105 -0
  106. package/dist/agents/tools.js.map +1 -0
  107. package/dist/agents/workspace.d.ts +32 -0
  108. package/dist/agents/workspace.d.ts.map +1 -0
  109. package/dist/agents/workspace.js +251 -0
  110. package/dist/agents/workspace.js.map +1 -0
  111. package/dist/analytics.d.ts +18 -0
  112. package/dist/analytics.d.ts.map +1 -0
  113. package/dist/analytics.js +163 -0
  114. package/dist/analytics.js.map +1 -0
  115. package/dist/auth/authorization-input.d.ts +16 -0
  116. package/dist/auth/authorization-input.d.ts.map +1 -0
  117. package/dist/auth/authorization-input.js +42 -0
  118. package/dist/auth/authorization-input.js.map +1 -0
  119. package/dist/auth/device-code.d.ts +93 -0
  120. package/dist/auth/device-code.d.ts.map +1 -0
  121. package/dist/auth/device-code.js +129 -0
  122. package/dist/auth/device-code.js.map +1 -0
  123. package/dist/auth/index.d.ts +10 -0
  124. package/dist/auth/index.d.ts.map +1 -0
  125. package/dist/auth/index.js +6 -0
  126. package/dist/auth/pkce.d.ts +13 -0
  127. package/dist/auth/pkce.d.ts.map +1 -0
  128. package/dist/auth/pkce.js +32 -0
  129. package/dist/auth/pkce.js.map +1 -0
  130. package/dist/auth/providers/anthropic.d.ts +40 -0
  131. package/dist/auth/providers/anthropic.d.ts.map +1 -0
  132. package/dist/auth/providers/anthropic.js +126 -0
  133. package/dist/auth/providers/anthropic.js.map +1 -0
  134. package/dist/auth/providers/github-copilot.d.ts +154 -0
  135. package/dist/auth/providers/github-copilot.d.ts.map +1 -0
  136. package/dist/auth/providers/github-copilot.js +340 -0
  137. package/dist/auth/providers/github-copilot.js.map +1 -0
  138. package/dist/auth/providers/openai-codex.d.ts +139 -0
  139. package/dist/auth/providers/openai-codex.d.ts.map +1 -0
  140. package/dist/auth/providers/openai-codex.js +519 -0
  141. package/dist/auth/providers/openai-codex.js.map +1 -0
  142. package/dist/auth/providers/xai.d.ts +64 -0
  143. package/dist/auth/providers/xai.d.ts.map +1 -0
  144. package/dist/auth/providers/xai.js +205 -0
  145. package/dist/auth/providers/xai.js.map +1 -0
  146. package/dist/auth/storage.d.ts +91 -0
  147. package/dist/auth/storage.d.ts.map +1 -0
  148. package/dist/auth/storage.js +197 -0
  149. package/dist/auth/storage.js.map +1 -0
  150. package/dist/auth/types.d.ts +89 -0
  151. package/dist/auth/types.d.ts.map +1 -0
  152. package/dist/auth/types.js +1 -0
  153. package/dist/clipboard/index.d.ts +26 -0
  154. package/dist/clipboard/index.d.ts.map +1 -0
  155. package/dist/clipboard/index.js +226 -0
  156. package/dist/clipboard/index.js.map +1 -0
  157. package/dist/constants.d.ts +10 -0
  158. package/dist/constants.d.ts.map +1 -0
  159. package/dist/constants.js +18 -0
  160. package/dist/constants.js.map +1 -0
  161. package/dist/error-classification.d.ts +10 -0
  162. package/dist/error-classification.d.ts.map +1 -0
  163. package/dist/error-classification.js +22 -0
  164. package/dist/error-classification.js.map +1 -0
  165. package/dist/evals/context-builder.d.ts +41 -0
  166. package/dist/evals/context-builder.d.ts.map +1 -0
  167. package/dist/evals/context-builder.js +161 -0
  168. package/dist/evals/context-builder.js.map +1 -0
  169. package/dist/evals/index.d.ts +4 -0
  170. package/dist/evals/index.d.ts.map +1 -0
  171. package/dist/evals/index.js +5 -0
  172. package/dist/evals/scorers/classify-command.d.ts +31 -0
  173. package/dist/evals/scorers/classify-command.d.ts.map +1 -0
  174. package/dist/evals/scorers/classify-command.js +73 -0
  175. package/dist/evals/scorers/classify-command.js.map +1 -0
  176. package/dist/evals/scorers/efficiency.d.ts +44 -0
  177. package/dist/evals/scorers/efficiency.d.ts.map +1 -0
  178. package/dist/evals/scorers/efficiency.js +259 -0
  179. package/dist/evals/scorers/efficiency.js.map +1 -0
  180. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  181. package/dist/evals/scorers/extract-tools.d.ts.map +1 -0
  182. package/dist/evals/scorers/extract-tools.js +60 -0
  183. package/dist/evals/scorers/extract-tools.js.map +1 -0
  184. package/dist/evals/scorers/index.d.ts +3 -0
  185. package/dist/evals/scorers/index.d.ts.map +1 -0
  186. package/dist/evals/scorers/index.js +3 -0
  187. package/dist/evals/scorers/outcome.d.ts +49 -0
  188. package/dist/evals/scorers/outcome.d.ts.map +1 -0
  189. package/dist/evals/scorers/outcome.js +347 -0
  190. package/dist/evals/scorers/outcome.js.map +1 -0
  191. package/dist/goal-manager.d.ts +78 -0
  192. package/dist/goal-manager.d.ts.map +1 -0
  193. package/dist/goal-manager.js +273 -0
  194. package/dist/goal-manager.js.map +1 -0
  195. package/dist/goal-signal.d.ts +14 -0
  196. package/dist/goal-signal.d.ts.map +1 -0
  197. package/dist/goal-signal.js +17 -0
  198. package/dist/goal-signal.js.map +1 -0
  199. package/dist/headless/cli.d.ts +42 -0
  200. package/dist/headless/cli.d.ts.map +1 -0
  201. package/dist/headless/cli.js +195 -0
  202. package/dist/headless/cli.js.map +1 -0
  203. package/dist/headless/flags.d.ts +33 -0
  204. package/dist/headless/flags.d.ts.map +1 -0
  205. package/dist/headless/flags.js +190 -0
  206. package/dist/headless/flags.js.map +1 -0
  207. package/dist/headless/format.d.ts +38 -0
  208. package/dist/headless/format.d.ts.map +1 -0
  209. package/dist/headless/format.js +89 -0
  210. package/dist/headless/format.js.map +1 -0
  211. package/dist/headless/index.d.ts +25 -0
  212. package/dist/headless/index.d.ts.map +1 -0
  213. package/dist/headless/index.js +6 -0
  214. package/dist/headless/policy.d.ts +17 -0
  215. package/dist/headless/policy.d.ts.map +1 -0
  216. package/dist/headless/policy.js +42 -0
  217. package/dist/headless/policy.js.map +1 -0
  218. package/dist/headless/run-mc.d.ts +7 -0
  219. package/dist/headless/run-mc.d.ts.map +1 -0
  220. package/dist/headless/run-mc.js +346 -0
  221. package/dist/headless/run-mc.js.map +1 -0
  222. package/dist/headless/types.d.ts +158 -0
  223. package/dist/headless/types.d.ts.map +1 -0
  224. package/dist/headless/types.js +18 -0
  225. package/dist/headless/types.js.map +1 -0
  226. package/dist/hooks/config.d.ts +11 -0
  227. package/dist/hooks/config.d.ts.map +1 -0
  228. package/dist/hooks/config.js +73 -0
  229. package/dist/hooks/config.js.map +1 -0
  230. package/dist/hooks/executor.d.ts +13 -0
  231. package/dist/hooks/executor.d.ts.map +1 -0
  232. package/dist/hooks/executor.js +128 -0
  233. package/dist/hooks/executor.js.map +1 -0
  234. package/dist/hooks/index.d.ts +6 -0
  235. package/dist/hooks/index.d.ts.map +1 -0
  236. package/dist/hooks/index.js +5 -0
  237. package/dist/hooks/manager.d.ts +47 -0
  238. package/dist/hooks/manager.d.ts.map +1 -0
  239. package/dist/hooks/manager.js +225 -0
  240. package/dist/hooks/manager.js.map +1 -0
  241. package/dist/hooks/types.d.ts +152 -0
  242. package/dist/hooks/types.d.ts.map +1 -0
  243. package/dist/hooks/types.js +8 -0
  244. package/dist/hooks/types.js.map +1 -0
  245. package/dist/index.d.ts +258 -0
  246. package/dist/index.d.ts.map +1 -0
  247. package/dist/index.js +740 -0
  248. package/dist/index.js.map +1 -0
  249. package/dist/ipc/ipc-reporter.d.ts +14 -0
  250. package/dist/ipc/ipc-reporter.d.ts.map +1 -0
  251. package/dist/ipc/ipc-reporter.js +21 -0
  252. package/dist/ipc/ipc-reporter.js.map +1 -0
  253. package/dist/lsp/client.d.ts +56 -0
  254. package/dist/lsp/client.d.ts.map +1 -0
  255. package/dist/lsp/client.js +251 -0
  256. package/dist/lsp/client.js.map +1 -0
  257. package/dist/lsp/index.d.ts +4 -0
  258. package/dist/lsp/index.d.ts.map +1 -0
  259. package/dist/lsp/index.js +4 -0
  260. package/dist/lsp/language.d.ts +9 -0
  261. package/dist/lsp/language.d.ts.map +1 -0
  262. package/dist/lsp/language.js +44 -0
  263. package/dist/lsp/language.js.map +1 -0
  264. package/dist/lsp/manager.d.ts +34 -0
  265. package/dist/lsp/manager.d.ts.map +1 -0
  266. package/dist/lsp/manager.js +82 -0
  267. package/dist/lsp/manager.js.map +1 -0
  268. package/dist/lsp/server.d.ts +27 -0
  269. package/dist/lsp/server.d.ts.map +1 -0
  270. package/dist/lsp/server.js +159 -0
  271. package/dist/lsp/server.js.map +1 -0
  272. package/dist/lsp/workspace.d.ts +9 -0
  273. package/dist/lsp/workspace.d.ts.map +1 -0
  274. package/dist/lsp/workspace.js +55 -0
  275. package/dist/lsp/workspace.js.map +1 -0
  276. package/dist/mcp/config.d.ts +54 -0
  277. package/dist/mcp/config.d.ts.map +1 -0
  278. package/dist/mcp/config.js +240 -0
  279. package/dist/mcp/config.js.map +1 -0
  280. package/dist/mcp/index.d.ts +5 -0
  281. package/dist/mcp/index.d.ts.map +1 -0
  282. package/dist/mcp/index.js +3 -0
  283. package/dist/mcp/manager.d.ts +98 -0
  284. package/dist/mcp/manager.d.ts.map +1 -0
  285. package/dist/mcp/manager.js +612 -0
  286. package/dist/mcp/manager.js.map +1 -0
  287. package/dist/mcp/state.d.ts +33 -0
  288. package/dist/mcp/state.d.ts.map +1 -0
  289. package/dist/mcp/state.js +88 -0
  290. package/dist/mcp/state.js.map +1 -0
  291. package/dist/mcp/types.d.ts +120 -0
  292. package/dist/mcp/types.d.ts.map +1 -0
  293. package/dist/mcp/types.js +1 -0
  294. package/dist/onboarding/custom-packs.d.ts +7 -0
  295. package/dist/onboarding/custom-packs.d.ts.map +1 -0
  296. package/dist/onboarding/custom-packs.js +17 -0
  297. package/dist/onboarding/custom-packs.js.map +1 -0
  298. package/dist/onboarding/custom-providers.d.ts +4 -0
  299. package/dist/onboarding/custom-providers.d.ts.map +1 -0
  300. package/dist/onboarding/custom-providers.js +30 -0
  301. package/dist/onboarding/custom-providers.js.map +1 -0
  302. package/dist/onboarding/index.d.ts +5 -0
  303. package/dist/onboarding/index.d.ts.map +1 -0
  304. package/dist/onboarding/index.js +3 -0
  305. package/dist/onboarding/om-settings.d.ts +25 -0
  306. package/dist/onboarding/om-settings.d.ts.map +1 -0
  307. package/dist/onboarding/om-settings.js +47 -0
  308. package/dist/onboarding/om-settings.js.map +1 -0
  309. package/dist/onboarding/packs.d.ts +46 -0
  310. package/dist/onboarding/packs.d.ts.map +1 -0
  311. package/dist/onboarding/packs.js +160 -0
  312. package/dist/onboarding/packs.js.map +1 -0
  313. package/dist/onboarding/settings.d.ts +338 -0
  314. package/dist/onboarding/settings.d.ts.map +1 -0
  315. package/dist/onboarding/settings.js +673 -0
  316. package/dist/onboarding/settings.js.map +1 -0
  317. package/dist/permissions.d.ts +55 -0
  318. package/dist/permissions.d.ts.map +1 -0
  319. package/dist/permissions.js +132 -0
  320. package/dist/permissions.js.map +1 -0
  321. package/dist/plugin.d.ts +81 -0
  322. package/dist/plugin.d.ts.map +1 -0
  323. package/dist/plugin.js +28 -0
  324. package/dist/plugin.js.map +1 -0
  325. package/dist/plugins/dependencies.d.ts +9 -0
  326. package/dist/plugins/dependencies.d.ts.map +1 -0
  327. package/dist/plugins/dependencies.js +88 -0
  328. package/dist/plugins/dependencies.js.map +1 -0
  329. package/dist/plugins/install.d.ts +21 -0
  330. package/dist/plugins/install.d.ts.map +1 -0
  331. package/dist/plugins/install.js +190 -0
  332. package/dist/plugins/install.js.map +1 -0
  333. package/dist/plugins/loader.d.ts +15 -0
  334. package/dist/plugins/loader.d.ts.map +1 -0
  335. package/dist/plugins/loader.js +206 -0
  336. package/dist/plugins/loader.js.map +1 -0
  337. package/dist/plugins/manager.d.ts +64 -0
  338. package/dist/plugins/manager.d.ts.map +1 -0
  339. package/dist/plugins/manager.js +384 -0
  340. package/dist/plugins/manager.js.map +1 -0
  341. package/dist/plugins/manifest.d.ts +14 -0
  342. package/dist/plugins/manifest.d.ts.map +1 -0
  343. package/dist/plugins/manifest.js +50 -0
  344. package/dist/plugins/manifest.js.map +1 -0
  345. package/dist/plugins/package-link.d.ts +3 -0
  346. package/dist/plugins/package-link.d.ts.map +1 -0
  347. package/dist/plugins/package-link.js +61 -0
  348. package/dist/plugins/package-link.js.map +1 -0
  349. package/dist/plugins/paths.d.ts +10 -0
  350. package/dist/plugins/paths.d.ts.map +1 -0
  351. package/dist/plugins/paths.js +25 -0
  352. package/dist/plugins/paths.js.map +1 -0
  353. package/dist/plugins/registry.d.ts +8 -0
  354. package/dist/plugins/registry.d.ts.map +1 -0
  355. package/dist/plugins/registry.js +112 -0
  356. package/dist/plugins/registry.js.map +1 -0
  357. package/dist/plugins/scaffold.d.ts +10 -0
  358. package/dist/plugins/scaffold.d.ts.map +1 -0
  359. package/dist/plugins/scaffold.js +116 -0
  360. package/dist/plugins/scaffold.js.map +1 -0
  361. package/dist/plugins/types.d.ts +45 -0
  362. package/dist/plugins/types.d.ts.map +1 -0
  363. package/dist/plugins/types.js +1 -0
  364. package/dist/processors/plan-rejection-abort.d.ts +12 -0
  365. package/dist/processors/plan-rejection-abort.d.ts.map +1 -0
  366. package/dist/processors/plan-rejection-abort.js +54 -0
  367. package/dist/processors/plan-rejection-abort.js.map +1 -0
  368. package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
  369. package/dist/providers/amazon-bedrock-gateway.d.ts.map +1 -0
  370. package/dist/providers/amazon-bedrock-gateway.js +152 -0
  371. package/dist/providers/amazon-bedrock-gateway.js.map +1 -0
  372. package/dist/providers/amazon-bedrock.d.ts +28 -0
  373. package/dist/providers/amazon-bedrock.d.ts.map +1 -0
  374. package/dist/providers/amazon-bedrock.js +83 -0
  375. package/dist/providers/amazon-bedrock.js.map +1 -0
  376. package/dist/providers/claude-max.d.ts +52 -0
  377. package/dist/providers/claude-max.d.ts.map +1 -0
  378. package/dist/providers/claude-max.js +171 -0
  379. package/dist/providers/claude-max.js.map +1 -0
  380. package/dist/providers/github-copilot.d.ts +60 -0
  381. package/dist/providers/github-copilot.d.ts.map +1 -0
  382. package/dist/providers/github-copilot.js +265 -0
  383. package/dist/providers/github-copilot.js.map +1 -0
  384. package/dist/providers/openai-codex.d.ts +72 -0
  385. package/dist/providers/openai-codex.d.ts.map +1 -0
  386. package/dist/providers/openai-codex.js +302 -0
  387. package/dist/providers/openai-codex.js.map +1 -0
  388. package/dist/providers/xai.d.ts +33 -0
  389. package/dist/providers/xai.d.ts.map +1 -0
  390. package/dist/providers/xai.js +70 -0
  391. package/dist/providers/xai.js.map +1 -0
  392. package/dist/schema.d.ts +192 -0
  393. package/dist/schema.d.ts.map +1 -0
  394. package/dist/schema.js +98 -0
  395. package/dist/schema.js.map +1 -0
  396. package/dist/theme-palette.d.ts +17 -0
  397. package/dist/theme-palette.d.ts.map +1 -0
  398. package/dist/theme-palette.js +21 -0
  399. package/dist/theme-palette.js.map +1 -0
  400. package/dist/tool-names.d.ts +73 -0
  401. package/dist/tool-names.d.ts.map +1 -0
  402. package/dist/tool-names.js +52 -0
  403. package/dist/tool-names.js.map +1 -0
  404. package/dist/tools/index.d.ts +6 -0
  405. package/dist/tools/index.d.ts.map +1 -0
  406. package/dist/tools/index.js +3 -0
  407. package/dist/tools/request-sandbox-access.d.ts +6 -0
  408. package/dist/tools/request-sandbox-access.d.ts.map +1 -0
  409. package/dist/tools/request-sandbox-access.js +79 -0
  410. package/dist/tools/request-sandbox-access.js.map +1 -0
  411. package/dist/tools/utils.d.ts +20 -0
  412. package/dist/tools/utils.d.ts.map +1 -0
  413. package/dist/tools/utils.js +32 -0
  414. package/dist/tools/utils.js.map +1 -0
  415. package/dist/tools/web-search.d.ts +35 -0
  416. package/dist/tools/web-search.d.ts.map +1 -0
  417. package/dist/tools/web-search.js +61 -0
  418. package/dist/tools/web-search.js.map +1 -0
  419. package/dist/utils/binaries.d.ts +7 -0
  420. package/dist/utils/binaries.d.ts.map +1 -0
  421. package/dist/utils/binaries.js +78 -0
  422. package/dist/utils/binaries.js.map +1 -0
  423. package/dist/utils/debug-log.d.ts +12 -0
  424. package/dist/utils/debug-log.d.ts.map +1 -0
  425. package/dist/utils/debug-log.js +59 -0
  426. package/dist/utils/debug-log.js.map +1 -0
  427. package/dist/utils/errors.d.ts +36 -0
  428. package/dist/utils/errors.d.ts.map +1 -0
  429. package/dist/utils/errors.js +172 -0
  430. package/dist/utils/errors.js.map +1 -0
  431. package/dist/utils/gateway-sync.d.ts +26 -0
  432. package/dist/utils/gateway-sync.d.ts.map +1 -0
  433. package/dist/utils/gateway-sync.js +61 -0
  434. package/dist/utils/gateway-sync.js.map +1 -0
  435. package/dist/utils/path-security.d.ts +2 -0
  436. package/dist/utils/path-security.d.ts.map +1 -0
  437. package/dist/utils/path-security.js +10 -0
  438. package/dist/utils/path-security.js.map +1 -0
  439. package/dist/utils/plan-diff.d.ts +25 -0
  440. package/dist/utils/plan-diff.d.ts.map +1 -0
  441. package/dist/utils/plan-diff.js +62 -0
  442. package/dist/utils/plan-diff.js.map +1 -0
  443. package/dist/utils/plans.d.ts +56 -0
  444. package/dist/utils/plans.d.ts.map +1 -0
  445. package/dist/utils/plans.js +117 -0
  446. package/dist/utils/plans.js.map +1 -0
  447. package/dist/utils/project.d.ts +160 -0
  448. package/dist/utils/project.d.ts.map +1 -0
  449. package/dist/utils/project.js +364 -0
  450. package/dist/utils/project.js.map +1 -0
  451. package/dist/utils/signals-pubsub.d.ts +41 -0
  452. package/dist/utils/signals-pubsub.d.ts.map +1 -0
  453. package/dist/utils/signals-pubsub.js +122 -0
  454. package/dist/utils/signals-pubsub.js.map +1 -0
  455. package/dist/utils/slash-command-loader.d.ts +52 -0
  456. package/dist/utils/slash-command-loader.d.ts.map +1 -0
  457. package/dist/utils/slash-command-loader.js +141 -0
  458. package/dist/utils/slash-command-loader.js.map +1 -0
  459. package/dist/utils/slash-command-processor.d.ts +14 -0
  460. package/dist/utils/slash-command-processor.d.ts.map +1 -0
  461. package/dist/utils/slash-command-processor.js +105 -0
  462. package/dist/utils/slash-command-processor.js.map +1 -0
  463. package/dist/utils/stdin-pipe.d.ts +33 -0
  464. package/dist/utils/stdin-pipe.d.ts.map +1 -0
  465. package/dist/utils/stdin-pipe.js +96 -0
  466. package/dist/utils/stdin-pipe.js.map +1 -0
  467. package/dist/utils/storage-factory.d.ts +50 -0
  468. package/dist/utils/storage-factory.d.ts.map +1 -0
  469. package/dist/utils/storage-factory.js +121 -0
  470. package/dist/utils/storage-factory.js.map +1 -0
  471. package/dist/utils/storage-maintenance.d.ts +103 -0
  472. package/dist/utils/storage-maintenance.d.ts.map +1 -0
  473. package/dist/utils/storage-maintenance.js +274 -0
  474. package/dist/utils/storage-maintenance.js.map +1 -0
  475. package/dist/utils/thread-lock.d.ts +26 -0
  476. package/dist/utils/thread-lock.d.ts.map +1 -0
  477. package/dist/utils/thread-lock.js +112 -0
  478. package/dist/utils/thread-lock.js.map +1 -0
  479. package/dist/utils/token-estimator.d.ts +3 -0
  480. package/dist/utils/token-estimator.d.ts.map +1 -0
  481. package/dist/utils/token-estimator.js +21 -0
  482. package/dist/utils/token-estimator.js.map +1 -0
  483. package/dist/utils/update-check.d.ts +101 -0
  484. package/dist/utils/update-check.d.ts.map +1 -0
  485. package/dist/utils/update-check.js +383 -0
  486. package/dist/utils/update-check.js.map +1 -0
  487. package/dist/voice/stt-registry.d.ts +64 -0
  488. package/dist/voice/stt-registry.d.ts.map +1 -0
  489. package/dist/voice/stt-registry.js +144 -0
  490. package/dist/voice/stt-registry.js.map +1 -0
  491. package/package.json +96 -0
@@ -0,0 +1,101 @@
1
+ /**
2
+ * Check for newer versions of mastracode on npm.
3
+ */
4
+ export type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';
5
+ /**
6
+ * Detect which package manager was used to install mastracode globally.
7
+ *
8
+ * Uses a multi-tier approach:
9
+ * 1. npm_config_user_agent env var (set when run via `pnpm run`, `npm run`, etc.)
10
+ * 2. npm_execpath env var (fallback for script-based invocation)
11
+ * 3. NODE_PATH env var (set by pnpm global bin stubs)
12
+ * 4. Resolved path of the running script (process.argv[1])
13
+ * 5. Shell-out to `pnpm list -g` to check if pnpm manages the package
14
+ * 6. Falls back to 'npm'
15
+ */
16
+ export declare function detectPackageManager(): Promise<PackageManager>;
17
+ /**
18
+ * Build the shell command string a user would run to install/update globally.
19
+ */
20
+ export declare function getInstallCommand(pm: PackageManager, version?: string): string;
21
+ /**
22
+ * Read the current version, injected at build time by tsdown's `define` option.
23
+ * Falls back to reading package.json at runtime (e.g. when running from source with tsx).
24
+ */
25
+ export declare function getCurrentVersion(): string;
26
+ /**
27
+ * Fetch the latest published version from npm.
28
+ * Returns null if the fetch fails (network error, timeout, etc.).
29
+ */
30
+ export declare function fetchLatestVersion(): Promise<string | null>;
31
+ /**
32
+ * Simple semver comparison: returns true if `latest` is newer than `current`.
33
+ * Handles standard x.y.z versions. Ignores pre-release tags.
34
+ */
35
+ export declare function isNewerVersion(current: string, latest: string): boolean;
36
+ /**
37
+ * Fetch the CHANGELOG.md for a specific published version from the npm CDN
38
+ * and extract a human-readable summary of changes.
39
+ * Returns null if the fetch fails or the changelog can't be parsed.
40
+ */
41
+ export declare function fetchChangelog(version: string): Promise<string | null>;
42
+ /**
43
+ * Extract the changelog section for a specific version and format it
44
+ * as a concise bullet list suitable for terminal display.
45
+ */
46
+ export declare function parseChangelog(markdown: string, version: string): string | null;
47
+ /** Result of attempting an auto-update: exit status plus captured stderr. */
48
+ export interface UpdateResult {
49
+ ok: boolean;
50
+ stderr?: string;
51
+ }
52
+ /**
53
+ * Run the appropriate global install command to update mastracode.
54
+ * Exit code 0 does not prove the running binary changed (the install may land
55
+ * in a location the PATH shim doesn't use) — verify with {@link locateOwnInstall}.
56
+ */
57
+ export declare function runUpdate(pm: PackageManager, targetVersion: string): Promise<UpdateResult>;
58
+ /**
59
+ * Find the installed mastracode package the running binary belongs to (walking
60
+ * up from `process.argv[1]`) and read its version fresh from disk. Returns
61
+ * null when it can't be determined, e.g. when running from source.
62
+ */
63
+ export declare function locateOwnInstall(): {
64
+ dir: string;
65
+ version: string | null;
66
+ } | null;
67
+ export type UpdateOutcome = {
68
+ status: 'updated';
69
+ message: string;
70
+ } | {
71
+ status: 'unchanged';
72
+ message: string;
73
+ } | {
74
+ status: 'failed';
75
+ message: string;
76
+ };
77
+ /**
78
+ * Decide what to tell the user after {@link runUpdate}: `updated` when the
79
+ * on-disk version matches the target (or can't be determined), `unchanged`
80
+ * when the package manager succeeded but the running install didn't change,
81
+ * `failed` on error (with the package manager's stderr).
82
+ */
83
+ export declare function resolveUpdateOutcome(opts: {
84
+ pm: PackageManager;
85
+ targetVersion: string;
86
+ result: UpdateResult;
87
+ install: {
88
+ dir: string;
89
+ version: string | null;
90
+ } | null;
91
+ /** Overrides the suggested manual command, e.g. when the update was delegated to the owning tool. */
92
+ manualCommand?: string;
93
+ }): UpdateOutcome;
94
+ /**
95
+ * Update mastracode and verify the result: delegates to the tool that owns the
96
+ * running install when we recognize it, skips the install when it isn't
97
+ * managed by `pm`, otherwise runs the package manager. Every executed update
98
+ * is verified against the on-disk version.
99
+ */
100
+ export declare function performUpdate(pm: PackageManager, targetVersion: string): Promise<UpdateOutcome>;
101
+ //# sourceMappingURL=update-check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-check.d.ts","sourceRoot":"","sources":["../../src/utils/update-check.ts"],"names":[],"mappings":"AAAA;;GAEG;AAmBH,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAW7D;;;;;;;;;;GAUG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,cAAc,CAAC,CA+CpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAY9E;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAS1C;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAcjE;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAevE;AAKD;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAe5E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiD/E;AAED,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC,CAE1F;AA0CD;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CA6BjF;AAED,MAAM,MAAM,aAAa,GACrB;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACtC;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxC;IAAE,MAAM,EAAE,QAAQ,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1C;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IACzC,EAAE,EAAE,cAAc,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACxD,qGAAqG;IACrG,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,GAAG,aAAa,CAsBhB;AAuDD;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,EAAE,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CAoCrG"}
@@ -0,0 +1,383 @@
1
+ import { readFileSync, realpathSync } from "fs";
2
+ import { homedir } from "os";
3
+ import { dirname, join, resolve, sep } from "path";
4
+ import { execFile } from "child_process";
5
+ import { fileURLToPath } from "url";
6
+ //#region src/utils/update-check.ts
7
+ /**
8
+ * Check for newer versions of mastracode on npm.
9
+ */
10
+ const PACKAGE_NAME = "mastracode";
11
+ const NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;
12
+ /** Timeout for the npm registry fetch (ms). */
13
+ const FETCH_TIMEOUT_MS = 5e3;
14
+ const USE_SHELL = process.platform === "win32";
15
+ function matchPM(str) {
16
+ if (/pnpm/i.test(str)) return "pnpm";
17
+ if (/\byarn\b/i.test(str)) return "yarn";
18
+ if (/\bbun\b/i.test(str)) return "bun";
19
+ if (/\bnpm\b/i.test(str)) return "npm";
20
+ return null;
21
+ }
22
+ /**
23
+ * Detect which package manager was used to install mastracode globally.
24
+ *
25
+ * Uses a multi-tier approach:
26
+ * 1. npm_config_user_agent env var (set when run via `pnpm run`, `npm run`, etc.)
27
+ * 2. npm_execpath env var (fallback for script-based invocation)
28
+ * 3. NODE_PATH env var (set by pnpm global bin stubs)
29
+ * 4. Resolved path of the running script (process.argv[1])
30
+ * 5. Shell-out to `pnpm list -g` to check if pnpm manages the package
31
+ * 6. Falls back to 'npm'
32
+ */
33
+ async function detectPackageManager() {
34
+ const userAgent = process.env.npm_config_user_agent;
35
+ if (userAgent) {
36
+ const pm = matchPM(userAgent);
37
+ if (pm) return pm;
38
+ }
39
+ const execPath = process.env.npm_execpath;
40
+ if (execPath) {
41
+ const pm = matchPM(execPath);
42
+ if (pm) return pm;
43
+ }
44
+ const nodePath = process.env.NODE_PATH;
45
+ if (nodePath) {
46
+ if (/[/\\]\.pnpm[/\\]/.test(nodePath) || /[/\\]pnpm[/\\]/.test(nodePath)) return "pnpm";
47
+ if (/[/\\]\.yarn[/\\]/.test(nodePath)) return "yarn";
48
+ if (/[/\\]\.bun[/\\]/.test(nodePath)) return "bun";
49
+ }
50
+ try {
51
+ const scriptPath = realpathSync(process.argv[1] ?? "");
52
+ if (/[/\\]\.?pnpm[/\\]/.test(scriptPath)) return "pnpm";
53
+ if (/[/\\]\.?yarn[/\\]/.test(scriptPath)) return "yarn";
54
+ if (/[/\\]\.?bun[/\\]/.test(scriptPath)) return "bun";
55
+ } catch {}
56
+ if (await new Promise((resolve) => {
57
+ execFile("pnpm", [
58
+ "list",
59
+ "-g",
60
+ "--depth=0",
61
+ PACKAGE_NAME
62
+ ], {
63
+ timeout: 3e3,
64
+ shell: USE_SHELL
65
+ }, (error, stdout) => {
66
+ resolve(!error && stdout.includes(PACKAGE_NAME));
67
+ });
68
+ })) return "pnpm";
69
+ return "npm";
70
+ }
71
+ /**
72
+ * Build the shell command string a user would run to install/update globally.
73
+ */
74
+ function getInstallCommand(pm, version) {
75
+ const pkg = version ? `${PACKAGE_NAME}@${version}` : `${PACKAGE_NAME}@latest`;
76
+ switch (pm) {
77
+ case "pnpm": return `pnpm add -g ${pkg}`;
78
+ case "yarn": return `yarn global add ${pkg}`;
79
+ case "bun": return `bun add -g ${pkg}`;
80
+ default: return `npm install -g ${pkg}`;
81
+ }
82
+ }
83
+ /**
84
+ * Read the current version, injected at build time by tsdown's `define` option.
85
+ * Falls back to reading package.json at runtime (e.g. when running from source with tsx).
86
+ */
87
+ function getCurrentVersion() {
88
+ if (typeof MASTRACODE_VERSION !== "undefined") return MASTRACODE_VERSION;
89
+ const pkgPath = resolve(dirname(fileURLToPath(import.meta.url)), "../../package.json");
90
+ return JSON.parse(readFileSync(pkgPath, "utf-8")).version;
91
+ }
92
+ /**
93
+ * Fetch the latest published version from npm.
94
+ * Returns null if the fetch fails (network error, timeout, etc.).
95
+ */
96
+ async function fetchLatestVersion() {
97
+ if (process.env.MASTRACODE_UPDATE_LATEST_VERSION) return process.env.MASTRACODE_UPDATE_LATEST_VERSION;
98
+ try {
99
+ const controller = new AbortController();
100
+ const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
101
+ const res = await fetch(NPM_REGISTRY_URL, { signal: controller.signal });
102
+ clearTimeout(timeout);
103
+ if (!res.ok) return null;
104
+ return (await res.json()).version ?? null;
105
+ } catch {
106
+ return null;
107
+ }
108
+ }
109
+ /**
110
+ * Simple semver comparison: returns true if `latest` is newer than `current`.
111
+ * Handles standard x.y.z versions. Ignores pre-release tags.
112
+ */
113
+ function isNewerVersion(current, latest) {
114
+ const parse = (v) => v.replace(/^v/, "").split("-")[0].split(".").map((s) => {
115
+ const n = Number(s);
116
+ return Number.isFinite(n) ? n : 0;
117
+ });
118
+ const [cMajor = 0, cMinor = 0, cPatch = 0] = parse(current);
119
+ const [lMajor = 0, lMinor = 0, lPatch = 0] = parse(latest);
120
+ if (lMajor !== cMajor) return lMajor > cMajor;
121
+ if (lMinor !== cMinor) return lMinor > cMinor;
122
+ return lPatch > cPatch;
123
+ }
124
+ /** Max entries to show in the changelog summary. */
125
+ const MAX_CHANGELOG_ENTRIES = 20;
126
+ /**
127
+ * Fetch the CHANGELOG.md for a specific published version from the npm CDN
128
+ * and extract a human-readable summary of changes.
129
+ * Returns null if the fetch fails or the changelog can't be parsed.
130
+ */
131
+ async function fetchChangelog(version) {
132
+ if (process.env.MASTRACODE_UPDATE_CHANGELOG) return process.env.MASTRACODE_UPDATE_CHANGELOG;
133
+ try {
134
+ const url = `https://unpkg.com/${PACKAGE_NAME}@${version}/CHANGELOG.md`;
135
+ const controller = new AbortController();
136
+ const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
137
+ const res = await fetch(url, { signal: controller.signal });
138
+ clearTimeout(timeout);
139
+ if (!res.ok) return null;
140
+ return parseChangelog(await res.text(), version);
141
+ } catch {
142
+ return null;
143
+ }
144
+ }
145
+ /**
146
+ * Extract the changelog section for a specific version and format it
147
+ * as a concise bullet list suitable for terminal display.
148
+ */
149
+ function parseChangelog(markdown, version) {
150
+ const versionHeader = `## ${version}`;
151
+ const startIdx = markdown.indexOf(versionHeader);
152
+ if (startIdx === -1) return null;
153
+ const afterHeader = startIdx + versionHeader.length;
154
+ const nextHeaderIdx = markdown.indexOf("\n## ", afterHeader);
155
+ const lines = (nextHeaderIdx === -1 ? markdown.slice(afterHeader) : markdown.slice(afterHeader, nextHeaderIdx)).split("\n");
156
+ const entries = [];
157
+ let skipIndented = false;
158
+ for (let i = 0; i < lines.length; i++) {
159
+ const raw = lines[i];
160
+ const trimmed = raw.trim();
161
+ if (!(raw === trimmed && trimmed.startsWith("- "))) {
162
+ if (skipIndented && /^\s+-\s/.test(raw)) continue;
163
+ skipIndented = false;
164
+ continue;
165
+ }
166
+ if (/^- Updated dependenc/i.test(trimmed)) {
167
+ skipIndented = true;
168
+ continue;
169
+ }
170
+ skipIndented = false;
171
+ let entry = trimmed.slice(2);
172
+ entry = entry.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1");
173
+ entry = entry.replace(/\s*\(#\d+\)\s*/g, " ");
174
+ entry = entry.replace(/\s*\(`[a-f0-9]+`\)\s*/g, " ");
175
+ entry = entry.replace(/\.\s*$/, "");
176
+ entry = entry.trim();
177
+ if (entry) entries.push(entry);
178
+ if (entries.length >= MAX_CHANGELOG_ENTRIES) break;
179
+ }
180
+ if (entries.length === 0) return null;
181
+ return entries.map((e) => ` • ${e}`).join("\n");
182
+ }
183
+ /**
184
+ * Run the appropriate global install command to update mastracode.
185
+ * Exit code 0 does not prove the running binary changed (the install may land
186
+ * in a location the PATH shim doesn't use) — verify with {@link locateOwnInstall}.
187
+ */
188
+ function runUpdate(pm, targetVersion) {
189
+ return execUpdate(pm, buildInstallArgs(pm, targetVersion));
190
+ }
191
+ function execUpdate(cmd, args) {
192
+ return new Promise((resolve) => {
193
+ execFile(cmd, args, {
194
+ timeout: 6e4,
195
+ shell: USE_SHELL
196
+ }, (error, _stdout, stderr) => {
197
+ const captured = (stderr ?? "").trim();
198
+ if (error) resolve({
199
+ ok: false,
200
+ stderr: captured || error.message
201
+ });
202
+ else resolve({
203
+ ok: true,
204
+ stderr: captured || void 0
205
+ });
206
+ });
207
+ });
208
+ }
209
+ function buildInstallArgs(pm, version) {
210
+ const pkg = `${PACKAGE_NAME}@${version}`;
211
+ switch (pm) {
212
+ case "pnpm": return [
213
+ "add",
214
+ "-g",
215
+ pkg
216
+ ];
217
+ case "yarn": return [
218
+ "global",
219
+ "add",
220
+ pkg
221
+ ];
222
+ case "bun": return [
223
+ "add",
224
+ "-g",
225
+ pkg
226
+ ];
227
+ default: return [
228
+ "install",
229
+ "-g",
230
+ pkg
231
+ ];
232
+ }
233
+ }
234
+ function formatUpdaterError(stderr) {
235
+ if (!stderr) return null;
236
+ const lines = stderr.split("\n").map((line) => line.trimEnd()).filter((line) => line.trim().length > 0);
237
+ if (lines.length === 0) return null;
238
+ return lines.slice(-5).join("\n");
239
+ }
240
+ /**
241
+ * Find the installed mastracode package the running binary belongs to (walking
242
+ * up from `process.argv[1]`) and read its version fresh from disk. Returns
243
+ * null when it can't be determined, e.g. when running from source.
244
+ */
245
+ function locateOwnInstall() {
246
+ const entry = process.argv[1];
247
+ if (!entry) return null;
248
+ let dir;
249
+ try {
250
+ dir = dirname(realpathSync(entry));
251
+ } catch {
252
+ return null;
253
+ }
254
+ let previous = "";
255
+ while (dir && dir !== previous) {
256
+ try {
257
+ const pkg = JSON.parse(readFileSync(resolve(dir, "package.json"), "utf-8"));
258
+ if (pkg.name === PACKAGE_NAME) return {
259
+ dir,
260
+ version: typeof pkg.version === "string" ? pkg.version : null
261
+ };
262
+ } catch {}
263
+ previous = dir;
264
+ dir = dirname(dir);
265
+ }
266
+ return null;
267
+ }
268
+ /**
269
+ * Decide what to tell the user after {@link runUpdate}: `updated` when the
270
+ * on-disk version matches the target (or can't be determined), `unchanged`
271
+ * when the package manager succeeded but the running install didn't change,
272
+ * `failed` on error (with the package manager's stderr).
273
+ */
274
+ function resolveUpdateOutcome(opts) {
275
+ const { pm, targetVersion, result, install } = opts;
276
+ const cmd = opts.manualCommand ?? getInstallCommand(pm, targetVersion);
277
+ if (!result.ok) {
278
+ const details = formatUpdaterError(result.stderr);
279
+ let message = `Auto-update failed. Run \`${cmd}\` manually.`;
280
+ if (details) message += `\n\n${details}`;
281
+ return {
282
+ status: "failed",
283
+ message
284
+ };
285
+ }
286
+ if (install?.version != null && install.version !== targetVersion) return {
287
+ status: "unchanged",
288
+ message: opts.manualCommand ? `The update ran, but the Mastra Code you are running (at ${install.dir}) is still v${install.version}. Try \`${cmd}\` manually.` : `The update installed, but the Mastra Code you are running (at ${install.dir}) is still v${install.version} — it looks like it is managed by another tool. Update it with that tool, or try \`${cmd}\`.`
289
+ };
290
+ return {
291
+ status: "updated",
292
+ message: `Updated to v${targetVersion}. Please restart Mastra Code.`
293
+ };
294
+ }
295
+ /** Global node_modules directory the package manager installs into, or null when unknown. */
296
+ function getGlobalRoot(pm) {
297
+ const args = pm === "yarn" ? ["global", "dir"] : ["root", "-g"];
298
+ return new Promise((res) => {
299
+ execFile(pm, args, {
300
+ timeout: 1e4,
301
+ shell: USE_SHELL
302
+ }, (error, stdout) => {
303
+ const out = (stdout ?? "").trim().split("\n").pop()?.trim();
304
+ if (error || !out) return res(null);
305
+ res(pm === "yarn" ? resolve(out, "node_modules") : out);
306
+ });
307
+ });
308
+ }
309
+ /**
310
+ * Whether updating via `pm` would touch the install the running binary uses.
311
+ * Fail-open: returns true when either side can't be determined, so the update
312
+ * proceeds and the post-install verification has the final word.
313
+ */
314
+ async function isOwnInstallManagedBy(pm, install) {
315
+ if (!install) return true;
316
+ const root = await getGlobalRoot(pm);
317
+ if (!root) return true;
318
+ try {
319
+ return realpathSync(resolve(root, PACKAGE_NAME)) === install.dir;
320
+ } catch {
321
+ return false;
322
+ }
323
+ }
324
+ function findInstallOwner(dir, version) {
325
+ if (dir.startsWith(join(homedir(), ".vite-plus") + sep)) return {
326
+ name: "vite-plus",
327
+ exec: {
328
+ cmd: "vp",
329
+ args: [
330
+ "install",
331
+ "-g",
332
+ `${PACKAGE_NAME}@${version}`
333
+ ]
334
+ },
335
+ command: `vp install -g ${PACKAGE_NAME}@${version}`
336
+ };
337
+ if (dir.split(sep).includes("Cellar")) return {
338
+ name: "Homebrew",
339
+ command: `brew upgrade ${PACKAGE_NAME}`
340
+ };
341
+ return null;
342
+ }
343
+ /**
344
+ * Update mastracode and verify the result: delegates to the tool that owns the
345
+ * running install when we recognize it, skips the install when it isn't
346
+ * managed by `pm`, otherwise runs the package manager. Every executed update
347
+ * is verified against the on-disk version.
348
+ */
349
+ async function performUpdate(pm, targetVersion) {
350
+ if (!/^[\w.+-]+$/.test(targetVersion)) return {
351
+ status: "failed",
352
+ message: `Auto-update aborted: unexpected version "${targetVersion}".`
353
+ };
354
+ const install = locateOwnInstall();
355
+ const owner = install ? findInstallOwner(install.dir, targetVersion) : null;
356
+ if (owner) {
357
+ if (!owner.exec) return {
358
+ status: "unchanged",
359
+ message: `Your Mastra Code install (at ${install.dir}) is managed by ${owner.name}. Update it with \`${owner.command}\`.`
360
+ };
361
+ return resolveUpdateOutcome({
362
+ pm,
363
+ targetVersion,
364
+ result: await execUpdate(owner.exec.cmd, owner.exec.args),
365
+ install: locateOwnInstall(),
366
+ manualCommand: owner.command
367
+ });
368
+ }
369
+ if (!await isOwnInstallManagedBy(pm, install)) return {
370
+ status: "unchanged",
371
+ message: `Your Mastra Code install (at ${install.dir}) is not managed by ${pm} — it looks like it was installed by another tool. Update it with that tool, or try \`${getInstallCommand(pm, targetVersion)}\`.`
372
+ };
373
+ return resolveUpdateOutcome({
374
+ pm,
375
+ targetVersion,
376
+ result: await runUpdate(pm, targetVersion),
377
+ install: locateOwnInstall()
378
+ });
379
+ }
380
+ //#endregion
381
+ export { detectPackageManager, fetchChangelog, fetchLatestVersion, getCurrentVersion, getInstallCommand, isNewerVersion, locateOwnInstall, parseChangelog, performUpdate, resolveUpdateOutcome, runUpdate };
382
+
383
+ //# sourceMappingURL=update-check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"update-check.js","names":[],"sources":["../../src/utils/update-check.ts"],"sourcesContent":["/**\n * Check for newer versions of mastracode on npm.\n */\n\nimport { execFile } from 'node:child_process';\nimport { readFileSync, realpathSync } from 'node:fs';\nimport { homedir } from 'node:os';\nimport { dirname, join, resolve, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\ndeclare const MASTRACODE_VERSION: string | undefined;\n\nconst PACKAGE_NAME = 'mastracode';\nconst NPM_REGISTRY_URL = `https://registry.npmjs.org/${PACKAGE_NAME}/latest`;\n\n/** Timeout for the npm registry fetch (ms). */\nconst FETCH_TIMEOUT_MS = 5_000;\n\n// Package managers and vp are .cmd shims on Windows; execFile can't spawn those without a shell (EINVAL).\nconst USE_SHELL = process.platform === 'win32';\n\nexport type PackageManager = 'npm' | 'pnpm' | 'yarn' | 'bun';\n\nfunction matchPM(str: string): PackageManager | null {\n // Order matters: check pnpm before npm since \"npm\" is a substring of some paths\n if (/pnpm/i.test(str)) return 'pnpm';\n if (/\\byarn\\b/i.test(str)) return 'yarn';\n if (/\\bbun\\b/i.test(str)) return 'bun';\n if (/\\bnpm\\b/i.test(str)) return 'npm';\n return null;\n}\n\n/**\n * Detect which package manager was used to install mastracode globally.\n *\n * Uses a multi-tier approach:\n * 1. npm_config_user_agent env var (set when run via `pnpm run`, `npm run`, etc.)\n * 2. npm_execpath env var (fallback for script-based invocation)\n * 3. NODE_PATH env var (set by pnpm global bin stubs)\n * 4. Resolved path of the running script (process.argv[1])\n * 5. Shell-out to `pnpm list -g` to check if pnpm manages the package\n * 6. Falls back to 'npm'\n */\nexport async function detectPackageManager(): Promise<PackageManager> {\n // Tier 1: npm_config_user_agent (most reliable when available)\n const userAgent = process.env.npm_config_user_agent;\n if (userAgent) {\n const pm = matchPM(userAgent);\n if (pm) return pm;\n }\n\n // Tier 2: npm_execpath\n const execPath = process.env.npm_execpath;\n if (execPath) {\n const pm = matchPM(execPath);\n if (pm) return pm;\n }\n\n // Tier 3: NODE_PATH (pnpm global stubs set this to paths containing .pnpm)\n const nodePath = process.env.NODE_PATH;\n if (nodePath) {\n if (/[/\\\\]\\.pnpm[/\\\\]/.test(nodePath) || /[/\\\\]pnpm[/\\\\]/.test(nodePath)) return 'pnpm';\n if (/[/\\\\]\\.yarn[/\\\\]/.test(nodePath)) return 'yarn';\n if (/[/\\\\]\\.bun[/\\\\]/.test(nodePath)) return 'bun';\n }\n\n // Tier 4: Resolved script path\n try {\n const scriptPath = realpathSync(process.argv[1] ?? '');\n if (/[/\\\\]\\.?pnpm[/\\\\]/.test(scriptPath)) return 'pnpm';\n if (/[/\\\\]\\.?yarn[/\\\\]/.test(scriptPath)) return 'yarn';\n if (/[/\\\\]\\.?bun[/\\\\]/.test(scriptPath)) return 'bun';\n } catch {\n // realpathSync can fail if argv[1] is missing/broken — fall through\n }\n\n // Tier 5: Check if the package is in pnpm's global store (non-blocking)\n const pnpmResult = await new Promise<boolean>(resolve => {\n execFile(\n 'pnpm',\n ['list', '-g', '--depth=0', PACKAGE_NAME],\n { timeout: 3_000, shell: USE_SHELL },\n (error, stdout) => {\n resolve(!error && stdout.includes(PACKAGE_NAME));\n },\n );\n });\n if (pnpmResult) return 'pnpm';\n\n return 'npm';\n}\n\n/**\n * Build the shell command string a user would run to install/update globally.\n */\nexport function getInstallCommand(pm: PackageManager, version?: string): string {\n const pkg = version ? `${PACKAGE_NAME}@${version}` : `${PACKAGE_NAME}@latest`;\n switch (pm) {\n case 'pnpm':\n return `pnpm add -g ${pkg}`;\n case 'yarn':\n return `yarn global add ${pkg}`;\n case 'bun':\n return `bun add -g ${pkg}`;\n default:\n return `npm install -g ${pkg}`;\n }\n}\n\n/**\n * Read the current version, injected at build time by tsdown's `define` option.\n * Falls back to reading package.json at runtime (e.g. when running from source with tsx).\n */\nexport function getCurrentVersion(): string {\n if (typeof MASTRACODE_VERSION !== 'undefined') {\n return MASTRACODE_VERSION;\n }\n // Fallback for running from source (e.g. pnpx tsx mastracode/src/main.ts)\n const dir = dirname(fileURLToPath(import.meta.url));\n const pkgPath = resolve(dir, '../../package.json');\n const pkg = JSON.parse(readFileSync(pkgPath, 'utf-8'));\n return pkg.version;\n}\n\n/**\n * Fetch the latest published version from npm.\n * Returns null if the fetch fails (network error, timeout, etc.).\n */\nexport async function fetchLatestVersion(): Promise<string | null> {\n if (process.env.MASTRACODE_UPDATE_LATEST_VERSION) return process.env.MASTRACODE_UPDATE_LATEST_VERSION;\n\n try {\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n const res = await fetch(NPM_REGISTRY_URL, { signal: controller.signal });\n clearTimeout(timeout);\n if (!res.ok) return null;\n const data = (await res.json()) as { version?: string };\n return data.version ?? null;\n } catch {\n return null;\n }\n}\n\n/**\n * Simple semver comparison: returns true if `latest` is newer than `current`.\n * Handles standard x.y.z versions. Ignores pre-release tags.\n */\nexport function isNewerVersion(current: string, latest: string): boolean {\n const parse = (v: string) =>\n v\n .replace(/^v/, '')\n .split('-')[0]!\n .split('.')\n .map(s => {\n const n = Number(s);\n return Number.isFinite(n) ? n : 0;\n });\n const [cMajor = 0, cMinor = 0, cPatch = 0] = parse(current);\n const [lMajor = 0, lMinor = 0, lPatch = 0] = parse(latest);\n if (lMajor !== cMajor) return lMajor > cMajor;\n if (lMinor !== cMinor) return lMinor > cMinor;\n return lPatch > cPatch;\n}\n\n/** Max entries to show in the changelog summary. */\nconst MAX_CHANGELOG_ENTRIES = 20;\n\n/**\n * Fetch the CHANGELOG.md for a specific published version from the npm CDN\n * and extract a human-readable summary of changes.\n * Returns null if the fetch fails or the changelog can't be parsed.\n */\nexport async function fetchChangelog(version: string): Promise<string | null> {\n if (process.env.MASTRACODE_UPDATE_CHANGELOG) return process.env.MASTRACODE_UPDATE_CHANGELOG;\n\n try {\n const url = `https://unpkg.com/${PACKAGE_NAME}@${version}/CHANGELOG.md`;\n const controller = new AbortController();\n const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);\n const res = await fetch(url, { signal: controller.signal });\n clearTimeout(timeout);\n if (!res.ok) return null;\n const text = await res.text();\n return parseChangelog(text, version);\n } catch {\n return null;\n }\n}\n\n/**\n * Extract the changelog section for a specific version and format it\n * as a concise bullet list suitable for terminal display.\n */\nexport function parseChangelog(markdown: string, version: string): string | null {\n const versionHeader = `## ${version}`;\n const startIdx = markdown.indexOf(versionHeader);\n if (startIdx === -1) return null;\n\n const afterHeader = startIdx + versionHeader.length;\n const nextHeaderIdx = markdown.indexOf('\\n## ', afterHeader);\n const section = nextHeaderIdx === -1 ? markdown.slice(afterHeader) : markdown.slice(afterHeader, nextHeaderIdx);\n\n const lines = section.split('\\n');\n const entries: string[] = [];\n let skipIndented = false;\n\n for (let i = 0; i < lines.length; i++) {\n const raw = lines[i]!;\n const trimmed = raw.trim();\n\n // Only match top-level entries (no leading whitespace before \"- \")\n const isTopLevel = raw === trimmed && trimmed.startsWith('- ');\n if (!isTopLevel) {\n // Skip indented sub-items (e.g. dependency list entries)\n if (skipIndented && /^\\s+-\\s/.test(raw)) continue;\n skipIndented = false;\n continue;\n }\n\n // Skip dependency update entries and their sub-items\n if (/^- Updated dependenc/i.test(trimmed)) {\n skipIndented = true;\n continue;\n }\n skipIndented = false;\n\n let entry = trimmed.slice(2);\n // Strip markdown links: [text](url) → text\n entry = entry.replace(/\\[([^\\]]+)\\]\\([^)]+\\)/g, '$1');\n // Strip PR references like (#15760)\n entry = entry.replace(/\\s*\\(#\\d+\\)\\s*/g, ' ');\n // Strip commit SHA references like (`abc123`)\n entry = entry.replace(/\\s*\\(`[a-f0-9]+`\\)\\s*/g, ' ');\n // Trim trailing periods for cleaner bullet display\n entry = entry.replace(/\\.\\s*$/, '');\n entry = entry.trim();\n if (entry) entries.push(entry);\n if (entries.length >= MAX_CHANGELOG_ENTRIES) break;\n }\n\n if (entries.length === 0) return null;\n return entries.map(e => ` • ${e}`).join('\\n');\n}\n\n/** Result of attempting an auto-update: exit status plus captured stderr. */\nexport interface UpdateResult {\n ok: boolean;\n stderr?: string;\n}\n\n/**\n * Run the appropriate global install command to update mastracode.\n * Exit code 0 does not prove the running binary changed (the install may land\n * in a location the PATH shim doesn't use) — verify with {@link locateOwnInstall}.\n */\nexport function runUpdate(pm: PackageManager, targetVersion: string): Promise<UpdateResult> {\n return execUpdate(pm, buildInstallArgs(pm, targetVersion));\n}\n\nfunction execUpdate(cmd: string, args: string[]): Promise<UpdateResult> {\n return new Promise(resolve => {\n execFile(cmd, args, { timeout: 60_000, shell: USE_SHELL }, (error, _stdout, stderr) => {\n const captured = (stderr ?? '').trim();\n if (error) {\n resolve({ ok: false, stderr: captured || error.message });\n } else {\n resolve({ ok: true, stderr: captured || undefined });\n }\n });\n });\n}\n\nfunction buildInstallArgs(pm: PackageManager, version: string): string[] {\n const pkg = `${PACKAGE_NAME}@${version}`;\n switch (pm) {\n case 'pnpm':\n return ['add', '-g', pkg];\n case 'yarn':\n return ['global', 'add', pkg];\n case 'bun':\n return ['add', '-g', pkg];\n default:\n return ['install', '-g', pkg];\n }\n}\n\n/** Max stderr lines to surface when an update fails. */\nconst MAX_UPDATE_ERROR_LINES = 5;\n\nfunction formatUpdaterError(stderr: string | undefined): string | null {\n if (!stderr) return null;\n const lines = stderr\n .split('\\n')\n .map(line => line.trimEnd())\n .filter(line => line.trim().length > 0);\n if (lines.length === 0) return null;\n return lines.slice(-MAX_UPDATE_ERROR_LINES).join('\\n');\n}\n\n/**\n * Find the installed mastracode package the running binary belongs to (walking\n * up from `process.argv[1]`) and read its version fresh from disk. Returns\n * null when it can't be determined, e.g. when running from source.\n */\nexport function locateOwnInstall(): { dir: string; version: string | null } | null {\n const entry = process.argv[1];\n if (!entry) return null;\n\n let dir: string;\n try {\n dir = dirname(realpathSync(entry));\n } catch {\n return null;\n }\n\n let previous = '';\n while (dir && dir !== previous) {\n try {\n const pkg = JSON.parse(readFileSync(resolve(dir, 'package.json'), 'utf-8')) as {\n name?: string;\n version?: string;\n };\n if (pkg.name === PACKAGE_NAME) {\n return { dir, version: typeof pkg.version === 'string' ? pkg.version : null };\n }\n } catch {\n // Not a readable manifest — keep walking up.\n }\n previous = dir;\n dir = dirname(dir);\n }\n\n return null;\n}\n\nexport type UpdateOutcome =\n | { status: 'updated'; message: string }\n | { status: 'unchanged'; message: string }\n | { status: 'failed'; message: string };\n\n/**\n * Decide what to tell the user after {@link runUpdate}: `updated` when the\n * on-disk version matches the target (or can't be determined), `unchanged`\n * when the package manager succeeded but the running install didn't change,\n * `failed` on error (with the package manager's stderr).\n */\nexport function resolveUpdateOutcome(opts: {\n pm: PackageManager;\n targetVersion: string;\n result: UpdateResult;\n install: { dir: string; version: string | null } | null;\n /** Overrides the suggested manual command, e.g. when the update was delegated to the owning tool. */\n manualCommand?: string;\n}): UpdateOutcome {\n const { pm, targetVersion, result, install } = opts;\n const cmd = opts.manualCommand ?? getInstallCommand(pm, targetVersion);\n\n if (!result.ok) {\n const details = formatUpdaterError(result.stderr);\n let message = `Auto-update failed. Run \\`${cmd}\\` manually.`;\n if (details) message += `\\n\\n${details}`;\n return { status: 'failed', message };\n }\n\n if (install?.version != null && install.version !== targetVersion) {\n const message = opts.manualCommand\n ? `The update ran, but the Mastra Code you are running (at ${install.dir}) is still ` +\n `v${install.version}. Try \\`${cmd}\\` manually.`\n : `The update installed, but the Mastra Code you are running (at ${install.dir}) is still ` +\n `v${install.version} — it looks like it is managed by another tool. Update it with that tool, ` +\n `or try \\`${cmd}\\`.`;\n return { status: 'unchanged', message };\n }\n\n return { status: 'updated', message: `Updated to v${targetVersion}. Please restart Mastra Code.` };\n}\n\n/** Global node_modules directory the package manager installs into, or null when unknown. */\nfunction getGlobalRoot(pm: PackageManager): Promise<string | null> {\n const args = pm === 'yarn' ? ['global', 'dir'] : ['root', '-g'];\n return new Promise(res => {\n execFile(pm, args, { timeout: 10_000, shell: USE_SHELL }, (error, stdout) => {\n const out = (stdout ?? '').trim().split('\\n').pop()?.trim();\n if (error || !out) return res(null);\n res(pm === 'yarn' ? resolve(out, 'node_modules') : out);\n });\n });\n}\n\n/**\n * Whether updating via `pm` would touch the install the running binary uses.\n * Fail-open: returns true when either side can't be determined, so the update\n * proceeds and the post-install verification has the final word.\n */\nasync function isOwnInstallManagedBy(pm: PackageManager, install: { dir: string } | null): Promise<boolean> {\n if (!install) return true;\n const root = await getGlobalRoot(pm);\n if (!root) return true;\n try {\n return realpathSync(resolve(root, PACKAGE_NAME)) === install.dir;\n } catch {\n // Package absent from the pm's global root: installing there can't affect the running binary.\n return false;\n }\n}\n\n/** A tool other than a package manager that owns the running install, matched by path. */\ninterface InstallOwner {\n name: string;\n /** Command to run to delegate the update; omitted when we only suggest `command` to the user. */\n exec?: { cmd: string; args: string[] };\n command: string;\n}\n\nfunction findInstallOwner(dir: string, version: string): InstallOwner | null {\n if (dir.startsWith(join(homedir(), '.vite-plus') + sep)) {\n return {\n name: 'vite-plus',\n exec: { cmd: 'vp', args: ['install', '-g', `${PACKAGE_NAME}@${version}`] },\n command: `vp install -g ${PACKAGE_NAME}@${version}`,\n };\n }\n // Homebrew keeps formulas under <prefix>/Cellar/ whatever the prefix, so match the path segment.\n if (dir.split(sep).includes('Cellar')) {\n // Suggest-only: brew formulas lag npm, and `brew upgrade` can pull unrelated updates.\n return { name: 'Homebrew', command: `brew upgrade ${PACKAGE_NAME}` };\n }\n return null;\n}\n\n/**\n * Update mastracode and verify the result: delegates to the tool that owns the\n * running install when we recognize it, skips the install when it isn't\n * managed by `pm`, otherwise runs the package manager. Every executed update\n * is verified against the on-disk version.\n */\nexport async function performUpdate(pm: PackageManager, targetVersion: string): Promise<UpdateOutcome> {\n // The registry-provided version reaches shell commands on Windows — accept only version tokens.\n if (!/^[\\w.+-]+$/.test(targetVersion)) {\n return { status: 'failed', message: `Auto-update aborted: unexpected version \"${targetVersion}\".` };\n }\n\n const install = locateOwnInstall();\n\n const owner = install ? findInstallOwner(install.dir, targetVersion) : null;\n if (owner) {\n if (!owner.exec) {\n const message =\n `Your Mastra Code install (at ${install!.dir}) is managed by ${owner.name}. ` +\n `Update it with \\`${owner.command}\\`.`;\n return { status: 'unchanged', message };\n }\n const result = await execUpdate(owner.exec.cmd, owner.exec.args);\n return resolveUpdateOutcome({\n pm,\n targetVersion,\n result,\n install: locateOwnInstall(),\n manualCommand: owner.command,\n });\n }\n\n if (!(await isOwnInstallManagedBy(pm, install))) {\n const message =\n `Your Mastra Code install (at ${install!.dir}) is not managed by ${pm} — it looks like it was ` +\n `installed by another tool. Update it with that tool, or try \\`${getInstallCommand(pm, targetVersion)}\\`.`;\n return { status: 'unchanged', message };\n }\n\n const result = await runUpdate(pm, targetVersion);\n // Re-locate so the version reflects what the install just wrote to disk.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oB,eAA+C;CAErG,IAAI,CAAC,aAAa,KAAK,aAAa,GAClC,OAAO;EAAE,QAAQ;EAAU,SAAS,4CAA4C,cAAc;CAAI;CAGpG,MAAM,UAAU,iBAAiB;CAEjC,MAAM,QAAQ,UAAU,iBAAiB,QAAQ,KAAK,aAAa,IAAI;CACvE,IAAI,OAAO;EACT,IAAI,CAAC,MAAM,MAIT,OAAO;GAAE,QAAQ;GAAa,SAAA,gCAFI,QAAS,IAAI,kBAAkB,MAAM,KAAK,qBACtD,MAAM,QAAQ;EACE;EAGxC,OAAO,qBAAqB;GAC1B;GACA;GACA,QAAA,MAJmB,WAAW,MAAM,KAAK,KAAK,MAAM,KAAK,IAAI;GAK7D,SAAS,iBAAiB;GAC1B,eAAe,MAAM;EACvB,CAAC;CACH;CAEA,IAAI,CAAE,MAAM,sBAAsB,IAAI,OAAO,GAI3C,OAAO;EAAE,QAAQ;EAAa,SAAA,gCAFI,QAAS,IAAI,sBAAsB,GAAG,wFACL,kBAAkB,IAAI,aAAa,EAAE;CAClE;CAKxC,OAAO,qBAAqB;EAAE;EAAI;EAAe,QAAA,MAF5B,UAAU,IAAI,aAAa;EAES,SAAS,iBAAiB;CAAE,CAAC;AACxF"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Speech-to-text (STT) model registry for push-to-talk voice input.
3
+ *
4
+ * This is the single source of truth shared by the `/voice` settings picker,
5
+ * settings validation, and the cloud transcription resolver. Entries are
6
+ * derived from models.dev (https://models.dev/api.json): a model is treated as
7
+ * STT when its modalities are audio-in / text-out with no text input.
8
+ *
9
+ * Most cloud providers here speak the OpenAI `/audio/transcriptions` shape, so
10
+ * the cloud engine resolves them through Mastra's `OpenAIVoice` (`MastraVoice`)
11
+ * built on the OpenAI client — `openai` uses the default endpoint, every other
12
+ * OpenAI-compatible host supplies its `baseURL`. Deepgram is the exception: it
13
+ * is not OpenAI-compatible, so it resolves through `@mastra/voice-deepgram`
14
+ * (`DeepgramVoice`). Deepgram is not in the models.dev STT snapshot but is a
15
+ * first-class hosted STT provider, so it is added deliberately.
16
+ *
17
+ * The accompanying snapshot test (`__tests__/stt-registry.test.ts`) re-derives
18
+ * the models.dev-backed entries from a checked-in snapshot so this list stays
19
+ * honest and can be refreshed deliberately rather than drifting by hand.
20
+ */
21
+ /**
22
+ * How a provider's transcription model is constructed.
23
+ * - `openai`: `OpenAIVoice` with the default OpenAI endpoint.
24
+ * - `openai-compatible`: `OpenAIVoice` pointed at the host's `baseURL`
25
+ * (its `/audio/transcriptions` endpoint follows the OpenAI shape).
26
+ * - `deepgram`: `DeepgramVoice` from `@mastra/voice-deepgram` (not
27
+ * OpenAI-compatible; uses the Deepgram SDK).
28
+ */
29
+ export type STTResolver = 'openai' | 'openai-compatible' | 'deepgram';
30
+ export interface STTModel {
31
+ /** models.dev provider id (also the AuthStorage key for the API key). */
32
+ provider: string;
33
+ /** Bare model id passed to the provider's transcription factory. */
34
+ model: string;
35
+ /** Human-friendly label for the picker. */
36
+ label: string;
37
+ /** How to build the transcription model. */
38
+ resolver: STTResolver;
39
+ /** Base URL for `openai-compatible` providers (from models.dev `api`). */
40
+ baseURL?: string;
41
+ }
42
+ /**
43
+ * The curated STT catalog. Order matters: the first entry for a provider is its
44
+ * default model, and the first overall entry (`openai`/`whisper-1`) is the
45
+ * global default.
46
+ */
47
+ export declare const STT_MODELS: readonly STTModel[];
48
+ /** The global default STT model (first registry entry). */
49
+ export declare const DEFAULT_STT_MODEL: STTModel;
50
+ /** The default STT provider when none is configured. */
51
+ export declare const DEFAULT_STT_PROVIDER: string;
52
+ /** Unique provider ids in registry order. */
53
+ export declare function sttProviders(): string[];
54
+ /** All models offered for a provider, in registry order. */
55
+ export declare function sttModelsForProvider(provider: string): STTModel[];
56
+ /** The default (first) model for a provider, or undefined if unknown. */
57
+ export declare function defaultModelForProvider(provider: string): STTModel | undefined;
58
+ /**
59
+ * Resolve a provider/model pair to a concrete registry entry.
60
+ * Falls back to the provider default (then the global default) so callers
61
+ * always get a usable entry even if settings name an unknown model.
62
+ */
63
+ export declare function resolveSTTModel(provider?: string, model?: string): STTModel;
64
+ //# sourceMappingURL=stt-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stt-registry.d.ts","sourceRoot":"","sources":["../../src/voice/stt-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,mBAAmB,GAAG,UAAU,CAAC;AAEtE,MAAM,WAAW,QAAQ;IACvB,yEAAyE;IACzE,QAAQ,EAAE,MAAM,CAAC;IACjB,oEAAoE;IACpE,KAAK,EAAE,MAAM,CAAC;IACd,2CAA2C;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,4CAA4C;IAC5C,QAAQ,EAAE,WAAW,CAAC;IACtB,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,eAAO,MAAM,UAAU,EAAE,SAAS,QAAQ,EAqFhC,CAAC;AAEX,2DAA2D;AAC3D,eAAO,MAAM,iBAAiB,EAAE,QAAyB,CAAC;AAE1D,wDAAwD;AACxD,eAAO,MAAM,oBAAoB,QAA6B,CAAC;AAE/D,6CAA6C;AAC7C,wBAAgB,YAAY,IAAI,MAAM,EAAE,CAUvC;AAED,4DAA4D;AAC5D,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,EAAE,CAEjE;AAED,yEAAyE;AACzE,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAE9E;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ,CAU3E"}