@amalgm/browser 0.1.0
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/CHANGELOG.md +16 -0
- package/LICENSE +5 -0
- package/PURPOSE.md +117 -0
- package/README.md +120 -0
- package/SECURITY.md +49 -0
- package/dist/bin/amalgm-browser-mcp.d.ts +2 -0
- package/dist/bin/amalgm-browser-mcp.js +5 -0
- package/dist/bin/amalgm-browser-mcp.js.map +1 -0
- package/dist/bin/amalgm-browser-rest.d.ts +2 -0
- package/dist/bin/amalgm-browser-rest.js +20 -0
- package/dist/bin/amalgm-browser-rest.js.map +1 -0
- package/dist/bin/amalgm-browser.d.ts +2 -0
- package/dist/bin/amalgm-browser.js +4 -0
- package/dist/bin/amalgm-browser.js.map +1 -0
- package/dist/src/action.d.ts +5 -0
- package/dist/src/action.js +42 -0
- package/dist/src/action.js.map +1 -0
- package/dist/src/adapters/actions.d.ts +10 -0
- package/dist/src/adapters/actions.js +41 -0
- package/dist/src/adapters/actions.js.map +1 -0
- package/dist/src/adapters/cli/actions.d.ts +7 -0
- package/dist/src/adapters/cli/actions.js +63 -0
- package/dist/src/adapters/cli/actions.js.map +1 -0
- package/dist/src/adapters/cli/args.d.ts +8 -0
- package/dist/src/adapters/cli/args.js +41 -0
- package/dist/src/adapters/cli/args.js.map +1 -0
- package/dist/src/adapters/cli/help.d.ts +1 -0
- package/dist/src/adapters/cli/help.js +29 -0
- package/dist/src/adapters/cli/help.js.map +1 -0
- package/dist/src/adapters/cli/resources.d.ts +4 -0
- package/dist/src/adapters/cli/resources.js +116 -0
- package/dist/src/adapters/cli/resources.js.map +1 -0
- package/dist/src/adapters/cli/run.d.ts +7 -0
- package/dist/src/adapters/cli/run.js +108 -0
- package/dist/src/adapters/cli/run.js.map +1 -0
- package/dist/src/adapters/execute.d.ts +4 -0
- package/dist/src/adapters/execute.js +91 -0
- package/dist/src/adapters/execute.js.map +1 -0
- package/dist/src/adapters/http/auth-routes.d.ts +2 -0
- package/dist/src/adapters/http/auth-routes.js +93 -0
- package/dist/src/adapters/http/auth-routes.js.map +1 -0
- package/dist/src/adapters/http/events.d.ts +3 -0
- package/dist/src/adapters/http/events.js +20 -0
- package/dist/src/adapters/http/events.js.map +1 -0
- package/dist/src/adapters/http/internal-routes.d.ts +2 -0
- package/dist/src/adapters/http/internal-routes.js +35 -0
- package/dist/src/adapters/http/internal-routes.js.map +1 -0
- package/dist/src/adapters/http/openapi.d.ts +1 -0
- package/dist/src/adapters/http/openapi.js +78 -0
- package/dist/src/adapters/http/openapi.js.map +1 -0
- package/dist/src/adapters/http/profile-routes.d.ts +2 -0
- package/dist/src/adapters/http/profile-routes.js +42 -0
- package/dist/src/adapters/http/profile-routes.js.map +1 -0
- package/dist/src/adapters/http/recording-routes.d.ts +2 -0
- package/dist/src/adapters/http/recording-routes.js +41 -0
- package/dist/src/adapters/http/recording-routes.js.map +1 -0
- package/dist/src/adapters/http/request.d.ts +4 -0
- package/dist/src/adapters/http/request.js +44 -0
- package/dist/src/adapters/http/request.js.map +1 -0
- package/dist/src/adapters/http/server.d.ts +2 -0
- package/dist/src/adapters/http/server.js +114 -0
- package/dist/src/adapters/http/server.js.map +1 -0
- package/dist/src/adapters/http/session-routes.d.ts +2 -0
- package/dist/src/adapters/http/session-routes.js +54 -0
- package/dist/src/adapters/http/session-routes.js.map +1 -0
- package/dist/src/adapters/http/types.d.ts +29 -0
- package/dist/src/adapters/http/types.js +2 -0
- package/dist/src/adapters/http/types.js.map +1 -0
- package/dist/src/adapters/mcp/server.d.ts +3 -0
- package/dist/src/adapters/mcp/server.js +74 -0
- package/dist/src/adapters/mcp/server.js.map +1 -0
- package/dist/src/adapters/mcp/tools.d.ts +3 -0
- package/dist/src/adapters/mcp/tools.js +45 -0
- package/dist/src/adapters/mcp/tools.js.map +1 -0
- package/dist/src/adapters/mcp/types.d.ts +17 -0
- package/dist/src/adapters/mcp/types.js +2 -0
- package/dist/src/adapters/mcp/types.js.map +1 -0
- package/dist/src/adapters/toolbox/aliases.d.ts +5 -0
- package/dist/src/adapters/toolbox/aliases.js +14 -0
- package/dist/src/adapters/toolbox/aliases.js.map +1 -0
- package/dist/src/adapters/toolbox/executor.d.ts +6 -0
- package/dist/src/adapters/toolbox/executor.js +13 -0
- package/dist/src/adapters/toolbox/executor.js.map +1 -0
- package/dist/src/adapters/toolbox/manifest.d.ts +15 -0
- package/dist/src/adapters/toolbox/manifest.js +24 -0
- package/dist/src/adapters/toolbox/manifest.js.map +1 -0
- package/dist/src/artifacts.d.ts +14 -0
- package/dist/src/artifacts.js +28 -0
- package/dist/src/artifacts.js.map +1 -0
- package/dist/src/auth/filter.d.ts +3 -0
- package/dist/src/auth/filter.js +60 -0
- package/dist/src/auth/filter.js.map +1 -0
- package/dist/src/auth/login.d.ts +41 -0
- package/dist/src/auth/login.js +145 -0
- package/dist/src/auth/login.js.map +1 -0
- package/dist/src/auth/portable.d.ts +18 -0
- package/dist/src/auth/portable.js +48 -0
- package/dist/src/auth/portable.js.map +1 -0
- package/dist/src/auth/service.d.ts +29 -0
- package/dist/src/auth/service.js +104 -0
- package/dist/src/auth/service.js.map +1 -0
- package/dist/src/auth/transport.d.ts +8 -0
- package/dist/src/auth/transport.js +45 -0
- package/dist/src/auth/transport.js.map +1 -0
- package/dist/src/auth/vault.d.ts +10 -0
- package/dist/src/auth/vault.js +27 -0
- package/dist/src/auth/vault.js.map +1 -0
- package/dist/src/cli.d.ts +2 -0
- package/dist/src/cli.js +3 -0
- package/dist/src/cli.js.map +1 -0
- package/dist/src/cookies/coordinator.d.ts +17 -0
- package/dist/src/cookies/coordinator.js +93 -0
- package/dist/src/cookies/coordinator.js.map +1 -0
- package/dist/src/cookies/jar.d.ts +21 -0
- package/dist/src/cookies/jar.js +146 -0
- package/dist/src/cookies/jar.js.map +1 -0
- package/dist/src/cookies/policy.d.ts +6 -0
- package/dist/src/cookies/policy.js +58 -0
- package/dist/src/cookies/policy.js.map +1 -0
- package/dist/src/cookies/secret-file.d.ts +10 -0
- package/dist/src/cookies/secret-file.js +80 -0
- package/dist/src/cookies/secret-file.js.map +1 -0
- package/dist/src/cookies/types.d.ts +64 -0
- package/dist/src/cookies/types.js +2 -0
- package/dist/src/cookies/types.js.map +1 -0
- package/dist/src/cookies.d.ts +5 -0
- package/dist/src/cookies.js +5 -0
- package/dist/src/cookies.js.map +1 -0
- package/dist/src/defaults.d.ts +24 -0
- package/dist/src/defaults.js +107 -0
- package/dist/src/defaults.js.map +1 -0
- package/dist/src/drivers/cdp/capture.d.ts +5 -0
- package/dist/src/drivers/cdp/capture.js +39 -0
- package/dist/src/drivers/cdp/capture.js.map +1 -0
- package/dist/src/drivers/cdp/client.d.ts +8 -0
- package/dist/src/drivers/cdp/client.js +88 -0
- package/dist/src/drivers/cdp/client.js.map +1 -0
- package/dist/src/drivers/cdp/input.d.ts +2 -0
- package/dist/src/drivers/cdp/input.js +15 -0
- package/dist/src/drivers/cdp/input.js.map +1 -0
- package/dist/src/drivers/cdp/screencast.d.ts +2 -0
- package/dist/src/drivers/cdp/screencast.js +39 -0
- package/dist/src/drivers/cdp/screencast.js.map +1 -0
- package/dist/src/drivers/cdp/target.d.ts +4 -0
- package/dist/src/drivers/cdp/target.js +34 -0
- package/dist/src/drivers/cdp/target.js.map +1 -0
- package/dist/src/drivers/electron/advertisement.d.ts +12 -0
- package/dist/src/drivers/electron/advertisement.js +57 -0
- package/dist/src/drivers/electron/advertisement.js.map +1 -0
- package/dist/src/drivers/electron/contracts.d.ts +45 -0
- package/dist/src/drivers/electron/contracts.js +10 -0
- package/dist/src/drivers/electron/contracts.js.map +1 -0
- package/dist/src/drivers/electron/cookie-adapter.d.ts +17 -0
- package/dist/src/drivers/electron/cookie-adapter.js +69 -0
- package/dist/src/drivers/electron/cookie-adapter.js.map +1 -0
- package/dist/src/drivers/electron/driver.d.ts +19 -0
- package/dist/src/drivers/electron/driver.js +115 -0
- package/dist/src/drivers/electron/driver.js.map +1 -0
- package/dist/src/drivers/electron/native/adblock/cache.d.ts +4 -0
- package/dist/src/drivers/electron/native/adblock/cache.js +54 -0
- package/dist/src/drivers/electron/native/adblock/cache.js.map +1 -0
- package/dist/src/drivers/electron/native/adblock/cosmetics.d.ts +11 -0
- package/dist/src/drivers/electron/native/adblock/cosmetics.js +45 -0
- package/dist/src/drivers/electron/native/adblock/cosmetics.js.map +1 -0
- package/dist/src/drivers/electron/native/adblock/index.d.ts +44 -0
- package/dist/src/drivers/electron/native/adblock/index.js +153 -0
- package/dist/src/drivers/electron/native/adblock/index.js.map +1 -0
- package/dist/src/drivers/electron/native/adblock/policy.d.ts +2 -0
- package/dist/src/drivers/electron/native/adblock/policy.js +12 -0
- package/dist/src/drivers/electron/native/adblock/policy.js.map +1 -0
- package/dist/src/drivers/electron/native/adblock/preload.d.ts +1 -0
- package/dist/src/drivers/electron/native/adblock/preload.js +131 -0
- package/dist/src/drivers/electron/native/adblock/preload.js.map +1 -0
- package/dist/src/drivers/electron/native/adblock/settings.d.ts +9 -0
- package/dist/src/drivers/electron/native/adblock/settings.js +37 -0
- package/dist/src/drivers/electron/native/adblock/settings.js.map +1 -0
- package/dist/src/drivers/electron/native/config.d.ts +4 -0
- package/dist/src/drivers/electron/native/config.js +9 -0
- package/dist/src/drivers/electron/native/config.js.map +1 -0
- package/dist/src/drivers/electron/native/contracts.d.ts +174 -0
- package/dist/src/drivers/electron/native/contracts.js +20 -0
- package/dist/src/drivers/electron/native/contracts.js.map +1 -0
- package/dist/src/drivers/electron/native/policy.d.ts +7 -0
- package/dist/src/drivers/electron/native/policy.js +43 -0
- package/dist/src/drivers/electron/native/policy.js.map +1 -0
- package/dist/src/drivers/electron/native/session.d.ts +4 -0
- package/dist/src/drivers/electron/native/session.js +11 -0
- package/dist/src/drivers/electron/native/session.js.map +1 -0
- package/dist/src/drivers/electron/native/shell/adblock-ipc.d.ts +10 -0
- package/dist/src/drivers/electron/native/shell/adblock-ipc.js +44 -0
- package/dist/src/drivers/electron/native/shell/adblock-ipc.js.map +1 -0
- package/dist/src/drivers/electron/native/shell/context-menu.d.ts +11 -0
- package/dist/src/drivers/electron/native/shell/context-menu.js +129 -0
- package/dist/src/drivers/electron/native/shell/context-menu.js.map +1 -0
- package/dist/src/drivers/electron/native/shell/downloads.d.ts +11 -0
- package/dist/src/drivers/electron/native/shell/downloads.js +90 -0
- package/dist/src/drivers/electron/native/shell/downloads.js.map +1 -0
- package/dist/src/drivers/electron/native/shell/helpers.d.ts +5 -0
- package/dist/src/drivers/electron/native/shell/helpers.js +53 -0
- package/dist/src/drivers/electron/native/shell/helpers.js.map +1 -0
- package/dist/src/drivers/electron/native/shell/permissions.d.ts +16 -0
- package/dist/src/drivers/electron/native/shell/permissions.js +107 -0
- package/dist/src/drivers/electron/native/shell/permissions.js.map +1 -0
- package/dist/src/drivers/electron/native/shell/sites.d.ts +24 -0
- package/dist/src/drivers/electron/native/shell/sites.js +119 -0
- package/dist/src/drivers/electron/native/shell/sites.js.map +1 -0
- package/dist/src/drivers/electron/native/shell/types.d.ts +13 -0
- package/dist/src/drivers/electron/native/shell/types.js +2 -0
- package/dist/src/drivers/electron/native/shell/types.js.map +1 -0
- package/dist/src/drivers/electron/native/shell.d.ts +14 -0
- package/dist/src/drivers/electron/native/shell.js +115 -0
- package/dist/src/drivers/electron/native/shell.js.map +1 -0
- package/dist/src/drivers/electron/native/surface/commands.d.ts +4 -0
- package/dist/src/drivers/electron/native/surface/commands.js +49 -0
- package/dist/src/drivers/electron/native/surface/commands.js.map +1 -0
- package/dist/src/drivers/electron/native/surface/create.d.ts +4 -0
- package/dist/src/drivers/electron/native/surface/create.js +46 -0
- package/dist/src/drivers/electron/native/surface/create.js.map +1 -0
- package/dist/src/drivers/electron/native/surface/events.d.ts +3 -0
- package/dist/src/drivers/electron/native/surface/events.js +55 -0
- package/dist/src/drivers/electron/native/surface/events.js.map +1 -0
- package/dist/src/drivers/electron/native/surface/presentation.d.ts +15 -0
- package/dist/src/drivers/electron/native/surface/presentation.js +87 -0
- package/dist/src/drivers/electron/native/surface/presentation.js.map +1 -0
- package/dist/src/drivers/electron/native/surface/state.d.ts +7 -0
- package/dist/src/drivers/electron/native/surface/state.js +45 -0
- package/dist/src/drivers/electron/native/surface/state.js.map +1 -0
- package/dist/src/drivers/electron/native/surface/types.d.ts +39 -0
- package/dist/src/drivers/electron/native/surface/types.js +2 -0
- package/dist/src/drivers/electron/native/surface/types.js.map +1 -0
- package/dist/src/drivers/electron/native/surface-controller.d.ts +6 -0
- package/dist/src/drivers/electron/native/surface-controller.js +138 -0
- package/dist/src/drivers/electron/native/surface-controller.js.map +1 -0
- package/dist/src/drivers/electron/policy.d.ts +4 -0
- package/dist/src/drivers/electron/policy.js +39 -0
- package/dist/src/drivers/electron/policy.js.map +1 -0
- package/dist/src/drivers/electron/session.d.ts +4 -0
- package/dist/src/drivers/electron/session.js +5 -0
- package/dist/src/drivers/electron/session.js.map +1 -0
- package/dist/src/drivers/headless/command.d.ts +25 -0
- package/dist/src/drivers/headless/command.js +114 -0
- package/dist/src/drivers/headless/command.js.map +1 -0
- package/dist/src/drivers/headless/cookie-adapter.d.ts +16 -0
- package/dist/src/drivers/headless/cookie-adapter.js +59 -0
- package/dist/src/drivers/headless/cookie-adapter.js.map +1 -0
- package/dist/src/drivers/headless/driver.d.ts +31 -0
- package/dist/src/drivers/headless/driver.js +238 -0
- package/dist/src/drivers/headless/driver.js.map +1 -0
- package/dist/src/drivers/headless/executable.d.ts +8 -0
- package/dist/src/drivers/headless/executable.js +56 -0
- package/dist/src/drivers/headless/executable.js.map +1 -0
- package/dist/src/drivers/headless/screencast.d.ts +3 -0
- package/dist/src/drivers/headless/screencast.js +21 -0
- package/dist/src/drivers/headless/screencast.js.map +1 -0
- package/dist/src/electron.d.ts +14 -0
- package/dist/src/electron.js +15 -0
- package/dist/src/electron.js.map +1 -0
- package/dist/src/errors.d.ts +9 -0
- package/dist/src/errors.js +25 -0
- package/dist/src/errors.js.map +1 -0
- package/dist/src/events.d.ts +13 -0
- package/dist/src/events.js +32 -0
- package/dist/src/events.js.map +1 -0
- package/dist/src/headless.d.ts +3 -0
- package/dist/src/headless.js +4 -0
- package/dist/src/headless.js.map +1 -0
- package/dist/src/http.d.ts +3 -0
- package/dist/src/http.js +3 -0
- package/dist/src/http.js.map +1 -0
- package/dist/src/ids.d.ts +2 -0
- package/dist/src/ids.js +9 -0
- package/dist/src/ids.js.map +1 -0
- package/dist/src/index.d.ts +14 -0
- package/dist/src/index.js +11 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interaction/delta.d.ts +25 -0
- package/dist/src/interaction/delta.js +102 -0
- package/dist/src/interaction/delta.js.map +1 -0
- package/dist/src/interaction/typing.d.ts +39 -0
- package/dist/src/interaction/typing.js +189 -0
- package/dist/src/interaction/typing.js.map +1 -0
- package/dist/src/mcp.d.ts +3 -0
- package/dist/src/mcp.js +3 -0
- package/dist/src/mcp.js.map +1 -0
- package/dist/src/migration/legacy-cookies.d.ts +2 -0
- package/dist/src/migration/legacy-cookies.js +60 -0
- package/dist/src/migration/legacy-cookies.js.map +1 -0
- package/dist/src/migration/legacy-crypto.d.ts +1 -0
- package/dist/src/migration/legacy-crypto.js +35 -0
- package/dist/src/migration/legacy-crypto.js.map +1 -0
- package/dist/src/migration/legacy-migration.d.ts +20 -0
- package/dist/src/migration/legacy-migration.js +81 -0
- package/dist/src/migration/legacy-migration.js.map +1 -0
- package/dist/src/migration/legacy-rows.d.ts +5 -0
- package/dist/src/migration/legacy-rows.js +72 -0
- package/dist/src/migration/legacy-rows.js.map +1 -0
- package/dist/src/persistence/sqlite-registry.d.ts +32 -0
- package/dist/src/persistence/sqlite-registry.js +136 -0
- package/dist/src/persistence/sqlite-registry.js.map +1 -0
- package/dist/src/ports.d.ts +93 -0
- package/dist/src/ports.js +4 -0
- package/dist/src/ports.js.map +1 -0
- package/dist/src/process.d.ts +4 -0
- package/dist/src/process.js +63 -0
- package/dist/src/process.js.map +1 -0
- package/dist/src/product-service.d.ts +30 -0
- package/dist/src/product-service.js +38 -0
- package/dist/src/product-service.js.map +1 -0
- package/dist/src/profiles/directories.d.ts +9 -0
- package/dist/src/profiles/directories.js +57 -0
- package/dist/src/profiles/directories.js.map +1 -0
- package/dist/src/profiles/service.d.ts +30 -0
- package/dist/src/profiles/service.js +89 -0
- package/dist/src/profiles/service.js.map +1 -0
- package/dist/src/recording/encoder.d.ts +22 -0
- package/dist/src/recording/encoder.js +89 -0
- package/dist/src/recording/encoder.js.map +1 -0
- package/dist/src/recording/sampler.d.ts +18 -0
- package/dist/src/recording/sampler.js +33 -0
- package/dist/src/recording/sampler.js.map +1 -0
- package/dist/src/recording/service.d.ts +27 -0
- package/dist/src/recording/service.js +180 -0
- package/dist/src/recording/service.js.map +1 -0
- package/dist/src/recording/source.d.ts +1 -0
- package/dist/src/recording/source.js +21 -0
- package/dist/src/recording/source.js.map +1 -0
- package/dist/src/recording.d.ts +3 -0
- package/dist/src/recording.js +4 -0
- package/dist/src/recording.js.map +1 -0
- package/dist/src/registry.d.ts +15 -0
- package/dist/src/registry.js +46 -0
- package/dist/src/registry.js.map +1 -0
- package/dist/src/runtime-selector.d.ts +12 -0
- package/dist/src/runtime-selector.js +78 -0
- package/dist/src/runtime-selector.js.map +1 -0
- package/dist/src/service-options.d.ts +19 -0
- package/dist/src/service-options.js +2 -0
- package/dist/src/service-options.js.map +1 -0
- package/dist/src/service.d.ts +39 -0
- package/dist/src/service.js +204 -0
- package/dist/src/service.js.map +1 -0
- package/dist/src/sessions/leases.d.ts +10 -0
- package/dist/src/sessions/leases.js +41 -0
- package/dist/src/sessions/leases.js.map +1 -0
- package/dist/src/sessions/prune.d.ts +2 -0
- package/dist/src/sessions/prune.js +8 -0
- package/dist/src/sessions/prune.js.map +1 -0
- package/dist/src/testing.d.ts +18 -0
- package/dist/src/testing.js +21 -0
- package/dist/src/testing.js.map +1 -0
- package/dist/src/toolbox.d.ts +3 -0
- package/dist/src/toolbox.js +4 -0
- package/dist/src/toolbox.js.map +1 -0
- package/dist/src/types.d.ts +273 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/docs/ACTIONS.md +27 -0
- package/docs/ARCHITECTURE.md +71 -0
- package/docs/AUTHENTICATION.md +56 -0
- package/docs/AXIOMS.md +20 -0
- package/docs/CLI.md +61 -0
- package/docs/COMPATIBILITY.md +45 -0
- package/docs/COOKIES.md +61 -0
- package/docs/ELECTRON_INTEGRATION.md +87 -0
- package/docs/ENGINE_INTEGRATION.md +73 -0
- package/docs/EVENTS.md +30 -0
- package/docs/HEADLESS_RUNTIME.md +58 -0
- package/docs/MCP.md +36 -0
- package/docs/MIGRATION.md +64 -0
- package/docs/OPERATIONS.md +69 -0
- package/docs/README.md +21 -0
- package/docs/REALTIME_BOUNDARY.md +33 -0
- package/docs/RECORDING.md +55 -0
- package/docs/REST.md +69 -0
- package/docs/SDK.md +101 -0
- package/docs/TESTING.md +57 -0
- package/docs/TOOLBOX_INTEGRATION.md +34 -0
- package/docs/TROUBLESHOOTING.md +67 -0
- package/examples/basic.ts +7 -0
- package/examples/custom-driver.ts +45 -0
- package/package.json +78 -0
- package/skills/use-amalgm-browser/SKILL.md +42 -0
- package/skills/use-amalgm-browser/agents/openai.yaml +4 -0
- package/skills/use-amalgm-browser/references/actions.md +40 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
- Extract the Browser product into a standalone TypeScript package.
|
|
6
|
+
- Provide SDK, CLI, MCP, authenticated REST/SSE, Toolbox, and Browser skill surfaces.
|
|
7
|
+
- Provide headless Chromium and verified Electron visible-surface drivers.
|
|
8
|
+
- Add encrypted cookie portability, named auth bundles, human login handoffs,
|
|
9
|
+
browser computer use, capture, and WebM recording.
|
|
10
|
+
- Add Browser-owned SQLite persistence, cross-process session leases, and an
|
|
11
|
+
idempotent read-only migration from legacy Engine Browser state.
|
|
12
|
+
- Extract the native Electron `WebContentsView` shell, surface lifecycle,
|
|
13
|
+
partition cookie adapter, downloads, permissions, context menus, and ad
|
|
14
|
+
blocking behind the optional Electron export.
|
|
15
|
+
- Verify all 22 actions through SDK, CLI, MCP, REST, and Toolbox, plus real
|
|
16
|
+
Chromium and real Electron capture/recording harnesses.
|
package/LICENSE
ADDED
package/PURPOSE.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Amalgm Browser
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Amalgm Browser gives users and software agents one safe, persistent,
|
|
6
|
+
observable way to browse and operate the web across desktop and server
|
|
7
|
+
environments. It presents the same browser actions through an SDK, CLI, MCP,
|
|
8
|
+
and REST API while selecting the correct underlying browser implementation
|
|
9
|
+
from host context. In the macOS desktop app, browser work can occur in a
|
|
10
|
+
visible Electron surface that the user can watch and control. Everywhere else,
|
|
11
|
+
the same work runs in an isolated headless Chromium session. Browser state
|
|
12
|
+
belongs to Browser, never to Chat, Agents, Engine, or the application renderer.
|
|
13
|
+
|
|
14
|
+
Browser serves users browsing visibly in Amalgm, agents using Browser through
|
|
15
|
+
a Toolbox, background automations and sub-agents, standalone SDK and CLI
|
|
16
|
+
consumers, MCP and REST clients, and future browser-driver implementations.
|
|
17
|
+
|
|
18
|
+
Amalgm Engine is a composition root. It may provide host capabilities,
|
|
19
|
+
execution context, artifact storage, event relay, and UI composition through
|
|
20
|
+
public Browser ports. It does not own a second browser implementation.
|
|
21
|
+
|
|
22
|
+
## Primitives
|
|
23
|
+
|
|
24
|
+
- A **browser service** is the sole mutation boundary for one Browser state
|
|
25
|
+
directory.
|
|
26
|
+
- A **driver** implements browser actions for one backend kind: `electron` or
|
|
27
|
+
`headless`.
|
|
28
|
+
- A **profile** is a durable or ephemeral browser working identity.
|
|
29
|
+
- A **session** is one live automation lifetime bound to one driver and one
|
|
30
|
+
profile.
|
|
31
|
+
- A **page** is one web page belonging to one session.
|
|
32
|
+
- A **surface** is one visible Electron-hosted page belonging to one session.
|
|
33
|
+
- An **action** is one typed browser operation with backend-independent
|
|
34
|
+
meaning.
|
|
35
|
+
- A **capability** states whether a driver supports an operation.
|
|
36
|
+
- A **capture** is a bounded raster result from a session's actual page.
|
|
37
|
+
- A **recording** is a bounded capture lifecycle and its stored artifact.
|
|
38
|
+
- A **cookie jar** is Browser's encrypted logical cookie authority.
|
|
39
|
+
- A **cookie adapter** reconciles one driver's physical cookie store with the
|
|
40
|
+
logical jar.
|
|
41
|
+
- An **auth bundle** is an explicit encrypted snapshot of named browser
|
|
42
|
+
authentication state.
|
|
43
|
+
- A **login session** is a TTL-bound handoff for human authentication.
|
|
44
|
+
- An **event** is a sanitized Browser state transition.
|
|
45
|
+
- An **artifact store** persists Browser captures, downloads, traces, and
|
|
46
|
+
recordings without making Browser a workspace authority.
|
|
47
|
+
- A **registry** stores durable Browser metadata.
|
|
48
|
+
- A **runtime context** carries opaque caller, host, project, authorization,
|
|
49
|
+
cancellation, and artifact information into Browser.
|
|
50
|
+
|
|
51
|
+
## Axioms
|
|
52
|
+
|
|
53
|
+
1. Browser owns browser state and never depends on Chat, Agents, Engine,
|
|
54
|
+
Realtime, or an application renderer to define it.
|
|
55
|
+
2. Every state change passes through `BrowserService`; drivers execute actions
|
|
56
|
+
and adapters expose the service without reimplementing its rules.
|
|
57
|
+
3. Every live session belongs to exactly one backend and one profile, and its
|
|
58
|
+
backend never changes during that session.
|
|
59
|
+
4. Every page and visible surface belongs to exactly one session. Visible
|
|
60
|
+
identity is stamped and verified; ambiguity or mismatch fails closed before
|
|
61
|
+
an action, and reconnection may only recover the same verified surface.
|
|
62
|
+
5. A fresh compatible desktop host selects Electron, an explicit operator CDP
|
|
63
|
+
endpoint selects CDP-capable headless execution, and everything else selects
|
|
64
|
+
headless. A standalone headed window is always explicit.
|
|
65
|
+
6. One action has one meaning across drivers. Backend differences are explicit
|
|
66
|
+
capabilities or typed unsupported-operation errors.
|
|
67
|
+
7. Cancellation and deadlines reach the underlying CDP call, encoder, fetch,
|
|
68
|
+
or child process. Process execution uses argv, bounded output, and bounded
|
|
69
|
+
termination without a shell.
|
|
70
|
+
8. Browser output is bounded or externalized through an artifact store.
|
|
71
|
+
Screenshot and computer-use coordinates share CSS-pixel space.
|
|
72
|
+
9. Application authentication, the Electron `defaultSession`, the isolated
|
|
73
|
+
`persist:amalgm-browser` partition, and headless profile stores are separate
|
|
74
|
+
security domains. Browser never reads application authentication state.
|
|
75
|
+
10. Cross-backend cookie portability occurs only through the encrypted Browser
|
|
76
|
+
jar. Merges are record-level, deletions are tombstoned, partition identity
|
|
77
|
+
is preserved, protected hosts are rejected, and drivers never reach into
|
|
78
|
+
one another's stores.
|
|
79
|
+
11. Cookie values, tokens, origin storage, encryption keys, and authorization
|
|
80
|
+
headers never appear in logs, events, diagnostics, ordinary API results, or
|
|
81
|
+
resource projections. Automatic synchronization moves cookies only.
|
|
82
|
+
12. Profiles, cookie identity, auth bundles, and login sessions remain distinct.
|
|
83
|
+
Ephemeral profiles are pruned unless live or explicitly referenced; named
|
|
84
|
+
auth bundles move origin storage only when explicitly requested.
|
|
85
|
+
13. Secret-bearing writes are encrypted, integrity-checked, atomic, and
|
|
86
|
+
permission-restricted. A missing or corrupt automatic cookie jar degrades
|
|
87
|
+
ordinary browsing safely instead of exposing secrets or disabling actions.
|
|
88
|
+
14. Capture and recording resolve the session's actual page target without
|
|
89
|
+
first-target fallbacks. Recording proves capture before encoding, permits
|
|
90
|
+
one active recording per session, captures page imagery only, and stops an
|
|
91
|
+
uncooperative encoder within a deadline.
|
|
92
|
+
15. Browser emits sanitized events. Project, cwd, authorization, and artifact
|
|
93
|
+
destinations enter through explicit context and ports; Browser never
|
|
94
|
+
invents a workspace or synchronization authority.
|
|
95
|
+
16. Browser migrations are versioned, atomic, idempotent, and restart-safe.
|
|
96
|
+
Existing Browser data is reused or verified before any destructive change.
|
|
97
|
+
17. TypeScript under `src/` and `bin/` is the sole implementation source. The
|
|
98
|
+
SDK owns behavior; CLI, MCP, REST, Toolbox, and Electron IPC remain thin
|
|
99
|
+
adapters with parity tests.
|
|
100
|
+
18. Browser installs and operates without Engine or Electron. Behavior on an
|
|
101
|
+
unseen session follows from these axioms without another special case.
|
|
102
|
+
|
|
103
|
+
## Predictable behavior
|
|
104
|
+
|
|
105
|
+
Before session creation, the host context selects one capable backend. The
|
|
106
|
+
session keeps that backend until close; a lost visible page either verifies and
|
|
107
|
+
reattaches to its original stamped surface or fails before acting. All public
|
|
108
|
+
surfaces dispatch the same typed action through `BrowserService`. Headless work
|
|
109
|
+
stays headless unless a caller explicitly asks for a headed debug window.
|
|
110
|
+
|
|
111
|
+
The visible Electron partition and every headless profile keep physically
|
|
112
|
+
separate Chromium stores. Their adapters may reconcile individual cookie
|
|
113
|
+
records through Browser's encrypted jar, including tombstoned deletions, but
|
|
114
|
+
they cannot inspect one another. Named auth bundles are separate, explicit
|
|
115
|
+
snapshots. Captures, input coordinates, and recordings all address the same
|
|
116
|
+
verified page, while large artifacts leave the API through the injected store.
|
|
117
|
+
Engine and Realtime can compose and relay Browser without becoming Browser.
|
package/README.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# @amalgm/browser
|
|
2
|
+
|
|
3
|
+
Amalgm Browser is one browser product for visible desktop browsing and
|
|
4
|
+
isolated headless automation. Its TypeScript SDK owns behavior; the CLI, MCP
|
|
5
|
+
server, REST API, Toolbox manifest, Electron host integration, and packaged
|
|
6
|
+
skill are projections of the same actions.
|
|
7
|
+
|
|
8
|
+
Browser is independent of Amalgm Engine, Chat, Agents, Tools, and Realtime.
|
|
9
|
+
Read the [purpose and axioms](./PURPOSE.md) for the product contract.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
Node.js 20 or newer is required.
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @amalgm/browser
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Electron is an optional peer dependency. Server consumers can install and
|
|
20
|
+
import the core or headless exports without loading Electron.
|
|
21
|
+
|
|
22
|
+
## SDK quick start
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
import { createBrowser } from '@amalgm/browser';
|
|
26
|
+
|
|
27
|
+
const browser = createBrowser();
|
|
28
|
+
const session = await browser.createSession({ id: 'research' });
|
|
29
|
+
|
|
30
|
+
await browser.execute(session.id, {
|
|
31
|
+
type: 'open',
|
|
32
|
+
url: 'https://example.com',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const snapshot = await browser.execute(session.id, { type: 'snapshot' });
|
|
36
|
+
await browser.closeSession(session.id);
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Standalone use selects the bundled headless runtime. A desktop composition can
|
|
40
|
+
inject `ElectronBrowserDriver`; an explicit `AMALGM_BROWSER_CDP_URL` attaches
|
|
41
|
+
the headless driver to an operator-owned Chromium endpoint. Backend selection
|
|
42
|
+
happens before session creation and never changes during the session.
|
|
43
|
+
|
|
44
|
+
## CLI quick start
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
amalgm-browser open https://example.com --session research
|
|
48
|
+
amalgm-browser snapshot --session research
|
|
49
|
+
amalgm-browser click @e3 --session research
|
|
50
|
+
amalgm-browser screenshot --session research --full-page
|
|
51
|
+
amalgm-browser close --session research
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Machine-readable JSON is the normal output. Use `--timeout`, `--cwd`,
|
|
55
|
+
`--headless`, `--headed`, or `--cdp` when the operation needs explicit runtime
|
|
56
|
+
context. See the [CLI reference](./docs/CLI.md).
|
|
57
|
+
|
|
58
|
+
## MCP and REST
|
|
59
|
+
|
|
60
|
+
```sh
|
|
61
|
+
amalgm-browser-mcp
|
|
62
|
+
|
|
63
|
+
AMALGM_BROWSER_TOKEN='replace-me' amalgm-browser-rest
|
|
64
|
+
# or
|
|
65
|
+
amalgm-browser serve --token 'replace-me'
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
MCP uses newline-delimited JSON-RPC over stdio and exposes 22
|
|
69
|
+
`browser_<action>` tools. REST defaults to loopback, authenticates every route
|
|
70
|
+
except health, publishes OpenAPI at `/v1/openapi.json`, and streams sanitized
|
|
71
|
+
events at `/v1/events`.
|
|
72
|
+
|
|
73
|
+
## State, cookies, and authentication
|
|
74
|
+
|
|
75
|
+
The default state root is `$AMALGM_BROWSER_DIR` (legacy
|
|
76
|
+
`$AMALGM_BROWSER_ROOT`), then `$AMALGM_DIR/browser`, then
|
|
77
|
+
`~/.amalgm/users/<scope>/browser`. Browser stores SQLite metadata, profile
|
|
78
|
+
directories, encrypted cookie and authentication resources, and fallback
|
|
79
|
+
artifacts there.
|
|
80
|
+
|
|
81
|
+
The visible Electron browser must use `persist:amalgm-browser`; it must never
|
|
82
|
+
use `defaultSession`. Electron and headless Chromium keep separate physical
|
|
83
|
+
stores. Their adapters can reconcile cookie records only through Browser's
|
|
84
|
+
encrypted, tombstone-aware logical jar. Named auth bundles are explicit and
|
|
85
|
+
separate from automatic cookie synchronization. See [cookies](./docs/COOKIES.md)
|
|
86
|
+
and [authentication](./docs/AUTHENTICATION.md).
|
|
87
|
+
|
|
88
|
+
## Recording
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
amalgm-browser recordings start --session research --fps 15 --duration-ms 5000
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Recordings contain the verified page only and are encoded as WebM. Results
|
|
95
|
+
report `wallSeconds` and `videoSeconds` separately. A host-provided artifact
|
|
96
|
+
destination writes to `<destination>/.amalgm/recordings`; otherwise Browser
|
|
97
|
+
uses its local fallback. See [recording](./docs/RECORDING.md).
|
|
98
|
+
|
|
99
|
+
## Desktop and Toolbox integration
|
|
100
|
+
|
|
101
|
+
- [Electron integration](./docs/ELECTRON_INTEGRATION.md) covers native
|
|
102
|
+
`WebContentsView` surfaces, identity, shell policy, cookies, and ad blocking.
|
|
103
|
+
- [Toolbox integration](./docs/TOOLBOX_INTEGRATION.md) covers the single
|
|
104
|
+
`browser` tool, capability grants, and legacy aliases.
|
|
105
|
+
- [Engine integration](./docs/ENGINE_INTEGRATION.md) covers composition and a
|
|
106
|
+
no-dual-writer cutover. Engine changes are deliberately a later stage.
|
|
107
|
+
|
|
108
|
+
## Verify
|
|
109
|
+
|
|
110
|
+
```sh
|
|
111
|
+
npm run verify
|
|
112
|
+
npm run test:real
|
|
113
|
+
npm run test:electron # macOS real-Electron harness
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Verification covers strict TypeScript, the 220-line source limit, runtime and
|
|
117
|
+
adapter contracts, migration fixtures, package installation, and tarball
|
|
118
|
+
hygiene. The opt-in suites use real bundled Chromium and real Electron.
|
|
119
|
+
|
|
120
|
+
The complete documentation index is [docs/README.md](./docs/README.md).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
Report vulnerabilities privately to the Amalgm maintainers. Do not file a
|
|
4
|
+
public issue containing credentials, cookies, login links, captured pages, or
|
|
5
|
+
recordings.
|
|
6
|
+
|
|
7
|
+
## Isolation
|
|
8
|
+
|
|
9
|
+
Browser separates application authentication, Electron
|
|
10
|
+
`persist:amalgm-browser`, each headless profile, the logical cookie jar, and
|
|
11
|
+
explicit auth bundles. It never queries Electron `defaultSession`. Drivers
|
|
12
|
+
cannot inspect one another's physical stores; portability uses only the
|
|
13
|
+
encrypted Browser adapter contract.
|
|
14
|
+
|
|
15
|
+
## Secrets
|
|
16
|
+
|
|
17
|
+
Cookie/auth/login secret files use AES-256-GCM, atomic replacement, private
|
|
18
|
+
directories, and mode `0600`. Metadata lists and events contain no values.
|
|
19
|
+
Protected application, auth, Supabase, loopback, and configured hosts are
|
|
20
|
+
rejected by cookie policy. Public adapter diagnostics redact secret query
|
|
21
|
+
parameters and key/value patterns.
|
|
22
|
+
|
|
23
|
+
Login creation is an explicit one-time credential-delivery operation. The raw
|
|
24
|
+
token is returned only to that trusted caller, then stored as a hash; ordinary
|
|
25
|
+
list/get and MCP projections do not expose it. Portable auth resources are
|
|
26
|
+
ciphertext but remain credentials and require an explicitly authorized
|
|
27
|
+
32-byte key.
|
|
28
|
+
|
|
29
|
+
Device-local encryption protects against accidental plaintext exposure. It
|
|
30
|
+
does not protect against an attacker who can read both encrypted files and the
|
|
31
|
+
local key or control the running Browser process.
|
|
32
|
+
|
|
33
|
+
## Network surfaces
|
|
34
|
+
|
|
35
|
+
REST requires a bearer token for every route except health, uses a separate
|
|
36
|
+
credential for physical cookie adapters, rejects sensitive requests before
|
|
37
|
+
body parsing where feasible, defaults to loopback, and refuses remote binding
|
|
38
|
+
without explicit authorization. Put TLS and network access control in front of
|
|
39
|
+
any remote deployment. Never expose `/internal/v1/*` to untrusted clients.
|
|
40
|
+
|
|
41
|
+
Electron bridge advertisements accept only loopback CDP URLs and are private,
|
|
42
|
+
atomic, PID-owned files. Visible actions verify the exact stamped surface and
|
|
43
|
+
fail before input or capture on ambiguity.
|
|
44
|
+
|
|
45
|
+
## User data
|
|
46
|
+
|
|
47
|
+
Treat captures, recordings, downloads, traces, profile directories, and
|
|
48
|
+
origin storage as sensitive. Artifact stores and embedding hosts must apply
|
|
49
|
+
appropriate authorization, retention, backup, and deletion policies.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amalgm-browser-mcp.js","sourceRoot":"","sources":["../../bin/amalgm-browser-mcp.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAEvD,MAAM,sBAAsB,CAAC,aAAa,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createBrowser } from '../src/index.js';
|
|
3
|
+
import { createBrowserHttpServer } from '../src/http.js';
|
|
4
|
+
const token = process.env.AMALGM_BROWSER_TOKEN;
|
|
5
|
+
if (!token)
|
|
6
|
+
throw new Error('AMALGM_BROWSER_TOKEN is required.');
|
|
7
|
+
const host = process.env.AMALGM_BROWSER_HOST || '127.0.0.1';
|
|
8
|
+
const port = Number(process.env.AMALGM_BROWSER_PORT || 0);
|
|
9
|
+
if (!['127.0.0.1', '::1', 'localhost'].includes(host) && process.env.AMALGM_BROWSER_ALLOW_REMOTE !== '1') {
|
|
10
|
+
throw new Error('Non-loopback bind requires AMALGM_BROWSER_ALLOW_REMOTE=1.');
|
|
11
|
+
}
|
|
12
|
+
const server = createBrowserHttpServer({
|
|
13
|
+
browser: createBrowser(),
|
|
14
|
+
token,
|
|
15
|
+
allowRemote: process.env.AMALGM_BROWSER_ALLOW_REMOTE === '1',
|
|
16
|
+
...(process.env.AMALGM_BROWSER_ADAPTER_TOKEN ? { adapterToken: process.env.AMALGM_BROWSER_ADAPTER_TOKEN } : {}),
|
|
17
|
+
});
|
|
18
|
+
const address = await server.listen(port, host);
|
|
19
|
+
process.stderr.write(`amalgm-browser-rest listening on http://${address.address}:${address.port}\n`);
|
|
20
|
+
//# sourceMappingURL=amalgm-browser-rest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amalgm-browser-rest.js","sourceRoot":"","sources":["../../bin/amalgm-browser-rest.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AAEzD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;AAC/C,IAAI,CAAC,KAAK;IAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;AACjE,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,WAAW,CAAC;AAC5D,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,CAAC,CAAC,CAAC;AAC1D,IAAI,CAAC,CAAC,WAAW,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,GAAG,EAAE,CAAC;IACzG,MAAM,IAAI,KAAK,CAAC,2DAA2D,CAAC,CAAC;AAC/E,CAAC;AACD,MAAM,MAAM,GAAG,uBAAuB,CAAC;IACrC,OAAO,EAAE,aAAa,EAAE;IACxB,KAAK;IACL,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,2BAA2B,KAAK,GAAG;IAC5D,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CAChH,CAAC,CAAC;AACH,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AAChD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,2CAA2C,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,IAAI,IAAI,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"amalgm-browser.js","sourceRoot":"","sources":["../../bin/amalgm-browser.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,CAAC,QAAQ,GAAG,MAAM,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BrowserAction, BrowserActionResult, BrowserCapability } from './types.js';
|
|
2
|
+
export declare function validateAction(action: BrowserAction): void;
|
|
3
|
+
export declare function assertActionCapability(action: BrowserAction, capabilities: readonly BrowserCapability[]): void;
|
|
4
|
+
export declare function safeOrigin(value: string): string;
|
|
5
|
+
export declare function boundResult(result: BrowserActionResult): BrowserActionResult;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { BrowserError } from './errors.js';
|
|
2
|
+
export function validateAction(action) {
|
|
3
|
+
if (action.type === 'open') {
|
|
4
|
+
try {
|
|
5
|
+
new URL(action.url);
|
|
6
|
+
}
|
|
7
|
+
catch {
|
|
8
|
+
throw new BrowserError('INVALID_INPUT', 'open requires a valid URL.');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
if (['click', 'fill', 'select'].includes(action.type)
|
|
12
|
+
&& !('target' in action && action.target)) {
|
|
13
|
+
throw new BrowserError('INVALID_INPUT', `${action.type} requires target.`);
|
|
14
|
+
}
|
|
15
|
+
if (action.type === 'cli' && (!Array.isArray(action.args) || !action.args.length)) {
|
|
16
|
+
throw new BrowserError('INVALID_INPUT', 'cli requires a non-empty argv array.');
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function assertActionCapability(action, capabilities) {
|
|
20
|
+
const required = action.type === 'cua' ? 'computer-use'
|
|
21
|
+
: action.type === 'screenshot' && action.fullPage ? 'full-page-capture' : 'core';
|
|
22
|
+
if (!capabilities.includes(required)) {
|
|
23
|
+
throw new BrowserError('CAPABILITY_UNSUPPORTED', `${action.type} requires the ${required} Browser capability.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function safeOrigin(value) {
|
|
27
|
+
try {
|
|
28
|
+
return new URL(value).origin;
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return 'opaque';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
export function boundResult(result) {
|
|
35
|
+
if (result.type !== 'value')
|
|
36
|
+
return result;
|
|
37
|
+
const encoded = JSON.stringify(result.value);
|
|
38
|
+
if (!encoded || encoded.length <= 15_000)
|
|
39
|
+
return result;
|
|
40
|
+
return { type: 'value', value: { truncated: true, text: encoded.slice(0, 15_000) } };
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=action.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action.ts"],"names":[],"mappings":"A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EACxB,GAAG,MAAM,CAAC,IAAI,iBAAiB,QAAQ,sBAAsB,CAC9D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,IAAI,CAAC;QAAC,OAAO,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;IAAC,CAAC;IACrC,MAAM,CAAC;QAAC,OAAO,QAAQ,CAAC;IAAC,CAAC;AAC5B,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,MAA2B;IACrD,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;QAAE,OAAO,MAAM,CAAC;IAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC7C,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IACxD,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC;AACvF,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const CORE_ACTIONS: readonly ["open", "snapshot", "screenshot", "click", "fill", "press", "select", "eval", "wait", "cli", "dialog", "tab", "console", "close"];
|
|
2
|
+
export declare const BROWSER_ACTIONS: readonly ["open", "snapshot", "screenshot", "click", "fill", "press", "select", "eval", "wait", "cli", "dialog", "tab", "console", "close", "cua", "record_start", "record_stop", "record_list", "auth_list", "auth_link_create", "auth_save", "auth_load"];
|
|
3
|
+
export type ProductActionName = typeof BROWSER_ACTIONS[number];
|
|
4
|
+
export interface BrowserActionDescriptor {
|
|
5
|
+
name: ProductActionName;
|
|
6
|
+
capability: 'core' | 'computer-use' | 'recording' | 'auth';
|
|
7
|
+
description: string;
|
|
8
|
+
inputSchema: Record<string, unknown>;
|
|
9
|
+
}
|
|
10
|
+
export declare const browserActionDescriptors: BrowserActionDescriptor[];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const CORE_ACTIONS = [
|
|
2
|
+
'open', 'snapshot', 'screenshot', 'click', 'fill', 'press', 'select', 'eval',
|
|
3
|
+
'wait', 'cli', 'dialog', 'tab', 'console', 'close',
|
|
4
|
+
];
|
|
5
|
+
export const BROWSER_ACTIONS = [
|
|
6
|
+
...CORE_ACTIONS,
|
|
7
|
+
'cua',
|
|
8
|
+
'record_start', 'record_stop', 'record_list',
|
|
9
|
+
'auth_list', 'auth_link_create', 'auth_save', 'auth_load',
|
|
10
|
+
];
|
|
11
|
+
const session = { session: { type: 'string', description: 'Browser session id.' } };
|
|
12
|
+
const target = { target: { type: 'string', description: 'Snapshot @ref, CSS selector, or text=Visible label.' } };
|
|
13
|
+
const object = (properties, required = []) => ({
|
|
14
|
+
type: 'object', properties, additionalProperties: false, ...(required.length ? { required } : {}),
|
|
15
|
+
});
|
|
16
|
+
export const browserActionDescriptors = [
|
|
17
|
+
descriptor('open', 'core', 'Open a URL in a persistent browser session.', object({ url: { type: 'string' }, ...session }, ['url'])),
|
|
18
|
+
descriptor('snapshot', 'core', 'Read an accessibility snapshot with stable @refs.', object(session)),
|
|
19
|
+
descriptor('screenshot', 'core', 'Capture page pixels in CSS-pixel coordinates.', object({ fullPage: { type: 'boolean' }, ...session })),
|
|
20
|
+
descriptor('click', 'core', 'Click a target.', object({ ...target, ...session }, ['target'])),
|
|
21
|
+
descriptor('fill', 'core', 'Fill a target with text.', object({ ...target, text: { type: 'string' }, submit: { type: 'boolean' }, ...session }, ['target', 'text'])),
|
|
22
|
+
descriptor('press', 'core', 'Press a key or key combination.', object({ key: { type: 'string' }, ...session }, ['key'])),
|
|
23
|
+
descriptor('select', 'core', 'Select a native option.', object({ ...target, value: { type: 'string' }, ...session }, ['target', 'value'])),
|
|
24
|
+
descriptor('eval', 'core', 'Evaluate JavaScript in the page.', object({ script: { type: 'string' }, ...session }, ['script'])),
|
|
25
|
+
descriptor('wait', 'core', 'Wait for a selector, URL, or duration.', object({ selector: { type: 'string' }, url: { type: 'string' }, ms: { type: 'number' }, timeoutMs: { type: 'number' }, ...session })),
|
|
26
|
+
descriptor('cli', 'core', 'Run an advanced agent-browser argv action.', object({ args: { type: 'array', items: { type: 'string' } }, timeoutMs: { type: 'number' }, ...session }, ['args'])),
|
|
27
|
+
descriptor('dialog', 'core', 'Accept or dismiss a page dialog.', object({ action: { enum: ['accept', 'dismiss'] }, text: { type: 'string' }, ...session }, ['action'])),
|
|
28
|
+
descriptor('tab', 'core', 'List, open, switch, or close tabs.', object({ action: { enum: ['list', 'switch', 'new', 'close'] }, id: { type: 'string' }, ...session }, ['action'])),
|
|
29
|
+
descriptor('console', 'core', 'Read console output and page errors.', object({ clear: { type: 'boolean' }, ...session })),
|
|
30
|
+
descriptor('close', 'core', 'Close a browser session.', object(session)),
|
|
31
|
+
descriptor('cua', 'computer-use', 'Perform one browser-scoped computer-use operation.', object({ operation: { type: 'object' }, ...session }, ['operation'])),
|
|
32
|
+
descriptor('record_start', 'recording', 'Start page-only WebM recording.', object({ fps: { type: 'number' }, name: { type: 'string' }, ...session })),
|
|
33
|
+
descriptor('record_stop', 'recording', 'Stop this session recording.', object(session)),
|
|
34
|
+
descriptor('record_list', 'recording', 'List recordings and active status.', object({})),
|
|
35
|
+
descriptor('auth_list', 'auth', 'List sanitized profiles, bundles, and login sessions.', object({})),
|
|
36
|
+
descriptor('auth_link_create', 'auth', 'Create a TTL-bound human login handoff.', object({ targetUrl: { type: 'string' }, domains: { type: 'array', items: { type: 'string' } }, ttlMs: { type: 'number' }, transport: { enum: ['electron-surface', 'novnc', 'external', 'manual'] }, liveUrl: { type: 'string' } }, ['targetUrl'])),
|
|
37
|
+
descriptor('auth_save', 'auth', 'Save named encrypted authentication state.', object({ name: { type: 'string' }, domains: { type: 'array', items: { type: 'string' } }, ...session }, ['name'])),
|
|
38
|
+
descriptor('auth_load', 'auth', 'Load a named encrypted authentication bundle.', object({ bundleId: { type: 'string' }, ...session }, ['bundleId'])),
|
|
39
|
+
];
|
|
40
|
+
function descriptor(name, capability, description, inputSchema) { return { name, capability, description, inputSchema }; }
|
|
41
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../src/adapters/actions.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM;IAC5E,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO;CAC1C,CAAC;AACX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,GAAG,YAAY;IACf,KAAK;IACL,cAAc,EAAE,aAAa,EAAE,aAAa;IAC5C,WAAW,EAAE,kBAAkB,EAAE,WAAW,EAAE,WAAW;CACjD,CAAC;AAUX,MAAM,OAAO,GAAG,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qBAAqB,EAAE,EAAE,CAAC;AACpF,MAAM,MAAM,GAAG,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qDAAqD,EAAE,EAAE,CAAC;AAClH,MAAM,MAAM,GAAG,CAAC,UAAmC,EAAE,WAAqB,EAAE,EAA2B,EAAE,CAAC,CAAC;IACzG,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CAClG,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,wBAAwB,GAA8B;IACjE,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,6CAA6C,E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AC,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IACpU,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,4CAA4C,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAChM,UAAU,CAAC,WAAW,EAAE,MAAM,EAAE,+CAA+C,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,CAAC;CACrJ,CAAC;AAEF,SAAS,UAAU,CACjB,IAAuB,EACvB,UAAiD,EACjD,WAAmB,EACnB,WAAoC,IACT,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ProductActionName } from '../actions.js';
|
|
2
|
+
import type { ParsedArgs } from './args.js';
|
|
3
|
+
export declare function cliAction(args: ParsedArgs): {
|
|
4
|
+
name: ProductActionName;
|
|
5
|
+
input: Record<string, unknown>;
|
|
6
|
+
} | null;
|
|
7
|
+
export declare function assertActionName(value: string | undefined): asserts value is ProductActionName;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { BrowserError } from '../../errors.js';
|
|
2
|
+
import { enabled, flag, jsonFlag } from './args.js';
|
|
3
|
+
export function cliAction(args) {
|
|
4
|
+
const [command, first, second] = args.words;
|
|
5
|
+
if (!command)
|
|
6
|
+
return null;
|
|
7
|
+
if (command === 'action')
|
|
8
|
+
return { name: first, input: common(args, jsonFlag(args, 'input')) };
|
|
9
|
+
if (!ACTION_NAMES.has(command))
|
|
10
|
+
return null;
|
|
11
|
+
const input = common(args, ['dialog', 'tab', 'console', 'cua'].includes(command) ? jsonFlag(args, 'input') : {});
|
|
12
|
+
if (command === 'open')
|
|
13
|
+
input.url = first;
|
|
14
|
+
if (command === 'click')
|
|
15
|
+
input.target = first;
|
|
16
|
+
if (command === 'fill') {
|
|
17
|
+
input.target = first;
|
|
18
|
+
input.text = second;
|
|
19
|
+
if (enabled(args, 'submit'))
|
|
20
|
+
input.submit = true;
|
|
21
|
+
}
|
|
22
|
+
if (command === 'press')
|
|
23
|
+
input.key = first;
|
|
24
|
+
if (command === 'select') {
|
|
25
|
+
input.target = first;
|
|
26
|
+
input.value = second;
|
|
27
|
+
}
|
|
28
|
+
if (command === 'eval')
|
|
29
|
+
input.script = first;
|
|
30
|
+
if (command === 'wait') {
|
|
31
|
+
if (flag(args, 'selector'))
|
|
32
|
+
input.selector = flag(args, 'selector');
|
|
33
|
+
if (flag(args, 'url'))
|
|
34
|
+
input.url = flag(args, 'url');
|
|
35
|
+
if (flag(args, 'ms'))
|
|
36
|
+
input.ms = Number(flag(args, 'ms'));
|
|
37
|
+
}
|
|
38
|
+
if (command === 'screenshot' && enabled(args, 'full-page'))
|
|
39
|
+
input.fullPage = true;
|
|
40
|
+
if (command === 'cli')
|
|
41
|
+
input.args = args.words.slice(1);
|
|
42
|
+
return { name: command, input };
|
|
43
|
+
}
|
|
44
|
+
function common(args, input) {
|
|
45
|
+
const session = flag(args, 'session');
|
|
46
|
+
const profile = flag(args, 'profile');
|
|
47
|
+
const timeout = flag(args, 'timeout');
|
|
48
|
+
return {
|
|
49
|
+
...input,
|
|
50
|
+
...(session ? { session } : {}),
|
|
51
|
+
...(profile ? { profile } : {}),
|
|
52
|
+
...(timeout ? { timeoutMs: Number(timeout) } : {}),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const ACTION_NAMES = new Set([
|
|
56
|
+
'open', 'snapshot', 'screenshot', 'click', 'fill', 'press', 'select', 'eval',
|
|
57
|
+
'wait', 'cli', 'dialog', 'tab', 'console', 'cua', 'close',
|
|
58
|
+
]);
|
|
59
|
+
export function assertActionName(value) {
|
|
60
|
+
if (!value)
|
|
61
|
+
throw new BrowserError('INVALID_INPUT', 'Action name is required.');
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=actions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../../../src/adapters/cli/actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAG/C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,UAAU,SAAS,CAAC,IAAgB;IACxC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;IAC5C,IAAI,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC;IAC1B,IAAI,OAAO,KAAK,QAAQ;QAAE,OAAO,EAAE,IAAI,EAAE,KAA0B,EAAE,KAAK,EAAE,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;IACpH,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5C,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IACjH,IAAI,OAAO,KAAK,MAAM;QAAE,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC;IAC1C,IAAI,OAAO,KAAK,OAAO;QAAE,KAAK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AAI,EAAE,OAA4B,EAAE,KAAK,EAAE,CAAC;AACvD,CAAC;AAED,SAAS,MAAM,CAAC,IAAgB,EAAE,KAA8B;IAC9D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IACtC,OAAO;QACL,GAAG,KAAK;QACR,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/B,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACnD,CAAC;AACJ,CAAC;AAED,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC;IAC3B,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM;IAC5E,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO;CAC1D,CAAC,CAAC;AAEH,MAAM,UAAU,gBAAgB,CAAC,KAAyB;IACxD,IAAI,CAAC,KAAK;QAAE,MAAM,IAAI,YAAY,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ParsedArgs {
|
|
2
|
+
words: string[];
|
|
3
|
+
flags: Map<string, string | boolean>;
|
|
4
|
+
}
|
|
5
|
+
export declare function parseArgs(argv: string[]): ParsedArgs;
|
|
6
|
+
export declare function flag(args: ParsedArgs, name: string): string | undefined;
|
|
7
|
+
export declare function enabled(args: ParsedArgs, name: string): boolean;
|
|
8
|
+
export declare function jsonFlag(args: ParsedArgs, name: string): Record<string, unknown>;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function parseArgs(argv) {
|
|
2
|
+
const words = [];
|
|
3
|
+
const flags = new Map();
|
|
4
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
5
|
+
const item = argv[index];
|
|
6
|
+
if (!item?.startsWith('--')) {
|
|
7
|
+
if (item !== undefined)
|
|
8
|
+
words.push(item);
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
const [name = '', inline] = item.slice(2).split('=', 2);
|
|
12
|
+
const next = argv[index + 1];
|
|
13
|
+
if (inline !== undefined)
|
|
14
|
+
flags.set(name, inline);
|
|
15
|
+
else if (next !== undefined && !next.startsWith('--')) {
|
|
16
|
+
flags.set(name, next);
|
|
17
|
+
index += 1;
|
|
18
|
+
}
|
|
19
|
+
else
|
|
20
|
+
flags.set(name, true);
|
|
21
|
+
}
|
|
22
|
+
return { words, flags };
|
|
23
|
+
}
|
|
24
|
+
export function flag(args, name) {
|
|
25
|
+
const value = args.flags.get(name);
|
|
26
|
+
return typeof value === 'string' ? value : undefined;
|
|
27
|
+
}
|
|
28
|
+
export function enabled(args, name) {
|
|
29
|
+
const value = args.flags.get(name);
|
|
30
|
+
return value === true || value === 'true';
|
|
31
|
+
}
|
|
32
|
+
export function jsonFlag(args, name) {
|
|
33
|
+
const value = flag(args, name);
|
|
34
|
+
if (!value)
|
|
35
|
+
return {};
|
|
36
|
+
const parsed = JSON.parse(value);
|
|
37
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
38
|
+
throw new Error(`--${name} must be a JSON object.`);
|
|
39
|
+
return parsed;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=args.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"args.js","sourceRoot":"","sources":["../../../../src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AC,CAAC;IACnC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AACD,MAAM,UAAU,OAAO,CAAC,IAAgB,EAAE,IAAY;IACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,MAAM,CAAC;AAC5C,CAAC;AACD,MAAM,UAAU,QAAQ,CAAC,IAAgB,EAAE,IAAY;IACrD,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC/B,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,CAAC;IACtB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAY,CAAC;IAC5C,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,KAAK,IAAI,yBAAyB,CAAC,CAAC;IACxH,OAAO,MAAiC,CAAC;AAC3C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HELP = "amalgm-browser \u2014 persistent browser automation\n\nActions:\n amalgm-browser open <url> [--session id]\n amalgm-browser snapshot|screenshot|close\n amalgm-browser click <target>\n amalgm-browser fill <target> <text> [--submit]\n amalgm-browser press <key>\n amalgm-browser select <target> <value>\n amalgm-browser eval <script>\n amalgm-browser wait [--selector css|--url value|--ms number]\n amalgm-browser dialog|tab|console|cua --input <json>\n amalgm-browser action <name> --input <json>\n\nResources:\n amalgm-browser sessions list|get|close|cancel|prune [id]\n amalgm-browser profiles list|get|create|update|delete|prune [id]\n amalgm-browser auth list|link|save|load|delete\n amalgm-browser recordings start [--duration-ms n]|stop|cancel|list|get\n amalgm-browser capabilities\n amalgm-browser doctor\n amalgm-browser serve [--port 0] [--host 127.0.0.1]\n amalgm-browser mcp\n\nGlobal options:\n --session <id> --profile <id> --root <path> --cwd <project> --json --timeout <ms>\n --headless --headed --cdp <endpoint>\n";
|