@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
package/dist/agent/index.js
DELETED
|
@@ -1,505 +0,0 @@
|
|
|
1
|
-
import logger from '@/logger';
|
|
2
|
-
import EventEmitter from "eventemitter3";
|
|
3
|
-
import z from "zod";
|
|
4
|
-
import { Observation } from '@/memory/observation';
|
|
5
|
-
import { ActionLimitError, AgentBusyError, AgentError } from "@/agent/errors";
|
|
6
|
-
import { Operation, checkOperation, currentOperation, operationOptions, untilAborted } from '@/common/operation';
|
|
7
|
-
import { AgentMemory } from "@/memory";
|
|
8
|
-
import { taskActions } from "@/actions/taskActions";
|
|
9
|
-
import { memoryActions } from '@/actions/memoryActions';
|
|
10
|
-
import { NOTEBOOK_INSTRUCTIONS } from '@/memory/notebook';
|
|
11
|
-
import { traceAsync } from "@/ai/baml_client";
|
|
12
|
-
import { telemetrifyAgent } from '@/telemetry/events';
|
|
13
|
-
import { isClaude } from '@/ai/util';
|
|
14
|
-
import { retryOnError } from '@/common';
|
|
15
|
-
import { renderContentParts } from '@/memory/rendering';
|
|
16
|
-
import { MultiModelHarness } from '@/ai/multiModelHarness';
|
|
17
|
-
// Options for the startAgent helper function
|
|
18
|
-
const DEFAULT_CONFIG = {
|
|
19
|
-
actions: [...taskActions], // Default to taskActions; other actions come from connectors
|
|
20
|
-
connectors: [],
|
|
21
|
-
llm: {
|
|
22
|
-
provider: 'google-ai',
|
|
23
|
-
options: {
|
|
24
|
-
model: 'gemini-2.5-pro-preview-05-06',
|
|
25
|
-
apiKey: process.env.GOOGLE_API_KEY || "YOUR_GOOGLE_API_KEY"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
prompt: null,
|
|
29
|
-
telemetry: true,
|
|
30
|
-
maxActions: Infinity,
|
|
31
|
-
};
|
|
32
|
-
export class Agent {
|
|
33
|
-
// maybe remove conns/actions from options since stored sep
|
|
34
|
-
options; //Omit<Required<AgentOptions>, 'actions'>;
|
|
35
|
-
connectors;
|
|
36
|
-
actions; // actions from connectors + any other additional ones configured
|
|
37
|
-
memoryOptions;
|
|
38
|
-
models;
|
|
39
|
-
//public readonly model: ModelHarness;
|
|
40
|
-
//public readonly micro: GroundingService;
|
|
41
|
-
//public readonly events: EventEmitter<AgentEvents>;
|
|
42
|
-
//protected readonly _emitter: EventEmitter<AgentEvents>;
|
|
43
|
-
events = new EventEmitter();
|
|
44
|
-
//public readonly memory: AgentMemory;
|
|
45
|
-
doneActing;
|
|
46
|
-
_paused = false;
|
|
47
|
-
_pauseResolve = null;
|
|
48
|
-
activeOperation;
|
|
49
|
-
idle = Promise.resolve();
|
|
50
|
-
stopped = false;
|
|
51
|
-
latestTaskMemory; // | null = null;
|
|
52
|
-
constructor(baseConfig = {}) {
|
|
53
|
-
this.options = {
|
|
54
|
-
...DEFAULT_CONFIG,
|
|
55
|
-
...baseConfig,
|
|
56
|
-
connectors: baseConfig.connectors ?? [],
|
|
57
|
-
actions: [...(baseConfig.actions || DEFAULT_CONFIG.actions)],
|
|
58
|
-
};
|
|
59
|
-
if (baseConfig.maxActions !== undefined && (!Number.isSafeInteger(baseConfig.maxActions) || baseConfig.maxActions < 1)) {
|
|
60
|
-
throw new Error('maxActions must be a positive integer');
|
|
61
|
-
}
|
|
62
|
-
this.connectors = this.options.connectors;
|
|
63
|
-
// Aggregate actions from connectors
|
|
64
|
-
//const aggregatedActions = [...this.options.actions];
|
|
65
|
-
this.actions = [...this.options.actions];
|
|
66
|
-
for (const connector of this.connectors) {
|
|
67
|
-
this.actions.push(...(connector.getActionSpace ? connector.getActionSpace() : []));
|
|
68
|
-
}
|
|
69
|
-
for (const action of memoryActions) {
|
|
70
|
-
if (this.actions.some(existing => existing.name === action.name))
|
|
71
|
-
throw new Error(`Action name '${action.name}' is reserved for task memory.`);
|
|
72
|
-
this.actions.push(action);
|
|
73
|
-
}
|
|
74
|
-
// Deduplicate actions by name
|
|
75
|
-
// TODO: maybe error instead, or automatically differentiate them?
|
|
76
|
-
//this.options.actions = Array.from(new Map(aggregatedActions.map(actDef => [actDef.name, actDef])).values());
|
|
77
|
-
const llms = Array.isArray(this.options.llm) ? this.options.llm : [this.options.llm];
|
|
78
|
-
let doPromptCaching = false;
|
|
79
|
-
for (const client of llms) {
|
|
80
|
-
// If any LLM is prompt-caching compatible, turn on prompt caching overall for memory etc.
|
|
81
|
-
if (isClaude(client) && (client.provider === 'anthropic' || client.provider === 'claude-code')) {
|
|
82
|
-
// Prompt-caching compatible client
|
|
83
|
-
if ('promptCaching' in client.options && client.options.promptCaching !== undefined) {
|
|
84
|
-
doPromptCaching = client.options.promptCaching;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
// Default to true if not specified, and override on client config to true
|
|
88
|
-
doPromptCaching = true;
|
|
89
|
-
client.options.promptCaching = true;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
//this.model = new ModelHarness({ llm: this.options.llm });
|
|
94
|
-
this.models = new MultiModelHarness(llms);
|
|
95
|
-
this.models.events.on('tokensUsed', (usage) => this.events.emit('tokensUsed', usage), this);
|
|
96
|
-
this.doneActing = false;
|
|
97
|
-
this._paused = false;
|
|
98
|
-
this._pauseResolve = null;
|
|
99
|
-
this.memoryOptions = {
|
|
100
|
-
// TODO: maybe do if Gemini or other prompt caching supported providers as well
|
|
101
|
-
// Claude supports prompt caching but only via Anthropic, not on Bedrock
|
|
102
|
-
promptCaching: doPromptCaching
|
|
103
|
-
};
|
|
104
|
-
// Empty memory will get replaced on first act(), but this prevents errors from having undefined memory
|
|
105
|
-
this.latestTaskMemory = new AgentMemory(this.memoryOptions);
|
|
106
|
-
}
|
|
107
|
-
getConnector(connectorClass) {
|
|
108
|
-
return this.connectors.find(c => c instanceof connectorClass);
|
|
109
|
-
}
|
|
110
|
-
require(connectorClass) {
|
|
111
|
-
const connector = this.getConnector(connectorClass);
|
|
112
|
-
if (!connector)
|
|
113
|
-
throw new Error(`Missing required connector ${connectorClass}`);
|
|
114
|
-
return connector;
|
|
115
|
-
}
|
|
116
|
-
async start() {
|
|
117
|
-
checkOperation();
|
|
118
|
-
if (this.busy)
|
|
119
|
-
throw new AgentBusyError();
|
|
120
|
-
// Register telemetry if enabled - do on start instead of cons to prevent weird subclass event issues
|
|
121
|
-
if (this.options.telemetry)
|
|
122
|
-
telemetrifyAgent(this);
|
|
123
|
-
//console.log('setting up model')
|
|
124
|
-
await this.models.setup();
|
|
125
|
-
//console.log('done setting up model')
|
|
126
|
-
logger.info("Agent: Starting connectors...");
|
|
127
|
-
for (const connector of this.connectors) {
|
|
128
|
-
if (connector.onStart)
|
|
129
|
-
await connector.onStart();
|
|
130
|
-
}
|
|
131
|
-
this.events.emit('start');
|
|
132
|
-
this.stopped = false;
|
|
133
|
-
logger.info("Agent: All connectors started.");
|
|
134
|
-
// logger.info("Making initial observations...");
|
|
135
|
-
// await this._recordConnectorObservations();
|
|
136
|
-
// logger.info("Initial observations recorded");
|
|
137
|
-
// Initial observations are handled by the first getObservations call in exec
|
|
138
|
-
}
|
|
139
|
-
identifyAction(action) {
|
|
140
|
-
// Get definition corresponding to an action
|
|
141
|
-
const actionDefinition = this.actions.find(def => def.name === action.variant);
|
|
142
|
-
if (!actionDefinition) {
|
|
143
|
-
// It's possible the action name was from a connector that is no longer active,
|
|
144
|
-
// or the action space was not correctly aggregated.
|
|
145
|
-
throw new AgentError(`Undefined action type '${action.variant}'. Ensure agent is configured with appropriate action definitions from connectors.`);
|
|
146
|
-
}
|
|
147
|
-
return actionDefinition;
|
|
148
|
-
}
|
|
149
|
-
/** True until underlying work settles, including after a cancelled caller returns. */
|
|
150
|
-
get busy() {
|
|
151
|
-
return this.activeOperation !== undefined;
|
|
152
|
-
}
|
|
153
|
-
whenIdle() {
|
|
154
|
-
return this.idle;
|
|
155
|
-
}
|
|
156
|
-
async runOperation(options, fn) {
|
|
157
|
-
const inherited = currentOperation();
|
|
158
|
-
if (inherited?.owner === this)
|
|
159
|
-
inherited.check();
|
|
160
|
-
if (this.busy)
|
|
161
|
-
throw new AgentBusyError();
|
|
162
|
-
if (this.stopped)
|
|
163
|
-
throw new AgentError('Agent is stopped; call start() before using it');
|
|
164
|
-
const operation = new Operation(this, options);
|
|
165
|
-
this.activeOperation = operation;
|
|
166
|
-
let markIdle;
|
|
167
|
-
this.idle = new Promise(resolve => { markIdle = resolve; });
|
|
168
|
-
const worker = operation.run(async () => {
|
|
169
|
-
operation.check();
|
|
170
|
-
try {
|
|
171
|
-
return await fn();
|
|
172
|
-
}
|
|
173
|
-
finally {
|
|
174
|
-
operation.check(); // Preserve the cancellation/deadline cause through downstream errors.
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
const settled = worker.finally(() => {
|
|
178
|
-
operation.dispose();
|
|
179
|
-
this.activeOperation = undefined;
|
|
180
|
-
markIdle();
|
|
181
|
-
});
|
|
182
|
-
return untilAborted(settled, operation.signal);
|
|
183
|
-
}
|
|
184
|
-
async exec(action, memory, options = {}) {
|
|
185
|
-
return this.runOperation(options, () => this._exec(action, memory));
|
|
186
|
-
}
|
|
187
|
-
async _exec(action, memory) {
|
|
188
|
-
checkOperation();
|
|
189
|
-
/**
|
|
190
|
-
* Execute an action that belongs to this Agent's action space.
|
|
191
|
-
* Provide memory to record the action taken, its results, and any connector observations to that memory.
|
|
192
|
-
*/
|
|
193
|
-
let actionDefinition = this.identifyAction(action);
|
|
194
|
-
let input;
|
|
195
|
-
if (actionDefinition.schema instanceof z.ZodObject) {
|
|
196
|
-
let variant;
|
|
197
|
-
({ variant, ...input } = action);
|
|
198
|
-
}
|
|
199
|
-
else {
|
|
200
|
-
input = action.input;
|
|
201
|
-
}
|
|
202
|
-
let parsed = actionDefinition.schema.safeParse(input);
|
|
203
|
-
if (!parsed.success) {
|
|
204
|
-
throw new AgentError(`Generated action '${action.variant}' violates input schema: ${parsed.error.message}`, { adaptable: true });
|
|
205
|
-
}
|
|
206
|
-
const memoryOnly = memoryActions.includes(actionDefinition);
|
|
207
|
-
if (!memoryOnly)
|
|
208
|
-
for (const connector of this.connectors) {
|
|
209
|
-
await connector.beforeAction?.(action, operationOptions());
|
|
210
|
-
checkOperation();
|
|
211
|
-
}
|
|
212
|
-
this.events.emit('actionStarted', action);
|
|
213
|
-
checkOperation();
|
|
214
|
-
const data = await actionDefinition.resolver({ input: parsed.data, agent: this, memory, ...operationOptions() });
|
|
215
|
-
checkOperation();
|
|
216
|
-
this.events.emit('actionDone', action);
|
|
217
|
-
checkOperation();
|
|
218
|
-
if (memory) {
|
|
219
|
-
// Record action taken
|
|
220
|
-
memory.recordObservation(Observation.fromActionTaken(actionDefinition.name, JSON.stringify(action), memoryOnly ? { type: 'notebook-write' } : undefined));
|
|
221
|
-
// Record results of action
|
|
222
|
-
if (data) {
|
|
223
|
-
memory.recordObservation(Observation.fromActionResult(actionDefinition.name, data, memoryOnly ? { type: 'notebook-result', limit: 1 } : undefined));
|
|
224
|
-
}
|
|
225
|
-
// Collect and record observations from connectors
|
|
226
|
-
if (memoryOnly)
|
|
227
|
-
this.events.emit('observationsRecorded'); // Checkpoint notes without another browser capture.
|
|
228
|
-
else
|
|
229
|
-
await this._recordConnectorObservations(memory);
|
|
230
|
-
}
|
|
231
|
-
return data;
|
|
232
|
-
}
|
|
233
|
-
async _recordConnectorObservations(memory) {
|
|
234
|
-
checkOperation();
|
|
235
|
-
for (const connector of this.connectors) {
|
|
236
|
-
// could do Promise.all if matters
|
|
237
|
-
const connObservations = connector.collectObservations ? await connector.collectObservations(operationOptions()) : [];
|
|
238
|
-
checkOperation();
|
|
239
|
-
//observations.push(...connObservations);
|
|
240
|
-
for (const obs of connObservations) {
|
|
241
|
-
memory.recordObservation(obs);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
this.events.emit('observationsRecorded');
|
|
245
|
-
}
|
|
246
|
-
get memory() {
|
|
247
|
-
//if (!this.latestTaskMemory) throw new Error("No memory available");
|
|
248
|
-
return this.latestTaskMemory;
|
|
249
|
-
}
|
|
250
|
-
async act(taskOrSteps, options = {}) {
|
|
251
|
-
return this.runOperation(options, () => this._runAct(taskOrSteps, options));
|
|
252
|
-
}
|
|
253
|
-
async _runAct(taskOrSteps, options) {
|
|
254
|
-
const instructions = [
|
|
255
|
-
...(this.options.prompt ? [this.options.prompt] : []),
|
|
256
|
-
...(options.prompt ? [options.prompt] : []),
|
|
257
|
-
].join('\n');
|
|
258
|
-
const taskMemory = options.memory ?? new AgentMemory({ ...this.memoryOptions, instructions: instructions === '' ? undefined : instructions });
|
|
259
|
-
if (Array.isArray(taskOrSteps)) {
|
|
260
|
-
const steps = taskOrSteps;
|
|
261
|
-
//this.events.emit('actStarted', steps.join(', '));
|
|
262
|
-
// trace overall task
|
|
263
|
-
await (traceAsync('multistep', async (steps, options) => {
|
|
264
|
-
for (const step of steps) {
|
|
265
|
-
checkOperation();
|
|
266
|
-
this.events.emit('actStarted', step, options);
|
|
267
|
-
await this._traceAct(step, taskMemory, options);
|
|
268
|
-
checkOperation();
|
|
269
|
-
this.events.emit('actDone', step, options);
|
|
270
|
-
}
|
|
271
|
-
})(steps, options));
|
|
272
|
-
//this.events.emit('actDone', steps.join(', '));
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
const task = taskOrSteps;
|
|
276
|
-
this.events.emit('actStarted', task, options);
|
|
277
|
-
await this._traceAct(task, taskMemory, options);
|
|
278
|
-
checkOperation();
|
|
279
|
-
this.events.emit('actDone', task, options);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
async _traceAct(task, memory, options = {}) {
|
|
283
|
-
// memory not serializable to trace so bake it
|
|
284
|
-
await (traceAsync('act', async (task) => {
|
|
285
|
-
await this._act(task, memory, options);
|
|
286
|
-
})(task));
|
|
287
|
-
}
|
|
288
|
-
async _buildContext(memory, options) {
|
|
289
|
-
checkOperation();
|
|
290
|
-
const messages = await memory.render(options);
|
|
291
|
-
checkOperation();
|
|
292
|
-
const connectorInstructions = [];
|
|
293
|
-
for (const connector of this.connectors) {
|
|
294
|
-
if (connector.getInstructions) {
|
|
295
|
-
const instructions = await connector.getInstructions(operationOptions());
|
|
296
|
-
checkOperation();
|
|
297
|
-
if (instructions) {
|
|
298
|
-
connectorInstructions.push({
|
|
299
|
-
connectorId: connector.id,
|
|
300
|
-
instructions: instructions
|
|
301
|
-
});
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
return {
|
|
306
|
-
instructions: memory.instructions,
|
|
307
|
-
observationContent: messages,
|
|
308
|
-
//observationContent: content,
|
|
309
|
-
connectorInstructions: connectorInstructions
|
|
310
|
-
};
|
|
311
|
-
}
|
|
312
|
-
async _act(description, memory, options = {}) {
|
|
313
|
-
checkOperation();
|
|
314
|
-
this.doneActing = false;
|
|
315
|
-
for (const connector of this.connectors) {
|
|
316
|
-
connector.onTaskStart?.(operationOptions());
|
|
317
|
-
checkOperation();
|
|
318
|
-
}
|
|
319
|
-
logger.info(`Act: ${description}`);
|
|
320
|
-
// for now simply add data to task
|
|
321
|
-
let dataContentParts = [];
|
|
322
|
-
if (options.data) {
|
|
323
|
-
//description += "\nUse the following data where appropriate:\n";
|
|
324
|
-
// description += "\n<data>\n";
|
|
325
|
-
// // if (typeof options.data === 'string') {
|
|
326
|
-
// // description += options.data;
|
|
327
|
-
// // } else {
|
|
328
|
-
// // description += Object.entries(options.data).map(([k, v]) => `${k}: ${v}`).join("\n");
|
|
329
|
-
// // }
|
|
330
|
-
// const parts = renderParts(options.data);
|
|
331
|
-
// description += "\n</data>";
|
|
332
|
-
dataContentParts = await renderContentParts(options.data, { mode: 'json', indent: 2 });
|
|
333
|
-
}
|
|
334
|
-
//this.events.emit('stepStart', description);
|
|
335
|
-
//const testData = convertOptionsToTestData(options);
|
|
336
|
-
// Initialize task memory and record initial observations
|
|
337
|
-
// Combine any agent-level and task-level instructions
|
|
338
|
-
checkOperation();
|
|
339
|
-
this.latestTaskMemory = memory;
|
|
340
|
-
// record initial observations
|
|
341
|
-
logger.info("Making initial observations...");
|
|
342
|
-
await this._recordConnectorObservations(memory);
|
|
343
|
-
logger.info("Initial observations recorded");
|
|
344
|
-
let actionCount = 0;
|
|
345
|
-
while (true) {
|
|
346
|
-
checkOperation();
|
|
347
|
-
if (actionCount >= this.options.maxActions)
|
|
348
|
-
throw new ActionLimitError(this.options.maxActions);
|
|
349
|
-
// Removed direct screenshot/tabState access here; it's part of memoryContext via connectors
|
|
350
|
-
logger.info(`Creating partial recipe`);
|
|
351
|
-
let reasoning = "";
|
|
352
|
-
let actions = [];
|
|
353
|
-
let memoryUpdates = [];
|
|
354
|
-
try {
|
|
355
|
-
this.events.emit('planningStarted');
|
|
356
|
-
const memoryContext = await this._buildContext(memory);
|
|
357
|
-
memoryContext.connectorInstructions.unshift({ connectorId: 'task_memory', instructions: NOTEBOOK_INSTRUCTIONS });
|
|
358
|
-
await retryOnError(async () => {
|
|
359
|
-
({ reasoning, actions, memory_updates: memoryUpdates } = await this.models.partialAct(memoryContext, description, dataContentParts, this.actions));
|
|
360
|
-
checkOperation();
|
|
361
|
-
if (actions.length === 0) {
|
|
362
|
-
// Empty action list behavior - default wait else ... err? what if not in action space?
|
|
363
|
-
//actions.push()
|
|
364
|
-
throw new AgentError(`No actions generated`);
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
// HTTP body is not JSON - comes from Anthropic sometimes, weird error
|
|
368
|
-
// Sometimes Anthropic will give 401 Unauthorized randomly even when authorized
|
|
369
|
-
{
|
|
370
|
-
mode: 'retry_on_partial_message',
|
|
371
|
-
errorSubstrings: ['HTTP body is not JSON', '401 Unauthorized', 'No actions generated'],
|
|
372
|
-
retryLimit: 3,
|
|
373
|
-
delayMs: 1000,
|
|
374
|
-
showWarnOnRetry: true
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
catch (error) {
|
|
378
|
-
checkOperation();
|
|
379
|
-
logger.error(`Error planning actions: ${error instanceof Error ? error.message : String(error)}`);
|
|
380
|
-
/**
|
|
381
|
-
* (1) Failure to conform to JSON
|
|
382
|
-
* (2) Misconfigured BAML client / bad API key
|
|
383
|
-
* (3) Network error (past max retries)
|
|
384
|
-
*/
|
|
385
|
-
// this.fail({
|
|
386
|
-
// variant: 'misalignment',
|
|
387
|
-
// message: `Could not create partial recipe -> ${(error as Error).message}`
|
|
388
|
-
// });
|
|
389
|
-
throw new AgentError(`Error planning actions: ${error.message}`, { variant: 'misalignment' });
|
|
390
|
-
}
|
|
391
|
-
logger.info({ reasoning, actions }, `Partial recipe created`);
|
|
392
|
-
// Could be emitted in memory and bubbled up instead of recordThought was called in more places
|
|
393
|
-
this.events.emit('thought', reasoning);
|
|
394
|
-
checkOperation();
|
|
395
|
-
memory.recordThought(reasoning);
|
|
396
|
-
// Persist the review using the existing audited, budgeted note action.
|
|
397
|
-
// Empty reviews are free; each attempted write consumes one action.
|
|
398
|
-
const batch = [...memoryUpdates.map(note => ({ variant: 'memory:note', ...note })), ...actions];
|
|
399
|
-
for (const action of batch) {
|
|
400
|
-
await this._waitIfPaused();
|
|
401
|
-
checkOperation();
|
|
402
|
-
if (this.doneActing)
|
|
403
|
-
break;
|
|
404
|
-
if (actionCount >= this.options.maxActions)
|
|
405
|
-
throw new ActionLimitError(this.options.maxActions);
|
|
406
|
-
const result = await this._exec(action, memory);
|
|
407
|
-
actionCount++;
|
|
408
|
-
// Preserve the current page when an update fails. Successful
|
|
409
|
-
// earlier writes remain; the next plan sees the failure result.
|
|
410
|
-
if (action.variant === 'memory:note' && result?.saved === false)
|
|
411
|
-
break;
|
|
412
|
-
// const postActionScreenshot = await this.screenshot();
|
|
413
|
-
// const actionDescriptor: ActionDescriptor = { ...action, screenshot: postActionScreenshot.image } as ActionDescriptor;
|
|
414
|
-
// this.events.emit('action', actionDescriptor);
|
|
415
|
-
logger.info({ action }, `Action taken`);
|
|
416
|
-
}
|
|
417
|
-
// If macro expects these actions should complete the step, break
|
|
418
|
-
// if (finished) {
|
|
419
|
-
// break;
|
|
420
|
-
// }
|
|
421
|
-
await this._waitIfPaused();
|
|
422
|
-
if (this.doneActing) {
|
|
423
|
-
break;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
logger.info(`Done with step`);
|
|
427
|
-
//this.events.emit('stepSuccess');
|
|
428
|
-
//this.currentTaskMemory = null;
|
|
429
|
-
}
|
|
430
|
-
async query(query, schema, options = {}) {
|
|
431
|
-
return this.runOperation(options, async () => {
|
|
432
|
-
// Record observations in case no act() was used beforehand
|
|
433
|
-
await this._recordConnectorObservations(this.latestTaskMemory);
|
|
434
|
-
const memoryContext = await this._buildContext(this.memory, options);
|
|
435
|
-
return await this.models.query(memoryContext, query, schema);
|
|
436
|
-
});
|
|
437
|
-
}
|
|
438
|
-
async queueDone() {
|
|
439
|
-
checkOperation();
|
|
440
|
-
this.doneActing = true;
|
|
441
|
-
}
|
|
442
|
-
async _waitIfPaused() {
|
|
443
|
-
checkOperation();
|
|
444
|
-
if (!this._paused)
|
|
445
|
-
return;
|
|
446
|
-
this.events.emit('pause');
|
|
447
|
-
checkOperation();
|
|
448
|
-
if (!this._paused)
|
|
449
|
-
return; // A pause listener may have resumed synchronously.
|
|
450
|
-
logger.info("Agent: Paused");
|
|
451
|
-
try {
|
|
452
|
-
await untilAborted(new Promise((resolve) => {
|
|
453
|
-
this._pauseResolve = resolve;
|
|
454
|
-
}), currentOperation()?.signal);
|
|
455
|
-
}
|
|
456
|
-
finally {
|
|
457
|
-
this._pauseResolve = null;
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
pause() {
|
|
461
|
-
checkOperation();
|
|
462
|
-
this._paused = true;
|
|
463
|
-
}
|
|
464
|
-
resume() {
|
|
465
|
-
checkOperation();
|
|
466
|
-
this._paused = false;
|
|
467
|
-
if (this._pauseResolve) {
|
|
468
|
-
this._pauseResolve();
|
|
469
|
-
this._pauseResolve = null;
|
|
470
|
-
}
|
|
471
|
-
this.events.emit('resume');
|
|
472
|
-
logger.info("Agent: Resumed");
|
|
473
|
-
}
|
|
474
|
-
get paused() {
|
|
475
|
-
return this._paused;
|
|
476
|
-
}
|
|
477
|
-
async stop() {
|
|
478
|
-
checkOperation();
|
|
479
|
-
/**
|
|
480
|
-
* Stop the agent and close the browser context.
|
|
481
|
-
* May be called asynchronously and interrupt an agent in the middle of a action sequence.
|
|
482
|
-
*/
|
|
483
|
-
this.stopped = true;
|
|
484
|
-
this.activeOperation?.cancel('Agent stopped');
|
|
485
|
-
this.doneActing = true;
|
|
486
|
-
if (this._paused) {
|
|
487
|
-
this._paused = false;
|
|
488
|
-
this._pauseResolve?.();
|
|
489
|
-
this._pauseResolve = null;
|
|
490
|
-
}
|
|
491
|
-
logger.info("Agent: Stopping connectors...");
|
|
492
|
-
for (const connector of this.connectors) {
|
|
493
|
-
try {
|
|
494
|
-
if (connector.onStop)
|
|
495
|
-
await connector.onStop();
|
|
496
|
-
}
|
|
497
|
-
catch (error) {
|
|
498
|
-
logger.warn(`Agent: Error stopping connector ${connector.id}: ${error instanceof Error ? error.message : String(error)}`);
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
this.events.emit('stop');
|
|
502
|
-
logger.info("Agent: All connectors stopped.");
|
|
503
|
-
logger.info("Agent: Stopped successfully.");
|
|
504
|
-
}
|
|
505
|
-
}
|
package/dist/agent/narrator.d.ts
DELETED
package/dist/agent/narrator.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { blueBright, bold, cyanBright, gray } from 'ansis';
|
|
2
|
-
export function narrateAgent(agent) {
|
|
3
|
-
let totalInputTokens = 0;
|
|
4
|
-
let totalOutputTokens = 0;
|
|
5
|
-
let totalCachedWriteInputTokens = 0;
|
|
6
|
-
let totalCachedReadInputTokens = 0;
|
|
7
|
-
let totalInputTokenCost = 0.0;
|
|
8
|
-
let totalOutputTokenCost = 0.0;
|
|
9
|
-
agent.events.on('tokensUsed', (usage) => {
|
|
10
|
-
totalInputTokens += usage.inputTokens;
|
|
11
|
-
totalOutputTokens += usage.outputTokens;
|
|
12
|
-
totalCachedWriteInputTokens += usage.cacheWriteInputTokens ?? 0;
|
|
13
|
-
totalCachedReadInputTokens += usage.cacheReadInputTokens ?? 0;
|
|
14
|
-
totalInputTokenCost += usage.inputCost ?? 0.0;
|
|
15
|
-
totalOutputTokenCost += usage.outputCost ?? 0.0;
|
|
16
|
-
});
|
|
17
|
-
agent.events.on('start', () => {
|
|
18
|
-
console.log(bold(blueBright(`▶ [start] agent started with ${agent.models.describe()}`)));
|
|
19
|
-
});
|
|
20
|
-
agent.events.on('stop', () => {
|
|
21
|
-
console.log(bold(blueBright(`■ [stop] agent stopped`)));
|
|
22
|
-
console.log(` Total usage: ` + bold `${totalInputTokens + totalCachedWriteInputTokens + totalCachedReadInputTokens}` + ` input tokens` + (totalCachedWriteInputTokens > 0 || totalCachedReadInputTokens > 0 ? ` (${totalCachedWriteInputTokens} cache write, ${totalCachedReadInputTokens} cache read)` : '') + ` / ` + bold `${totalOutputTokens}` + ` output tokens`);
|
|
23
|
-
if (totalInputTokenCost > 0 || totalOutputTokenCost > 0) {
|
|
24
|
-
if (agent.models.numUniqueModels === 1 && agent.models.describe().startsWith('claude-code')) {
|
|
25
|
-
console.log(` Cost: ` + cyanBright `None - using Claude Pro or Max subscription`);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
console.log(` Cost: $${(totalInputTokenCost + totalOutputTokenCost).toFixed(3)}`);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
// Show token usage and cost if available
|
|
32
|
-
// if (totalInputTokenCost > 0 || totalOutputTokenCost > 0) {
|
|
33
|
-
// console.log(` Total usage: ` + bold`${totalInputTokens}` + ` input tokens (` + `$${totalInputTokenCost.toFixed(3)}` + `)` + ` / ` + bold`${totalOutputTokens}` + ` output tokens (` + `$${totalOutputTokenCost.toFixed(3)}` + `)`);
|
|
34
|
-
// } else {
|
|
35
|
-
// console.log(` Total usage: ` + bold`${totalInputTokens}` + ` input tokens` + ` / ` + bold`${totalOutputTokens}` + ` output tokens`);
|
|
36
|
-
// }
|
|
37
|
-
});
|
|
38
|
-
agent.events.on('thought', (thought) => {
|
|
39
|
-
console.log(gray `${thought}`);
|
|
40
|
-
//console.log(gray`⚙︎ ${thought}`);
|
|
41
|
-
});
|
|
42
|
-
agent.events.on('actStarted', (task, options) => {
|
|
43
|
-
console.log(bold(cyanBright(`◆ [act] ${task}`)));
|
|
44
|
-
});
|
|
45
|
-
agent.events.on('actionStarted', (action) => {
|
|
46
|
-
const actionDefinition = agent.identifyAction(action);
|
|
47
|
-
console.log(bold ` ${actionDefinition.render(action)}`);
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
export function narrateBrowserAgent(agent) {
|
|
51
|
-
narrateAgent(agent);
|
|
52
|
-
agent.browserAgentEvents.on('nav', (url) => {
|
|
53
|
-
console.log(bold(cyanBright `⛓︎ [nav] ${url}`));
|
|
54
|
-
});
|
|
55
|
-
agent.browserAgentEvents.on('extractStarted', (instructions, schema) => {
|
|
56
|
-
console.log(bold(cyanBright `⛏ [extract] ${instructions}`));
|
|
57
|
-
});
|
|
58
|
-
agent.browserAgentEvents.on('extractDone', (instructions, data) => {
|
|
59
|
-
// console.log has a decent default formatter for arbitrary data e.g. objects
|
|
60
|
-
console.log(data);
|
|
61
|
-
//console.log(blueBright`${JSON.stringify(data, null, 2)}`);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|