@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.
- package/dist/cli.cjs +2 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +2 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.mjs +1 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/index.cjs +2704 -1522
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +188 -50
- package/dist/index.d.ts +1147 -23
- package/dist/index.mjs +2527 -1362
- package/dist/index.mjs.map +1 -0
- package/node_modules/patchright-core/README.md +3 -0
- package/node_modules/patchright-core/ThirdPartyNotices.txt +13 -0
- package/node_modules/patchright-core/bin/install_media_pack.ps1 +5 -0
- package/node_modules/patchright-core/bin/install_webkit_wsl.ps1 +33 -0
- package/node_modules/patchright-core/bin/reinstall_chrome_beta_linux.sh +42 -0
- package/node_modules/patchright-core/bin/reinstall_chrome_beta_mac.sh +13 -0
- package/node_modules/patchright-core/bin/reinstall_chrome_beta_win.ps1 +24 -0
- package/node_modules/patchright-core/bin/reinstall_chrome_stable_linux.sh +42 -0
- package/node_modules/patchright-core/bin/reinstall_chrome_stable_mac.sh +12 -0
- package/node_modules/patchright-core/bin/reinstall_chrome_stable_win.ps1 +24 -0
- package/node_modules/patchright-core/bin/reinstall_msedge_beta_linux.sh +48 -0
- package/node_modules/patchright-core/bin/reinstall_msedge_beta_mac.sh +11 -0
- package/node_modules/patchright-core/bin/reinstall_msedge_beta_win.ps1 +23 -0
- package/node_modules/patchright-core/bin/reinstall_msedge_dev_linux.sh +48 -0
- package/node_modules/patchright-core/bin/reinstall_msedge_dev_mac.sh +11 -0
- package/node_modules/patchright-core/bin/reinstall_msedge_dev_win.ps1 +23 -0
- package/node_modules/patchright-core/bin/reinstall_msedge_stable_linux.sh +48 -0
- package/node_modules/patchright-core/bin/reinstall_msedge_stable_mac.sh +11 -0
- package/node_modules/patchright-core/bin/reinstall_msedge_stable_win.ps1 +24 -0
- package/node_modules/patchright-core/browsers.json +52 -0
- package/node_modules/patchright-core/cli.js +22 -0
- package/node_modules/patchright-core/index.d.ts +17 -0
- package/node_modules/patchright-core/index.js +17 -0
- package/node_modules/patchright-core/index.mjs +28 -0
- package/node_modules/patchright-core/lib/bootstrap.js +149 -0
- package/node_modules/patchright-core/lib/coreBundle.js +80653 -0
- package/node_modules/patchright-core/lib/entry/cliDaemon.js +5 -0
- package/node_modules/patchright-core/lib/entry/dashboardApp.js +3 -0
- package/node_modules/patchright-core/lib/entry/mcp.js +10 -0
- package/node_modules/patchright-core/lib/entry/oopBrowserDownload.js +3 -0
- package/node_modules/patchright-core/lib/package.js +50 -0
- package/node_modules/patchright-core/lib/server/chromium/appIcon.png +0 -0
- package/node_modules/patchright-core/lib/server/electron/loader.js +112 -0
- package/node_modules/patchright-core/lib/serverRegistry.js +1939 -0
- package/node_modules/patchright-core/lib/serverRegistry.js.LICENSE +65 -0
- package/node_modules/patchright-core/lib/tools/cli-client/channelSessions.js +141 -0
- package/node_modules/patchright-core/lib/tools/cli-client/cli.js +7 -0
- package/node_modules/patchright-core/lib/tools/cli-client/help.json +808 -0
- package/node_modules/patchright-core/lib/tools/cli-client/minimist.js +128 -0
- package/node_modules/patchright-core/lib/tools/cli-client/output.js +352 -0
- package/node_modules/patchright-core/lib/tools/cli-client/program.js +422 -0
- package/node_modules/patchright-core/lib/tools/cli-client/registry.js +180 -0
- package/node_modules/patchright-core/lib/tools/cli-client/session.js +261 -0
- package/node_modules/patchright-core/lib/tools/dashboard/appIcon.png +0 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/SKILL.md +493 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/element-attributes.md +23 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/playwright-tests.md +39 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/pr-attachments.md +60 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/request-mocking.md +87 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/running-code.md +245 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/session-management.md +227 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/storage-state.md +275 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/test-generation.md +433 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/tracing.md +139 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-cli/references/video-recording.md +216 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/SKILL.md +136 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/gallery-spec.md +144 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/migration.md +89 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/react.md +69 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/typing.md +173 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-component-testing/references/vue.md +77 -0
- package/node_modules/patchright-core/lib/tools/skills/playwright-trace/SKILL.md +174 -0
- package/node_modules/patchright-core/lib/tools/utils/extension.js +112 -0
- package/node_modules/patchright-core/lib/tools/utils/socketConnection.js +108 -0
- package/node_modules/patchright-core/lib/utilsBundle.js +86225 -0
- package/node_modules/patchright-core/lib/utilsBundle.js.LICENSE +1890 -0
- package/node_modules/patchright-core/lib/vite/dashboard/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/node_modules/patchright-core/lib/vite/dashboard/assets/codeMirrorModule-CQ8RZGBm.js +32 -0
- package/node_modules/patchright-core/lib/vite/dashboard/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/patchright-core/lib/vite/dashboard/assets/firefox-1bWoP6pv.svg +1 -0
- package/node_modules/patchright-core/lib/vite/dashboard/assets/firefox-beta-k3eOH_eK.svg +1 -0
- package/node_modules/patchright-core/lib/vite/dashboard/assets/firefox-nightly-Cp5nfeDT.svg +1 -0
- package/node_modules/patchright-core/lib/vite/dashboard/assets/index-AwgwcYie.css +1 -0
- package/node_modules/patchright-core/lib/vite/dashboard/assets/index-hRvO4yU2.js +12 -0
- package/node_modules/patchright-core/lib/vite/dashboard/assets/safari-na3_-uQk.svg +1 -0
- package/node_modules/patchright-core/lib/vite/dashboard/index.html +29 -0
- package/node_modules/patchright-core/lib/vite/dashboard/playwright-logo.svg +24 -0
- package/node_modules/patchright-core/lib/vite/htmlReport/index.html +16 -0
- package/node_modules/patchright-core/lib/vite/htmlReport/report.css +2 -0
- package/node_modules/patchright-core/lib/vite/htmlReport/report.js +32 -0
- package/node_modules/patchright-core/lib/vite/recorder/assets/codeMirrorModule--QdMvsKi.css +1 -0
- package/node_modules/patchright-core/lib/vite/recorder/assets/codeMirrorModule-GBnsXk4c.js +32 -0
- package/node_modules/patchright-core/lib/vite/recorder/assets/codicon-DCmgc-ay.ttf +0 -0
- package/node_modules/patchright-core/lib/vite/recorder/assets/index-BZpYJZ-P.css +1 -0
- package/node_modules/patchright-core/lib/vite/recorder/assets/index-CVDOfo-j.js +129 -0
- package/node_modules/patchright-core/lib/vite/recorder/index.html +29 -0
- package/node_modules/patchright-core/lib/vite/recorder/playwright-logo.svg +9 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/assets/codeMirrorModule-G79327TW.js +32 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/assets/defaultSettingsView-D9EV0iaS.js +184 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/assets/urlMatch-L3liM589.js +1 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/assets/xtermModule-Al_u-Nk5.js +7 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/codeMirrorModule.-QdMvsKi.css +1 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/codicon.DCmgc-ay.ttf +0 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/defaultSettingsView.C8BeHuxd.css +1 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/index.B_TqY17P.css +1 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/index.CMB2-c8e.js +1 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/index.html +44 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/manifest.webmanifest +16 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/playwright-logo.svg +9 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/snapshot.B_Jk1wbt.js +1 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/snapshot.html +10 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/sw.bundle.js +4 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/uiMode.C3yLoy2G.js +5 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/uiMode.CyMfwkXJ.css +1 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/uiMode.html +18 -0
- package/node_modules/patchright-core/lib/vite/traceViewer/xtermModule.kHJ-D0s7.css +1 -0
- package/node_modules/patchright-core/lib/webp_codec.LICENSE +173 -0
- package/node_modules/patchright-core/lib/webp_codec.wasm +0 -0
- package/node_modules/patchright-core/lib/xdg-open +1267 -0
- package/node_modules/patchright-core/package.json +34 -0
- package/node_modules/patchright-core/types/protocol.d.ts +24776 -0
- package/node_modules/patchright-core/types/structs.d.ts +52 -0
- package/node_modules/patchright-core/types/types.d.ts +27167 -0
- package/node_modules/playwright/.bun-tag-91d746a6045e143f +0 -0
- package/node_modules/playwright/README.md +300 -0
- package/node_modules/playwright/ThirdPartyNotices.txt +14 -0
- package/node_modules/playwright/cli.js +19 -0
- package/node_modules/playwright/index.d.ts +17 -0
- package/node_modules/playwright/index.js +17 -0
- package/node_modules/playwright/index.mjs +18 -0
- package/node_modules/playwright/lib/agents/agentParser.js +89 -0
- package/node_modules/playwright/lib/agents/copilot-setup-steps.yml +34 -0
- package/node_modules/playwright/lib/agents/generateAgents.js +395 -0
- package/node_modules/playwright/lib/agents/playwright-test-coverage.prompt.md +31 -0
- package/node_modules/playwright/lib/agents/playwright-test-generate.prompt.md +8 -0
- package/node_modules/playwright/lib/agents/playwright-test-generator.agent.md +88 -0
- package/node_modules/playwright/lib/agents/playwright-test-heal.prompt.md +6 -0
- package/node_modules/playwright/lib/agents/playwright-test-healer.agent.md +56 -0
- package/node_modules/playwright/lib/agents/playwright-test-plan.prompt.md +9 -0
- package/node_modules/playwright/lib/agents/playwright-test-planner.agent.md +74 -0
- package/node_modules/playwright/lib/cli/reportActions.js +78 -0
- package/node_modules/playwright/lib/cli/testActions.js +217 -0
- package/node_modules/playwright/lib/common/index.js +2937 -0
- package/node_modules/playwright/lib/common/index.js.txt +33 -0
- package/node_modules/playwright/lib/errorContext.js +129 -0
- package/node_modules/playwright/lib/globals.js +58 -0
- package/node_modules/playwright/lib/index.js +827 -0
- package/node_modules/playwright/lib/isomorphic.js +260 -0
- package/node_modules/playwright/lib/isomorphic.js.txt +9 -0
- package/node_modules/playwright/lib/loader/loaderProcessEntry.js +34 -0
- package/node_modules/playwright/lib/loader/loaderProcessEntry.js.txt +9 -0
- package/node_modules/playwright/lib/matchers/expect.js +13496 -0
- package/node_modules/playwright/lib/matchers/expect.js.LICENSE +640 -0
- package/node_modules/playwright/lib/matchers/expect.js.txt +67 -0
- package/node_modules/playwright/lib/mcp/test/browserBackend.js +135 -0
- package/node_modules/playwright/lib/mcp/test/generatorTools.js +122 -0
- package/node_modules/playwright/lib/mcp/test/plannerTools.js +150 -0
- package/node_modules/playwright/lib/mcp/test/seed.js +82 -0
- package/node_modules/playwright/lib/mcp/test/streams.js +44 -0
- package/node_modules/playwright/lib/mcp/test/testBackend.js +99 -0
- package/node_modules/playwright/lib/mcp/test/testContext.js +306 -0
- package/node_modules/playwright/lib/mcp/test/testTool.js +30 -0
- package/node_modules/playwright/lib/mcp/test/testTools.js +98 -0
- package/node_modules/playwright/lib/package.js +47 -0
- package/node_modules/playwright/lib/program.js +242 -0
- package/node_modules/playwright/lib/runner/index.js +8721 -0
- package/node_modules/playwright/lib/runner/index.js.txt +62 -0
- package/node_modules/playwright/lib/transform/babelBundle.js +72490 -0
- package/node_modules/playwright/lib/transform/babelBundle.js.LICENSE +2384 -0
- package/node_modules/playwright/lib/transform/babelBundle.js.txt +328 -0
- package/node_modules/playwright/lib/transform/esmLoader.js +8213 -0
- package/node_modules/playwright/lib/transform/esmLoader.js.LICENSE +355 -0
- package/node_modules/playwright/lib/transform/esmLoader.js.txt +60 -0
- package/node_modules/playwright/lib/util.js +373 -0
- package/node_modules/playwright/lib/worker/workerProcessEntry.js +1860 -0
- package/node_modules/playwright/lib/worker/workerProcessEntry.js.txt +19 -0
- package/node_modules/playwright/package.json +50 -0
- package/node_modules/playwright/test.d.ts +18 -0
- package/node_modules/playwright/test.js +24 -0
- package/node_modules/playwright/test.mjs +35 -0
- package/node_modules/playwright/types/test.d.ts +11191 -0
- package/node_modules/playwright/types/testReporter.d.ts +950 -0
- package/package.json +21 -12
- package/dist/actions/desktopActions.d.ts +0 -58
- package/dist/actions/desktopActions.js +0 -155
- package/dist/actions/index.d.ts +0 -27
- package/dist/actions/index.js +0 -11
- package/dist/actions/memoryActions.d.ts +0 -9
- package/dist/actions/memoryActions.js +0 -34
- package/dist/actions/taskActions.d.ts +0 -8
- package/dist/actions/taskActions.js +0 -27
- package/dist/actions/types.d.ts +0 -35
- package/dist/actions/types.js +0 -5
- package/dist/actions/util.d.ts +0 -21
- package/dist/actions/util.js +0 -280
- package/dist/actions/webActions.d.ts +0 -87
- package/dist/actions/webActions.js +0 -214
- package/dist/actions/webActions.test.d.ts +0 -1
- package/dist/actions/webActions.test.js +0 -43
- package/dist/agent/browserAgent.d.ts +0 -31
- package/dist/agent/browserAgent.js +0 -136
- package/dist/agent/errors.d.ts +0 -22
- package/dist/agent/errors.js +0 -97
- package/dist/agent/index.d.ts +0 -64
- package/dist/agent/index.js +0 -505
- package/dist/agent/narrator.d.ts +0 -4
- package/dist/agent/narrator.js +0 -63
- package/dist/agent/pause.test.d.ts +0 -1
- package/dist/agent/pause.test.js +0 -194
- package/dist/ai/baml_client/async_client.d.ts +0 -64
- package/dist/ai/baml_client/async_client.js +0 -284
- package/dist/ai/baml_client/async_request.d.ts +0 -39
- package/dist/ai/baml_client/async_request.js +0 -134
- package/dist/ai/baml_client/config.d.ts +0 -11
- package/dist/ai/baml_client/config.js +0 -20
- package/dist/ai/baml_client/globals.d.ts +0 -16
- package/dist/ai/baml_client/globals.js +0 -37
- package/dist/ai/baml_client/index.d.ts +0 -17
- package/dist/ai/baml_client/index.js +0 -42
- package/dist/ai/baml_client/inlinedbaml.d.ts +0 -19
- package/dist/ai/baml_client/inlinedbaml.js +0 -31
- package/dist/ai/baml_client/parser.d.ts +0 -53
- package/dist/ai/baml_client/parser.js +0 -86
- package/dist/ai/baml_client/partial_types.d.ts +0 -61
- package/dist/ai/baml_client/partial_types.js +0 -10
- package/dist/ai/baml_client/sync_client.d.ts +0 -57
- package/dist/ai/baml_client/sync_client.js +0 -142
- package/dist/ai/baml_client/sync_request.d.ts +0 -37
- package/dist/ai/baml_client/sync_request.js +0 -134
- package/dist/ai/baml_client/tracing.d.ts +0 -16
- package/dist/ai/baml_client/tracing.js +0 -18
- package/dist/ai/baml_client/type_builder.d.ts +0 -40
- package/dist/ai/baml_client/type_builder.js +0 -120
- package/dist/ai/baml_client/types.d.ts +0 -69
- package/dist/ai/baml_client/types.js +0 -15
- package/dist/ai/baml_client/watchers.d.ts +0 -32
- package/dist/ai/baml_client/watchers.js +0 -50
- package/dist/ai/baseten.d.ts +0 -4
- package/dist/ai/baseten.js +0 -10
- package/dist/ai/claudeCode.d.ts +0 -1
- package/dist/ai/claudeCode.js +0 -186
- package/dist/ai/modelHarness.d.ts +0 -39
- package/dist/ai/modelHarness.js +0 -324
- package/dist/ai/modelResponseError.d.ts +0 -4
- package/dist/ai/modelResponseError.js +0 -8
- package/dist/ai/multiModelHarness.d.ts +0 -24
- package/dist/ai/multiModelHarness.js +0 -52
- package/dist/ai/plannerResponse.d.ts +0 -34
- package/dist/ai/plannerResponse.js +0 -96
- package/dist/ai/plannerResponse.test.d.ts +0 -1
- package/dist/ai/plannerResponse.test.js +0 -112
- package/dist/ai/structuredOutput.d.ts +0 -11
- package/dist/ai/structuredOutput.js +0 -94
- package/dist/ai/structuredOutput.test.d.ts +0 -1
- package/dist/ai/structuredOutput.test.js +0 -91
- package/dist/ai/types.d.ts +0 -119
- package/dist/ai/types.js +0 -5
- package/dist/ai/util.d.ts +0 -13
- package/dist/ai/util.js +0 -200
- package/dist/ai/util.test.d.ts +0 -1
- package/dist/ai/util.test.js +0 -95
- package/dist/cli.js +0 -3
- package/dist/common/actions.js +0 -14
- package/dist/common/events.d.ts +0 -17
- package/dist/common/events.js +0 -3
- package/dist/common/failure.d.ts +0 -68
- package/dist/common/failure.js +0 -1
- package/dist/common/index.d.ts +0 -3
- package/dist/common/index.js +0 -3
- package/dist/common/operation.d.ts +0 -31
- package/dist/common/operation.js +0 -102
- package/dist/common/operation.test.d.ts +0 -1
- package/dist/common/operation.test.js +0 -53
- package/dist/common/retry.d.ts +0 -16
- package/dist/common/retry.js +0 -35
- package/dist/common/util.d.ts +0 -23
- package/dist/common/util.js +0 -139
- package/dist/connectors/browserConnector.d.ts +0 -53
- package/dist/connectors/browserConnector.js +0 -290
- package/dist/connectors/desktopConnector.d.ts +0 -58
- package/dist/connectors/desktopConnector.js +0 -68
- package/dist/connectors/index.d.ts +0 -14
- package/dist/connectors/index.js +0 -2
- package/dist/index.js +0 -28
- package/dist/logger.d.ts +0 -3
- package/dist/logger.js +0 -15
- package/dist/memory/agentMemory.d.ts +0 -47
- package/dist/memory/agentMemory.js +0 -167
- package/dist/memory/agentMemory.test.d.ts +0 -1
- package/dist/memory/agentMemory.test.js +0 -150
- package/dist/memory/image.d.ts +0 -28
- package/dist/memory/image.js +0 -95
- package/dist/memory/image.test.d.ts +0 -1
- package/dist/memory/image.test.js +0 -46
- package/dist/memory/index.d.ts +0 -3
- package/dist/memory/index.js +0 -3
- package/dist/memory/masking.d.ts +0 -7
- package/dist/memory/masking.js +0 -141
- package/dist/memory/masking.test.d.ts +0 -1
- package/dist/memory/masking.test.js +0 -117
- package/dist/memory/notebook.d.ts +0 -58
- package/dist/memory/notebook.js +0 -75
- package/dist/memory/notebook.test.d.ts +0 -1
- package/dist/memory/notebook.test.js +0 -99
- package/dist/memory/observation.d.ts +0 -38
- package/dist/memory/observation.js +0 -79
- package/dist/memory/rendering/index.d.ts +0 -10
- package/dist/memory/rendering/index.js +0 -13
- package/dist/memory/rendering/renderJsonParts.d.ts +0 -3
- package/dist/memory/rendering/renderJsonParts.js +0 -115
- package/dist/memory/rendering/renderJsonParts.test.d.ts +0 -1
- package/dist/memory/rendering/renderJsonParts.test.js +0 -217
- package/dist/memory/rendering/renderXmlParts.d.ts +0 -7
- package/dist/memory/rendering/renderXmlParts.js +0 -127
- package/dist/memory/serde.d.ts +0 -20
- package/dist/memory/serde.js +0 -67
- package/dist/memory/serde.test.d.ts +0 -1
- package/dist/memory/serde.test.js +0 -64
- package/dist/memory/util.d.ts +0 -2
- package/dist/memory/util.js +0 -17
- package/dist/telemetry/events.d.ts +0 -9
- package/dist/telemetry/events.js +0 -80
- package/dist/telemetry/index.d.ts +0 -6
- package/dist/telemetry/index.js +0 -91
- package/dist/types.d.ts +0 -30
- package/dist/types.js +0 -1
- package/dist/util.d.ts +0 -1
- package/dist/util.js +0 -12
- package/dist/version.d.ts +0 -1
- package/dist/version.js +0 -3
- package/dist/web/browserProvider.d.ts +0 -24
- package/dist/web/browserProvider.js +0 -164
- package/dist/web/browserProvider.test.d.ts +0 -1
- package/dist/web/browserProvider.test.js +0 -44
- package/dist/web/harness.d.ts +0 -109
- package/dist/web/harness.js +0 -401
- package/dist/web/recovery.d.ts +0 -46
- package/dist/web/recovery.js +0 -137
- package/dist/web/recovery.test.d.ts +0 -1
- package/dist/web/recovery.test.js +0 -182
- package/dist/web/stability.d.ts +0 -57
- package/dist/web/stability.js +0 -323
- package/dist/web/tabs.d.ts +0 -58
- package/dist/web/tabs.js +0 -293
- package/dist/web/transformer.d.ts +0 -7
- package/dist/web/transformer.js +0 -41
- package/dist/web/types.d.ts +0 -37
- package/dist/web/types.js +0 -2
- package/dist/web/util.d.ts +0 -3
- package/dist/web/util.js +0 -81
- package/dist/web/visualizer/cursor.d.ts +0 -16
- package/dist/web/visualizer/cursor.js +0 -153
- package/dist/web/visualizer/index.d.ts +0 -22
- package/dist/web/visualizer/index.js +0 -47
- package/dist/web/visualizer/mouseEffects.d.ts +0 -18
- package/dist/web/visualizer/mouseEffects.js +0 -287
- package/dist/web/visualizer/typeEffects.d.ts +0 -10
- package/dist/web/visualizer/typeEffects.js +0 -190
- package/dist/web/zodReexport.test.d.ts +0 -1
- package/dist/web/zodReexport.test.js +0 -14
- /package/{dist/common/actions.d.ts → node_modules/patchright-core/.bun-tag-19f23bd68c84ec1f} +0 -0
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ActionDefinition } from '@/actions';
|
|
2
|
-
import { Observation } from '@/memory/observation';
|
|
3
|
-
import type { Action } from '@/actions/types';
|
|
4
|
-
import type { OperationOptions } from '@/common/operation';
|
|
5
|
-
export interface AgentConnector {
|
|
6
|
-
id: string;
|
|
7
|
-
onStart?(): Promise<void>;
|
|
8
|
-
onStop?(): Promise<void>;
|
|
9
|
-
beforeAction?(action: Action, options?: OperationOptions): Promise<void>;
|
|
10
|
-
onTaskStart?(options?: OperationOptions): void;
|
|
11
|
-
getActionSpace?(): ActionDefinition<any>[];
|
|
12
|
-
collectObservations?(options?: OperationOptions): Promise<Observation[]>;
|
|
13
|
-
getInstructions?(options?: OperationOptions): Promise<void | string>;
|
|
14
|
-
}
|
package/dist/connectors/index.js
DELETED
package/dist/index.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
process.env.BAML_LOG = 'off';
|
|
2
|
-
import { setLogLevel } from '@/ai/baml_client/config';
|
|
3
|
-
export { Agent } from "@/agent";
|
|
4
|
-
export { createAction } from '@/actions';
|
|
5
|
-
export { BrowserAgent, startBrowserAgent } from '@/agent/browserAgent';
|
|
6
|
-
//export { Magnus } from "@/agent/magnus";
|
|
7
|
-
//export type { AgentOptions as TestCaseAgentOptions } from "@/agent";
|
|
8
|
-
export * from "@/agent";
|
|
9
|
-
export * from "@/memory";
|
|
10
|
-
export * from "@/web/harness";
|
|
11
|
-
export * from "@/actions";
|
|
12
|
-
export * from "@/connectors";
|
|
13
|
-
export * from "@/web/browserProvider";
|
|
14
|
-
export * from "@/connectors/browserConnector";
|
|
15
|
-
export * from "@/connectors/desktopConnector";
|
|
16
|
-
export * from "@/agent/errors";
|
|
17
|
-
export * from "@/types";
|
|
18
|
-
export * from "@/ai/types";
|
|
19
|
-
export * from "@/web/types";
|
|
20
|
-
export { BrowserBlockedError } from '@/web/recovery';
|
|
21
|
-
export * from "@/actions/types";
|
|
22
|
-
export * from '@/common';
|
|
23
|
-
export * from "@/telemetry";
|
|
24
|
-
export { buildDefaultBrowserAgentOptions } from "@/ai/util";
|
|
25
|
-
export { logger } from './logger';
|
|
26
|
-
export { z } from 'zod';
|
|
27
|
-
//export { ModelUsage } from '@/ai/modelHarness';
|
|
28
|
-
setLogLevel('OFF');
|
package/dist/logger.d.ts
DELETED
package/dist/logger.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import pino from 'pino';
|
|
2
|
-
export const logger = pino({
|
|
3
|
-
level: process.env.MAGNITUDE_LOG_LEVEL || 'warn',
|
|
4
|
-
transport: process.stdout.isTTY ? {
|
|
5
|
-
target: 'pino-pretty',
|
|
6
|
-
options: {
|
|
7
|
-
colorize: !process.env.NO_COLOR,
|
|
8
|
-
translateTime: 'SYS:HH:MM:ss.l',
|
|
9
|
-
ignore: 'pid,hostname'
|
|
10
|
-
}
|
|
11
|
-
} : undefined
|
|
12
|
-
}).child({
|
|
13
|
-
name: "agent"
|
|
14
|
-
});
|
|
15
|
-
export default logger;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { MultiMediaMessage } from '@/ai/baml_client';
|
|
2
|
-
import { Observation, ObservationRetentionOptions, ObservationRole, ObservationSource } from './observation';
|
|
3
|
-
import { MultiMediaJson } from './serde';
|
|
4
|
-
import { Image as BamlImage } from '@boundaryml/baml';
|
|
5
|
-
import { type NoteInput } from './notebook';
|
|
6
|
-
export interface SerializedAgentMemory {
|
|
7
|
-
instructions?: string;
|
|
8
|
-
notes?: NoteInput[];
|
|
9
|
-
observations: {
|
|
10
|
-
source: ObservationSource;
|
|
11
|
-
role: ObservationRole;
|
|
12
|
-
timestamp: number;
|
|
13
|
-
data: MultiMediaJson;
|
|
14
|
-
options?: ObservationRetentionOptions;
|
|
15
|
-
}[];
|
|
16
|
-
}
|
|
17
|
-
export interface AgentMemoryOptions {
|
|
18
|
-
instructions?: string | null;
|
|
19
|
-
promptCaching?: boolean;
|
|
20
|
-
thoughtLimit?: number;
|
|
21
|
-
}
|
|
22
|
-
export interface MemoryRenderOptions {
|
|
23
|
-
/** Full audit history bypasses actor retention without changing actor visibility or cache state. */
|
|
24
|
-
history?: 'retained' | 'full';
|
|
25
|
-
}
|
|
26
|
-
export declare class AgentMemory {
|
|
27
|
-
private options;
|
|
28
|
-
private observations;
|
|
29
|
-
private notebook;
|
|
30
|
-
private visibleSourceIds;
|
|
31
|
-
private freezeMask?;
|
|
32
|
-
private cacheControlIndices;
|
|
33
|
-
constructor(options?: AgentMemoryOptions);
|
|
34
|
-
get instructions(): string | null;
|
|
35
|
-
render(options?: MemoryRenderOptions): Promise<MultiMediaMessage[]>;
|
|
36
|
-
simpleRender(): Promise<(BamlImage | string)[]>;
|
|
37
|
-
private observationPrefix;
|
|
38
|
-
private resolveNoteSource;
|
|
39
|
-
remember(note: NoteInput, expectedText?: string): void;
|
|
40
|
-
forget(key: string): void;
|
|
41
|
-
isEmpty(): boolean;
|
|
42
|
-
recordThought(content: string): void;
|
|
43
|
-
recordObservation(obs: Observation): void;
|
|
44
|
-
getLastThoughtMessage(): string | null;
|
|
45
|
-
toJSON(): Promise<SerializedAgentMemory>;
|
|
46
|
-
loadJSON(data: SerializedAgentMemory): Promise<void>;
|
|
47
|
-
}
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import { Observation } from './observation';
|
|
2
|
-
import { jsonToObservableData, observableDataToJson } from './serde';
|
|
3
|
-
import { applyMask, maskObservations } from './masking';
|
|
4
|
-
import { TaskNotebook } from './notebook';
|
|
5
|
-
// export interface FreezeState {
|
|
6
|
-
// //lastFrozenObservationIndex: number,
|
|
7
|
-
// // ^ just use length of mask
|
|
8
|
-
// visibilityMask: boolean[],
|
|
9
|
-
// }
|
|
10
|
-
const CACHE_CONTROL_LIMIT = 3; // Anthropic allows max of 4, we use static one on system, 3 can be cyclic
|
|
11
|
-
export class AgentMemory {
|
|
12
|
-
//public readonly events: EventEmitter<AgentMemoryEvents> = new EventEmitter();
|
|
13
|
-
options;
|
|
14
|
-
// Custom instructions relating to this memory instance (e.g. agent-level and/or task-level instructions)
|
|
15
|
-
//public readonly instructions: string | null;
|
|
16
|
-
observations = [];
|
|
17
|
-
notebook = new TaskNotebook();
|
|
18
|
-
visibleSourceIds = new Set();
|
|
19
|
-
//private freezeState?: FreezeState;
|
|
20
|
-
freezeMask;
|
|
21
|
-
cacheControlIndices = [];
|
|
22
|
-
constructor(options) {
|
|
23
|
-
//this.instructions = instructions ?? null;
|
|
24
|
-
this.options = {
|
|
25
|
-
instructions: options?.instructions ?? null,
|
|
26
|
-
promptCaching: options?.promptCaching ?? false,
|
|
27
|
-
//optimizeForPromptCaching: false,
|
|
28
|
-
thoughtLimit: options?.thoughtLimit ?? 20
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
get instructions() {
|
|
32
|
-
// why is this on memory? prob should just be on agent
|
|
33
|
-
return this.options.instructions;
|
|
34
|
-
}
|
|
35
|
-
async render(options) {
|
|
36
|
-
if (options?.history === 'full') {
|
|
37
|
-
const messages = [];
|
|
38
|
-
for (const [index, observation] of this.observations.entries()) {
|
|
39
|
-
messages.push(await observation.render({ prefix: this.observationPrefix(observation, index) }));
|
|
40
|
-
}
|
|
41
|
-
const notes = this.notebook.render();
|
|
42
|
-
if (notes)
|
|
43
|
-
messages.push({ role: 'user', cacheControl: false, content: [notes] });
|
|
44
|
-
return messages;
|
|
45
|
-
}
|
|
46
|
-
if (this.options.promptCaching && this.cacheControlIndices.length >= CACHE_CONTROL_LIMIT) {
|
|
47
|
-
this.freezeMask = undefined;
|
|
48
|
-
this.cacheControlIndices = [];
|
|
49
|
-
}
|
|
50
|
-
const mask = await maskObservations(this.observations, this.freezeMask);
|
|
51
|
-
// Preserve complete note actions in the audit, not obsolete facts in actor context.
|
|
52
|
-
this.observations.forEach((observation, index) => {
|
|
53
|
-
if (observation.retention?.type === 'notebook-write')
|
|
54
|
-
mask[index] = false;
|
|
55
|
-
});
|
|
56
|
-
const visibleObservations = applyMask(this.observations, mask);
|
|
57
|
-
this.visibleSourceIds = new Set([
|
|
58
|
-
...visibleObservations.filter(({ observation }) => observation.source.startsWith('connector:')).map(({ index }) => index),
|
|
59
|
-
...this.notebook.sourceIds(),
|
|
60
|
-
]);
|
|
61
|
-
const lastVisible = visibleObservations.at(-1);
|
|
62
|
-
if (lastVisible)
|
|
63
|
-
this.cacheControlIndices.push(lastVisible.index); // index WRT full observation list
|
|
64
|
-
let messages = [];
|
|
65
|
-
for (const { observation, index } of visibleObservations) {
|
|
66
|
-
const message = await observation.render({
|
|
67
|
-
prefix: this.observationPrefix(observation, index),
|
|
68
|
-
cacheControl: this.options.promptCaching && this.cacheControlIndices.includes(index)
|
|
69
|
-
});
|
|
70
|
-
messages.push(message);
|
|
71
|
-
}
|
|
72
|
-
if (this.options.promptCaching) {
|
|
73
|
-
this.freezeMask = mask;
|
|
74
|
-
}
|
|
75
|
-
const notes = this.notebook.render();
|
|
76
|
-
if (notes)
|
|
77
|
-
messages.push({ role: 'user', cacheControl: false, content: [notes] });
|
|
78
|
-
return messages;
|
|
79
|
-
}
|
|
80
|
-
async simpleRender() {
|
|
81
|
-
return (await this.render({ history: 'full' })).flatMap(message => message.content);
|
|
82
|
-
}
|
|
83
|
-
observationPrefix(observation, index) {
|
|
84
|
-
if (observation.source.startsWith('connector:'))
|
|
85
|
-
return [`[Observation ${index}] ${observation.source}\n`];
|
|
86
|
-
return observation.source.startsWith('action:taken') || observation.source === 'thought'
|
|
87
|
-
? [`[${new Date(observation.timestamp).toTimeString().split(' ')[0]}]: `] : [];
|
|
88
|
-
}
|
|
89
|
-
resolveNoteSource(observations, id) {
|
|
90
|
-
const observation = observations[id];
|
|
91
|
-
if (!observation?.source.startsWith('connector:'))
|
|
92
|
-
throw new Error(`Observation ${id} is not a captured connector source.`);
|
|
93
|
-
const data = observation.content;
|
|
94
|
-
const url = data && typeof data === 'object' && 'url' in data && typeof data.url === 'string' ? data.url : undefined;
|
|
95
|
-
return { observation: id, capturedAt: observation.timestamp, ...(url !== undefined ? { url } : {}) };
|
|
96
|
-
}
|
|
97
|
-
remember(note, expectedText) {
|
|
98
|
-
this.notebook.put(note, id => {
|
|
99
|
-
if (!this.visibleSourceIds.has(id))
|
|
100
|
-
throw new Error(`Observation ${id} is not shown in the current context or notebook.`);
|
|
101
|
-
return this.resolveNoteSource(this.observations, id);
|
|
102
|
-
}, expectedText);
|
|
103
|
-
}
|
|
104
|
-
forget(key) {
|
|
105
|
-
this.notebook.forget(key);
|
|
106
|
-
}
|
|
107
|
-
isEmpty() {
|
|
108
|
-
return this.observations.length === 0;
|
|
109
|
-
}
|
|
110
|
-
recordThought(content) {
|
|
111
|
-
this.observations.push(Observation.fromThought(content, { type: 'thought', limit: this.options.thoughtLimit }));
|
|
112
|
-
//this.events.emit('thought', content);
|
|
113
|
-
}
|
|
114
|
-
recordObservation(obs) {
|
|
115
|
-
this.observations.push(obs);
|
|
116
|
-
}
|
|
117
|
-
getLastThoughtMessage() {
|
|
118
|
-
for (let i = this.observations.length - 1; i >= 0; i--) {
|
|
119
|
-
const obs = this.observations[i];
|
|
120
|
-
// toString() is a little funky here, or the idea that thought might not just be text
|
|
121
|
-
if (obs.source.startsWith('thought'))
|
|
122
|
-
return obs.toString();
|
|
123
|
-
}
|
|
124
|
-
return null;
|
|
125
|
-
}
|
|
126
|
-
async toJSON() {
|
|
127
|
-
const observations = [];
|
|
128
|
-
for (const observation of this.observations) {
|
|
129
|
-
observations.push({
|
|
130
|
-
source: observation.source,
|
|
131
|
-
role: observation.role,
|
|
132
|
-
timestamp: observation.timestamp,
|
|
133
|
-
data: await observableDataToJson(observation.content),
|
|
134
|
-
options: observation.retention,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
const notes = this.notebook.toJSON();
|
|
138
|
-
return {
|
|
139
|
-
// TODO: include other options as well
|
|
140
|
-
...(this.options.instructions ? { instructions: this.options.instructions } : {}),
|
|
141
|
-
...(notes.length ? { notes } : {}),
|
|
142
|
-
observations: observations
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
// TODO: turn into class static method / rework cons
|
|
146
|
-
async loadJSON(data) {
|
|
147
|
-
//jsonToObservableData(data);
|
|
148
|
-
const observations = [];
|
|
149
|
-
for (const observation of data.observations) {
|
|
150
|
-
observations.push(new Observation(observation.source, observation.role, await jsonToObservableData(observation.data), observation.options, observation.timestamp));
|
|
151
|
-
}
|
|
152
|
-
// nvm
|
|
153
|
-
//this.instructions = this.instructions;
|
|
154
|
-
const notebook = new TaskNotebook();
|
|
155
|
-
for (const note of data.notes ?? [])
|
|
156
|
-
notebook.put(note, id => this.resolveNoteSource(observations, id));
|
|
157
|
-
this.observations = observations;
|
|
158
|
-
this.notebook = notebook;
|
|
159
|
-
this.visibleSourceIds.clear();
|
|
160
|
-
this.freezeMask = undefined;
|
|
161
|
-
this.cacheControlIndices = [];
|
|
162
|
-
// return {
|
|
163
|
-
// ...(this.instructions ? { instructions: this.instructions } : {}),
|
|
164
|
-
// observations: observations
|
|
165
|
-
// };
|
|
166
|
-
}
|
|
167
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { expect, test } from 'bun:test';
|
|
2
|
-
import sharp from 'sharp';
|
|
3
|
-
import { AgentMemory } from './agentMemory';
|
|
4
|
-
import { Observation } from './observation';
|
|
5
|
-
import { Image } from './image';
|
|
6
|
-
const screen = (n) => Observation.fromConnector('fixture', {
|
|
7
|
-
url: `https://fixture.invalid/record/${n}?filter=active`,
|
|
8
|
-
screenshot: new Image(sharp({ create: { width: 2, height: 2, channels: 3, background: { r: n * 13, g: 80, b: 120 } } }).png()),
|
|
9
|
-
}, { type: 'screenshot', limit: 2, dedupe: true });
|
|
10
|
-
const text = async (memory) => (await memory.render()).flatMap(message => message.content)
|
|
11
|
-
.filter(part => typeof part === 'string').join('');
|
|
12
|
-
for (const promptCaching of [false, true])
|
|
13
|
-
test(`full audit bypasses all actor filters without changing actor state, caching ${promptCaching}`, async () => {
|
|
14
|
-
const memory = new AgentMemory({ promptCaching, thoughtLimit: 1 });
|
|
15
|
-
memory.recordObservation(screen(0));
|
|
16
|
-
memory.recordObservation(screen(0)); // Identical screenshots remain separate audit events.
|
|
17
|
-
memory.recordObservation(Observation.fromActionTaken('memory:note', 'Obsolete fact', { type: 'notebook-write' }));
|
|
18
|
-
memory.recordObservation(Observation.fromActionResult('memory:note', 'Old result', { type: 'notebook-result', limit: 1 }));
|
|
19
|
-
memory.recordThought('Old thought');
|
|
20
|
-
memory.recordObservation(screen(1));
|
|
21
|
-
memory.recordObservation(screen(2));
|
|
22
|
-
memory.recordObservation(Observation.fromActionTaken('memory:forget', 'Forget obsolete fact', { type: 'notebook-write' }));
|
|
23
|
-
memory.recordObservation(Observation.fromActionResult('memory:forget', 'New result', { type: 'notebook-result', limit: 1 }));
|
|
24
|
-
memory.recordThought('Latest thought');
|
|
25
|
-
const saved = await memory.toJSON();
|
|
26
|
-
const control = new AgentMemory({ promptCaching, thoughtLimit: 1 });
|
|
27
|
-
await control.loadJSON(saved);
|
|
28
|
-
await memory.render();
|
|
29
|
-
await control.render();
|
|
30
|
-
const audit = await memory.render({ history: 'full' });
|
|
31
|
-
const auditText = audit.flatMap(message => message.content).filter(part => typeof part === 'string').join('');
|
|
32
|
-
expect(audit).toHaveLength(saved.observations.length);
|
|
33
|
-
expect(audit.every(message => !message.cacheControl)).toBe(true);
|
|
34
|
-
for (const expected of ['[Observation 0]', '[Observation 1]', 'Obsolete fact', 'Old result', 'Old thought', 'Forget obsolete fact']) {
|
|
35
|
-
expect(auditText).toContain(expected);
|
|
36
|
-
}
|
|
37
|
-
expect(() => memory.remember({ key: 'hidden', text: 'Audit is not actor visibility', sources: [0] })).toThrow('not shown');
|
|
38
|
-
expect(await memory.toJSON()).toEqual(saved);
|
|
39
|
-
expect(await memory.render()).toEqual(await control.render());
|
|
40
|
-
expect(await text(memory)).not.toContain('Obsolete fact');
|
|
41
|
-
});
|
|
42
|
-
for (const promptCaching of [false, true])
|
|
43
|
-
test(`notes survive screenshot and thought eviction with prompt caching ${promptCaching}`, async () => {
|
|
44
|
-
const memory = new AgentMemory({ promptCaching, thoughtLimit: 1 });
|
|
45
|
-
memory.recordObservation(screen(0));
|
|
46
|
-
expect(await text(memory)).toContain('[Observation 0]');
|
|
47
|
-
memory.remember({ key: 'record', text: 'Exact value: 791; status uncertain.', sources: [0] });
|
|
48
|
-
for (let i = 1; i < 15; i++) {
|
|
49
|
-
memory.recordThought(i === 1 ? 'Discard-this-old-thought' : `Intermediate check ${i}`);
|
|
50
|
-
memory.recordObservation(screen(i));
|
|
51
|
-
await memory.render();
|
|
52
|
-
}
|
|
53
|
-
const rendered = await text(memory);
|
|
54
|
-
expect(rendered).not.toContain('[Observation 0]');
|
|
55
|
-
expect(rendered).not.toContain('Discard-this-old-thought');
|
|
56
|
-
expect(rendered).toContain('Exact value: 791; status uncertain.');
|
|
57
|
-
expect(rendered).toContain('https://fixture.invalid/record/0?filter=active');
|
|
58
|
-
expect((await memory.render()).at(-1)?.cacheControl).toBe(false);
|
|
59
|
-
const saved = JSON.parse(JSON.stringify(await memory.toJSON()));
|
|
60
|
-
const restored = new AgentMemory({ promptCaching });
|
|
61
|
-
await restored.loadJSON(saved);
|
|
62
|
-
expect(await restored.toJSON()).toEqual(saved);
|
|
63
|
-
expect(await text(restored)).toContain('Exact value: 791; status uncertain.');
|
|
64
|
-
expect((await restored.simpleRender()).join('')).toContain('not independent evidence');
|
|
65
|
-
// Consolidation can reference provenance still shown in the notebook.
|
|
66
|
-
restored.remember({ key: 'consolidated', text: 'Prior observed value: 791.', sources: [0] });
|
|
67
|
-
restored.forget('record');
|
|
68
|
-
expect(await text(restored)).not.toContain('status uncertain');
|
|
69
|
-
});
|
|
70
|
-
test('only visible connector observations or retained note sources can be cited', async () => {
|
|
71
|
-
const memory = new AgentMemory();
|
|
72
|
-
memory.recordObservation(screen(0));
|
|
73
|
-
memory.recordObservation(Observation.fromThought('A model claim is not a source.'));
|
|
74
|
-
memory.recordObservation(Observation.fromActionTaken('answer', 'A model answer is not a source.'));
|
|
75
|
-
for (let i = 1; i < 4; i++)
|
|
76
|
-
memory.recordObservation(screen(i));
|
|
77
|
-
await memory.render();
|
|
78
|
-
for (const id of [0, 1, 2, 999, -1, 0.5]) {
|
|
79
|
-
expect(() => memory.remember({ key: 'invalid', text: 'claim', sources: [id] })).toThrow();
|
|
80
|
-
}
|
|
81
|
-
memory.remember({ key: 'observed', text: 'visible fact', sources: [5] });
|
|
82
|
-
memory.recordObservation(screen(4));
|
|
83
|
-
// Merely recording an observation does not make it model-visible.
|
|
84
|
-
expect(() => memory.remember({ key: 'not-seen', text: 'claim', sources: [6] })).toThrow();
|
|
85
|
-
expect((await memory.toJSON()).notes).toHaveLength(1);
|
|
86
|
-
});
|
|
87
|
-
test('loading legacy memory clears notes and visibility/cache state', async () => {
|
|
88
|
-
const memory = new AgentMemory({ promptCaching: true });
|
|
89
|
-
memory.recordObservation(screen(0));
|
|
90
|
-
await memory.render();
|
|
91
|
-
memory.remember({ key: 'old-task', text: 'old task fact', sources: [0] });
|
|
92
|
-
const legacy = new AgentMemory();
|
|
93
|
-
legacy.recordObservation(Observation.fromConnector('fixture', 'New task observation'));
|
|
94
|
-
await memory.loadJSON(await legacy.toJSON());
|
|
95
|
-
expect((await memory.toJSON()).notes).toBeUndefined();
|
|
96
|
-
expect(() => memory.remember({ key: 'premature', text: 'claim', sources: [0] })).toThrow();
|
|
97
|
-
expect(await text(memory)).not.toContain('old task fact');
|
|
98
|
-
expect(await text(memory)).toContain('New task observation');
|
|
99
|
-
});
|
|
100
|
-
test('malformed checkpoint provenance does not replace current memory', async () => {
|
|
101
|
-
const memory = new AgentMemory();
|
|
102
|
-
memory.recordObservation(screen(0));
|
|
103
|
-
const saved = await memory.toJSON();
|
|
104
|
-
await expect(memory.loadJSON({ ...saved, notes: [{ key: 'bad', text: 'claim', sources: [50] }] })).rejects.toThrow();
|
|
105
|
-
expect(await memory.toJSON()).toEqual(saved);
|
|
106
|
-
});
|
|
107
|
-
for (const promptCaching of [false, true])
|
|
108
|
-
test(`completed checks outlive the default thought window and can be corrected, caching ${promptCaching}`, async () => {
|
|
109
|
-
const memory = new AgentMemory({ promptCaching });
|
|
110
|
-
const url = `https://fixture.invalid/${crypto.randomUUID()}`;
|
|
111
|
-
memory.recordObservation(Observation.fromConnector('fixture', { url, value: 'pending' }, { type: 'state', limit: 1 }));
|
|
112
|
-
memory.recordThought('Original inspection finished.');
|
|
113
|
-
await memory.render();
|
|
114
|
-
memory.remember({ key: 'inspection', text: 'Checked record; observed status pending. Follow-up unresolved.', sources: [0] });
|
|
115
|
-
for (let i = 0; i < 35; i++) {
|
|
116
|
-
memory.recordObservation(Observation.fromConnector('fixture', `Other record ${i}`, { type: 'state', limit: 1 }));
|
|
117
|
-
memory.recordThought(`Unrelated check ${i}`);
|
|
118
|
-
await memory.render();
|
|
119
|
-
}
|
|
120
|
-
const rendered = await text(memory);
|
|
121
|
-
expect(rendered).not.toContain('Original inspection finished.');
|
|
122
|
-
expect(rendered).not.toContain('[Observation 0]');
|
|
123
|
-
expect(rendered).toContain('Checked record; observed status pending. Follow-up unresolved.');
|
|
124
|
-
// A legitimate later revisit can change the fact: no automatic "already seen" skip.
|
|
125
|
-
memory.recordObservation(Observation.fromConnector('fixture', { url, value: 'complete' }, { type: 'state', limit: 1 }));
|
|
126
|
-
const latestId = (await memory.toJSON()).observations.length - 1;
|
|
127
|
-
await memory.render();
|
|
128
|
-
memory.remember({ key: 'inspection', text: 'Rechecked record; now complete. No follow-up remains.', sources: [latestId] }, 'Checked record; observed status pending. Follow-up unresolved.');
|
|
129
|
-
const corrected = await text(memory);
|
|
130
|
-
expect(corrected).toContain('now complete');
|
|
131
|
-
expect(corrected).not.toContain('status pending');
|
|
132
|
-
expect((await memory.toJSON()).notes?.[0].sources).toEqual([latestId]);
|
|
133
|
-
expect((await memory.toJSON()).observations[0].data).toHaveProperty('value');
|
|
134
|
-
const saved = await memory.toJSON();
|
|
135
|
-
const restored = new AgentMemory({ promptCaching });
|
|
136
|
-
await restored.loadJSON(saved);
|
|
137
|
-
await restored.render();
|
|
138
|
-
expect(() => restored.remember({ key: 'inspection', text: 'A different record', sources: [latestId] })).toThrow('already exists');
|
|
139
|
-
expect(() => restored.remember({ key: 'inspection', text: 'Stale correction', sources: [latestId] }, 'Checked record; observed status pending. Follow-up unresolved.')).toThrow('exactly match');
|
|
140
|
-
expect(await restored.toJSON()).toEqual(saved);
|
|
141
|
-
});
|
|
142
|
-
test('duplicate keys in a checkpoint fail without replacing existing memory', async () => {
|
|
143
|
-
const memory = new AgentMemory();
|
|
144
|
-
memory.recordObservation(screen(0));
|
|
145
|
-
await memory.render();
|
|
146
|
-
memory.remember({ key: 'unique', text: 'Keep this fact', sources: [0] });
|
|
147
|
-
const saved = await memory.toJSON();
|
|
148
|
-
await expect(memory.loadJSON({ ...saved, notes: [...saved.notes, { ...saved.notes[0], text: 'Discarded duplicate' }] })).rejects.toThrow('already exists');
|
|
149
|
-
expect(await memory.toJSON()).toEqual(saved);
|
|
150
|
-
});
|
package/dist/memory/image.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { Image as BamlImage } from '@boundaryml/baml';
|
|
2
|
-
import { StoredMedia } from './serde';
|
|
3
|
-
import { Sharp } from 'sharp';
|
|
4
|
-
import sharp from 'sharp';
|
|
5
|
-
export type ImageMediaType = `image/${string}`;
|
|
6
|
-
export declare class Image {
|
|
7
|
-
/**
|
|
8
|
-
* Wrapper for a Sharp image with conveniences to go to/from base64, convert to BAML, or serialize as JSON
|
|
9
|
-
*/
|
|
10
|
-
private img;
|
|
11
|
-
private encoded?;
|
|
12
|
-
constructor(img: Sharp);
|
|
13
|
-
static fromBase64(base64: string): Image;
|
|
14
|
-
getFormat(): Promise<keyof sharp.FormatEnum>;
|
|
15
|
-
private encode;
|
|
16
|
-
/**
|
|
17
|
-
* Convert the image to a JSON representation
|
|
18
|
-
*/
|
|
19
|
-
toJson(): Promise<StoredMedia>;
|
|
20
|
-
toBase64(): Promise<string>;
|
|
21
|
-
toBaml(): Promise<BamlImage>;
|
|
22
|
-
saveToFile(filepath: string): Promise<void>;
|
|
23
|
-
getDimensions(): Promise<{
|
|
24
|
-
width: number;
|
|
25
|
-
height: number;
|
|
26
|
-
}>;
|
|
27
|
-
resize(width: number, height: number): Promise<Image>;
|
|
28
|
-
}
|
package/dist/memory/image.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { Image as BamlImage } from '@boundaryml/baml';
|
|
2
|
-
import sharp from 'sharp';
|
|
3
|
-
export class Image {
|
|
4
|
-
/**
|
|
5
|
-
* Wrapper for a Sharp image with conveniences to go to/from base64, convert to BAML, or serialize as JSON
|
|
6
|
-
*/
|
|
7
|
-
// represents the start of a pipeline
|
|
8
|
-
img;
|
|
9
|
-
encoded;
|
|
10
|
-
// Cached metadata property for sync access + required width/height properties
|
|
11
|
-
//private metadata: Sharp['metadata'] & { width: number, height: number };
|
|
12
|
-
//private content: string;
|
|
13
|
-
//private mediaType: ImageMediaType;
|
|
14
|
-
//constructor(type: 'url' | 'base64', content: string, mediaType: ImageMediaType) {
|
|
15
|
-
constructor(img) {
|
|
16
|
-
// Own the pipeline configuration; later caller edits cannot change it.
|
|
17
|
-
this.img = img.clone();
|
|
18
|
-
}
|
|
19
|
-
static fromBase64(base64) {
|
|
20
|
-
// if (!mediaType) {
|
|
21
|
-
// const match = base64.match(/^data:(.*?);base64,/);
|
|
22
|
-
// mediaType = match ? `image/${match[1]}` : undefined;
|
|
23
|
-
// }
|
|
24
|
-
// if (!mediaType) {
|
|
25
|
-
// throw new Error("Image media type must be specified either in base64 encoded string or in mediaType parameter");
|
|
26
|
-
// }
|
|
27
|
-
const base64Data = base64.replace(/^data:.*?;base64,/, '');
|
|
28
|
-
//return new Image('base64', base64Data, mediaType);
|
|
29
|
-
return new Image(sharp(Buffer.from(base64Data, 'base64')));
|
|
30
|
-
}
|
|
31
|
-
async getFormat() {
|
|
32
|
-
return (await this.encode()).format;
|
|
33
|
-
}
|
|
34
|
-
encode() {
|
|
35
|
-
// Share in-flight work across rendering, deduplication and checkpoints.
|
|
36
|
-
// Retain encoded strings, not both a Buffer and its base64 copy.
|
|
37
|
-
return this.encoded ??= this.img.clone().toBuffer({ resolveWithObject: true }).then(({ data, info }) => ({
|
|
38
|
-
base64: data.toString('base64'), format: info.format, width: info.width, height: info.height,
|
|
39
|
-
})).catch(error => {
|
|
40
|
-
this.encoded = undefined;
|
|
41
|
-
throw error;
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Convert the image to a JSON representation
|
|
46
|
-
*/
|
|
47
|
-
async toJson() {
|
|
48
|
-
// Source metadata can describe raw input or a pre-conversion format.
|
|
49
|
-
// Use the format of the bytes emitted by the Sharp pipeline.
|
|
50
|
-
const { base64, format } = await this.encode();
|
|
51
|
-
return {
|
|
52
|
-
type: 'media',
|
|
53
|
-
format,
|
|
54
|
-
storage: 'base64',
|
|
55
|
-
base64,
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
async toBase64() {
|
|
59
|
-
return (await this.encode()).base64;
|
|
60
|
-
}
|
|
61
|
-
async toBaml() {
|
|
62
|
-
const { format, base64 } = await this.toJson();
|
|
63
|
-
return BamlImage.fromBase64(`image/${format}`, base64);
|
|
64
|
-
}
|
|
65
|
-
async saveToFile(filepath) {
|
|
66
|
-
await this.img.clone().toFile(filepath);
|
|
67
|
-
//console.log(`Image saved to ${filepath}`);
|
|
68
|
-
}
|
|
69
|
-
async getDimensions() {
|
|
70
|
-
//const { width, height } = await this.img.clone().metadata();
|
|
71
|
-
// Need to convert to buffer in order for metadata to be updated - otherwise it returns metadata of the original image
|
|
72
|
-
const { width, height } = await this.encode();
|
|
73
|
-
if (!width || !height)
|
|
74
|
-
throw new Error("Unable to get dimensions from image");
|
|
75
|
-
return { width, height };
|
|
76
|
-
}
|
|
77
|
-
async resize(width, height) {
|
|
78
|
-
// if (this.type != 'base64') throw new Error("Only base64 images can be resized");
|
|
79
|
-
// const img = sharp(Buffer.from(this.content));
|
|
80
|
-
// const metadata = await img.metadata();
|
|
81
|
-
//console.log(`resizing to: ${width}, ${height}`);
|
|
82
|
-
//console.log("Before resizing:", await this.getDimensions());
|
|
83
|
-
// if (!metadata.width || !metadata.height)
|
|
84
|
-
const resizedImage = new Image(this.img.clone().resize({
|
|
85
|
-
// Round width/height since sometimes they are floats due to rounding errors - sharp will throw if not integers
|
|
86
|
-
width: Math.round(width),
|
|
87
|
-
height: Math.round(height),
|
|
88
|
-
fit: 'fill', // exact size, no cropping
|
|
89
|
-
kernel: sharp.kernel.lanczos3
|
|
90
|
-
}));
|
|
91
|
-
//resizedImage.saveToFile('foo.png');
|
|
92
|
-
//console.log("After resizing:", await resizedImage.getDimensions());
|
|
93
|
-
return resizedImage;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { expect, spyOn, test } from 'bun:test';
|
|
2
|
-
import sharp from 'sharp';
|
|
3
|
-
import { Image } from './image';
|
|
4
|
-
import { Observation } from './observation';
|
|
5
|
-
import { AgentMemory } from './agentMemory';
|
|
6
|
-
test('rendering, hashes and checkpoints share one in-flight encoding per image', async () => {
|
|
7
|
-
const image = new Image(sharp({ create: { width: 3, height: 4, channels: 3, background: '#123456' } }).png());
|
|
8
|
-
const observation = Observation.fromConnector('fixture', { screenshot: image });
|
|
9
|
-
const memory = new AgentMemory();
|
|
10
|
-
memory.recordObservation(observation);
|
|
11
|
-
const encode = spyOn(sharp.prototype, 'toBuffer');
|
|
12
|
-
try {
|
|
13
|
-
const [json] = await Promise.all([image.toJson(), memory.render(), observation.hash(), memory.toJSON(), image.getDimensions(), image.toBase64()]);
|
|
14
|
-
await Promise.all([memory.render(), observation.hash(), memory.toJSON(), image.toBaml()]);
|
|
15
|
-
expect(encode).toHaveBeenCalledTimes(1);
|
|
16
|
-
expect(await image.getDimensions()).toEqual({ width: 3, height: 4 });
|
|
17
|
-
json.base64 = 'Caller mutation';
|
|
18
|
-
expect((await image.toJson()).base64).not.toBe('Caller mutation');
|
|
19
|
-
}
|
|
20
|
-
finally {
|
|
21
|
-
encode.mockRestore();
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
test('an Image owns its pipeline configuration and resizing returns an independent image', async () => {
|
|
25
|
-
const pipeline = sharp({ create: { width: 3, height: 4, channels: 3, background: '#123456' } }).png();
|
|
26
|
-
const image = new Image(pipeline);
|
|
27
|
-
pipeline.resize(10, 20).jpeg();
|
|
28
|
-
expect(await image.getDimensions()).toEqual({ width: 3, height: 4 });
|
|
29
|
-
expect(await image.getFormat()).toBe('png');
|
|
30
|
-
const saved = await image.toJson();
|
|
31
|
-
const resized = await image.resize(8, 9);
|
|
32
|
-
expect(await resized.getDimensions()).toEqual({ width: 8, height: 9 });
|
|
33
|
-
expect(await image.toJson()).toEqual(saved);
|
|
34
|
-
});
|
|
35
|
-
test('failed image encodings are retryable rather than cached rejections', async () => {
|
|
36
|
-
const image = new Image(sharp({ create: { width: 2, height: 2, channels: 3, background: '#123456' } }).png());
|
|
37
|
-
const encode = spyOn(sharp.prototype, 'toBuffer').mockRejectedValueOnce(new Error('Transient encoding failure'));
|
|
38
|
-
try {
|
|
39
|
-
await expect(image.toJson()).rejects.toThrow('Transient encoding failure');
|
|
40
|
-
expect((await image.toJson()).format).toBe('png');
|
|
41
|
-
expect(encode).toHaveBeenCalledTimes(2);
|
|
42
|
-
}
|
|
43
|
-
finally {
|
|
44
|
-
encode.mockRestore();
|
|
45
|
-
}
|
|
46
|
-
});
|
package/dist/memory/index.d.ts
DELETED
package/dist/memory/index.js
DELETED
package/dist/memory/masking.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { Observation } from './observation';
|
|
2
|
-
export declare function maskObservations(observations: Observation[], freezeMask?: boolean[]): Promise<boolean[]>;
|
|
3
|
-
export interface MaskedObservation {
|
|
4
|
-
observation: Observation;
|
|
5
|
-
index: number;
|
|
6
|
-
}
|
|
7
|
-
export declare function applyMask(observations: Observation[], mask: boolean[]): MaskedObservation[];
|