@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
@@ -1,32 +0,0 @@
1
- /*************************************************************************************************
2
-
3
- Welcome to Baml! To use this generated code, please run one of the following:
4
-
5
- $ npm install @boundaryml/baml
6
- $ yarn add @boundaryml/baml
7
- $ pnpm add @boundaryml/baml
8
-
9
- *************************************************************************************************/
10
- export interface VarNotification<T> {
11
- variable_name: string;
12
- value: T;
13
- timestamp: string;
14
- function_name: string;
15
- }
16
- interface InternalStreamEvent {
17
- streamId: string;
18
- notificationType: "start" | "update" | "end";
19
- value?: any;
20
- }
21
- type VarHandler<T> = (event: VarNotification<T>) => void;
22
- type InternalStreamHandler = (event: InternalStreamEvent) => void;
23
- export interface InternalEventBindings {
24
- functionName: string;
25
- vars: Record<string, VarHandler<any>[]>;
26
- streams: Record<string, InternalStreamHandler[]>;
27
- functions: Record<string, InternalEventBindings>;
28
- }
29
- export interface EventCollectorInternal {
30
- __handlers(): InternalEventBindings;
31
- }
32
- export {};
@@ -1,50 +0,0 @@
1
- /*************************************************************************************************
2
-
3
- Welcome to Baml! To use this generated code, please run one of the following:
4
-
5
- $ npm install @boundaryml/baml
6
- $ yarn add @boundaryml/baml
7
- $ pnpm add @boundaryml/baml
8
-
9
- *************************************************************************************************/
10
- // Simple async iterable stream for watch notifications
11
- class NotificationStream {
12
- eventQueue = [];
13
- isComplete = false;
14
- pushValue(value) {
15
- this.eventQueue.push(value);
16
- }
17
- complete() {
18
- this.isComplete = true;
19
- this.eventQueue.push(null);
20
- }
21
- async *[Symbol.asyncIterator]() {
22
- while (true) {
23
- const event = this.eventQueue.shift();
24
- if (event === undefined) {
25
- if (this.isComplete) {
26
- break;
27
- }
28
- // Wait a bit for more events
29
- await new Promise(resolve => setTimeout(resolve, 10));
30
- continue;
31
- }
32
- if (event === null) {
33
- break;
34
- }
35
- yield event;
36
- }
37
- }
38
- async getFinalResponse() {
39
- // For emit streams, just get the last value
40
- let lastValue = null;
41
- for await (const value of this) {
42
- lastValue = value;
43
- }
44
- return lastValue;
45
- }
46
- toStreamable() {
47
- throw new Error("toStreamable not implemented for EmitStream");
48
- }
49
- }
50
- export {};
@@ -1,4 +0,0 @@
1
- import type { BasetenClient } from './types';
2
- export declare const DEFAULT_BASETEN_MODEL = "deepseek-ai/DeepSeek-V4.1-Flash";
3
- export declare const DEFAULT_BASETEN_BASE_URL = "https://inference.baseten.co/v1";
4
- export declare function validateBasetenOptions({ model, reasoningEffort }: BasetenClient['options']): void;
@@ -1,10 +0,0 @@
1
- export const DEFAULT_BASETEN_MODEL = 'deepseek-ai/DeepSeek-V4.1-Flash';
2
- export const DEFAULT_BASETEN_BASE_URL = 'https://inference.baseten.co/v1';
3
- export function validateBasetenOptions({ model, reasoningEffort }) {
4
- // https://docs.baseten.co/inference/model-apis/reasoning
5
- // Other models have different supported levels; leave those to the provider.
6
- if (model === DEFAULT_BASETEN_MODEL && reasoningEffort !== undefined
7
- && !['none', 'low', 'high', 'max'].includes(reasoningEffort)) {
8
- throw new Error(`${model} reasoning effort must be none, low, high, or max.`);
9
- }
10
- }
@@ -1 +0,0 @@
1
- export declare function completeClaudeCodeAuthFlow(): Promise<string>;
@@ -1,186 +0,0 @@
1
- import { promises as fs } from 'fs';
2
- import { homedir } from 'os';
3
- import { join, dirname } from 'path';
4
- import crypto from 'crypto';
5
- import { bold, cyanBright } from 'ansis';
6
- import { exec } from 'node:child_process';
7
- // Simple cross-platform function to open URLs
8
- function openUrl(url) {
9
- return new Promise((resolve, reject) => {
10
- let command;
11
- switch (process.platform) {
12
- case 'darwin':
13
- command = `open "${url}"`;
14
- break;
15
- case 'win32':
16
- command = `start "${url}"`;
17
- break;
18
- default:
19
- command = `xdg-open "${url}"`;
20
- break;
21
- }
22
- exec(command, (error) => {
23
- if (error) {
24
- reject(error);
25
- }
26
- else {
27
- resolve();
28
- }
29
- });
30
- });
31
- }
32
- // Constants
33
- const CLIENT_ID = '9d1c250a-e61b-44d9-88ed-5944d1962f5e';
34
- const CREDS_PATH = join(homedir(), '.magnitude', 'credentials', 'claudeCode.json');
35
- // 1. Generate PKCE pair
36
- function generatePKCE() {
37
- const verifier = crypto.randomBytes(32).toString('base64url');
38
- const challenge = crypto
39
- .createHash('sha256')
40
- .update(verifier)
41
- .digest('base64url');
42
- return { verifier, challenge };
43
- }
44
- // 2. Get OAuth authorization URL
45
- function getAuthorizationURL(pkce) {
46
- const url = new URL('https://claude.ai/oauth/authorize');
47
- url.searchParams.set('code', 'true');
48
- url.searchParams.set('client_id', CLIENT_ID);
49
- url.searchParams.set('response_type', 'code');
50
- url.searchParams.set('redirect_uri', 'https://console.anthropic.com/oauth/code/callback');
51
- url.searchParams.set('scope', 'org:create_api_key user:profile user:inference');
52
- url.searchParams.set('code_challenge', pkce.challenge);
53
- url.searchParams.set('code_challenge_method', 'S256');
54
- url.searchParams.set('state', pkce.verifier);
55
- return url.toString();
56
- }
57
- // 3. Exchange authorization code for tokens
58
- async function exchangeCodeForTokens(code, verifier) {
59
- const [authCode, state] = code.split('#');
60
- const response = await fetch('https://console.anthropic.com/v1/oauth/token', {
61
- method: 'POST',
62
- headers: { 'Content-Type': 'application/json' },
63
- body: JSON.stringify({
64
- code: authCode,
65
- state: state,
66
- grant_type: 'authorization_code',
67
- client_id: CLIENT_ID,
68
- redirect_uri: 'https://console.anthropic.com/oauth/code/callback',
69
- code_verifier: verifier,
70
- }),
71
- });
72
- if (!response.ok) {
73
- throw new Error(`Token exchange failed: ${response.statusText}`);
74
- }
75
- const data = await response.json();
76
- return {
77
- access_token: data.access_token,
78
- refresh_token: data.refresh_token,
79
- expires_at: Date.now() + (data.expires_in * 1000),
80
- };
81
- }
82
- // 4. Refresh access token
83
- async function refreshAccessToken(refreshToken) {
84
- const response = await fetch('https://console.anthropic.com/v1/oauth/token', {
85
- method: 'POST',
86
- headers: { 'Content-Type': 'application/json' },
87
- body: JSON.stringify({
88
- grant_type: 'refresh_token',
89
- refresh_token: refreshToken,
90
- client_id: CLIENT_ID,
91
- }),
92
- });
93
- if (!response.ok) {
94
- throw new Error(`Token refresh failed: ${response.statusText}`);
95
- }
96
- const data = await response.json();
97
- return {
98
- access_token: data.access_token,
99
- refresh_token: data.refresh_token,
100
- expires_at: Date.now() + (data.expires_in * 1000),
101
- };
102
- }
103
- // 5. Save credentials
104
- async function saveCredentials(creds) {
105
- await fs.mkdir(dirname(CREDS_PATH), { recursive: true });
106
- await fs.writeFile(CREDS_PATH, JSON.stringify(creds, null, 2));
107
- await fs.chmod(CREDS_PATH, 0o600); // Read/write for owner only
108
- }
109
- // 6. Load credentials
110
- async function loadCredentials() {
111
- try {
112
- const data = await fs.readFile(CREDS_PATH, 'utf-8');
113
- return JSON.parse(data);
114
- }
115
- catch {
116
- return null;
117
- }
118
- }
119
- // 7. Get valid access token (refresh if needed)
120
- async function getValidAccessToken() {
121
- const creds = await loadCredentials();
122
- if (!creds)
123
- return null;
124
- // If token is still valid, return it
125
- if (creds.expires_at > Date.now() + 60000) { // 1 minute buffer
126
- return creds.access_token;
127
- }
128
- // Otherwise, refresh it
129
- try {
130
- const newCreds = await refreshAccessToken(creds.refresh_token);
131
- await saveCredentials(newCreds);
132
- return newCreds.access_token;
133
- }
134
- catch {
135
- return null;
136
- }
137
- }
138
- export async function completeClaudeCodeAuthFlow() {
139
- // Try to get existing valid token
140
- const existingToken = await getValidAccessToken();
141
- if (existingToken)
142
- return existingToken;
143
- // Otherwise, go through auth flow
144
- const pkce = generatePKCE();
145
- const authUrl = getAuthorizationURL(pkce);
146
- console.log(bold `Claude Code Pro/Max access token missing or expired.`);
147
- //console.log(cyanBright`Accounts with Max plan can be used for API access.`)
148
- console.log(cyanBright `Opening browser for authentication...`);
149
- try {
150
- await openUrl(authUrl);
151
- }
152
- catch (err) {
153
- console.log('Could not open browser automatically');
154
- }
155
- //console.log('Open this URL in your browser:');
156
- console.log(bold `\nIf browser did not open, visit:`);
157
- console.log(authUrl);
158
- console.log(bold `\nPaste the authorization code here:`);
159
- const code = await new Promise((resolve) => {
160
- process.stdin.once('data', (data) => {
161
- resolve(data.toString().trim());
162
- });
163
- });
164
- const creds = await exchangeCodeForTokens(code, pkce.verifier);
165
- await saveCredentials(creds);
166
- console.log(bold `\nCredentials saved!`);
167
- return creds.access_token;
168
- }
169
- /*
170
- // Usage
171
- const response = await fetch('https://api.anthropic.com/v1/messages', {
172
- method: 'POST',
173
- headers: {
174
- 'Content-Type': 'application/json',
175
- 'Authorization': `Bearer ${accessToken}`,
176
- 'anthropic-beta': 'oauth-2025-04-20',
177
- // make sure to exclude x-api-key
178
- },
179
- body: JSON.stringify({
180
- model: 'claude-3-5-sonnet-20241022',
181
- messages: [{ role: 'user', content: 'Hello!' }],
182
- max_tokens: 100,
183
- }),
184
- });
185
-
186
- */
@@ -1,39 +0,0 @@
1
- import { AgentContext } from "@/ai/baml_client";
2
- import { ClientRegistry } from "@boundaryml/baml";
3
- import { LLMClient, ModelUsage } from "@/ai/types";
4
- import { ActionDefinition } from "@/actions";
5
- import { Schema, z } from 'zod';
6
- import { Image } from '@/memory/image';
7
- import EventEmitter from "eventemitter3";
8
- import { MultiMediaContentPart } from "@/memory/rendering";
9
- import { type PlannerResponse } from './plannerResponse';
10
- interface ModelHarnessOptions {
11
- llm: LLMClient;
12
- }
13
- export interface ModelHarnessEvents {
14
- 'tokensUsed': (usage: ModelUsage) => {};
15
- }
16
- export declare class ModelHarness {
17
- /**
18
- * Strong reasoning agent for high level strategy and planning.
19
- */
20
- readonly events: EventEmitter<ModelHarnessEvents>;
21
- private options;
22
- private cr;
23
- private clientOptions;
24
- private baml;
25
- private logger;
26
- private planner?;
27
- constructor(options: ModelHarnessOptions);
28
- setup(): Promise<void>;
29
- protected createClientRegistry(options: Record<string, any>): ClientRegistry;
30
- private clientForSchema;
31
- describeModel(): string;
32
- private _withUsage;
33
- private _reportCallUsage;
34
- partialAct<T>(context: AgentContext, // Changed to ModularMemoryContext
35
- task: string, data: MultiMediaContentPart[], actionVocabulary: ActionDefinition<T>[]): Promise<PlannerResponse>;
36
- extract<T extends Schema>(instructions: string, schema: T, screenshot: Image, domContent: string): Promise<z.infer<T>>;
37
- query<T extends Schema>(context: AgentContext, query: string, schema: T): Promise<z.infer<T>>;
38
- }
39
- export {};
@@ -1,324 +0,0 @@
1
- import { convertToBamlClientOptions } from "./util";
2
- // Import ModularMemoryContext instead of old MemoryContext
3
- import { b } from "@/ai/baml_client";
4
- import { Collector, ClientRegistry, BamlValidationError } from "@boundaryml/baml";
5
- import logger from "@/logger";
6
- import TypeBuilder from "./baml_client/type_builder";
7
- import { z } from 'zod';
8
- import { convertActionDefinitionsToBaml, convertZodToBaml } from "@/actions/util";
9
- import EventEmitter from "eventemitter3";
10
- import { parsePlannerResponse, PlannerResponseError, memoryUpdatesSchema } from './plannerResponse';
11
- import { anthropicOutputFormat, plannerSchema, usesStructuredOutput } from './structuredOutput';
12
- import { ModelResponseError } from './modelResponseError';
13
- import { DEFAULT_BASETEN_MODEL } from './baseten';
14
- import { checkOperation, operationOptions } from '@/common/operation';
15
- export class ModelHarness {
16
- /**
17
- * Strong reasoning agent for high level strategy and planning.
18
- */
19
- events = new EventEmitter();
20
- options;
21
- cr;
22
- clientOptions;
23
- baml;
24
- logger;
25
- planner;
26
- constructor(options) {
27
- this.options = {
28
- llm: options.llm,
29
- //promptCaching: options.promptCaching ?? false
30
- };
31
- this.logger = logger.child({ name: 'llm' });
32
- }
33
- async setup() {
34
- // Must be called after constructor
35
- this.planner = undefined;
36
- this.clientOptions = await convertToBamlClientOptions(this.options.llm);
37
- this.cr = this.createClientRegistry(this.clientOptions);
38
- this.baml = b.withOptions({ clientRegistry: this.cr });
39
- }
40
- createClientRegistry(options) {
41
- const registry = new ClientRegistry();
42
- registry.addLlmClient('Magnus', this.options.llm.provider === 'claude-code' ? 'anthropic'
43
- : this.options.llm.provider === 'baseten' ? 'openai-generic' : this.options.llm.provider, options, 'DefaultRetryPolicy');
44
- registry.setPrimary('Magnus');
45
- return registry;
46
- }
47
- clientForSchema(schema) {
48
- if (!usesStructuredOutput(this.options.llm))
49
- return this.cr;
50
- // Reuse the conservative schema subset across providers; all original
51
- // value constraints and notebook semantics remain locally validated.
52
- const format = anthropicOutputFormat(schema);
53
- if (!format) {
54
- this.logger.debug('Schema requires prompt-only output; native structured output cannot represent it');
55
- return this.cr;
56
- }
57
- const outputOptions = this.options.llm.provider === 'baseten'
58
- ? { response_format: { type: 'json_schema', json_schema: { name: 'magnitude_response', strict: true, schema: format.schema } } }
59
- : { output_config: { format } };
60
- return this.createClientRegistry({ ...this.clientOptions, ...outputOptions });
61
- }
62
- describeModel() {
63
- return `${this.options.llm.provider}:${'model' in this.options.llm.options ? this.options.llm.options.model : 'unknown'}`;
64
- }
65
- async _withUsage(invoke) {
66
- checkOperation();
67
- // Scope usage to this invocation, including failed parses and provider
68
- // retries. A shared cumulative collector can double-count concurrent calls.
69
- const collector = new Collector('model-call');
70
- try {
71
- try {
72
- return await invoke(collector);
73
- }
74
- finally {
75
- checkOperation();
76
- // Even syntactically complete JSON must not hide a provider
77
- // refusal or a truncated batch. Neither gets a format retry.
78
- if (this.options.llm.provider === 'anthropic' || this.options.llm.provider === 'claude-code') {
79
- let reason;
80
- try {
81
- reason = collector.last?.calls.at(-1)?.httpResponse?.body.json()?.stop_reason;
82
- }
83
- catch { /* A transport error may not contain JSON. */ }
84
- if (reason === 'refusal' || reason === 'max_tokens')
85
- throw new ModelResponseError(reason);
86
- }
87
- else if (this.options.llm.provider === 'openai' || this.options.llm.provider === 'baseten') {
88
- let choice;
89
- try {
90
- choice = collector.last?.calls.at(-1)?.httpResponse?.body.json()?.choices?.[0];
91
- }
92
- catch { /* A transport error may not contain JSON. */ }
93
- if (choice?.message?.refusal || choice?.finish_reason === 'content_filter')
94
- throw new ModelResponseError('refusal');
95
- if (choice?.finish_reason === 'length')
96
- throw new ModelResponseError('max_tokens');
97
- }
98
- }
99
- }
100
- finally {
101
- for (const log of collector.logs) {
102
- for (const call of log.calls) {
103
- try {
104
- this._reportCallUsage(call);
105
- }
106
- catch {
107
- this.logger.warn('Unable to report model response usage');
108
- }
109
- }
110
- }
111
- }
112
- }
113
- _reportCallUsage(call) {
114
- let inputTokens = call.usage?.inputTokens;
115
- let outputTokens = call.usage?.outputTokens;
116
- let cacheWriteInputTokens = 0;
117
- let cacheReadInputTokens = 0;
118
- if (this.options.llm.provider === 'anthropic' || this.options.llm.provider === 'claude-code') {
119
- // Anthropic's input_tokens excludes cache reads/writes. BAML's
120
- // normalized usage does not expose that breakdown.
121
- try {
122
- const usage = call.httpResponse?.body.json()?.usage;
123
- if (usage) {
124
- inputTokens = usage.input_tokens ?? inputTokens;
125
- outputTokens = usage.output_tokens ?? outputTokens;
126
- cacheWriteInputTokens = usage.cache_creation_input_tokens ?? 0;
127
- cacheReadInputTokens = usage.cache_read_input_tokens ?? 0;
128
- }
129
- }
130
- catch { /* Non-JSON error response; use per-call usage if available. */ }
131
- }
132
- else if (this.options.llm.provider === 'openai' || this.options.llm.provider === 'baseten') {
133
- try {
134
- const usage = call.httpResponse?.body.json()?.usage;
135
- if (usage) {
136
- // Both providers include cached input in prompt_tokens and reasoning
137
- // output in completion_tokens. Neither should be counted twice.
138
- cacheReadInputTokens = usage.prompt_tokens_details?.cached_tokens ?? 0;
139
- cacheWriteInputTokens = usage.prompt_tokens_details?.cache_write_tokens ?? 0;
140
- const totalInputTokens = usage.prompt_tokens ?? inputTokens;
141
- if (totalInputTokens != null)
142
- inputTokens = totalInputTokens - cacheReadInputTokens - cacheWriteInputTokens;
143
- outputTokens = usage.completion_tokens ?? outputTokens;
144
- }
145
- }
146
- catch { /* Non-JSON error response; use per-call usage if available. */ }
147
- }
148
- // A transport failure with no usage is not a paid completion. In
149
- // particular, never reuse the preceding successful response's usage.
150
- if (inputTokens == null && outputTokens == null)
151
- return;
152
- inputTokens ??= 0;
153
- outputTokens ??= 0;
154
- const model = this.options.llm.options.model ?? 'unknown';
155
- const isLuna = /^gpt-5\.6-luna(?:-\d{4}-\d{2}-\d{2})?$/.test(model);
156
- // Get cost if known
157
- const knownCostMap = this.options.llm.provider === 'baseten' ? {
158
- // Baseten Model API rates, verified 2026-09-15. Do not inherit other providers' prices.
159
- // https://www.baseten.co/library/deepseek-v41-flash/
160
- [DEFAULT_BASETEN_MODEL]: { inputTokens: 0.30, outputTokens: 1.20, cacheReadInputTokens: 0.03 },
161
- } : {
162
- // TODO: track cached savings on Gemini
163
- 'gemini-2.5-pro': { inputTokens: 1.25, outputTokens: 10.0 },
164
- 'gemini-2.5-flash': { inputTokens: 0.30, outputTokens: 2.50 },
165
- 'gemini-2.5-flash-lite': { inputTokens: 0.10, outputTokens: 0.40 },
166
- 'claude-3.5-sonnet': { inputTokens: 3.00, outputTokens: 15.00, cacheWriteInputTokens: 3.75, cacheReadInputTokens: 0.30 },
167
- 'claude-3.7-sonnet': { inputTokens: 3.00, outputTokens: 15.00, cacheWriteInputTokens: 3.75, cacheReadInputTokens: 0.30 },
168
- 'claude-sonnet-4': { inputTokens: 3.00, outputTokens: 15.00, cacheWriteInputTokens: 3.75, cacheReadInputTokens: 0.30 },
169
- // Standard API pricing, using the default 5-minute cache TTL:
170
- // https://platform.claude.com/docs/en/models/sonnet-5/overview#pricing
171
- 'claude-sonnet-5': { inputTokens: 2.00, outputTokens: 10.00, cacheWriteInputTokens: 2.50, cacheReadInputTokens: 0.20 },
172
- 'claude-haiku-4-5': { inputTokens: 1.00, outputTokens: 5.00, cacheWriteInputTokens: 1.25, cacheReadInputTokens: 0.10 },
173
- 'claude-opus-4': { inputTokens: 15.00, outputTokens: 75.00, cacheWriteInputTokens: 18.75, cacheReadInputTokens: 1.50 },
174
- 'gpt-4.1': { inputTokens: 2.00, outputTokens: 8.00 },
175
- 'gpt-4.1-mini': { inputTokens: 0.40, outputTokens: 1.60 },
176
- 'gpt-4.1-nano': { inputTokens: 0.10, outputTokens: 0.40 },
177
- 'gpt-4o': { inputTokens: 3.75, outputTokens: 15.00 },
178
- // https://developers.openai.com/api/docs/models/gpt-5.6-luna
179
- 'gpt-5.6-luna': { inputTokens: 0.20, outputTokens: 1.20, cacheWriteInputTokens: 0.25, cacheReadInputTokens: 0.02 },
180
- // Assuming Nebius prices, may be higher
181
- 'qwen2.5-vl-72b': { inputTokens: 0.25, outputTokens: 0.75 }
182
- };
183
- let inputTokenCost;
184
- let outputTokenCost;
185
- let cacheWriteInputTokenCost;
186
- let cacheReadInputTokenCost;
187
- for (const [name, costs] of Object.entries(knownCostMap)) {
188
- if (this.options.llm.provider === 'baseten' ? model === name : name === 'gpt-5.6-luna' ? isLuna : model.includes(name)) {
189
- inputTokenCost = costs.inputTokens / 1_000_000;
190
- outputTokenCost = costs.outputTokens / 1_000_000;
191
- cacheReadInputTokenCost = costs.cacheReadInputTokens ? costs.cacheReadInputTokens / 1_000_000 : undefined;
192
- cacheWriteInputTokenCost = costs.cacheWriteInputTokens ? costs.cacheWriteInputTokens / 1_000_000 : undefined;
193
- }
194
- }
195
- // Luna long-context pricing applies to the entire request, including
196
- // cached input. Output usage already includes billed reasoning tokens.
197
- if (isLuna && inputTokens + cacheReadInputTokens + cacheWriteInputTokens > 272_000) {
198
- if (inputTokenCost !== undefined)
199
- inputTokenCost *= 2;
200
- if (cacheWriteInputTokenCost !== undefined)
201
- cacheWriteInputTokenCost *= 2;
202
- if (cacheReadInputTokenCost !== undefined)
203
- cacheReadInputTokenCost *= 2;
204
- if (outputTokenCost !== undefined)
205
- outputTokenCost *= 1.5;
206
- }
207
- // console.log("cacheWriteInputTokenCost:", cacheWriteInputTokenCost);
208
- // console.log("cacheWriteInputTokens:", cacheWriteInputTokens);
209
- const usage = {
210
- llm: {
211
- provider: this.options.llm.provider,
212
- model: model
213
- }, //this.options.llm,
214
- inputTokens: inputTokens,
215
- outputTokens: outputTokens,
216
- ...(cacheWriteInputTokens ? { cacheWriteInputTokens } : {}),
217
- ...(cacheReadInputTokens ? { cacheReadInputTokens } : {}),
218
- ...(inputTokenCost !== undefined && (!cacheWriteInputTokens || cacheWriteInputTokenCost !== undefined) && (!cacheReadInputTokens || cacheReadInputTokenCost !== undefined) ? {
219
- inputCost: inputTokens * inputTokenCost +
220
- (cacheWriteInputTokenCost ? cacheWriteInputTokenCost * cacheWriteInputTokens : 0.0) +
221
- (cacheReadInputTokenCost ? cacheReadInputTokenCost * cacheReadInputTokens : 0.0)
222
- } : {}),
223
- ...(outputTokenCost ? { outputCost: outputTokens * outputTokenCost } : {}),
224
- // ...(cacheWriteInputTokenCost ? { : inputTokens * inputTokenCost } : {}),
225
- // ...(cacheReadInputTokenCost ? { outputCost: outputTokens * outputTokenCost } : {})
226
- };
227
- this.events.emit('tokensUsed', usage);
228
- //console.log("Usage:", usage);
229
- }
230
- async partialAct(context, // Changed to ModularMemoryContext
231
- task, data, actionVocabulary) {
232
- // Notes have one planner path: a required review before browser actions.
233
- // Keep memory:note registered on Agent for execution and explicit callers.
234
- actionVocabulary = actionVocabulary.filter(action => action.name !== 'memory:note');
235
- if (!this.planner || this.planner.vocabulary.length !== actionVocabulary.length
236
- || actionVocabulary.some((action, index) => {
237
- const saved = this.planner.vocabulary[index];
238
- return action.name !== saved.name || action.description !== saved.description || action.schema !== saved.schema;
239
- })) {
240
- const tb = new TypeBuilder();
241
- tb.PartialRecipe.addProperty('memory_updates', convertZodToBaml(tb, memoryUpdatesSchema)).description(memoryUpdatesSchema.description);
242
- tb.PartialRecipe.addProperty('actions', tb.list(convertActionDefinitionsToBaml(tb, actionVocabulary))).description('Always provide at least one action');
243
- this.planner = {
244
- vocabulary: actionVocabulary.map(({ name, description, schema }) => ({ name, description, schema })),
245
- tb, clientRegistry: this.clientForSchema(plannerSchema(actionVocabulary)),
246
- };
247
- }
248
- const { tb, clientRegistry } = this.planner;
249
- for (let attempt = 0;; attempt++) {
250
- try {
251
- return await this._withUsage(async (collector) => {
252
- let bamlRejected = false;
253
- try {
254
- await this.baml.CreatePartialRecipe(context, task, data, this.options.llm.provider === 'claude-code', { tb, collector, clientRegistry, signal: operationOptions().signal });
255
- }
256
- catch (error) {
257
- checkOperation();
258
- if (!(error instanceof BamlValidationError))
259
- throw error;
260
- bamlRejected = true;
261
- }
262
- // BAML can fail first or coerce invalid fields. Diagnose its
263
- // raw response locally, but never bypass either validator.
264
- checkOperation();
265
- const plan = parsePlannerResponse(collector.last?.rawLlmResponse ?? null, actionVocabulary);
266
- if (bamlRejected)
267
- throw new PlannerResponseError('$: BAML parser rejected the response despite local validation; return a plan matching the supplied schema');
268
- return plan;
269
- });
270
- }
271
- catch (error) {
272
- checkOperation();
273
- if (!(error instanceof PlannerResponseError))
274
- throw error;
275
- this.logger.warn({ attempt: attempt + 1, diagnostic: error.diagnostic }, attempt === 0
276
- ? 'Invalid planner response; retrying once with the same observations'
277
- : 'Invalid planner response; no format retries remain');
278
- if (attempt === 1)
279
- throw new PlannerResponseError(error.diagnostic, 'Planner returned an invalid plan on both attempts');
280
- // No invalid output is appended to memory or executed. Keep the
281
- // correction short even when the rejected response is enormous.
282
- context = { ...context, observationContent: [...context.observationContent, {
283
- role: 'user', cacheControl: false, content: [`Your previous response was rejected as an invalid plan. No actions were executed. Validation: ${error.diagnostic}. Correct the reported fields. Return only one complete JSON object with concise reasoning, a memory_updates array (empty when nothing new needs retaining), and a non-empty actions array matching the schema. No XML, prose, simulated tool calls, or imagined observations. Plan only the next batch from the observations above.`],
284
- }] };
285
- }
286
- }
287
- }
288
- async extract(instructions, schema, screenshot, domContent) {
289
- const tb = new TypeBuilder();
290
- if (schema instanceof z.ZodObject) {
291
- // populate ExtractedData with schema KVs instead of wrapping in data key unnecessarily
292
- for (const [key, fieldSchema] of Object.entries(schema.shape)) {
293
- tb.ExtractedData.addProperty(key, convertZodToBaml(tb, fieldSchema));
294
- }
295
- }
296
- else {
297
- // for array or primitive have to wrap data key
298
- tb.ExtractedData.addProperty('data', convertZodToBaml(tb, schema));
299
- }
300
- // } else if (schema instanceof z.ZodArray) {
301
- // }
302
- const clientRegistry = this.clientForSchema(schema instanceof z.ZodObject ? schema : z.object({ data: schema }));
303
- const bamlScreenshot = await screenshot.toBaml();
304
- const resp = await this._withUsage(collector => this.baml.ExtractData(instructions, bamlScreenshot, domContent, this.options.llm.provider === 'claude-code', { tb, collector, clientRegistry, signal: operationOptions().signal }));
305
- return schema.parse(schema instanceof z.ZodObject ? resp : resp.data);
306
- }
307
- // ^ extract could prob be a subset of query w trimmed mem
308
- async query(context, query, schema) {
309
- const tb = new TypeBuilder();
310
- if (schema instanceof z.ZodObject) {
311
- // populate ExtractedData with schema KVs instead of wrapping in data key unnecessarily
312
- for (const [key, fieldSchema] of Object.entries(schema.shape)) {
313
- tb.QueryResponse.addProperty(key, convertZodToBaml(tb, fieldSchema));
314
- }
315
- }
316
- else {
317
- // for array or primitive have to wrap data key
318
- tb.QueryResponse.addProperty('data', convertZodToBaml(tb, schema));
319
- }
320
- const clientRegistry = this.clientForSchema(schema instanceof z.ZodObject ? schema : z.object({ data: schema }));
321
- const resp = await this._withUsage(collector => this.baml.QueryMemory(context, query, this.options.llm.provider === 'claude-code', { tb, collector, clientRegistry, signal: operationOptions().signal }));
322
- return schema.parse(schema instanceof z.ZodObject ? resp : resp.data);
323
- }
324
- }
@@ -1,4 +0,0 @@
1
- export declare class ModelResponseError extends Error {
2
- readonly reason: 'refusal' | 'max_tokens';
3
- constructor(reason: 'refusal' | 'max_tokens');
4
- }
@@ -1,8 +0,0 @@
1
- export class ModelResponseError extends Error {
2
- reason;
3
- constructor(reason) {
4
- super(reason === 'refusal' ? 'Model refused the request' : 'Model response exceeded its output-token limit');
5
- this.reason = reason;
6
- this.name = 'ModelResponseError';
7
- }
8
- }