@ddwang/magnitude-core 0.3.1-ddwang.2 → 0.3.1-ddwang.21

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 (363) hide show
  1. package/dist/cli.cjs +2 -0
  2. package/dist/cli.cjs.map +1 -0
  3. package/dist/cli.d.cts +2 -0
  4. package/dist/cli.d.ts +2 -0
  5. package/dist/cli.mjs +1 -0
  6. package/dist/cli.mjs.map +1 -0
  7. package/dist/index.cjs +2704 -1522
  8. package/dist/index.cjs.map +1 -0
  9. package/dist/index.d.cts +188 -50
  10. package/dist/index.d.ts +1147 -23
  11. package/dist/index.mjs +2527 -1362
  12. package/dist/index.mjs.map +1 -0
  13. package/node_modules/patchright-core/README.md +3 -0
  14. package/node_modules/patchright-core/ThirdPartyNotices.txt +13 -0
  15. package/node_modules/patchright-core/bin/install_media_pack.ps1 +5 -0
  16. package/node_modules/patchright-core/bin/install_webkit_wsl.ps1 +33 -0
  17. package/node_modules/patchright-core/bin/reinstall_chrome_beta_linux.sh +42 -0
  18. package/node_modules/patchright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
  19. package/node_modules/patchright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
  20. package/node_modules/patchright-core/bin/reinstall_chrome_stable_linux.sh +42 -0
  21. package/node_modules/patchright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
  22. package/node_modules/patchright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
  23. package/node_modules/patchright-core/bin/reinstall_msedge_beta_linux.sh +48 -0
  24. package/node_modules/patchright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
  25. package/node_modules/patchright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
  26. package/node_modules/patchright-core/bin/reinstall_msedge_dev_linux.sh +48 -0
  27. package/node_modules/patchright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
  28. package/node_modules/patchright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
  29. package/node_modules/patchright-core/bin/reinstall_msedge_stable_linux.sh +48 -0
  30. package/node_modules/patchright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
  31. package/node_modules/patchright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
  32. package/node_modules/patchright-core/browsers.json +52 -0
  33. package/node_modules/patchright-core/cli.js +22 -0
  34. package/node_modules/patchright-core/index.d.ts +17 -0
  35. package/node_modules/patchright-core/index.js +17 -0
  36. package/node_modules/patchright-core/index.mjs +28 -0
  37. package/node_modules/patchright-core/lib/bootstrap.js +149 -0
  38. package/node_modules/patchright-core/lib/coreBundle.js +80653 -0
  39. package/node_modules/patchright-core/lib/entry/cliDaemon.js +5 -0
  40. package/node_modules/patchright-core/lib/entry/dashboardApp.js +3 -0
  41. package/node_modules/patchright-core/lib/entry/mcp.js +10 -0
  42. package/node_modules/patchright-core/lib/entry/oopBrowserDownload.js +3 -0
  43. package/node_modules/patchright-core/lib/package.js +50 -0
  44. package/node_modules/patchright-core/lib/server/chromium/appIcon.png +0 -0
  45. package/node_modules/patchright-core/lib/server/electron/loader.js +112 -0
  46. package/node_modules/patchright-core/lib/serverRegistry.js +1939 -0
  47. package/node_modules/patchright-core/lib/serverRegistry.js.LICENSE +65 -0
  48. package/node_modules/patchright-core/lib/tools/cli-client/channelSessions.js +141 -0
  49. package/node_modules/patchright-core/lib/tools/cli-client/cli.js +7 -0
  50. package/node_modules/patchright-core/lib/tools/cli-client/help.json +808 -0
  51. package/node_modules/patchright-core/lib/tools/cli-client/minimist.js +128 -0
  52. package/node_modules/patchright-core/lib/tools/cli-client/output.js +352 -0
  53. package/node_modules/patchright-core/lib/tools/cli-client/program.js +422 -0
  54. package/node_modules/patchright-core/lib/tools/cli-client/registry.js +180 -0
  55. package/node_modules/patchright-core/lib/tools/cli-client/session.js +261 -0
  56. package/node_modules/patchright-core/lib/tools/dashboard/appIcon.png +0 -0
  57. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/SKILL.md +493 -0
  58. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
  59. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
  60. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
  61. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
  62. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
  63. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
  64. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
  65. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
  66. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
  67. package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
  68. package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
  69. package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
  70. package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
  71. package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
  72. package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
  73. package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
  74. package/node_modules/patchright-core/lib/tools/skills/playwright-trace/SKILL.md +174 -0
  75. package/node_modules/patchright-core/lib/tools/utils/extension.js +112 -0
  76. package/node_modules/patchright-core/lib/tools/utils/socketConnection.js +108 -0
  77. package/node_modules/patchright-core/lib/utilsBundle.js +86225 -0
  78. package/node_modules/patchright-core/lib/utilsBundle.js.LICENSE +1890 -0
  79. package/node_modules/patchright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
  80. package/node_modules/patchright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
  81. package/node_modules/patchright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
  82. package/node_modules/patchright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
  83. package/node_modules/patchright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
  84. package/node_modules/patchright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
  85. package/node_modules/patchright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
  86. package/node_modules/patchright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
  87. package/node_modules/patchright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
  88. package/node_modules/patchright-core/lib/vite/dashboard/index.html +29 -0
  89. package/node_modules/patchright-core/lib/vite/dashboard/playwright-logo.svg +24 -0
  90. package/node_modules/patchright-core/lib/vite/htmlReport/index.html +16 -0
  91. package/node_modules/patchright-core/lib/vite/htmlReport/report.css +2 -0
  92. package/node_modules/patchright-core/lib/vite/htmlReport/report.js +32 -0
  93. package/node_modules/patchright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
  94. package/node_modules/patchright-core/lib/vite/recorder/assets/codeMirrorModule-GBnsXk4c.js +32 -0
  95. package/node_modules/patchright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
  96. package/node_modules/patchright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
  97. package/node_modules/patchright-core/lib/vite/recorder/assets/index-CVDOfo-j.js +129 -0
  98. package/node_modules/patchright-core/lib/vite/recorder/index.html +29 -0
  99. package/node_modules/patchright-core/lib/vite/recorder/playwright-logo.svg +9 -0
  100. package/node_modules/patchright-core/lib/vite/traceViewer/assets/codeMirrorModule-G79327TW.js +32 -0
  101. package/node_modules/patchright-core/lib/vite/traceViewer/assets/defaultSettingsView-D9EV0iaS.js +184 -0
  102. package/node_modules/patchright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
  103. package/node_modules/patchright-core/lib/vite/traceViewer/assets/xtermModule-Al_u-Nk5.js +7 -0
  104. package/node_modules/patchright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
  105. package/node_modules/patchright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
  106. package/node_modules/patchright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
  107. package/node_modules/patchright-core/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
  108. package/node_modules/patchright-core/lib/vite/traceViewer/index.CMB2-c8e.js +1 -0
  109. package/node_modules/patchright-core/lib/vite/traceViewer/index.html +44 -0
  110. package/node_modules/patchright-core/lib/vite/traceViewer/manifest.webmanifest +16 -0
  111. package/node_modules/patchright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
  112. package/node_modules/patchright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
  113. package/node_modules/patchright-core/lib/vite/traceViewer/snapshot.html +10 -0
  114. package/node_modules/patchright-core/lib/vite/traceViewer/sw.bundle.js +4 -0
  115. package/node_modules/patchright-core/lib/vite/traceViewer/uiMode.C3yLoy2G.js +5 -0
  116. package/node_modules/patchright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
  117. package/node_modules/patchright-core/lib/vite/traceViewer/uiMode.html +18 -0
  118. package/node_modules/patchright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
  119. package/node_modules/patchright-core/lib/webp_codec.LICENSE +173 -0
  120. package/node_modules/patchright-core/lib/webp_codec.wasm +0 -0
  121. package/node_modules/patchright-core/lib/xdg-open +1267 -0
  122. package/node_modules/patchright-core/package.json +34 -0
  123. package/node_modules/patchright-core/types/protocol.d.ts +24776 -0
  124. package/node_modules/patchright-core/types/structs.d.ts +52 -0
  125. package/node_modules/patchright-core/types/types.d.ts +27167 -0
  126. package/node_modules/playwright/.bun-tag-91d746a6045e143f +0 -0
  127. package/node_modules/playwright/README.md +300 -0
  128. package/node_modules/playwright/ThirdPartyNotices.txt +14 -0
  129. package/node_modules/playwright/cli.js +19 -0
  130. package/node_modules/playwright/index.d.ts +17 -0
  131. package/node_modules/playwright/index.js +17 -0
  132. package/node_modules/playwright/index.mjs +18 -0
  133. package/node_modules/playwright/lib/agents/agentParser.js +89 -0
  134. package/node_modules/playwright/lib/agents/copilot-setup-steps.yml +34 -0
  135. package/node_modules/playwright/lib/agents/generateAgents.js +395 -0
  136. package/node_modules/playwright/lib/agents/playwright-test-coverage.prompt.md +31 -0
  137. package/node_modules/playwright/lib/agents/playwright-test-generate.prompt.md +8 -0
  138. package/node_modules/playwright/lib/agents/playwright-test-generator.agent.md +88 -0
  139. package/node_modules/playwright/lib/agents/playwright-test-heal.prompt.md +6 -0
  140. package/node_modules/playwright/lib/agents/playwright-test-healer.agent.md +56 -0
  141. package/node_modules/playwright/lib/agents/playwright-test-plan.prompt.md +9 -0
  142. package/node_modules/playwright/lib/agents/playwright-test-planner.agent.md +74 -0
  143. package/node_modules/playwright/lib/cli/reportActions.js +78 -0
  144. package/node_modules/playwright/lib/cli/testActions.js +217 -0
  145. package/node_modules/playwright/lib/common/index.js +2937 -0
  146. package/node_modules/playwright/lib/common/index.js.txt +33 -0
  147. package/node_modules/playwright/lib/errorContext.js +129 -0
  148. package/node_modules/playwright/lib/globals.js +58 -0
  149. package/node_modules/playwright/lib/index.js +827 -0
  150. package/node_modules/playwright/lib/isomorphic.js +260 -0
  151. package/node_modules/playwright/lib/isomorphic.js.txt +9 -0
  152. package/node_modules/playwright/lib/loader/loaderProcessEntry.js +34 -0
  153. package/node_modules/playwright/lib/loader/loaderProcessEntry.js.txt +9 -0
  154. package/node_modules/playwright/lib/matchers/expect.js +13496 -0
  155. package/node_modules/playwright/lib/matchers/expect.js.LICENSE +640 -0
  156. package/node_modules/playwright/lib/matchers/expect.js.txt +67 -0
  157. package/node_modules/playwright/lib/mcp/test/browserBackend.js +135 -0
  158. package/node_modules/playwright/lib/mcp/test/generatorTools.js +122 -0
  159. package/node_modules/playwright/lib/mcp/test/plannerTools.js +150 -0
  160. package/node_modules/playwright/lib/mcp/test/seed.js +82 -0
  161. package/node_modules/playwright/lib/mcp/test/streams.js +44 -0
  162. package/node_modules/playwright/lib/mcp/test/testBackend.js +99 -0
  163. package/node_modules/playwright/lib/mcp/test/testContext.js +306 -0
  164. package/node_modules/playwright/lib/mcp/test/testTool.js +30 -0
  165. package/node_modules/playwright/lib/mcp/test/testTools.js +98 -0
  166. package/node_modules/playwright/lib/package.js +47 -0
  167. package/node_modules/playwright/lib/program.js +242 -0
  168. package/node_modules/playwright/lib/runner/index.js +8721 -0
  169. package/node_modules/playwright/lib/runner/index.js.txt +62 -0
  170. package/node_modules/playwright/lib/transform/babelBundle.js +72490 -0
  171. package/node_modules/playwright/lib/transform/babelBundle.js.LICENSE +2384 -0
  172. package/node_modules/playwright/lib/transform/babelBundle.js.txt +328 -0
  173. package/node_modules/playwright/lib/transform/esmLoader.js +8213 -0
  174. package/node_modules/playwright/lib/transform/esmLoader.js.LICENSE +355 -0
  175. package/node_modules/playwright/lib/transform/esmLoader.js.txt +60 -0
  176. package/node_modules/playwright/lib/util.js +373 -0
  177. package/node_modules/playwright/lib/worker/workerProcessEntry.js +1860 -0
  178. package/node_modules/playwright/lib/worker/workerProcessEntry.js.txt +19 -0
  179. package/node_modules/playwright/package.json +50 -0
  180. package/node_modules/playwright/test.d.ts +18 -0
  181. package/node_modules/playwright/test.js +24 -0
  182. package/node_modules/playwright/test.mjs +35 -0
  183. package/node_modules/playwright/types/test.d.ts +11191 -0
  184. package/node_modules/playwright/types/testReporter.d.ts +950 -0
  185. package/package.json +21 -12
  186. package/dist/actions/desktopActions.d.ts +0 -58
  187. package/dist/actions/desktopActions.js +0 -155
  188. package/dist/actions/index.d.ts +0 -27
  189. package/dist/actions/index.js +0 -11
  190. package/dist/actions/memoryActions.d.ts +0 -9
  191. package/dist/actions/memoryActions.js +0 -34
  192. package/dist/actions/taskActions.d.ts +0 -8
  193. package/dist/actions/taskActions.js +0 -27
  194. package/dist/actions/types.d.ts +0 -35
  195. package/dist/actions/types.js +0 -5
  196. package/dist/actions/util.d.ts +0 -21
  197. package/dist/actions/util.js +0 -280
  198. package/dist/actions/webActions.d.ts +0 -87
  199. package/dist/actions/webActions.js +0 -214
  200. package/dist/actions/webActions.test.d.ts +0 -1
  201. package/dist/actions/webActions.test.js +0 -43
  202. package/dist/agent/browserAgent.d.ts +0 -31
  203. package/dist/agent/browserAgent.js +0 -136
  204. package/dist/agent/errors.d.ts +0 -22
  205. package/dist/agent/errors.js +0 -97
  206. package/dist/agent/index.d.ts +0 -64
  207. package/dist/agent/index.js +0 -505
  208. package/dist/agent/narrator.d.ts +0 -4
  209. package/dist/agent/narrator.js +0 -63
  210. package/dist/agent/pause.test.d.ts +0 -1
  211. package/dist/agent/pause.test.js +0 -194
  212. package/dist/ai/baml_client/async_client.d.ts +0 -64
  213. package/dist/ai/baml_client/async_client.js +0 -284
  214. package/dist/ai/baml_client/async_request.d.ts +0 -39
  215. package/dist/ai/baml_client/async_request.js +0 -134
  216. package/dist/ai/baml_client/config.d.ts +0 -11
  217. package/dist/ai/baml_client/config.js +0 -20
  218. package/dist/ai/baml_client/globals.d.ts +0 -16
  219. package/dist/ai/baml_client/globals.js +0 -37
  220. package/dist/ai/baml_client/index.d.ts +0 -17
  221. package/dist/ai/baml_client/index.js +0 -42
  222. package/dist/ai/baml_client/inlinedbaml.d.ts +0 -19
  223. package/dist/ai/baml_client/inlinedbaml.js +0 -31
  224. package/dist/ai/baml_client/parser.d.ts +0 -53
  225. package/dist/ai/baml_client/parser.js +0 -86
  226. package/dist/ai/baml_client/partial_types.d.ts +0 -61
  227. package/dist/ai/baml_client/partial_types.js +0 -10
  228. package/dist/ai/baml_client/sync_client.d.ts +0 -57
  229. package/dist/ai/baml_client/sync_client.js +0 -142
  230. package/dist/ai/baml_client/sync_request.d.ts +0 -37
  231. package/dist/ai/baml_client/sync_request.js +0 -134
  232. package/dist/ai/baml_client/tracing.d.ts +0 -16
  233. package/dist/ai/baml_client/tracing.js +0 -18
  234. package/dist/ai/baml_client/type_builder.d.ts +0 -40
  235. package/dist/ai/baml_client/type_builder.js +0 -120
  236. package/dist/ai/baml_client/types.d.ts +0 -69
  237. package/dist/ai/baml_client/types.js +0 -15
  238. package/dist/ai/baml_client/watchers.d.ts +0 -32
  239. package/dist/ai/baml_client/watchers.js +0 -50
  240. package/dist/ai/baseten.d.ts +0 -4
  241. package/dist/ai/baseten.js +0 -10
  242. package/dist/ai/claudeCode.d.ts +0 -1
  243. package/dist/ai/claudeCode.js +0 -186
  244. package/dist/ai/modelHarness.d.ts +0 -39
  245. package/dist/ai/modelHarness.js +0 -324
  246. package/dist/ai/modelResponseError.d.ts +0 -4
  247. package/dist/ai/modelResponseError.js +0 -8
  248. package/dist/ai/multiModelHarness.d.ts +0 -24
  249. package/dist/ai/multiModelHarness.js +0 -52
  250. package/dist/ai/plannerResponse.d.ts +0 -34
  251. package/dist/ai/plannerResponse.js +0 -96
  252. package/dist/ai/plannerResponse.test.d.ts +0 -1
  253. package/dist/ai/plannerResponse.test.js +0 -112
  254. package/dist/ai/structuredOutput.d.ts +0 -11
  255. package/dist/ai/structuredOutput.js +0 -94
  256. package/dist/ai/structuredOutput.test.d.ts +0 -1
  257. package/dist/ai/structuredOutput.test.js +0 -91
  258. package/dist/ai/types.d.ts +0 -119
  259. package/dist/ai/types.js +0 -5
  260. package/dist/ai/util.d.ts +0 -13
  261. package/dist/ai/util.js +0 -200
  262. package/dist/ai/util.test.d.ts +0 -1
  263. package/dist/ai/util.test.js +0 -95
  264. package/dist/cli.js +0 -3
  265. package/dist/common/actions.js +0 -14
  266. package/dist/common/events.d.ts +0 -17
  267. package/dist/common/events.js +0 -3
  268. package/dist/common/failure.d.ts +0 -68
  269. package/dist/common/failure.js +0 -1
  270. package/dist/common/index.d.ts +0 -3
  271. package/dist/common/index.js +0 -3
  272. package/dist/common/operation.d.ts +0 -31
  273. package/dist/common/operation.js +0 -102
  274. package/dist/common/operation.test.d.ts +0 -1
  275. package/dist/common/operation.test.js +0 -53
  276. package/dist/common/retry.d.ts +0 -16
  277. package/dist/common/retry.js +0 -35
  278. package/dist/common/util.d.ts +0 -23
  279. package/dist/common/util.js +0 -139
  280. package/dist/connectors/browserConnector.d.ts +0 -53
  281. package/dist/connectors/browserConnector.js +0 -290
  282. package/dist/connectors/desktopConnector.d.ts +0 -58
  283. package/dist/connectors/desktopConnector.js +0 -68
  284. package/dist/connectors/index.d.ts +0 -14
  285. package/dist/connectors/index.js +0 -2
  286. package/dist/index.js +0 -28
  287. package/dist/logger.d.ts +0 -3
  288. package/dist/logger.js +0 -15
  289. package/dist/memory/agentMemory.d.ts +0 -47
  290. package/dist/memory/agentMemory.js +0 -167
  291. package/dist/memory/agentMemory.test.d.ts +0 -1
  292. package/dist/memory/agentMemory.test.js +0 -150
  293. package/dist/memory/image.d.ts +0 -28
  294. package/dist/memory/image.js +0 -95
  295. package/dist/memory/image.test.d.ts +0 -1
  296. package/dist/memory/image.test.js +0 -46
  297. package/dist/memory/index.d.ts +0 -3
  298. package/dist/memory/index.js +0 -3
  299. package/dist/memory/masking.d.ts +0 -7
  300. package/dist/memory/masking.js +0 -141
  301. package/dist/memory/masking.test.d.ts +0 -1
  302. package/dist/memory/masking.test.js +0 -117
  303. package/dist/memory/notebook.d.ts +0 -58
  304. package/dist/memory/notebook.js +0 -75
  305. package/dist/memory/notebook.test.d.ts +0 -1
  306. package/dist/memory/notebook.test.js +0 -99
  307. package/dist/memory/observation.d.ts +0 -38
  308. package/dist/memory/observation.js +0 -79
  309. package/dist/memory/rendering/index.d.ts +0 -10
  310. package/dist/memory/rendering/index.js +0 -13
  311. package/dist/memory/rendering/renderJsonParts.d.ts +0 -3
  312. package/dist/memory/rendering/renderJsonParts.js +0 -115
  313. package/dist/memory/rendering/renderJsonParts.test.d.ts +0 -1
  314. package/dist/memory/rendering/renderJsonParts.test.js +0 -217
  315. package/dist/memory/rendering/renderXmlParts.d.ts +0 -7
  316. package/dist/memory/rendering/renderXmlParts.js +0 -127
  317. package/dist/memory/serde.d.ts +0 -20
  318. package/dist/memory/serde.js +0 -67
  319. package/dist/memory/serde.test.d.ts +0 -1
  320. package/dist/memory/serde.test.js +0 -64
  321. package/dist/memory/util.d.ts +0 -2
  322. package/dist/memory/util.js +0 -17
  323. package/dist/telemetry/events.d.ts +0 -9
  324. package/dist/telemetry/events.js +0 -80
  325. package/dist/telemetry/index.d.ts +0 -6
  326. package/dist/telemetry/index.js +0 -91
  327. package/dist/types.d.ts +0 -30
  328. package/dist/types.js +0 -1
  329. package/dist/util.d.ts +0 -1
  330. package/dist/util.js +0 -12
  331. package/dist/version.d.ts +0 -1
  332. package/dist/version.js +0 -3
  333. package/dist/web/browserProvider.d.ts +0 -24
  334. package/dist/web/browserProvider.js +0 -164
  335. package/dist/web/browserProvider.test.d.ts +0 -1
  336. package/dist/web/browserProvider.test.js +0 -44
  337. package/dist/web/harness.d.ts +0 -109
  338. package/dist/web/harness.js +0 -401
  339. package/dist/web/recovery.d.ts +0 -46
  340. package/dist/web/recovery.js +0 -137
  341. package/dist/web/recovery.test.d.ts +0 -1
  342. package/dist/web/recovery.test.js +0 -182
  343. package/dist/web/stability.d.ts +0 -57
  344. package/dist/web/stability.js +0 -323
  345. package/dist/web/tabs.d.ts +0 -58
  346. package/dist/web/tabs.js +0 -293
  347. package/dist/web/transformer.d.ts +0 -7
  348. package/dist/web/transformer.js +0 -41
  349. package/dist/web/types.d.ts +0 -37
  350. package/dist/web/types.js +0 -2
  351. package/dist/web/util.d.ts +0 -3
  352. package/dist/web/util.js +0 -81
  353. package/dist/web/visualizer/cursor.d.ts +0 -16
  354. package/dist/web/visualizer/cursor.js +0 -153
  355. package/dist/web/visualizer/index.d.ts +0 -22
  356. package/dist/web/visualizer/index.js +0 -47
  357. package/dist/web/visualizer/mouseEffects.d.ts +0 -18
  358. package/dist/web/visualizer/mouseEffects.js +0 -287
  359. package/dist/web/visualizer/typeEffects.d.ts +0 -10
  360. package/dist/web/visualizer/typeEffects.js +0 -190
  361. package/dist/web/zodReexport.test.d.ts +0 -1
  362. package/dist/web/zodReexport.test.js +0 -14
  363. /package/{dist/common/actions.d.ts → node_modules/patchright-core/.bun-tag-19f23bd68c84ec1f} +0 -0
package/dist/ai/util.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import { type LLMClient } from '@/ai/types';
2
- import { AgentOptions } from "@/agent";
3
- import { BrowserConnectorOptions } from "@/connectors/browserConnector";
4
- export declare function convertToBamlClientOptions(client: LLMClient): Promise<Record<string, any>>;
5
- export declare function tryDeriveUIGroundedClient(): LLMClient | null;
6
- export declare function isClaude(llm: LLMClient): boolean;
7
- export declare function buildDefaultBrowserAgentOptions({ agentOptions, browserOptions }: {
8
- agentOptions: AgentOptions;
9
- browserOptions: BrowserConnectorOptions;
10
- }): {
11
- agentOptions: AgentOptions;
12
- browserOptions: BrowserConnectorOptions;
13
- };
package/dist/ai/util.js DELETED
@@ -1,200 +0,0 @@
1
- import { completeClaudeCodeAuthFlow } from './claudeCode';
2
- import { DEFAULT_BASETEN_BASE_URL, DEFAULT_BASETEN_MODEL, validateBasetenOptions } from './baseten';
3
- function cleanNestedObject(obj) {
4
- // Remove null/undefined key values entirely
5
- return Object.fromEntries(Object.entries(obj)
6
- // Filter out null/undefined values
7
- .filter(([_, value]) => value !== null && value !== undefined)
8
- // Process nested objects recursively
9
- .map(([key, value]) => [
10
- key,
11
- typeof value === 'object' ? cleanNestedObject(value) : value
12
- ]));
13
- }
14
- export async function convertToBamlClientOptions(client) {
15
- // extract options compatible with https://docs.boundaryml.com/ref/llm-client-providers/overview
16
- // Default to temperature 0.0
17
- // Some client options (e.g. azure) do not have a temperature setting
18
- const temp = 'temperature' in client.options ?
19
- (client.options.temperature ?? 0.0) : 0.0;
20
- let options;
21
- if (client.provider === 'claude-code') {
22
- // Special case - oauth with claude code max anthropic account
23
- const oauthToken = await completeClaudeCodeAuthFlow();
24
- options = {
25
- model: client.options.model,
26
- temperature: temp,
27
- max_tokens: client.options.maxTokens,
28
- headers: {
29
- 'Authorization': `Bearer ${oauthToken}`,
30
- 'anthropic-beta': 'oauth-2025-04-20' + (client.options.promptCaching ? ',prompt-caching-2024-07-31' : ''),
31
- // Overrides this header from being automatically derived from ANTHROPIC_API_KEY
32
- 'X-API-Key': ''
33
- },
34
- ...(client.options.promptCaching ? { allowed_role_metadata: "all" } : {}),
35
- };
36
- }
37
- else if (client.provider === 'anthropic') {
38
- options = {
39
- api_key: client.options.apiKey,
40
- model: client.options.model,
41
- temperature: temp,
42
- max_tokens: client.options.maxTokens,
43
- ...(client.options.promptCaching ? {
44
- allowed_role_metadata: "all",
45
- headers: { 'anthropic-beta': 'prompt-caching-2024-07-31' }
46
- } : {}),
47
- };
48
- }
49
- else if (client.provider === 'aws-bedrock') {
50
- options = {
51
- model_id: client.options.model,
52
- inference_configuration: {
53
- temperature: temp,
54
- }
55
- };
56
- }
57
- else if (client.provider === 'google-ai') {
58
- options = {
59
- base_url: client.options.baseUrl,
60
- model: client.options.model,
61
- api_key: client.options.apiKey,
62
- generationConfig: {
63
- temperature: temp,
64
- //thinking_budget: 0
65
- }
66
- };
67
- }
68
- else if (client.provider === 'vertex-ai') {
69
- options = {
70
- location: client.options.location,
71
- base_url: client.options.baseUrl,
72
- project_id: client.options.projectId,
73
- credentials: client.options.credentials,
74
- anthropic_version: client.options.anthropicVersion,
75
- model: client.options.model,
76
- // generationConfig: {
77
- // temperature: temp,
78
- // }
79
- };
80
- }
81
- else if (client.provider === 'openai') {
82
- options = {
83
- api_key: client.options.apiKey,
84
- base_url: client.options.baseUrl,
85
- model: client.options.model,
86
- temperature: client.options.temperature,
87
- reasoning_effort: client.options.reasoningEffort,
88
- max_completion_tokens: client.options.maxCompletionTokens,
89
- };
90
- }
91
- else if (client.provider === 'baseten') {
92
- validateBasetenOptions(client.options);
93
- const apiKey = client.options.apiKey ?? process.env.BASETEN_API_KEY;
94
- if (!apiKey)
95
- throw new Error('Set BASETEN_API_KEY or provide llm.options.apiKey for the Baseten provider.');
96
- options = {
97
- base_url: client.options.baseUrl ?? DEFAULT_BASETEN_BASE_URL,
98
- api_key: apiKey,
99
- model: client.options.model,
100
- temperature: client.options.temperature,
101
- reasoning_effort: client.options.reasoningEffort,
102
- max_tokens: client.options.maxTokens,
103
- };
104
- }
105
- else if (client.provider === 'openai-generic') {
106
- options = {
107
- base_url: client.options.baseUrl,
108
- api_key: client.options.apiKey,
109
- model: client.options.model,
110
- temperature: temp,
111
- headers: {
112
- "HTTP-Referer": "https://magnitude.run",
113
- "X-Title": "Magnitude",
114
- ...client.options.headers
115
- }
116
- };
117
- }
118
- else if (client.provider === 'azure-openai') {
119
- options = {
120
- resource_name: client.options.resourceName,
121
- deployment_id: client.options.deploymentId,
122
- api_version: client.options.apiVersion,
123
- api_key: client.options.apiKey
124
- };
125
- }
126
- else {
127
- throw new Error(`Invalid provider: ${client.provider}`);
128
- }
129
- return cleanNestedObject(options);
130
- }
131
- export function tryDeriveUIGroundedClient() {
132
- if (process.env.ANTHROPIC_API_KEY) {
133
- return {
134
- provider: 'anthropic',
135
- options: {
136
- // TODO: do more testing on best claude model for visuals
137
- // model: 'claude-3-5-sonnet-20240620', // <- definitely not, pre computer use
138
- // model: 'claude-3-5-sonnet-20241022', // <- not great on rescaling res
139
- //model: 'claude-3-7-sonnet-latest', // <- underplans
140
- // model: 'claude-sonnet-4-20250514', // <- underplans, also supposedly worse at visual reasoning
141
- model: 'claude-haiku-4-5-20251001', // <- fast, cost-effective, good performance
142
- apiKey: process.env.ANTHROPIC_API_KEY
143
- }
144
- };
145
- }
146
- else if (process.env.OPENAI_API_KEY) {
147
- return {
148
- provider: 'openai',
149
- options: { model: 'gpt-5.6-luna', apiKey: process.env.OPENAI_API_KEY }
150
- };
151
- }
152
- else if (process.env.BASETEN_API_KEY) {
153
- return {
154
- provider: 'baseten',
155
- options: { model: DEFAULT_BASETEN_MODEL, apiKey: process.env.BASETEN_API_KEY }
156
- };
157
- }
158
- else {
159
- return null;
160
- }
161
- }
162
- export function isClaude(llm) {
163
- if ('model' in llm.options) { //if (llm.provider === 'anthropic' || llm.provider === 'aws-bedrock' || llm.provider === 'vertex-ai') {
164
- const model = llm.options.model;
165
- if (model.includes('claude'))
166
- return true;
167
- }
168
- return false;
169
- }
170
- const DEFAULT_BROWSER_AGENT_TEMP = 0.2;
171
- export function buildDefaultBrowserAgentOptions({ agentOptions, browserOptions }) {
172
- /**
173
- * Given any provided options for agent or browser connector, fill out additional key fields using environment,
174
- * or any model-specific constraints (e.g. Claude needing 1024x768 virtual screen space)
175
- */
176
- const envLlm = tryDeriveUIGroundedClient();
177
- let llms = agentOptions.llm ? (Array.isArray(agentOptions.llm) ? agentOptions.llm : [agentOptions.llm]) : (envLlm ? [envLlm] : []);
178
- if (llms.length == 0) {
179
- throw new Error("No LLM configured or available from environment. Set ANTHROPIC_API_KEY, OPENAI_API_KEY, or BASETEN_API_KEY, or configure llm explicitly. See https://docs.magnitude.run/customizing/llm-configuration for details");
180
- }
181
- // Set reasonable temp if not provided
182
- let virtualScreenDimensions = null;
183
- for (const llm of llms) {
184
- let llmOptions = {
185
- ...(llm.provider === 'openai' || llm.provider === 'baseten' ? {} : { temperature: DEFAULT_BROWSER_AGENT_TEMP }),
186
- ...llm.options
187
- };
188
- //let modifiedLlm = {...llm, options: llmOptions as any }
189
- llm.options = llmOptions;
190
- if (isClaude(llm)) {
191
- // Claude only really works on 1024x768 screenshots
192
- // if any model is claude, use virtual screen dimensions
193
- virtualScreenDimensions = { width: 1024, height: 768 };
194
- }
195
- }
196
- return {
197
- agentOptions: { ...agentOptions, llm: llms },
198
- browserOptions: { ...browserOptions, virtualScreenDimensions: virtualScreenDimensions ?? undefined }
199
- };
200
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,95 +0,0 @@
1
- import { expect, test } from 'bun:test';
2
- import { buildDefaultBrowserAgentOptions, convertToBamlClientOptions, tryDeriveUIGroundedClient } from './util';
3
- import { DEFAULT_BASETEN_MODEL } from './baseten';
4
- test('Anthropic output limits are explicit and omitted limits retain transport defaults', async () => {
5
- const options = { model: 'claude-sonnet-5', apiKey: 'fixture', temperature: 1 };
6
- expect(await convertToBamlClientOptions({ provider: 'anthropic', options }))
7
- .toEqual({ model: options.model, api_key: 'fixture', temperature: 1 });
8
- expect(await convertToBamlClientOptions({ provider: 'anthropic', options: { ...options, maxTokens: 32_768 } }))
9
- .toEqual({ model: options.model, api_key: 'fixture', temperature: 1, max_tokens: 32_768 });
10
- });
11
- test('OpenAI option conversion preserves explicit values without injecting sampling defaults', async () => {
12
- expect(await convertToBamlClientOptions({ provider: 'openai', options: { model: 'gpt-5.6-luna' } }))
13
- .toEqual({ model: 'gpt-5.6-luna' });
14
- expect(await convertToBamlClientOptions({ provider: 'openai', options: {
15
- model: 'gpt-5.6-luna', apiKey: 'fixture', baseUrl: 'http://127.0.0.1:8080/v1',
16
- temperature: 0, reasoningEffort: 'none', maxCompletionTokens: 4096,
17
- } })).toEqual({ model: 'gpt-5.6-luna', api_key: 'fixture', base_url: 'http://127.0.0.1:8080/v1',
18
- temperature: 0, reasoning_effort: 'none', max_completion_tokens: 4096 });
19
- });
20
- test('Baseten uses its own credentials, endpoint and token parameter', async () => {
21
- const previous = process.env.BASETEN_API_KEY;
22
- try {
23
- process.env.BASETEN_API_KEY = 'fixture-baseten';
24
- expect(await convertToBamlClientOptions({ provider: 'baseten', options: { model: DEFAULT_BASETEN_MODEL } }))
25
- .toEqual({ model: DEFAULT_BASETEN_MODEL, api_key: 'fixture-baseten', base_url: 'https://inference.baseten.co/v1' });
26
- expect(await convertToBamlClientOptions({ provider: 'baseten', options: {
27
- model: DEFAULT_BASETEN_MODEL, apiKey: 'override', baseUrl: 'http://127.0.0.1:8080/v1',
28
- temperature: 0, reasoningEffort: 'none', maxTokens: 4096,
29
- } })).toEqual({ model: DEFAULT_BASETEN_MODEL, api_key: 'override', base_url: 'http://127.0.0.1:8080/v1',
30
- temperature: 0, reasoning_effort: 'none', max_tokens: 4096 });
31
- for (const reasoningEffort of ['minimal', 'medium', 'xhigh']) {
32
- await expect(convertToBamlClientOptions({ provider: 'baseten', options: { model: DEFAULT_BASETEN_MODEL, reasoningEffort } }))
33
- .rejects.toThrow('reasoning effort must be none, low, high, or max');
34
- }
35
- delete process.env.BASETEN_API_KEY;
36
- await expect(convertToBamlClientOptions({ provider: 'baseten', options: { model: DEFAULT_BASETEN_MODEL } }))
37
- .rejects.toThrow('Set BASETEN_API_KEY');
38
- }
39
- finally {
40
- if (previous === undefined)
41
- delete process.env.BASETEN_API_KEY;
42
- else
43
- process.env.BASETEN_API_KEY = previous;
44
- }
45
- });
46
- test('browser defaults leave OpenAI and Baseten sampling unset while retaining Claude defaults', () => {
47
- const llm = [
48
- { provider: 'openai', options: { model: 'gpt-5.6-luna', reasoningEffort: 'high' } },
49
- { provider: 'anthropic', options: { model: 'claude-haiku-4-5-20251001' } },
50
- { provider: 'baseten', options: { model: DEFAULT_BASETEN_MODEL, reasoningEffort: 'high' } },
51
- ];
52
- const result = buildDefaultBrowserAgentOptions({ agentOptions: { llm }, browserOptions: {} });
53
- expect(llm[0].options).toEqual({ model: 'gpt-5.6-luna', reasoningEffort: 'high' });
54
- expect(llm[1].options).toEqual({ model: 'claude-haiku-4-5-20251001', temperature: 0.2 });
55
- expect(llm[2].options).toEqual({ model: DEFAULT_BASETEN_MODEL, reasoningEffort: 'high' });
56
- expect(result.browserOptions.virtualScreenDimensions).toEqual({ width: 1024, height: 768 });
57
- });
58
- test('environment discovery supports Baseten alone and preserves existing provider precedence', () => {
59
- const previous = { anthropic: process.env.ANTHROPIC_API_KEY, openai: process.env.OPENAI_API_KEY, baseten: process.env.BASETEN_API_KEY };
60
- try {
61
- delete process.env.ANTHROPIC_API_KEY;
62
- delete process.env.OPENAI_API_KEY;
63
- delete process.env.BASETEN_API_KEY;
64
- expect(tryDeriveUIGroundedClient()).toBeNull();
65
- expect(() => buildDefaultBrowserAgentOptions({ agentOptions: {}, browserOptions: {} })).toThrow('OPENAI_API_KEY');
66
- process.env.BASETEN_API_KEY = 'fixture-baseten';
67
- const baseten = buildDefaultBrowserAgentOptions({ agentOptions: {}, browserOptions: {} });
68
- expect(baseten.agentOptions.llm).toEqual([{ provider: 'baseten', options: { model: DEFAULT_BASETEN_MODEL, apiKey: 'fixture-baseten' } }]);
69
- expect(baseten.browserOptions.virtualScreenDimensions).toBeUndefined();
70
- process.env.OPENAI_API_KEY = 'fixture-openai';
71
- expect(tryDeriveUIGroundedClient()).toEqual({ provider: 'openai', options: { model: 'gpt-5.6-luna', apiKey: 'fixture-openai' } });
72
- const defaults = buildDefaultBrowserAgentOptions({ agentOptions: {}, browserOptions: {} });
73
- expect(defaults.agentOptions.llm).toEqual([{ provider: 'openai', options: { model: 'gpt-5.6-luna', apiKey: 'fixture-openai' } }]);
74
- expect(defaults.browserOptions.virtualScreenDimensions).toBeUndefined();
75
- process.env.ANTHROPIC_API_KEY = 'fixture-anthropic';
76
- expect(tryDeriveUIGroundedClient()?.provider).toBe('anthropic');
77
- const explicit = { provider: 'openai', options: { model: 'gpt-5.6-luna', temperature: 0 } };
78
- expect(buildDefaultBrowserAgentOptions({ agentOptions: { llm: explicit }, browserOptions: {} }).agentOptions.llm).toEqual([explicit]);
79
- expect(explicit.options.temperature).toBe(0);
80
- }
81
- finally {
82
- if (previous.anthropic === undefined)
83
- delete process.env.ANTHROPIC_API_KEY;
84
- else
85
- process.env.ANTHROPIC_API_KEY = previous.anthropic;
86
- if (previous.openai === undefined)
87
- delete process.env.OPENAI_API_KEY;
88
- else
89
- process.env.OPENAI_API_KEY = previous.openai;
90
- if (previous.baseten === undefined)
91
- delete process.env.BASETEN_API_KEY;
92
- else
93
- process.env.BASETEN_API_KEY = previous.baseten;
94
- }
95
- });
package/dist/cli.js DELETED
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env node
2
- 'use strict';
3
-
@@ -1,14 +0,0 @@
1
- "use strict";
2
- // import { ClickWebAction, NavigateWebAction, ScrollWebAction, SwitchTabWebAction, TypeWebAction } from "@/web/types";
3
- // import { ClickIntent, TypeIntent, ScrollIntent, SwitchTabIntent, Action } from "@/actions/types";
4
- // //'load' | 'click' | 'hover' | 'type' | 'scroll' | 'wait' | 'back';
5
- // // move somewhere else, to action types, why is this here
6
- // export type ActionDescriptor = Action & { screenshot: string };
7
- // // export type ActionDescriptor = NavigateActionDescriptor | ClickActionDescriptor | TypeActionDescriptor | ScrollActionDescriptor | SwitchTabDescriptor;
8
- // // export type ActionVariant = ActionDescriptor['variant'];
9
- // // export type NavigateActionDescriptor = NavigateWebAction & { screenshot: string };
10
- // // export type ClickActionDescriptor = ClickIntent & ClickWebAction & { screenshot: string };
11
- // // export type TypeActionDescriptor = TypeIntent & TypeWebAction & { screenshot: string };
12
- // // export type ScrollActionDescriptor = ScrollIntent & ScrollWebAction & { screenshot: string };
13
- // // export type SwitchTabDescriptor = SwitchTabIntent & SwitchTabWebAction & { screenshot: string };
14
- // //const a: ClickActionDescriptor = { variant: 'click', x: 1, y: 2, target: ''}
@@ -1,17 +0,0 @@
1
- import { Action } from "@/actions/types";
2
- import { ActOptions } from "@/agent";
3
- import { ModelUsage } from "@/ai/types";
4
- export interface AgentEvents {
5
- 'start': () => void;
6
- 'stop': () => void;
7
- 'thought': (thought: string) => void;
8
- 'actStarted': (task: string, options: ActOptions) => void;
9
- 'actDone': (task: string, options: ActOptions) => void;
10
- 'actionStarted': (action: Action) => void;
11
- 'actionDone': (action: Action) => void;
12
- 'observationsRecorded': () => void;
13
- 'planningStarted': () => void;
14
- 'pause': () => void;
15
- 'resume': () => void;
16
- 'tokensUsed': (usage: ModelUsage) => void;
17
- }
@@ -1,3 +0,0 @@
1
- // Common interfaces that can be used anywhere
2
- // Goal is not to expose internals but provide all necessary info in events
3
- export {};
@@ -1,68 +0,0 @@
1
- /**
2
- * Represents any reason why a test case could have failed, for example:
3
- * - Step could not be completed
4
- * - Check did not pass
5
- * - Could not navigate to starting URL
6
- * - Time or action based timeout
7
- * - Operation cancelled by signal
8
- * - ...
9
- */
10
- export type FailureDescriptor = BugDetectedFailure | MisalignmentFailure | NetworkFailure | BrowserFailure | RateLimitFailure | ApiKeyFailure | UnknownFailure | CancelledFailure;
11
- export type BugSeverity = 'critical' | 'high' | 'medium' | 'low';
12
- /**
13
- * Step and check failures are classified into one of:
14
- * BugDetectedFailure: seems to be something wrong with the application itself
15
- * MisalignmentFailure: seems to be a discrepency between the test case and the interface
16
- * OR the agent did not properly recognize the relationship between test case and interface
17
- */
18
- export interface BugDetectedFailure {
19
- variant: 'bug';
20
- title: string;
21
- expectedResult: string;
22
- actualResult: string;
23
- severity: BugSeverity;
24
- }
25
- export interface MisalignmentFailure {
26
- /**
27
- * Major misalignment: when a step/check fails due to:
28
- * 1. Poorly written step/check that is completely unrelated to the interface
29
- * 2. Or interface has changed so much that step/check no longer applicable
30
- * 3. Planner did not do good enough job adjusting recipe for minor misalignment
31
- * Misalignment could be due to a poorly written test case OR bad agent behavior.
32
- */
33
- variant: 'misalignment';
34
- message: string;
35
- }
36
- export interface NetworkFailure {
37
- /**
38
- * For example, failure to connect to starting URL, or any other network errors
39
- * that would completely prevent the test from executing.
40
- */
41
- variant: 'network';
42
- message: string;
43
- }
44
- export interface BrowserFailure {
45
- /**
46
- * E.g. something goes wrong with playwright interactions, any DOM manipulation, etc.
47
- */
48
- variant: 'browser';
49
- message: string;
50
- }
51
- export interface RateLimitFailure {
52
- variant: 'rate_limit';
53
- message: string;
54
- }
55
- export interface ApiKeyFailure {
56
- variant: 'api_key';
57
- message: string;
58
- }
59
- export interface UnknownFailure {
60
- variant: 'unknown';
61
- message: string;
62
- }
63
- export interface CancelledFailure {
64
- /**
65
- * Operation was cancelled, typically by an AbortSignal from a controlling process (e.g., test runner pool).
66
- */
67
- variant: 'cancelled';
68
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export * from './events';
2
- export * from './failure';
3
- export * from './util';
@@ -1,3 +0,0 @@
1
- export * from './events';
2
- export * from './failure';
3
- export * from './util';
@@ -1,31 +0,0 @@
1
- export interface OperationOptions {
2
- signal?: AbortSignal;
3
- /** Absolute Unix time in milliseconds, shared by every step, retry, and wait. */
4
- deadline?: number;
5
- }
6
- export declare class Operation {
7
- readonly owner: object;
8
- private options;
9
- private controller;
10
- private timer?;
11
- private closed;
12
- readonly signal: AbortSignal;
13
- readonly deadline?: number;
14
- private externalAbort;
15
- constructor(owner: object, options: OperationOptions);
16
- private scheduleDeadline;
17
- cancel(reason?: unknown): void;
18
- check(): void;
19
- run<T>(fn: () => Promise<T>): Promise<T>;
20
- dispose(): void;
21
- }
22
- export declare function currentOperation(): Operation | undefined;
23
- export declare function checkOperation(): void;
24
- export declare function operationOptions(): OperationOptions;
25
- /** Wait for every branch, even when one fails, before releasing the operation. */
26
- export declare function drainAll<T extends readonly unknown[]>(promises: {
27
- [K in keyof T]: Promise<T[K]>;
28
- }): Promise<T>;
29
- /** Only race the public result or passive waits. The worker must still drain before reuse. */
30
- export declare function untilAborted<T>(promise: Promise<T>, signal?: AbortSignal): Promise<T>;
31
- export declare function operationSleep(ms: number, signal?: AbortSignal | undefined): Promise<void>;
@@ -1,102 +0,0 @@
1
- import { AsyncLocalStorage } from 'node:async_hooks';
2
- import { OperationCancelledError, OperationDeadlineError } from '@/agent/errors';
3
- // Keep context through async callbacks so a late callback cannot act on a reused agent.
4
- const operations = new AsyncLocalStorage();
5
- export class Operation {
6
- owner;
7
- options;
8
- controller = new AbortController();
9
- timer;
10
- closed = false;
11
- signal = this.controller.signal;
12
- deadline;
13
- externalAbort = () => this.cancel(this.options.signal?.reason);
14
- constructor(owner, options) {
15
- this.owner = owner;
16
- this.options = options;
17
- if (options.deadline !== undefined && !Number.isFinite(options.deadline)) {
18
- throw new TypeError('deadline must be a finite Unix timestamp in milliseconds');
19
- }
20
- this.deadline = options.deadline;
21
- options.signal?.addEventListener('abort', this.externalAbort, { once: true });
22
- if (options.signal?.aborted)
23
- this.externalAbort();
24
- this.scheduleDeadline();
25
- }
26
- scheduleDeadline() {
27
- if (this.deadline === undefined || this.signal.aborted)
28
- return;
29
- const remaining = this.deadline - Date.now();
30
- if (remaining <= 0)
31
- this.controller.abort(new OperationDeadlineError(this.deadline));
32
- else
33
- this.timer = setTimeout(() => this.scheduleDeadline(), Math.min(remaining, 2_147_483_647));
34
- }
35
- cancel(reason) {
36
- clearTimeout(this.timer);
37
- if (!this.signal.aborted)
38
- this.controller.abort(new OperationCancelledError(reason));
39
- }
40
- check() {
41
- if (!this.signal.aborted && this.deadline !== undefined && Date.now() >= this.deadline) {
42
- this.controller.abort(new OperationDeadlineError(this.deadline));
43
- }
44
- if (this.signal.aborted)
45
- throw this.signal.reason;
46
- if (this.closed)
47
- throw new OperationCancelledError('Operation already finished');
48
- }
49
- run(fn) {
50
- return operations.run(this, fn);
51
- }
52
- dispose() {
53
- this.closed = true;
54
- clearTimeout(this.timer);
55
- this.options.signal?.removeEventListener('abort', this.externalAbort);
56
- }
57
- }
58
- export function currentOperation() {
59
- return operations.getStore();
60
- }
61
- export function checkOperation() {
62
- currentOperation()?.check();
63
- }
64
- export function operationOptions() {
65
- checkOperation();
66
- const operation = currentOperation();
67
- return { signal: operation?.signal, deadline: operation?.deadline };
68
- }
69
- /** Wait for every branch, even when one fails, before releasing the operation. */
70
- export async function drainAll(promises) {
71
- const results = await Promise.allSettled(promises);
72
- const failure = results.find(result => result.status === 'rejected');
73
- if (failure?.status === 'rejected')
74
- throw failure.reason;
75
- return results.map(result => result.value);
76
- }
77
- /** Only race the public result or passive waits. The worker must still drain before reuse. */
78
- export function untilAborted(promise, signal) {
79
- if (!signal)
80
- return promise;
81
- return new Promise((resolve, reject) => {
82
- const abort = () => {
83
- signal.removeEventListener('abort', abort);
84
- reject(signal.reason);
85
- };
86
- signal.addEventListener('abort', abort, { once: true });
87
- if (signal.aborted)
88
- abort();
89
- promise.then(resolve, reject).finally(() => signal.removeEventListener('abort', abort));
90
- });
91
- }
92
- export async function operationSleep(ms, signal = currentOperation()?.signal) {
93
- checkOperation();
94
- let timer;
95
- try {
96
- await untilAborted(new Promise(resolve => { timer = setTimeout(resolve, ms); }), signal);
97
- checkOperation();
98
- }
99
- finally {
100
- clearTimeout(timer);
101
- }
102
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,53 +0,0 @@
1
- import { expect, test } from 'bun:test';
2
- import { Operation, checkOperation, currentOperation, operationSleep } from './operation';
3
- import { OperationCancelledError, OperationDeadlineError } from '@/agent/errors';
4
- test('operation context is isolated across concurrent owners and cleared outside them', async () => {
5
- const first = new Operation({}, {}), second = new Operation({}, {});
6
- try {
7
- await Promise.all([first, second].map(operation => operation.run(async () => {
8
- await operationSleep(1);
9
- expect(currentOperation()).toBe(operation);
10
- })));
11
- expect(currentOperation()).toBeUndefined();
12
- }
13
- finally {
14
- first.dispose();
15
- second.dispose();
16
- }
17
- });
18
- test('deadline wakes waits and remains a typed cause', async () => {
19
- const deadline = Date.now() + 30;
20
- const operation = new Operation({}, { deadline });
21
- try {
22
- await expect(operation.run(() => operationSleep(10_000))).rejects.toBeInstanceOf(OperationDeadlineError);
23
- expect(operation.signal.reason.deadline).toBe(deadline);
24
- }
25
- finally {
26
- operation.dispose();
27
- }
28
- });
29
- test('deadlines beyond the timer maximum do not overflow into immediate cancellation', async () => {
30
- const operation = new Operation({}, { deadline: Date.now() + 2_147_483_647 + 100_000 });
31
- try {
32
- await operation.run(() => operationSleep(5));
33
- expect(operation.signal.aborted).toBe(false);
34
- }
35
- finally {
36
- operation.dispose();
37
- }
38
- });
39
- test('first abort wins and external listeners are removed on disposal', async () => {
40
- const controller = new AbortController();
41
- const operation = new Operation({}, { signal: controller.signal });
42
- operation.cancel('first');
43
- controller.abort('second');
44
- expect(operation.signal.reason).toBeInstanceOf(OperationCancelledError);
45
- expect(operation.signal.reason.cause).toBe('first');
46
- operation.dispose();
47
- const anotherController = new AbortController();
48
- const completed = new Operation({}, { signal: anotherController.signal });
49
- completed.dispose();
50
- anotherController.abort();
51
- expect(completed.signal.aborted).toBe(false);
52
- await expect(completed.run(async () => checkOperation())).rejects.toBeInstanceOf(OperationCancelledError);
53
- });
@@ -1,16 +0,0 @@
1
- type RetryOptions = {
2
- retries?: number;
3
- delay?: number;
4
- maxDelay?: number;
5
- exponential?: boolean | number;
6
- throwOnExhaustion?: boolean;
7
- retryIf?: (error: Error) => boolean;
8
- onRetry?: (error: Error, attempt: number) => void;
9
- };
10
- export declare function retry<T>(fn: () => Promise<T>, options: RetryOptions & {
11
- throwOnExhaustion: false;
12
- }): Promise<T | null>;
13
- export declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions & {
14
- throwOnExhaustion?: true;
15
- }): Promise<T>;
16
- export {};