@tianshu-ai/tianshu 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (917) hide show
  1. package/LICENSE +200 -0
  2. package/README.md +284 -0
  3. package/README.zh-CN.md +136 -0
  4. package/bin/tianshu.mjs +32 -0
  5. package/package.json +60 -0
  6. package/packages/plugin-sdk/dist/agent-loop.d.ts +96 -0
  7. package/packages/plugin-sdk/dist/agent-loop.d.ts.map +1 -0
  8. package/packages/plugin-sdk/dist/agent-loop.js +11 -0
  9. package/packages/plugin-sdk/dist/agent-loop.js.map +1 -0
  10. package/packages/plugin-sdk/dist/capabilities.d.ts +48 -0
  11. package/packages/plugin-sdk/dist/capabilities.d.ts.map +1 -0
  12. package/packages/plugin-sdk/dist/capabilities.js +61 -0
  13. package/packages/plugin-sdk/dist/capabilities.js.map +1 -0
  14. package/packages/plugin-sdk/dist/catalog.d.ts +60 -0
  15. package/packages/plugin-sdk/dist/catalog.d.ts.map +1 -0
  16. package/packages/plugin-sdk/dist/catalog.js +11 -0
  17. package/packages/plugin-sdk/dist/catalog.js.map +1 -0
  18. package/packages/plugin-sdk/dist/client.d.ts +171 -0
  19. package/packages/plugin-sdk/dist/client.d.ts.map +1 -0
  20. package/packages/plugin-sdk/dist/client.js +96 -0
  21. package/packages/plugin-sdk/dist/client.js.map +1 -0
  22. package/packages/plugin-sdk/dist/index.d.ts +9 -0
  23. package/packages/plugin-sdk/dist/index.d.ts.map +1 -0
  24. package/packages/plugin-sdk/dist/index.js +19 -0
  25. package/packages/plugin-sdk/dist/index.js.map +1 -0
  26. package/packages/plugin-sdk/dist/lsp.d.ts +32 -0
  27. package/packages/plugin-sdk/dist/lsp.d.ts.map +1 -0
  28. package/packages/plugin-sdk/dist/lsp.js +19 -0
  29. package/packages/plugin-sdk/dist/lsp.js.map +1 -0
  30. package/packages/plugin-sdk/dist/manifest.d.ts +423 -0
  31. package/packages/plugin-sdk/dist/manifest.d.ts.map +1 -0
  32. package/packages/plugin-sdk/dist/manifest.js +7 -0
  33. package/packages/plugin-sdk/dist/manifest.js.map +1 -0
  34. package/packages/plugin-sdk/dist/mcp-client.d.ts +74 -0
  35. package/packages/plugin-sdk/dist/mcp-client.d.ts.map +1 -0
  36. package/packages/plugin-sdk/dist/mcp-client.js +226 -0
  37. package/packages/plugin-sdk/dist/mcp-client.js.map +1 -0
  38. package/packages/plugin-sdk/dist/mcp-fetch.d.ts +10 -0
  39. package/packages/plugin-sdk/dist/mcp-fetch.d.ts.map +1 -0
  40. package/packages/plugin-sdk/dist/mcp-fetch.js +130 -0
  41. package/packages/plugin-sdk/dist/mcp-fetch.js.map +1 -0
  42. package/packages/plugin-sdk/dist/mcp-toolset.d.ts +128 -0
  43. package/packages/plugin-sdk/dist/mcp-toolset.d.ts.map +1 -0
  44. package/packages/plugin-sdk/dist/mcp-toolset.js +246 -0
  45. package/packages/plugin-sdk/dist/mcp-toolset.js.map +1 -0
  46. package/packages/plugin-sdk/dist/server.d.ts +486 -0
  47. package/packages/plugin-sdk/dist/server.d.ts.map +1 -0
  48. package/packages/plugin-sdk/dist/server.js +10 -0
  49. package/packages/plugin-sdk/dist/server.js.map +1 -0
  50. package/packages/plugin-sdk/dist/session-inbox.d.ts +56 -0
  51. package/packages/plugin-sdk/dist/session-inbox.d.ts.map +1 -0
  52. package/packages/plugin-sdk/dist/session-inbox.js +12 -0
  53. package/packages/plugin-sdk/dist/session-inbox.js.map +1 -0
  54. package/packages/plugin-sdk/package.json +36 -0
  55. package/packages/server/builtinConfig/plugins/README.md +1 -0
  56. package/packages/server/builtinConfig/plugins/files/manifest.json +100 -0
  57. package/packages/server/builtinConfig/plugins/files/skills/files-workspace-layout.md +29 -0
  58. package/packages/server/builtinConfig/plugins/microsandbox/manifest.json +177 -0
  59. package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-browser-howto.md +155 -0
  60. package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-build-use.md +201 -0
  61. package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-config.md +38 -0
  62. package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-exec-howto.md +144 -0
  63. package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-libreoffice.md +159 -0
  64. package/packages/server/builtinConfig/plugins/microsandbox/skills/microsandbox-main-orchestration.md +75 -0
  65. package/packages/server/builtinConfig/plugins/microsandbox/templates/README.md +26 -0
  66. package/packages/server/builtinConfig/plugins/microsandbox/templates/browser.yaml +105 -0
  67. package/packages/server/builtinConfig/plugins/microsandbox/templates/task-runner-with-browser.yaml +80 -0
  68. package/packages/server/builtinConfig/plugins/microsandbox/templates/task-runner.yaml +80 -0
  69. package/packages/server/builtinConfig/plugins/web-search/manifest.json +65 -0
  70. package/packages/server/builtinConfig/plugins/web-search/skills/web-search-howto.md +69 -0
  71. package/packages/server/builtinConfig/plugins/workboard/agent-seeds/echo-demo/agent.json +7 -0
  72. package/packages/server/builtinConfig/plugins/workboard/agent-seeds/llm-default/SOUL.md +53 -0
  73. package/packages/server/builtinConfig/plugins/workboard/agent-seeds/llm-default/agent.json +7 -0
  74. package/packages/server/builtinConfig/plugins/workboard/manifest.json +180 -0
  75. package/packages/server/builtinConfig/plugins/workboard/skills/large-input-large-output.md +185 -0
  76. package/packages/server/builtinConfig/plugins/workboard/skills/workboard-howto.md +166 -0
  77. package/packages/server/builtinConfig/plugins/workboard/skills/worker-creator.md +267 -0
  78. package/packages/server/builtinConfig/plugins/workboard/skills/worker-fleet.md +431 -0
  79. package/packages/server/dist/catalog.d.ts +52 -0
  80. package/packages/server/dist/catalog.d.ts.map +1 -0
  81. package/packages/server/dist/catalog.js +189 -0
  82. package/packages/server/dist/catalog.js.map +1 -0
  83. package/packages/server/dist/chat/active-harnesses.d.ts +34 -0
  84. package/packages/server/dist/chat/active-harnesses.d.ts.map +1 -0
  85. package/packages/server/dist/chat/active-harnesses.js +118 -0
  86. package/packages/server/dist/chat/active-harnesses.js.map +1 -0
  87. package/packages/server/dist/chat/agent-loop.d.ts +64 -0
  88. package/packages/server/dist/chat/agent-loop.d.ts.map +1 -0
  89. package/packages/server/dist/chat/agent-loop.js +597 -0
  90. package/packages/server/dist/chat/agent-loop.js.map +1 -0
  91. package/packages/server/dist/chat/agent-tool-adapter.d.ts +33 -0
  92. package/packages/server/dist/chat/agent-tool-adapter.d.ts.map +1 -0
  93. package/packages/server/dist/chat/agent-tool-adapter.js +260 -0
  94. package/packages/server/dist/chat/agent-tool-adapter.js.map +1 -0
  95. package/packages/server/dist/chat/compact.d.ts +52 -0
  96. package/packages/server/dist/chat/compact.d.ts.map +1 -0
  97. package/packages/server/dist/chat/compact.js +248 -0
  98. package/packages/server/dist/chat/compact.js.map +1 -0
  99. package/packages/server/dist/chat/dump-system-prompt.d.ts +17 -0
  100. package/packages/server/dist/chat/dump-system-prompt.d.ts.map +1 -0
  101. package/packages/server/dist/chat/dump-system-prompt.js +58 -0
  102. package/packages/server/dist/chat/dump-system-prompt.js.map +1 -0
  103. package/packages/server/dist/chat/handler.d.ts +186 -0
  104. package/packages/server/dist/chat/handler.d.ts.map +1 -0
  105. package/packages/server/dist/chat/handler.js +1248 -0
  106. package/packages/server/dist/chat/handler.js.map +1 -0
  107. package/packages/server/dist/chat/image-fit.d.ts +34 -0
  108. package/packages/server/dist/chat/image-fit.d.ts.map +1 -0
  109. package/packages/server/dist/chat/image-fit.js +157 -0
  110. package/packages/server/dist/chat/image-fit.js.map +1 -0
  111. package/packages/server/dist/chat/messages.d.ts +118 -0
  112. package/packages/server/dist/chat/messages.d.ts.map +1 -0
  113. package/packages/server/dist/chat/messages.js +341 -0
  114. package/packages/server/dist/chat/messages.js.map +1 -0
  115. package/packages/server/dist/chat/session-inbox.d.ts +114 -0
  116. package/packages/server/dist/chat/session-inbox.d.ts.map +1 -0
  117. package/packages/server/dist/chat/session-inbox.js +418 -0
  118. package/packages/server/dist/chat/session-inbox.js.map +1 -0
  119. package/packages/server/dist/chat/sqlite-session-repo.d.ts +26 -0
  120. package/packages/server/dist/chat/sqlite-session-repo.d.ts.map +1 -0
  121. package/packages/server/dist/chat/sqlite-session-repo.js +132 -0
  122. package/packages/server/dist/chat/sqlite-session-repo.js.map +1 -0
  123. package/packages/server/dist/chat/sqlite-session-storage.d.ts +83 -0
  124. package/packages/server/dist/chat/sqlite-session-storage.d.ts.map +1 -0
  125. package/packages/server/dist/chat/sqlite-session-storage.js +418 -0
  126. package/packages/server/dist/chat/sqlite-session-storage.js.map +1 -0
  127. package/packages/server/dist/chat/stub-execution-env.d.ts +3 -0
  128. package/packages/server/dist/chat/stub-execution-env.d.ts.map +1 -0
  129. package/packages/server/dist/chat/stub-execution-env.js +87 -0
  130. package/packages/server/dist/chat/stub-execution-env.js.map +1 -0
  131. package/packages/server/dist/chat/token-estimate.d.ts +11 -0
  132. package/packages/server/dist/chat/token-estimate.d.ts.map +1 -0
  133. package/packages/server/dist/chat/token-estimate.js +67 -0
  134. package/packages/server/dist/chat/token-estimate.js.map +1 -0
  135. package/packages/server/dist/chat/ws-protocol.d.ts +244 -0
  136. package/packages/server/dist/chat/ws-protocol.d.ts.map +1 -0
  137. package/packages/server/dist/chat/ws-protocol.js +193 -0
  138. package/packages/server/dist/chat/ws-protocol.js.map +1 -0
  139. package/packages/server/dist/cli.d.ts +9 -0
  140. package/packages/server/dist/cli.d.ts.map +1 -0
  141. package/packages/server/dist/cli.js +329 -0
  142. package/packages/server/dist/cli.js.map +1 -0
  143. package/packages/server/dist/core/agent-seeds.d.ts +25 -0
  144. package/packages/server/dist/core/agent-seeds.d.ts.map +1 -0
  145. package/packages/server/dist/core/agent-seeds.js +69 -0
  146. package/packages/server/dist/core/agent-seeds.js.map +1 -0
  147. package/packages/server/dist/core/config.d.ts +172 -0
  148. package/packages/server/dist/core/config.d.ts.map +1 -0
  149. package/packages/server/dist/core/config.js +155 -0
  150. package/packages/server/dist/core/config.js.map +1 -0
  151. package/packages/server/dist/core/db-pool.d.ts +32 -0
  152. package/packages/server/dist/core/db-pool.d.ts.map +1 -0
  153. package/packages/server/dist/core/db-pool.js +108 -0
  154. package/packages/server/dist/core/db-pool.js.map +1 -0
  155. package/packages/server/dist/core/dev-mode.d.ts +13 -0
  156. package/packages/server/dist/core/dev-mode.d.ts.map +1 -0
  157. package/packages/server/dist/core/dev-mode.js +51 -0
  158. package/packages/server/dist/core/dev-mode.js.map +1 -0
  159. package/packages/server/dist/core/global-ops.d.ts +54 -0
  160. package/packages/server/dist/core/global-ops.d.ts.map +1 -0
  161. package/packages/server/dist/core/global-ops.js +143 -0
  162. package/packages/server/dist/core/global-ops.js.map +1 -0
  163. package/packages/server/dist/core/identity-resolvers.d.ts +102 -0
  164. package/packages/server/dist/core/identity-resolvers.d.ts.map +1 -0
  165. package/packages/server/dist/core/identity-resolvers.js +176 -0
  166. package/packages/server/dist/core/identity-resolvers.js.map +1 -0
  167. package/packages/server/dist/core/index.d.ts +13 -0
  168. package/packages/server/dist/core/index.d.ts.map +1 -0
  169. package/packages/server/dist/core/index.js +18 -0
  170. package/packages/server/dist/core/index.js.map +1 -0
  171. package/packages/server/dist/core/llm.d.ts +45 -0
  172. package/packages/server/dist/core/llm.d.ts.map +1 -0
  173. package/packages/server/dist/core/llm.js +140 -0
  174. package/packages/server/dist/core/llm.js.map +1 -0
  175. package/packages/server/dist/core/mcp-manager.d.ts +47 -0
  176. package/packages/server/dist/core/mcp-manager.d.ts.map +1 -0
  177. package/packages/server/dist/core/mcp-manager.js +129 -0
  178. package/packages/server/dist/core/mcp-manager.js.map +1 -0
  179. package/packages/server/dist/core/middleware.d.ts +31 -0
  180. package/packages/server/dist/core/middleware.d.ts.map +1 -0
  181. package/packages/server/dist/core/middleware.js +102 -0
  182. package/packages/server/dist/core/middleware.js.map +1 -0
  183. package/packages/server/dist/core/migrations/001-initial.d.ts +4 -0
  184. package/packages/server/dist/core/migrations/001-initial.d.ts.map +1 -0
  185. package/packages/server/dist/core/migrations/001-initial.js +66 -0
  186. package/packages/server/dist/core/migrations/001-initial.js.map +1 -0
  187. package/packages/server/dist/core/migrations/002-task-dependencies.d.ts +4 -0
  188. package/packages/server/dist/core/migrations/002-task-dependencies.d.ts.map +1 -0
  189. package/packages/server/dist/core/migrations/002-task-dependencies.js +20 -0
  190. package/packages/server/dist/core/migrations/002-task-dependencies.js.map +1 -0
  191. package/packages/server/dist/core/migrations/003-session-tree.d.ts +4 -0
  192. package/packages/server/dist/core/migrations/003-session-tree.d.ts.map +1 -0
  193. package/packages/server/dist/core/migrations/003-session-tree.js +96 -0
  194. package/packages/server/dist/core/migrations/003-session-tree.js.map +1 -0
  195. package/packages/server/dist/core/migrations/003-worker-agents.d.ts +4 -0
  196. package/packages/server/dist/core/migrations/003-worker-agents.d.ts.map +1 -0
  197. package/packages/server/dist/core/migrations/003-worker-agents.js +65 -0
  198. package/packages/server/dist/core/migrations/003-worker-agents.js.map +1 -0
  199. package/packages/server/dist/core/migrations/004-rebuild-message-chain.d.ts +4 -0
  200. package/packages/server/dist/core/migrations/004-rebuild-message-chain.d.ts.map +1 -0
  201. package/packages/server/dist/core/migrations/004-rebuild-message-chain.js +52 -0
  202. package/packages/server/dist/core/migrations/004-rebuild-message-chain.js.map +1 -0
  203. package/packages/server/dist/core/migrations/005-task-status-rename.d.ts +4 -0
  204. package/packages/server/dist/core/migrations/005-task-status-rename.d.ts.map +1 -0
  205. package/packages/server/dist/core/migrations/005-task-status-rename.js +64 -0
  206. package/packages/server/dist/core/migrations/005-task-status-rename.js.map +1 -0
  207. package/packages/server/dist/core/migrations/006-task-labels.d.ts +4 -0
  208. package/packages/server/dist/core/migrations/006-task-labels.d.ts.map +1 -0
  209. package/packages/server/dist/core/migrations/006-task-labels.js +43 -0
  210. package/packages/server/dist/core/migrations/006-task-labels.js.map +1 -0
  211. package/packages/server/dist/core/migrations/007-session-inbox.d.ts +4 -0
  212. package/packages/server/dist/core/migrations/007-session-inbox.d.ts.map +1 -0
  213. package/packages/server/dist/core/migrations/007-session-inbox.js +67 -0
  214. package/packages/server/dist/core/migrations/007-session-inbox.js.map +1 -0
  215. package/packages/server/dist/core/migrations/008-task-intervention.d.ts +4 -0
  216. package/packages/server/dist/core/migrations/008-task-intervention.d.ts.map +1 -0
  217. package/packages/server/dist/core/migrations/008-task-intervention.js +60 -0
  218. package/packages/server/dist/core/migrations/008-task-intervention.js.map +1 -0
  219. package/packages/server/dist/core/migrations/index.d.ts +12 -0
  220. package/packages/server/dist/core/migrations/index.d.ts.map +1 -0
  221. package/packages/server/dist/core/migrations/index.js +58 -0
  222. package/packages/server/dist/core/migrations/index.js.map +1 -0
  223. package/packages/server/dist/core/paths.d.ts +53 -0
  224. package/packages/server/dist/core/paths.d.ts.map +1 -0
  225. package/packages/server/dist/core/paths.js +125 -0
  226. package/packages/server/dist/core/paths.js.map +1 -0
  227. package/packages/server/dist/core/plugins/builtin-loader.d.ts +56 -0
  228. package/packages/server/dist/core/plugins/builtin-loader.d.ts.map +1 -0
  229. package/packages/server/dist/core/plugins/builtin-loader.js +153 -0
  230. package/packages/server/dist/core/plugins/builtin-loader.js.map +1 -0
  231. package/packages/server/dist/core/plugins/discovery.d.ts +28 -0
  232. package/packages/server/dist/core/plugins/discovery.d.ts.map +1 -0
  233. package/packages/server/dist/core/plugins/discovery.js +97 -0
  234. package/packages/server/dist/core/plugins/discovery.js.map +1 -0
  235. package/packages/server/dist/core/plugins/index.d.ts +6 -0
  236. package/packages/server/dist/core/plugins/index.d.ts.map +1 -0
  237. package/packages/server/dist/core/plugins/index.js +6 -0
  238. package/packages/server/dist/core/plugins/index.js.map +1 -0
  239. package/packages/server/dist/core/plugins/manifest.d.ts +9 -0
  240. package/packages/server/dist/core/plugins/manifest.d.ts.map +1 -0
  241. package/packages/server/dist/core/plugins/manifest.js +584 -0
  242. package/packages/server/dist/core/plugins/manifest.js.map +1 -0
  243. package/packages/server/dist/core/plugins/registry.d.ts +269 -0
  244. package/packages/server/dist/core/plugins/registry.d.ts.map +1 -0
  245. package/packages/server/dist/core/plugins/registry.js +1003 -0
  246. package/packages/server/dist/core/plugins/registry.js.map +1 -0
  247. package/packages/server/dist/core/plugins/secrets.d.ts +46 -0
  248. package/packages/server/dist/core/plugins/secrets.d.ts.map +1 -0
  249. package/packages/server/dist/core/plugins/secrets.js +174 -0
  250. package/packages/server/dist/core/plugins/secrets.js.map +1 -0
  251. package/packages/server/dist/core/plugins/skills.d.ts +131 -0
  252. package/packages/server/dist/core/plugins/skills.d.ts.map +1 -0
  253. package/packages/server/dist/core/plugins/skills.js +389 -0
  254. package/packages/server/dist/core/plugins/skills.js.map +1 -0
  255. package/packages/server/dist/core/templates.d.ts +28 -0
  256. package/packages/server/dist/core/templates.d.ts.map +1 -0
  257. package/packages/server/dist/core/templates.js +103 -0
  258. package/packages/server/dist/core/templates.js.map +1 -0
  259. package/packages/server/dist/core/tenant-context.d.ts +18 -0
  260. package/packages/server/dist/core/tenant-context.d.ts.map +1 -0
  261. package/packages/server/dist/core/tenant-context.js +42 -0
  262. package/packages/server/dist/core/tenant-context.js.map +1 -0
  263. package/packages/server/dist/core/tenant-id.d.ts +8 -0
  264. package/packages/server/dist/core/tenant-id.d.ts.map +1 -0
  265. package/packages/server/dist/core/tenant-id.js +53 -0
  266. package/packages/server/dist/core/tenant-id.js.map +1 -0
  267. package/packages/server/dist/core/tenant-skills.d.ts +29 -0
  268. package/packages/server/dist/core/tenant-skills.d.ts.map +1 -0
  269. package/packages/server/dist/core/tenant-skills.js +77 -0
  270. package/packages/server/dist/core/tenant-skills.js.map +1 -0
  271. package/packages/server/dist/core/worker-agents-fs.d.ts +44 -0
  272. package/packages/server/dist/core/worker-agents-fs.d.ts.map +1 -0
  273. package/packages/server/dist/core/worker-agents-fs.js +86 -0
  274. package/packages/server/dist/core/worker-agents-fs.js.map +1 -0
  275. package/packages/server/dist/core/worker-agents.d.ts +77 -0
  276. package/packages/server/dist/core/worker-agents.d.ts.map +1 -0
  277. package/packages/server/dist/core/worker-agents.js +191 -0
  278. package/packages/server/dist/core/worker-agents.js.map +1 -0
  279. package/packages/server/dist/index.d.ts +2 -0
  280. package/packages/server/dist/index.d.ts.map +1 -0
  281. package/packages/server/dist/index.js +623 -0
  282. package/packages/server/dist/index.js.map +1 -0
  283. package/packages/server/dist/lsp/client.d.ts +53 -0
  284. package/packages/server/dist/lsp/client.d.ts.map +1 -0
  285. package/packages/server/dist/lsp/client.js +258 -0
  286. package/packages/server/dist/lsp/client.js.map +1 -0
  287. package/packages/server/dist/lsp/format.d.ts +13 -0
  288. package/packages/server/dist/lsp/format.d.ts.map +1 -0
  289. package/packages/server/dist/lsp/format.js +55 -0
  290. package/packages/server/dist/lsp/format.js.map +1 -0
  291. package/packages/server/dist/lsp/index.d.ts +20 -0
  292. package/packages/server/dist/lsp/index.d.ts.map +1 -0
  293. package/packages/server/dist/lsp/index.js +32 -0
  294. package/packages/server/dist/lsp/index.js.map +1 -0
  295. package/packages/server/dist/lsp/language-registry.d.ts +29 -0
  296. package/packages/server/dist/lsp/language-registry.d.ts.map +1 -0
  297. package/packages/server/dist/lsp/language-registry.js +62 -0
  298. package/packages/server/dist/lsp/language-registry.js.map +1 -0
  299. package/packages/server/dist/lsp/manager.d.ts +77 -0
  300. package/packages/server/dist/lsp/manager.d.ts.map +1 -0
  301. package/packages/server/dist/lsp/manager.js +300 -0
  302. package/packages/server/dist/lsp/manager.js.map +1 -0
  303. package/packages/server/dist/plugins-routes.d.ts +96 -0
  304. package/packages/server/dist/plugins-routes.d.ts.map +1 -0
  305. package/packages/server/dist/plugins-routes.js +627 -0
  306. package/packages/server/dist/plugins-routes.js.map +1 -0
  307. package/packages/server/dist/setup/checks/config.d.ts +9 -0
  308. package/packages/server/dist/setup/checks/config.d.ts.map +1 -0
  309. package/packages/server/dist/setup/checks/config.js +66 -0
  310. package/packages/server/dist/setup/checks/config.js.map +1 -0
  311. package/packages/server/dist/setup/checks/db.d.ts +6 -0
  312. package/packages/server/dist/setup/checks/db.d.ts.map +1 -0
  313. package/packages/server/dist/setup/checks/db.js +79 -0
  314. package/packages/server/dist/setup/checks/db.js.map +1 -0
  315. package/packages/server/dist/setup/checks/known-models.d.ts +18 -0
  316. package/packages/server/dist/setup/checks/known-models.d.ts.map +1 -0
  317. package/packages/server/dist/setup/checks/known-models.js +119 -0
  318. package/packages/server/dist/setup/checks/known-models.js.map +1 -0
  319. package/packages/server/dist/setup/checks/network.d.ts +11 -0
  320. package/packages/server/dist/setup/checks/network.d.ts.map +1 -0
  321. package/packages/server/dist/setup/checks/network.js +176 -0
  322. package/packages/server/dist/setup/checks/network.js.map +1 -0
  323. package/packages/server/dist/setup/checks/plugins.d.ts +9 -0
  324. package/packages/server/dist/setup/checks/plugins.d.ts.map +1 -0
  325. package/packages/server/dist/setup/checks/plugins.js +194 -0
  326. package/packages/server/dist/setup/checks/plugins.js.map +1 -0
  327. package/packages/server/dist/setup/checks/providers.d.ts +12 -0
  328. package/packages/server/dist/setup/checks/providers.d.ts.map +1 -0
  329. package/packages/server/dist/setup/checks/providers.js +368 -0
  330. package/packages/server/dist/setup/checks/providers.js.map +1 -0
  331. package/packages/server/dist/setup/checks/runtime.d.ts +3 -0
  332. package/packages/server/dist/setup/checks/runtime.d.ts.map +1 -0
  333. package/packages/server/dist/setup/checks/runtime.js +44 -0
  334. package/packages/server/dist/setup/checks/runtime.js.map +1 -0
  335. package/packages/server/dist/setup/checks/sandbox.d.ts +9 -0
  336. package/packages/server/dist/setup/checks/sandbox.d.ts.map +1 -0
  337. package/packages/server/dist/setup/checks/sandbox.js +110 -0
  338. package/packages/server/dist/setup/checks/sandbox.js.map +1 -0
  339. package/packages/server/dist/setup/checks/tenants.d.ts +9 -0
  340. package/packages/server/dist/setup/checks/tenants.d.ts.map +1 -0
  341. package/packages/server/dist/setup/checks/tenants.js +509 -0
  342. package/packages/server/dist/setup/checks/tenants.js.map +1 -0
  343. package/packages/server/dist/setup/cli-agent.d.ts +39 -0
  344. package/packages/server/dist/setup/cli-agent.d.ts.map +1 -0
  345. package/packages/server/dist/setup/cli-agent.js +1353 -0
  346. package/packages/server/dist/setup/cli-agent.js.map +1 -0
  347. package/packages/server/dist/setup/doctor.d.ts +32 -0
  348. package/packages/server/dist/setup/doctor.d.ts.map +1 -0
  349. package/packages/server/dist/setup/doctor.js +80 -0
  350. package/packages/server/dist/setup/doctor.js.map +1 -0
  351. package/packages/server/dist/setup/launchd.d.ts +107 -0
  352. package/packages/server/dist/setup/launchd.d.ts.map +1 -0
  353. package/packages/server/dist/setup/launchd.js +309 -0
  354. package/packages/server/dist/setup/launchd.js.map +1 -0
  355. package/packages/server/dist/setup/load-env.d.ts +21 -0
  356. package/packages/server/dist/setup/load-env.d.ts.map +1 -0
  357. package/packages/server/dist/setup/load-env.js +88 -0
  358. package/packages/server/dist/setup/load-env.js.map +1 -0
  359. package/packages/server/dist/setup/probe-default-model.d.ts +28 -0
  360. package/packages/server/dist/setup/probe-default-model.d.ts.map +1 -0
  361. package/packages/server/dist/setup/probe-default-model.js +133 -0
  362. package/packages/server/dist/setup/probe-default-model.js.map +1 -0
  363. package/packages/server/dist/setup/render.d.ts +28 -0
  364. package/packages/server/dist/setup/render.d.ts.map +1 -0
  365. package/packages/server/dist/setup/render.js +60 -0
  366. package/packages/server/dist/setup/render.js.map +1 -0
  367. package/packages/server/dist/setup/repo-root.d.ts +3 -0
  368. package/packages/server/dist/setup/repo-root.d.ts.map +1 -0
  369. package/packages/server/dist/setup/repo-root.js +43 -0
  370. package/packages/server/dist/setup/repo-root.js.map +1 -0
  371. package/packages/server/dist/setup/service.d.ts +60 -0
  372. package/packages/server/dist/setup/service.d.ts.map +1 -0
  373. package/packages/server/dist/setup/service.js +345 -0
  374. package/packages/server/dist/setup/service.js.map +1 -0
  375. package/packages/server/dist/setup/start-server.d.ts +23 -0
  376. package/packages/server/dist/setup/start-server.d.ts.map +1 -0
  377. package/packages/server/dist/setup/start-server.js +465 -0
  378. package/packages/server/dist/setup/start-server.js.map +1 -0
  379. package/packages/server/dist/setup/wizard.d.ts +59 -0
  380. package/packages/server/dist/setup/wizard.d.ts.map +1 -0
  381. package/packages/server/dist/setup/wizard.js +556 -0
  382. package/packages/server/dist/setup/wizard.js.map +1 -0
  383. package/packages/server/dist/tools/edit-file.d.ts +13 -0
  384. package/packages/server/dist/tools/edit-file.d.ts.map +1 -0
  385. package/packages/server/dist/tools/edit-file.js +90 -0
  386. package/packages/server/dist/tools/edit-file.js.map +1 -0
  387. package/packages/server/dist/tools/glob.d.ts +12 -0
  388. package/packages/server/dist/tools/glob.d.ts.map +1 -0
  389. package/packages/server/dist/tools/glob.js +82 -0
  390. package/packages/server/dist/tools/glob.js.map +1 -0
  391. package/packages/server/dist/tools/index.d.ts +82 -0
  392. package/packages/server/dist/tools/index.d.ts.map +1 -0
  393. package/packages/server/dist/tools/index.js +72 -0
  394. package/packages/server/dist/tools/index.js.map +1 -0
  395. package/packages/server/dist/tools/list-dir.d.ts +24 -0
  396. package/packages/server/dist/tools/list-dir.d.ts.map +1 -0
  397. package/packages/server/dist/tools/list-dir.js +99 -0
  398. package/packages/server/dist/tools/list-dir.js.map +1 -0
  399. package/packages/server/dist/tools/path-helper.d.ts +15 -0
  400. package/packages/server/dist/tools/path-helper.d.ts.map +1 -0
  401. package/packages/server/dist/tools/path-helper.js +72 -0
  402. package/packages/server/dist/tools/path-helper.js.map +1 -0
  403. package/packages/server/dist/tools/read-file.d.ts +17 -0
  404. package/packages/server/dist/tools/read-file.d.ts.map +1 -0
  405. package/packages/server/dist/tools/read-file.js +94 -0
  406. package/packages/server/dist/tools/read-file.js.map +1 -0
  407. package/packages/server/dist/tools/sandbox.d.ts +57 -0
  408. package/packages/server/dist/tools/sandbox.d.ts.map +1 -0
  409. package/packages/server/dist/tools/sandbox.js +291 -0
  410. package/packages/server/dist/tools/sandbox.js.map +1 -0
  411. package/packages/server/dist/tools/write-file.d.ts +12 -0
  412. package/packages/server/dist/tools/write-file.d.ts.map +1 -0
  413. package/packages/server/dist/tools/write-file.js +67 -0
  414. package/packages/server/dist/tools/write-file.js.map +1 -0
  415. package/packages/server/dist/worker-agents-routes.d.ts +11 -0
  416. package/packages/server/dist/worker-agents-routes.d.ts.map +1 -0
  417. package/packages/server/dist/worker-agents-routes.js +253 -0
  418. package/packages/server/dist/worker-agents-routes.js.map +1 -0
  419. package/packages/server/package.json +41 -0
  420. package/packages/web/dist/assets/index-DH-gJ09_.js +60 -0
  421. package/packages/web/dist/assets/index-xU4lYYqY.css +2 -0
  422. package/packages/web/dist/index.html +14 -0
  423. package/packages/web/package.json +36 -0
  424. package/plugins/README.md +64 -0
  425. package/plugins/files/dist/client.d.ts +5 -0
  426. package/plugins/files/dist/client.d.ts.map +1 -0
  427. package/plugins/files/dist/client.js +354 -0
  428. package/plugins/files/dist/client.js.map +1 -0
  429. package/plugins/files/dist/server.d.ts +32 -0
  430. package/plugins/files/dist/server.d.ts.map +1 -0
  431. package/plugins/files/dist/server.js +514 -0
  432. package/plugins/files/dist/server.js.map +1 -0
  433. package/plugins/files/dist/tools/edit-file.d.ts +29 -0
  434. package/plugins/files/dist/tools/edit-file.d.ts.map +1 -0
  435. package/plugins/files/dist/tools/edit-file.js +230 -0
  436. package/plugins/files/dist/tools/edit-file.js.map +1 -0
  437. package/plugins/files/dist/tools/edit-file.prompt.md +36 -0
  438. package/plugins/files/dist/tools/glob.d.ts +12 -0
  439. package/plugins/files/dist/tools/glob.d.ts.map +1 -0
  440. package/plugins/files/dist/tools/glob.js +84 -0
  441. package/plugins/files/dist/tools/glob.js.map +1 -0
  442. package/plugins/files/dist/tools/index.d.ts +13 -0
  443. package/plugins/files/dist/tools/index.d.ts.map +1 -0
  444. package/plugins/files/dist/tools/index.js +158 -0
  445. package/plugins/files/dist/tools/index.js.map +1 -0
  446. package/plugins/files/dist/tools/list-dir.d.ts +24 -0
  447. package/plugins/files/dist/tools/list-dir.d.ts.map +1 -0
  448. package/plugins/files/dist/tools/list-dir.js +104 -0
  449. package/plugins/files/dist/tools/list-dir.js.map +1 -0
  450. package/plugins/files/dist/tools/load-prompt.d.ts +5 -0
  451. package/plugins/files/dist/tools/load-prompt.d.ts.map +1 -0
  452. package/plugins/files/dist/tools/load-prompt.js +39 -0
  453. package/plugins/files/dist/tools/load-prompt.js.map +1 -0
  454. package/plugins/files/dist/tools/path-helper.d.ts +32 -0
  455. package/plugins/files/dist/tools/path-helper.d.ts.map +1 -0
  456. package/plugins/files/dist/tools/path-helper.js +113 -0
  457. package/plugins/files/dist/tools/path-helper.js.map +1 -0
  458. package/plugins/files/dist/tools/read-file.d.ts +17 -0
  459. package/plugins/files/dist/tools/read-file.d.ts.map +1 -0
  460. package/plugins/files/dist/tools/read-file.js +109 -0
  461. package/plugins/files/dist/tools/read-file.js.map +1 -0
  462. package/plugins/files/dist/tools/read-tracker.d.ts +28 -0
  463. package/plugins/files/dist/tools/read-tracker.d.ts.map +1 -0
  464. package/plugins/files/dist/tools/read-tracker.js +135 -0
  465. package/plugins/files/dist/tools/read-tracker.js.map +1 -0
  466. package/plugins/files/dist/tools/replacers.d.ts +27 -0
  467. package/plugins/files/dist/tools/replacers.d.ts.map +1 -0
  468. package/plugins/files/dist/tools/replacers.js +221 -0
  469. package/plugins/files/dist/tools/replacers.js.map +1 -0
  470. package/plugins/files/dist/tools/tenant-config-delete.d.ts +12 -0
  471. package/plugins/files/dist/tools/tenant-config-delete.d.ts.map +1 -0
  472. package/plugins/files/dist/tools/tenant-config-delete.js +70 -0
  473. package/plugins/files/dist/tools/tenant-config-delete.js.map +1 -0
  474. package/plugins/files/dist/tools/tenant-config-edit.d.ts +25 -0
  475. package/plugins/files/dist/tools/tenant-config-edit.d.ts.map +1 -0
  476. package/plugins/files/dist/tools/tenant-config-edit.js +142 -0
  477. package/plugins/files/dist/tools/tenant-config-edit.js.map +1 -0
  478. package/plugins/files/dist/tools/tenant-config-glob.d.ts +12 -0
  479. package/plugins/files/dist/tools/tenant-config-glob.d.ts.map +1 -0
  480. package/plugins/files/dist/tools/tenant-config-glob.js +64 -0
  481. package/plugins/files/dist/tools/tenant-config-glob.js.map +1 -0
  482. package/plugins/files/dist/tools/tenant-config-helper.d.ts +64 -0
  483. package/plugins/files/dist/tools/tenant-config-helper.d.ts.map +1 -0
  484. package/plugins/files/dist/tools/tenant-config-helper.js +162 -0
  485. package/plugins/files/dist/tools/tenant-config-helper.js.map +1 -0
  486. package/plugins/files/dist/tools/tenant-config-list.d.ts +20 -0
  487. package/plugins/files/dist/tools/tenant-config-list.d.ts.map +1 -0
  488. package/plugins/files/dist/tools/tenant-config-list.js +95 -0
  489. package/plugins/files/dist/tools/tenant-config-list.js.map +1 -0
  490. package/plugins/files/dist/tools/tenant-config-read.d.ts +17 -0
  491. package/plugins/files/dist/tools/tenant-config-read.d.ts.map +1 -0
  492. package/plugins/files/dist/tools/tenant-config-read.js +87 -0
  493. package/plugins/files/dist/tools/tenant-config-read.js.map +1 -0
  494. package/plugins/files/dist/tools/tenant-config-write.d.ts +14 -0
  495. package/plugins/files/dist/tools/tenant-config-write.d.ts.map +1 -0
  496. package/plugins/files/dist/tools/tenant-config-write.js +78 -0
  497. package/plugins/files/dist/tools/tenant-config-write.js.map +1 -0
  498. package/plugins/files/dist/tools/text-shape.d.ts +20 -0
  499. package/plugins/files/dist/tools/text-shape.d.ts.map +1 -0
  500. package/plugins/files/dist/tools/text-shape.js +57 -0
  501. package/plugins/files/dist/tools/text-shape.js.map +1 -0
  502. package/plugins/files/dist/tools/write-file.d.ts +12 -0
  503. package/plugins/files/dist/tools/write-file.d.ts.map +1 -0
  504. package/plugins/files/dist/tools/write-file.js +89 -0
  505. package/plugins/files/dist/tools/write-file.js.map +1 -0
  506. package/plugins/files/dist/tools/write-file.prompt.md +14 -0
  507. package/plugins/files/manifest.json +100 -0
  508. package/plugins/files/package.json +39 -0
  509. package/plugins/files/skills/files-workspace-layout.md +29 -0
  510. package/plugins/microsandbox/dist/admin/browser-routes.d.ts +41 -0
  511. package/plugins/microsandbox/dist/admin/browser-routes.d.ts.map +1 -0
  512. package/plugins/microsandbox/dist/admin/browser-routes.js +208 -0
  513. package/plugins/microsandbox/dist/admin/browser-routes.js.map +1 -0
  514. package/plugins/microsandbox/dist/admin/preview-exec.d.ts +38 -0
  515. package/plugins/microsandbox/dist/admin/preview-exec.d.ts.map +1 -0
  516. package/plugins/microsandbox/dist/admin/preview-exec.js +185 -0
  517. package/plugins/microsandbox/dist/admin/preview-exec.js.map +1 -0
  518. package/plugins/microsandbox/dist/admin/routes.d.ts +35 -0
  519. package/plugins/microsandbox/dist/admin/routes.d.ts.map +1 -0
  520. package/plugins/microsandbox/dist/admin/routes.js +728 -0
  521. package/plugins/microsandbox/dist/admin/routes.js.map +1 -0
  522. package/plugins/microsandbox/dist/admin/sandboxfile-io.d.ts +11 -0
  523. package/plugins/microsandbox/dist/admin/sandboxfile-io.d.ts.map +1 -0
  524. package/plugins/microsandbox/dist/admin/sandboxfile-io.js +72 -0
  525. package/plugins/microsandbox/dist/admin/sandboxfile-io.js.map +1 -0
  526. package/plugins/microsandbox/dist/admin/templates.d.ts +16 -0
  527. package/plugins/microsandbox/dist/admin/templates.d.ts.map +1 -0
  528. package/plugins/microsandbox/dist/admin/templates.js +66 -0
  529. package/plugins/microsandbox/dist/admin/templates.js.map +1 -0
  530. package/plugins/microsandbox/dist/admin.d.ts +5 -0
  531. package/plugins/microsandbox/dist/admin.d.ts.map +1 -0
  532. package/plugins/microsandbox/dist/admin.js +256 -0
  533. package/plugins/microsandbox/dist/admin.js.map +1 -0
  534. package/plugins/microsandbox/dist/build/builder.d.ts +69 -0
  535. package/plugins/microsandbox/dist/build/builder.d.ts.map +1 -0
  536. package/plugins/microsandbox/dist/build/builder.js +257 -0
  537. package/plugins/microsandbox/dist/build/builder.js.map +1 -0
  538. package/plugins/microsandbox/dist/build/metadata.d.ts +27 -0
  539. package/plugins/microsandbox/dist/build/metadata.d.ts.map +1 -0
  540. package/plugins/microsandbox/dist/build/metadata.js +55 -0
  541. package/plugins/microsandbox/dist/build/metadata.js.map +1 -0
  542. package/plugins/microsandbox/dist/build/pointer.d.ts +51 -0
  543. package/plugins/microsandbox/dist/build/pointer.d.ts.map +1 -0
  544. package/plugins/microsandbox/dist/build/pointer.js +130 -0
  545. package/plugins/microsandbox/dist/build/pointer.js.map +1 -0
  546. package/plugins/microsandbox/dist/build/sandboxfile.d.ts +15 -0
  547. package/plugins/microsandbox/dist/build/sandboxfile.d.ts.map +1 -0
  548. package/plugins/microsandbox/dist/build/sandboxfile.js +176 -0
  549. package/plugins/microsandbox/dist/build/sandboxfile.js.map +1 -0
  550. package/plugins/microsandbox/dist/client.d.ts +5 -0
  551. package/plugins/microsandbox/dist/client.d.ts.map +1 -0
  552. package/plugins/microsandbox/dist/client.js +941 -0
  553. package/plugins/microsandbox/dist/client.js.map +1 -0
  554. package/plugins/microsandbox/dist/runner/browser.d.ts +50 -0
  555. package/plugins/microsandbox/dist/runner/browser.d.ts.map +1 -0
  556. package/plugins/microsandbox/dist/runner/browser.js +142 -0
  557. package/plugins/microsandbox/dist/runner/browser.js.map +1 -0
  558. package/plugins/microsandbox/dist/runner/free-port.d.ts +6 -0
  559. package/plugins/microsandbox/dist/runner/free-port.d.ts.map +1 -0
  560. package/plugins/microsandbox/dist/runner/free-port.js +53 -0
  561. package/plugins/microsandbox/dist/runner/free-port.js.map +1 -0
  562. package/plugins/microsandbox/dist/runner/index.d.ts +28 -0
  563. package/plugins/microsandbox/dist/runner/index.d.ts.map +1 -0
  564. package/plugins/microsandbox/dist/runner/index.js +72 -0
  565. package/plugins/microsandbox/dist/runner/index.js.map +1 -0
  566. package/plugins/microsandbox/dist/runner/microsandbox.d.ts +64 -0
  567. package/plugins/microsandbox/dist/runner/microsandbox.d.ts.map +1 -0
  568. package/plugins/microsandbox/dist/runner/microsandbox.js +668 -0
  569. package/plugins/microsandbox/dist/runner/microsandbox.js.map +1 -0
  570. package/plugins/microsandbox/dist/runner/nullable.d.ts +36 -0
  571. package/plugins/microsandbox/dist/runner/nullable.d.ts.map +1 -0
  572. package/plugins/microsandbox/dist/runner/nullable.js +82 -0
  573. package/plugins/microsandbox/dist/runner/nullable.js.map +1 -0
  574. package/plugins/microsandbox/dist/runner/pool.d.ts +97 -0
  575. package/plugins/microsandbox/dist/runner/pool.d.ts.map +1 -0
  576. package/plugins/microsandbox/dist/runner/pool.js +494 -0
  577. package/plugins/microsandbox/dist/runner/pool.js.map +1 -0
  578. package/plugins/microsandbox/dist/runner/types.d.ts +33 -0
  579. package/plugins/microsandbox/dist/runner/types.d.ts.map +1 -0
  580. package/plugins/microsandbox/dist/runner/types.js +79 -0
  581. package/plugins/microsandbox/dist/runner/types.js.map +1 -0
  582. package/plugins/microsandbox/dist/server.d.ts +7 -0
  583. package/plugins/microsandbox/dist/server.d.ts.map +1 -0
  584. package/plugins/microsandbox/dist/server.js +276 -0
  585. package/plugins/microsandbox/dist/server.js.map +1 -0
  586. package/plugins/microsandbox/dist/tools/browser.d.ts +25 -0
  587. package/plugins/microsandbox/dist/tools/browser.d.ts.map +1 -0
  588. package/plugins/microsandbox/dist/tools/browser.js +78 -0
  589. package/plugins/microsandbox/dist/tools/browser.js.map +1 -0
  590. package/plugins/microsandbox/dist/tools/build.d.ts +5 -0
  591. package/plugins/microsandbox/dist/tools/build.d.ts.map +1 -0
  592. package/plugins/microsandbox/dist/tools/build.js +243 -0
  593. package/plugins/microsandbox/dist/tools/build.js.map +1 -0
  594. package/plugins/microsandbox/dist/tools/index.d.ts +9 -0
  595. package/plugins/microsandbox/dist/tools/index.d.ts.map +1 -0
  596. package/plugins/microsandbox/dist/tools/index.js +430 -0
  597. package/plugins/microsandbox/dist/tools/index.js.map +1 -0
  598. package/plugins/microsandbox/dist/tools/mcp-client.d.ts +63 -0
  599. package/plugins/microsandbox/dist/tools/mcp-client.d.ts.map +1 -0
  600. package/plugins/microsandbox/dist/tools/mcp-client.js +226 -0
  601. package/plugins/microsandbox/dist/tools/mcp-client.js.map +1 -0
  602. package/plugins/microsandbox/manifest.json +177 -0
  603. package/plugins/microsandbox/package.json +38 -0
  604. package/plugins/microsandbox/skills/microsandbox-browser-howto.md +155 -0
  605. package/plugins/microsandbox/skills/microsandbox-build-use.md +201 -0
  606. package/plugins/microsandbox/skills/microsandbox-config.md +38 -0
  607. package/plugins/microsandbox/skills/microsandbox-exec-howto.md +144 -0
  608. package/plugins/microsandbox/skills/microsandbox-libreoffice.md +159 -0
  609. package/plugins/microsandbox/templates/README.md +26 -0
  610. package/plugins/web-search/dist/server.d.ts +4 -0
  611. package/plugins/web-search/dist/server.d.ts.map +1 -0
  612. package/plugins/web-search/dist/server.js +73 -0
  613. package/plugins/web-search/dist/server.js.map +1 -0
  614. package/plugins/web-search/dist/tools/health.d.ts +31 -0
  615. package/plugins/web-search/dist/tools/health.d.ts.map +1 -0
  616. package/plugins/web-search/dist/tools/health.js +59 -0
  617. package/plugins/web-search/dist/tools/health.js.map +1 -0
  618. package/plugins/web-search/dist/tools/index.d.ts +3 -0
  619. package/plugins/web-search/dist/tools/index.d.ts.map +1 -0
  620. package/plugins/web-search/dist/tools/index.js +2 -0
  621. package/plugins/web-search/dist/tools/index.js.map +1 -0
  622. package/plugins/web-search/dist/tools/providers.d.ts +43 -0
  623. package/plugins/web-search/dist/tools/providers.d.ts.map +1 -0
  624. package/plugins/web-search/dist/tools/providers.js +140 -0
  625. package/plugins/web-search/dist/tools/providers.js.map +1 -0
  626. package/plugins/web-search/dist/tools/web-search.d.ts +15 -0
  627. package/plugins/web-search/dist/tools/web-search.d.ts.map +1 -0
  628. package/plugins/web-search/dist/tools/web-search.js +244 -0
  629. package/plugins/web-search/dist/tools/web-search.js.map +1 -0
  630. package/plugins/web-search/manifest.json +65 -0
  631. package/plugins/web-search/node_modules/@esbuild/darwin-arm64/README.md +3 -0
  632. package/plugins/web-search/node_modules/@esbuild/darwin-arm64/package.json +20 -0
  633. package/plugins/web-search/node_modules/@vitest/expect/LICENSE +21 -0
  634. package/plugins/web-search/node_modules/@vitest/expect/README.md +21 -0
  635. package/plugins/web-search/node_modules/@vitest/expect/dist/index.d.ts +808 -0
  636. package/plugins/web-search/node_modules/@vitest/expect/dist/index.js +1799 -0
  637. package/plugins/web-search/node_modules/@vitest/expect/package.json +46 -0
  638. package/plugins/web-search/node_modules/@vitest/mocker/LICENSE +21 -0
  639. package/plugins/web-search/node_modules/@vitest/mocker/README.md +5 -0
  640. package/plugins/web-search/node_modules/@vitest/mocker/dist/auto-register.d.ts +2 -0
  641. package/plugins/web-search/node_modules/@vitest/mocker/dist/auto-register.js +9 -0
  642. package/plugins/web-search/node_modules/@vitest/mocker/dist/browser.d.ts +53 -0
  643. package/plugins/web-search/node_modules/@vitest/mocker/dist/browser.js +91 -0
  644. package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-interceptor-native.js +15 -0
  645. package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-mocker.js +1602 -0
  646. package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-pathe.M-eThtNZ.js +174 -0
  647. package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-registry.js +182 -0
  648. package/plugins/web-search/node_modules/@vitest/mocker/dist/chunk-utils.js +16 -0
  649. package/plugins/web-search/node_modules/@vitest/mocker/dist/index.d.ts +21 -0
  650. package/plugins/web-search/node_modules/@vitest/mocker/dist/index.js +174 -0
  651. package/plugins/web-search/node_modules/@vitest/mocker/dist/mocker.d-Ce9_ySj5.d.ts +83 -0
  652. package/plugins/web-search/node_modules/@vitest/mocker/dist/node.d.ts +821 -0
  653. package/plugins/web-search/node_modules/@vitest/mocker/dist/node.js +1306 -0
  654. package/plugins/web-search/node_modules/@vitest/mocker/dist/redirect.d.ts +3 -0
  655. package/plugins/web-search/node_modules/@vitest/mocker/dist/redirect.js +75 -0
  656. package/plugins/web-search/node_modules/@vitest/mocker/dist/register.d.ts +9 -0
  657. package/plugins/web-search/node_modules/@vitest/mocker/dist/register.js +41 -0
  658. package/plugins/web-search/node_modules/@vitest/mocker/dist/registry.d-D765pazg.d.ts +87 -0
  659. package/plugins/web-search/node_modules/@vitest/mocker/dist/types.d-D_aRZRdy.d.ts +8 -0
  660. package/plugins/web-search/node_modules/@vitest/mocker/package.json +82 -0
  661. package/plugins/web-search/node_modules/@vitest/pretty-format/LICENSE +21 -0
  662. package/plugins/web-search/node_modules/@vitest/pretty-format/dist/index.d.ts +119 -0
  663. package/plugins/web-search/node_modules/@vitest/pretty-format/dist/index.js +1387 -0
  664. package/plugins/web-search/node_modules/@vitest/pretty-format/package.json +44 -0
  665. package/plugins/web-search/node_modules/@vitest/runner/LICENSE +21 -0
  666. package/plugins/web-search/node_modules/@vitest/runner/README.md +5 -0
  667. package/plugins/web-search/node_modules/@vitest/runner/dist/chunk-hooks.js +2254 -0
  668. package/plugins/web-search/node_modules/@vitest/runner/dist/index.d.ts +261 -0
  669. package/plugins/web-search/node_modules/@vitest/runner/dist/index.js +6 -0
  670. package/plugins/web-search/node_modules/@vitest/runner/dist/tasks.d-CkscK4of.d.ts +558 -0
  671. package/plugins/web-search/node_modules/@vitest/runner/dist/types.d.ts +163 -0
  672. package/plugins/web-search/node_modules/@vitest/runner/dist/types.js +1 -0
  673. package/plugins/web-search/node_modules/@vitest/runner/dist/utils.d.ts +47 -0
  674. package/plugins/web-search/node_modules/@vitest/runner/dist/utils.js +6 -0
  675. package/plugins/web-search/node_modules/@vitest/runner/package.json +49 -0
  676. package/plugins/web-search/node_modules/@vitest/snapshot/LICENSE +21 -0
  677. package/plugins/web-search/node_modules/@vitest/snapshot/README.md +84 -0
  678. package/plugins/web-search/node_modules/@vitest/snapshot/dist/environment.d-DHdQ1Csl.d.ts +22 -0
  679. package/plugins/web-search/node_modules/@vitest/snapshot/dist/environment.d.ts +16 -0
  680. package/plugins/web-search/node_modules/@vitest/snapshot/dist/environment.js +40 -0
  681. package/plugins/web-search/node_modules/@vitest/snapshot/dist/index.d.ts +137 -0
  682. package/plugins/web-search/node_modules/@vitest/snapshot/dist/index.js +2305 -0
  683. package/plugins/web-search/node_modules/@vitest/snapshot/dist/manager.d.ts +18 -0
  684. package/plugins/web-search/node_modules/@vitest/snapshot/dist/manager.js +73 -0
  685. package/plugins/web-search/node_modules/@vitest/snapshot/dist/rawSnapshot.d-lFsMJFUd.d.ts +61 -0
  686. package/plugins/web-search/node_modules/@vitest/snapshot/package.json +54 -0
  687. package/plugins/web-search/node_modules/@vitest/spy/LICENSE +21 -0
  688. package/plugins/web-search/node_modules/@vitest/spy/README.md +3 -0
  689. package/plugins/web-search/node_modules/@vitest/spy/dist/index.d.ts +356 -0
  690. package/plugins/web-search/node_modules/@vitest/spy/dist/index.js +191 -0
  691. package/plugins/web-search/node_modules/@vitest/spy/package.json +38 -0
  692. package/plugins/web-search/node_modules/@vitest/utils/LICENSE +21 -0
  693. package/plugins/web-search/node_modules/@vitest/utils/dist/chunk-_commonjsHelpers.js +158 -0
  694. package/plugins/web-search/node_modules/@vitest/utils/dist/diff.d.ts +104 -0
  695. package/plugins/web-search/node_modules/@vitest/utils/dist/diff.js +2185 -0
  696. package/plugins/web-search/node_modules/@vitest/utils/dist/error.d.ts +9 -0
  697. package/plugins/web-search/node_modules/@vitest/utils/dist/error.js +162 -0
  698. package/plugins/web-search/node_modules/@vitest/utils/dist/helpers.d.ts +56 -0
  699. package/plugins/web-search/node_modules/@vitest/utils/dist/helpers.js +251 -0
  700. package/plugins/web-search/node_modules/@vitest/utils/dist/index.d.ts +57 -0
  701. package/plugins/web-search/node_modules/@vitest/utils/dist/index.js +633 -0
  702. package/plugins/web-search/node_modules/@vitest/utils/dist/source-map.d.ts +139 -0
  703. package/plugins/web-search/node_modules/@vitest/utils/dist/source-map.js +996 -0
  704. package/plugins/web-search/node_modules/@vitest/utils/dist/types.d-BCElaP-c.d.ts +53 -0
  705. package/plugins/web-search/node_modules/@vitest/utils/dist/types.d.ts +53 -0
  706. package/plugins/web-search/node_modules/@vitest/utils/dist/types.js +1 -0
  707. package/plugins/web-search/node_modules/@vitest/utils/package.json +77 -0
  708. package/plugins/web-search/node_modules/chai/LICENSE +21 -0
  709. package/plugins/web-search/node_modules/chai/README.md +162 -0
  710. package/plugins/web-search/node_modules/chai/package.json +74 -0
  711. package/plugins/web-search/node_modules/esbuild/README.md +3 -0
  712. package/plugins/web-search/node_modules/esbuild/package.json +49 -0
  713. package/plugins/web-search/node_modules/std-env/README.md +118 -0
  714. package/plugins/web-search/node_modules/std-env/dist/index.cjs +1 -0
  715. package/plugins/web-search/node_modules/std-env/dist/index.d.cts +92 -0
  716. package/plugins/web-search/node_modules/std-env/dist/index.d.mts +92 -0
  717. package/plugins/web-search/node_modules/std-env/dist/index.d.ts +92 -0
  718. package/plugins/web-search/node_modules/std-env/dist/index.mjs +1 -0
  719. package/plugins/web-search/node_modules/std-env/package.json +46 -0
  720. package/plugins/web-search/node_modules/tinyexec/LICENSE +21 -0
  721. package/plugins/web-search/node_modules/tinyexec/README.md +256 -0
  722. package/plugins/web-search/node_modules/tinyexec/dist/main.cjs +575 -0
  723. package/plugins/web-search/node_modules/tinyexec/dist/main.d.cts +70 -0
  724. package/plugins/web-search/node_modules/tinyexec/dist/main.d.ts +70 -0
  725. package/plugins/web-search/node_modules/tinyexec/dist/main.js +578 -0
  726. package/plugins/web-search/node_modules/tinyexec/package.json +66 -0
  727. package/plugins/web-search/node_modules/tinyrainbow/README.md +28 -0
  728. package/plugins/web-search/node_modules/tinyrainbow/dist/browser.d.ts +8 -0
  729. package/plugins/web-search/node_modules/tinyrainbow/dist/browser.js +20 -0
  730. package/plugins/web-search/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +90 -0
  731. package/plugins/web-search/node_modules/tinyrainbow/dist/index-8b61d5bc.d.ts +59 -0
  732. package/plugins/web-search/node_modules/tinyrainbow/dist/node.d.ts +8 -0
  733. package/plugins/web-search/node_modules/tinyrainbow/dist/node.js +22 -0
  734. package/plugins/web-search/node_modules/tinyrainbow/package.json +37 -0
  735. package/plugins/web-search/node_modules/typescript/README.md +50 -0
  736. package/plugins/web-search/node_modules/typescript/package.json +120 -0
  737. package/plugins/web-search/node_modules/vite/README.md +20 -0
  738. package/plugins/web-search/node_modules/vite/dist/client/client.mjs +1106 -0
  739. package/plugins/web-search/node_modules/vite/dist/client/env.mjs +19 -0
  740. package/plugins/web-search/node_modules/vite/dist/node/chunks/build.js +4 -0
  741. package/plugins/web-search/node_modules/vite/dist/node/chunks/build2.js +5538 -0
  742. package/plugins/web-search/node_modules/vite/dist/node/chunks/chunk.js +48 -0
  743. package/plugins/web-search/node_modules/vite/dist/node/chunks/config.js +36065 -0
  744. package/plugins/web-search/node_modules/vite/dist/node/chunks/config2.js +4 -0
  745. package/plugins/web-search/node_modules/vite/dist/node/chunks/dist.js +6758 -0
  746. package/plugins/web-search/node_modules/vite/dist/node/chunks/lib.js +377 -0
  747. package/plugins/web-search/node_modules/vite/dist/node/chunks/logger.js +329 -0
  748. package/plugins/web-search/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +96 -0
  749. package/plugins/web-search/node_modules/vite/dist/node/chunks/optimizer.js +4 -0
  750. package/plugins/web-search/node_modules/vite/dist/node/chunks/postcss-import.js +479 -0
  751. package/plugins/web-search/node_modules/vite/dist/node/chunks/preview.js +4 -0
  752. package/plugins/web-search/node_modules/vite/dist/node/chunks/server.js +4 -0
  753. package/plugins/web-search/node_modules/vite/dist/node/cli.js +698 -0
  754. package/plugins/web-search/node_modules/vite/dist/node/index.d.ts +3717 -0
  755. package/plugins/web-search/node_modules/vite/dist/node/index.js +30 -0
  756. package/plugins/web-search/node_modules/vite/dist/node/module-runner.d.ts +311 -0
  757. package/plugins/web-search/node_modules/vite/dist/node/module-runner.js +1160 -0
  758. package/plugins/web-search/node_modules/vite/package.json +199 -0
  759. package/plugins/web-search/node_modules/vite/types/package.json +4 -0
  760. package/plugins/web-search/node_modules/vitest/README.md +7 -0
  761. package/plugins/web-search/node_modules/vitest/dist/browser.d.ts +34 -0
  762. package/plugins/web-search/node_modules/vitest/dist/browser.js +8 -0
  763. package/plugins/web-search/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js +7 -0
  764. package/plugins/web-search/node_modules/vitest/dist/chunks/base.DfmxU-tU.js +38 -0
  765. package/plugins/web-search/node_modules/vitest/dist/chunks/benchmark.CYdenmiT.js +37 -0
  766. package/plugins/web-search/node_modules/vitest/dist/chunks/benchmark.d.BwvBVTda.d.ts +24 -0
  767. package/plugins/web-search/node_modules/vitest/dist/chunks/cac.0BJqEUeA.js +1469 -0
  768. package/plugins/web-search/node_modules/vitest/dist/chunks/cli-api.DWGBtMmz.js +10660 -0
  769. package/plugins/web-search/node_modules/vitest/dist/chunks/config.d.BKdhh7Zx.d.ts +224 -0
  770. package/plugins/web-search/node_modules/vitest/dist/chunks/console.CtFJOzRO.js +153 -0
  771. package/plugins/web-search/node_modules/vitest/dist/chunks/constants.DnKduX2e.js +44 -0
  772. package/plugins/web-search/node_modules/vitest/dist/chunks/coverage.DVF1vEu8.js +25 -0
  773. package/plugins/web-search/node_modules/vitest/dist/chunks/coverage.DfSpMS-b.js +4350 -0
  774. package/plugins/web-search/node_modules/vitest/dist/chunks/coverage.d.S9RMNXIe.d.ts +35 -0
  775. package/plugins/web-search/node_modules/vitest/dist/chunks/creator.GK6I-cL4.js +640 -0
  776. package/plugins/web-search/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js +73 -0
  777. package/plugins/web-search/node_modules/vitest/dist/chunks/defaults.B7q_naMc.js +115 -0
  778. package/plugins/web-search/node_modules/vitest/dist/chunks/env.D4Lgay0q.js +8 -0
  779. package/plugins/web-search/node_modules/vitest/dist/chunks/environment.d.cL3nLXbE.d.ts +119 -0
  780. package/plugins/web-search/node_modules/vitest/dist/chunks/execute.B7h3T_Hc.js +708 -0
  781. package/plugins/web-search/node_modules/vitest/dist/chunks/git.BVQ8w_Sw.js +72 -0
  782. package/plugins/web-search/node_modules/vitest/dist/chunks/global.d.MAmajcmJ.d.ts +136 -0
  783. package/plugins/web-search/node_modules/vitest/dist/chunks/globals.DEHgCU4V.js +26 -0
  784. package/plugins/web-search/node_modules/vitest/dist/chunks/index.B521nVV-.js +157 -0
  785. package/plugins/web-search/node_modules/vitest/dist/chunks/index.BCWujgDG.js +231 -0
  786. package/plugins/web-search/node_modules/vitest/dist/chunks/index.CdQS2e2Q.js +37 -0
  787. package/plugins/web-search/node_modules/vitest/dist/chunks/index.CmSc2RE5.js +587 -0
  788. package/plugins/web-search/node_modules/vitest/dist/chunks/index.CwejwG0H.js +105 -0
  789. package/plugins/web-search/node_modules/vitest/dist/chunks/index.D3XRDfWc.js +213 -0
  790. package/plugins/web-search/node_modules/vitest/dist/chunks/index.VByaPkjc.js +2183 -0
  791. package/plugins/web-search/node_modules/vitest/dist/chunks/index.X0nbfr6-.js +6584 -0
  792. package/plugins/web-search/node_modules/vitest/dist/chunks/inspector.C914Efll.js +57 -0
  793. package/plugins/web-search/node_modules/vitest/dist/chunks/mocker.d.BE_2ls6u.d.ts +17 -0
  794. package/plugins/web-search/node_modules/vitest/dist/chunks/node.fjCdwEIl.js +15 -0
  795. package/plugins/web-search/node_modules/vitest/dist/chunks/reporters.d.BuRON0I0.d.ts +3168 -0
  796. package/plugins/web-search/node_modules/vitest/dist/chunks/rpc.-pEldfrD.js +83 -0
  797. package/plugins/web-search/node_modules/vitest/dist/chunks/runBaseTests.9Ij9_de-.js +129 -0
  798. package/plugins/web-search/node_modules/vitest/dist/chunks/setup-common.Dd054P77.js +60 -0
  799. package/plugins/web-search/node_modules/vitest/dist/chunks/suite.d.FvehnV49.d.ts +10 -0
  800. package/plugins/web-search/node_modules/vitest/dist/chunks/typechecker.DRKU1-1g.js +874 -0
  801. package/plugins/web-search/node_modules/vitest/dist/chunks/utils.CAioKnHs.js +61 -0
  802. package/plugins/web-search/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +65 -0
  803. package/plugins/web-search/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +4015 -0
  804. package/plugins/web-search/node_modules/vitest/dist/chunks/vite.d.BnOPPc46.d.ts +25 -0
  805. package/plugins/web-search/node_modules/vitest/dist/chunks/vm.BThCzidc.js +756 -0
  806. package/plugins/web-search/node_modules/vitest/dist/chunks/worker.d.CUgIPz9V.d.ts +176 -0
  807. package/plugins/web-search/node_modules/vitest/dist/chunks/worker.d.uzWsCv9X.d.ts +8 -0
  808. package/plugins/web-search/node_modules/vitest/dist/cli.js +27 -0
  809. package/plugins/web-search/node_modules/vitest/dist/config.cjs +148 -0
  810. package/plugins/web-search/node_modules/vitest/dist/config.d.ts +100 -0
  811. package/plugins/web-search/node_modules/vitest/dist/config.js +21 -0
  812. package/plugins/web-search/node_modules/vitest/dist/coverage.d.ts +108 -0
  813. package/plugins/web-search/node_modules/vitest/dist/coverage.js +34 -0
  814. package/plugins/web-search/node_modules/vitest/dist/environments.d.ts +26 -0
  815. package/plugins/web-search/node_modules/vitest/dist/environments.js +2 -0
  816. package/plugins/web-search/node_modules/vitest/dist/execute.d.ts +150 -0
  817. package/plugins/web-search/node_modules/vitest/dist/execute.js +13 -0
  818. package/plugins/web-search/node_modules/vitest/dist/index.d.ts +651 -0
  819. package/plugins/web-search/node_modules/vitest/dist/index.js +18 -0
  820. package/plugins/web-search/node_modules/vitest/dist/mocker.d.ts +1 -0
  821. package/plugins/web-search/node_modules/vitest/dist/mocker.js +1 -0
  822. package/plugins/web-search/node_modules/vitest/dist/node.d.ts +158 -0
  823. package/plugins/web-search/node_modules/vitest/dist/node.js +105 -0
  824. package/plugins/web-search/node_modules/vitest/dist/path.js +7 -0
  825. package/plugins/web-search/node_modules/vitest/dist/reporters.d.ts +25 -0
  826. package/plugins/web-search/node_modules/vitest/dist/reporters.js +23 -0
  827. package/plugins/web-search/node_modules/vitest/dist/runners.d.ts +46 -0
  828. package/plugins/web-search/node_modules/vitest/dist/runners.js +235 -0
  829. package/plugins/web-search/node_modules/vitest/dist/snapshot.d.ts +9 -0
  830. package/plugins/web-search/node_modules/vitest/dist/snapshot.js +4 -0
  831. package/plugins/web-search/node_modules/vitest/dist/spy.js +1 -0
  832. package/plugins/web-search/node_modules/vitest/dist/suite.d.ts +5 -0
  833. package/plugins/web-search/node_modules/vitest/dist/suite.js +5 -0
  834. package/plugins/web-search/node_modules/vitest/dist/worker.js +124 -0
  835. package/plugins/web-search/node_modules/vitest/dist/workers/forks.js +43 -0
  836. package/plugins/web-search/node_modules/vitest/dist/workers/runVmTests.js +90 -0
  837. package/plugins/web-search/node_modules/vitest/dist/workers/threads.js +31 -0
  838. package/plugins/web-search/node_modules/vitest/dist/workers/vmForks.js +47 -0
  839. package/plugins/web-search/node_modules/vitest/dist/workers/vmThreads.js +37 -0
  840. package/plugins/web-search/node_modules/vitest/dist/workers.d.ts +40 -0
  841. package/plugins/web-search/node_modules/vitest/dist/workers.js +30 -0
  842. package/plugins/web-search/node_modules/vitest/package.json +207 -0
  843. package/plugins/web-search/package.json +30 -0
  844. package/plugins/web-search/skills/web-search-howto.md +69 -0
  845. package/plugins/workboard/agent-seeds/echo-demo/agent.json +7 -0
  846. package/plugins/workboard/agent-seeds/llm-default/SOUL.md +53 -0
  847. package/plugins/workboard/agent-seeds/llm-default/agent.json +7 -0
  848. package/plugins/workboard/dist/client.d.ts +5 -0
  849. package/plugins/workboard/dist/client.d.ts.map +1 -0
  850. package/plugins/workboard/dist/client.js +895 -0
  851. package/plugins/workboard/dist/client.js.map +1 -0
  852. package/plugins/workboard/dist/db/agents.d.ts +100 -0
  853. package/plugins/workboard/dist/db/agents.d.ts.map +1 -0
  854. package/plugins/workboard/dist/db/agents.js +280 -0
  855. package/plugins/workboard/dist/db/agents.js.map +1 -0
  856. package/plugins/workboard/dist/db/schema.d.ts +3 -0
  857. package/plugins/workboard/dist/db/schema.d.ts.map +1 -0
  858. package/plugins/workboard/dist/db/schema.js +31 -0
  859. package/plugins/workboard/dist/db/schema.js.map +1 -0
  860. package/plugins/workboard/dist/db/session-history.d.ts +28 -0
  861. package/plugins/workboard/dist/db/session-history.d.ts.map +1 -0
  862. package/plugins/workboard/dist/db/session-history.js +224 -0
  863. package/plugins/workboard/dist/db/session-history.js.map +1 -0
  864. package/plugins/workboard/dist/db/tasks.d.ts +260 -0
  865. package/plugins/workboard/dist/db/tasks.d.ts.map +1 -0
  866. package/plugins/workboard/dist/db/tasks.js +451 -0
  867. package/plugins/workboard/dist/db/tasks.js.map +1 -0
  868. package/plugins/workboard/dist/db/worker-agents.d.ts +16 -0
  869. package/plugins/workboard/dist/db/worker-agents.d.ts.map +1 -0
  870. package/plugins/workboard/dist/db/worker-agents.js +62 -0
  871. package/plugins/workboard/dist/db/worker-agents.js.map +1 -0
  872. package/plugins/workboard/dist/effective-skills.d.ts +13 -0
  873. package/plugins/workboard/dist/effective-skills.d.ts.map +1 -0
  874. package/plugins/workboard/dist/effective-skills.js +126 -0
  875. package/plugins/workboard/dist/effective-skills.js.map +1 -0
  876. package/plugins/workboard/dist/fs-worker-agents.d.ts +35 -0
  877. package/plugins/workboard/dist/fs-worker-agents.d.ts.map +1 -0
  878. package/plugins/workboard/dist/fs-worker-agents.js +199 -0
  879. package/plugins/workboard/dist/fs-worker-agents.js.map +1 -0
  880. package/plugins/workboard/dist/migrate-worker-agents.d.ts +11 -0
  881. package/plugins/workboard/dist/migrate-worker-agents.d.ts.map +1 -0
  882. package/plugins/workboard/dist/migrate-worker-agents.js +89 -0
  883. package/plugins/workboard/dist/migrate-worker-agents.js.map +1 -0
  884. package/plugins/workboard/dist/routes/handlers.d.ts +106 -0
  885. package/plugins/workboard/dist/routes/handlers.d.ts.map +1 -0
  886. package/plugins/workboard/dist/routes/handlers.js +668 -0
  887. package/plugins/workboard/dist/routes/handlers.js.map +1 -0
  888. package/plugins/workboard/dist/server.d.ts +6 -0
  889. package/plugins/workboard/dist/server.d.ts.map +1 -0
  890. package/plugins/workboard/dist/server.js +368 -0
  891. package/plugins/workboard/dist/server.js.map +1 -0
  892. package/plugins/workboard/dist/tools/index.d.ts +70 -0
  893. package/plugins/workboard/dist/tools/index.d.ts.map +1 -0
  894. package/plugins/workboard/dist/tools/index.js +963 -0
  895. package/plugins/workboard/dist/tools/index.js.map +1 -0
  896. package/plugins/workboard/dist/types.d.ts +27 -0
  897. package/plugins/workboard/dist/types.d.ts.map +1 -0
  898. package/plugins/workboard/dist/types.js +16 -0
  899. package/plugins/workboard/dist/types.js.map +1 -0
  900. package/plugins/workboard/dist/worker/pool.d.ts +220 -0
  901. package/plugins/workboard/dist/worker/pool.d.ts.map +1 -0
  902. package/plugins/workboard/dist/worker/pool.js +866 -0
  903. package/plugins/workboard/dist/worker/pool.js.map +1 -0
  904. package/plugins/workboard/dist/worker/tool-policy.d.ts +27 -0
  905. package/plugins/workboard/dist/worker/tool-policy.d.ts.map +1 -0
  906. package/plugins/workboard/dist/worker/tool-policy.js +76 -0
  907. package/plugins/workboard/dist/worker/tool-policy.js.map +1 -0
  908. package/plugins/workboard/dist/worker-agents-page.d.ts +4 -0
  909. package/plugins/workboard/dist/worker-agents-page.d.ts.map +1 -0
  910. package/plugins/workboard/dist/worker-agents-page.js +193 -0
  911. package/plugins/workboard/dist/worker-agents-page.js.map +1 -0
  912. package/plugins/workboard/manifest.json +180 -0
  913. package/plugins/workboard/package.json +37 -0
  914. package/plugins/workboard/skills/large-input-large-output.md +185 -0
  915. package/plugins/workboard/skills/workboard-howto.md +166 -0
  916. package/plugins/workboard/skills/worker-creator.md +267 -0
  917. package/plugins/workboard/skills/worker-fleet.md +431 -0
@@ -0,0 +1,2254 @@
1
+ import { isObject, createDefer, toArray, isNegativeNaN, format, objectAttr, objDisplay, getSafeTimers, shuffle, assertTypes } from '@vitest/utils';
2
+ import { parseSingleStack } from '@vitest/utils/source-map';
3
+ import { processError } from '@vitest/utils/error';
4
+ import { stripLiteral } from 'strip-literal';
5
+ import { relative } from 'pathe';
6
+
7
+ class PendingError extends Error {
8
+ code = "VITEST_PENDING";
9
+ taskId;
10
+ constructor(message, task, note) {
11
+ super(message);
12
+ this.message = message;
13
+ this.note = note;
14
+ this.taskId = task.id;
15
+ }
16
+ }
17
+ class TestRunAbortError extends Error {
18
+ name = "TestRunAbortError";
19
+ reason;
20
+ constructor(message, reason) {
21
+ super(message);
22
+ this.reason = reason;
23
+ }
24
+ }
25
+
26
+ // use WeakMap here to make the Test and Suite object serializable
27
+ const fnMap = new WeakMap();
28
+ const testFixtureMap = new WeakMap();
29
+ const hooksMap = new WeakMap();
30
+ function setFn(key, fn) {
31
+ fnMap.set(key, fn);
32
+ }
33
+ function getFn(key) {
34
+ return fnMap.get(key);
35
+ }
36
+ function setTestFixture(key, fixture) {
37
+ testFixtureMap.set(key, fixture);
38
+ }
39
+ function getTestFixture(key) {
40
+ return testFixtureMap.get(key);
41
+ }
42
+ function setHooks(key, hooks) {
43
+ hooksMap.set(key, hooks);
44
+ }
45
+ function getHooks(key) {
46
+ return hooksMap.get(key);
47
+ }
48
+
49
+ async function runSetupFiles(config, files, runner) {
50
+ if (config.sequence.setupFiles === "parallel") {
51
+ await Promise.all(files.map(async (fsPath) => {
52
+ await runner.importFile(fsPath, "setup");
53
+ }));
54
+ } else {
55
+ for (const fsPath of files) {
56
+ await runner.importFile(fsPath, "setup");
57
+ }
58
+ }
59
+ }
60
+
61
+ function mergeScopedFixtures(testFixtures, scopedFixtures) {
62
+ const scopedFixturesMap = scopedFixtures.reduce((map, fixture) => {
63
+ map[fixture.prop] = fixture;
64
+ return map;
65
+ }, {});
66
+ const newFixtures = {};
67
+ testFixtures.forEach((fixture) => {
68
+ const useFixture = scopedFixturesMap[fixture.prop] || { ...fixture };
69
+ newFixtures[useFixture.prop] = useFixture;
70
+ });
71
+ for (const fixtureKep in newFixtures) {
72
+ var _fixture$deps;
73
+ const fixture = newFixtures[fixtureKep];
74
+ // if the fixture was define before the scope, then its dep
75
+ // will reference the original fixture instead of the scope
76
+ fixture.deps = (_fixture$deps = fixture.deps) === null || _fixture$deps === void 0 ? void 0 : _fixture$deps.map((dep) => newFixtures[dep.prop]);
77
+ }
78
+ return Object.values(newFixtures);
79
+ }
80
+ function mergeContextFixtures(fixtures, context, runner) {
81
+ const fixtureOptionKeys = [
82
+ "auto",
83
+ "injected",
84
+ "scope"
85
+ ];
86
+ const fixtureArray = Object.entries(fixtures).map(([prop, value]) => {
87
+ const fixtureItem = { value };
88
+ if (Array.isArray(value) && value.length >= 2 && isObject(value[1]) && Object.keys(value[1]).some((key) => fixtureOptionKeys.includes(key))) {
89
+ var _runner$injectValue;
90
+ // fixture with options
91
+ Object.assign(fixtureItem, value[1]);
92
+ const userValue = value[0];
93
+ fixtureItem.value = fixtureItem.injected ? ((_runner$injectValue = runner.injectValue) === null || _runner$injectValue === void 0 ? void 0 : _runner$injectValue.call(runner, prop)) ?? userValue : userValue;
94
+ }
95
+ fixtureItem.scope = fixtureItem.scope || "test";
96
+ if (fixtureItem.scope === "worker" && !runner.getWorkerContext) {
97
+ fixtureItem.scope = "file";
98
+ }
99
+ fixtureItem.prop = prop;
100
+ fixtureItem.isFn = typeof fixtureItem.value === "function";
101
+ return fixtureItem;
102
+ });
103
+ if (Array.isArray(context.fixtures)) {
104
+ context.fixtures = context.fixtures.concat(fixtureArray);
105
+ } else {
106
+ context.fixtures = fixtureArray;
107
+ }
108
+ // Update dependencies of fixture functions
109
+ fixtureArray.forEach((fixture) => {
110
+ if (fixture.isFn) {
111
+ const usedProps = getUsedProps(fixture.value);
112
+ if (usedProps.length) {
113
+ fixture.deps = context.fixtures.filter(({ prop }) => prop !== fixture.prop && usedProps.includes(prop));
114
+ }
115
+ // test can access anything, so we ignore it
116
+ if (fixture.scope !== "test") {
117
+ var _fixture$deps2;
118
+ (_fixture$deps2 = fixture.deps) === null || _fixture$deps2 === void 0 ? void 0 : _fixture$deps2.forEach((dep) => {
119
+ if (!dep.isFn) {
120
+ // non fn fixtures are always resolved and available to anyone
121
+ return;
122
+ }
123
+ // worker scope can only import from worker scope
124
+ if (fixture.scope === "worker" && dep.scope === "worker") {
125
+ return;
126
+ }
127
+ // file scope an import from file and worker scopes
128
+ if (fixture.scope === "file" && dep.scope !== "test") {
129
+ return;
130
+ }
131
+ throw new SyntaxError(`cannot use the ${dep.scope} fixture "${dep.prop}" inside the ${fixture.scope} fixture "${fixture.prop}"`);
132
+ });
133
+ }
134
+ }
135
+ });
136
+ return context;
137
+ }
138
+ const fixtureValueMaps = new Map();
139
+ const cleanupFnArrayMap = new Map();
140
+ async function callFixtureCleanup(context) {
141
+ const cleanupFnArray = cleanupFnArrayMap.get(context) ?? [];
142
+ for (const cleanup of cleanupFnArray.reverse()) {
143
+ await cleanup();
144
+ }
145
+ cleanupFnArrayMap.delete(context);
146
+ }
147
+ function withFixtures(runner, fn, testContext) {
148
+ return (hookContext) => {
149
+ const context = hookContext || testContext;
150
+ if (!context) {
151
+ return fn({});
152
+ }
153
+ const fixtures = getTestFixture(context);
154
+ if (!(fixtures === null || fixtures === void 0 ? void 0 : fixtures.length)) {
155
+ return fn(context);
156
+ }
157
+ const usedProps = getUsedProps(fn);
158
+ const hasAutoFixture = fixtures.some(({ auto }) => auto);
159
+ if (!usedProps.length && !hasAutoFixture) {
160
+ return fn(context);
161
+ }
162
+ if (!fixtureValueMaps.get(context)) {
163
+ fixtureValueMaps.set(context, new Map());
164
+ }
165
+ const fixtureValueMap = fixtureValueMaps.get(context);
166
+ if (!cleanupFnArrayMap.has(context)) {
167
+ cleanupFnArrayMap.set(context, []);
168
+ }
169
+ const cleanupFnArray = cleanupFnArrayMap.get(context);
170
+ const usedFixtures = fixtures.filter(({ prop, auto }) => auto || usedProps.includes(prop));
171
+ const pendingFixtures = resolveDeps(usedFixtures);
172
+ if (!pendingFixtures.length) {
173
+ return fn(context);
174
+ }
175
+ async function resolveFixtures() {
176
+ for (const fixture of pendingFixtures) {
177
+ // fixture could be already initialized during "before" hook
178
+ if (fixtureValueMap.has(fixture)) {
179
+ continue;
180
+ }
181
+ const resolvedValue = await resolveFixtureValue(runner, fixture, context, cleanupFnArray);
182
+ context[fixture.prop] = resolvedValue;
183
+ fixtureValueMap.set(fixture, resolvedValue);
184
+ if (fixture.scope === "test") {
185
+ cleanupFnArray.unshift(() => {
186
+ fixtureValueMap.delete(fixture);
187
+ });
188
+ }
189
+ }
190
+ }
191
+ return resolveFixtures().then(() => fn(context));
192
+ };
193
+ }
194
+ const globalFixturePromise = new WeakMap();
195
+ function resolveFixtureValue(runner, fixture, context, cleanupFnArray) {
196
+ var _runner$getWorkerCont;
197
+ const fileContext = getFileContext(context.task.file);
198
+ const workerContext = (_runner$getWorkerCont = runner.getWorkerContext) === null || _runner$getWorkerCont === void 0 ? void 0 : _runner$getWorkerCont.call(runner);
199
+ if (!fixture.isFn) {
200
+ var _fixture$prop;
201
+ fileContext[_fixture$prop = fixture.prop] ?? (fileContext[_fixture$prop] = fixture.value);
202
+ if (workerContext) {
203
+ var _fixture$prop2;
204
+ workerContext[_fixture$prop2 = fixture.prop] ?? (workerContext[_fixture$prop2] = fixture.value);
205
+ }
206
+ return fixture.value;
207
+ }
208
+ if (fixture.scope === "test") {
209
+ return resolveFixtureFunction(fixture.value, context, cleanupFnArray);
210
+ }
211
+ // in case the test runs in parallel
212
+ if (globalFixturePromise.has(fixture)) {
213
+ return globalFixturePromise.get(fixture);
214
+ }
215
+ let fixtureContext;
216
+ if (fixture.scope === "worker") {
217
+ if (!workerContext) {
218
+ throw new TypeError("[@vitest/runner] The worker context is not available in the current test runner. Please, provide the `getWorkerContext` method when initiating the runner.");
219
+ }
220
+ fixtureContext = workerContext;
221
+ } else {
222
+ fixtureContext = fileContext;
223
+ }
224
+ if (fixture.prop in fixtureContext) {
225
+ return fixtureContext[fixture.prop];
226
+ }
227
+ if (!cleanupFnArrayMap.has(fixtureContext)) {
228
+ cleanupFnArrayMap.set(fixtureContext, []);
229
+ }
230
+ const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext);
231
+ const promise = resolveFixtureFunction(fixture.value, fixtureContext, cleanupFnFileArray).then((value) => {
232
+ fixtureContext[fixture.prop] = value;
233
+ globalFixturePromise.delete(fixture);
234
+ return value;
235
+ });
236
+ globalFixturePromise.set(fixture, promise);
237
+ return promise;
238
+ }
239
+ async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
240
+ // wait for `use` call to extract fixture value
241
+ const useFnArgPromise = createDefer();
242
+ let isUseFnArgResolved = false;
243
+ const fixtureReturn = fixtureFn(context, async (useFnArg) => {
244
+ // extract `use` argument
245
+ isUseFnArgResolved = true;
246
+ useFnArgPromise.resolve(useFnArg);
247
+ // suspend fixture teardown by holding off `useReturnPromise` resolution until cleanup
248
+ const useReturnPromise = createDefer();
249
+ cleanupFnArray.push(async () => {
250
+ // start teardown by resolving `use` Promise
251
+ useReturnPromise.resolve();
252
+ // wait for finishing teardown
253
+ await fixtureReturn;
254
+ });
255
+ await useReturnPromise;
256
+ }).catch((e) => {
257
+ // treat fixture setup error as test failure
258
+ if (!isUseFnArgResolved) {
259
+ useFnArgPromise.reject(e);
260
+ return;
261
+ }
262
+ // otherwise re-throw to avoid silencing error during cleanup
263
+ throw e;
264
+ });
265
+ return useFnArgPromise;
266
+ }
267
+ function resolveDeps(fixtures, depSet = new Set(), pendingFixtures = []) {
268
+ fixtures.forEach((fixture) => {
269
+ if (pendingFixtures.includes(fixture)) {
270
+ return;
271
+ }
272
+ if (!fixture.isFn || !fixture.deps) {
273
+ pendingFixtures.push(fixture);
274
+ return;
275
+ }
276
+ if (depSet.has(fixture)) {
277
+ throw new Error(`Circular fixture dependency detected: ${fixture.prop} <- ${[...depSet].reverse().map((d) => d.prop).join(" <- ")}`);
278
+ }
279
+ depSet.add(fixture);
280
+ resolveDeps(fixture.deps, depSet, pendingFixtures);
281
+ pendingFixtures.push(fixture);
282
+ depSet.clear();
283
+ });
284
+ return pendingFixtures;
285
+ }
286
+ function getUsedProps(fn) {
287
+ let fnString = stripLiteral(fn.toString());
288
+ // match lowered async function and strip it off
289
+ // example code on esbuild-try https://esbuild.github.io/try/#YgAwLjI0LjAALS1zdXBwb3J0ZWQ6YXN5bmMtYXdhaXQ9ZmFsc2UAZQBlbnRyeS50cwBjb25zdCBvID0gewogIGYxOiBhc3luYyAoKSA9PiB7fSwKICBmMjogYXN5bmMgKGEpID0+IHt9LAogIGYzOiBhc3luYyAoYSwgYikgPT4ge30sCiAgZjQ6IGFzeW5jIGZ1bmN0aW9uKGEpIHt9LAogIGY1OiBhc3luYyBmdW5jdGlvbiBmZihhKSB7fSwKICBhc3luYyBmNihhKSB7fSwKCiAgZzE6IGFzeW5jICgpID0+IHt9LAogIGcyOiBhc3luYyAoeyBhIH0pID0+IHt9LAogIGczOiBhc3luYyAoeyBhIH0sIGIpID0+IHt9LAogIGc0OiBhc3luYyBmdW5jdGlvbiAoeyBhIH0pIHt9LAogIGc1OiBhc3luYyBmdW5jdGlvbiBnZyh7IGEgfSkge30sCiAgYXN5bmMgZzYoeyBhIH0pIHt9LAoKICBoMTogYXN5bmMgKCkgPT4ge30sCiAgLy8gY29tbWVudCBiZXR3ZWVuCiAgaDI6IGFzeW5jIChhKSA9PiB7fSwKfQ
290
+ // __async(this, null, function*
291
+ // __async(this, arguments, function*
292
+ // __async(this, [_0, _1], function*
293
+ if (/__async\((?:this|null), (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) {
294
+ fnString = fnString.split(/__async\((?:this|null),/)[1];
295
+ }
296
+ const match = fnString.match(/[^(]*\(([^)]*)/);
297
+ if (!match) {
298
+ return [];
299
+ }
300
+ const args = splitByComma(match[1]);
301
+ if (!args.length) {
302
+ return [];
303
+ }
304
+ let first = args[0];
305
+ if ("__VITEST_FIXTURE_INDEX__" in fn) {
306
+ first = args[fn.__VITEST_FIXTURE_INDEX__];
307
+ if (!first) {
308
+ return [];
309
+ }
310
+ }
311
+ if (!(first.startsWith("{") && first.endsWith("}"))) {
312
+ throw new Error(`The first argument inside a fixture must use object destructuring pattern, e.g. ({ test } => {}). Instead, received "${first}".`);
313
+ }
314
+ const _first = first.slice(1, -1).replace(/\s/g, "");
315
+ const props = splitByComma(_first).map((prop) => {
316
+ return prop.replace(/:.*|=.*/g, "");
317
+ });
318
+ const last = props.at(-1);
319
+ if (last && last.startsWith("...")) {
320
+ throw new Error(`Rest parameters are not supported in fixtures, received "${last}".`);
321
+ }
322
+ return props;
323
+ }
324
+ function splitByComma(s) {
325
+ const result = [];
326
+ const stack = [];
327
+ let start = 0;
328
+ for (let i = 0; i < s.length; i++) {
329
+ if (s[i] === "{" || s[i] === "[") {
330
+ stack.push(s[i] === "{" ? "}" : "]");
331
+ } else if (s[i] === stack[stack.length - 1]) {
332
+ stack.pop();
333
+ } else if (!stack.length && s[i] === ",") {
334
+ const token = s.substring(start, i).trim();
335
+ if (token) {
336
+ result.push(token);
337
+ }
338
+ start = i + 1;
339
+ }
340
+ }
341
+ const lastToken = s.substring(start).trim();
342
+ if (lastToken) {
343
+ result.push(lastToken);
344
+ }
345
+ return result;
346
+ }
347
+
348
+ let _test;
349
+ function setCurrentTest(test) {
350
+ _test = test;
351
+ }
352
+ function getCurrentTest() {
353
+ return _test;
354
+ }
355
+ const tests = [];
356
+ function addRunningTest(test) {
357
+ tests.push(test);
358
+ return () => {
359
+ tests.splice(tests.indexOf(test));
360
+ };
361
+ }
362
+ function getRunningTests() {
363
+ return tests;
364
+ }
365
+
366
+ function createChainable(keys, fn) {
367
+ function create(context) {
368
+ const chain = function(...args) {
369
+ return fn.apply(context, args);
370
+ };
371
+ Object.assign(chain, fn);
372
+ chain.withContext = () => chain.bind(context);
373
+ chain.setContext = (key, value) => {
374
+ context[key] = value;
375
+ };
376
+ chain.mergeContext = (ctx) => {
377
+ Object.assign(context, ctx);
378
+ };
379
+ for (const key of keys) {
380
+ Object.defineProperty(chain, key, { get() {
381
+ return create({
382
+ ...context,
383
+ [key]: true
384
+ });
385
+ } });
386
+ }
387
+ return chain;
388
+ }
389
+ const chain = create({});
390
+ chain.fn = fn;
391
+ return chain;
392
+ }
393
+
394
+ /**
395
+ * Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
396
+ * Suites can contain both tests and other suites, enabling complex test structures.
397
+ *
398
+ * @param {string} name - The name of the suite, used for identification and reporting.
399
+ * @param {Function} fn - A function that defines the tests and suites within this suite.
400
+ * @example
401
+ * ```ts
402
+ * // Define a suite with two tests
403
+ * suite('Math operations', () => {
404
+ * test('should add two numbers', () => {
405
+ * expect(add(1, 2)).toBe(3);
406
+ * });
407
+ *
408
+ * test('should subtract two numbers', () => {
409
+ * expect(subtract(5, 2)).toBe(3);
410
+ * });
411
+ * });
412
+ * ```
413
+ * @example
414
+ * ```ts
415
+ * // Define nested suites
416
+ * suite('String operations', () => {
417
+ * suite('Trimming', () => {
418
+ * test('should trim whitespace from start and end', () => {
419
+ * expect(' hello '.trim()).toBe('hello');
420
+ * });
421
+ * });
422
+ *
423
+ * suite('Concatenation', () => {
424
+ * test('should concatenate two strings', () => {
425
+ * expect('hello' + ' ' + 'world').toBe('hello world');
426
+ * });
427
+ * });
428
+ * });
429
+ * ```
430
+ */
431
+ const suite = createSuite();
432
+ /**
433
+ * Defines a test case with a given name and test function. The test function can optionally be configured with test options.
434
+ *
435
+ * @param {string | Function} name - The name of the test or a function that will be used as a test name.
436
+ * @param {TestOptions | TestFunction} [optionsOrFn] - Optional. The test options or the test function if no explicit name is provided.
437
+ * @param {number | TestOptions | TestFunction} [optionsOrTest] - Optional. The test function or options, depending on the previous parameters.
438
+ * @throws {Error} If called inside another test function.
439
+ * @example
440
+ * ```ts
441
+ * // Define a simple test
442
+ * test('should add two numbers', () => {
443
+ * expect(add(1, 2)).toBe(3);
444
+ * });
445
+ * ```
446
+ * @example
447
+ * ```ts
448
+ * // Define a test with options
449
+ * test('should subtract two numbers', { retry: 3 }, () => {
450
+ * expect(subtract(5, 2)).toBe(3);
451
+ * });
452
+ * ```
453
+ */
454
+ const test = createTest(function(name, optionsOrFn, optionsOrTest) {
455
+ if (getCurrentTest()) {
456
+ throw new Error("Calling the test function inside another test function is not allowed. Please put it inside \"describe\" or \"suite\" so it can be properly collected.");
457
+ }
458
+ getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
459
+ });
460
+ /**
461
+ * Creates a suite of tests, allowing for grouping and hierarchical organization of tests.
462
+ * Suites can contain both tests and other suites, enabling complex test structures.
463
+ *
464
+ * @param {string} name - The name of the suite, used for identification and reporting.
465
+ * @param {Function} fn - A function that defines the tests and suites within this suite.
466
+ * @example
467
+ * ```ts
468
+ * // Define a suite with two tests
469
+ * describe('Math operations', () => {
470
+ * test('should add two numbers', () => {
471
+ * expect(add(1, 2)).toBe(3);
472
+ * });
473
+ *
474
+ * test('should subtract two numbers', () => {
475
+ * expect(subtract(5, 2)).toBe(3);
476
+ * });
477
+ * });
478
+ * ```
479
+ * @example
480
+ * ```ts
481
+ * // Define nested suites
482
+ * describe('String operations', () => {
483
+ * describe('Trimming', () => {
484
+ * test('should trim whitespace from start and end', () => {
485
+ * expect(' hello '.trim()).toBe('hello');
486
+ * });
487
+ * });
488
+ *
489
+ * describe('Concatenation', () => {
490
+ * test('should concatenate two strings', () => {
491
+ * expect('hello' + ' ' + 'world').toBe('hello world');
492
+ * });
493
+ * });
494
+ * });
495
+ * ```
496
+ */
497
+ const describe = suite;
498
+ /**
499
+ * Defines a test case with a given name and test function. The test function can optionally be configured with test options.
500
+ *
501
+ * @param {string | Function} name - The name of the test or a function that will be used as a test name.
502
+ * @param {TestOptions | TestFunction} [optionsOrFn] - Optional. The test options or the test function if no explicit name is provided.
503
+ * @param {number | TestOptions | TestFunction} [optionsOrTest] - Optional. The test function or options, depending on the previous parameters.
504
+ * @throws {Error} If called inside another test function.
505
+ * @example
506
+ * ```ts
507
+ * // Define a simple test
508
+ * it('adds two numbers', () => {
509
+ * expect(add(1, 2)).toBe(3);
510
+ * });
511
+ * ```
512
+ * @example
513
+ * ```ts
514
+ * // Define a test with options
515
+ * it('subtracts two numbers', { retry: 3 }, () => {
516
+ * expect(subtract(5, 2)).toBe(3);
517
+ * });
518
+ * ```
519
+ */
520
+ const it = test;
521
+ let runner;
522
+ let defaultSuite;
523
+ let currentTestFilepath;
524
+ function assert(condition, message) {
525
+ if (!condition) {
526
+ throw new Error(`Vitest failed to find ${message}. This is a bug in Vitest. Please, open an issue with reproduction.`);
527
+ }
528
+ }
529
+ function getDefaultSuite() {
530
+ assert(defaultSuite, "the default suite");
531
+ return defaultSuite;
532
+ }
533
+ function getTestFilepath() {
534
+ return currentTestFilepath;
535
+ }
536
+ function getRunner() {
537
+ assert(runner, "the runner");
538
+ return runner;
539
+ }
540
+ function createDefaultSuite(runner) {
541
+ const config = runner.config.sequence;
542
+ const collector = suite("", { concurrent: config.concurrent }, () => {});
543
+ // no parent suite for top-level tests
544
+ delete collector.suite;
545
+ return collector;
546
+ }
547
+ function clearCollectorContext(filepath, currentRunner) {
548
+ if (!defaultSuite) {
549
+ defaultSuite = createDefaultSuite(currentRunner);
550
+ }
551
+ runner = currentRunner;
552
+ currentTestFilepath = filepath;
553
+ collectorContext.tasks.length = 0;
554
+ defaultSuite.clear();
555
+ collectorContext.currentSuite = defaultSuite;
556
+ }
557
+ function getCurrentSuite() {
558
+ const currentSuite = collectorContext.currentSuite || defaultSuite;
559
+ assert(currentSuite, "the current suite");
560
+ return currentSuite;
561
+ }
562
+ function createSuiteHooks() {
563
+ return {
564
+ beforeAll: [],
565
+ afterAll: [],
566
+ beforeEach: [],
567
+ afterEach: []
568
+ };
569
+ }
570
+ function parseArguments(optionsOrFn, optionsOrTest) {
571
+ let options = {};
572
+ let fn = () => {};
573
+ // it('', () => {}, { retry: 2 })
574
+ if (typeof optionsOrTest === "object") {
575
+ // it('', { retry: 2 }, { retry: 3 })
576
+ if (typeof optionsOrFn === "object") {
577
+ throw new TypeError("Cannot use two objects as arguments. Please provide options and a function callback in that order.");
578
+ }
579
+ console.warn("Using an object as a third argument is deprecated. Vitest 4 will throw an error if the third argument is not a timeout number. Please use the second argument for options. See more at https://vitest.dev/guide/migration");
580
+ options = optionsOrTest;
581
+ } else if (typeof optionsOrTest === "number") {
582
+ options = { timeout: optionsOrTest };
583
+ } else if (typeof optionsOrFn === "object") {
584
+ options = optionsOrFn;
585
+ }
586
+ if (typeof optionsOrFn === "function") {
587
+ if (typeof optionsOrTest === "function") {
588
+ throw new TypeError("Cannot use two functions as arguments. Please use the second argument for options.");
589
+ }
590
+ fn = optionsOrFn;
591
+ } else if (typeof optionsOrTest === "function") {
592
+ fn = optionsOrTest;
593
+ }
594
+ return {
595
+ options,
596
+ handler: fn
597
+ };
598
+ }
599
+ // implementations
600
+ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions, parentCollectorFixtures) {
601
+ const tasks = [];
602
+ let suite;
603
+ initSuite(true);
604
+ const task = function(name = "", options = {}) {
605
+ var _collectorContext$cur;
606
+ const timeout = (options === null || options === void 0 ? void 0 : options.timeout) ?? runner.config.testTimeout;
607
+ const task = {
608
+ id: "",
609
+ name,
610
+ suite: (_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.suite,
611
+ each: options.each,
612
+ fails: options.fails,
613
+ context: undefined,
614
+ type: "test",
615
+ file: undefined,
616
+ timeout,
617
+ retry: options.retry ?? runner.config.retry,
618
+ repeats: options.repeats,
619
+ mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
620
+ meta: options.meta ?? Object.create(null),
621
+ annotations: []
622
+ };
623
+ const handler = options.handler;
624
+ if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
625
+ task.concurrent = true;
626
+ }
627
+ task.shuffle = suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.shuffle;
628
+ const context = createTestContext(task, runner);
629
+ // create test context
630
+ Object.defineProperty(task, "context", {
631
+ value: context,
632
+ enumerable: false
633
+ });
634
+ setTestFixture(context, options.fixtures);
635
+ // custom can be called from any place, let's assume the limit is 15 stacks
636
+ const limit = Error.stackTraceLimit;
637
+ Error.stackTraceLimit = 15;
638
+ const stackTraceError = new Error("STACK_TRACE_ERROR");
639
+ Error.stackTraceLimit = limit;
640
+ if (handler) {
641
+ setFn(task, withTimeout(withAwaitAsyncAssertions(withFixtures(runner, handler, context), task), timeout, false, stackTraceError, (_, error) => abortIfTimeout([context], error)));
642
+ }
643
+ if (runner.config.includeTaskLocation) {
644
+ const error = stackTraceError.stack;
645
+ const stack = findTestFileStackTrace(error);
646
+ if (stack) {
647
+ task.location = stack;
648
+ }
649
+ }
650
+ tasks.push(task);
651
+ return task;
652
+ };
653
+ const test = createTest(function(name, optionsOrFn, optionsOrTest) {
654
+ let { options, handler } = parseArguments(optionsOrFn, optionsOrTest);
655
+ // inherit repeats, retry, timeout from suite
656
+ if (typeof suiteOptions === "object") {
657
+ options = Object.assign({}, suiteOptions, options);
658
+ }
659
+ // inherit concurrent / sequential from suite
660
+ options.concurrent = this.concurrent || !this.sequential && (options === null || options === void 0 ? void 0 : options.concurrent);
661
+ options.sequential = this.sequential || !this.concurrent && (options === null || options === void 0 ? void 0 : options.sequential);
662
+ const test = task(formatName(name), {
663
+ ...this,
664
+ ...options,
665
+ handler
666
+ });
667
+ test.type = "test";
668
+ });
669
+ let collectorFixtures = parentCollectorFixtures;
670
+ const collector = {
671
+ type: "collector",
672
+ name,
673
+ mode,
674
+ suite,
675
+ options: suiteOptions,
676
+ test,
677
+ tasks,
678
+ collect,
679
+ task,
680
+ clear,
681
+ on: addHook,
682
+ fixtures() {
683
+ return collectorFixtures;
684
+ },
685
+ scoped(fixtures) {
686
+ const parsed = mergeContextFixtures(fixtures, { fixtures: collectorFixtures }, runner);
687
+ if (parsed.fixtures) {
688
+ collectorFixtures = parsed.fixtures;
689
+ }
690
+ }
691
+ };
692
+ function addHook(name, ...fn) {
693
+ getHooks(suite)[name].push(...fn);
694
+ }
695
+ function initSuite(includeLocation) {
696
+ var _collectorContext$cur2;
697
+ if (typeof suiteOptions === "number") {
698
+ suiteOptions = { timeout: suiteOptions };
699
+ }
700
+ suite = {
701
+ id: "",
702
+ type: "suite",
703
+ name,
704
+ suite: (_collectorContext$cur2 = collectorContext.currentSuite) === null || _collectorContext$cur2 === void 0 ? void 0 : _collectorContext$cur2.suite,
705
+ mode,
706
+ each,
707
+ file: undefined,
708
+ shuffle: suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.shuffle,
709
+ tasks: [],
710
+ meta: Object.create(null),
711
+ concurrent: suiteOptions === null || suiteOptions === void 0 ? void 0 : suiteOptions.concurrent
712
+ };
713
+ if (runner && includeLocation && runner.config.includeTaskLocation) {
714
+ const limit = Error.stackTraceLimit;
715
+ Error.stackTraceLimit = 15;
716
+ const error = new Error("stacktrace").stack;
717
+ Error.stackTraceLimit = limit;
718
+ const stack = findTestFileStackTrace(error);
719
+ if (stack) {
720
+ suite.location = stack;
721
+ }
722
+ }
723
+ setHooks(suite, createSuiteHooks());
724
+ }
725
+ function clear() {
726
+ tasks.length = 0;
727
+ initSuite(false);
728
+ }
729
+ async function collect(file) {
730
+ if (!file) {
731
+ throw new TypeError("File is required to collect tasks.");
732
+ }
733
+ if (factory) {
734
+ await runWithSuite(collector, () => factory(test));
735
+ }
736
+ const allChildren = [];
737
+ for (const i of tasks) {
738
+ allChildren.push(i.type === "collector" ? await i.collect(file) : i);
739
+ }
740
+ suite.file = file;
741
+ suite.tasks = allChildren;
742
+ allChildren.forEach((task) => {
743
+ task.file = file;
744
+ });
745
+ return suite;
746
+ }
747
+ collectTask(collector);
748
+ return collector;
749
+ }
750
+ function withAwaitAsyncAssertions(fn, task) {
751
+ return async (...args) => {
752
+ const fnResult = await fn(...args);
753
+ // some async expect will be added to this array, in case user forget to await them
754
+ if (task.promises) {
755
+ const result = await Promise.allSettled(task.promises);
756
+ const errors = result.map((r) => r.status === "rejected" ? r.reason : undefined).filter(Boolean);
757
+ if (errors.length) {
758
+ throw errors;
759
+ }
760
+ }
761
+ return fnResult;
762
+ };
763
+ }
764
+ function createSuite() {
765
+ function suiteFn(name, factoryOrOptions, optionsOrFactory) {
766
+ var _currentSuite$options;
767
+ const mode = this.only ? "only" : this.skip ? "skip" : this.todo ? "todo" : "run";
768
+ const currentSuite = collectorContext.currentSuite || defaultSuite;
769
+ let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
770
+ const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
771
+ const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
772
+ // inherit options from current suite
773
+ options = {
774
+ ...currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.options,
775
+ ...options,
776
+ shuffle: this.shuffle ?? options.shuffle ?? (currentSuite === null || currentSuite === void 0 || (_currentSuite$options = currentSuite.options) === null || _currentSuite$options === void 0 ? void 0 : _currentSuite$options.shuffle) ?? (runner === null || runner === void 0 ? void 0 : runner.config.sequence.shuffle)
777
+ };
778
+ // inherit concurrent / sequential from suite
779
+ const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
780
+ const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
781
+ options.concurrent = isConcurrent && !isSequential;
782
+ options.sequential = isSequential && !isConcurrent;
783
+ return createSuiteCollector(formatName(name), factory, mode, this.each, options, currentSuite === null || currentSuite === void 0 ? void 0 : currentSuite.fixtures());
784
+ }
785
+ suiteFn.each = function(cases, ...args) {
786
+ const suite = this.withContext();
787
+ this.setContext("each", true);
788
+ if (Array.isArray(cases) && args.length) {
789
+ cases = formatTemplateString(cases, args);
790
+ }
791
+ return (name, optionsOrFn, fnOrOptions) => {
792
+ const _name = formatName(name);
793
+ const arrayOnlyCases = cases.every(Array.isArray);
794
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
795
+ const fnFirst = typeof optionsOrFn === "function" && typeof fnOrOptions === "object";
796
+ cases.forEach((i, idx) => {
797
+ const items = Array.isArray(i) ? i : [i];
798
+ if (fnFirst) {
799
+ if (arrayOnlyCases) {
800
+ suite(formatTitle(_name, items, idx), () => handler(...items), options);
801
+ } else {
802
+ suite(formatTitle(_name, items, idx), () => handler(i), options);
803
+ }
804
+ } else {
805
+ if (arrayOnlyCases) {
806
+ suite(formatTitle(_name, items, idx), options, () => handler(...items));
807
+ } else {
808
+ suite(formatTitle(_name, items, idx), options, () => handler(i));
809
+ }
810
+ }
811
+ });
812
+ this.setContext("each", undefined);
813
+ };
814
+ };
815
+ suiteFn.for = function(cases, ...args) {
816
+ if (Array.isArray(cases) && args.length) {
817
+ cases = formatTemplateString(cases, args);
818
+ }
819
+ return (name, optionsOrFn, fnOrOptions) => {
820
+ const name_ = formatName(name);
821
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
822
+ cases.forEach((item, idx) => {
823
+ suite(formatTitle(name_, toArray(item), idx), options, () => handler(item));
824
+ });
825
+ };
826
+ };
827
+ suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
828
+ suiteFn.runIf = (condition) => condition ? suite : suite.skip;
829
+ return createChainable([
830
+ "concurrent",
831
+ "sequential",
832
+ "shuffle",
833
+ "skip",
834
+ "only",
835
+ "todo"
836
+ ], suiteFn);
837
+ }
838
+ function createTaskCollector(fn, context) {
839
+ const taskFn = fn;
840
+ taskFn.each = function(cases, ...args) {
841
+ const test = this.withContext();
842
+ this.setContext("each", true);
843
+ if (Array.isArray(cases) && args.length) {
844
+ cases = formatTemplateString(cases, args);
845
+ }
846
+ return (name, optionsOrFn, fnOrOptions) => {
847
+ const _name = formatName(name);
848
+ const arrayOnlyCases = cases.every(Array.isArray);
849
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
850
+ const fnFirst = typeof optionsOrFn === "function" && typeof fnOrOptions === "object";
851
+ cases.forEach((i, idx) => {
852
+ const items = Array.isArray(i) ? i : [i];
853
+ if (fnFirst) {
854
+ if (arrayOnlyCases) {
855
+ test(formatTitle(_name, items, idx), () => handler(...items), options);
856
+ } else {
857
+ test(formatTitle(_name, items, idx), () => handler(i), options);
858
+ }
859
+ } else {
860
+ if (arrayOnlyCases) {
861
+ test(formatTitle(_name, items, idx), options, () => handler(...items));
862
+ } else {
863
+ test(formatTitle(_name, items, idx), options, () => handler(i));
864
+ }
865
+ }
866
+ });
867
+ this.setContext("each", undefined);
868
+ };
869
+ };
870
+ taskFn.for = function(cases, ...args) {
871
+ const test = this.withContext();
872
+ if (Array.isArray(cases) && args.length) {
873
+ cases = formatTemplateString(cases, args);
874
+ }
875
+ return (name, optionsOrFn, fnOrOptions) => {
876
+ const _name = formatName(name);
877
+ const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
878
+ cases.forEach((item, idx) => {
879
+ // monkey-patch handler to allow parsing fixture
880
+ const handlerWrapper = (ctx) => handler(item, ctx);
881
+ handlerWrapper.__VITEST_FIXTURE_INDEX__ = 1;
882
+ handlerWrapper.toString = () => handler.toString();
883
+ test(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
884
+ });
885
+ };
886
+ };
887
+ taskFn.skipIf = function(condition) {
888
+ return condition ? this.skip : this;
889
+ };
890
+ taskFn.runIf = function(condition) {
891
+ return condition ? this : this.skip;
892
+ };
893
+ taskFn.scoped = function(fixtures) {
894
+ const collector = getCurrentSuite();
895
+ collector.scoped(fixtures);
896
+ };
897
+ taskFn.extend = function(fixtures) {
898
+ const _context = mergeContextFixtures(fixtures, context || {}, runner);
899
+ const originalWrapper = fn;
900
+ return createTest(function(name, optionsOrFn, optionsOrTest) {
901
+ const collector = getCurrentSuite();
902
+ const scopedFixtures = collector.fixtures();
903
+ const context = { ...this };
904
+ if (scopedFixtures) {
905
+ context.fixtures = mergeScopedFixtures(context.fixtures || [], scopedFixtures);
906
+ }
907
+ const { handler, options } = parseArguments(optionsOrFn, optionsOrTest);
908
+ const timeout = options.timeout ?? (runner === null || runner === void 0 ? void 0 : runner.config.testTimeout);
909
+ originalWrapper.call(context, formatName(name), handler, timeout);
910
+ }, _context);
911
+ };
912
+ const _test = createChainable([
913
+ "concurrent",
914
+ "sequential",
915
+ "skip",
916
+ "only",
917
+ "todo",
918
+ "fails"
919
+ ], taskFn);
920
+ if (context) {
921
+ _test.mergeContext(context);
922
+ }
923
+ return _test;
924
+ }
925
+ function createTest(fn, context) {
926
+ return createTaskCollector(fn, context);
927
+ }
928
+ function formatName(name) {
929
+ return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
930
+ }
931
+ function formatTitle(template, items, idx) {
932
+ if (template.includes("%#") || template.includes("%$")) {
933
+ // '%#' match index of the test case
934
+ template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/%\$/g, `${idx + 1}`).replace(/__vitest_escaped_%__/g, "%%");
935
+ }
936
+ const count = template.split("%").length - 1;
937
+ if (template.includes("%f")) {
938
+ const placeholders = template.match(/%f/g) || [];
939
+ placeholders.forEach((_, i) => {
940
+ if (isNegativeNaN(items[i]) || Object.is(items[i], -0)) {
941
+ // Replace the i-th occurrence of '%f' with '-%f'
942
+ let occurrence = 0;
943
+ template = template.replace(/%f/g, (match) => {
944
+ occurrence++;
945
+ return occurrence === i + 1 ? "-%f" : match;
946
+ });
947
+ }
948
+ });
949
+ }
950
+ let formatted = format(template, ...items.slice(0, count));
951
+ const isObjectItem = isObject(items[0]);
952
+ formatted = formatted.replace(/\$([$\w.]+)/g, (_, key) => {
953
+ var _runner$config;
954
+ const isArrayKey = /^\d+$/.test(key);
955
+ if (!isObjectItem && !isArrayKey) {
956
+ return `$${key}`;
957
+ }
958
+ const arrayElement = isArrayKey ? objectAttr(items, key) : undefined;
959
+ const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
960
+ return objDisplay(value, { truncate: runner === null || runner === void 0 || (_runner$config = runner.config) === null || _runner$config === void 0 || (_runner$config = _runner$config.chaiConfig) === null || _runner$config === void 0 ? void 0 : _runner$config.truncateThreshold });
961
+ });
962
+ return formatted;
963
+ }
964
+ function formatTemplateString(cases, args) {
965
+ const header = cases.join("").trim().replace(/ /g, "").split("\n").map((i) => i.split("|"))[0];
966
+ const res = [];
967
+ for (let i = 0; i < Math.floor(args.length / header.length); i++) {
968
+ const oneCase = {};
969
+ for (let j = 0; j < header.length; j++) {
970
+ oneCase[header[j]] = args[i * header.length + j];
971
+ }
972
+ res.push(oneCase);
973
+ }
974
+ return res;
975
+ }
976
+ function findTestFileStackTrace(error) {
977
+ const testFilePath = getTestFilepath();
978
+ // first line is the error message
979
+ const lines = error.split("\n").slice(1);
980
+ for (const line of lines) {
981
+ const stack = parseSingleStack(line);
982
+ if (stack && stack.file === testFilePath) {
983
+ return {
984
+ line: stack.line,
985
+ column: stack.column
986
+ };
987
+ }
988
+ }
989
+ }
990
+
991
+ /**
992
+ * If any tasks been marked as `only`, mark all other tasks as `skip`.
993
+ */
994
+ function interpretTaskModes(file, namePattern, testLocations, onlyMode, parentIsOnly, allowOnly) {
995
+ const matchedLocations = [];
996
+ const traverseSuite = (suite, parentIsOnly, parentMatchedWithLocation) => {
997
+ const suiteIsOnly = parentIsOnly || suite.mode === "only";
998
+ suite.tasks.forEach((t) => {
999
+ // Check if either the parent suite or the task itself are marked as included
1000
+ const includeTask = suiteIsOnly || t.mode === "only";
1001
+ if (onlyMode) {
1002
+ if (t.type === "suite" && (includeTask || someTasksAreOnly(t))) {
1003
+ // Don't skip this suite
1004
+ if (t.mode === "only") {
1005
+ checkAllowOnly(t, allowOnly);
1006
+ t.mode = "run";
1007
+ }
1008
+ } else if (t.mode === "run" && !includeTask) {
1009
+ t.mode = "skip";
1010
+ } else if (t.mode === "only") {
1011
+ checkAllowOnly(t, allowOnly);
1012
+ t.mode = "run";
1013
+ }
1014
+ }
1015
+ let hasLocationMatch = parentMatchedWithLocation;
1016
+ // Match test location against provided locations, only run if present
1017
+ // in `testLocations`. Note: if `includeTaskLocations` is not enabled,
1018
+ // all test will be skipped.
1019
+ if (testLocations !== undefined && testLocations.length !== 0) {
1020
+ if (t.location && (testLocations === null || testLocations === void 0 ? void 0 : testLocations.includes(t.location.line))) {
1021
+ t.mode = "run";
1022
+ matchedLocations.push(t.location.line);
1023
+ hasLocationMatch = true;
1024
+ } else if (parentMatchedWithLocation) {
1025
+ t.mode = "run";
1026
+ } else if (t.type === "test") {
1027
+ t.mode = "skip";
1028
+ }
1029
+ }
1030
+ if (t.type === "test") {
1031
+ if (namePattern && !getTaskFullName(t).match(namePattern)) {
1032
+ t.mode = "skip";
1033
+ }
1034
+ } else if (t.type === "suite") {
1035
+ if (t.mode === "skip") {
1036
+ skipAllTasks(t);
1037
+ } else if (t.mode === "todo") {
1038
+ todoAllTasks(t);
1039
+ } else {
1040
+ traverseSuite(t, includeTask, hasLocationMatch);
1041
+ }
1042
+ }
1043
+ });
1044
+ // if all subtasks are skipped, mark as skip
1045
+ if (suite.mode === "run" || suite.mode === "queued") {
1046
+ if (suite.tasks.length && suite.tasks.every((i) => i.mode !== "run" && i.mode !== "queued")) {
1047
+ suite.mode = "skip";
1048
+ }
1049
+ }
1050
+ };
1051
+ traverseSuite(file, parentIsOnly, false);
1052
+ const nonMatching = testLocations === null || testLocations === void 0 ? void 0 : testLocations.filter((loc) => !matchedLocations.includes(loc));
1053
+ if (nonMatching && nonMatching.length !== 0) {
1054
+ const message = nonMatching.length === 1 ? `line ${nonMatching[0]}` : `lines ${nonMatching.join(", ")}`;
1055
+ if (file.result === undefined) {
1056
+ file.result = {
1057
+ state: "fail",
1058
+ errors: []
1059
+ };
1060
+ }
1061
+ if (file.result.errors === undefined) {
1062
+ file.result.errors = [];
1063
+ }
1064
+ file.result.errors.push(processError(new Error(`No test found in ${file.name} in ${message}`)));
1065
+ }
1066
+ }
1067
+ function getTaskFullName(task) {
1068
+ return `${task.suite ? `${getTaskFullName(task.suite)} ` : ""}${task.name}`;
1069
+ }
1070
+ function someTasksAreOnly(suite) {
1071
+ return suite.tasks.some((t) => t.mode === "only" || t.type === "suite" && someTasksAreOnly(t));
1072
+ }
1073
+ function skipAllTasks(suite) {
1074
+ suite.tasks.forEach((t) => {
1075
+ if (t.mode === "run" || t.mode === "queued") {
1076
+ t.mode = "skip";
1077
+ if (t.type === "suite") {
1078
+ skipAllTasks(t);
1079
+ }
1080
+ }
1081
+ });
1082
+ }
1083
+ function todoAllTasks(suite) {
1084
+ suite.tasks.forEach((t) => {
1085
+ if (t.mode === "run" || t.mode === "queued") {
1086
+ t.mode = "todo";
1087
+ if (t.type === "suite") {
1088
+ todoAllTasks(t);
1089
+ }
1090
+ }
1091
+ });
1092
+ }
1093
+ function checkAllowOnly(task, allowOnly) {
1094
+ if (allowOnly) {
1095
+ return;
1096
+ }
1097
+ const error = processError(new Error("[Vitest] Unexpected .only modifier. Remove it or pass --allowOnly argument to bypass this error"));
1098
+ task.result = {
1099
+ state: "fail",
1100
+ errors: [error]
1101
+ };
1102
+ }
1103
+ function generateHash(str) {
1104
+ let hash = 0;
1105
+ if (str.length === 0) {
1106
+ return `${hash}`;
1107
+ }
1108
+ for (let i = 0; i < str.length; i++) {
1109
+ const char = str.charCodeAt(i);
1110
+ hash = (hash << 5) - hash + char;
1111
+ hash = hash & hash;
1112
+ }
1113
+ return `${hash}`;
1114
+ }
1115
+ function calculateSuiteHash(parent) {
1116
+ parent.tasks.forEach((t, idx) => {
1117
+ t.id = `${parent.id}_${idx}`;
1118
+ if (t.type === "suite") {
1119
+ calculateSuiteHash(t);
1120
+ }
1121
+ });
1122
+ }
1123
+ function createFileTask(filepath, root, projectName, pool) {
1124
+ const path = relative(root, filepath);
1125
+ const file = {
1126
+ id: generateFileHash(path, projectName),
1127
+ name: path,
1128
+ type: "suite",
1129
+ mode: "queued",
1130
+ filepath,
1131
+ tasks: [],
1132
+ meta: Object.create(null),
1133
+ projectName,
1134
+ file: undefined,
1135
+ pool
1136
+ };
1137
+ file.file = file;
1138
+ setFileContext(file, Object.create(null));
1139
+ return file;
1140
+ }
1141
+ /**
1142
+ * Generate a unique ID for a file based on its path and project name
1143
+ * @param file File relative to the root of the project to keep ID the same between different machines
1144
+ * @param projectName The name of the test project
1145
+ */
1146
+ function generateFileHash(file, projectName) {
1147
+ return generateHash(`${file}${projectName || ""}`);
1148
+ }
1149
+
1150
+ const now$2 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
1151
+ async function collectTests(specs, runner) {
1152
+ const files = [];
1153
+ const config = runner.config;
1154
+ for (const spec of specs) {
1155
+ var _runner$onCollectStar;
1156
+ const filepath = typeof spec === "string" ? spec : spec.filepath;
1157
+ const testLocations = typeof spec === "string" ? undefined : spec.testLocations;
1158
+ const file = createFileTask(filepath, config.root, config.name, runner.pool);
1159
+ file.shuffle = config.sequence.shuffle;
1160
+ (_runner$onCollectStar = runner.onCollectStart) === null || _runner$onCollectStar === void 0 ? void 0 : _runner$onCollectStar.call(runner, file);
1161
+ clearCollectorContext(filepath, runner);
1162
+ try {
1163
+ var _runner$getImportDura;
1164
+ const setupFiles = toArray(config.setupFiles);
1165
+ if (setupFiles.length) {
1166
+ const setupStart = now$2();
1167
+ await runSetupFiles(config, setupFiles, runner);
1168
+ const setupEnd = now$2();
1169
+ file.setupDuration = setupEnd - setupStart;
1170
+ } else {
1171
+ file.setupDuration = 0;
1172
+ }
1173
+ const collectStart = now$2();
1174
+ await runner.importFile(filepath, "collect");
1175
+ const durations = (_runner$getImportDura = runner.getImportDurations) === null || _runner$getImportDura === void 0 ? void 0 : _runner$getImportDura.call(runner);
1176
+ if (durations) {
1177
+ file.importDurations = durations;
1178
+ }
1179
+ const defaultTasks = await getDefaultSuite().collect(file);
1180
+ const fileHooks = createSuiteHooks();
1181
+ mergeHooks(fileHooks, getHooks(defaultTasks));
1182
+ for (const c of [...defaultTasks.tasks, ...collectorContext.tasks]) {
1183
+ if (c.type === "test" || c.type === "suite") {
1184
+ file.tasks.push(c);
1185
+ } else if (c.type === "collector") {
1186
+ const suite = await c.collect(file);
1187
+ if (suite.name || suite.tasks.length) {
1188
+ mergeHooks(fileHooks, getHooks(suite));
1189
+ file.tasks.push(suite);
1190
+ }
1191
+ } else {
1192
+ // check that types are exhausted
1193
+ c;
1194
+ }
1195
+ }
1196
+ setHooks(file, fileHooks);
1197
+ file.collectDuration = now$2() - collectStart;
1198
+ } catch (e) {
1199
+ var _runner$getImportDura2;
1200
+ const error = processError(e);
1201
+ file.result = {
1202
+ state: "fail",
1203
+ errors: [error]
1204
+ };
1205
+ const durations = (_runner$getImportDura2 = runner.getImportDurations) === null || _runner$getImportDura2 === void 0 ? void 0 : _runner$getImportDura2.call(runner);
1206
+ if (durations) {
1207
+ file.importDurations = durations;
1208
+ }
1209
+ }
1210
+ calculateSuiteHash(file);
1211
+ const hasOnlyTasks = someTasksAreOnly(file);
1212
+ interpretTaskModes(file, config.testNamePattern, testLocations, hasOnlyTasks, false, config.allowOnly);
1213
+ if (file.mode === "queued") {
1214
+ file.mode = "run";
1215
+ }
1216
+ files.push(file);
1217
+ }
1218
+ return files;
1219
+ }
1220
+ function mergeHooks(baseHooks, hooks) {
1221
+ for (const _key in hooks) {
1222
+ const key = _key;
1223
+ baseHooks[key].push(...hooks[key]);
1224
+ }
1225
+ return baseHooks;
1226
+ }
1227
+
1228
+ /**
1229
+ * Return a function for running multiple async operations with limited concurrency.
1230
+ */
1231
+ function limitConcurrency(concurrency = Infinity) {
1232
+ // The number of currently active + pending tasks.
1233
+ let count = 0;
1234
+ // The head and tail of the pending task queue, built using a singly linked list.
1235
+ // Both head and tail are initially undefined, signifying an empty queue.
1236
+ // They both become undefined again whenever there are no pending tasks.
1237
+ let head;
1238
+ let tail;
1239
+ // A bookkeeping function executed whenever a task has been run to completion.
1240
+ const finish = () => {
1241
+ count--;
1242
+ // Check if there are further pending tasks in the queue.
1243
+ if (head) {
1244
+ // Allow the next pending task to run and pop it from the queue.
1245
+ head[0]();
1246
+ head = head[1];
1247
+ // The head may now be undefined if there are no further pending tasks.
1248
+ // In that case, set tail to undefined as well.
1249
+ tail = head && tail;
1250
+ }
1251
+ };
1252
+ return (func, ...args) => {
1253
+ // Create a promise chain that:
1254
+ // 1. Waits for its turn in the task queue (if necessary).
1255
+ // 2. Runs the task.
1256
+ // 3. Allows the next pending task (if any) to run.
1257
+ return new Promise((resolve) => {
1258
+ if (count++ < concurrency) {
1259
+ // No need to queue if fewer than maxConcurrency tasks are running.
1260
+ resolve();
1261
+ } else if (tail) {
1262
+ // There are pending tasks, so append to the queue.
1263
+ tail = tail[1] = [resolve];
1264
+ } else {
1265
+ // No other pending tasks, initialize the queue with a new tail and head.
1266
+ head = tail = [resolve];
1267
+ }
1268
+ }).then(() => {
1269
+ // Running func here ensures that even a non-thenable result or an
1270
+ // immediately thrown error gets wrapped into a Promise.
1271
+ return func(...args);
1272
+ }).finally(finish);
1273
+ };
1274
+ }
1275
+
1276
+ /**
1277
+ * Partition in tasks groups by consecutive concurrent
1278
+ */
1279
+ function partitionSuiteChildren(suite) {
1280
+ let tasksGroup = [];
1281
+ const tasksGroups = [];
1282
+ for (const c of suite.tasks) {
1283
+ if (tasksGroup.length === 0 || c.concurrent === tasksGroup[0].concurrent) {
1284
+ tasksGroup.push(c);
1285
+ } else {
1286
+ tasksGroups.push(tasksGroup);
1287
+ tasksGroup = [c];
1288
+ }
1289
+ }
1290
+ if (tasksGroup.length > 0) {
1291
+ tasksGroups.push(tasksGroup);
1292
+ }
1293
+ return tasksGroups;
1294
+ }
1295
+
1296
+ /**
1297
+ * @deprecated use `isTestCase` instead
1298
+ */
1299
+ function isAtomTest(s) {
1300
+ return isTestCase(s);
1301
+ }
1302
+ function isTestCase(s) {
1303
+ return s.type === "test";
1304
+ }
1305
+ function getTests(suite) {
1306
+ const tests = [];
1307
+ const arraySuites = toArray(suite);
1308
+ for (const s of arraySuites) {
1309
+ if (isTestCase(s)) {
1310
+ tests.push(s);
1311
+ } else {
1312
+ for (const task of s.tasks) {
1313
+ if (isTestCase(task)) {
1314
+ tests.push(task);
1315
+ } else {
1316
+ const taskTests = getTests(task);
1317
+ for (const test of taskTests) {
1318
+ tests.push(test);
1319
+ }
1320
+ }
1321
+ }
1322
+ }
1323
+ }
1324
+ return tests;
1325
+ }
1326
+ function getTasks(tasks = []) {
1327
+ return toArray(tasks).flatMap((s) => isTestCase(s) ? [s] : [s, ...getTasks(s.tasks)]);
1328
+ }
1329
+ function getSuites(suite) {
1330
+ return toArray(suite).flatMap((s) => s.type === "suite" ? [s, ...getSuites(s.tasks)] : []);
1331
+ }
1332
+ function hasTests(suite) {
1333
+ return toArray(suite).some((s) => s.tasks.some((c) => isTestCase(c) || hasTests(c)));
1334
+ }
1335
+ function hasFailed(suite) {
1336
+ return toArray(suite).some((s) => {
1337
+ var _s$result;
1338
+ return ((_s$result = s.result) === null || _s$result === void 0 ? void 0 : _s$result.state) === "fail" || s.type === "suite" && hasFailed(s.tasks);
1339
+ });
1340
+ }
1341
+ function getNames(task) {
1342
+ const names = [task.name];
1343
+ let current = task;
1344
+ while (current === null || current === void 0 ? void 0 : current.suite) {
1345
+ current = current.suite;
1346
+ if (current === null || current === void 0 ? void 0 : current.name) {
1347
+ names.unshift(current.name);
1348
+ }
1349
+ }
1350
+ if (current !== task.file) {
1351
+ names.unshift(task.file.name);
1352
+ }
1353
+ return names;
1354
+ }
1355
+ function getFullName(task, separator = " > ") {
1356
+ return getNames(task).join(separator);
1357
+ }
1358
+ function getTestName(task, separator = " > ") {
1359
+ return getNames(task).slice(1).join(separator);
1360
+ }
1361
+
1362
+ const now$1 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
1363
+ const unixNow = Date.now;
1364
+ const { clearTimeout, setTimeout } = getSafeTimers();
1365
+ function updateSuiteHookState(task, name, state, runner) {
1366
+ if (!task.result) {
1367
+ task.result = { state: "run" };
1368
+ }
1369
+ if (!task.result.hooks) {
1370
+ task.result.hooks = {};
1371
+ }
1372
+ const suiteHooks = task.result.hooks;
1373
+ if (suiteHooks) {
1374
+ suiteHooks[name] = state;
1375
+ let event = state === "run" ? "before-hook-start" : "before-hook-end";
1376
+ if (name === "afterAll" || name === "afterEach") {
1377
+ event = state === "run" ? "after-hook-start" : "after-hook-end";
1378
+ }
1379
+ updateTask(event, task, runner);
1380
+ }
1381
+ }
1382
+ function getSuiteHooks(suite, name, sequence) {
1383
+ const hooks = getHooks(suite)[name];
1384
+ if (sequence === "stack" && (name === "afterAll" || name === "afterEach")) {
1385
+ return hooks.slice().reverse();
1386
+ }
1387
+ return hooks;
1388
+ }
1389
+ async function callTestHooks(runner, test, hooks, sequence) {
1390
+ if (sequence === "stack") {
1391
+ hooks = hooks.slice().reverse();
1392
+ }
1393
+ if (!hooks.length) {
1394
+ return;
1395
+ }
1396
+ const context = test.context;
1397
+ const onTestFailed = test.context.onTestFailed;
1398
+ const onTestFinished = test.context.onTestFinished;
1399
+ context.onTestFailed = () => {
1400
+ throw new Error(`Cannot call "onTestFailed" inside a test hook.`);
1401
+ };
1402
+ context.onTestFinished = () => {
1403
+ throw new Error(`Cannot call "onTestFinished" inside a test hook.`);
1404
+ };
1405
+ if (sequence === "parallel") {
1406
+ try {
1407
+ await Promise.all(hooks.map((fn) => fn(test.context)));
1408
+ } catch (e) {
1409
+ failTask(test.result, e, runner.config.diffOptions);
1410
+ }
1411
+ } else {
1412
+ for (const fn of hooks) {
1413
+ try {
1414
+ await fn(test.context);
1415
+ } catch (e) {
1416
+ failTask(test.result, e, runner.config.diffOptions);
1417
+ }
1418
+ }
1419
+ }
1420
+ context.onTestFailed = onTestFailed;
1421
+ context.onTestFinished = onTestFinished;
1422
+ }
1423
+ async function callSuiteHook(suite, currentTask, name, runner, args) {
1424
+ const sequence = runner.config.sequence.hooks;
1425
+ const callbacks = [];
1426
+ // stop at file level
1427
+ const parentSuite = "filepath" in suite ? null : suite.suite || suite.file;
1428
+ if (name === "beforeEach" && parentSuite) {
1429
+ callbacks.push(...await callSuiteHook(parentSuite, currentTask, name, runner, args));
1430
+ }
1431
+ const hooks = getSuiteHooks(suite, name, sequence);
1432
+ if (hooks.length > 0) {
1433
+ updateSuiteHookState(currentTask, name, "run", runner);
1434
+ }
1435
+ async function runHook(hook) {
1436
+ return getBeforeHookCleanupCallback(hook, await hook(...args), name === "beforeEach" ? args[0] : undefined);
1437
+ }
1438
+ if (sequence === "parallel") {
1439
+ callbacks.push(...await Promise.all(hooks.map((hook) => runHook(hook))));
1440
+ } else {
1441
+ for (const hook of hooks) {
1442
+ callbacks.push(await runHook(hook));
1443
+ }
1444
+ }
1445
+ if (hooks.length > 0) {
1446
+ updateSuiteHookState(currentTask, name, "pass", runner);
1447
+ }
1448
+ if (name === "afterEach" && parentSuite) {
1449
+ callbacks.push(...await callSuiteHook(parentSuite, currentTask, name, runner, args));
1450
+ }
1451
+ return callbacks;
1452
+ }
1453
+ const packs = new Map();
1454
+ const eventsPacks = [];
1455
+ const pendingTasksUpdates = [];
1456
+ function sendTasksUpdate(runner) {
1457
+ if (packs.size) {
1458
+ var _runner$onTaskUpdate;
1459
+ const taskPacks = Array.from(packs).map(([id, task]) => {
1460
+ return [
1461
+ id,
1462
+ task[0],
1463
+ task[1]
1464
+ ];
1465
+ });
1466
+ const p = (_runner$onTaskUpdate = runner.onTaskUpdate) === null || _runner$onTaskUpdate === void 0 ? void 0 : _runner$onTaskUpdate.call(runner, taskPacks, eventsPacks);
1467
+ if (p) {
1468
+ pendingTasksUpdates.push(p);
1469
+ // remove successful promise to not grow array indefnitely,
1470
+ // but keep rejections so finishSendTasksUpdate can handle them
1471
+ p.then(() => pendingTasksUpdates.splice(pendingTasksUpdates.indexOf(p), 1), () => {});
1472
+ }
1473
+ eventsPacks.length = 0;
1474
+ packs.clear();
1475
+ }
1476
+ }
1477
+ async function finishSendTasksUpdate(runner) {
1478
+ sendTasksUpdate(runner);
1479
+ await Promise.all(pendingTasksUpdates);
1480
+ }
1481
+ function throttle(fn, ms) {
1482
+ let last = 0;
1483
+ let pendingCall;
1484
+ return function call(...args) {
1485
+ const now = unixNow();
1486
+ if (now - last > ms) {
1487
+ last = now;
1488
+ clearTimeout(pendingCall);
1489
+ pendingCall = undefined;
1490
+ return fn.apply(this, args);
1491
+ }
1492
+ // Make sure fn is still called even if there are no further calls
1493
+ pendingCall ?? (pendingCall = setTimeout(() => call.bind(this)(...args), ms));
1494
+ };
1495
+ }
1496
+ // throttle based on summary reporter's DURATION_UPDATE_INTERVAL_MS
1497
+ const sendTasksUpdateThrottled = throttle(sendTasksUpdate, 100);
1498
+ function updateTask(event, task, runner) {
1499
+ eventsPacks.push([
1500
+ task.id,
1501
+ event,
1502
+ undefined
1503
+ ]);
1504
+ packs.set(task.id, [task.result, task.meta]);
1505
+ sendTasksUpdateThrottled(runner);
1506
+ }
1507
+ async function callCleanupHooks(runner, cleanups) {
1508
+ const sequence = runner.config.sequence.hooks;
1509
+ if (sequence === "stack") {
1510
+ cleanups = cleanups.slice().reverse();
1511
+ }
1512
+ if (sequence === "parallel") {
1513
+ await Promise.all(cleanups.map(async (fn) => {
1514
+ if (typeof fn !== "function") {
1515
+ return;
1516
+ }
1517
+ await fn();
1518
+ }));
1519
+ } else {
1520
+ for (const fn of cleanups) {
1521
+ if (typeof fn !== "function") {
1522
+ continue;
1523
+ }
1524
+ await fn();
1525
+ }
1526
+ }
1527
+ }
1528
+ async function runTest(test, runner) {
1529
+ var _runner$onBeforeRunTa, _test$result, _runner$onAfterRunTas;
1530
+ await ((_runner$onBeforeRunTa = runner.onBeforeRunTask) === null || _runner$onBeforeRunTa === void 0 ? void 0 : _runner$onBeforeRunTa.call(runner, test));
1531
+ if (test.mode !== "run" && test.mode !== "queued") {
1532
+ updateTask("test-prepare", test, runner);
1533
+ updateTask("test-finished", test, runner);
1534
+ return;
1535
+ }
1536
+ if (((_test$result = test.result) === null || _test$result === void 0 ? void 0 : _test$result.state) === "fail") {
1537
+ // should not be possible to get here, I think this is just copy pasted from suite
1538
+ // TODO: maybe someone fails tests in `beforeAll` hooks?
1539
+ // https://github.com/vitest-dev/vitest/pull/7069
1540
+ updateTask("test-failed-early", test, runner);
1541
+ return;
1542
+ }
1543
+ const start = now$1();
1544
+ test.result = {
1545
+ state: "run",
1546
+ startTime: unixNow(),
1547
+ retryCount: 0
1548
+ };
1549
+ updateTask("test-prepare", test, runner);
1550
+ const cleanupRunningTest = addRunningTest(test);
1551
+ setCurrentTest(test);
1552
+ const suite = test.suite || test.file;
1553
+ const repeats = test.repeats ?? 0;
1554
+ for (let repeatCount = 0; repeatCount <= repeats; repeatCount++) {
1555
+ const retry = test.retry ?? 0;
1556
+ for (let retryCount = 0; retryCount <= retry; retryCount++) {
1557
+ var _test$result2, _test$result3;
1558
+ let beforeEachCleanups = [];
1559
+ try {
1560
+ var _runner$onBeforeTryTa, _runner$onAfterTryTas;
1561
+ await ((_runner$onBeforeTryTa = runner.onBeforeTryTask) === null || _runner$onBeforeTryTa === void 0 ? void 0 : _runner$onBeforeTryTa.call(runner, test, {
1562
+ retry: retryCount,
1563
+ repeats: repeatCount
1564
+ }));
1565
+ test.result.repeatCount = repeatCount;
1566
+ beforeEachCleanups = await callSuiteHook(suite, test, "beforeEach", runner, [test.context, suite]);
1567
+ if (runner.runTask) {
1568
+ await runner.runTask(test);
1569
+ } else {
1570
+ const fn = getFn(test);
1571
+ if (!fn) {
1572
+ throw new Error("Test function is not found. Did you add it using `setFn`?");
1573
+ }
1574
+ await fn();
1575
+ }
1576
+ await ((_runner$onAfterTryTas = runner.onAfterTryTask) === null || _runner$onAfterTryTas === void 0 ? void 0 : _runner$onAfterTryTas.call(runner, test, {
1577
+ retry: retryCount,
1578
+ repeats: repeatCount
1579
+ }));
1580
+ if (test.result.state !== "fail") {
1581
+ if (!test.repeats) {
1582
+ test.result.state = "pass";
1583
+ } else if (test.repeats && retry === retryCount) {
1584
+ test.result.state = "pass";
1585
+ }
1586
+ }
1587
+ } catch (e) {
1588
+ failTask(test.result, e, runner.config.diffOptions);
1589
+ }
1590
+ try {
1591
+ var _runner$onTaskFinishe;
1592
+ await ((_runner$onTaskFinishe = runner.onTaskFinished) === null || _runner$onTaskFinishe === void 0 ? void 0 : _runner$onTaskFinishe.call(runner, test));
1593
+ } catch (e) {
1594
+ failTask(test.result, e, runner.config.diffOptions);
1595
+ }
1596
+ try {
1597
+ await callSuiteHook(suite, test, "afterEach", runner, [test.context, suite]);
1598
+ await callCleanupHooks(runner, beforeEachCleanups);
1599
+ await callFixtureCleanup(test.context);
1600
+ } catch (e) {
1601
+ failTask(test.result, e, runner.config.diffOptions);
1602
+ }
1603
+ await callTestHooks(runner, test, test.onFinished || [], "stack");
1604
+ if (test.result.state === "fail") {
1605
+ await callTestHooks(runner, test, test.onFailed || [], runner.config.sequence.hooks);
1606
+ }
1607
+ test.onFailed = undefined;
1608
+ test.onFinished = undefined;
1609
+ // skipped with new PendingError
1610
+ if (((_test$result2 = test.result) === null || _test$result2 === void 0 ? void 0 : _test$result2.pending) || ((_test$result3 = test.result) === null || _test$result3 === void 0 ? void 0 : _test$result3.state) === "skip") {
1611
+ var _test$result4;
1612
+ test.mode = "skip";
1613
+ test.result = {
1614
+ state: "skip",
1615
+ note: (_test$result4 = test.result) === null || _test$result4 === void 0 ? void 0 : _test$result4.note,
1616
+ pending: true,
1617
+ duration: now$1() - start
1618
+ };
1619
+ updateTask("test-finished", test, runner);
1620
+ setCurrentTest(undefined);
1621
+ cleanupRunningTest();
1622
+ return;
1623
+ }
1624
+ if (test.result.state === "pass") {
1625
+ break;
1626
+ }
1627
+ if (retryCount < retry) {
1628
+ // reset state when retry test
1629
+ test.result.state = "run";
1630
+ test.result.retryCount = (test.result.retryCount ?? 0) + 1;
1631
+ }
1632
+ // update retry info
1633
+ updateTask("test-retried", test, runner);
1634
+ }
1635
+ }
1636
+ // if test is marked to be failed, flip the result
1637
+ if (test.fails) {
1638
+ if (test.result.state === "pass") {
1639
+ const error = processError(new Error("Expect test to fail"));
1640
+ test.result.state = "fail";
1641
+ test.result.errors = [error];
1642
+ } else {
1643
+ test.result.state = "pass";
1644
+ test.result.errors = undefined;
1645
+ }
1646
+ }
1647
+ cleanupRunningTest();
1648
+ setCurrentTest(undefined);
1649
+ test.result.duration = now$1() - start;
1650
+ await ((_runner$onAfterRunTas = runner.onAfterRunTask) === null || _runner$onAfterRunTas === void 0 ? void 0 : _runner$onAfterRunTas.call(runner, test));
1651
+ updateTask("test-finished", test, runner);
1652
+ }
1653
+ function failTask(result, err, diffOptions) {
1654
+ if (err instanceof PendingError) {
1655
+ result.state = "skip";
1656
+ result.note = err.note;
1657
+ result.pending = true;
1658
+ return;
1659
+ }
1660
+ result.state = "fail";
1661
+ const errors = Array.isArray(err) ? err : [err];
1662
+ for (const e of errors) {
1663
+ const error = processError(e, diffOptions);
1664
+ result.errors ?? (result.errors = []);
1665
+ result.errors.push(error);
1666
+ }
1667
+ }
1668
+ function markTasksAsSkipped(suite, runner) {
1669
+ suite.tasks.forEach((t) => {
1670
+ t.mode = "skip";
1671
+ t.result = {
1672
+ ...t.result,
1673
+ state: "skip"
1674
+ };
1675
+ updateTask("test-finished", t, runner);
1676
+ if (t.type === "suite") {
1677
+ markTasksAsSkipped(t, runner);
1678
+ }
1679
+ });
1680
+ }
1681
+ async function runSuite(suite, runner) {
1682
+ var _runner$onBeforeRunSu, _suite$result;
1683
+ await ((_runner$onBeforeRunSu = runner.onBeforeRunSuite) === null || _runner$onBeforeRunSu === void 0 ? void 0 : _runner$onBeforeRunSu.call(runner, suite));
1684
+ if (((_suite$result = suite.result) === null || _suite$result === void 0 ? void 0 : _suite$result.state) === "fail") {
1685
+ markTasksAsSkipped(suite, runner);
1686
+ // failed during collection
1687
+ updateTask("suite-failed-early", suite, runner);
1688
+ return;
1689
+ }
1690
+ const start = now$1();
1691
+ const mode = suite.mode;
1692
+ suite.result = {
1693
+ state: mode === "skip" || mode === "todo" ? mode : "run",
1694
+ startTime: unixNow()
1695
+ };
1696
+ updateTask("suite-prepare", suite, runner);
1697
+ let beforeAllCleanups = [];
1698
+ if (suite.mode === "skip") {
1699
+ suite.result.state = "skip";
1700
+ updateTask("suite-finished", suite, runner);
1701
+ } else if (suite.mode === "todo") {
1702
+ suite.result.state = "todo";
1703
+ updateTask("suite-finished", suite, runner);
1704
+ } else {
1705
+ var _runner$onAfterRunSui;
1706
+ try {
1707
+ try {
1708
+ beforeAllCleanups = await callSuiteHook(suite, suite, "beforeAll", runner, [suite]);
1709
+ } catch (e) {
1710
+ markTasksAsSkipped(suite, runner);
1711
+ throw e;
1712
+ }
1713
+ if (runner.runSuite) {
1714
+ await runner.runSuite(suite);
1715
+ } else {
1716
+ for (let tasksGroup of partitionSuiteChildren(suite)) {
1717
+ if (tasksGroup[0].concurrent === true) {
1718
+ await Promise.all(tasksGroup.map((c) => runSuiteChild(c, runner)));
1719
+ } else {
1720
+ const { sequence } = runner.config;
1721
+ if (suite.shuffle) {
1722
+ // run describe block independently from tests
1723
+ const suites = tasksGroup.filter((group) => group.type === "suite");
1724
+ const tests = tasksGroup.filter((group) => group.type === "test");
1725
+ const groups = shuffle([suites, tests], sequence.seed);
1726
+ tasksGroup = groups.flatMap((group) => shuffle(group, sequence.seed));
1727
+ }
1728
+ for (const c of tasksGroup) {
1729
+ await runSuiteChild(c, runner);
1730
+ }
1731
+ }
1732
+ }
1733
+ }
1734
+ } catch (e) {
1735
+ failTask(suite.result, e, runner.config.diffOptions);
1736
+ }
1737
+ try {
1738
+ await callSuiteHook(suite, suite, "afterAll", runner, [suite]);
1739
+ await callCleanupHooks(runner, beforeAllCleanups);
1740
+ if (suite.file === suite) {
1741
+ const context = getFileContext(suite);
1742
+ await callFixtureCleanup(context);
1743
+ }
1744
+ } catch (e) {
1745
+ failTask(suite.result, e, runner.config.diffOptions);
1746
+ }
1747
+ if (suite.mode === "run" || suite.mode === "queued") {
1748
+ if (!runner.config.passWithNoTests && !hasTests(suite)) {
1749
+ var _suite$result$errors;
1750
+ suite.result.state = "fail";
1751
+ if (!((_suite$result$errors = suite.result.errors) === null || _suite$result$errors === void 0 ? void 0 : _suite$result$errors.length)) {
1752
+ const error = processError(new Error(`No test found in suite ${suite.name}`));
1753
+ suite.result.errors = [error];
1754
+ }
1755
+ } else if (hasFailed(suite)) {
1756
+ suite.result.state = "fail";
1757
+ } else {
1758
+ suite.result.state = "pass";
1759
+ }
1760
+ }
1761
+ suite.result.duration = now$1() - start;
1762
+ updateTask("suite-finished", suite, runner);
1763
+ await ((_runner$onAfterRunSui = runner.onAfterRunSuite) === null || _runner$onAfterRunSui === void 0 ? void 0 : _runner$onAfterRunSui.call(runner, suite));
1764
+ }
1765
+ }
1766
+ let limitMaxConcurrency;
1767
+ async function runSuiteChild(c, runner) {
1768
+ if (c.type === "test") {
1769
+ return limitMaxConcurrency(() => runTest(c, runner));
1770
+ } else if (c.type === "suite") {
1771
+ return runSuite(c, runner);
1772
+ }
1773
+ }
1774
+ async function runFiles(files, runner) {
1775
+ limitMaxConcurrency ?? (limitMaxConcurrency = limitConcurrency(runner.config.maxConcurrency));
1776
+ for (const file of files) {
1777
+ if (!file.tasks.length && !runner.config.passWithNoTests) {
1778
+ var _file$result;
1779
+ if (!((_file$result = file.result) === null || _file$result === void 0 || (_file$result = _file$result.errors) === null || _file$result === void 0 ? void 0 : _file$result.length)) {
1780
+ const error = processError(new Error(`No test suite found in file ${file.filepath}`));
1781
+ file.result = {
1782
+ state: "fail",
1783
+ errors: [error]
1784
+ };
1785
+ }
1786
+ }
1787
+ await runSuite(file, runner);
1788
+ }
1789
+ }
1790
+ const workerRunners = new WeakSet();
1791
+ async function startTests(specs, runner) {
1792
+ var _runner$cancel;
1793
+ const cancel = (_runner$cancel = runner.cancel) === null || _runner$cancel === void 0 ? void 0 : _runner$cancel.bind(runner);
1794
+ // Ideally, we need to have an event listener for this, but only have a runner here.
1795
+ // Adding another onCancel felt wrong (maybe it needs to be refactored)
1796
+ runner.cancel = (reason) => {
1797
+ // We intentionally create only one error since there is only one test run that can be cancelled
1798
+ const error = new TestRunAbortError("The test run was aborted by the user.", reason);
1799
+ getRunningTests().forEach((test) => abortContextSignal(test.context, error));
1800
+ return cancel === null || cancel === void 0 ? void 0 : cancel(reason);
1801
+ };
1802
+ if (!workerRunners.has(runner)) {
1803
+ var _runner$onCleanupWork;
1804
+ (_runner$onCleanupWork = runner.onCleanupWorkerContext) === null || _runner$onCleanupWork === void 0 ? void 0 : _runner$onCleanupWork.call(runner, async () => {
1805
+ var _runner$getWorkerCont;
1806
+ const context = (_runner$getWorkerCont = runner.getWorkerContext) === null || _runner$getWorkerCont === void 0 ? void 0 : _runner$getWorkerCont.call(runner);
1807
+ if (context) {
1808
+ await callFixtureCleanup(context);
1809
+ }
1810
+ });
1811
+ workerRunners.add(runner);
1812
+ }
1813
+ try {
1814
+ var _runner$onBeforeColle, _runner$onCollected, _runner$onBeforeRunFi, _runner$onAfterRunFil;
1815
+ const paths = specs.map((f) => typeof f === "string" ? f : f.filepath);
1816
+ await ((_runner$onBeforeColle = runner.onBeforeCollect) === null || _runner$onBeforeColle === void 0 ? void 0 : _runner$onBeforeColle.call(runner, paths));
1817
+ const files = await collectTests(specs, runner);
1818
+ await ((_runner$onCollected = runner.onCollected) === null || _runner$onCollected === void 0 ? void 0 : _runner$onCollected.call(runner, files));
1819
+ await ((_runner$onBeforeRunFi = runner.onBeforeRunFiles) === null || _runner$onBeforeRunFi === void 0 ? void 0 : _runner$onBeforeRunFi.call(runner, files));
1820
+ await runFiles(files, runner);
1821
+ await ((_runner$onAfterRunFil = runner.onAfterRunFiles) === null || _runner$onAfterRunFil === void 0 ? void 0 : _runner$onAfterRunFil.call(runner, files));
1822
+ await finishSendTasksUpdate(runner);
1823
+ return files;
1824
+ } finally {
1825
+ runner.cancel = cancel;
1826
+ }
1827
+ }
1828
+ async function publicCollect(specs, runner) {
1829
+ var _runner$onBeforeColle2, _runner$onCollected2;
1830
+ const paths = specs.map((f) => typeof f === "string" ? f : f.filepath);
1831
+ await ((_runner$onBeforeColle2 = runner.onBeforeCollect) === null || _runner$onBeforeColle2 === void 0 ? void 0 : _runner$onBeforeColle2.call(runner, paths));
1832
+ const files = await collectTests(specs, runner);
1833
+ await ((_runner$onCollected2 = runner.onCollected) === null || _runner$onCollected2 === void 0 ? void 0 : _runner$onCollected2.call(runner, files));
1834
+ return files;
1835
+ }
1836
+
1837
+ const now = Date.now;
1838
+ const collectorContext = {
1839
+ tasks: [],
1840
+ currentSuite: null
1841
+ };
1842
+ function collectTask(task) {
1843
+ var _collectorContext$cur;
1844
+ (_collectorContext$cur = collectorContext.currentSuite) === null || _collectorContext$cur === void 0 ? void 0 : _collectorContext$cur.tasks.push(task);
1845
+ }
1846
+ async function runWithSuite(suite, fn) {
1847
+ const prev = collectorContext.currentSuite;
1848
+ collectorContext.currentSuite = suite;
1849
+ await fn();
1850
+ collectorContext.currentSuite = prev;
1851
+ }
1852
+ function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
1853
+ if (timeout <= 0 || timeout === Number.POSITIVE_INFINITY) {
1854
+ return fn;
1855
+ }
1856
+ const { setTimeout, clearTimeout } = getSafeTimers();
1857
+ // this function name is used to filter error in test/cli/test/fails.test.ts
1858
+ return function runWithTimeout(...args) {
1859
+ const startTime = now();
1860
+ const runner = getRunner();
1861
+ runner._currentTaskStartTime = startTime;
1862
+ runner._currentTaskTimeout = timeout;
1863
+ return new Promise((resolve_, reject_) => {
1864
+ var _timer$unref;
1865
+ const timer = setTimeout(() => {
1866
+ clearTimeout(timer);
1867
+ rejectTimeoutError();
1868
+ }, timeout);
1869
+ // `unref` might not exist in browser
1870
+ (_timer$unref = timer.unref) === null || _timer$unref === void 0 ? void 0 : _timer$unref.call(timer);
1871
+ function rejectTimeoutError() {
1872
+ const error = makeTimeoutError(isHook, timeout, stackTraceError);
1873
+ onTimeout === null || onTimeout === void 0 ? void 0 : onTimeout(args, error);
1874
+ reject_(error);
1875
+ }
1876
+ function resolve(result) {
1877
+ runner._currentTaskStartTime = undefined;
1878
+ runner._currentTaskTimeout = undefined;
1879
+ clearTimeout(timer);
1880
+ // if test/hook took too long in microtask, setTimeout won't be triggered,
1881
+ // but we still need to fail the test, see
1882
+ // https://github.com/vitest-dev/vitest/issues/2920
1883
+ if (now() - startTime >= timeout) {
1884
+ rejectTimeoutError();
1885
+ return;
1886
+ }
1887
+ resolve_(result);
1888
+ }
1889
+ function reject(error) {
1890
+ runner._currentTaskStartTime = undefined;
1891
+ runner._currentTaskTimeout = undefined;
1892
+ clearTimeout(timer);
1893
+ reject_(error);
1894
+ }
1895
+ // sync test/hook will be caught by try/catch
1896
+ try {
1897
+ const result = fn(...args);
1898
+ // the result is a thenable, we don't wrap this in Promise.resolve
1899
+ // to avoid creating new promises
1900
+ if (typeof result === "object" && result != null && typeof result.then === "function") {
1901
+ result.then(resolve, reject);
1902
+ } else {
1903
+ resolve(result);
1904
+ }
1905
+ }
1906
+ // user sync test/hook throws an error
1907
+ catch (error) {
1908
+ reject(error);
1909
+ }
1910
+ });
1911
+ };
1912
+ }
1913
+ const abortControllers = new WeakMap();
1914
+ function abortIfTimeout([context], error) {
1915
+ if (context) {
1916
+ abortContextSignal(context, error);
1917
+ }
1918
+ }
1919
+ function abortContextSignal(context, error) {
1920
+ const abortController = abortControllers.get(context);
1921
+ abortController === null || abortController === void 0 ? void 0 : abortController.abort(error);
1922
+ }
1923
+ function createTestContext(test, runner) {
1924
+ var _runner$extendTaskCon;
1925
+ const context = function() {
1926
+ throw new Error("done() callback is deprecated, use promise instead");
1927
+ };
1928
+ let abortController = abortControllers.get(context);
1929
+ if (!abortController) {
1930
+ abortController = new AbortController();
1931
+ abortControllers.set(context, abortController);
1932
+ }
1933
+ context.signal = abortController.signal;
1934
+ context.task = test;
1935
+ context.skip = (condition, note) => {
1936
+ if (condition === false) {
1937
+ // do nothing
1938
+ return undefined;
1939
+ }
1940
+ test.result ?? (test.result = { state: "skip" });
1941
+ test.result.pending = true;
1942
+ throw new PendingError("test is skipped; abort execution", test, typeof condition === "string" ? condition : note);
1943
+ };
1944
+ async function annotate(message, location, type, attachment) {
1945
+ const annotation = {
1946
+ message,
1947
+ type: type || "notice"
1948
+ };
1949
+ if (attachment) {
1950
+ if (!attachment.body && !attachment.path) {
1951
+ throw new TypeError(`Test attachment requires body or path to be set. Both are missing.`);
1952
+ }
1953
+ if (attachment.body && attachment.path) {
1954
+ throw new TypeError(`Test attachment requires only one of "body" or "path" to be set. Both are specified.`);
1955
+ }
1956
+ annotation.attachment = attachment;
1957
+ // convert to a string so it's easier to serialise
1958
+ if (attachment.body instanceof Uint8Array) {
1959
+ attachment.body = encodeUint8Array(attachment.body);
1960
+ }
1961
+ }
1962
+ if (location) {
1963
+ annotation.location = location;
1964
+ }
1965
+ if (!runner.onTestAnnotate) {
1966
+ throw new Error(`Test runner doesn't support test annotations.`);
1967
+ }
1968
+ await finishSendTasksUpdate(runner);
1969
+ const resolvedAnnotation = await runner.onTestAnnotate(test, annotation);
1970
+ test.annotations.push(resolvedAnnotation);
1971
+ return resolvedAnnotation;
1972
+ }
1973
+ context.annotate = (message, type, attachment) => {
1974
+ if (test.result && test.result.state !== "run") {
1975
+ throw new Error(`Cannot annotate tests outside of the test run. The test "${test.name}" finished running with the "${test.result.state}" state already.`);
1976
+ }
1977
+ let location;
1978
+ const stack = new Error("STACK_TRACE").stack;
1979
+ const index = stack.includes("STACK_TRACE") ? 2 : 1;
1980
+ const stackLine = stack.split("\n")[index];
1981
+ const parsed = parseSingleStack(stackLine);
1982
+ if (parsed) {
1983
+ location = {
1984
+ file: parsed.file,
1985
+ line: parsed.line,
1986
+ column: parsed.column
1987
+ };
1988
+ }
1989
+ if (typeof type === "object") {
1990
+ return recordAsyncAnnotation(test, annotate(message, location, undefined, type));
1991
+ } else {
1992
+ return recordAsyncAnnotation(test, annotate(message, location, type, attachment));
1993
+ }
1994
+ };
1995
+ context.onTestFailed = (handler, timeout) => {
1996
+ test.onFailed || (test.onFailed = []);
1997
+ test.onFailed.push(withTimeout(handler, timeout ?? runner.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
1998
+ };
1999
+ context.onTestFinished = (handler, timeout) => {
2000
+ test.onFinished || (test.onFinished = []);
2001
+ test.onFinished.push(withTimeout(handler, timeout ?? runner.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
2002
+ };
2003
+ return ((_runner$extendTaskCon = runner.extendTaskContext) === null || _runner$extendTaskCon === void 0 ? void 0 : _runner$extendTaskCon.call(runner, context)) || context;
2004
+ }
2005
+ function makeTimeoutError(isHook, timeout, stackTraceError) {
2006
+ const message = `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.\nIf this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
2007
+ const error = new Error(message);
2008
+ if (stackTraceError === null || stackTraceError === void 0 ? void 0 : stackTraceError.stack) {
2009
+ error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
2010
+ }
2011
+ return error;
2012
+ }
2013
+ const fileContexts = new WeakMap();
2014
+ function getFileContext(file) {
2015
+ const context = fileContexts.get(file);
2016
+ if (!context) {
2017
+ throw new Error(`Cannot find file context for ${file.name}`);
2018
+ }
2019
+ return context;
2020
+ }
2021
+ function setFileContext(file, context) {
2022
+ fileContexts.set(file, context);
2023
+ }
2024
+ const table = [];
2025
+ for (let i = 65; i < 91; i++) {
2026
+ table.push(String.fromCharCode(i));
2027
+ }
2028
+ for (let i = 97; i < 123; i++) {
2029
+ table.push(String.fromCharCode(i));
2030
+ }
2031
+ for (let i = 0; i < 10; i++) {
2032
+ table.push(i.toString(10));
2033
+ }
2034
+ function encodeUint8Array(bytes) {
2035
+ let base64 = "";
2036
+ const len = bytes.byteLength;
2037
+ for (let i = 0; i < len; i += 3) {
2038
+ if (len === i + 1) {
2039
+ const a = (bytes[i] & 252) >> 2;
2040
+ const b = (bytes[i] & 3) << 4;
2041
+ base64 += table[a];
2042
+ base64 += table[b];
2043
+ base64 += "==";
2044
+ } else if (len === i + 2) {
2045
+ const a = (bytes[i] & 252) >> 2;
2046
+ const b = (bytes[i] & 3) << 4 | (bytes[i + 1] & 240) >> 4;
2047
+ const c = (bytes[i + 1] & 15) << 2;
2048
+ base64 += table[a];
2049
+ base64 += table[b];
2050
+ base64 += table[c];
2051
+ base64 += "=";
2052
+ } else {
2053
+ const a = (bytes[i] & 252) >> 2;
2054
+ const b = (bytes[i] & 3) << 4 | (bytes[i + 1] & 240) >> 4;
2055
+ const c = (bytes[i + 1] & 15) << 2 | (bytes[i + 2] & 192) >> 6;
2056
+ const d = bytes[i + 2] & 63;
2057
+ base64 += table[a];
2058
+ base64 += table[b];
2059
+ base64 += table[c];
2060
+ base64 += table[d];
2061
+ }
2062
+ }
2063
+ return base64;
2064
+ }
2065
+ function recordAsyncAnnotation(test, promise) {
2066
+ // if promise is explicitly awaited, remove it from the list
2067
+ promise = promise.finally(() => {
2068
+ if (!test.promises) {
2069
+ return;
2070
+ }
2071
+ const index = test.promises.indexOf(promise);
2072
+ if (index !== -1) {
2073
+ test.promises.splice(index, 1);
2074
+ }
2075
+ });
2076
+ // record promise
2077
+ if (!test.promises) {
2078
+ test.promises = [];
2079
+ }
2080
+ test.promises.push(promise);
2081
+ return promise;
2082
+ }
2083
+
2084
+ function getDefaultHookTimeout() {
2085
+ return getRunner().config.hookTimeout;
2086
+ }
2087
+ const CLEANUP_TIMEOUT_KEY = Symbol.for("VITEST_CLEANUP_TIMEOUT");
2088
+ const CLEANUP_STACK_TRACE_KEY = Symbol.for("VITEST_CLEANUP_STACK_TRACE");
2089
+ function getBeforeHookCleanupCallback(hook, result, context) {
2090
+ if (typeof result === "function") {
2091
+ const timeout = CLEANUP_TIMEOUT_KEY in hook && typeof hook[CLEANUP_TIMEOUT_KEY] === "number" ? hook[CLEANUP_TIMEOUT_KEY] : getDefaultHookTimeout();
2092
+ const stackTraceError = CLEANUP_STACK_TRACE_KEY in hook && hook[CLEANUP_STACK_TRACE_KEY] instanceof Error ? hook[CLEANUP_STACK_TRACE_KEY] : undefined;
2093
+ return withTimeout(result, timeout, true, stackTraceError, (_, error) => {
2094
+ if (context) {
2095
+ abortContextSignal(context, error);
2096
+ }
2097
+ });
2098
+ }
2099
+ }
2100
+ /**
2101
+ * Registers a callback function to be executed once before all tests within the current suite.
2102
+ * This hook is useful for scenarios where you need to perform setup operations that are common to all tests in a suite, such as initializing a database connection or setting up a test environment.
2103
+ *
2104
+ * **Note:** The `beforeAll` hooks are executed in the order they are defined one after another. You can configure this by changing the `sequence.hooks` option in the config file.
2105
+ *
2106
+ * @param {Function} fn - The callback function to be executed before all tests.
2107
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2108
+ * @returns {void}
2109
+ * @example
2110
+ * ```ts
2111
+ * // Example of using beforeAll to set up a database connection
2112
+ * beforeAll(async () => {
2113
+ * await database.connect();
2114
+ * });
2115
+ * ```
2116
+ */
2117
+ function beforeAll(fn, timeout = getDefaultHookTimeout()) {
2118
+ assertTypes(fn, "\"beforeAll\" callback", ["function"]);
2119
+ const stackTraceError = new Error("STACK_TRACE_ERROR");
2120
+ return getCurrentSuite().on("beforeAll", Object.assign(withTimeout(fn, timeout, true, stackTraceError), {
2121
+ [CLEANUP_TIMEOUT_KEY]: timeout,
2122
+ [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2123
+ }));
2124
+ }
2125
+ /**
2126
+ * Registers a callback function to be executed once after all tests within the current suite have completed.
2127
+ * This hook is useful for scenarios where you need to perform cleanup operations after all tests in a suite have run, such as closing database connections or cleaning up temporary files.
2128
+ *
2129
+ * **Note:** The `afterAll` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
2130
+ *
2131
+ * @param {Function} fn - The callback function to be executed after all tests.
2132
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2133
+ * @returns {void}
2134
+ * @example
2135
+ * ```ts
2136
+ * // Example of using afterAll to close a database connection
2137
+ * afterAll(async () => {
2138
+ * await database.disconnect();
2139
+ * });
2140
+ * ```
2141
+ */
2142
+ function afterAll(fn, timeout) {
2143
+ assertTypes(fn, "\"afterAll\" callback", ["function"]);
2144
+ return getCurrentSuite().on("afterAll", withTimeout(fn, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR")));
2145
+ }
2146
+ /**
2147
+ * Registers a callback function to be executed before each test within the current suite.
2148
+ * This hook is useful for scenarios where you need to reset or reinitialize the test environment before each test runs, such as resetting database states, clearing caches, or reinitializing variables.
2149
+ *
2150
+ * **Note:** The `beforeEach` hooks are executed in the order they are defined one after another. You can configure this by changing the `sequence.hooks` option in the config file.
2151
+ *
2152
+ * @param {Function} fn - The callback function to be executed before each test. This function receives an `TestContext` parameter if additional test context is needed.
2153
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2154
+ * @returns {void}
2155
+ * @example
2156
+ * ```ts
2157
+ * // Example of using beforeEach to reset a database state
2158
+ * beforeEach(async () => {
2159
+ * await database.reset();
2160
+ * });
2161
+ * ```
2162
+ */
2163
+ function beforeEach(fn, timeout = getDefaultHookTimeout()) {
2164
+ assertTypes(fn, "\"beforeEach\" callback", ["function"]);
2165
+ const stackTraceError = new Error("STACK_TRACE_ERROR");
2166
+ const runner = getRunner();
2167
+ return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(withFixtures(runner, fn), timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
2168
+ [CLEANUP_TIMEOUT_KEY]: timeout,
2169
+ [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2170
+ }));
2171
+ }
2172
+ /**
2173
+ * Registers a callback function to be executed after each test within the current suite has completed.
2174
+ * This hook is useful for scenarios where you need to clean up or reset the test environment after each test runs, such as deleting temporary files, clearing test-specific database entries, or resetting mocked functions.
2175
+ *
2176
+ * **Note:** The `afterEach` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
2177
+ *
2178
+ * @param {Function} fn - The callback function to be executed after each test. This function receives an `TestContext` parameter if additional test context is needed.
2179
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2180
+ * @returns {void}
2181
+ * @example
2182
+ * ```ts
2183
+ * // Example of using afterEach to delete temporary files created during a test
2184
+ * afterEach(async () => {
2185
+ * await fileSystem.deleteTempFiles();
2186
+ * });
2187
+ * ```
2188
+ */
2189
+ function afterEach(fn, timeout) {
2190
+ assertTypes(fn, "\"afterEach\" callback", ["function"]);
2191
+ const runner = getRunner();
2192
+ return getCurrentSuite().on("afterEach", withTimeout(withFixtures(runner, fn), timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2193
+ }
2194
+ /**
2195
+ * Registers a callback function to be executed when a test fails within the current suite.
2196
+ * This function allows for custom actions to be performed in response to test failures, such as logging, cleanup, or additional diagnostics.
2197
+ *
2198
+ * **Note:** The `onTestFailed` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
2199
+ *
2200
+ * @param {Function} fn - The callback function to be executed upon a test failure. The function receives the test result (including errors).
2201
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2202
+ * @throws {Error} Throws an error if the function is not called within a test.
2203
+ * @returns {void}
2204
+ * @example
2205
+ * ```ts
2206
+ * // Example of using onTestFailed to log failure details
2207
+ * onTestFailed(({ errors }) => {
2208
+ * console.log(`Test failed: ${test.name}`, errors);
2209
+ * });
2210
+ * ```
2211
+ */
2212
+ const onTestFailed = createTestHook("onTestFailed", (test, handler, timeout) => {
2213
+ test.onFailed || (test.onFailed = []);
2214
+ test.onFailed.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2215
+ });
2216
+ /**
2217
+ * Registers a callback function to be executed when the current test finishes, regardless of the outcome (pass or fail).
2218
+ * This function is ideal for performing actions that should occur after every test execution, such as cleanup, logging, or resetting shared resources.
2219
+ *
2220
+ * This hook is useful if you have access to a resource in the test itself and you want to clean it up after the test finishes. It is a more compact way to clean up resources than using the combination of `beforeEach` and `afterEach`.
2221
+ *
2222
+ * **Note:** The `onTestFinished` hooks are running in reverse order of their registration. You can configure this by changing the `sequence.hooks` option in the config file.
2223
+ *
2224
+ * **Note:** The `onTestFinished` hook is not called if the test is canceled with a dynamic `ctx.skip()` call.
2225
+ *
2226
+ * @param {Function} fn - The callback function to be executed after a test finishes. The function can receive parameters providing details about the completed test, including its success or failure status.
2227
+ * @param {number} [timeout] - Optional timeout in milliseconds for the hook. If not provided, the default hook timeout from the runner's configuration is used.
2228
+ * @throws {Error} Throws an error if the function is not called within a test.
2229
+ * @returns {void}
2230
+ * @example
2231
+ * ```ts
2232
+ * // Example of using onTestFinished for cleanup
2233
+ * const db = await connectToDatabase();
2234
+ * onTestFinished(async () => {
2235
+ * await db.disconnect();
2236
+ * });
2237
+ * ```
2238
+ */
2239
+ const onTestFinished = createTestHook("onTestFinished", (test, handler, timeout) => {
2240
+ test.onFinished || (test.onFinished = []);
2241
+ test.onFinished.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2242
+ });
2243
+ function createTestHook(name, handler) {
2244
+ return (fn, timeout) => {
2245
+ assertTypes(fn, `"${name}" callback`, ["function"]);
2246
+ const current = getCurrentTest();
2247
+ if (!current) {
2248
+ throw new Error(`Hook ${name}() can only be called inside a test`);
2249
+ }
2250
+ return handler(current, fn, timeout);
2251
+ };
2252
+ }
2253
+
2254
+ export { someTasksAreOnly as A, limitConcurrency as B, partitionSuiteChildren as C, getFullName as D, getNames as E, getSuites as F, getTasks as G, getTestName as H, getTests as I, hasFailed as J, hasTests as K, isAtomTest as L, isTestCase as M, afterAll as a, afterEach as b, beforeAll as c, beforeEach as d, onTestFinished as e, getHooks as f, getFn as g, setHooks as h, startTests as i, createTaskCollector as j, describe as k, getCurrentSuite as l, it as m, suite as n, onTestFailed as o, publicCollect as p, getCurrentTest as q, createChainable as r, setFn as s, test as t, updateTask as u, calculateSuiteHash as v, createFileTask as w, generateFileHash as x, generateHash as y, interpretTaskModes as z };