@xopcai/xopc 0.0.251 → 0.0.252
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/README.md +8 -5
- package/README.zh-CN.md +8 -5
- package/dist/browser-ext/dist/background.js +358 -768
- package/dist/browser-ext/manifest.json +1 -2
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-DfBjTSo9.js → activity-store-w3eq3YpP.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Bo_dmLv8.js → agent-avatar-dicebear-k039rbUz.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-kILWelNb.js → agent-defaults-settings-panel-D4J4oq8p.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-yuUn8n-f.js → agents-Bmth_bSQ.js} +1 -1
- package/dist/gateway/static/root/assets/{api-zxpcJfgj.js → api-2joIfbrH.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Cz56nrVF.js → app-management-settings-panel-ByJ4kiD0.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DxSws5U4.js → appearance-settings-BK2Jga-B.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-B3ky7cWU.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-7k15-hqo.js → archive-plugin-DMDKtYpi.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-B-SFpjd9.js → attachment-load-B764Ql3Z.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Qy36j19q.js → automations-page-D-sO8CZe.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-Ds5-_-9z.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CPOZQt8F.js → binary-plugins-fxtzYRpv.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DhvVlIp9.js → block-editor-Bcjtvckh.js} +3 -3
- package/dist/gateway/static/root/assets/browser-automation-inputs-BSmnusjD.js +1 -0
- package/dist/gateway/static/root/assets/browser-automations-page-DC_OQIBk.js +3 -0
- package/dist/gateway/static/root/assets/browser-settings-page-C1FojyG6.js +3 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Bs59UCut.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-CM9vNmoo.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-CX-yWwLD.js → channels-status-swr-BuWjIG_a.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-1PJoxRuV.js → chat-terminal-dock-5SevEo_I.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-BPZ44D-V.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-CBCc6zFA.js → cron-expression-DtsfalBM.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-u8K5Kt_N.js → date-picker-tDEQV5TP.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-y_i_cnpz.js → dependency-picker-HhNwg0Y2.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DyL0JxLm.js → desktop-pet-acU4Li-C.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-d2d_IsyP.js → desktop-pet-settings-R84AR0Pe.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-DqIBKJwl.js → extension-debug-page-CrLlRkSN.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DUW1xxj2.js → extension-page-BH5lmZXE.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BHY9qaNw.js → extension-settings-page-BscjNAd1.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-CMNbl0FZ.js → gateway-config-swr-9HidFZUd.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-settings-BxLcW6ij.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CR7Xg8As.js → gateway-startup-retry-DRCPXONr.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-7CD9iPR7.js → heartbeat-settings-K5Zhl2rx.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-CZAg9RBv.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-C5mn73ca.js → image-generation-api-CR6Kle8H.js} +1 -1
- package/dist/gateway/static/root/assets/index-D4Ykja-U.js +72 -0
- package/dist/gateway/static/root/assets/index-zIJ3AXgR.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BtlqMleF.js → keyboard-shortcuts-settings-B1QR49-7.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-BjxfkjxE.js → local-app-workbench-page-wicoV-ti.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-B7xqQe2s.js → local-apps-page-C74It-T8.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-CF4erhjB.js → locale-store-BfZGZKSs.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-kACaPZKL.js → logs-page-xX-7S49A.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-A432siER.js → management-settings-1kNnYL97.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-CQvzsE24.js → markdown-view-DjiwT28p.js} +2 -2
- package/dist/gateway/static/root/assets/{media-plugins-CpvYiauZ.js → media-plugins-B5c0AoS1.js} +1 -1
- package/dist/gateway/static/root/assets/messages-DaIwVWar.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-DyjVGngO.js → mobile-pairing-wizard-CsIZqK51.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-CfWxopl4.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-CYN-LCHJ.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-B3FKzjR6.js → page-tabs-CqJN6Ljz.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DnjrwAHD.js → preview-open-alternatives-DqRIGxf4.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-COcr_NUJ.js → product-open-page-DE2nPE_K.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-B5G3LzDq.js +1 -0
- package/dist/gateway/static/root/assets/{projects-page-BzH8pjEz.js → projects-page-CuVK2mKu.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-BsRBlji7.js → registry-api-Bpy8XX-5.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-Dnd73xWt.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-LO4wZ_dO.js → runtime-tools-settings-panel-Bb4b74-P.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-crcj4-Pm.js → schema-form-DoPU5j3J.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-XL4LyKZe.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-0ForzDSS.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-Bl4MvTmq.js → settings-form-section-Ci-9WajJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DplrjZ6x.js → settings-page-CL_2F95D.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DVws6XZc.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-CJP1kURj.js → share-preview-page-XUA3oKQX.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BwDvcacF.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BJjrATqE.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-DsjcKg9Q.js → skills-page-sXXAZDc9.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-D6gWBbvy.js → skills-page.utils-DD79Bl1I.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-_eCXfqCo.js → system-settings-panel-BEH64qBV.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-0jxMi75O.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-BOgkc_9D.js → theme-store-CISSxU1c.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-W5mktxl1.js → tunnel-api-DrKDhnJm.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Na2DYzT3.js → use-autosave-CPYePL-Q.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-B6zLDfDl.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-OXweUxS_.js → voice-api-key-field-DKqzrCXx.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-C-ryeIxj.js → voice-config-api-e9xWjwBX.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BqOsO47I.js → work-discovery-overlay-kTQug6bq.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-B9S_lfT1.js → workflow-run-setup-panel-m9SKj_GT.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Bcd1XqP7.js +5 -0
- package/dist/gateway/static/root/index.html +10 -10
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/new-session.js +9 -0
- package/dist/src/agent/agent-manager.d.ts +2 -1
- package/dist/src/agent/agent-manager.js +6 -5
- package/dist/src/agent/background-review/run-background-review.js +1 -1
- package/dist/src/agent/coding/repository-instructions.js +2 -2
- package/dist/src/agent/coding/workspace-revision.js +2 -2
- package/dist/src/agent/commands/command-isolation.js +2 -2
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/external-tools/composio-provider.d.ts +1 -0
- package/dist/src/agent/external-tools/composio-provider.js +64 -34
- package/dist/src/agent/external-tools/search-error.js +5 -3
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/mcp/oauth/mcp-oauth-store.js +1 -1
- package/dist/src/agent/service.js +4 -3
- package/dist/src/agent/service.types.d.ts +2 -1
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.js +4 -0
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent/tool-manuals/browser.d.ts +1 -1
- package/dist/src/agent/tool-manuals/browser.js +15 -226
- package/dist/src/agent/tools/browser/tool/browser-use-tool.d.ts +4 -21
- package/dist/src/agent/tools/browser/tool/browser-use-tool.js +48 -165
- package/dist/src/agent/tools/browser/tool/schemas.d.ts +203 -16
- package/dist/src/agent/tools/browser/tool/schemas.js +146 -16
- package/dist/src/agent/tools/browser-automation-tool.d.ts +121 -0
- package/dist/src/agent/tools/browser-automation-tool.js +197 -0
- package/dist/src/agent/tools/factory.d.ts +6 -9
- package/dist/src/agent/tools/factory.js +28 -55
- package/dist/src/agent/tools/index.d.ts +2 -2
- package/dist/src/agent/tools/index.js +3 -3
- package/dist/src/agent/tools/review-workspace.js +2 -2
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/oauth/xopc-cloud.js +3 -1
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/automations/domain/defaults.js +1 -1
- package/dist/src/automations/domain/types.d.ts +5 -5
- package/dist/src/automations/domain/validation.d.ts +12 -12
- package/dist/src/automations/domain/validation.js +3 -3
- package/dist/src/automations/draft/automation-draft-validator.d.ts +3 -3
- package/dist/src/automations/draft/automation-draft-validator.js +1 -1
- package/dist/src/automations/service/action-executor.d.ts +1 -1
- package/dist/src/automations/service/action-executor.js +7 -7
- package/dist/src/browser/{recipes → automations}/index.d.ts +1 -0
- package/dist/src/browser/automations/index.js +4 -0
- package/dist/src/browser/automations/repository.d.ts +13 -0
- package/dist/src/browser/automations/repository.js +60 -0
- package/dist/src/browser/automations/runner.d.ts +17 -0
- package/dist/src/browser/automations/runner.js +173 -0
- package/dist/src/browser/automations/runtime-service.d.ts +6 -0
- package/dist/src/browser/automations/runtime-service.js +37 -0
- package/dist/src/browser/automations/schema.d.ts +144 -0
- package/dist/src/browser/automations/schema.js +135 -0
- package/dist/src/browser/automations/service.d.ts +146 -0
- package/dist/src/browser/automations/service.js +168 -0
- package/dist/src/browser/automations/types.d.ts +90 -0
- package/dist/src/browser/cache-dir-policy.d.ts +1 -1
- package/dist/src/browser/cache-dir-policy.js +1 -4
- package/dist/src/browser/drivers/browser-driver.d.ts +17 -0
- package/dist/src/browser/drivers/create-driver.d.ts +3 -0
- package/dist/src/browser/drivers/create-driver.js +84 -0
- package/dist/src/browser/drivers/extension-driver.d.ts +20 -0
- package/dist/src/browser/drivers/extension-driver.js +47 -0
- package/dist/src/browser/drivers/playwright-driver.d.ts +38 -0
- package/dist/src/browser/drivers/playwright-driver.js +406 -0
- package/dist/src/browser/index.d.ts +10 -15
- package/dist/src/browser/index.js +10 -15
- package/dist/src/browser/install-lock.d.ts +1 -2
- package/dist/src/browser/install-lock.js +3 -9
- package/dist/src/browser/install-progress.d.ts +1 -1
- package/dist/src/browser/observation/format.d.ts +2 -0
- package/dist/src/browser/observation/format.js +26 -0
- package/dist/src/browser/policy/approval-store.d.ts +17 -0
- package/dist/src/browser/policy/approval-store.js +62 -0
- package/dist/src/browser/policy/browser-policy.d.ts +3 -0
- package/dist/src/browser/policy/browser-policy.js +27 -0
- package/dist/src/browser/providers/browser-ext-install.d.ts +1 -1
- package/dist/src/browser/providers/browser-ext-install.js +4 -6
- package/dist/src/browser/providers/browser-use.js +1 -1
- package/dist/src/browser/providers/browserbase.js +1 -1
- package/dist/src/browser/providers/extension-ws-acquire.d.ts +1 -4
- package/dist/src/browser/providers/extension-ws-acquire.js +1 -13
- package/dist/src/browser/providers/extension.d.ts +3 -22
- package/dist/src/browser/providers/extension.js +7 -15
- package/dist/src/browser/providers/index.d.ts +2 -2
- package/dist/src/browser/providers/index.js +3 -3
- package/dist/src/browser/providers/types.d.ts +0 -94
- package/dist/src/browser/readiness.d.ts +4 -22
- package/dist/src/browser/readiness.js +55 -118
- package/dist/src/browser/runtime/browser-runtime.d.ts +30 -0
- package/dist/src/browser/runtime/browser-runtime.js +362 -0
- package/dist/src/browser/url-policy.d.ts +3 -3
- package/dist/src/browser/url-policy.js +7 -6
- package/dist/src/browser/verification/expectation.d.ts +2 -0
- package/dist/src/browser/verification/expectation.js +17 -0
- package/dist/src/cli/command-loaders.js +1 -0
- package/dist/src/cli/command-manifest.js +5 -1
- package/dist/src/cli/commands/browser-cli-helpers.d.ts +0 -6
- package/dist/src/cli/commands/browser-cli-helpers.js +11 -144
- package/dist/src/cli/commands/browser.d.ts +0 -5
- package/dist/src/cli/commands/browser.js +11 -152
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/node-version.js +25 -9
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/platform.d.ts +1 -0
- package/dist/src/cli/commands/platform.js +111 -0
- package/dist/src/config/index.js +4 -4
- package/dist/src/config/loader.js +10 -4
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/config/schema.d.ts +131 -84
- package/dist/src/config/schema.js +112 -59
- package/dist/src/connectors/composio-sessions.js +1 -3
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/extensions/marketplace.js +4 -0
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +12 -26
- package/dist/src/gateway/hono/lib/config-payload.js +11 -40
- package/dist/src/gateway/hono/routes/browser-automations.d.ts +3 -0
- package/dist/src/gateway/hono/routes/browser-automations.js +77 -0
- package/dist/src/gateway/hono/routes/browser-install.js +0 -32
- package/dist/src/gateway/hono/routes/browser.d.ts +0 -17
- package/dist/src/gateway/hono/routes/browser.js +46 -568
- package/dist/src/gateway/hono/routes/config-patch/misc.js +8 -1
- package/dist/src/gateway/hono/routes/config.js +0 -11
- package/dist/src/gateway/hono/routes/lazy-bundles.js +5 -5
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/service/config-coordinator.js +1 -1
- package/dist/src/gateway/service.d.ts +4 -6
- package/dist/src/gateway/service.js +24 -27
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/platform/client.d.ts +121 -0
- package/dist/src/platform/client.js +108 -0
- package/dist/src/platform/contracts.d.ts +194 -0
- package/dist/src/platform/contracts.js +150 -0
- package/dist/src/platform/index.d.ts +4 -0
- package/dist/src/platform/index.js +9 -0
- package/dist/src/platform/resolution.d.ts +4 -0
- package/dist/src/platform/resolution.js +16 -0
- package/dist/src/platform/worker.d.ts +6 -0
- package/dist/src/platform/worker.js +75 -0
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/providers/xopc-cloud-config.js +3 -1
- package/dist/src/session/session-context-for-llm.js +41 -1
- package/dist/src/share/hosted-session-share.js +3 -1
- package/dist/src/share/share-thumbnail.js +1 -1
- package/dist/src/storage/sqlite/migrations/153_browser_control_v2.sql +45 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +16 -20
- package/dist/src/tasks/home-query-service.js +1 -1
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/tunnel/env.js +3 -1
- package/dist/src/work-discovery/service.js +1 -1
- package/dist/src/workflows/service/workflow-run-service.js +1 -1
- package/package.json +6 -6
- package/dist/gateway/static/root/assets/apps-page-BnizTdgs.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-CZRKqSqY.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-pN5LbChY.js +0 -8
- package/dist/gateway/static/root/assets/browser-workflow-inputs-BX1-uM9L.js +0 -1
- package/dist/gateway/static/root/assets/browser-workflows-page-C65MI57t.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CJw2e16J.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-CRgjb4Ck.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-Dcpdy06y.js +0 -2
- package/dist/gateway/static/root/assets/gateway-config-api-e3BRcgDx.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-Cheo0Rkc.js +0 -1
- package/dist/gateway/static/root/assets/home-page-DVrTRqNc.js +0 -1
- package/dist/gateway/static/root/assets/index-B7CX4Qob.css +0 -2
- package/dist/gateway/static/root/assets/index-BHrpyJ4t.js +0 -72
- package/dist/gateway/static/root/assets/messages-Cf5hpZE6.js +0 -3
- package/dist/gateway/static/root/assets/note-detail-panel-CUd8O4K7.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BLQwd39W.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-NttW338u.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BxpjSDnL.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BLMaibOb.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BRvvKhoH.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DTOsxQC1.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-CemgzEi4.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-BWYanBlQ.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-D0Z_K5JT.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-B_-SNat-.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-CNOT2Coo.js +0 -5
- package/dist/src/agent/tools/browser-recipe-tool.d.ts +0 -12
- package/dist/src/agent/tools/browser-recipe-tool.js +0 -113
- package/dist/src/browser/actions/extension-registry-bridge.d.ts +0 -5
- package/dist/src/browser/actions/extension-registry-bridge.js +0 -312
- package/dist/src/browser/actions/registry.d.ts +0 -5
- package/dist/src/browser/actions/registry.js +0 -741
- package/dist/src/browser/actions/types.d.ts +0 -65
- package/dist/src/browser/backend-from-config.d.ts +0 -22
- package/dist/src/browser/backend-from-config.js +0 -99
- package/dist/src/browser/browser-command-timeout.d.ts +0 -2
- package/dist/src/browser/browser-command-timeout.js +0 -11
- package/dist/src/browser/cdp-local-launcher.d.ts +0 -35
- package/dist/src/browser/cdp-local-launcher.js +0 -154
- package/dist/src/browser/cdp-supervisor.d.ts +0 -58
- package/dist/src/browser/cdp-supervisor.js +0 -133
- package/dist/src/browser/humanize.d.ts +0 -80
- package/dist/src/browser/humanize.js +0 -363
- package/dist/src/browser/manager.d.ts +0 -50
- package/dist/src/browser/manager.js +0 -251
- package/dist/src/browser/pipeline/output.d.ts +0 -35
- package/dist/src/browser/pipeline/output.js +0 -74
- package/dist/src/browser/pipeline/runner.d.ts +0 -27
- package/dist/src/browser/pipeline/runner.js +0 -453
- package/dist/src/browser/pipeline/schema.d.ts +0 -42
- package/dist/src/browser/pipeline/schema.js +0 -116
- package/dist/src/browser/pipeline/template.d.ts +0 -30
- package/dist/src/browser/pipeline/template.js +0 -112
- package/dist/src/browser/providers/cloakbrowser.d.ts +0 -83
- package/dist/src/browser/providers/cloakbrowser.js +0 -612
- package/dist/src/browser/recipes/index.js +0 -3
- package/dist/src/browser/recipes/repository.d.ts +0 -13
- package/dist/src/browser/recipes/repository.js +0 -81
- package/dist/src/browser/recipes/runtime-service.d.ts +0 -6
- package/dist/src/browser/recipes/runtime-service.js +0 -30
- package/dist/src/browser/recipes/service.d.ts +0 -36
- package/dist/src/browser/recipes/service.js +0 -186
- package/dist/src/browser/recipes/types.d.ts +0 -36
- package/dist/src/browser/schemas.d.ts +0 -53
- package/dist/src/browser/schemas.js +0 -68
- package/dist/src/browser/session-lifecycle.d.ts +0 -40
- package/dist/src/browser/session-lifecycle.js +0 -136
- package/dist/src/browser/snapshot-helpers.d.ts +0 -24
- package/dist/src/browser/snapshot-helpers.js +0 -70
- package/dist/src/browser/stealth.d.ts +0 -46
- package/dist/src/browser/stealth.js +0 -163
- package/dist/src/gateway/hono/routes/browser-workflows.d.ts +0 -3
- package/dist/src/gateway/hono/routes/browser-workflows.js +0 -78
- /package/dist/src/browser/{actions → automations}/types.js +0 -0
- /package/dist/src/browser/{recipes/types.js → drivers/browser-driver.js} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const DEFAULT_AUTOMATION_TIMEOUT_SECONDS = 1800;
|
|
3
3
|
const DEFAULT_BROWSER_AUTOMATION_TIMEOUT_SECONDS = 600;
|
|
4
4
|
function defaultAutomationTimeoutSeconds(action) {
|
|
5
|
-
return action.kind === "
|
|
5
|
+
return action.kind === "browser_automation" ? 600 : DEFAULT_AUTOMATION_TIMEOUT_SECONDS;
|
|
6
6
|
}
|
|
7
7
|
function resolveAutomationTimeoutSeconds(action, reliability) {
|
|
8
8
|
return reliability?.executionTimeoutSeconds ?? ("timeoutSeconds" in action ? action.timeoutSeconds : void 0) ?? reliability?.timeoutSeconds ?? defaultAutomationTimeoutSeconds(action);
|
|
@@ -46,9 +46,9 @@ export type AutomationAction = {
|
|
|
46
46
|
maxSubagents?: number;
|
|
47
47
|
timeoutSeconds?: number;
|
|
48
48
|
} | {
|
|
49
|
-
kind: '
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
kind: 'browser_automation';
|
|
50
|
+
automationId: string;
|
|
51
|
+
inputs?: Record<string, unknown>;
|
|
52
52
|
timeoutSeconds?: number;
|
|
53
53
|
} | {
|
|
54
54
|
kind: 'task_command';
|
|
@@ -189,8 +189,8 @@ export interface AutomationDeps {
|
|
|
189
189
|
getDefaultAgentId?: () => string;
|
|
190
190
|
prepareAgentSession?: (input: PrepareAutomationAgentSessionInput) => Promise<void>;
|
|
191
191
|
workflowRunService?: WorkflowRunServiceLike;
|
|
192
|
-
|
|
193
|
-
runAndWait(
|
|
192
|
+
browserAutomationService?: {
|
|
193
|
+
runAndWait(automationId: string, inputs: Record<string, unknown>, signal?: AbortSignal): Promise<{
|
|
194
194
|
id: string;
|
|
195
195
|
status: 'queued' | 'running' | 'succeeded' | 'failed' | 'cancelled';
|
|
196
196
|
result?: unknown;
|
|
@@ -59,9 +59,9 @@ export declare const AutomationActionSchema: z.ZodDiscriminatedUnion<[z.ZodObjec
|
|
|
59
59
|
maxSubagents: z.ZodOptional<z.ZodNumber>;
|
|
60
60
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
61
61
|
}, z.core.$strict>, z.ZodObject<{
|
|
62
|
-
kind: z.ZodLiteral<"
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
kind: z.ZodLiteral<"browser_automation">;
|
|
63
|
+
automationId: z.ZodString;
|
|
64
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
65
65
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
66
66
|
}, z.core.$strict>, z.ZodObject<{
|
|
67
67
|
kind: z.ZodLiteral<"task_command">;
|
|
@@ -236,9 +236,9 @@ export declare const AutomationSchema: z.ZodObject<{
|
|
|
236
236
|
maxSubagents: z.ZodOptional<z.ZodNumber>;
|
|
237
237
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
238
238
|
}, z.core.$strict>, z.ZodObject<{
|
|
239
|
-
kind: z.ZodLiteral<"
|
|
240
|
-
|
|
241
|
-
|
|
239
|
+
kind: z.ZodLiteral<"browser_automation">;
|
|
240
|
+
automationId: z.ZodString;
|
|
241
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
242
242
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
243
243
|
}, z.core.$strict>, z.ZodObject<{
|
|
244
244
|
kind: z.ZodLiteral<"task_command">;
|
|
@@ -398,9 +398,9 @@ export declare const CreateAutomationSchema: z.ZodObject<{
|
|
|
398
398
|
maxSubagents: z.ZodOptional<z.ZodNumber>;
|
|
399
399
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
400
400
|
}, z.core.$strict>, z.ZodObject<{
|
|
401
|
-
kind: z.ZodLiteral<"
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
kind: z.ZodLiteral<"browser_automation">;
|
|
402
|
+
automationId: z.ZodString;
|
|
403
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
404
404
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
405
405
|
}, z.core.$strict>, z.ZodObject<{
|
|
406
406
|
kind: z.ZodLiteral<"task_command">;
|
|
@@ -587,9 +587,9 @@ export declare const UpdateAutomationSchema: z.ZodObject<{
|
|
|
587
587
|
maxSubagents: z.ZodOptional<z.ZodNumber>;
|
|
588
588
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
589
589
|
}, z.core.$strict>, z.ZodObject<{
|
|
590
|
-
kind: z.ZodLiteral<"
|
|
591
|
-
|
|
592
|
-
|
|
590
|
+
kind: z.ZodLiteral<"browser_automation">;
|
|
591
|
+
automationId: z.ZodString;
|
|
592
|
+
inputs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
593
593
|
timeoutSeconds: z.ZodOptional<z.ZodNumber>;
|
|
594
594
|
}, z.core.$strict>, z.ZodObject<{
|
|
595
595
|
kind: z.ZodLiteral<"task_command">;
|
|
@@ -83,9 +83,9 @@ const AutomationActionSchema = z.discriminatedUnion("kind", [
|
|
|
83
83
|
timeoutSeconds: z.number().int().min(1).max(86400).optional()
|
|
84
84
|
}).strict(),
|
|
85
85
|
z.object({
|
|
86
|
-
kind: z.literal("
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
kind: z.literal("browser_automation"),
|
|
87
|
+
automationId: nonEmptyString.max(100),
|
|
88
|
+
inputs: z.record(z.string(), z.unknown()).optional(),
|
|
89
89
|
timeoutSeconds: z.number().int().min(1).max(86400).optional()
|
|
90
90
|
}).strict(),
|
|
91
91
|
z.object({
|
|
@@ -37,9 +37,9 @@ export declare function buildAutomationDraftResponse(draft: GeneratedAutomationD
|
|
|
37
37
|
maxSubagents?: number;
|
|
38
38
|
timeoutSeconds?: number;
|
|
39
39
|
} | {
|
|
40
|
-
kind: "
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
kind: "browser_automation";
|
|
41
|
+
automationId: string;
|
|
42
|
+
inputs?: Record<string, unknown>;
|
|
43
43
|
timeoutSeconds?: number;
|
|
44
44
|
} | {
|
|
45
45
|
kind: "task_command";
|
|
@@ -90,7 +90,7 @@ function summarizeTrigger(trigger) {
|
|
|
90
90
|
}
|
|
91
91
|
function summarizeAction(action) {
|
|
92
92
|
if (action.kind === "workflow") return `Starts workflow ${action.workflowId}.`;
|
|
93
|
-
if (action.kind === "
|
|
93
|
+
if (action.kind === "browser_automation") return `Runs browser automation ${action.automationId}.`;
|
|
94
94
|
if (action.kind === "task_command") return `Applies ${action.command?.type ?? "a command"} to task ${action.taskId}.`;
|
|
95
95
|
return action.agentId ? `Runs agent ${action.agentId}.` : "Runs the default agent.";
|
|
96
96
|
}
|
|
@@ -4,7 +4,7 @@ export declare class AutomationActionExecutor {
|
|
|
4
4
|
setDeps(deps: AutomationDeps): void;
|
|
5
5
|
execute(automation: Automation, run: AutomationRun, signal: AbortSignal, hooks?: AutomationActionExecutionHooks): Promise<AutomationActionTask>;
|
|
6
6
|
private executeWithoutTimeout;
|
|
7
|
-
private
|
|
7
|
+
private executeBrowserAutomation;
|
|
8
8
|
private executeAgent;
|
|
9
9
|
private executeWorkflow;
|
|
10
10
|
}
|
|
@@ -105,7 +105,7 @@ var AutomationActionExecutor = class {
|
|
|
105
105
|
error: "Automation run was cancelled"
|
|
106
106
|
};
|
|
107
107
|
if (automation.action.kind === "workflow") return this.executeWorkflow(automation, automation.action, run, signal, hooks);
|
|
108
|
-
if (automation.action.kind === "
|
|
108
|
+
if (automation.action.kind === "browser_automation") return this.executeBrowserAutomation(automation, automation.action, signal, hooks);
|
|
109
109
|
if (automation.action.kind === "task_command") {
|
|
110
110
|
await hooks.onRunPatch?.({ currentPhase: "action" });
|
|
111
111
|
const execute = this.deps.executeTaskCommand;
|
|
@@ -128,26 +128,26 @@ var AutomationActionExecutor = class {
|
|
|
128
128
|
}
|
|
129
129
|
return this.executeAgent(automation, automation.action, run, signal, hooks, deadlineAtMs);
|
|
130
130
|
}
|
|
131
|
-
async
|
|
131
|
+
async executeBrowserAutomation(automation, action, signal, hooks) {
|
|
132
132
|
await hooks.onRunPatch?.({ currentPhase: "action" });
|
|
133
133
|
const safetyMode = automation.safety?.mode ?? "auto_apply";
|
|
134
134
|
if (safetyMode !== "auto_apply") return {
|
|
135
135
|
status: "succeeded",
|
|
136
|
-
summary: `${safetyMode === "suggest_only" ? "Suggest only" : "Ask before applying"}: Browser automation ${action.
|
|
136
|
+
summary: `${safetyMode === "suggest_only" ? "Suggest only" : "Ask before applying"}: Browser automation ${action.automationId} was not run.`
|
|
137
137
|
};
|
|
138
|
-
const service = this.deps.
|
|
138
|
+
const service = this.deps.browserAutomationService;
|
|
139
139
|
if (!service) return {
|
|
140
140
|
status: "failed",
|
|
141
141
|
error: "Browser automation is not available"
|
|
142
142
|
};
|
|
143
|
-
const run = await service.runAndWait(action.
|
|
143
|
+
const run = await service.runAndWait(action.automationId, action.inputs ?? {}, signal);
|
|
144
144
|
if (run.status === "succeeded") return {
|
|
145
145
|
status: "succeeded",
|
|
146
|
-
summary: `Browser automation ${action.
|
|
146
|
+
summary: `Browser automation ${action.automationId} completed: ${JSON.stringify(run.result ?? null).slice(0, 3500)}`
|
|
147
147
|
};
|
|
148
148
|
return {
|
|
149
149
|
status: run.status === "cancelled" ? "cancelled" : "failed",
|
|
150
|
-
error: run.error ?? `Browser automation ${action.
|
|
150
|
+
error: run.error ?? `Browser automation ${action.automationId} ${run.status}`
|
|
151
151
|
};
|
|
152
152
|
}
|
|
153
153
|
async executeAgent(automation, action, run, signal, hooks, deadlineAtMs) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BrowserAutomationDefinitionSchema } from "./schema.js";
|
|
2
|
+
import { BrowserAutomationService } from "./service.js";
|
|
3
|
+
import { createRuntimeBrowserAutomationService } from "./runtime-service.js";
|
|
4
|
+
export { BrowserAutomationDefinitionSchema, BrowserAutomationService, createRuntimeBrowserAutomationService };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { BrowserAutomation, BrowserAutomationRun, BrowserAutomationRunEvent } from './types.js';
|
|
2
|
+
export declare const listBrowserAutomations: () => BrowserAutomation[];
|
|
3
|
+
export declare const getBrowserAutomation: (id: string) => BrowserAutomation | null;
|
|
4
|
+
export declare function saveBrowserAutomation(value: BrowserAutomation): void;
|
|
5
|
+
export declare const deleteBrowserAutomation: (id: string) => boolean;
|
|
6
|
+
export declare function saveBrowserAutomationRun(value: BrowserAutomationRun): void;
|
|
7
|
+
export declare const getBrowserAutomationRun: (id: string) => BrowserAutomationRun | null;
|
|
8
|
+
export declare const listBrowserAutomationRuns: (automationId?: string) => BrowserAutomationRun[];
|
|
9
|
+
export declare const listActiveBrowserAutomationRuns: () => BrowserAutomationRun[];
|
|
10
|
+
export declare const hasActiveBrowserAutomationRuns: (automationId: string) => boolean;
|
|
11
|
+
export declare const nextBrowserAutomationRunEventSeq: (runId: string) => number;
|
|
12
|
+
export declare function appendBrowserAutomationRunEvent(value: BrowserAutomationRunEvent): void;
|
|
13
|
+
export declare const listBrowserAutomationRunEvents: (runId: string) => BrowserAutomationRunEvent[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getSqliteDatabase, runSqliteWriteTransaction } from "../../storage/sqlite/transaction.js";
|
|
2
|
+
import "../../storage/sqlite/index.js";
|
|
3
|
+
//#region src/browser/automations/repository.ts
|
|
4
|
+
const AUTOMATION_SELECT = "SELECT automation_id, revision, status, definition_json, created_at_ms, updated_at_ms FROM browser_automations";
|
|
5
|
+
const RUN_SELECT = "SELECT run_id, automation_id, automation_revision, definition_json, status, inputs_json, result_json, error, created_at_ms, started_at_ms, ended_at_ms, duration_ms FROM browser_automation_runs";
|
|
6
|
+
const parseAutomation = (row) => ({
|
|
7
|
+
id: row.automation_id,
|
|
8
|
+
revision: row.revision,
|
|
9
|
+
status: row.status,
|
|
10
|
+
definition: JSON.parse(row.definition_json),
|
|
11
|
+
createdAtMs: row.created_at_ms,
|
|
12
|
+
updatedAtMs: row.updated_at_ms
|
|
13
|
+
});
|
|
14
|
+
const parseRun = (row) => ({
|
|
15
|
+
id: row.run_id,
|
|
16
|
+
automationId: row.automation_id,
|
|
17
|
+
automationRevision: row.automation_revision,
|
|
18
|
+
definition: JSON.parse(row.definition_json),
|
|
19
|
+
status: row.status,
|
|
20
|
+
inputs: JSON.parse(row.inputs_json),
|
|
21
|
+
result: row.result_json ? JSON.parse(row.result_json) : void 0,
|
|
22
|
+
error: row.error ?? void 0,
|
|
23
|
+
createdAtMs: row.created_at_ms,
|
|
24
|
+
startedAtMs: row.started_at_ms ?? void 0,
|
|
25
|
+
endedAtMs: row.ended_at_ms ?? void 0,
|
|
26
|
+
durationMs: row.duration_ms ?? void 0
|
|
27
|
+
});
|
|
28
|
+
const listBrowserAutomations = () => getSqliteDatabase().prepare(`${AUTOMATION_SELECT} ORDER BY updated_at_ms DESC`).all().map(parseAutomation);
|
|
29
|
+
const getBrowserAutomation = (id) => {
|
|
30
|
+
const row = getSqliteDatabase().prepare(`${AUTOMATION_SELECT} WHERE automation_id = ?`).get(id);
|
|
31
|
+
return row ? parseAutomation(row) : null;
|
|
32
|
+
};
|
|
33
|
+
function saveBrowserAutomation(value) {
|
|
34
|
+
runSqliteWriteTransaction((db) => db.prepare("INSERT INTO browser_automations (automation_id, revision, status, definition_json, created_at_ms, updated_at_ms) VALUES (?, ?, ?, ?, ?, ?) ON CONFLICT(automation_id) DO UPDATE SET revision=excluded.revision, status=excluded.status, definition_json=excluded.definition_json, updated_at_ms=excluded.updated_at_ms").run(value.id, value.revision, value.status, JSON.stringify(value.definition), value.createdAtMs, value.updatedAtMs));
|
|
35
|
+
}
|
|
36
|
+
const deleteBrowserAutomation = (id) => runSqliteWriteTransaction((db) => db.prepare("DELETE FROM browser_automations WHERE automation_id = ?").run(id).changes > 0);
|
|
37
|
+
function saveBrowserAutomationRun(value) {
|
|
38
|
+
runSqliteWriteTransaction((db) => db.prepare("INSERT INTO browser_automation_runs (run_id, automation_id, automation_revision, definition_json, status, inputs_json, result_json, error, created_at_ms, started_at_ms, ended_at_ms, duration_ms) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(run_id) DO UPDATE SET status=excluded.status, result_json=excluded.result_json, error=excluded.error, started_at_ms=excluded.started_at_ms, ended_at_ms=excluded.ended_at_ms, duration_ms=excluded.duration_ms").run(value.id, value.automationId, value.automationRevision, JSON.stringify(value.definition), value.status, JSON.stringify(value.inputs), value.result === void 0 ? null : JSON.stringify(value.result), value.error ?? null, value.createdAtMs, value.startedAtMs ?? null, value.endedAtMs ?? null, value.durationMs ?? null));
|
|
39
|
+
}
|
|
40
|
+
const getBrowserAutomationRun = (id) => {
|
|
41
|
+
const row = getSqliteDatabase().prepare(`${RUN_SELECT} WHERE run_id = ?`).get(id);
|
|
42
|
+
return row ? parseRun(row) : null;
|
|
43
|
+
};
|
|
44
|
+
const listBrowserAutomationRuns = (automationId) => (automationId ? getSqliteDatabase().prepare(`${RUN_SELECT} WHERE automation_id = ? ORDER BY created_at_ms DESC`).all(automationId) : getSqliteDatabase().prepare(`${RUN_SELECT} ORDER BY created_at_ms DESC`).all()).map(parseRun);
|
|
45
|
+
const listActiveBrowserAutomationRuns = () => getSqliteDatabase().prepare(`${RUN_SELECT} WHERE status IN ('queued', 'running')`).all().map(parseRun);
|
|
46
|
+
const hasActiveBrowserAutomationRuns = (automationId) => Boolean(getSqliteDatabase().prepare("SELECT 1 FROM browser_automation_runs WHERE automation_id = ? AND status IN ('queued', 'running') LIMIT 1").get(automationId));
|
|
47
|
+
const nextBrowserAutomationRunEventSeq = (runId) => getSqliteDatabase().prepare("SELECT COALESCE(MAX(seq), 0) + 1 AS seq FROM browser_action_audit WHERE run_id = ?").get(runId).seq;
|
|
48
|
+
function appendBrowserAutomationRunEvent(value) {
|
|
49
|
+
runSqliteWriteTransaction((db) => db.prepare("INSERT INTO browser_action_audit (event_id, run_id, seq, type, data_json, created_at_ms) VALUES (?, ?, ?, ?, ?, ?)").run(value.id, value.runId, value.seq, value.type, value.data === void 0 ? null : JSON.stringify(value.data), value.createdAtMs));
|
|
50
|
+
}
|
|
51
|
+
const listBrowserAutomationRunEvents = (runId) => getSqliteDatabase().prepare("SELECT event_id, run_id, seq, type, data_json, created_at_ms FROM browser_action_audit WHERE run_id = ? ORDER BY seq").all(runId).map((row) => ({
|
|
52
|
+
id: row.event_id,
|
|
53
|
+
runId: row.run_id,
|
|
54
|
+
seq: row.seq,
|
|
55
|
+
type: row.type,
|
|
56
|
+
data: row.data_json ? JSON.parse(row.data_json) : void 0,
|
|
57
|
+
createdAtMs: row.created_at_ms
|
|
58
|
+
}));
|
|
59
|
+
//#endregion
|
|
60
|
+
export { appendBrowserAutomationRunEvent, deleteBrowserAutomation, getBrowserAutomation, getBrowserAutomationRun, hasActiveBrowserAutomationRuns, listActiveBrowserAutomationRuns, listBrowserAutomationRunEvents, listBrowserAutomationRuns, listBrowserAutomations, nextBrowserAutomationRunEventSeq, saveBrowserAutomation, saveBrowserAutomationRun };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { BrowserControlResult } from '@xopcai/browser-control-contract';
|
|
2
|
+
import type { BrowserRuntime } from '../runtime/browser-runtime.js';
|
|
3
|
+
import type { BrowserAutomationDefinition } from './types.js';
|
|
4
|
+
export declare function runBrowserAutomation(input: {
|
|
5
|
+
definition: BrowserAutomationDefinition;
|
|
6
|
+
inputs: Record<string, unknown>;
|
|
7
|
+
runtime: BrowserRuntime;
|
|
8
|
+
taskKey: string;
|
|
9
|
+
signal: AbortSignal;
|
|
10
|
+
onStep: (event: {
|
|
11
|
+
index: number;
|
|
12
|
+
action: string;
|
|
13
|
+
status: 'started' | 'completed' | 'failed';
|
|
14
|
+
result?: BrowserControlResult;
|
|
15
|
+
}) => void;
|
|
16
|
+
}): Promise<BrowserControlResult>;
|
|
17
|
+
export declare function resolveBrowserAutomationInputs(definition: BrowserAutomationDefinition, provided: Record<string, unknown>): Record<string, unknown>;
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
//#region src/browser/automations/runner.ts
|
|
2
|
+
async function runBrowserAutomation(input) {
|
|
3
|
+
const startedAt = Date.now();
|
|
4
|
+
const values = resolveBrowserAutomationInputs(input.definition, input.inputs);
|
|
5
|
+
let observation;
|
|
6
|
+
let sessionId;
|
|
7
|
+
for (let index = 0; index < input.definition.steps.length; index += 1) {
|
|
8
|
+
const step = input.definition.steps[index];
|
|
9
|
+
input.onStep({
|
|
10
|
+
index,
|
|
11
|
+
action: step.action,
|
|
12
|
+
status: "started"
|
|
13
|
+
});
|
|
14
|
+
try {
|
|
15
|
+
if (step.action !== "navigate" && !observation) {
|
|
16
|
+
const observed = await input.runtime.execute(input.taskKey, {
|
|
17
|
+
action: "observe",
|
|
18
|
+
sessionId
|
|
19
|
+
}, input.signal);
|
|
20
|
+
if (!observed.ok) {
|
|
21
|
+
input.onStep({
|
|
22
|
+
index,
|
|
23
|
+
action: step.action,
|
|
24
|
+
status: "failed",
|
|
25
|
+
result: observed
|
|
26
|
+
});
|
|
27
|
+
return observed;
|
|
28
|
+
}
|
|
29
|
+
observation = observed.receipt.observation;
|
|
30
|
+
sessionId = observation?.sessionId;
|
|
31
|
+
}
|
|
32
|
+
if (step.action === "navigate") assertAllowedDomain(input.definition.allowedDomains, render(step.url, values));
|
|
33
|
+
const action = buildAction(step, values, observation, sessionId);
|
|
34
|
+
const result = await input.runtime.execute(input.taskKey, action, input.signal);
|
|
35
|
+
if (!result.ok) {
|
|
36
|
+
input.onStep({
|
|
37
|
+
index,
|
|
38
|
+
action: step.action,
|
|
39
|
+
status: "failed",
|
|
40
|
+
result
|
|
41
|
+
});
|
|
42
|
+
return result;
|
|
43
|
+
}
|
|
44
|
+
observation = result.receipt.observation ?? observation;
|
|
45
|
+
sessionId = observation?.sessionId ?? sessionId;
|
|
46
|
+
if (step.action === "navigate") assertAllowedDomain(input.definition.allowedDomains, observation?.url ?? render(step.url, values));
|
|
47
|
+
input.onStep({
|
|
48
|
+
index,
|
|
49
|
+
action: step.action,
|
|
50
|
+
status: "completed",
|
|
51
|
+
result
|
|
52
|
+
});
|
|
53
|
+
} catch (error) {
|
|
54
|
+
const result = automationFailure(step.action === "navigate" ? "BLOCKED_URL" : "INVALID_INPUT", error, observation);
|
|
55
|
+
input.onStep({
|
|
56
|
+
index,
|
|
57
|
+
action: step.action,
|
|
58
|
+
status: "failed",
|
|
59
|
+
result
|
|
60
|
+
});
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
ok: true,
|
|
66
|
+
receipt: {
|
|
67
|
+
action: "sequence",
|
|
68
|
+
risk: input.definition.risk,
|
|
69
|
+
durationMs: Date.now() - startedAt,
|
|
70
|
+
verified: true,
|
|
71
|
+
observation
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function buildAction(step, inputs, observation, sessionId) {
|
|
76
|
+
if (step.action === "navigate") return {
|
|
77
|
+
...step,
|
|
78
|
+
url: render(step.url, inputs),
|
|
79
|
+
sessionId
|
|
80
|
+
};
|
|
81
|
+
if (!observation) throw new Error("Browser observation is unavailable.");
|
|
82
|
+
const revision = observation.revision;
|
|
83
|
+
const ref = "target" in step && step.target ? resolveTarget(step.target, observation) : void 0;
|
|
84
|
+
switch (step.action) {
|
|
85
|
+
case "click": return {
|
|
86
|
+
action: "click",
|
|
87
|
+
sessionId,
|
|
88
|
+
revision,
|
|
89
|
+
ref,
|
|
90
|
+
expect: step.expect
|
|
91
|
+
};
|
|
92
|
+
case "fill": return {
|
|
93
|
+
action: "fill",
|
|
94
|
+
sessionId,
|
|
95
|
+
revision,
|
|
96
|
+
ref,
|
|
97
|
+
value: render(step.value, inputs),
|
|
98
|
+
submit: step.submit,
|
|
99
|
+
expect: step.expect
|
|
100
|
+
};
|
|
101
|
+
case "select": return {
|
|
102
|
+
action: "select",
|
|
103
|
+
sessionId,
|
|
104
|
+
revision,
|
|
105
|
+
ref,
|
|
106
|
+
value: render(step.value, inputs),
|
|
107
|
+
expect: step.expect
|
|
108
|
+
};
|
|
109
|
+
case "press": return {
|
|
110
|
+
action: "press",
|
|
111
|
+
sessionId,
|
|
112
|
+
revision,
|
|
113
|
+
ref,
|
|
114
|
+
key: render(step.key, inputs),
|
|
115
|
+
expect: step.expect
|
|
116
|
+
};
|
|
117
|
+
case "scroll": return {
|
|
118
|
+
action: "scroll",
|
|
119
|
+
sessionId,
|
|
120
|
+
revision,
|
|
121
|
+
ref,
|
|
122
|
+
deltaY: step.deltaY,
|
|
123
|
+
expect: step.expect
|
|
124
|
+
};
|
|
125
|
+
case "wait": return {
|
|
126
|
+
action: "wait",
|
|
127
|
+
sessionId,
|
|
128
|
+
revision,
|
|
129
|
+
ref,
|
|
130
|
+
condition: step.condition,
|
|
131
|
+
value: step.value ? render(step.value, inputs) : void 0,
|
|
132
|
+
timeoutMs: step.timeoutMs
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function resolveTarget(target, observation) {
|
|
137
|
+
const matches = observation.nodes.filter((node) => node.role === target.role && (!target.name || node.name === target.name) && (!target.nameIncludes || node.name.includes(target.nameIncludes)));
|
|
138
|
+
if (matches.length !== 1) throw new Error(`Semantic target must match exactly one element; matched ${matches.length}: ${JSON.stringify(target)}`);
|
|
139
|
+
return matches[0].ref;
|
|
140
|
+
}
|
|
141
|
+
function render(value, inputs) {
|
|
142
|
+
return value.replace(/\$\{input\.([a-zA-Z][a-zA-Z0-9_]*)\}/g, (_match, key) => {
|
|
143
|
+
if (!(key in inputs)) throw new Error(`Missing automation input: ${key}`);
|
|
144
|
+
return String(inputs[key]);
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function resolveBrowserAutomationInputs(definition, provided) {
|
|
148
|
+
const values = { ...provided };
|
|
149
|
+
for (const [name, spec] of Object.entries(definition.inputs)) {
|
|
150
|
+
const value = values[name] ?? spec.default;
|
|
151
|
+
if (value === void 0 && spec.required) throw new Error(`Missing required automation input: ${name}`);
|
|
152
|
+
if (value !== void 0 && typeof value !== spec.type) throw new Error(`Automation input ${name} must be ${spec.type}.`);
|
|
153
|
+
if (values[name] === void 0 && value !== void 0) values[name] = value;
|
|
154
|
+
}
|
|
155
|
+
for (const name of Object.keys(values)) if (!definition.inputs[name]) throw new Error(`Unknown automation input: ${name}`);
|
|
156
|
+
return values;
|
|
157
|
+
}
|
|
158
|
+
function assertAllowedDomain(allowedDomains, url) {
|
|
159
|
+
const host = new URL(url).hostname.toLowerCase();
|
|
160
|
+
if (!allowedDomains.some((domain) => domain.toLowerCase() === host)) throw new Error(`Automation navigated outside its allowed domains: ${host}`);
|
|
161
|
+
}
|
|
162
|
+
function automationFailure(code, error, observation) {
|
|
163
|
+
return {
|
|
164
|
+
ok: false,
|
|
165
|
+
error: {
|
|
166
|
+
code,
|
|
167
|
+
message: error instanceof Error ? error.message : String(error),
|
|
168
|
+
observation
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
export { resolveBrowserAutomationInputs, runBrowserAutomation };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Config } from '../../config/schema.js';
|
|
2
|
+
import { BrowserAutomationService } from './service.js';
|
|
3
|
+
export declare function createRuntimeBrowserAutomationService(deps: {
|
|
4
|
+
getConfig: () => Config;
|
|
5
|
+
emit?: (type: string, payload: unknown) => void;
|
|
6
|
+
}): BrowserAutomationService;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { BrowserRuntime } from "../runtime/browser-runtime.js";
|
|
2
|
+
import { createBrowserDriver } from "../drivers/create-driver.js";
|
|
3
|
+
import { runBrowserAutomation } from "./runner.js";
|
|
4
|
+
import { BrowserAutomationService } from "./service.js";
|
|
5
|
+
//#region src/browser/automations/runtime-service.ts
|
|
6
|
+
function createRuntimeBrowserAutomationService(deps) {
|
|
7
|
+
const runtime = new BrowserRuntime({
|
|
8
|
+
getConfig: () => deps.getConfig().browser,
|
|
9
|
+
createDriver: () => createBrowserDriver(deps.getConfig().browser),
|
|
10
|
+
allowedUploadRoots: [process.cwd()],
|
|
11
|
+
emit: deps.emit
|
|
12
|
+
});
|
|
13
|
+
return new BrowserAutomationService(async ({ definition, inputs, signal, onStep }) => {
|
|
14
|
+
const taskKey = `browser-automation:${crypto.randomUUID()}`;
|
|
15
|
+
try {
|
|
16
|
+
const result = await runBrowserAutomation({
|
|
17
|
+
definition,
|
|
18
|
+
inputs,
|
|
19
|
+
runtime,
|
|
20
|
+
taskKey,
|
|
21
|
+
signal,
|
|
22
|
+
onStep
|
|
23
|
+
});
|
|
24
|
+
return result.ok ? {
|
|
25
|
+
ok: true,
|
|
26
|
+
result: result.receipt
|
|
27
|
+
} : {
|
|
28
|
+
ok: false,
|
|
29
|
+
error: "error" in result ? result.error.message : "Browser automation failed."
|
|
30
|
+
};
|
|
31
|
+
} finally {
|
|
32
|
+
await runtime.closeTaskSession(taskKey);
|
|
33
|
+
}
|
|
34
|
+
}, deps.emit);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { createRuntimeBrowserAutomationService };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const BrowserAutomationDefinitionSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
description: z.ZodOptional<z.ZodString>;
|
|
6
|
+
allowedDomains: z.ZodArray<z.ZodString>;
|
|
7
|
+
risk: z.ZodEnum<{
|
|
8
|
+
read: "read";
|
|
9
|
+
sensitive: "sensitive";
|
|
10
|
+
destructive: "destructive";
|
|
11
|
+
draft: "draft";
|
|
12
|
+
external_effect: "external_effect";
|
|
13
|
+
}>;
|
|
14
|
+
inputs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
15
|
+
type: z.ZodEnum<{
|
|
16
|
+
string: "string";
|
|
17
|
+
number: "number";
|
|
18
|
+
boolean: "boolean";
|
|
19
|
+
}>;
|
|
20
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
default: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
22
|
+
description: z.ZodOptional<z.ZodString>;
|
|
23
|
+
choices: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
24
|
+
}, z.core.$strict>>>;
|
|
25
|
+
steps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
26
|
+
action: z.ZodLiteral<"navigate">;
|
|
27
|
+
url: z.ZodString;
|
|
28
|
+
expect: z.ZodOptional<z.ZodObject<{
|
|
29
|
+
urlIncludes: z.ZodOptional<z.ZodString>;
|
|
30
|
+
titleIncludes: z.ZodOptional<z.ZodString>;
|
|
31
|
+
textIncludes: z.ZodOptional<z.ZodString>;
|
|
32
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
33
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
34
|
+
hidden: "hidden";
|
|
35
|
+
visible: "visible";
|
|
36
|
+
}>>;
|
|
37
|
+
}, z.core.$strict>>;
|
|
38
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
39
|
+
action: z.ZodLiteral<"click">;
|
|
40
|
+
target: z.ZodObject<{
|
|
41
|
+
role: z.ZodString;
|
|
42
|
+
name: z.ZodOptional<z.ZodString>;
|
|
43
|
+
nameIncludes: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strict>;
|
|
45
|
+
expect: z.ZodOptional<z.ZodObject<{
|
|
46
|
+
urlIncludes: z.ZodOptional<z.ZodString>;
|
|
47
|
+
titleIncludes: z.ZodOptional<z.ZodString>;
|
|
48
|
+
textIncludes: z.ZodOptional<z.ZodString>;
|
|
49
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
50
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
51
|
+
hidden: "hidden";
|
|
52
|
+
visible: "visible";
|
|
53
|
+
}>>;
|
|
54
|
+
}, z.core.$strict>>;
|
|
55
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
56
|
+
action: z.ZodLiteral<"fill">;
|
|
57
|
+
target: z.ZodObject<{
|
|
58
|
+
role: z.ZodString;
|
|
59
|
+
name: z.ZodOptional<z.ZodString>;
|
|
60
|
+
nameIncludes: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strict>;
|
|
62
|
+
value: z.ZodString;
|
|
63
|
+
submit: z.ZodOptional<z.ZodBoolean>;
|
|
64
|
+
expect: z.ZodOptional<z.ZodObject<{
|
|
65
|
+
urlIncludes: z.ZodOptional<z.ZodString>;
|
|
66
|
+
titleIncludes: z.ZodOptional<z.ZodString>;
|
|
67
|
+
textIncludes: z.ZodOptional<z.ZodString>;
|
|
68
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
69
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
70
|
+
hidden: "hidden";
|
|
71
|
+
visible: "visible";
|
|
72
|
+
}>>;
|
|
73
|
+
}, z.core.$strict>>;
|
|
74
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
75
|
+
action: z.ZodLiteral<"select">;
|
|
76
|
+
target: z.ZodObject<{
|
|
77
|
+
role: z.ZodString;
|
|
78
|
+
name: z.ZodOptional<z.ZodString>;
|
|
79
|
+
nameIncludes: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, z.core.$strict>;
|
|
81
|
+
value: z.ZodString;
|
|
82
|
+
expect: z.ZodOptional<z.ZodObject<{
|
|
83
|
+
urlIncludes: z.ZodOptional<z.ZodString>;
|
|
84
|
+
titleIncludes: z.ZodOptional<z.ZodString>;
|
|
85
|
+
textIncludes: z.ZodOptional<z.ZodString>;
|
|
86
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
87
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
88
|
+
hidden: "hidden";
|
|
89
|
+
visible: "visible";
|
|
90
|
+
}>>;
|
|
91
|
+
}, z.core.$strict>>;
|
|
92
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
93
|
+
action: z.ZodLiteral<"press">;
|
|
94
|
+
target: z.ZodOptional<z.ZodObject<{
|
|
95
|
+
role: z.ZodString;
|
|
96
|
+
name: z.ZodOptional<z.ZodString>;
|
|
97
|
+
nameIncludes: z.ZodOptional<z.ZodString>;
|
|
98
|
+
}, z.core.$strict>>;
|
|
99
|
+
key: z.ZodString;
|
|
100
|
+
expect: z.ZodOptional<z.ZodObject<{
|
|
101
|
+
urlIncludes: z.ZodOptional<z.ZodString>;
|
|
102
|
+
titleIncludes: z.ZodOptional<z.ZodString>;
|
|
103
|
+
textIncludes: z.ZodOptional<z.ZodString>;
|
|
104
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
105
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
106
|
+
hidden: "hidden";
|
|
107
|
+
visible: "visible";
|
|
108
|
+
}>>;
|
|
109
|
+
}, z.core.$strict>>;
|
|
110
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
111
|
+
action: z.ZodLiteral<"scroll">;
|
|
112
|
+
target: z.ZodOptional<z.ZodObject<{
|
|
113
|
+
role: z.ZodString;
|
|
114
|
+
name: z.ZodOptional<z.ZodString>;
|
|
115
|
+
nameIncludes: z.ZodOptional<z.ZodString>;
|
|
116
|
+
}, z.core.$strict>>;
|
|
117
|
+
deltaY: z.ZodNumber;
|
|
118
|
+
expect: z.ZodOptional<z.ZodObject<{
|
|
119
|
+
urlIncludes: z.ZodOptional<z.ZodString>;
|
|
120
|
+
titleIncludes: z.ZodOptional<z.ZodString>;
|
|
121
|
+
textIncludes: z.ZodOptional<z.ZodString>;
|
|
122
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
123
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
124
|
+
hidden: "hidden";
|
|
125
|
+
visible: "visible";
|
|
126
|
+
}>>;
|
|
127
|
+
}, z.core.$strict>>;
|
|
128
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
129
|
+
action: z.ZodLiteral<"wait">;
|
|
130
|
+
condition: z.ZodEnum<{
|
|
131
|
+
hidden: "hidden";
|
|
132
|
+
text: "text";
|
|
133
|
+
visible: "visible";
|
|
134
|
+
page_idle: "page_idle";
|
|
135
|
+
}>;
|
|
136
|
+
value: z.ZodOptional<z.ZodString>;
|
|
137
|
+
target: z.ZodOptional<z.ZodObject<{
|
|
138
|
+
role: z.ZodString;
|
|
139
|
+
name: z.ZodOptional<z.ZodString>;
|
|
140
|
+
nameIncludes: z.ZodOptional<z.ZodString>;
|
|
141
|
+
}, z.core.$strict>>;
|
|
142
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
143
|
+
}, z.core.$strict>], "action">>;
|
|
144
|
+
}, z.core.$strict>;
|