teamshare-bridge 0.25.15 → 0.26.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/dist/bridge/auto-upgrade.js +9 -2
- package/dist/bridge/auto-upgrade.js.map +1 -1
- package/dist/bridge/autostart-launcher.js +8 -3
- package/dist/bridge/autostart-launcher.js.map +1 -1
- package/dist/bridge/cdp-handler.js +8 -9
- package/dist/bridge/cdp-handler.js.map +1 -1
- package/dist/bridge/daemon-inbox.js +57 -22
- package/dist/bridge/daemon-inbox.js.map +1 -1
- package/dist/bridge/daemon-instance.js +40 -10
- package/dist/bridge/daemon-instance.js.map +1 -1
- package/dist/bridge/daemon-support.js +3 -1
- package/dist/bridge/daemon-support.js.map +1 -1
- package/dist/bridge/daemon.d.ts +1 -1
- package/dist/bridge/daemon.js +75 -31
- package/dist/bridge/daemon.js.map +1 -1
- package/dist/bridge/doctor.js +61 -18
- package/dist/bridge/doctor.js.map +1 -1
- package/dist/bridge/hidden-launch.js.map +1 -1
- package/dist/bridge/index.js +26 -8
- package/dist/bridge/index.js.map +1 -1
- package/dist/bridge/install-verify.js +2 -1
- package/dist/bridge/install-verify.js.map +1 -1
- package/dist/bridge/local-server.d.ts +3 -1
- package/dist/bridge/local-server.js +53 -15
- package/dist/bridge/local-server.js.map +1 -1
- package/dist/bridge/protocol.js +82 -20
- package/dist/bridge/protocol.js.map +1 -1
- package/dist/bridge/service.d.ts +1 -1
- package/dist/bridge/service.js +77 -21
- package/dist/bridge/service.js.map +1 -1
- package/dist/bridge/session-relay.d.ts +2 -1
- package/dist/bridge/session-relay.js +17 -1
- package/dist/bridge/session-relay.js.map +1 -1
- package/dist/bridge/singleton-policy.js +42 -7
- package/dist/bridge/singleton-policy.js.map +1 -1
- package/dist/bridge/spawn.d.ts +7 -1
- package/dist/bridge/spawn.js +132 -18
- package/dist/bridge/spawn.js.map +1 -1
- package/dist/bridge/stopped-marker.js.map +1 -1
- package/dist/bridge/supervisor-restart.js.map +1 -1
- package/dist/bridge/upgrade-marker.js.map +1 -1
- package/dist/bridge/upgrade-preflight.js.map +1 -1
- package/dist/bridge/wake-handler.js +56 -19
- package/dist/bridge/wake-handler.js.map +1 -1
- package/dist/bridge/wake-lanes.d.ts +5 -0
- package/dist/bridge/wake-lanes.js +23 -3
- package/dist/bridge/wake-lanes.js.map +1 -1
- package/dist/bridge/wake-outbox.js +3 -2
- package/dist/bridge/wake-outbox.js.map +1 -1
- package/dist/bridge/wake-queue-store.js.map +1 -1
- package/dist/bridge/wake-routing.d.ts +4 -2
- package/dist/bridge/wake-routing.js +92 -16
- package/dist/bridge/wake-routing.js.map +1 -1
- package/dist/cli/commands/audit.js +6 -5
- package/dist/cli/commands/audit.js.map +1 -1
- package/dist/cli/commands/blog.js +11 -1
- package/dist/cli/commands/blog.js.map +1 -1
- package/dist/cli/commands/board.js +5 -1
- package/dist/cli/commands/board.js.map +1 -1
- package/dist/cli/commands/browse.js +167 -61
- package/dist/cli/commands/browse.js.map +1 -1
- package/dist/cli/commands/browser.js +14 -5
- package/dist/cli/commands/browser.js.map +1 -1
- package/dist/cli/commands/build.js +183 -51
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/chat.js +31 -9
- package/dist/cli/commands/chat.js.map +1 -1
- package/dist/cli/commands/cleanup.js +6 -2
- package/dist/cli/commands/cleanup.js.map +1 -1
- package/dist/cli/commands/connect.js.map +1 -1
- package/dist/cli/commands/context.js +8 -1
- package/dist/cli/commands/context.js.map +1 -1
- package/dist/cli/commands/disconnect.js.map +1 -1
- package/dist/cli/commands/doc.js +20 -6
- package/dist/cli/commands/doc.js.map +1 -1
- package/dist/cli/commands/insight.js +57 -54
- package/dist/cli/commands/insight.js.map +1 -1
- package/dist/cli/commands/key.js +10 -4
- package/dist/cli/commands/key.js.map +1 -1
- package/dist/cli/commands/link.js +11 -3
- package/dist/cli/commands/link.js.map +1 -1
- package/dist/cli/commands/plan.js +15 -5
- package/dist/cli/commands/plan.js.map +1 -1
- package/dist/cli/commands/planner.d.ts +3 -3
- package/dist/cli/commands/planner.js +76 -76
- package/dist/cli/commands/planner.js.map +1 -1
- package/dist/cli/commands/research.d.ts +1 -1
- package/dist/cli/commands/research.js +274 -247
- package/dist/cli/commands/research.js.map +1 -1
- package/dist/cli/commands/run.js +67 -23
- package/dist/cli/commands/run.js.map +1 -1
- package/dist/cli/commands/scaffold.js +4 -1
- package/dist/cli/commands/scaffold.js.map +1 -1
- package/dist/cli/commands/set-folder.js +6 -2
- package/dist/cli/commands/set-folder.js.map +1 -1
- package/dist/cli/commands/shared.js +12 -2
- package/dist/cli/commands/shared.js.map +1 -1
- package/dist/cli/commands/skills.js.map +1 -1
- package/dist/cli/commands/usage.js +8 -2
- package/dist/cli/commands/usage.js.map +1 -1
- package/dist/cli/commands/worker.js +82 -28
- package/dist/cli/commands/worker.js.map +1 -1
- package/dist/cli/commands/workflow-author.d.ts +1 -0
- package/dist/cli/commands/workflow-author.js +170 -0
- package/dist/cli/commands/workflow-author.js.map +1 -0
- package/dist/cli/commands/workflow.js +120 -110
- package/dist/cli/commands/workflow.js.map +1 -1
- package/dist/cli/index.js +6 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils.js +9 -5
- package/dist/cli/utils.js.map +1 -1
- package/dist/lib/api-agents.d.ts +11 -9
- package/dist/lib/api-agents.js +11 -11
- package/dist/lib/api-agents.js.map +1 -1
- package/dist/lib/api-content.d.ts +12 -12
- package/dist/lib/api-content.js +46 -46
- package/dist/lib/api-content.js.map +1 -1
- package/dist/lib/api-core.js +13 -12
- package/dist/lib/api-core.js.map +1 -1
- package/dist/lib/api-tasks.d.ts +28 -2
- package/dist/lib/api-tasks.js +29 -21
- package/dist/lib/api-tasks.js.map +1 -1
- package/dist/lib/api-types.d.ts +36 -28
- package/dist/lib/api.d.ts +14 -14
- package/dist/lib/api.js +26 -26
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/audit/docs.js.map +1 -1
- package/dist/lib/audit/errors.js.map +1 -1
- package/dist/lib/audit/gates.js +9 -2
- package/dist/lib/audit/gates.js.map +1 -1
- package/dist/lib/audit/modularity.js +4 -1
- package/dist/lib/audit/modularity.js.map +1 -1
- package/dist/lib/audit/quality.js +1 -1
- package/dist/lib/audit/quality.js.map +1 -1
- package/dist/lib/audit/rbac.js.map +1 -1
- package/dist/lib/audit/reporter.js.map +1 -1
- package/dist/lib/audit/runner.js +29 -8
- package/dist/lib/audit/runner.js.map +1 -1
- package/dist/lib/audit/security.js +35 -7
- package/dist/lib/audit/security.js.map +1 -1
- package/dist/lib/audit/ux.js +1 -4
- package/dist/lib/audit/ux.js.map +1 -1
- package/dist/lib/auto-run-state.js +5 -1
- package/dist/lib/auto-run-state.js.map +1 -1
- package/dist/lib/blog/charts.js.map +1 -1
- package/dist/lib/bridge-notice.js +2 -2
- package/dist/lib/bridge-notice.js.map +1 -1
- package/dist/lib/brief.d.ts +2 -2
- package/dist/lib/brief.js +158 -153
- package/dist/lib/brief.js.map +1 -1
- package/dist/lib/browser/batch.d.ts +18 -0
- package/dist/lib/browser/batch.js +42 -4
- package/dist/lib/browser/batch.js.map +1 -1
- package/dist/lib/browser/browse-actions.js +326 -293
- package/dist/lib/browser/browse-actions.js.map +1 -1
- package/dist/lib/browser/browse-cdp.js +51 -28
- package/dist/lib/browser/browse-cdp.js.map +1 -1
- package/dist/lib/browser/browse-editor.d.ts +1 -1
- package/dist/lib/browser/browse-editor.js +335 -236
- package/dist/lib/browser/browse-editor.js.map +1 -1
- package/dist/lib/browser/browse-harness.js +27 -8
- package/dist/lib/browser/browse-harness.js.map +1 -1
- package/dist/lib/browser/browse-llm.d.ts +10 -0
- package/dist/lib/browser/browse-llm.js +182 -39
- package/dist/lib/browser/browse-llm.js.map +1 -1
- package/dist/lib/browser/browse-safety.d.ts +12 -0
- package/dist/lib/browser/browse-safety.js +29 -17
- package/dist/lib/browser/browse-safety.js.map +1 -1
- package/dist/lib/browser/browse-stealth.d.ts +9 -0
- package/dist/lib/browser/browse-stealth.js +118 -66
- package/dist/lib/browser/browse-stealth.js.map +1 -1
- package/dist/lib/browser/browse-types.js +143 -143
- package/dist/lib/browser/browse-types.js.map +1 -1
- package/dist/lib/browser/cdp.d.ts +32 -0
- package/dist/lib/browser/cdp.js +139 -9
- package/dist/lib/browser/cdp.js.map +1 -1
- package/dist/lib/browser/human-input-guard.js +14 -4
- package/dist/lib/browser/human-input-guard.js.map +1 -1
- package/dist/lib/browser/launch.js +3 -1
- package/dist/lib/browser/launch.js.map +1 -1
- package/dist/lib/browser/login.js +97 -19
- package/dist/lib/browser/login.js.map +1 -1
- package/dist/lib/browser/option-state.js +8 -2
- package/dist/lib/browser/option-state.js.map +1 -1
- package/dist/lib/browser/owned-registry.js.map +1 -1
- package/dist/lib/browser/personal-fields.js +54 -9
- package/dist/lib/browser/personal-fields.js.map +1 -1
- package/dist/lib/browser/process.js +10 -2
- package/dist/lib/browser/process.js.map +1 -1
- package/dist/lib/browser/profile-guard.js +5 -0
- package/dist/lib/browser/profile-guard.js.map +1 -1
- package/dist/lib/browser/screen-change.js.map +1 -1
- package/dist/lib/browser/session.d.ts +19 -0
- package/dist/lib/browser/session.js +34 -3
- package/dist/lib/browser/session.js.map +1 -1
- package/dist/lib/browser/stage-file.d.ts +31 -0
- package/dist/lib/browser/stage-file.js +123 -0
- package/dist/lib/browser/stage-file.js.map +1 -0
- package/dist/lib/cache-cleaner.js +54 -15
- package/dist/lib/cache-cleaner.js.map +1 -1
- package/dist/lib/chat/board-reply.js +16 -4
- package/dist/lib/chat/board-reply.js.map +1 -1
- package/dist/lib/chat/chat-lock.js.map +1 -1
- package/dist/lib/chat/chat-reply.js +21 -13
- package/dist/lib/chat/chat-reply.js.map +1 -1
- package/dist/lib/chat/daemon-reporter.js +1 -0
- package/dist/lib/chat/daemon-reporter.js.map +1 -1
- package/dist/lib/chat/doc-reply.js +32 -7
- package/dist/lib/chat/doc-reply.js.map +1 -1
- package/dist/lib/chat/index.d.ts +1 -1
- package/dist/lib/chat/index.js.map +1 -1
- package/dist/lib/chat/session-stream.d.ts +7 -1
- package/dist/lib/chat/session-stream.js +2 -1
- package/dist/lib/chat/session-stream.js.map +1 -1
- package/dist/lib/chat/workflow-author-reply.d.ts +41 -0
- package/dist/lib/chat/workflow-author-reply.js +158 -0
- package/dist/lib/chat/workflow-author-reply.js.map +1 -0
- package/dist/lib/config.js +30 -23
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/context/scan.js +12 -4
- package/dist/lib/context/scan.js.map +1 -1
- package/dist/lib/context/sync.js +6 -1
- package/dist/lib/context/sync.js.map +1 -1
- package/dist/lib/diagnostics.js +24 -7
- package/dist/lib/diagnostics.js.map +1 -1
- package/dist/lib/documents/convert.js +0 -2
- package/dist/lib/documents/convert.js.map +1 -1
- package/dist/lib/documents/docx-inspect.js +6 -2
- package/dist/lib/documents/docx-inspect.js.map +1 -1
- package/dist/lib/documents/docx-template.js +11 -20
- package/dist/lib/documents/docx-template.js.map +1 -1
- package/dist/lib/documents/job-runner.js.map +1 -1
- package/dist/lib/documents/source.js.map +1 -1
- package/dist/lib/git/git-auto.js +43 -10
- package/dist/lib/git/git-auto.js.map +1 -1
- package/dist/lib/git/git-branch.js +15 -15
- package/dist/lib/git/git-core.d.ts +2 -2
- package/dist/lib/git/git-core.js +7 -7
- package/dist/lib/git/git-core.js.map +1 -1
- package/dist/lib/git/git-discovery.js +49 -42
- package/dist/lib/git/git-discovery.js.map +1 -1
- package/dist/lib/git/git-finalize.d.ts +2 -2
- package/dist/lib/git/git-finalize.js +99 -96
- package/dist/lib/git/git-finalize.js.map +1 -1
- package/dist/lib/git/git-pipeline.d.ts +9 -9
- package/dist/lib/git/git-pipeline.js.map +1 -1
- package/dist/lib/git/git-prepare.d.ts +2 -2
- package/dist/lib/git/git-prepare.js +45 -42
- package/dist/lib/git/git-prepare.js.map +1 -1
- package/dist/lib/git/git-presence.js +16 -6
- package/dist/lib/git/git-presence.js.map +1 -1
- package/dist/lib/git/git-runner.js +82 -22
- package/dist/lib/git/git-runner.js.map +1 -1
- package/dist/lib/git/index-recovery.js +18 -4
- package/dist/lib/git/index-recovery.js.map +1 -1
- package/dist/lib/git/index.d.ts +4 -4
- package/dist/lib/git/index.js.map +1 -1
- package/dist/lib/git/pr-create.js +4 -1
- package/dist/lib/git/pr-create.js.map +1 -1
- package/dist/lib/git/question-pause.d.ts +1 -1
- package/dist/lib/git/question-pause.js +1 -1
- package/dist/lib/git/question-pause.js.map +1 -1
- package/dist/lib/git/slug.js.map +1 -1
- package/dist/lib/git/stash-context.js +3 -1
- package/dist/lib/git/stash-context.js.map +1 -1
- package/dist/lib/harness/agy-pty.js +9 -4
- package/dist/lib/harness/agy-pty.js.map +1 -1
- package/dist/lib/harness/harness-adapter.d.ts +1 -3
- package/dist/lib/harness/harness-adapter.js +61 -20
- package/dist/lib/harness/harness-adapter.js.map +1 -1
- package/dist/lib/harness/harness-models.js +10 -3
- package/dist/lib/harness/harness-models.js.map +1 -1
- package/dist/lib/harness/harness-output.js +14 -6
- package/dist/lib/harness/harness-output.js.map +1 -1
- package/dist/lib/harness/harness.js +32 -14
- package/dist/lib/harness/harness.js.map +1 -1
- package/dist/lib/harness/index.d.ts +3 -3
- package/dist/lib/harness/index.js.map +1 -1
- package/dist/lib/harness/plan-gate.js.map +1 -1
- package/dist/lib/harness/resume.js +3 -1
- package/dist/lib/harness/resume.js.map +1 -1
- package/dist/lib/harness/run-scope.js.map +1 -1
- package/dist/lib/harness/session-store.js.map +1 -1
- package/dist/lib/harness/spawn.js +41 -14
- package/dist/lib/harness/spawn.js.map +1 -1
- package/dist/lib/human-style.d.ts +29 -0
- package/dist/lib/human-style.js +114 -0
- package/dist/lib/human-style.js.map +1 -0
- package/dist/lib/llm/index.d.ts +3 -3
- package/dist/lib/llm/index.js.map +1 -1
- package/dist/lib/llm/llm-chat.js.map +1 -1
- package/dist/lib/llm/llm-tools.js +229 -63
- package/dist/lib/llm/llm-tools.js.map +1 -1
- package/dist/lib/llm/llm.d.ts +1 -1
- package/dist/lib/llm/llm.js +28 -6
- package/dist/lib/llm/llm.js.map +1 -1
- package/dist/lib/llm/models.js +27 -5
- package/dist/lib/llm/models.js.map +1 -1
- package/dist/lib/llm/retry.js.map +1 -1
- package/dist/lib/llm/usage-reader.js +30 -10
- package/dist/lib/llm/usage-reader.js.map +1 -1
- package/dist/lib/llm/usage.js.map +1 -1
- package/dist/lib/lock.d.ts +5 -1
- package/dist/lib/lock.js +13 -4
- package/dist/lib/lock.js.map +1 -1
- package/dist/lib/mcp-identity.js +4 -1
- package/dist/lib/mcp-identity.js.map +1 -1
- package/dist/lib/media-gen/generate.d.ts +1 -1
- package/dist/lib/media-gen/generate.js +83 -68
- package/dist/lib/media-gen/generate.js.map +1 -1
- package/dist/lib/orchestrator/client.js +66 -15
- package/dist/lib/orchestrator/client.js.map +1 -1
- package/dist/lib/orchestrator/handlers/browser.js +198 -35
- package/dist/lib/orchestrator/handlers/browser.js.map +1 -1
- package/dist/lib/orchestrator/handlers/cv-parse.js +0 -1
- package/dist/lib/orchestrator/handlers/cv-parse.js.map +1 -1
- package/dist/lib/orchestrator/handlers/git.js +91 -70
- package/dist/lib/orchestrator/handlers/git.js.map +1 -1
- package/dist/lib/orchestrator/handlers/index.d.ts +2 -2
- package/dist/lib/orchestrator/handlers/index.js.map +1 -1
- package/dist/lib/orchestrator/handlers/misc.js +48 -15
- package/dist/lib/orchestrator/handlers/misc.js.map +1 -1
- package/dist/lib/orchestrator/handlers/planner.js +61 -61
- package/dist/lib/orchestrator/handlers/planner.js.map +1 -1
- package/dist/lib/orchestrator/runner.js +6 -3
- package/dist/lib/orchestrator/runner.js.map +1 -1
- package/dist/lib/orchestrator/worktree.js +133 -40
- package/dist/lib/orchestrator/worktree.js.map +1 -1
- package/dist/lib/package-manager.js +28 -4
- package/dist/lib/package-manager.js.map +1 -1
- package/dist/lib/process-tree.js +16 -3
- package/dist/lib/process-tree.js.map +1 -1
- package/dist/lib/rate-gate.js +3 -2
- package/dist/lib/rate-gate.js.map +1 -1
- package/dist/lib/run-report.js.map +1 -1
- package/dist/lib/scaffold/renderer.js.map +1 -1
- package/dist/lib/scaffold/structure.js.map +1 -1
- package/dist/lib/scaffold/verify.js.map +1 -1
- package/dist/lib/secret-store.js +28 -9
- package/dist/lib/secret-store.js.map +1 -1
- package/dist/lib/skills.js +1 -1
- package/dist/lib/skills.js.map +1 -1
- package/dist/lib/tail-file.js.map +1 -1
- package/dist/lib/tools/browser-tool.js +153 -55
- package/dist/lib/tools/browser-tool.js.map +1 -1
- package/dist/lib/tools/chart-builder.js +29 -7
- package/dist/lib/tools/chart-builder.js.map +1 -1
- package/dist/lib/tools/csv-cruncher.js +22 -6
- package/dist/lib/tools/csv-cruncher.js.map +1 -1
- package/dist/lib/tools/docx-report.js +419 -54
- package/dist/lib/tools/docx-report.js.map +1 -1
- package/dist/lib/tools/docx-source.js +3 -1
- package/dist/lib/tools/docx-source.js.map +1 -1
- package/dist/lib/tools/pdf-exporter.js +151 -37
- package/dist/lib/tools/pdf-exporter.js.map +1 -1
- package/dist/lib/tools/pptx-deck.js +34 -6
- package/dist/lib/tools/pptx-deck.js.map +1 -1
- package/dist/lib/tools/process-image.js +16 -4
- package/dist/lib/tools/process-image.js.map +1 -1
- package/dist/lib/tools/qr-generator.js +4 -1
- package/dist/lib/tools/qr-generator.js.map +1 -1
- package/dist/lib/tools/runner.js +4 -2
- package/dist/lib/tools/runner.js.map +1 -1
- package/dist/lib/tools/xlsx-workbook.js +4 -1
- package/dist/lib/tools/xlsx-workbook.js.map +1 -1
- package/dist/lib/version-check.js +11 -5
- package/dist/lib/version-check.js.map +1 -1
- package/dist/lib/wake-claim.js +2 -1
- package/dist/lib/wake-claim.js.map +1 -1
- package/dist/lib/wake-state.js +12 -6
- package/dist/lib/wake-state.js.map +1 -1
- package/dist/lib/workflow/node-executor.js +144 -18
- package/dist/lib/workflow/node-executor.js.map +1 -1
- package/dist/lib/workspace/bus.js +3 -1
- package/dist/lib/workspace/bus.js.map +1 -1
- package/dist/lib/workspace/classify.js +77 -18
- package/dist/lib/workspace/classify.js.map +1 -1
- package/dist/lib/workspace/mirror-lease.js +6 -2
- package/dist/lib/workspace/mirror-lease.js.map +1 -1
- package/dist/lib/workspace/mirror.js +34 -10
- package/dist/lib/workspace/mirror.js.map +1 -1
- package/dist/lib/workspace/opencode-projects.js +9 -4
- package/dist/lib/workspace/opencode-projects.js.map +1 -1
- package/dist/lib/workspace/presence.js +6 -2
- package/dist/lib/workspace/presence.js.map +1 -1
- package/dist/lib/workspace/repo-lock.js +16 -4
- package/dist/lib/workspace/repo-lock.js.map +1 -1
- package/dist/lib/workspace/session-mention.js.map +1 -1
- package/dist/lib/workspace/shim-runner.js +22 -5
- package/dist/lib/workspace/shim-runner.js.map +1 -1
- package/dist/lib/workspace/shims.js +8 -2
- package/dist/lib/workspace/shims.js.map +1 -1
- package/dist/lib/workspace/stop-notice.js +5 -2
- package/dist/lib/workspace/stop-notice.js.map +1 -1
- package/dist/lib/workspace/stop-save.js +9 -4
- package/dist/lib/workspace/stop-save.js.map +1 -1
- package/package.json +10 -2
|
@@ -137,149 +137,149 @@ exports.MULTI_SELECT_PAUSE_MS = 1_000;
|
|
|
137
137
|
*/
|
|
138
138
|
exports.FAST_RULE_0 = '0. BE FAST AND DECISIVE. The page text, element list and screenshot are CONTEXT ONLY - never describe, summarise, quote or restate them, and never write a sentence. Use the context to identify the current UNANSWERED question, then reply with the JSON array immediately. Your entire reply must be that array.';
|
|
139
139
|
exports.DEEP_RULE_0 = '0. This may be a HARD problem (advanced coding / algorithms). The page text, element list and screenshot are CONTEXT ONLY - never describe, summarise or restate them. Reason about the ANSWER only, then reply with the JSON array. For coding questions write the most time-efficient solution and emit the FULL solution via write_code.';
|
|
140
|
-
exports.SYSTEM_PROMPT = `You are a browser automation agent. A screenshot and a grouped list of interactive elements are attached.
|
|
141
|
-
|
|
142
|
-
Your task: identify unanswered questions and answer them by clicking the correct elements.
|
|
143
|
-
|
|
144
|
-
RULES (STRICT):
|
|
145
|
-
${exports.FAST_RULE_0}
|
|
146
|
-
1. NEVER click Next, Submit, Back, Save, Continue, or any navigation. ONLY answer questions on the current screen.
|
|
147
|
-
2. NEVER ask for help. If uncertain, pick the BEST GUESS. Always decide — never wait.
|
|
148
|
-
3. Handle MULTIPLE unanswered questions in a SINGLE response.
|
|
149
|
-
4. NEVER return done unless you have VERIFIED every single question is answered. See VERIFICATION CHECKLIST below.
|
|
150
|
-
5. NEVER answer personal questions — see PERSONAL QUESTIONS section below.
|
|
151
|
-
|
|
152
|
-
VERIFICATION CHECKLIST (MANDATORY before returning done):
|
|
153
|
-
Before returning done, you MUST check EVERY question group:
|
|
154
|
-
- Radio questions: exactly ONE option must be selected (checked). If none selected → you MUST pick an answer.
|
|
155
|
-
- Checkbox questions: ALL correct options must be checked. If any correct option is missing → you MUST check it.
|
|
156
|
-
- Text input questions: the input must have a non-empty value. If empty → you MUST type an answer.
|
|
157
|
-
If ANY question fails this check, you MUST answer it — NEVER return done with unanswered questions.
|
|
158
|
-
If you return done while questions are unanswered, the task will FAIL. You will be retried.
|
|
159
|
-
|
|
160
|
-
QUESTION TYPES AND STATUS:
|
|
161
|
-
- radio (single answer): Only ONE option can be correct.
|
|
162
|
-
* "unanswered" → click the best answer
|
|
163
|
-
* "answered (X selected, can change)" → if you think X is WRONG, click a DIFFERENT option (browser auto-deselects the old one)
|
|
164
|
-
* Only return done if you're confident the selected answer is correct
|
|
165
|
-
|
|
166
|
-
- checkbox (MULTIPLE answers possible): MULTIPLE options can be correct.
|
|
167
|
-
* "unanswered" → click ALL correct answers
|
|
168
|
-
* "partially answered (N/M checked, can add/remove)" → if wrong answers are checked, click them AGAIN to uncheck. If correct answers are missing, click them to check.
|
|
169
|
-
* Clicking a [CHECKED] element unchecks it. Clicking an unchecked element checks it.
|
|
170
|
-
|
|
171
|
-
- text input: Type the answer into the field.
|
|
172
|
-
* "unanswered" → type the answer
|
|
173
|
-
* "answered (has input, can edit)" → clear and retype if wrong
|
|
174
|
-
|
|
175
|
-
MULTI-SELECT EXAMPLE (checkbox with 2 correct, 1 wrong currently checked):
|
|
176
|
-
[{"action":"click","elementIndex":4,"reason":"Uncheck wrong answer"},
|
|
177
|
-
{"action":"click","elementIndex":2,"reason":"Check correct answer A"},
|
|
178
|
-
{"action":"click","elementIndex":5,"reason":"Check correct answer C"}]
|
|
179
|
-
|
|
180
|
-
RADIO CHANGE EXAMPLE (radio has wrong answer selected):
|
|
181
|
-
[{"action":"click","elementIndex":1,"reason":"Change to correct answer B"}]
|
|
182
|
-
|
|
183
|
-
COMBINED EXAMPLE:
|
|
184
|
-
[{"action":"click","elementIndex":1,"reason":"Q1: select B (radio)"},
|
|
185
|
-
{"action":"click","elementIndex":4,"reason":"Q2: uncheck wrong"},
|
|
186
|
-
{"action":"click","elementIndex":5,"reason":"Q2: check correct"},
|
|
187
|
-
{"action":"type","elementIndex":9,"text":"42","reason":"Q3: fill answer"}]
|
|
188
|
-
|
|
189
|
-
CODE TYPE EXAMPLE (typing code into an editor — note escaped newlines and quotes):
|
|
190
|
-
[{"action":"type","elementIndex":5,"text":"function twoSum(nums: number[], target: number): number[] {\\n const map = new Map<number, number>();\\n for (let i = 0; i < nums.length; i++) {\\n const complement = target - nums[i];\\n if (map.has(complement)) {\\n return [map.get(complement), i];\\n }\\n map.set(nums[i], i);\\n }\\n return [];\\n}","reason":"Type the solution function"}]
|
|
191
|
-
|
|
192
|
-
WRITE_CODE EXAMPLE (large code blocks — preferred for code > 100 chars):
|
|
193
|
-
[{"action":"write_code","elementIndex":5,"code":"function twoSum(nums: number[], target: number): number[] {\\n const map = new Map<number, number>();\\n for (let i = 0; i < nums.length; i++) {\\n const complement = target - nums[i];\\n if (map.has(complement)) {\\n return [map.get(complement), i];\\n }\\n map.set(nums[i], i);\\n }\\n return [];\\n}","reason":"Type the solution function"}]
|
|
194
|
-
|
|
195
|
-
WHEN TO USE write_code vs type:
|
|
196
|
-
- "write_code" for code blocks, functions, classes, multi-line snippets (> 100 chars)
|
|
197
|
-
- "type" for short answers: numbers, single words, short strings (< 100 chars)
|
|
198
|
-
- "write_code" preserves exact indentation and newlines — no formatting changes
|
|
199
|
-
|
|
200
|
-
CODE FORMATTING RULES (CRITICAL):
|
|
201
|
-
- Use 2-space indentation. Each nesting level adds exactly 2 more spaces.
|
|
202
|
-
- Function body = 2 spaces, loop body = 4 spaces, if-body = 6 spaces.
|
|
203
|
-
- NEVER use tabs or 4/8-space indentation.
|
|
204
|
-
- Keep code compact: single-line statements when appropriate.
|
|
205
|
-
|
|
206
|
-
CODE OPTIMIZATION RULES (CRITICAL — for coding problems):
|
|
207
|
-
1. ALWAYS write the most time-efficient solution. Correctness alone is NOT enough.
|
|
208
|
-
2. Prefer O(n) or O(n log n) over O(n²). Never write O(n²) if an O(n) approach exists.
|
|
209
|
-
3. Use HashMap/Set for O(1) lookups instead of nested loops for searching/matching.
|
|
210
|
-
4. Consider space-time tradeoffs — a HashMap is worth the O(n) space for O(n) time.
|
|
211
|
-
5. Avoid unnecessary re-computation — cache results in variables.
|
|
212
|
-
6. Use sliding window, two pointers, or binary search where applicable.
|
|
213
|
-
7. Pre-compute prefix sums, frequency maps, or lookup tables when helpful.
|
|
214
|
-
8. Choose the right data structure:
|
|
215
|
-
- Deque for sliding window problems
|
|
216
|
-
- Heap/priority queue for top-K problems
|
|
217
|
-
- Trie for prefix/string matching problems
|
|
218
|
-
- Union-Find for connected components
|
|
219
|
-
- BFS for shortest path, DFS for exploration
|
|
220
|
-
9. NEVER write brute force if an optimized approach exists.
|
|
221
|
-
10. If the problem has constraints (e.g., n <= 10^5), ensure your solution runs within limits.
|
|
222
|
-
|
|
223
|
-
OPTIMIZATION EXAMPLE:
|
|
224
|
-
Problem: "Given an array of integers, return indices of two numbers that add up to target."
|
|
225
|
-
|
|
226
|
-
NAIVE (WRONG for efficiency — O(n²) time):
|
|
227
|
-
for (let i = 0; i < nums.length; i++) {
|
|
228
|
-
for (let j = i + 1; j < nums.length; j++) {
|
|
229
|
-
if (nums[i] + nums[j] === target) return [i, j];
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
OPTIMIZED (CORRECT — O(n) time, O(n) space):
|
|
234
|
-
const map = new Map();
|
|
235
|
-
for (let i = 0; i < nums.length; i++) {
|
|
236
|
-
const complement = target - nums[i];
|
|
237
|
-
if (map.has(complement)) return [map.get(complement), i];
|
|
238
|
-
map.set(nums[i], i);
|
|
239
|
-
}
|
|
240
|
-
return [];
|
|
241
|
-
|
|
242
|
-
Available actions:
|
|
243
|
-
- click: {action:"click", elementIndex:number} — click to check/uncheck/select
|
|
244
|
-
- type: {action:"type", elementIndex:number, text:string} — type short input (< 100 chars)
|
|
245
|
-
- write_code: {action:"write_code", elementIndex:number, code:string} — write code block (> 100 chars), preserves exact indentation
|
|
246
|
-
- scroll: {action:"scroll", delta:number} — scroll up (-) or down (+)
|
|
247
|
-
- press: {action:"press", key:string} — press Enter, Tab, etc.
|
|
248
|
-
- done: {action:"done", summary:string} — all visible questions answered correctly
|
|
249
|
-
|
|
250
|
-
ERROR CORRECTION (CRITICAL):
|
|
251
|
-
- Check <page_context> for "Errors on screen" after each action
|
|
252
|
-
- If errors are visible (wrong answer, validation error, "Incorrect", "Wrong Answer", "Error"), FIX THEM immediately
|
|
253
|
-
- For text inputs with errors: clear and retype the correct answer
|
|
254
|
-
- For code editors with errors: retype the correct code using write_code
|
|
255
|
-
- For radio/checkbox with errors: click the correct option
|
|
256
|
-
- NEVER return "done" if errors are visible on screen
|
|
257
|
-
- Keep running until ALL questions are answered correctly with NO errors
|
|
258
|
-
|
|
259
|
-
CORRECTION MODE:
|
|
260
|
-
- The <page_context> block shows the current editor content — compare it to the expected answer
|
|
261
|
-
- If editor content is WRONG or INCOMPLETE, type the CORRECT code to replace it
|
|
262
|
-
- If you previously typed wrong code, use write_code to replace with correct code
|
|
263
|
-
- You may be asked the same question multiple times — each time, check if the current answer is correct before acting
|
|
264
|
-
|
|
265
|
-
PERSONAL QUESTIONS — NEVER ANSWER THEM:
|
|
266
|
-
- Questions about the person operating the browser (name, email, phone, address, SSN, passport, password, card, bank, date of birth, salary, work authorization, personal profile links) are OFF LIMITS. Read the PERSONAL QUESTIONS addendum appended below and follow it exactly.
|
|
267
|
-
- If a question asks for personal info, do NOT click or type — leave it empty.
|
|
268
|
-
- A personal field left empty is NOT an unanswered question. If ALL remaining questions are personal, return done immediately.
|
|
269
|
-
|
|
270
|
-
RESPONSE FORMAT RULES (CRITICAL — follow exactly):
|
|
271
|
-
- Return ONLY a valid JSON array. No explanations, no markdown fences, no extra text.
|
|
272
|
-
- The response MUST be parseable by JSON.parse(). Test mentally: is your output valid JSON?
|
|
273
|
-
- For type actions with code: the text field is a JSON string. Escape special characters:
|
|
274
|
-
* Newlines → \\n (backslash + n, NOT a literal newline)
|
|
275
|
-
* Quotes → \\" (backslash + quote)
|
|
276
|
-
* Backslashes → \\\\ (double backslash)
|
|
277
|
-
* Tabs → \\t
|
|
278
|
-
- WRONG: {"text":"function foo() {\n return 1;}"}
|
|
279
|
-
- RIGHT: {"text":"function foo() {\\n return 1;}"}
|
|
280
|
-
- WRONG: {"text":"say "hello""}
|
|
281
|
-
- RIGHT: {"text":"say \\"hello\\""}
|
|
282
|
-
- NEVER put raw newlines or unescaped quotes inside the text string.
|
|
140
|
+
exports.SYSTEM_PROMPT = `You are a browser automation agent. A screenshot and a grouped list of interactive elements are attached.
|
|
141
|
+
|
|
142
|
+
Your task: identify unanswered questions and answer them by clicking the correct elements.
|
|
143
|
+
|
|
144
|
+
RULES (STRICT):
|
|
145
|
+
${exports.FAST_RULE_0}
|
|
146
|
+
1. NEVER click Next, Submit, Back, Save, Continue, or any navigation. ONLY answer questions on the current screen.
|
|
147
|
+
2. NEVER ask for help. If uncertain, pick the BEST GUESS. Always decide — never wait.
|
|
148
|
+
3. Handle MULTIPLE unanswered questions in a SINGLE response.
|
|
149
|
+
4. NEVER return done unless you have VERIFIED every single question is answered. See VERIFICATION CHECKLIST below.
|
|
150
|
+
5. NEVER answer personal questions — see PERSONAL QUESTIONS section below.
|
|
151
|
+
|
|
152
|
+
VERIFICATION CHECKLIST (MANDATORY before returning done):
|
|
153
|
+
Before returning done, you MUST check EVERY question group:
|
|
154
|
+
- Radio questions: exactly ONE option must be selected (checked). If none selected → you MUST pick an answer.
|
|
155
|
+
- Checkbox questions: ALL correct options must be checked. If any correct option is missing → you MUST check it.
|
|
156
|
+
- Text input questions: the input must have a non-empty value. If empty → you MUST type an answer.
|
|
157
|
+
If ANY question fails this check, you MUST answer it — NEVER return done with unanswered questions.
|
|
158
|
+
If you return done while questions are unanswered, the task will FAIL. You will be retried.
|
|
159
|
+
|
|
160
|
+
QUESTION TYPES AND STATUS:
|
|
161
|
+
- radio (single answer): Only ONE option can be correct.
|
|
162
|
+
* "unanswered" → click the best answer
|
|
163
|
+
* "answered (X selected, can change)" → if you think X is WRONG, click a DIFFERENT option (browser auto-deselects the old one)
|
|
164
|
+
* Only return done if you're confident the selected answer is correct
|
|
165
|
+
|
|
166
|
+
- checkbox (MULTIPLE answers possible): MULTIPLE options can be correct.
|
|
167
|
+
* "unanswered" → click ALL correct answers
|
|
168
|
+
* "partially answered (N/M checked, can add/remove)" → if wrong answers are checked, click them AGAIN to uncheck. If correct answers are missing, click them to check.
|
|
169
|
+
* Clicking a [CHECKED] element unchecks it. Clicking an unchecked element checks it.
|
|
170
|
+
|
|
171
|
+
- text input: Type the answer into the field.
|
|
172
|
+
* "unanswered" → type the answer
|
|
173
|
+
* "answered (has input, can edit)" → clear and retype if wrong
|
|
174
|
+
|
|
175
|
+
MULTI-SELECT EXAMPLE (checkbox with 2 correct, 1 wrong currently checked):
|
|
176
|
+
[{"action":"click","elementIndex":4,"reason":"Uncheck wrong answer"},
|
|
177
|
+
{"action":"click","elementIndex":2,"reason":"Check correct answer A"},
|
|
178
|
+
{"action":"click","elementIndex":5,"reason":"Check correct answer C"}]
|
|
179
|
+
|
|
180
|
+
RADIO CHANGE EXAMPLE (radio has wrong answer selected):
|
|
181
|
+
[{"action":"click","elementIndex":1,"reason":"Change to correct answer B"}]
|
|
182
|
+
|
|
183
|
+
COMBINED EXAMPLE:
|
|
184
|
+
[{"action":"click","elementIndex":1,"reason":"Q1: select B (radio)"},
|
|
185
|
+
{"action":"click","elementIndex":4,"reason":"Q2: uncheck wrong"},
|
|
186
|
+
{"action":"click","elementIndex":5,"reason":"Q2: check correct"},
|
|
187
|
+
{"action":"type","elementIndex":9,"text":"42","reason":"Q3: fill answer"}]
|
|
188
|
+
|
|
189
|
+
CODE TYPE EXAMPLE (typing code into an editor — note escaped newlines and quotes):
|
|
190
|
+
[{"action":"type","elementIndex":5,"text":"function twoSum(nums: number[], target: number): number[] {\\n const map = new Map<number, number>();\\n for (let i = 0; i < nums.length; i++) {\\n const complement = target - nums[i];\\n if (map.has(complement)) {\\n return [map.get(complement), i];\\n }\\n map.set(nums[i], i);\\n }\\n return [];\\n}","reason":"Type the solution function"}]
|
|
191
|
+
|
|
192
|
+
WRITE_CODE EXAMPLE (large code blocks — preferred for code > 100 chars):
|
|
193
|
+
[{"action":"write_code","elementIndex":5,"code":"function twoSum(nums: number[], target: number): number[] {\\n const map = new Map<number, number>();\\n for (let i = 0; i < nums.length; i++) {\\n const complement = target - nums[i];\\n if (map.has(complement)) {\\n return [map.get(complement), i];\\n }\\n map.set(nums[i], i);\\n }\\n return [];\\n}","reason":"Type the solution function"}]
|
|
194
|
+
|
|
195
|
+
WHEN TO USE write_code vs type:
|
|
196
|
+
- "write_code" for code blocks, functions, classes, multi-line snippets (> 100 chars)
|
|
197
|
+
- "type" for short answers: numbers, single words, short strings (< 100 chars)
|
|
198
|
+
- "write_code" preserves exact indentation and newlines — no formatting changes
|
|
199
|
+
|
|
200
|
+
CODE FORMATTING RULES (CRITICAL):
|
|
201
|
+
- Use 2-space indentation. Each nesting level adds exactly 2 more spaces.
|
|
202
|
+
- Function body = 2 spaces, loop body = 4 spaces, if-body = 6 spaces.
|
|
203
|
+
- NEVER use tabs or 4/8-space indentation.
|
|
204
|
+
- Keep code compact: single-line statements when appropriate.
|
|
205
|
+
|
|
206
|
+
CODE OPTIMIZATION RULES (CRITICAL — for coding problems):
|
|
207
|
+
1. ALWAYS write the most time-efficient solution. Correctness alone is NOT enough.
|
|
208
|
+
2. Prefer O(n) or O(n log n) over O(n²). Never write O(n²) if an O(n) approach exists.
|
|
209
|
+
3. Use HashMap/Set for O(1) lookups instead of nested loops for searching/matching.
|
|
210
|
+
4. Consider space-time tradeoffs — a HashMap is worth the O(n) space for O(n) time.
|
|
211
|
+
5. Avoid unnecessary re-computation — cache results in variables.
|
|
212
|
+
6. Use sliding window, two pointers, or binary search where applicable.
|
|
213
|
+
7. Pre-compute prefix sums, frequency maps, or lookup tables when helpful.
|
|
214
|
+
8. Choose the right data structure:
|
|
215
|
+
- Deque for sliding window problems
|
|
216
|
+
- Heap/priority queue for top-K problems
|
|
217
|
+
- Trie for prefix/string matching problems
|
|
218
|
+
- Union-Find for connected components
|
|
219
|
+
- BFS for shortest path, DFS for exploration
|
|
220
|
+
9. NEVER write brute force if an optimized approach exists.
|
|
221
|
+
10. If the problem has constraints (e.g., n <= 10^5), ensure your solution runs within limits.
|
|
222
|
+
|
|
223
|
+
OPTIMIZATION EXAMPLE:
|
|
224
|
+
Problem: "Given an array of integers, return indices of two numbers that add up to target."
|
|
225
|
+
|
|
226
|
+
NAIVE (WRONG for efficiency — O(n²) time):
|
|
227
|
+
for (let i = 0; i < nums.length; i++) {
|
|
228
|
+
for (let j = i + 1; j < nums.length; j++) {
|
|
229
|
+
if (nums[i] + nums[j] === target) return [i, j];
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
OPTIMIZED (CORRECT — O(n) time, O(n) space):
|
|
234
|
+
const map = new Map();
|
|
235
|
+
for (let i = 0; i < nums.length; i++) {
|
|
236
|
+
const complement = target - nums[i];
|
|
237
|
+
if (map.has(complement)) return [map.get(complement), i];
|
|
238
|
+
map.set(nums[i], i);
|
|
239
|
+
}
|
|
240
|
+
return [];
|
|
241
|
+
|
|
242
|
+
Available actions:
|
|
243
|
+
- click: {action:"click", elementIndex:number} — click to check/uncheck/select
|
|
244
|
+
- type: {action:"type", elementIndex:number, text:string} — type short input (< 100 chars)
|
|
245
|
+
- write_code: {action:"write_code", elementIndex:number, code:string} — write code block (> 100 chars), preserves exact indentation
|
|
246
|
+
- scroll: {action:"scroll", delta:number} — scroll up (-) or down (+)
|
|
247
|
+
- press: {action:"press", key:string} — press Enter, Tab, etc.
|
|
248
|
+
- done: {action:"done", summary:string} — all visible questions answered correctly
|
|
249
|
+
|
|
250
|
+
ERROR CORRECTION (CRITICAL):
|
|
251
|
+
- Check <page_context> for "Errors on screen" after each action
|
|
252
|
+
- If errors are visible (wrong answer, validation error, "Incorrect", "Wrong Answer", "Error"), FIX THEM immediately
|
|
253
|
+
- For text inputs with errors: clear and retype the correct answer
|
|
254
|
+
- For code editors with errors: retype the correct code using write_code
|
|
255
|
+
- For radio/checkbox with errors: click the correct option
|
|
256
|
+
- NEVER return "done" if errors are visible on screen
|
|
257
|
+
- Keep running until ALL questions are answered correctly with NO errors
|
|
258
|
+
|
|
259
|
+
CORRECTION MODE:
|
|
260
|
+
- The <page_context> block shows the current editor content — compare it to the expected answer
|
|
261
|
+
- If editor content is WRONG or INCOMPLETE, type the CORRECT code to replace it
|
|
262
|
+
- If you previously typed wrong code, use write_code to replace with correct code
|
|
263
|
+
- You may be asked the same question multiple times — each time, check if the current answer is correct before acting
|
|
264
|
+
|
|
265
|
+
PERSONAL QUESTIONS — NEVER ANSWER THEM:
|
|
266
|
+
- Questions about the person operating the browser (name, email, phone, address, SSN, passport, password, card, bank, date of birth, salary, work authorization, personal profile links) are OFF LIMITS. Read the PERSONAL QUESTIONS addendum appended below and follow it exactly.
|
|
267
|
+
- If a question asks for personal info, do NOT click or type — leave it empty.
|
|
268
|
+
- A personal field left empty is NOT an unanswered question. If ALL remaining questions are personal, return done immediately.
|
|
269
|
+
|
|
270
|
+
RESPONSE FORMAT RULES (CRITICAL — follow exactly):
|
|
271
|
+
- Return ONLY a valid JSON array. No explanations, no markdown fences, no extra text.
|
|
272
|
+
- The response MUST be parseable by JSON.parse(). Test mentally: is your output valid JSON?
|
|
273
|
+
- For type actions with code: the text field is a JSON string. Escape special characters:
|
|
274
|
+
* Newlines → \\n (backslash + n, NOT a literal newline)
|
|
275
|
+
* Quotes → \\" (backslash + quote)
|
|
276
|
+
* Backslashes → \\\\ (double backslash)
|
|
277
|
+
* Tabs → \\t
|
|
278
|
+
- WRONG: {"text":"function foo() {\n return 1;}"}
|
|
279
|
+
- RIGHT: {"text":"function foo() {\\n return 1;}"}
|
|
280
|
+
- WRONG: {"text":"say "hello""}
|
|
281
|
+
- RIGHT: {"text":"say \\"hello\\""}
|
|
282
|
+
- NEVER put raw newlines or unescaped quotes inside the text string.
|
|
283
283
|
- If you need to explain your reasoning, use the "reason" field, NOT the "text" field.`;
|
|
284
284
|
function sleep(ms) {
|
|
285
285
|
return new Promise((r) => setTimeout(r, ms));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browse-types.js","sourceRoot":"","sources":["../../../src/lib/browser/browse-types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"browse-types.js","sourceRoot":"","sources":["../../../src/lib/browser/browse-types.ts"],"names":[],"mappings":";;;AAgIA,8CAoBC;AAGD,oDAkCC;AAUD,gDAeC;AAuMD,sBAEC;AAED,8BAEC;AAhSD,0DAA0D;AAC1D,SAAgB,iBAAiB,CAC/B,QAAuB;IAEvB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAChD,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;QAC1B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACpD,MAAM,CAAC,GAAG,CAAC,EAA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AAM,CAAC;AAC3C;;;;;;;;GAQG;AACU,QAAA,eAAe,GAAG,CAAC,CAAC;AACjC;;;GAGG;AACU,QAAA,eAAe,GAAG,MAAM,CAAC;AACtC,2EAA2E;AAC9D,QAAA,eAAe,GAAG,KAAK,CAAC;AACrC;;;GAGG;AACU,QAAA,qBAAqB,GAAG,KAAK,CAAC;AAE3C;;;;GAIG;AACU,QAAA,WAAW,GACtB,qTAAqT,CAAC;AAC3S,QAAA,WAAW,GACtB,6UAA6U,CAAC;AAEnU,QAAA,aAAa,GAAG;;;;;EAK3B,mBAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uFA0I0E,CAAC;AAExF,SAAgB,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,SAAgB,SAAS,CAAC,GAAW,EAAE,GAAW;IAChD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC;AAC3D,CAAC"}
|
|
@@ -176,6 +176,38 @@ export declare function scrollPage(page: CdpPage, deltaY: number): Promise<void>
|
|
|
176
176
|
* Evaluate a JavaScript expression in the page context.
|
|
177
177
|
*/
|
|
178
178
|
export declare function evaluateJs(page: CdpPage, expression: string): Promise<any>;
|
|
179
|
+
/**
|
|
180
|
+
* Attach a local file to a file input, using CDP's DOM domain.
|
|
181
|
+
*
|
|
182
|
+
* WHY THIS EXISTS (2026-10): there was NO way to attach a file to a web form
|
|
183
|
+
* anywhere in the product - `DOM.setFileInputFiles`, `Page.setInterceptFileChooser`
|
|
184
|
+
* and `input[type=file]` had ZERO matches in the whole repo, and the DOM
|
|
185
|
+
* domain was never even enabled. A job application that asks for a CV file
|
|
186
|
+
* therefore could not be completed by any browser path.
|
|
187
|
+
*
|
|
188
|
+
* The sequence is the canonical CDP one: enable the DOM domain, resolve the
|
|
189
|
+
* document, query the node, then set its files. `files` are ABSOLUTE paths on
|
|
190
|
+
* the machine that runs Chrome - the caller is responsible for staging the
|
|
191
|
+
* bytes there (see `stage-file.ts`) and for keeping them inside the run's
|
|
192
|
+
* private directory.
|
|
193
|
+
*/
|
|
194
|
+
export declare function setFileInputFiles(page: CdpPage, filePath: string, selector?: string): Promise<{
|
|
195
|
+
ok: boolean;
|
|
196
|
+
error?: string;
|
|
197
|
+
}>;
|
|
198
|
+
/**
|
|
199
|
+
* Submit the form on the page.
|
|
200
|
+
*
|
|
201
|
+
* There was no submit action anywhere: the only ways to submit were pressing
|
|
202
|
+
* Enter (which submits only when a field has focus) or running
|
|
203
|
+
* `form.requestSubmit()` by hand through `evaluate`. This does the latter
|
|
204
|
+
* properly - preferring the form that actually has a submit control, and
|
|
205
|
+
* reporting clearly when there is nothing to submit.
|
|
206
|
+
*/
|
|
207
|
+
export declare function submitForm(page: CdpPage, selector?: string): Promise<{
|
|
208
|
+
ok: boolean;
|
|
209
|
+
error?: string;
|
|
210
|
+
}>;
|
|
179
211
|
/**
|
|
180
212
|
* Detect which code/rich-text editor is active on the page.
|
|
181
213
|
*/
|
package/dist/lib/browser/cdp.js
CHANGED
|
@@ -23,6 +23,8 @@ exports.typeText = typeText;
|
|
|
23
23
|
exports.pressKey = pressKey;
|
|
24
24
|
exports.scrollPage = scrollPage;
|
|
25
25
|
exports.evaluateJs = evaluateJs;
|
|
26
|
+
exports.setFileInputFiles = setFileInputFiles;
|
|
27
|
+
exports.submitForm = submitForm;
|
|
26
28
|
exports.detectEditor = detectEditor;
|
|
27
29
|
exports.focusSelector = focusSelector;
|
|
28
30
|
exports.sleep = sleep;
|
|
@@ -189,10 +191,14 @@ async function pickActiveTab(port, prevTargetId) {
|
|
|
189
191
|
// Multiple windows are visible (the browser is unfocused): prefer the most
|
|
190
192
|
// recently created tab - the one the site just opened/foregrounded - unless
|
|
191
193
|
// the bound tab already IS that newest tab.
|
|
192
|
-
const newest = visible.reduce((best, a) => (targetSeenOrder.get(a.id) ?? 0) > (targetSeenOrder.get(best.id) ?? 0)
|
|
194
|
+
const newest = visible.reduce((best, a) => (targetSeenOrder.get(a.id) ?? 0) > (targetSeenOrder.get(best.id) ?? 0)
|
|
195
|
+
? a
|
|
196
|
+
: best);
|
|
193
197
|
if (prevTargetId) {
|
|
194
198
|
const prev = visible.find((a) => a.id === prevTargetId);
|
|
195
|
-
if (prev &&
|
|
199
|
+
if (prev &&
|
|
200
|
+
(targetSeenOrder.get(prev.id) ?? 0) >=
|
|
201
|
+
(targetSeenOrder.get(newest.id) ?? 0)) {
|
|
196
202
|
return byId(prev.id);
|
|
197
203
|
}
|
|
198
204
|
}
|
|
@@ -341,8 +347,14 @@ function cdpSend(page, method, params) {
|
|
|
341
347
|
reject(new Error(`CDP timeout: ${method}`));
|
|
342
348
|
}, 30_000);
|
|
343
349
|
page.pending.set(id, {
|
|
344
|
-
resolve: (v) => {
|
|
345
|
-
|
|
350
|
+
resolve: (v) => {
|
|
351
|
+
clearTimeout(timeout);
|
|
352
|
+
resolve(v);
|
|
353
|
+
},
|
|
354
|
+
reject: (e) => {
|
|
355
|
+
clearTimeout(timeout);
|
|
356
|
+
reject(e);
|
|
357
|
+
},
|
|
346
358
|
});
|
|
347
359
|
page.ws.send(JSON.stringify({ id, method, params }));
|
|
348
360
|
});
|
|
@@ -471,6 +483,10 @@ async function extractElements(page) {
|
|
|
471
483
|
const sels = [
|
|
472
484
|
'input[type="radio"]', 'input[type="checkbox"]',
|
|
473
485
|
'input[type="text"]', 'input[type="email"]', 'input[type="password"]',
|
|
486
|
+
// A file input is how a CV reaches a job application form. It used to
|
|
487
|
+
// be ABSENT from this list, so elementIndex could never address one
|
|
488
|
+
// and DOM.setFileInputFiles had nothing to attach to.
|
|
489
|
+
'input[type="file"]',
|
|
474
490
|
'input:not([type])',
|
|
475
491
|
'textarea', 'select', 'button', 'a',
|
|
476
492
|
'[role="radio"]', '[role="checkbox"]', '[role="button"]',
|
|
@@ -621,10 +637,18 @@ async function extractElements(page) {
|
|
|
621
637
|
*/
|
|
622
638
|
async function clickAt(page, x, y) {
|
|
623
639
|
await cdpSend(page, 'Input.dispatchMouseEvent', {
|
|
624
|
-
type: 'mousePressed',
|
|
640
|
+
type: 'mousePressed',
|
|
641
|
+
x,
|
|
642
|
+
y,
|
|
643
|
+
button: 'left',
|
|
644
|
+
clickCount: 1,
|
|
625
645
|
});
|
|
626
646
|
await cdpSend(page, 'Input.dispatchMouseEvent', {
|
|
627
|
-
type: 'mouseReleased',
|
|
647
|
+
type: 'mouseReleased',
|
|
648
|
+
x,
|
|
649
|
+
y,
|
|
650
|
+
button: 'left',
|
|
651
|
+
clickCount: 1,
|
|
628
652
|
});
|
|
629
653
|
}
|
|
630
654
|
/**
|
|
@@ -645,15 +669,26 @@ async function pressKey(page, key) {
|
|
|
645
669
|
Space: { code: 'Space', key: ' ' },
|
|
646
670
|
};
|
|
647
671
|
const k = keyMap[key] ?? { code: key, key };
|
|
648
|
-
await cdpSend(page, 'Input.dispatchKeyEvent', {
|
|
649
|
-
|
|
672
|
+
await cdpSend(page, 'Input.dispatchKeyEvent', {
|
|
673
|
+
type: 'keyDown',
|
|
674
|
+
code: k.code,
|
|
675
|
+
key: k.key,
|
|
676
|
+
});
|
|
677
|
+
await cdpSend(page, 'Input.dispatchKeyEvent', {
|
|
678
|
+
type: 'keyUp',
|
|
679
|
+
code: k.code,
|
|
680
|
+
key: k.key,
|
|
681
|
+
});
|
|
650
682
|
}
|
|
651
683
|
/**
|
|
652
684
|
* Scroll the page by a delta (positive = down, negative = up).
|
|
653
685
|
*/
|
|
654
686
|
async function scrollPage(page, deltaY) {
|
|
655
687
|
await cdpSend(page, 'Input.dispatchMouseWheelEvent', {
|
|
656
|
-
x: 0,
|
|
688
|
+
x: 0,
|
|
689
|
+
y: 0,
|
|
690
|
+
deltaX: 0,
|
|
691
|
+
deltaY,
|
|
657
692
|
});
|
|
658
693
|
}
|
|
659
694
|
/**
|
|
@@ -667,6 +702,101 @@ async function evaluateJs(page, expression) {
|
|
|
667
702
|
});
|
|
668
703
|
return result?.result?.value;
|
|
669
704
|
}
|
|
705
|
+
/**
|
|
706
|
+
* Attach a local file to a file input, using CDP's DOM domain.
|
|
707
|
+
*
|
|
708
|
+
* WHY THIS EXISTS (2026-10): there was NO way to attach a file to a web form
|
|
709
|
+
* anywhere in the product - `DOM.setFileInputFiles`, `Page.setInterceptFileChooser`
|
|
710
|
+
* and `input[type=file]` had ZERO matches in the whole repo, and the DOM
|
|
711
|
+
* domain was never even enabled. A job application that asks for a CV file
|
|
712
|
+
* therefore could not be completed by any browser path.
|
|
713
|
+
*
|
|
714
|
+
* The sequence is the canonical CDP one: enable the DOM domain, resolve the
|
|
715
|
+
* document, query the node, then set its files. `files` are ABSOLUTE paths on
|
|
716
|
+
* the machine that runs Chrome - the caller is responsible for staging the
|
|
717
|
+
* bytes there (see `stage-file.ts`) and for keeping them inside the run's
|
|
718
|
+
* private directory.
|
|
719
|
+
*/
|
|
720
|
+
async function setFileInputFiles(page, filePath, selector) {
|
|
721
|
+
try {
|
|
722
|
+
await cdpSend(page, 'DOM.enable', {});
|
|
723
|
+
const doc = await cdpSend(page, 'DOM.getDocument', { depth: 1 });
|
|
724
|
+
const rootNodeId = doc?.root?.nodeId;
|
|
725
|
+
if (!rootNodeId) {
|
|
726
|
+
return { ok: false, error: 'the page has no DOM document' };
|
|
727
|
+
}
|
|
728
|
+
const css = selector && selector.trim() ? selector.trim() : 'input[type="file"]';
|
|
729
|
+
const found = await cdpSend(page, 'DOM.querySelector', {
|
|
730
|
+
nodeId: rootNodeId,
|
|
731
|
+
selector: css,
|
|
732
|
+
});
|
|
733
|
+
const nodeId = found?.nodeId;
|
|
734
|
+
if (!nodeId) {
|
|
735
|
+
return {
|
|
736
|
+
ok: false,
|
|
737
|
+
error: `no file input matched "${css}" on this page`,
|
|
738
|
+
};
|
|
739
|
+
}
|
|
740
|
+
await cdpSend(page, 'DOM.setFileInputFiles', {
|
|
741
|
+
nodeId,
|
|
742
|
+
files: [filePath],
|
|
743
|
+
});
|
|
744
|
+
return { ok: true };
|
|
745
|
+
}
|
|
746
|
+
catch (err) {
|
|
747
|
+
return {
|
|
748
|
+
ok: false,
|
|
749
|
+
error: err instanceof Error ? err.message : String(err),
|
|
750
|
+
};
|
|
751
|
+
}
|
|
752
|
+
}
|
|
753
|
+
/**
|
|
754
|
+
* Submit the form on the page.
|
|
755
|
+
*
|
|
756
|
+
* There was no submit action anywhere: the only ways to submit were pressing
|
|
757
|
+
* Enter (which submits only when a field has focus) or running
|
|
758
|
+
* `form.requestSubmit()` by hand through `evaluate`. This does the latter
|
|
759
|
+
* properly - preferring the form that actually has a submit control, and
|
|
760
|
+
* reporting clearly when there is nothing to submit.
|
|
761
|
+
*/
|
|
762
|
+
async function submitForm(page, selector) {
|
|
763
|
+
const css = selector && selector.trim() ? selector.trim() : 'form';
|
|
764
|
+
const js = `(() => {
|
|
765
|
+
const sel = ${JSON.stringify(css)};
|
|
766
|
+
const forms = Array.from(document.querySelectorAll(sel));
|
|
767
|
+
if (!forms.length) return { ok: false, error: 'no form matched "' + sel + '"' };
|
|
768
|
+
// Prefer a form that has a submit control; fall back to the first one.
|
|
769
|
+
const withButton = forms.find((f) => f.querySelector(
|
|
770
|
+
'button[type="submit"], input[type="submit"], button:not([type])'
|
|
771
|
+
));
|
|
772
|
+
const form = withButton || forms[0];
|
|
773
|
+
try {
|
|
774
|
+
if (typeof form.requestSubmit === 'function') {
|
|
775
|
+
form.requestSubmit();
|
|
776
|
+
} else {
|
|
777
|
+
form.submit();
|
|
778
|
+
}
|
|
779
|
+
return { ok: true, action: form.getAttribute('action') || '' };
|
|
780
|
+
} catch (e) {
|
|
781
|
+
return { ok: false, error: String(e && e.message ? e.message : e) };
|
|
782
|
+
}
|
|
783
|
+
})()`;
|
|
784
|
+
try {
|
|
785
|
+
const result = await evaluateJs(page, js);
|
|
786
|
+
if (!result || typeof result !== 'object') {
|
|
787
|
+
return { ok: false, error: 'the page did not answer the submit request' };
|
|
788
|
+
}
|
|
789
|
+
return result.ok
|
|
790
|
+
? { ok: true }
|
|
791
|
+
: { ok: false, error: result.error ?? 'the form could not be submitted' };
|
|
792
|
+
}
|
|
793
|
+
catch (err) {
|
|
794
|
+
return {
|
|
795
|
+
ok: false,
|
|
796
|
+
error: err instanceof Error ? err.message : String(err),
|
|
797
|
+
};
|
|
798
|
+
}
|
|
799
|
+
}
|
|
670
800
|
/**
|
|
671
801
|
* Detect which code/rich-text editor is active on the page.
|
|
672
802
|
*/
|