@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,141 +0,0 @@
1
- export async function maskObservations(observations, freezeMask) {
2
- // If freezeMask provided, will guarantee that first freezeMask.length observations return the same mask provided in freezeMask
3
- // - for dedupe: adjacent types in frozen section should survive if unfrozen contains that type with an equivalent value, instead of keeping most recent
4
- // - for limit: limit should only apply to unfrozen section and should ignore (not count) anything in frozen section
5
- /**
6
- * Returns a boolean mask indicating which observations should be visible,
7
- * based on type-specific `dedupe` and `limit` options specified in `obs.retention`.
8
- *
9
- * For each type:
10
- * 1. If `dedupe` is true, marks older adjacent identical observations as false,
11
- * keeping only the last in such a sequence.
12
- * 2. If `limit` is set, marks only the last N observations of that type as true.
13
- *
14
- * Deduplication is applied before limiting for each type.
15
- * Untyped observations (no `obs.retention.type`) are always marked as true.
16
- *
17
- * If freezeMask is provided:
18
- * - The first freezeMask.length observations will have their mask values frozen
19
- * - Dedupe will preserve frozen observations if equivalent values exist in unfrozen section
20
- * - Limit only applies to unfrozen observations
21
- *
22
- * @returns A boolean array where true indicates the observation at that index should be visible
23
- */
24
- const frozenCount = freezeMask?.length ?? 0;
25
- // Initialize mask
26
- const mask = new Array(observations.length).fill(true);
27
- // Copy frozen mask values if provided
28
- if (freezeMask) {
29
- for (let i = 0; i < frozenCount && i < observations.length; i++) {
30
- mask[i] = freezeMask[i];
31
- }
32
- }
33
- // Group observations by type, tracking their original indices
34
- const observationsByType = new Map();
35
- observations.forEach((obs, index) => {
36
- if (obs.retention && obs.retention.type) {
37
- const type = obs.retention.type;
38
- if (!observationsByType.has(type)) {
39
- observationsByType.set(type, {
40
- frozenIndices: [],
41
- unfrozenIndices: [],
42
- frozenObs: [],
43
- unfrozenObs: [],
44
- limit: obs.retention.limit,
45
- dedupe: obs.retention.dedupe,
46
- });
47
- }
48
- const typeData = observationsByType.get(type);
49
- if (index < frozenCount) {
50
- typeData.frozenIndices.push(index);
51
- typeData.frozenObs.push(obs);
52
- }
53
- else {
54
- typeData.unfrozenIndices.push(index);
55
- typeData.unfrozenObs.push(obs);
56
- }
57
- }
58
- // Untyped observations: frozen ones keep their freezeMask value, unfrozen remain true
59
- });
60
- // Process each type
61
- for (const [type, data] of observationsByType.entries()) {
62
- // Only process unfrozen observations for dedupe and limit
63
- let visibleUnfrozenIndices = [...data.unfrozenIndices];
64
- // Apply deduplication to unfrozen section
65
- if (data.dedupe && data.unfrozenObs.length > 1) {
66
- const dedupedIndices = [];
67
- dedupedIndices.unshift(data.unfrozenIndices[data.unfrozenIndices.length - 1]);
68
- for (let i = data.unfrozenIndices.length - 2; i >= 0; i--) {
69
- const currentObs = data.unfrozenObs[i];
70
- const lastKeptIdx = dedupedIndices[0];
71
- const lastKeptObs = observations[lastKeptIdx];
72
- if (!(await currentObs.equals(lastKeptObs))) {
73
- dedupedIndices.unshift(data.unfrozenIndices[i]);
74
- }
75
- }
76
- visibleUnfrozenIndices = dedupedIndices;
77
- }
78
- // Special handling for dedupe with frozen observations
79
- if (data.dedupe && freezeMask) {
80
- // Check if any frozen observations should be preserved
81
- // because equivalent values exist in unfrozen section
82
- const frozenToPreserve = new Set();
83
- for (let i = 0; i < data.frozenIndices.length; i++) {
84
- const frozenIdx = data.frozenIndices[i];
85
- if (mask[frozenIdx]) { // Only check if currently visible in freezeMask
86
- const frozenObs = data.frozenObs[i];
87
- // Check if any unfrozen observation equals this frozen one
88
- for (const unfrozenObs of data.unfrozenObs) {
89
- if (await frozenObs.equals(unfrozenObs)) {
90
- frozenToPreserve.add(frozenIdx);
91
- break;
92
- }
93
- }
94
- }
95
- }
96
- // Ensure preserved frozen observations stay visible
97
- frozenToPreserve.forEach(idx => {
98
- mask[idx] = true;
99
- });
100
- }
101
- // Apply limit only to unfrozen observations
102
- if (data.limit !== undefined && data.limit >= 0) {
103
- if (data.limit === 0) {
104
- visibleUnfrozenIndices = [];
105
- }
106
- else {
107
- // Limit only counts unfrozen observations
108
- visibleUnfrozenIndices = visibleUnfrozenIndices.slice(-data.limit);
109
- }
110
- }
111
- // Mark non-visible unfrozen observations as false
112
- const visibleSet = new Set(visibleUnfrozenIndices);
113
- data.unfrozenIndices.forEach(idx => {
114
- if (!visibleSet.has(idx)) {
115
- mask[idx] = false;
116
- }
117
- });
118
- // Frozen observations keep their freezeMask values (already set above)
119
- }
120
- return mask;
121
- }
122
- export function applyMask(observations, mask) {
123
- /**
124
- * Applies a boolean mask to an array of observations, returning only those
125
- * observations where the corresponding mask value is true, along with their original indices.
126
- *
127
- * @param observations - The array of observations to filter
128
- * @param mask - Boolean array where true indicates the observation should be included
129
- * @returns Array of objects containing the observation and its original index
130
- */
131
- if (observations.length !== mask.length) {
132
- throw new Error(`Mask length (${mask.length}) must match observations length (${observations.length})`);
133
- }
134
- const result = [];
135
- observations.forEach((observation, index) => {
136
- if (mask[index]) {
137
- result.push({ observation, index });
138
- }
139
- });
140
- return result;
141
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,117 +0,0 @@
1
- import { describe, expect, test } from 'bun:test';
2
- import { Observation } from './observation';
3
- import { maskObservations, applyMask } from './masking';
4
- describe('maskObservations with freezeMask', () => {
5
- test('freezeMask preserves frozen observation mask values', async () => {
6
- const observations = [
7
- new Observation('connector:test', 'user', 'obs1'),
8
- new Observation('connector:test', 'user', 'obs2'),
9
- new Observation('connector:test', 'user', 'obs3'),
10
- new Observation('connector:test', 'user', 'obs4'),
11
- ];
12
- const freezeMask = [true, false, true];
13
- const mask = await maskObservations(observations, freezeMask);
14
- // First 3 observations should match freezeMask exactly
15
- expect(mask[0]).toBe(true);
16
- expect(mask[1]).toBe(false);
17
- expect(mask[2]).toBe(true);
18
- // Fourth observation (unfrozen) should be true by default
19
- expect(mask[3]).toBe(true);
20
- });
21
- test('basic dedupe behavior', async () => {
22
- // First test basic dedupe to understand behavior
23
- const observations = [
24
- new Observation('connector:test', 'user', 'content1', { type: 'msg', dedupe: true }),
25
- new Observation('connector:test', 'user', 'content1', { type: 'msg', dedupe: true }),
26
- new Observation('connector:test', 'user', 'content2', { type: 'msg', dedupe: true }),
27
- ];
28
- const mask = await maskObservations(observations);
29
- // Dedupe keeps the last occurrence when adjacent
30
- expect(mask).toEqual([false, true, true]);
31
- });
32
- test('dedupe preserves frozen observations when equivalent exists in unfrozen', async () => {
33
- const observations = [
34
- new Observation('connector:test', 'user', 'duplicate', { type: 'msg', dedupe: true }),
35
- new Observation('connector:test', 'user', 'unique', { type: 'msg', dedupe: true }),
36
- new Observation('connector:test', 'user', 'duplicate', { type: 'msg', dedupe: true }), // This duplicates frozen[0]
37
- new Observation('connector:test', 'user', 'another', { type: 'msg', dedupe: true }),
38
- ];
39
- // With freezeMask, frozen observation should be preserved since equivalent exists in unfrozen
40
- const freezeMask = [true, true];
41
- const maskWithFreeze = await maskObservations(observations, freezeMask);
42
- expect(maskWithFreeze).toEqual([true, true, true, true]);
43
- });
44
- test('limit only applies to unfrozen observations', async () => {
45
- const observations = [
46
- new Observation('connector:test', 'user', 'frozen1', { type: 'limited', limit: 2 }),
47
- new Observation('connector:test', 'user', 'frozen2', { type: 'limited', limit: 2 }),
48
- new Observation('connector:test', 'user', 'frozen3', { type: 'limited', limit: 2 }),
49
- new Observation('connector:test', 'user', 'unfrozen1', { type: 'limited', limit: 2 }),
50
- new Observation('connector:test', 'user', 'unfrozen2', { type: 'limited', limit: 2 }),
51
- new Observation('connector:test', 'user', 'unfrozen3', { type: 'limited', limit: 2 }),
52
- ];
53
- // Without freezeMask, only last 2 observations would be kept
54
- const normalMask = await maskObservations(observations);
55
- expect(normalMask).toEqual([false, false, false, false, true, true]);
56
- // With freezeMask, frozen observations don't count towards limit
57
- // So we keep all 3 frozen + last 2 unfrozen
58
- const freezeMask = [true, true, true];
59
- const maskWithFreeze = await maskObservations(observations, freezeMask);
60
- expect(maskWithFreeze).toEqual([true, true, true, false, true, true]);
61
- });
62
- test('freezeMask with mixed frozen values and limit', async () => {
63
- const observations = [
64
- new Observation('connector:test', 'user', 'frozen1', { type: 'mixed', limit: 1 }),
65
- new Observation('connector:test', 'user', 'frozen2', { type: 'mixed', limit: 1 }),
66
- new Observation('connector:test', 'user', 'unfrozen1', { type: 'mixed', limit: 1 }),
67
- new Observation('connector:test', 'user', 'unfrozen2', { type: 'mixed', limit: 1 }),
68
- ];
69
- // Freeze mask says to hide frozen2 but show frozen1
70
- const freezeMask = [true, false];
71
- const mask = await maskObservations(observations, freezeMask);
72
- // frozen1: true (from freezeMask)
73
- // frozen2: false (from freezeMask)
74
- // unfrozen1: false (exceeded limit of 1 for unfrozen)
75
- // unfrozen2: true (last unfrozen, within limit)
76
- expect(mask).toEqual([true, false, false, true]);
77
- });
78
- test('applyMask filters observations correctly', () => {
79
- const observations = [
80
- new Observation('connector:test', 'user', 'obs1'),
81
- new Observation('connector:test', 'user', 'obs2'),
82
- new Observation('connector:test', 'user', 'obs3'),
83
- ];
84
- const mask = [true, false, true];
85
- const filtered = applyMask(observations, mask);
86
- expect(filtered.length).toBe(2);
87
- expect(filtered[0].observation.content).toBe('obs1');
88
- expect(filtered[0].index).toBe(0);
89
- expect(filtered[1].observation.content).toBe('obs3');
90
- expect(filtered[1].index).toBe(2);
91
- });
92
- test('freezeMask with no typed observations', async () => {
93
- // Test that untyped observations respect freezeMask
94
- const observations = [
95
- new Observation('connector:test', 'user', 'frozen1'),
96
- new Observation('connector:test', 'user', 'frozen2'),
97
- new Observation('connector:test', 'user', 'unfrozen1'),
98
- new Observation('connector:test', 'user', 'unfrozen2'),
99
- ];
100
- const freezeMask = [false, true];
101
- const mask = await maskObservations(observations, freezeMask);
102
- // Frozen observations keep their freezeMask values
103
- // Unfrozen untyped observations remain true
104
- expect(mask).toEqual([false, true, true, true]);
105
- });
106
- test('freezeMask longer than observations array', async () => {
107
- const observations = [
108
- new Observation('connector:test', 'user', 'obs1'),
109
- new Observation('connector:test', 'user', 'obs2'),
110
- ];
111
- const freezeMask = [true, false, true, false];
112
- const mask = await maskObservations(observations, freezeMask);
113
- // Should only apply freezeMask to existing observations
114
- expect(mask.length).toBe(2);
115
- expect(mask).toEqual([true, false]);
116
- });
117
- });
@@ -1,58 +0,0 @@
1
- import { z } from 'zod';
2
- export declare const NOTEBOOK_LIMITS: {
3
- readonly entries: 32;
4
- readonly text: 2000;
5
- readonly key: 80;
6
- readonly sources: 8;
7
- readonly bytes: 65536;
8
- };
9
- export declare const NOTEBOOK_INSTRUCTIONS: string;
10
- export declare const noteSchema: z.ZodObject<{
11
- key: z.ZodString;
12
- text: z.ZodString;
13
- sources: z.ZodArray<z.ZodNumber, "many">;
14
- }, "strict", z.ZodTypeAny, {
15
- key: string;
16
- text: string;
17
- sources: number[];
18
- }, {
19
- key: string;
20
- text: string;
21
- sources: number[];
22
- }>;
23
- export type NoteInput = z.infer<typeof noteSchema>;
24
- export declare const noteUpdateSchema: z.ZodObject<{
25
- key: z.ZodString;
26
- text: z.ZodString;
27
- sources: z.ZodArray<z.ZodNumber, "many">;
28
- } & {
29
- operation: z.ZodEnum<["add", "correct"]>;
30
- expected_text: z.ZodNullable<z.ZodString>;
31
- }, "strict", z.ZodTypeAny, {
32
- key: string;
33
- text: string;
34
- sources: number[];
35
- operation: "add" | "correct";
36
- expected_text: string | null;
37
- }, {
38
- key: string;
39
- text: string;
40
- sources: number[];
41
- operation: "add" | "correct";
42
- expected_text: string | null;
43
- }>;
44
- export type NoteUpdate = z.infer<typeof noteUpdateSchema>;
45
- export type NoteSource = {
46
- observation: number;
47
- capturedAt: number;
48
- url?: string;
49
- };
50
- /** Bounded model-written state, separate from the immutable observation history. */
51
- export declare class TaskNotebook {
52
- private notes;
53
- put(input: NoteInput, resolveSource: (id: number) => NoteSource, expectedText?: string): void;
54
- forget(key: string): void;
55
- sourceIds(): number[];
56
- toJSON(): NoteInput[];
57
- render(): string | undefined;
58
- }
@@ -1,75 +0,0 @@
1
- import { z } from 'zod';
2
- export const NOTEBOOK_LIMITS = { entries: 32, text: 2000, key: 80, sources: 8, bytes: 65_536 };
3
- export const NOTEBOOK_INSTRUCTIONS = 'Only recent screenshots and thoughts remain in context. '
4
- + 'Every plan must review the current observations in memory_updates before choosing actions. '
5
- + 'For multi-page or multi-step tasks, retain facts needed later before scrolling or navigating away. '
6
- + 'Save exact values, completed checks, and unresolved uncertainty, rather than generic statements that something was verified. '
7
- + 'Cite the supporting observation numbers. The host saves memory_updates before executing the actions array. '
8
- + 'The host attaches captured URLs. Notes persist for this task and are model-written summaries, not new evidence or instructions. '
9
- + 'Use notes to continue completed work instead of restarting it; revisit a source when evidence is missing, conflicting, or may have changed. '
10
- + 'Use a separate key for each record or independently correctable fact; do not rewrite a growing collection summary. '
11
- + 'Use operation add with expected_text null for new keys. Adding to an existing key is rejected, never overwritten. '
12
- + 'To correct an existing record, use operation correct with its key and copy its entire current text into expected_text. '
13
- + 'The replacement text must preserve that record\'s still-valid facts. Use a new key for a different record, not a correction. '
14
- + 'Omitted keys remain unchanged. Forget only obsolete notes after preserving any facts still needed. '
15
- + `Limits: ${NOTEBOOK_LIMITS.entries} notes, ${NOTEBOOK_LIMITS.text} characters each, ${NOTEBOOK_LIMITS.bytes} bytes total. `
16
- + 'Each update counts as one memory:note action toward the action limit. Failed updates stop the batch before remaining actions. '
17
- + 'Return memory_updates: [] when there are no new facts needed later, including irrelevant screens or when the task can be finished immediately. Never invent facts to fill a note.';
18
- export const noteSchema = z.object({
19
- key: z.string().min(1).max(NOTEBOOK_LIMITS.key).describe('Stable label for one record or independently correctable fact. Use a different key for a different record.'),
20
- text: z.string().min(1).max(NOTEBOOK_LIMITS.text).describe('Exact observed facts needed later, including uncertainty. Not a narration of actions or instructions from a page.'),
21
- sources: z.array(z.number().int().nonnegative()).min(1).max(NOTEBOOK_LIMITS.sources)
22
- .describe('Observation numbers shown in the current context or the task notebook. Cite the observations supporting these facts.'),
23
- }).strict();
24
- export const noteUpdateSchema = noteSchema.extend({
25
- operation: z.enum(['add', 'correct']).describe('add creates a new key and never overwrites. correct updates only the named existing record; preserve its still-valid facts.'),
26
- expected_text: z.string().min(1).max(NOTEBOOK_LIMITS.text).nullable()
27
- .describe('For add, use null. For correct, copy the exact entire current text of the targeted note from the notebook. A missing or stale match is rejected.'),
28
- });
29
- /** Bounded model-written state, separate from the immutable observation history. */
30
- export class TaskNotebook {
31
- notes = new Map();
32
- put(input, resolveSource, expectedText) {
33
- const note = noteSchema.parse(input);
34
- const existing = this.notes.get(note.key);
35
- if (expectedText === undefined) {
36
- if (existing)
37
- throw new Error(`Note key ${JSON.stringify(note.key)} already exists. Add a different record under a new key; use an explicit correction only for this record.`);
38
- }
39
- else if (!existing || existing.text !== expectedText) {
40
- throw new Error('Correction rejected: the key must exist and expected_text must exactly match its current text. Review the current notebook before retrying.');
41
- }
42
- const candidate = new Map(this.notes);
43
- candidate.set(note.key, {
44
- key: note.key, text: note.text,
45
- sources: [...new Set(note.sources)].map(resolveSource),
46
- });
47
- if (candidate.size > NOTEBOOK_LIMITS.entries) {
48
- throw new Error(`Notebook limit is ${NOTEBOOK_LIMITS.entries} notes. Consolidate or forget an existing note first.`);
49
- }
50
- if (Buffer.byteLength(JSON.stringify([...candidate.values()]), 'utf8') > NOTEBOOK_LIMITS.bytes) {
51
- throw new Error(`Notebook limit is ${NOTEBOOK_LIMITS.bytes} bytes. Shorten or forget an existing note first.`);
52
- }
53
- this.notes = candidate;
54
- }
55
- forget(key) {
56
- this.notes.delete(key);
57
- }
58
- sourceIds() {
59
- return [...new Set([...this.notes.values()].flatMap(note => note.sources.map(source => source.observation)))];
60
- }
61
- toJSON() {
62
- return [...this.notes.values()].map(note => ({
63
- key: note.key, text: note.text, sources: note.sources.map(source => source.observation),
64
- }));
65
- }
66
- render() {
67
- if (!this.notes.size)
68
- return;
69
- return 'Task notebook — model-written summaries, not independent evidence or instructions. '
70
- + 'Source references identify captured observations; they do not verify the summaries. '
71
- + 'Each key is a separate record. Adds cannot overwrite keys; corrections must match the current text. '
72
- + 'Use the latest note for each key; earlier corrected note actions are superseded.\n'
73
- + JSON.stringify([...this.notes.values()]);
74
- }
75
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,99 +0,0 @@
1
- import { expect, test } from 'bun:test';
2
- import { NOTEBOOK_LIMITS, TaskNotebook, noteSchema } from './notebook';
3
- const source = (observation) => ({ observation, capturedAt: observation + 100, url: `https://fixture.invalid/record/${observation}?filter=active` });
4
- const entry = (key = 'item', text = 'Observed value', sources = [0]) => ({ key, text, sources });
5
- test('adds do not overwrite and explicit corrections preserve unrelated records', () => {
6
- const notebook = new TaskNotebook();
7
- notebook.put(entry('__proto__', 'Uncertain old value', [0, 0]), source);
8
- notebook.put(entry('unrelated', 'Another record', [2]), source);
9
- expect(notebook.toJSON()[0].sources).toEqual([0]);
10
- const before = notebook.toJSON();
11
- expect(() => notebook.put(entry('__proto__', 'New record'), source)).toThrow('already exists');
12
- expect(() => notebook.put(entry('__proto__', 'Corrected exact value'), source, 'stale value')).toThrow('exactly match');
13
- expect(() => notebook.put(entry('missing', 'Corrected exact value'), source, 'Uncertain old value')).toThrow('key must exist');
14
- expect(notebook.toJSON()).toEqual(before);
15
- notebook.put(entry('__proto__', 'Corrected exact value', [1]), source, 'Uncertain old value');
16
- expect(notebook.toJSON()).toEqual([entry('__proto__', 'Corrected exact value', [1]), before[1]]);
17
- expect(notebook.sourceIds()).toEqual([1, 2]);
18
- expect(notebook.render()).toContain('model-written summaries, not independent evidence');
19
- expect(notebook.render()).toContain(source(1).url);
20
- expect(notebook.render()).not.toContain('Uncertain old value');
21
- notebook.forget('__proto__');
22
- notebook.forget('unrelated');
23
- notebook.forget('already absent');
24
- expect(notebook.render()).toBeUndefined();
25
- });
26
- test('entry limits reject updates atomically without evicting old facts', () => {
27
- const notebook = new TaskNotebook();
28
- for (let i = 0; i < NOTEBOOK_LIMITS.entries; i++)
29
- notebook.put(entry(`item-${i}`), source);
30
- const before = notebook.toJSON();
31
- expect(() => notebook.put(entry('overflow'), source)).toThrow('Consolidate or forget');
32
- expect(notebook.toJSON()).toEqual(before);
33
- notebook.put(entry('item-0', 'replacement'), source, 'Observed value');
34
- expect(notebook.toJSON().slice(1)).toEqual(before.slice(1));
35
- notebook.forget('item-1');
36
- notebook.put(entry('new-slot'), source);
37
- expect(notebook.toJSON()).toHaveLength(NOTEBOOK_LIMITS.entries);
38
- });
39
- test('the byte cap includes Unicode and captured URLs, beyond text character counts', () => {
40
- const notebook = new TaskNotebook();
41
- notebook.put(entry(), source);
42
- const before = notebook.toJSON();
43
- expect(() => notebook.put(entry('oversized-url'), id => ({ ...source(id), url: 'x'.repeat(NOTEBOOK_LIMITS.bytes) })))
44
- .toThrow('bytes');
45
- expect(notebook.toJSON()).toEqual(before);
46
- expect(() => notebook.put(entry('item', 'Valid replacement'), id => ({ ...source(id), url: 'x'.repeat(NOTEBOOK_LIMITS.bytes) }), 'Observed value'))
47
- .toThrow('bytes');
48
- expect(notebook.toJSON()).toEqual(before);
49
- let rejected = false;
50
- for (let i = 0; i < NOTEBOOK_LIMITS.entries; i++) {
51
- try {
52
- notebook.put(entry(`unicode-${i}`, '界'.repeat(NOTEBOOK_LIMITS.text)), source);
53
- }
54
- catch (error) {
55
- expect(String(error)).toContain('bytes');
56
- rejected = true;
57
- break;
58
- }
59
- }
60
- expect(rejected).toBe(true);
61
- expect(notebook.toJSON().length).toBeLessThan(NOTEBOOK_LIMITS.entries);
62
- });
63
- test('invalid content or provenance never replaces a valid note', () => {
64
- const notebook = new TaskNotebook();
65
- notebook.put(entry(), source);
66
- const before = notebook.toJSON();
67
- for (const input of [entry('', 'fact'), entry('item', ''), entry('item', 'x'.repeat(NOTEBOOK_LIMITS.text + 1)),
68
- entry('item', 'fact', []), entry('item', 'fact', [-1]), entry('item', 'fact', [0.5]),
69
- entry('item', 'fact', Array(NOTEBOOK_LIMITS.sources + 1).fill(0))]) {
70
- expect(noteSchema.safeParse(input).success).toBe(false);
71
- expect(() => notebook.put(input, source)).toThrow();
72
- }
73
- expect(() => notebook.put(entry(), () => { throw new Error('Unobserved source'); }, 'Observed value')).toThrow('Unobserved source');
74
- expect(notebook.toJSON()).toEqual(before);
75
- const exported = notebook.toJSON();
76
- exported[0].sources.push(99);
77
- expect(notebook.toJSON()).toEqual(before);
78
- });
79
- test('varied add/correct sequences never change omitted records or accept stale corrections', () => {
80
- let seed = 0x5932;
81
- const next = () => { seed = (Math.imul(seed, 1664525) + 1013904223) >>> 0; return seed; };
82
- const notebook = new TaskNotebook();
83
- const expected = new Map();
84
- for (let i = 0; i < NOTEBOOK_LIMITS.entries; i++) {
85
- const note = entry(`record-${next()}`, `Exact value ${next()}`, [i]);
86
- notebook.put(note, source);
87
- expected.set(note.key, note);
88
- }
89
- for (let i = 0; i < 100; i++) {
90
- const old = [...expected.values()][next() % expected.size];
91
- const corrected = entry(old.key, `Changed value ${next()}`, [next() % NOTEBOOK_LIMITS.entries]);
92
- expect(() => notebook.put(corrected, source)).toThrow('already exists');
93
- expect(notebook.toJSON()).toEqual([...expected.values()]);
94
- notebook.put(corrected, source, old.text);
95
- expected.set(old.key, corrected);
96
- expect(() => notebook.put(old, source, old.text)).toThrow('exactly match');
97
- expect(notebook.toJSON()).toEqual([...expected.values()]);
98
- }
99
- });
@@ -1,38 +0,0 @@
1
- import { Image } from './image';
2
- import { MultiMediaJson } from './serde';
3
- import { MultiMediaMessage } from '@/ai/baml_client';
4
- import { type MultiMediaContentPart } from './rendering';
5
- export type ObservableDataPrimitive = Image | string | number | boolean | null | undefined;
6
- export type ObservableDataArray = Array<RenderableContent>;
7
- export type ObservableDataObject = {
8
- [key: string]: RenderableContent;
9
- };
10
- export type RenderableContent = ObservableDataPrimitive | ObservableDataArray | ObservableDataObject;
11
- export type ObservationRole = 'user' | 'assistant';
12
- export interface ObservationRetentionOptions {
13
- type: string;
14
- limit?: number;
15
- dedupe?: boolean;
16
- }
17
- export type ObservationSource = `connector:${string}` | `action:taken:${string}` | `action:result:${string}` | `thought`;
18
- export declare class Observation {
19
- readonly source: ObservationSource;
20
- readonly role: ObservationRole;
21
- readonly timestamp: number;
22
- readonly content: RenderableContent;
23
- readonly retention?: ObservationRetentionOptions;
24
- constructor(source: ObservationSource, role: ObservationRole, content: RenderableContent, retention?: ObservationRetentionOptions, timestamp?: number);
25
- static fromConnector(connectorId: string, content: RenderableContent, options?: ObservationRetentionOptions): Observation;
26
- static fromActionTaken(actionId: string, content: RenderableContent, options?: ObservationRetentionOptions): Observation;
27
- static fromActionResult(actionId: string, content: RenderableContent, options?: ObservationRetentionOptions): Observation;
28
- static fromThought(content: RenderableContent, options?: ObservationRetentionOptions): Observation;
29
- toString(): string;
30
- toJson(): Promise<MultiMediaJson>;
31
- render(options?: {
32
- prefix?: MultiMediaContentPart[];
33
- postfix?: MultiMediaContentPart[];
34
- cacheControl?: boolean;
35
- }): Promise<MultiMediaMessage>;
36
- hash(): Promise<string>;
37
- equals(obs: Observation): Promise<boolean>;
38
- }
@@ -1,79 +0,0 @@
1
- /**
2
- * Observations and declarations for what kind of data is "observable" - i.e. can be processed into BAML context or JSON.
3
- */
4
- import { fnv1a32Hex } from '@/util';
5
- import { observableDataToJson } from './serde';
6
- import { renderContentParts } from './rendering';
7
- export class Observation {
8
- source; // where this observation came from
9
- role;
10
- timestamp; // time this observation was made
11
- content; // the arbitrarily-structured multimedia content of this observation
12
- retention;
13
- constructor(source, role, content, retention, timestamp) {
14
- this.source = source;
15
- this.role = role;
16
- this.content = content;
17
- this.timestamp = timestamp ?? Date.now();
18
- this.retention = retention;
19
- }
20
- static fromConnector(connectorId, content, options) {
21
- return new Observation(`connector:${connectorId}`, 'user', content, options);
22
- }
23
- static fromActionTaken(actionId, content, options) {
24
- // see notes on fromThought
25
- return new Observation(`action:taken:${actionId}`, 'user', content, options);
26
- }
27
- static fromActionResult(actionId, content, options) {
28
- return new Observation(`action:result:${actionId}`, 'user', content, options);
29
- }
30
- static fromThought(content, options) {
31
- // may want to reconsider this structure - probably want to show something that actually matches what the assistant sent else it might pattern match.
32
- // or just do these as user messages.
33
- // changed to user for now
34
- return new Observation(`thought`, 'user', content, options);
35
- }
36
- toString() {
37
- // will be pretty ugly usually
38
- return JSON.stringify(this.content);
39
- }
40
- async toJson() {
41
- return await observableDataToJson(this.content);
42
- }
43
- async render(options) {
44
- return {
45
- role: this.role,
46
- cacheControl: options?.cacheControl ?? false,
47
- content: [...(options?.prefix ?? []), ...(await renderContentParts(this.content, { mode: 'json', indent: 2 })), ...(options?.postfix ?? [])]
48
- };
49
- }
50
- // async renderContentParts(): Promise<MultiMediaContentPart[]> {
51
- // return await renderParts(this.content);
52
- // }
53
- // async toContext(): Promise<BamlRenderable[]> {
54
- // return await observableDataToContext(this.data);
55
- // }
56
- async hash() {
57
- // build str of all text+img content
58
- const stringifiedContent = JSON.stringify(await this.toJson());
59
- return fnv1a32Hex(stringifiedContent);
60
- }
61
- async equals(obs) {
62
- // TODO: deep eq for both text and img content
63
- return (await this.hash()) == (await obs.hash());
64
- }
65
- }
66
- // export async function renderObservations(observations: Observation[]): Promise<BamlRenderable[]> {
67
- // /**
68
- // * Refines observations (according to observation culling options) and converts to BAML-renderable content
69
- // */
70
- // const filteredObservations = await filterObservations(observations);
71
- // let content: BamlRenderable[] = [];
72
- // for (const obs of filteredObservations) {
73
- // if (obs.source.startsWith('action:taken') || obs.source.startsWith('thought')) {
74
- // content.push(`[${new Date(obs.timestamp).toTimeString().split(' ')[0]}]: `);
75
- // }
76
- // content = [...content, ...await obs.toContext(), "\n"];
77
- // }
78
- // return content;
79
- // }
@@ -1,10 +0,0 @@
1
- import { RenderableContent } from "@/memory/observation";
2
- import { Image as BamlImage } from '@boundaryml/baml';
3
- export type MultiMediaContentPart = BamlImage | string;
4
- export type RenderOptions = {
5
- mode: 'json';
6
- indent: 0 | 2 | 4;
7
- } | {
8
- mode: 'xml';
9
- };
10
- export declare function renderContentParts(data: RenderableContent, options: RenderOptions): Promise<import("./renderXmlParts").MultiMediaContentPart[]>;
@@ -1,13 +0,0 @@
1
- import { renderXmlParts } from "./renderXmlParts";
2
- import { renderJsonParts } from "./renderJsonParts";
3
- export async function renderContentParts(data, options) {
4
- if (options.mode === 'json') {
5
- return await renderJsonParts(data, options.indent);
6
- }
7
- else if (options.mode === 'xml') {
8
- return await renderXmlParts(data);
9
- }
10
- else {
11
- throw new Error(`Invalid render mode ${options.mode}`);
12
- }
13
- }
@@ -1,3 +0,0 @@
1
- import { RenderableContent } from "@/memory/observation";
2
- import { MultiMediaContentPart } from "@/memory/rendering";
3
- export declare function renderJsonParts(data: RenderableContent, indent: number): Promise<MultiMediaContentPart[]>;