@mastra/code-sdk 0.0.0-agent-tags-alpha-20261125185303

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 (407) hide show
  1. package/LICENSE.md +32 -0
  2. package/README.md +284 -0
  3. package/dist/acp/agent.d.ts +48 -0
  4. package/dist/acp/agent.js +414 -0
  5. package/dist/acp/errors.d.ts +3 -0
  6. package/dist/acp/errors.js +11 -0
  7. package/dist/acp/event-mapper.d.ts +28 -0
  8. package/dist/acp/event-mapper.js +274 -0
  9. package/dist/acp/index.d.ts +9 -0
  10. package/dist/acp/index.js +21 -0
  11. package/dist/acp/runtime.d.ts +5 -0
  12. package/dist/acp/runtime.js +91 -0
  13. package/dist/acp/server.d.ts +4 -0
  14. package/dist/acp/server.js +35 -0
  15. package/dist/acp/skills.d.ts +6 -0
  16. package/dist/acp/skills.js +30 -0
  17. package/dist/acp.d.ts +2 -0
  18. package/dist/acp.js +1 -0
  19. package/dist/agent-connections/messaging-processor.d.ts +17 -0
  20. package/dist/agent-connections/messaging-processor.js +131 -0
  21. package/dist/agent-connections/ownership.d.ts +24 -0
  22. package/dist/agent-connections/ownership.js +96 -0
  23. package/dist/agent-connections/registry.d.ts +20 -0
  24. package/dist/agent-connections/registry.js +167 -0
  25. package/dist/agent-connections/session-advertisement.d.ts +27 -0
  26. package/dist/agent-connections/session-advertisement.js +86 -0
  27. package/dist/agent-connections/signal-provider.d.ts +141 -0
  28. package/dist/agent-connections/signal-provider.js +35 -0
  29. package/dist/agent-connections/state-processor.d.ts +23 -0
  30. package/dist/agent-connections/state-processor.js +270 -0
  31. package/dist/agent-connections/thread-state.d.ts +41 -0
  32. package/dist/agent-connections/thread-state.js +157 -0
  33. package/dist/agent-connections/tools.d.ts +133 -0
  34. package/dist/agent-connections/tools.js +616 -0
  35. package/dist/agent-connections/types.d.ts +99 -0
  36. package/dist/agent-connections/types.js +4 -0
  37. package/dist/agent-connections/untrusted-text.d.ts +5 -0
  38. package/dist/agent-connections/untrusted-text.js +19 -0
  39. package/dist/agents/background-completion-events.d.ts +16 -0
  40. package/dist/agents/background-completion-events.js +16 -0
  41. package/dist/agents/background-completion.d.ts +22 -0
  42. package/dist/agents/background-completion.js +73 -0
  43. package/dist/agents/context-audit.d.ts +84 -0
  44. package/dist/agents/context-audit.js +115 -0
  45. package/dist/agents/credential-resolver.d.ts +74 -0
  46. package/dist/agents/credential-resolver.js +142 -0
  47. package/dist/agents/custom-provider-source.d.ts +35 -0
  48. package/dist/agents/custom-provider-source.js +22 -0
  49. package/dist/agents/fastembed-subprocess.d.ts +52 -0
  50. package/dist/agents/fastembed-subprocess.js +282 -0
  51. package/dist/agents/instructions.d.ts +42 -0
  52. package/dist/agents/instructions.js +69 -0
  53. package/dist/agents/mastracode-gateway.d.ts +85 -0
  54. package/dist/agents/mastracode-gateway.js +500 -0
  55. package/dist/agents/memory.d.ts +36 -0
  56. package/dist/agents/memory.js +248 -0
  57. package/dist/agents/model.d.ts +158 -0
  58. package/dist/agents/model.js +382 -0
  59. package/dist/agents/modes/build.d.ts +12 -0
  60. package/dist/agents/modes/build.js +33 -0
  61. package/dist/agents/modes/explore.d.ts +10 -0
  62. package/dist/agents/modes/explore.js +25 -0
  63. package/dist/agents/modes/plan.d.ts +8 -0
  64. package/dist/agents/modes/plan.js +43 -0
  65. package/dist/agents/prompts/agent-instructions.d.ts +122 -0
  66. package/dist/agents/prompts/agent-instructions.js +617 -0
  67. package/dist/agents/prompts/build.d.ts +12 -0
  68. package/dist/agents/prompts/build.js +73 -0
  69. package/dist/agents/prompts/fast.d.ts +5 -0
  70. package/dist/agents/prompts/fast.js +23 -0
  71. package/dist/agents/prompts/index.d.ts +61 -0
  72. package/dist/agents/prompts/index.js +141 -0
  73. package/dist/agents/prompts/model.d.ts +5 -0
  74. package/dist/agents/prompts/model.js +20 -0
  75. package/dist/agents/prompts/plan.d.ts +11 -0
  76. package/dist/agents/prompts/plan.js +132 -0
  77. package/dist/agents/prompts/tool-guidance.d.ts +18 -0
  78. package/dist/agents/prompts/tool-guidance.js +158 -0
  79. package/dist/agents/sandbox-filesystem.d.ts +232 -0
  80. package/dist/agents/sandbox-filesystem.js +851 -0
  81. package/dist/agents/subagents/execute.d.ts +3 -0
  82. package/dist/agents/subagents/execute.js +24 -0
  83. package/dist/agents/subagents/explore.d.ts +3 -0
  84. package/dist/agents/subagents/explore.js +15 -0
  85. package/dist/agents/subagents/index.d.ts +6 -0
  86. package/dist/agents/subagents/index.js +15 -0
  87. package/dist/agents/subagents/plan.d.ts +3 -0
  88. package/dist/agents/subagents/plan.js +15 -0
  89. package/dist/agents/thread-caveman-state.d.ts +17 -0
  90. package/dist/agents/thread-caveman-state.js +104 -0
  91. package/dist/agents/tool-availability.d.ts +17 -0
  92. package/dist/agents/tool-availability.js +134 -0
  93. package/dist/agents/tools.d.ts +37 -0
  94. package/dist/agents/tools.js +154 -0
  95. package/dist/agents/workflow-builder-agent.d.ts +2 -0
  96. package/dist/agents/workflow-builder-agent.js +79 -0
  97. package/dist/agents/workspace.d.ts +35 -0
  98. package/dist/agents/workspace.js +207 -0
  99. package/dist/analytics.d.ts +18 -0
  100. package/dist/analytics.js +159 -0
  101. package/dist/auth/account-rotation-processor.d.ts +210 -0
  102. package/dist/auth/account-rotation-processor.js +662 -0
  103. package/dist/auth/account-routing-context.d.ts +17 -0
  104. package/dist/auth/account-routing-context.js +38 -0
  105. package/dist/auth/authorization-input.d.ts +16 -0
  106. package/dist/auth/authorization-input.js +39 -0
  107. package/dist/auth/device-code.d.ts +93 -0
  108. package/dist/auth/device-code.js +126 -0
  109. package/dist/auth/index.d.ts +13 -0
  110. package/dist/auth/index.js +9 -0
  111. package/dist/auth/pkce.d.ts +13 -0
  112. package/dist/auth/pkce.js +29 -0
  113. package/dist/auth/provider-auth-error.d.ts +24 -0
  114. package/dist/auth/provider-auth-error.js +44 -0
  115. package/dist/auth/providers/anthropic.d.ts +40 -0
  116. package/dist/auth/providers/anthropic.js +117 -0
  117. package/dist/auth/providers/github-copilot.d.ts +154 -0
  118. package/dist/auth/providers/github-copilot.js +359 -0
  119. package/dist/auth/providers/kimi-coding.d.ts +38 -0
  120. package/dist/auth/providers/kimi-coding.js +225 -0
  121. package/dist/auth/providers/openai-codex.d.ts +141 -0
  122. package/dist/auth/providers/openai-codex.js +531 -0
  123. package/dist/auth/providers/xai.d.ts +64 -0
  124. package/dist/auth/providers/xai.js +223 -0
  125. package/dist/auth/storage.d.ts +222 -0
  126. package/dist/auth/storage.js +805 -0
  127. package/dist/auth/types.d.ts +164 -0
  128. package/dist/auth/types.js +1 -0
  129. package/dist/clipboard/index.d.ts +26 -0
  130. package/dist/clipboard/index.js +224 -0
  131. package/dist/constants.d.ts +29 -0
  132. package/dist/constants.js +34 -0
  133. package/dist/error-classification.d.ts +10 -0
  134. package/dist/error-classification.js +19 -0
  135. package/dist/evals/context-builder.d.ts +41 -0
  136. package/dist/evals/context-builder.js +156 -0
  137. package/dist/evals/index.d.ts +4 -0
  138. package/dist/evals/index.js +5 -0
  139. package/dist/evals/scorers/classify-command.d.ts +30 -0
  140. package/dist/evals/scorers/classify-command.js +61 -0
  141. package/dist/evals/scorers/efficiency.d.ts +44 -0
  142. package/dist/evals/scorers/efficiency.js +256 -0
  143. package/dist/evals/scorers/extract-tools.d.ts +25 -0
  144. package/dist/evals/scorers/extract-tools.js +57 -0
  145. package/dist/evals/scorers/index.d.ts +3 -0
  146. package/dist/evals/scorers/index.js +3 -0
  147. package/dist/evals/scorers/outcome.d.ts +49 -0
  148. package/dist/evals/scorers/outcome.js +360 -0
  149. package/dist/experimental-agent.d.ts +19 -0
  150. package/dist/experimental-agent.js +45 -0
  151. package/dist/factory/client.d.ts +44 -0
  152. package/dist/factory/client.js +110 -0
  153. package/dist/factory/remote-controller.d.ts +34 -0
  154. package/dist/factory/remote-controller.js +40 -0
  155. package/dist/factory/remote-session.d.ts +210 -0
  156. package/dist/factory/remote-session.js +415 -0
  157. package/dist/goal-manager.d.ts +114 -0
  158. package/dist/goal-manager.js +351 -0
  159. package/dist/goal-signal.d.ts +14 -0
  160. package/dist/goal-signal.js +14 -0
  161. package/dist/headless/cli.d.ts +55 -0
  162. package/dist/headless/cli.js +261 -0
  163. package/dist/headless/flags.d.ts +33 -0
  164. package/dist/headless/flags.js +207 -0
  165. package/dist/headless/format.d.ts +41 -0
  166. package/dist/headless/format.js +94 -0
  167. package/dist/headless/index.d.ts +25 -0
  168. package/dist/headless/index.js +6 -0
  169. package/dist/headless/policy.d.ts +17 -0
  170. package/dist/headless/policy.js +39 -0
  171. package/dist/headless/run-mc.d.ts +7 -0
  172. package/dist/headless/run-mc.js +438 -0
  173. package/dist/headless/types.d.ts +175 -0
  174. package/dist/headless/types.js +16 -0
  175. package/dist/hooks/config.d.ts +11 -0
  176. package/dist/hooks/config.js +77 -0
  177. package/dist/hooks/executor.d.ts +13 -0
  178. package/dist/hooks/executor.js +128 -0
  179. package/dist/hooks/index.d.ts +6 -0
  180. package/dist/hooks/index.js +5 -0
  181. package/dist/hooks/manager.d.ts +75 -0
  182. package/dist/hooks/manager.js +289 -0
  183. package/dist/hooks/types.d.ts +180 -0
  184. package/dist/hooks/types.js +5 -0
  185. package/dist/index.d.ts +537 -0
  186. package/dist/index.js +1399 -0
  187. package/dist/ipc/ipc-reporter.d.ts +14 -0
  188. package/dist/ipc/ipc-reporter.js +18 -0
  189. package/dist/knowledge-inspector.d.ts +139 -0
  190. package/dist/knowledge-inspector.js +533 -0
  191. package/dist/knowledge-scope-id.d.ts +7 -0
  192. package/dist/knowledge-scope-id.js +10 -0
  193. package/dist/knowledge-scope.d.ts +41 -0
  194. package/dist/knowledge-scope.js +85 -0
  195. package/dist/lsp/client.d.ts +56 -0
  196. package/dist/lsp/client.js +248 -0
  197. package/dist/lsp/index.d.ts +4 -0
  198. package/dist/lsp/index.js +4 -0
  199. package/dist/lsp/language.d.ts +9 -0
  200. package/dist/lsp/language.js +41 -0
  201. package/dist/lsp/manager.d.ts +34 -0
  202. package/dist/lsp/manager.js +79 -0
  203. package/dist/lsp/server.d.ts +27 -0
  204. package/dist/lsp/server.js +158 -0
  205. package/dist/lsp/workspace.d.ts +9 -0
  206. package/dist/lsp/workspace.js +52 -0
  207. package/dist/mcp/config.d.ts +77 -0
  208. package/dist/mcp/config.js +313 -0
  209. package/dist/mcp/index.d.ts +6 -0
  210. package/dist/mcp/index.js +3 -0
  211. package/dist/mcp/manager.d.ts +104 -0
  212. package/dist/mcp/manager.js +693 -0
  213. package/dist/mcp/state.d.ts +35 -0
  214. package/dist/mcp/state.js +94 -0
  215. package/dist/mcp/types.d.ts +139 -0
  216. package/dist/mcp/types.js +1 -0
  217. package/dist/onboarding/custom-packs.d.ts +7 -0
  218. package/dist/onboarding/custom-packs.js +17 -0
  219. package/dist/onboarding/custom-providers.d.ts +4 -0
  220. package/dist/onboarding/custom-providers.js +27 -0
  221. package/dist/onboarding/index.d.ts +5 -0
  222. package/dist/onboarding/index.js +3 -0
  223. package/dist/onboarding/om-settings.d.ts +47 -0
  224. package/dist/onboarding/om-settings.js +80 -0
  225. package/dist/onboarding/pack-activation.d.ts +43 -0
  226. package/dist/onboarding/pack-activation.js +105 -0
  227. package/dist/onboarding/packs.d.ts +106 -0
  228. package/dist/onboarding/packs.js +283 -0
  229. package/dist/onboarding/settings.d.ts +563 -0
  230. package/dist/onboarding/settings.js +1110 -0
  231. package/dist/permissions.d.ts +55 -0
  232. package/dist/permissions.js +139 -0
  233. package/dist/platform/index.d.ts +74 -0
  234. package/dist/platform/index.js +199 -0
  235. package/dist/plugin.d.ts +156 -0
  236. package/dist/plugin.js +27 -0
  237. package/dist/plugins/dependencies.d.ts +9 -0
  238. package/dist/plugins/dependencies.js +84 -0
  239. package/dist/plugins/install.d.ts +21 -0
  240. package/dist/plugins/install.js +187 -0
  241. package/dist/plugins/loader.d.ts +25 -0
  242. package/dist/plugins/loader.js +264 -0
  243. package/dist/plugins/manager.d.ts +115 -0
  244. package/dist/plugins/manager.js +507 -0
  245. package/dist/plugins/manifest.d.ts +14 -0
  246. package/dist/plugins/manifest.js +47 -0
  247. package/dist/plugins/package-link.d.ts +3 -0
  248. package/dist/plugins/package-link.js +58 -0
  249. package/dist/plugins/paths.d.ts +10 -0
  250. package/dist/plugins/paths.js +22 -0
  251. package/dist/plugins/registry.d.ts +8 -0
  252. package/dist/plugins/registry.js +109 -0
  253. package/dist/plugins/scaffold.d.ts +10 -0
  254. package/dist/plugins/scaffold.js +115 -0
  255. package/dist/plugins/signal-lane.d.ts +59 -0
  256. package/dist/plugins/signal-lane.js +163 -0
  257. package/dist/plugins/types.d.ts +95 -0
  258. package/dist/plugins/types.js +1 -0
  259. package/dist/process-memory-diagnostics.d.ts +136 -0
  260. package/dist/process-memory-diagnostics.js +497 -0
  261. package/dist/processors/plan-rejection-abort.d.ts +16 -0
  262. package/dist/processors/plan-rejection-abort.js +62 -0
  263. package/dist/providers/amazon-bedrock-gateway.d.ts +47 -0
  264. package/dist/providers/amazon-bedrock-gateway.js +142 -0
  265. package/dist/providers/amazon-bedrock.d.ts +28 -0
  266. package/dist/providers/amazon-bedrock.js +99 -0
  267. package/dist/providers/anthropic-prompt-cache.d.ts +19 -0
  268. package/dist/providers/anthropic-prompt-cache.js +8 -0
  269. package/dist/providers/anthropic-thinking.d.ts +5 -0
  270. package/dist/providers/anthropic-thinking.js +22 -0
  271. package/dist/providers/claude-max.d.ts +67 -0
  272. package/dist/providers/claude-max.js +232 -0
  273. package/dist/providers/github-copilot-gateway.d.ts +35 -0
  274. package/dist/providers/github-copilot-gateway.js +58 -0
  275. package/dist/providers/github-copilot.d.ts +60 -0
  276. package/dist/providers/github-copilot.js +320 -0
  277. package/dist/providers/google-thinking.d.ts +31 -0
  278. package/dist/providers/google-thinking.js +64 -0
  279. package/dist/providers/google-vertex-gateway.d.ts +23 -0
  280. package/dist/providers/google-vertex-gateway.js +49 -0
  281. package/dist/providers/google-vertex.d.ts +6 -0
  282. package/dist/providers/google-vertex.js +51 -0
  283. package/dist/providers/kimi-coding.d.ts +14 -0
  284. package/dist/providers/kimi-coding.js +80 -0
  285. package/dist/providers/model-ids.d.ts +53 -0
  286. package/dist/providers/model-ids.js +132 -0
  287. package/dist/providers/openai-codex.d.ts +114 -0
  288. package/dist/providers/openai-codex.js +427 -0
  289. package/dist/providers/provider-thinking.d.ts +23 -0
  290. package/dist/providers/provider-thinking.js +61 -0
  291. package/dist/providers/thinking-request.d.ts +14 -0
  292. package/dist/providers/thinking-request.js +87 -0
  293. package/dist/providers/xai.d.ts +33 -0
  294. package/dist/providers/xai.js +72 -0
  295. package/dist/schedules/index.d.ts +10 -0
  296. package/dist/schedules/index.js +6 -0
  297. package/dist/schedules/interval.d.ts +49 -0
  298. package/dist/schedules/interval.js +212 -0
  299. package/dist/schedules/prompt.d.ts +36 -0
  300. package/dist/schedules/prompt.js +36 -0
  301. package/dist/schedules/run-script.d.ts +8 -0
  302. package/dist/schedules/run-script.js +80 -0
  303. package/dist/schedules/scheduler.d.ts +101 -0
  304. package/dist/schedules/scheduler.js +167 -0
  305. package/dist/schedules/tools.d.ts +57 -0
  306. package/dist/schedules/tools.js +217 -0
  307. package/dist/schema.d.ts +499 -0
  308. package/dist/schema.js +131 -0
  309. package/dist/theme-palette.d.ts +17 -0
  310. package/dist/theme-palette.js +18 -0
  311. package/dist/thinking-catalog.d.ts +4 -0
  312. package/dist/thinking-catalog.js +13 -0
  313. package/dist/thinking.d.ts +37 -0
  314. package/dist/thinking.js +134 -0
  315. package/dist/tool-names.d.ts +77 -0
  316. package/dist/tool-names.js +53 -0
  317. package/dist/tools/index.d.ts +6 -0
  318. package/dist/tools/index.js +3 -0
  319. package/dist/tools/request-sandbox-access.d.ts +6 -0
  320. package/dist/tools/request-sandbox-access.js +80 -0
  321. package/dist/tools/utils.d.ts +20 -0
  322. package/dist/tools/utils.js +31 -0
  323. package/dist/tools/web-search.d.ts +116 -0
  324. package/dist/tools/web-search.js +158 -0
  325. package/dist/tools/workflows/create-workflow.d.ts +7 -0
  326. package/dist/tools/workflows/create-workflow.js +82 -0
  327. package/dist/tools/workflows/delete-workflow.d.ts +7 -0
  328. package/dist/tools/workflows/delete-workflow.js +18 -0
  329. package/dist/tools/workflows/ephemeral-memory.d.ts +28 -0
  330. package/dist/tools/workflows/ephemeral-memory.js +41 -0
  331. package/dist/tools/workflows/extract-json-schema.d.ts +12 -0
  332. package/dist/tools/workflows/extract-json-schema.js +19 -0
  333. package/dist/tools/workflows/get-workflow.d.ts +11 -0
  334. package/dist/tools/workflows/get-workflow.js +31 -0
  335. package/dist/tools/workflows/list-available-agents.d.ts +8 -0
  336. package/dist/tools/workflows/list-available-agents.js +29 -0
  337. package/dist/tools/workflows/list-available-classifiers.d.ts +19 -0
  338. package/dist/tools/workflows/list-available-classifiers.js +53 -0
  339. package/dist/tools/workflows/list-available-tools.d.ts +9 -0
  340. package/dist/tools/workflows/list-available-tools.js +37 -0
  341. package/dist/tools/workflows/list-available-workflows.d.ts +9 -0
  342. package/dist/tools/workflows/list-available-workflows.js +29 -0
  343. package/dist/tools/workflows/list-workflows.d.ts +9 -0
  344. package/dist/tools/workflows/list-workflows.js +30 -0
  345. package/dist/tools/workflows/run-workflow.d.ts +9 -0
  346. package/dist/tools/workflows/run-workflow.js +49 -0
  347. package/dist/tools/workflows/save-workflow.d.ts +1125 -0
  348. package/dist/tools/workflows/save-workflow.js +25 -0
  349. package/dist/tools/workflows/tool-ids.d.ts +16 -0
  350. package/dist/tools/workflows/tool-ids.js +17 -0
  351. package/dist/utils/binaries.d.ts +7 -0
  352. package/dist/utils/binaries.js +97 -0
  353. package/dist/utils/debug-log.d.ts +12 -0
  354. package/dist/utils/debug-log.js +56 -0
  355. package/dist/utils/discarding-scores-storage.d.ts +33 -0
  356. package/dist/utils/discarding-scores-storage.js +51 -0
  357. package/dist/utils/errors.d.ts +36 -0
  358. package/dist/utils/errors.js +215 -0
  359. package/dist/utils/gateway-sync.d.ts +26 -0
  360. package/dist/utils/gateway-sync.js +58 -0
  361. package/dist/utils/local-observability.d.ts +19 -0
  362. package/dist/utils/local-observability.js +54 -0
  363. package/dist/utils/maintenance-lock.d.ts +42 -0
  364. package/dist/utils/maintenance-lock.js +196 -0
  365. package/dist/utils/notification-dispatch.d.ts +74 -0
  366. package/dist/utils/notification-dispatch.js +128 -0
  367. package/dist/utils/open-url.d.ts +10 -0
  368. package/dist/utils/open-url.js +27 -0
  369. package/dist/utils/path-security.d.ts +2 -0
  370. package/dist/utils/path-security.js +7 -0
  371. package/dist/utils/plan-diff.d.ts +25 -0
  372. package/dist/utils/plan-diff.js +59 -0
  373. package/dist/utils/plans.d.ts +61 -0
  374. package/dist/utils/plans.js +120 -0
  375. package/dist/utils/project.d.ts +160 -0
  376. package/dist/utils/project.js +361 -0
  377. package/dist/utils/prune-cli.d.ts +24 -0
  378. package/dist/utils/prune-cli.js +124 -0
  379. package/dist/utils/signals-pubsub.d.ts +103 -0
  380. package/dist/utils/signals-pubsub.js +409 -0
  381. package/dist/utils/slash-command-loader.d.ts +52 -0
  382. package/dist/utils/slash-command-loader.js +139 -0
  383. package/dist/utils/slash-command-processor.d.ts +14 -0
  384. package/dist/utils/slash-command-processor.js +106 -0
  385. package/dist/utils/stdin-pipe.d.ts +33 -0
  386. package/dist/utils/stdin-pipe.js +93 -0
  387. package/dist/utils/storage-factory.d.ts +50 -0
  388. package/dist/utils/storage-factory.js +118 -0
  389. package/dist/utils/storage-maintenance.d.ts +121 -0
  390. package/dist/utils/storage-maintenance.js +352 -0
  391. package/dist/utils/thread-lock.d.ts +26 -0
  392. package/dist/utils/thread-lock.js +109 -0
  393. package/dist/utils/token-estimator.d.ts +3 -0
  394. package/dist/utils/token-estimator.js +19 -0
  395. package/dist/utils/update-check.d.ts +151 -0
  396. package/dist/utils/update-check.js +430 -0
  397. package/dist/utils/wake-session.d.ts +44 -0
  398. package/dist/utils/wake-session.js +83 -0
  399. package/dist/voice/stt-registry.d.ts +67 -0
  400. package/dist/voice/stt-registry.js +144 -0
  401. package/dist/voice/transcribe.d.ts +10 -0
  402. package/dist/voice/transcribe.js +75 -0
  403. package/dist/workflows/register-primitives.d.ts +52 -0
  404. package/dist/workflows/register-primitives.js +40 -0
  405. package/dist/workflows/service.d.ts +64 -0
  406. package/dist/workflows/service.js +50 -0
  407. package/package.json +117 -0
@@ -0,0 +1,151 @@
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. Pre-release tags only matter against the
34
+ * matching release; two pre-releases of the same version compare equal.
35
+ */
36
+ export declare function isNewerVersion(current: string, latest: string): boolean;
37
+ /**
38
+ * Fetch the CHANGELOG.md for a specific published version from the npm CDN
39
+ * and extract a human-readable summary of changes.
40
+ * Returns null if the fetch fails or the changelog can't be parsed.
41
+ */
42
+ export declare function fetchChangelog(version: string): Promise<string | null>;
43
+ /**
44
+ * Extract the changelog section for a specific version and format it
45
+ * as a concise bullet list suitable for terminal display.
46
+ */
47
+ export declare function parseChangelog(markdown: string, version: string): string | null;
48
+ /** Result of attempting an auto-update: exit status plus captured stderr. */
49
+ export interface UpdateResult {
50
+ ok: boolean;
51
+ stderr?: string;
52
+ }
53
+ /**
54
+ * Run the appropriate global install command to update mastracode.
55
+ * Exit code 0 does not prove the running binary changed (the install may land
56
+ * in a location the PATH shim doesn't use) — verify with {@link locateOwnInstall}.
57
+ */
58
+ export declare function runUpdate(pm: PackageManager, targetVersion: string): Promise<UpdateResult>;
59
+ /**
60
+ * Find the installed mastracode package the running binary belongs to (walking
61
+ * up from `process.argv[1]`) and read its version fresh from disk. Returns
62
+ * null when it can't be determined, e.g. when running from source.
63
+ */
64
+ export declare function locateOwnInstall(): {
65
+ dir: string;
66
+ version: string | null;
67
+ } | null;
68
+ /**
69
+ * Result of an update attempt. `message` is a ready-made sentence; the other
70
+ * fields let callers lay the result out themselves.
71
+ */
72
+ export type UpdateOutcome = {
73
+ status: 'updated';
74
+ message: string;
75
+ /** The package manager or tool that installed the update. */
76
+ via: string;
77
+ } | {
78
+ status: 'unchanged';
79
+ message: string;
80
+ /** Command the user can run to update the install they're running. */
81
+ command: string;
82
+ /** Where the running install lives, when known. */
83
+ installDir?: string;
84
+ /** Version still on disk after the update ran, when the update ran at all. */
85
+ runningVersion?: string;
86
+ /** Tool that ran the update (when it ran but didn't change the running install). */
87
+ ranWith?: string;
88
+ /** Tool that owns the install when we only suggest its command (e.g. Homebrew). */
89
+ managedBy?: string;
90
+ } | {
91
+ status: 'failed';
92
+ message: string;
93
+ /** Command the user can run instead, when there is one. */
94
+ command?: string;
95
+ /** Why it failed: the tail of the package manager's stderr, or our own reason. */
96
+ details?: string;
97
+ };
98
+ /**
99
+ * Decide what to tell the user after {@link runUpdate}: `updated` when the
100
+ * on-disk version matches the target (or can't be determined), `unchanged`
101
+ * when the package manager succeeded but the running install didn't change,
102
+ * `failed` on error (with the package manager's stderr).
103
+ */
104
+ export declare function resolveUpdateOutcome(opts: {
105
+ pm: PackageManager;
106
+ targetVersion: string;
107
+ result: UpdateResult;
108
+ install: {
109
+ dir: string;
110
+ version: string | null;
111
+ } | null;
112
+ /** Overrides the suggested manual command, e.g. when the update was delegated to the owning tool. */
113
+ manualCommand?: string;
114
+ /** Tool that ran the update when it wasn't `pm`, e.g. vite-plus. */
115
+ via?: string;
116
+ }): UpdateOutcome;
117
+ /**
118
+ * What an update will do for the running install: run an install (with the
119
+ * tool and command it will use), or nothing, with the result to show instead.
120
+ */
121
+ export type UpdatePlan = {
122
+ willInstall: true;
123
+ /** The package manager or tool that will run the install. */
124
+ via: string;
125
+ /** The install command, as the user would type it. */
126
+ command: string;
127
+ exec: {
128
+ cmd: string;
129
+ args: string[];
130
+ };
131
+ } | {
132
+ willInstall: false;
133
+ outcome: Extract<UpdateOutcome, {
134
+ status: 'unchanged' | 'failed';
135
+ }>;
136
+ };
137
+ /**
138
+ * Decide how to update the running install, without changing anything:
139
+ * delegate to the tool that owns it when we recognize it, only suggest a
140
+ * command when that tool can't be run for the user (Homebrew) or `pm` doesn't
141
+ * manage it, otherwise run `pm`. {@link performUpdate} carries out this plan,
142
+ * so callers can show what will happen before it starts.
143
+ */
144
+ export declare function planUpdate(pm: PackageManager, targetVersion: string): Promise<UpdatePlan>;
145
+ /**
146
+ * Update mastracode following {@link planUpdate} (pass a plan already shown to
147
+ * the user, or let this make one), then verify the result against the version
148
+ * on disk.
149
+ */
150
+ export declare function performUpdate(pm: PackageManager, targetVersion: string, plan?: UpdatePlan): Promise<UpdateOutcome>;
151
+ //# sourceMappingURL=update-check.d.ts.map
@@ -0,0 +1,430 @@
1
+ import { dirname, join, resolve, sep } from "path";
2
+ import { readFileSync, realpathSync } from "fs";
3
+ import { execFile } from "child_process";
4
+ import { homedir } from "os";
5
+ import { fileURLToPath } from "url";
6
+ // 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 dir = dirname(fileURLToPath(import.meta.url));
90
+ const pkgPath = resolve(dir, "../../package.json");
91
+ return JSON.parse(readFileSync(pkgPath, "utf-8")).version;
92
+ }
93
+ /**
94
+ * Fetch the latest published version from npm.
95
+ * Returns null if the fetch fails (network error, timeout, etc.).
96
+ */
97
+ async function fetchLatestVersion() {
98
+ if (process.env.MASTRACODE_UPDATE_LATEST_VERSION) return process.env.MASTRACODE_UPDATE_LATEST_VERSION;
99
+ try {
100
+ const controller = new AbortController();
101
+ const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
102
+ const res = await fetch(NPM_REGISTRY_URL, { signal: controller.signal });
103
+ clearTimeout(timeout);
104
+ if (!res.ok) return null;
105
+ return (await res.json()).version ?? null;
106
+ } catch {
107
+ return null;
108
+ }
109
+ }
110
+ const isPrerelease = (v) => v.includes("-");
111
+ /**
112
+ * Simple semver comparison: returns true if `latest` is newer than `current`.
113
+ * Handles standard x.y.z versions. Pre-release tags only matter against the
114
+ * matching release; two pre-releases of the same version compare equal.
115
+ */
116
+ function isNewerVersion(current, latest) {
117
+ const parse = (v) => v.replace(/^v/, "").split("-")[0].split(".").map((s) => {
118
+ const n = Number(s);
119
+ return Number.isFinite(n) ? n : 0;
120
+ });
121
+ const [cMajor = 0, cMinor = 0, cPatch = 0] = parse(current);
122
+ const [lMajor = 0, lMinor = 0, lPatch = 0] = parse(latest);
123
+ if (lMajor !== cMajor) return lMajor > cMajor;
124
+ if (lMinor !== cMinor) return lMinor > cMinor;
125
+ if (lPatch !== cPatch) return lPatch > cPatch;
126
+ return isPrerelease(current) && !isPrerelease(latest);
127
+ }
128
+ /** Max entries to show in the changelog summary. */
129
+ const MAX_CHANGELOG_ENTRIES = 20;
130
+ /**
131
+ * Fetch the CHANGELOG.md for a specific published version from the npm CDN
132
+ * and extract a human-readable summary of changes.
133
+ * Returns null if the fetch fails or the changelog can't be parsed.
134
+ */
135
+ async function fetchChangelog(version) {
136
+ if (process.env.MASTRACODE_UPDATE_CHANGELOG) return process.env.MASTRACODE_UPDATE_CHANGELOG;
137
+ try {
138
+ const url = `https://unpkg.com/${PACKAGE_NAME}@${version}/CHANGELOG.md`;
139
+ const controller = new AbortController();
140
+ const timeout = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
141
+ const res = await fetch(url, { signal: controller.signal });
142
+ clearTimeout(timeout);
143
+ if (!res.ok) return null;
144
+ return parseChangelog(await res.text(), version);
145
+ } catch {
146
+ return null;
147
+ }
148
+ }
149
+ /**
150
+ * Extract the changelog section for a specific version and format it
151
+ * as a concise bullet list suitable for terminal display.
152
+ */
153
+ function parseChangelog(markdown, version) {
154
+ const versionHeader = `## ${version}`;
155
+ const startIdx = markdown.indexOf(versionHeader);
156
+ if (startIdx === -1) return null;
157
+ const afterHeader = startIdx + versionHeader.length;
158
+ const nextHeaderIdx = markdown.indexOf("\n## ", afterHeader);
159
+ const lines = (nextHeaderIdx === -1 ? markdown.slice(afterHeader) : markdown.slice(afterHeader, nextHeaderIdx)).split("\n");
160
+ const entries = [];
161
+ let skipIndented = false;
162
+ for (let i = 0; i < lines.length; i++) {
163
+ const raw = lines[i];
164
+ const trimmed = raw.trim();
165
+ if (!(raw === trimmed && trimmed.startsWith("- "))) {
166
+ if (skipIndented && /^\s+-\s/.test(raw)) continue;
167
+ skipIndented = false;
168
+ continue;
169
+ }
170
+ if (/^- Updated dependenc/i.test(trimmed)) {
171
+ skipIndented = true;
172
+ continue;
173
+ }
174
+ skipIndented = false;
175
+ let entry = trimmed.slice(2);
176
+ entry = entry.replace(/\[([^\]]+)\]\([^)]+\)/g, "$1");
177
+ entry = entry.replace(/\s*\(#\d+\)\s*/g, " ");
178
+ entry = entry.replace(/\s*\(`[a-f0-9]+`\)\s*/g, " ");
179
+ entry = entry.replace(/\.\s*$/, "");
180
+ entry = entry.trim();
181
+ if (entry) entries.push(entry);
182
+ if (entries.length >= MAX_CHANGELOG_ENTRIES) break;
183
+ }
184
+ if (entries.length === 0) return null;
185
+ return entries.map((e) => ` • ${e}`).join("\n");
186
+ }
187
+ /**
188
+ * Run the appropriate global install command to update mastracode.
189
+ * Exit code 0 does not prove the running binary changed (the install may land
190
+ * in a location the PATH shim doesn't use) — verify with {@link locateOwnInstall}.
191
+ */
192
+ function runUpdate(pm, targetVersion) {
193
+ return execUpdate(pm, buildInstallArgs(pm, targetVersion));
194
+ }
195
+ function execUpdate(cmd, args) {
196
+ return new Promise((resolve) => {
197
+ execFile(cmd, args, {
198
+ timeout: 6e4,
199
+ shell: USE_SHELL
200
+ }, (error, _stdout, stderr) => {
201
+ const captured = (stderr ?? "").trim();
202
+ if (error) resolve({
203
+ ok: false,
204
+ stderr: captured || error.message
205
+ });
206
+ else resolve({
207
+ ok: true,
208
+ stderr: captured || void 0
209
+ });
210
+ });
211
+ });
212
+ }
213
+ function buildInstallArgs(pm, version) {
214
+ const pkg = `${PACKAGE_NAME}@${version}`;
215
+ switch (pm) {
216
+ case "pnpm": return [
217
+ "add",
218
+ "-g",
219
+ pkg
220
+ ];
221
+ case "yarn": return [
222
+ "global",
223
+ "add",
224
+ pkg
225
+ ];
226
+ case "bun": return [
227
+ "add",
228
+ "-g",
229
+ pkg
230
+ ];
231
+ default: return [
232
+ "install",
233
+ "-g",
234
+ pkg
235
+ ];
236
+ }
237
+ }
238
+ function formatUpdaterError(stderr) {
239
+ if (!stderr) return null;
240
+ const lines = stderr.split("\n").map((line) => line.trimEnd()).filter((line) => line.trim().length > 0);
241
+ if (lines.length === 0) return null;
242
+ return lines.slice(-5).join("\n");
243
+ }
244
+ /**
245
+ * Find the installed mastracode package the running binary belongs to (walking
246
+ * up from `process.argv[1]`) and read its version fresh from disk. Returns
247
+ * null when it can't be determined, e.g. when running from source.
248
+ */
249
+ function locateOwnInstall() {
250
+ const entry = process.argv[1];
251
+ if (!entry) return null;
252
+ let dir;
253
+ try {
254
+ dir = dirname(realpathSync(entry));
255
+ } catch {
256
+ return null;
257
+ }
258
+ let previous = "";
259
+ while (dir && dir !== previous) {
260
+ try {
261
+ const pkg = JSON.parse(readFileSync(resolve(dir, "package.json"), "utf-8"));
262
+ if (pkg.name === PACKAGE_NAME) return {
263
+ dir,
264
+ version: typeof pkg.version === "string" ? pkg.version : null
265
+ };
266
+ } catch {}
267
+ previous = dir;
268
+ dir = dirname(dir);
269
+ }
270
+ return null;
271
+ }
272
+ /**
273
+ * Decide what to tell the user after {@link runUpdate}: `updated` when the
274
+ * on-disk version matches the target (or can't be determined), `unchanged`
275
+ * when the package manager succeeded but the running install didn't change,
276
+ * `failed` on error (with the package manager's stderr).
277
+ */
278
+ function resolveUpdateOutcome(opts) {
279
+ const { pm, targetVersion, result, install } = opts;
280
+ const cmd = opts.manualCommand ?? getInstallCommand(pm, targetVersion);
281
+ const via = opts.via ?? pm;
282
+ if (!result.ok) {
283
+ const details = formatUpdaterError(result.stderr) ?? void 0;
284
+ let message = `Auto-update failed. Run \`${cmd}\` manually.`;
285
+ if (details) message += `\n\n${details}`;
286
+ return {
287
+ status: "failed",
288
+ message,
289
+ command: cmd,
290
+ ...details ? { details } : {}
291
+ };
292
+ }
293
+ if (install?.version != null && install.version !== targetVersion) return {
294
+ status: "unchanged",
295
+ 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}\`.`,
296
+ command: cmd,
297
+ installDir: install.dir,
298
+ runningVersion: install.version,
299
+ ranWith: via
300
+ };
301
+ return {
302
+ status: "updated",
303
+ message: `Updated to v${targetVersion}. Please restart Mastra Code.`,
304
+ via
305
+ };
306
+ }
307
+ /** Global node_modules directory the package manager installs into, or null when unknown. */
308
+ function getGlobalRoot(pm) {
309
+ const args = pm === "yarn" ? ["global", "dir"] : ["root", "-g"];
310
+ return new Promise((res) => {
311
+ execFile(pm, args, {
312
+ timeout: 1e4,
313
+ shell: USE_SHELL
314
+ }, (error, stdout) => {
315
+ const out = (stdout ?? "").trim().split("\n").pop()?.trim();
316
+ if (error || !out) return res(null);
317
+ res(pm === "yarn" ? resolve(out, "node_modules") : out);
318
+ });
319
+ });
320
+ }
321
+ /**
322
+ * Whether updating via `pm` would touch the install the running binary uses.
323
+ * Fail-open: returns true when either side can't be determined, so the update
324
+ * proceeds and the post-install verification has the final word.
325
+ */
326
+ async function isOwnInstallManagedBy(pm, install) {
327
+ if (!install) return true;
328
+ const root = await getGlobalRoot(pm);
329
+ if (!root) return true;
330
+ try {
331
+ return realpathSync(resolve(root, PACKAGE_NAME)) === install.dir;
332
+ } catch {
333
+ return false;
334
+ }
335
+ }
336
+ function findInstallOwner(dir, version) {
337
+ if (dir.startsWith(join(homedir(), ".vite-plus") + sep)) return {
338
+ name: "vite-plus",
339
+ exec: {
340
+ cmd: "vp",
341
+ args: [
342
+ "install",
343
+ "-g",
344
+ `${PACKAGE_NAME}@${version}`
345
+ ]
346
+ },
347
+ command: `vp install -g ${PACKAGE_NAME}@${version}`
348
+ };
349
+ if (dir.split(sep).includes("Cellar")) return {
350
+ name: "Homebrew",
351
+ command: `brew upgrade ${PACKAGE_NAME}`
352
+ };
353
+ return null;
354
+ }
355
+ /**
356
+ * Decide how to update the running install, without changing anything:
357
+ * delegate to the tool that owns it when we recognize it, only suggest a
358
+ * command when that tool can't be run for the user (Homebrew) or `pm` doesn't
359
+ * manage it, otherwise run `pm`. {@link performUpdate} carries out this plan,
360
+ * so callers can show what will happen before it starts.
361
+ */
362
+ async function planUpdate(pm, targetVersion) {
363
+ if (!/^[\w.+-]+$/.test(targetVersion)) return {
364
+ willInstall: false,
365
+ outcome: {
366
+ status: "failed",
367
+ message: `Auto-update aborted: unexpected version "${targetVersion}".`,
368
+ details: `The npm registry returned an unexpected version: "${targetVersion}".`
369
+ }
370
+ };
371
+ const install = locateOwnInstall();
372
+ const owner = install ? findInstallOwner(install.dir, targetVersion) : null;
373
+ if (owner) {
374
+ if (!owner.exec) return {
375
+ willInstall: false,
376
+ outcome: {
377
+ status: "unchanged",
378
+ message: `Your Mastra Code install (at ${install.dir}) is managed by ${owner.name}. Update it with \`${owner.command}\`.`,
379
+ command: owner.command,
380
+ installDir: install.dir,
381
+ managedBy: owner.name
382
+ }
383
+ };
384
+ return {
385
+ willInstall: true,
386
+ via: owner.name,
387
+ command: owner.command,
388
+ exec: owner.exec
389
+ };
390
+ }
391
+ const command = getInstallCommand(pm, targetVersion);
392
+ if (!await isOwnInstallManagedBy(pm, install)) return {
393
+ willInstall: false,
394
+ outcome: {
395
+ status: "unchanged",
396
+ 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 \`${command}\`.`,
397
+ command,
398
+ installDir: install.dir
399
+ }
400
+ };
401
+ return {
402
+ willInstall: true,
403
+ via: pm,
404
+ command,
405
+ exec: {
406
+ cmd: pm,
407
+ args: buildInstallArgs(pm, targetVersion)
408
+ }
409
+ };
410
+ }
411
+ /**
412
+ * Update mastracode following {@link planUpdate} (pass a plan already shown to
413
+ * the user, or let this make one), then verify the result against the version
414
+ * on disk.
415
+ */
416
+ async function performUpdate(pm, targetVersion, plan) {
417
+ plan ??= await planUpdate(pm, targetVersion);
418
+ if (!plan.willInstall) return plan.outcome;
419
+ return resolveUpdateOutcome({
420
+ pm,
421
+ targetVersion,
422
+ result: await execUpdate(plan.exec.cmd, plan.exec.args),
423
+ install: locateOwnInstall(),
424
+ ...plan.via === pm ? {} : {
425
+ manualCommand: plan.command,
426
+ via: plan.via
427
+ }
428
+ });
429
+ }
430
+ export { detectPackageManager, fetchChangelog, fetchLatestVersion, getCurrentVersion, getInstallCommand, isNewerVersion, locateOwnInstall, parseChangelog, performUpdate, planUpdate, resolveUpdateOutcome, runUpdate };
@@ -0,0 +1,44 @@
1
+ import type { AgentController, Session } from '@mastra/core/agent-controller';
2
+ import type { LeaseProvider } from '@mastra/core/events';
3
+ /** A session here serves the thread's resource, but the thread belongs to another project. */
4
+ export declare const FOREIGN_THREAD: unique symbol;
5
+ /** The session a wake runs as, and the dispatch lease that covers the thread. */
6
+ export type WakeSession<TState> = {
7
+ session: Session<TState>;
8
+ /**
9
+ * The thread's scope (`threadScopeKey`) when it carries the session's whole
10
+ * scope: only the process holding that scope's dispatch lease delivers it.
11
+ * Unset for a thread with no scope, which the resource's lease covers.
12
+ */
13
+ scope?: string;
14
+ };
15
+ /** A stable key for a session's thread scope, or `undefined` when it has none. */
16
+ export declare function threadScopeKey(scope: Record<string, string>): string | undefined;
17
+ /**
18
+ * The session a wake for `threadId` should run as, or `FOREIGN_THREAD` when
19
+ * this process serves the resource but not the thread.
20
+ *
21
+ * A resource is not a project: processes in different directories can share
22
+ * one resource id (to share recall, say), and each then has a live session for
23
+ * it. Picking by resource alone runs the thread in whichever process asked,
24
+ * with that process's workspace, tools and cwd. The thread's scope tags (the
25
+ * ones `thread.create()` stamps, such as `projectPath`) say which session it
26
+ * belongs to. A thread with no scope tags, or with tags no session here
27
+ * contradicts, keeps going to the resource's session.
28
+ *
29
+ * A session that has the thread open always owns it. When the thread belongs to
30
+ * another project, that session delivers it under a lease for this one thread
31
+ * (`openThreadScope`), and the thread's own project yields it while another
32
+ * process holds that lease (`leases`), so only one process runs it and the
33
+ * project's other threads stay with the project.
34
+ */
35
+ export declare function findWakeSession<TState>(controller: Pick<AgentController<TState>, 'getSession'>, liveSessions: Iterable<Session<TState>>, { resourceId, threadId }: {
36
+ resourceId: string;
37
+ threadId: string;
38
+ }, leases?: Pick<LeaseProvider, 'getLeaseOwner'>): Promise<WakeSession<TState> | typeof FOREIGN_THREAD | undefined>;
39
+ /**
40
+ * The dispatch lease scopes a session needs: its own, plus a lease for its open
41
+ * thread alone when that thread belongs to another project (`findWakeSession`).
42
+ */
43
+ export declare function sessionLeaseScopes<TState>(session: Session<TState>): Promise<Array<string | undefined>>;
44
+ //# sourceMappingURL=wake-session.d.ts.map