@tangle-network/browser-agent-driver 0.33.2 → 0.34.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/README.md +42 -1
- package/discovery/llms.txt +27 -0
- package/discovery/tangle-agent.json +36 -0
- package/dist/brain/action-parse.d.ts +16 -0
- package/dist/brain/action-parse.d.ts.map +1 -0
- package/dist/brain/action-parse.js +191 -0
- package/dist/brain/action-parse.js.map +1 -0
- package/dist/brain/decide.d.ts +58 -0
- package/dist/brain/decide.d.ts.map +1 -0
- package/dist/brain/decide.js +418 -0
- package/dist/brain/decide.js.map +1 -0
- package/dist/brain/history-compact.d.ts +19 -0
- package/dist/brain/history-compact.d.ts.map +1 -0
- package/dist/brain/history-compact.js +153 -0
- package/dist/brain/history-compact.js.map +1 -0
- package/dist/brain/index.d.ts +78 -152
- package/dist/brain/index.d.ts.map +1 -1
- package/dist/brain/index.js +62 -2268
- package/dist/brain/index.js.map +1 -1
- package/dist/brain/model-client.d.ts +101 -0
- package/dist/brain/model-client.d.ts.map +1 -0
- package/dist/brain/model-client.js +391 -0
- package/dist/brain/model-client.js.map +1 -0
- package/dist/brain/plan.d.ts +57 -0
- package/dist/brain/plan.d.ts.map +1 -0
- package/dist/brain/plan.js +194 -0
- package/dist/brain/plan.js.map +1 -0
- package/dist/brain/prompts.d.ts +37 -0
- package/dist/brain/prompts.d.ts.map +1 -0
- package/dist/brain/prompts.js +455 -0
- package/dist/brain/prompts.js.map +1 -0
- package/dist/brain/provider-fetch.d.ts +26 -0
- package/dist/brain/provider-fetch.d.ts.map +1 -0
- package/dist/brain/provider-fetch.js +45 -0
- package/dist/brain/provider-fetch.js.map +1 -0
- package/dist/brain/snapshot-budget.d.ts +20 -0
- package/dist/brain/snapshot-budget.d.ts.map +1 -0
- package/dist/brain/snapshot-budget.js +202 -0
- package/dist/brain/snapshot-budget.js.map +1 -0
- package/dist/brain/system-prompt.d.ts +67 -0
- package/dist/brain/system-prompt.d.ts.map +1 -0
- package/dist/brain/system-prompt.js +128 -0
- package/dist/brain/system-prompt.js.map +1 -0
- package/dist/brain/tasks/design-audit.d.ts +33 -0
- package/dist/brain/tasks/design-audit.d.ts.map +1 -0
- package/dist/brain/tasks/design-audit.js +100 -0
- package/dist/brain/tasks/design-audit.js.map +1 -0
- package/dist/brain/tasks/evaluate.d.ts +25 -0
- package/dist/brain/tasks/evaluate.d.ts.map +1 -0
- package/dist/brain/tasks/evaluate.js +55 -0
- package/dist/brain/tasks/evaluate.js.map +1 -0
- package/dist/brain/tasks/goal-verification.d.ts +32 -0
- package/dist/brain/tasks/goal-verification.d.ts.map +1 -0
- package/dist/brain/tasks/goal-verification.js +68 -0
- package/dist/brain/tasks/goal-verification.js.map +1 -0
- package/dist/brain/tasks/knowledge.d.ts +26 -0
- package/dist/brain/tasks/knowledge.d.ts.map +1 -0
- package/dist/brain/tasks/knowledge.js +56 -0
- package/dist/brain/tasks/knowledge.js.map +1 -0
- package/dist/brain/tasks/link-scout.d.ts +37 -0
- package/dist/brain/tasks/link-scout.d.ts.map +1 -0
- package/dist/brain/tasks/link-scout.js +69 -0
- package/dist/brain/tasks/link-scout.js.map +1 -0
- package/dist/brain/types.d.ts +55 -0
- package/dist/brain/types.d.ts.map +1 -0
- package/dist/brain/types.js +7 -0
- package/dist/brain/types.js.map +1 -0
- package/dist/browser/stealth-init-script.d.ts +9 -0
- package/dist/browser/stealth-init-script.d.ts.map +1 -0
- package/dist/browser/stealth-init-script.js +128 -0
- package/dist/browser/stealth-init-script.js.map +1 -0
- package/dist/browser/storage-state.d.ts +29 -0
- package/dist/browser/storage-state.d.ts.map +1 -0
- package/dist/browser/storage-state.js +47 -0
- package/dist/browser/storage-state.js.map +1 -0
- package/dist/cli/args.d.ts +141 -0
- package/dist/cli/args.d.ts.map +1 -0
- package/dist/cli/args.js +167 -0
- package/dist/cli/args.js.map +1 -0
- package/dist/cli/benchmark-sync.d.ts +9 -0
- package/dist/cli/benchmark-sync.d.ts.map +1 -0
- package/dist/cli/benchmark-sync.js +43 -0
- package/dist/cli/benchmark-sync.js.map +1 -0
- package/dist/cli/build-config.d.ts +11 -0
- package/dist/cli/build-config.d.ts.map +1 -0
- package/dist/cli/build-config.js +355 -0
- package/dist/cli/build-config.js.map +1 -0
- package/dist/cli/commands/auth.d.ts +3 -0
- package/dist/cli/commands/auth.d.ts.map +1 -0
- package/dist/cli/commands/auth.js +36 -0
- package/dist/cli/commands/auth.js.map +1 -0
- package/dist/cli/commands/chrome-debug.d.ts +7 -0
- package/dist/cli/commands/chrome-debug.d.ts.map +1 -0
- package/dist/cli/commands/chrome-debug.js +11 -0
- package/dist/cli/commands/chrome-debug.js.map +1 -0
- package/dist/cli/commands/design-audit.d.ts +3 -0
- package/dist/cli/commands/design-audit.d.ts.map +1 -0
- package/dist/cli/commands/design-audit.js +68 -0
- package/dist/cli/commands/design-audit.js.map +1 -0
- package/dist/cli/commands/preview.d.ts +14 -0
- package/dist/cli/commands/preview.d.ts.map +1 -0
- package/dist/cli/commands/preview.js +31 -0
- package/dist/cli/commands/preview.js.map +1 -0
- package/dist/cli/commands/run.d.ts +3 -0
- package/dist/cli/commands/run.d.ts.map +1 -0
- package/dist/cli/commands/run.js +728 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/runs.d.ts +8 -0
- package/dist/cli/commands/runs.d.ts.map +1 -0
- package/dist/cli/commands/runs.js +35 -0
- package/dist/cli/commands/runs.js.map +1 -0
- package/dist/cli/commands/share.d.ts +10 -0
- package/dist/cli/commands/share.d.ts.map +1 -0
- package/dist/cli/commands/share.js +32 -0
- package/dist/cli/commands/share.js.map +1 -0
- package/dist/cli/commands/showcase.d.ts +17 -0
- package/dist/cli/commands/showcase.d.ts.map +1 -0
- package/dist/cli/commands/showcase.js +20 -0
- package/dist/cli/commands/showcase.js.map +1 -0
- package/dist/cli/commands/snapshot.d.ts +12 -0
- package/dist/cli/commands/snapshot.d.ts.map +1 -0
- package/dist/cli/commands/snapshot.js +24 -0
- package/dist/cli/commands/snapshot.js.map +1 -0
- package/dist/cli/commands/view.d.ts +7 -0
- package/dist/cli/commands/view.d.ts.map +1 -0
- package/dist/cli/commands/view.js +23 -0
- package/dist/cli/commands/view.js.map +1 -0
- package/dist/cli/constants.d.ts +6 -0
- package/dist/cli/constants.d.ts.map +1 -0
- package/dist/cli/constants.js +3 -0
- package/dist/cli/constants.js.map +1 -0
- package/dist/cli/version.d.ts +7 -0
- package/dist/cli/version.d.ts.map +1 -0
- package/dist/cli/version.js +16 -0
- package/dist/cli/version.js.map +1 -0
- package/dist/cli-design-audit.d.ts +44 -36
- package/dist/cli-design-audit.d.ts.map +1 -1
- package/dist/cli-design-audit.js +137 -1646
- package/dist/cli-design-audit.js.map +1 -1
- package/dist/cli-jobs.js +2 -1
- package/dist/cli-jobs.js.map +1 -1
- package/dist/cli.js +66 -1697
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +5 -0
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +8 -0
- package/dist/config.js.map +1 -1
- package/dist/design/audit/evolve/agent.d.ts +23 -0
- package/dist/design/audit/evolve/agent.d.ts.map +1 -0
- package/dist/design/audit/evolve/agent.js +272 -0
- package/dist/design/audit/evolve/agent.js.map +1 -0
- package/dist/design/audit/evolve/css.d.ts +10 -0
- package/dist/design/audit/evolve/css.d.ts.map +1 -0
- package/dist/design/audit/evolve/css.js +206 -0
- package/dist/design/audit/evolve/css.js.map +1 -0
- package/dist/design/audit/evolve/index.d.ts +13 -0
- package/dist/design/audit/evolve/index.d.ts.map +1 -0
- package/dist/design/audit/evolve/index.js +12 -0
- package/dist/design/audit/evolve/index.js.map +1 -0
- package/dist/design/audit/evolve/report.d.ts +3 -0
- package/dist/design/audit/evolve/report.d.ts.map +1 -0
- package/dist/design/audit/evolve/report.js +45 -0
- package/dist/design/audit/evolve/report.js.map +1 -0
- package/dist/design/audit/evolve/types.d.ts +14 -0
- package/dist/design/audit/evolve/types.d.ts.map +1 -0
- package/dist/design/audit/evolve/types.js +2 -0
- package/dist/design/audit/evolve/types.js.map +1 -0
- package/dist/design/audit/pipeline.d.ts +12 -0
- package/dist/design/audit/pipeline.d.ts.map +1 -1
- package/dist/design/audit/pipeline.js +43 -27
- package/dist/design/audit/pipeline.js.map +1 -1
- package/dist/design/audit/reference/artifact/build.d.ts +33 -0
- package/dist/design/audit/reference/artifact/build.d.ts.map +1 -0
- package/dist/design/audit/reference/artifact/build.js +64 -0
- package/dist/design/audit/reference/artifact/build.js.map +1 -0
- package/dist/design/audit/reference/artifact/render.d.ts +39 -0
- package/dist/design/audit/reference/artifact/render.d.ts.map +1 -0
- package/dist/design/audit/reference/artifact/render.js +213 -0
- package/dist/design/audit/reference/artifact/render.js.map +1 -0
- package/dist/design/audit/reference/artifact/text.d.ts +11 -0
- package/dist/design/audit/reference/artifact/text.d.ts.map +1 -0
- package/dist/design/audit/reference/artifact/text.js +20 -0
- package/dist/design/audit/reference/artifact/text.js.map +1 -0
- package/dist/design/audit/reference/artifact/to-findings.d.ts +57 -0
- package/dist/design/audit/reference/artifact/to-findings.d.ts.map +1 -0
- package/dist/design/audit/reference/artifact/to-findings.js +314 -0
- package/dist/design/audit/reference/artifact/to-findings.js.map +1 -0
- package/dist/design/audit/reference/config.d.ts +50 -0
- package/dist/design/audit/reference/config.d.ts.map +1 -0
- package/dist/design/audit/reference/config.js +108 -0
- package/dist/design/audit/reference/config.js.map +1 -0
- package/dist/design/audit/reference/contracts.d.ts +1030 -0
- package/dist/design/audit/reference/contracts.d.ts.map +1 -0
- package/dist/design/audit/reference/contracts.js +28 -0
- package/dist/design/audit/reference/contracts.js.map +1 -0
- package/dist/design/audit/reference/corpus/build.d.ts +115 -0
- package/dist/design/audit/reference/corpus/build.d.ts.map +1 -0
- package/dist/design/audit/reference/corpus/build.js +152 -0
- package/dist/design/audit/reference/corpus/build.js.map +1 -0
- package/dist/design/audit/reference/corpus/schema.d.ts +33 -0
- package/dist/design/audit/reference/corpus/schema.d.ts.map +1 -0
- package/dist/design/audit/reference/corpus/schema.js +249 -0
- package/dist/design/audit/reference/corpus/schema.js.map +1 -0
- package/dist/design/audit/reference/corpus/store.d.ts +26 -0
- package/dist/design/audit/reference/corpus/store.d.ts.map +1 -0
- package/dist/design/audit/reference/corpus/store.js +104 -0
- package/dist/design/audit/reference/corpus/store.js.map +1 -0
- package/dist/design/audit/reference/dna/delta.d.ts +21 -0
- package/dist/design/audit/reference/dna/delta.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/delta.js +126 -0
- package/dist/design/audit/reference/dna/delta.js.map +1 -0
- package/dist/design/audit/reference/dna/derive.d.ts +31 -0
- package/dist/design/audit/reference/dna/derive.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/derive.js +381 -0
- package/dist/design/audit/reference/dna/derive.js.map +1 -0
- package/dist/design/audit/reference/dna/descriptor.d.ts +36 -0
- package/dist/design/audit/reference/dna/descriptor.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/descriptor.js +209 -0
- package/dist/design/audit/reference/dna/descriptor.js.map +1 -0
- package/dist/design/audit/reference/dna/page-adapter.d.ts +17 -0
- package/dist/design/audit/reference/dna/page-adapter.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/page-adapter.js +35 -0
- package/dist/design/audit/reference/dna/page-adapter.js.map +1 -0
- package/dist/design/audit/reference/dna/scroll-capture.d.ts +93 -0
- package/dist/design/audit/reference/dna/scroll-capture.d.ts.map +1 -0
- package/dist/design/audit/reference/dna/scroll-capture.js +374 -0
- package/dist/design/audit/reference/dna/scroll-capture.js.map +1 -0
- package/dist/design/audit/reference/engine/budget.d.ts +63 -0
- package/dist/design/audit/reference/engine/budget.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/budget.js +110 -0
- package/dist/design/audit/reference/engine/budget.js.map +1 -0
- package/dist/design/audit/reference/engine/core.d.ts +32 -0
- package/dist/design/audit/reference/engine/core.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/core.js +261 -0
- package/dist/design/audit/reference/engine/core.js.map +1 -0
- package/dist/design/audit/reference/engine/guard.d.ts +43 -0
- package/dist/design/audit/reference/engine/guard.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/guard.js +43 -0
- package/dist/design/audit/reference/engine/guard.js.map +1 -0
- package/dist/design/audit/reference/engine/score-core.d.ts +48 -0
- package/dist/design/audit/reference/engine/score-core.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/score-core.js +134 -0
- package/dist/design/audit/reference/engine/score-core.js.map +1 -0
- package/dist/design/audit/reference/engine/wiring.d.ts +35 -0
- package/dist/design/audit/reference/engine/wiring.d.ts.map +1 -0
- package/dist/design/audit/reference/engine/wiring.js +80 -0
- package/dist/design/audit/reference/engine/wiring.js.map +1 -0
- package/dist/design/audit/reference/eval/taste-core.d.ts +77 -0
- package/dist/design/audit/reference/eval/taste-core.d.ts.map +1 -0
- package/dist/design/audit/reference/eval/taste-core.js +95 -0
- package/dist/design/audit/reference/eval/taste-core.js.map +1 -0
- package/dist/design/audit/reference/generate/generator.d.ts +49 -0
- package/dist/design/audit/reference/generate/generator.d.ts.map +1 -0
- package/dist/design/audit/reference/generate/generator.js +94 -0
- package/dist/design/audit/reference/generate/generator.js.map +1 -0
- package/dist/design/audit/reference/generate/parse.d.ts +28 -0
- package/dist/design/audit/reference/generate/parse.d.ts.map +1 -0
- package/dist/design/audit/reference/generate/parse.js +180 -0
- package/dist/design/audit/reference/generate/parse.js.map +1 -0
- package/dist/design/audit/reference/generate/prompt.d.ts +36 -0
- package/dist/design/audit/reference/generate/prompt.d.ts.map +1 -0
- package/dist/design/audit/reference/generate/prompt.js +124 -0
- package/dist/design/audit/reference/generate/prompt.js.map +1 -0
- package/dist/design/audit/reference/index.d.ts +26 -0
- package/dist/design/audit/reference/index.d.ts.map +1 -0
- package/dist/design/audit/reference/index.js +31 -0
- package/dist/design/audit/reference/index.js.map +1 -0
- package/dist/design/audit/reference/judge/image-clamp.d.ts +34 -0
- package/dist/design/audit/reference/judge/image-clamp.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/image-clamp.js +88 -0
- package/dist/design/audit/reference/judge/image-clamp.js.map +1 -0
- package/dist/design/audit/reference/judge/pairwise.d.ts +34 -0
- package/dist/design/audit/reference/judge/pairwise.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/pairwise.js +105 -0
- package/dist/design/audit/reference/judge/pairwise.js.map +1 -0
- package/dist/design/audit/reference/judge/parse.d.ts +31 -0
- package/dist/design/audit/reference/judge/parse.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/parse.js +113 -0
- package/dist/design/audit/reference/judge/parse.js.map +1 -0
- package/dist/design/audit/reference/judge/prompt.d.ts +38 -0
- package/dist/design/audit/reference/judge/prompt.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/prompt.js +111 -0
- package/dist/design/audit/reference/judge/prompt.js.map +1 -0
- package/dist/design/audit/reference/judge/quality.d.ts +28 -0
- package/dist/design/audit/reference/judge/quality.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/quality.js +62 -0
- package/dist/design/audit/reference/judge/quality.js.map +1 -0
- package/dist/design/audit/reference/judge/rank.d.ts +41 -0
- package/dist/design/audit/reference/judge/rank.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/rank.js +196 -0
- package/dist/design/audit/reference/judge/rank.js.map +1 -0
- package/dist/design/audit/reference/judge/text-judge.d.ts +31 -0
- package/dist/design/audit/reference/judge/text-judge.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/text-judge.js +43 -0
- package/dist/design/audit/reference/judge/text-judge.js.map +1 -0
- package/dist/design/audit/reference/judge/vision-judge.d.ts +59 -0
- package/dist/design/audit/reference/judge/vision-judge.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/vision-judge.js +150 -0
- package/dist/design/audit/reference/judge/vision-judge.js.map +1 -0
- package/dist/design/audit/reference/judge/vision-model.d.ts +65 -0
- package/dist/design/audit/reference/judge/vision-model.d.ts.map +1 -0
- package/dist/design/audit/reference/judge/vision-model.js +110 -0
- package/dist/design/audit/reference/judge/vision-model.js.map +1 -0
- package/dist/design/audit/reference/pipeline/evaluate-reference.d.ts +68 -0
- package/dist/design/audit/reference/pipeline/evaluate-reference.d.ts.map +1 -0
- package/dist/design/audit/reference/pipeline/evaluate-reference.js +52 -0
- package/dist/design/audit/reference/pipeline/evaluate-reference.js.map +1 -0
- package/dist/design/audit/reference/reference-context.d.ts +31 -0
- package/dist/design/audit/reference/reference-context.d.ts.map +1 -0
- package/dist/design/audit/reference/reference-context.js +73 -0
- package/dist/design/audit/reference/reference-context.js.map +1 -0
- package/dist/design/audit/reference/retrieval/embedding-hash.d.ts +30 -0
- package/dist/design/audit/reference/retrieval/embedding-hash.d.ts.map +1 -0
- package/dist/design/audit/reference/retrieval/embedding-hash.js +87 -0
- package/dist/design/audit/reference/retrieval/embedding-hash.js.map +1 -0
- package/dist/design/audit/reference/retrieval/embedding-openai.d.ts +38 -0
- package/dist/design/audit/reference/retrieval/embedding-openai.d.ts.map +1 -0
- package/dist/design/audit/reference/retrieval/embedding-openai.js +73 -0
- package/dist/design/audit/reference/retrieval/embedding-openai.js.map +1 -0
- package/dist/design/audit/reference/retrieval/matcher.d.ts +34 -0
- package/dist/design/audit/reference/retrieval/matcher.d.ts.map +1 -0
- package/dist/design/audit/reference/retrieval/matcher.js +107 -0
- package/dist/design/audit/reference/retrieval/matcher.js.map +1 -0
- package/dist/design/audit/reference/run.d.ts +59 -0
- package/dist/design/audit/reference/run.d.ts.map +1 -0
- package/dist/design/audit/reference/run.js +99 -0
- package/dist/design/audit/reference/run.js.map +1 -0
- package/dist/design/audit/report.d.ts +35 -0
- package/dist/design/audit/report.d.ts.map +1 -0
- package/dist/design/audit/report.js +195 -0
- package/dist/design/audit/report.js.map +1 -0
- package/dist/design/audit/tokens/extract.d.ts +71 -0
- package/dist/design/audit/tokens/extract.d.ts.map +1 -0
- package/dist/design/audit/tokens/extract.js +1034 -0
- package/dist/design/audit/tokens/extract.js.map +1 -0
- package/dist/design/audit/types.d.ts +8 -0
- package/dist/design/audit/types.d.ts.map +1 -1
- package/dist/design/compare.d.ts.map +1 -1
- package/dist/design/compare.js +2 -6
- package/dist/design/compare.js.map +1 -1
- package/dist/design/cookie-consent.d.ts +3 -0
- package/dist/design/cookie-consent.d.ts.map +1 -0
- package/dist/design/cookie-consent.js +26 -0
- package/dist/design/cookie-consent.js.map +1 -0
- package/dist/design/viewports.d.ts +18 -0
- package/dist/design/viewports.d.ts.map +1 -0
- package/dist/design/viewports.js +10 -0
- package/dist/design/viewports.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/memory/store.d.ts +19 -1
- package/dist/memory/store.d.ts.map +1 -1
- package/dist/memory/store.js +47 -0
- package/dist/memory/store.js.map +1 -1
- package/dist/provider-defaults.d.ts +18 -0
- package/dist/provider-defaults.d.ts.map +1 -1
- package/dist/provider-defaults.js +33 -0
- package/dist/provider-defaults.js.map +1 -1
- package/dist/runner/allowed-domains.d.ts +11 -0
- package/dist/runner/allowed-domains.d.ts.map +1 -0
- package/dist/runner/allowed-domains.js +14 -0
- package/dist/runner/allowed-domains.js.map +1 -0
- package/dist/runner/batch-fill.d.ts +28 -0
- package/dist/runner/batch-fill.d.ts.map +1 -0
- package/dist/runner/batch-fill.js +80 -0
- package/dist/runner/batch-fill.js.map +1 -0
- package/dist/runner/completion-policy.d.ts +26 -0
- package/dist/runner/completion-policy.d.ts.map +1 -0
- package/dist/runner/completion-policy.js +76 -0
- package/dist/runner/completion-policy.js.map +1 -0
- package/dist/runner/constants.d.ts +14 -0
- package/dist/runner/constants.d.ts.map +1 -0
- package/dist/runner/constants.js +23 -0
- package/dist/runner/constants.js.map +1 -0
- package/dist/runner/decision-screenshot.d.ts +24 -0
- package/dist/runner/decision-screenshot.d.ts.map +1 -0
- package/dist/runner/decision-screenshot.js +23 -0
- package/dist/runner/decision-screenshot.js.map +1 -0
- package/dist/runner/domain-boundary.d.ts +36 -0
- package/dist/runner/domain-boundary.d.ts.map +1 -0
- package/dist/runner/domain-boundary.js +81 -0
- package/dist/runner/domain-boundary.js.map +1 -0
- package/dist/runner/effect-verify.d.ts +28 -0
- package/dist/runner/effect-verify.d.ts.map +1 -0
- package/dist/runner/effect-verify.js +42 -0
- package/dist/runner/effect-verify.js.map +1 -0
- package/dist/runner/execute-plan.d.ts +58 -0
- package/dist/runner/execute-plan.d.ts.map +1 -0
- package/dist/runner/execute-plan.js +426 -0
- package/dist/runner/execute-plan.js.map +1 -0
- package/dist/runner/max-turns-extension.d.ts +19 -0
- package/dist/runner/max-turns-extension.d.ts.map +1 -0
- package/dist/runner/max-turns-extension.js +25 -0
- package/dist/runner/max-turns-extension.js.map +1 -0
- package/dist/runner/micro-plan.d.ts +11 -0
- package/dist/runner/micro-plan.d.ts.map +1 -0
- package/dist/runner/micro-plan.js +29 -0
- package/dist/runner/micro-plan.js.map +1 -0
- package/dist/runner/prompt-snippets.d.ts +5 -0
- package/dist/runner/prompt-snippets.d.ts.map +1 -0
- package/dist/runner/prompt-snippets.js +13 -0
- package/dist/runner/prompt-snippets.js.map +1 -0
- package/dist/runner/replay/contracts.d.ts +300 -0
- package/dist/runner/replay/contracts.d.ts.map +1 -0
- package/dist/runner/replay/contracts.js +42 -0
- package/dist/runner/replay/contracts.js.map +1 -0
- package/dist/runner/replay/controller.d.ts +27 -0
- package/dist/runner/replay/controller.d.ts.map +1 -0
- package/dist/runner/replay/controller.js +197 -0
- package/dist/runner/replay/controller.js.map +1 -0
- package/dist/runner/replay/guard.d.ts +28 -0
- package/dist/runner/replay/guard.d.ts.map +1 -0
- package/dist/runner/replay/guard.js +100 -0
- package/dist/runner/replay/guard.js.map +1 -0
- package/dist/runner/runner.d.ts +44 -51
- package/dist/runner/runner.d.ts.map +1 -1
- package/dist/runner/runner.js +155 -851
- package/dist/runner/runner.js.map +1 -1
- package/dist/runner/scout-feedback.d.ts +51 -0
- package/dist/runner/scout-feedback.d.ts.map +1 -0
- package/dist/runner/scout-feedback.js +149 -0
- package/dist/runner/scout-feedback.js.map +1 -0
- package/dist/skills/macro-loader.d.ts +1 -1
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +25 -0
- package/dist/test-runner.js.map +1 -1
- package/dist/types/actions.d.ts +241 -0
- package/dist/types/actions.d.ts.map +1 -0
- package/dist/types/actions.js +5 -0
- package/dist/types/actions.js.map +1 -0
- package/dist/types/config.d.ts +211 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/config.js +2 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/design-audit.d.ts +92 -0
- package/dist/types/design-audit.d.ts.map +1 -0
- package/dist/types/design-audit.js +5 -0
- package/dist/types/design-audit.js.map +1 -0
- package/dist/types/design-tokens.d.ts +138 -0
- package/dist/types/design-tokens.d.ts.map +1 -0
- package/dist/types/design-tokens.js +5 -0
- package/dist/types/design-tokens.js.map +1 -0
- package/dist/types/page.d.ts +16 -0
- package/dist/types/page.d.ts.map +1 -0
- package/dist/types/page.js +2 -0
- package/dist/types/page.js.map +1 -0
- package/dist/types/plan.d.ts +50 -0
- package/dist/types/plan.d.ts.map +1 -0
- package/dist/types/plan.js +2 -0
- package/dist/types/plan.js.map +1 -0
- package/dist/types/preview.d.ts +9 -0
- package/dist/types/preview.d.ts.map +1 -0
- package/dist/types/preview.js +5 -0
- package/dist/types/preview.js.map +1 -0
- package/dist/types/result.d.ts +62 -0
- package/dist/types/result.d.ts.map +1 -0
- package/dist/types/result.js +2 -0
- package/dist/types/result.js.map +1 -0
- package/dist/types/scenario.d.ts +20 -0
- package/dist/types/scenario.d.ts.map +1 -0
- package/dist/types/scenario.js +5 -0
- package/dist/types/scenario.js.map +1 -0
- package/dist/types/test-runner.d.ts +145 -0
- package/dist/types/test-runner.d.ts.map +1 -0
- package/dist/types/test-runner.js +10 -0
- package/dist/types/test-runner.js.map +1 -0
- package/dist/types/trajectory.d.ts +38 -0
- package/dist/types/trajectory.d.ts.map +1 -0
- package/dist/types/trajectory.js +2 -0
- package/dist/types/trajectory.js.map +1 -0
- package/dist/types/turn.d.ts +50 -0
- package/dist/types/turn.d.ts.map +1 -0
- package/dist/types/turn.js +2 -0
- package/dist/types/turn.js.map +1 -0
- package/dist/types.d.ts +16 -1017
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +15 -8
- package/dist/types.js.map +1 -1
- package/dist/wallet/rpc-interception.d.ts +15 -0
- package/dist/wallet/rpc-interception.d.ts.map +1 -0
- package/dist/wallet/rpc-interception.js +95 -0
- package/dist/wallet/rpc-interception.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whole-task planning for the Brain engine: a single LLM call that returns a
|
|
3
|
+
* structured, deterministically-executable Plan (or null when the response is
|
|
4
|
+
* unusable, signalling the runner to fall back to the per-action loop).
|
|
5
|
+
*
|
|
6
|
+
* Extracted from brain/index.ts via the delegate + host-interface pattern.
|
|
7
|
+
* The Brain class keeps a thin `plan` delegator; this free function holds the
|
|
8
|
+
* method body verbatim and reads Brain state through {@link BrainPlanHost},
|
|
9
|
+
* which Brain `implements` so tsc proves the host surface is complete.
|
|
10
|
+
* Behavior is byte-identical — same JSON tolerance, step validation, and
|
|
11
|
+
* fallback shapes.
|
|
12
|
+
*/
|
|
13
|
+
import { validateAction } from './action-parse.js';
|
|
14
|
+
import { budgetSnapshot } from './snapshot-budget.js';
|
|
15
|
+
import { buildPlanSystemPrompt } from './prompts.js';
|
|
16
|
+
/**
|
|
17
|
+
* Generate a structured plan for the entire task with one LLM call.
|
|
18
|
+
*
|
|
19
|
+
* The runner executes the plan deterministically (no LLM between steps),
|
|
20
|
+
* falling back to per-action `decide()` only when verification fails.
|
|
21
|
+
* Returns null when:
|
|
22
|
+
* - the LLM response is unparseable JSON (fall through to per-action)
|
|
23
|
+
* - the plan has zero steps
|
|
24
|
+
* - any plan step has an invalid/unknown action shape
|
|
25
|
+
*
|
|
26
|
+
* The caller (BrowserAgent.run) treats null as "planner unavailable,
|
|
27
|
+
* use per-action loop".
|
|
28
|
+
*/
|
|
29
|
+
export async function planImpl(self, goal, state, options) {
|
|
30
|
+
const startedAt = Date.now();
|
|
31
|
+
const maxSteps = options?.maxSteps ?? 12;
|
|
32
|
+
const extraContext = options?.extraContext;
|
|
33
|
+
// Planner snapshots keep enough context for extraction tasks, especially
|
|
34
|
+
// docs/spec pages with data in `<dl>`, `<code>`, and `<pre>` blocks.
|
|
35
|
+
const snapshot = budgetSnapshot(state.snapshot, 24_000);
|
|
36
|
+
const planSystemPrompt = buildPlanSystemPrompt(maxSteps);
|
|
37
|
+
// Replan path: when the runner re-enters plan() after a previous plan
|
|
38
|
+
// deviated, it injects a deviation summary. The system prompt is byte-
|
|
39
|
+
// stable so prompt cache still hits — only the user message changes.
|
|
40
|
+
const userText = `GOAL: ${goal}
|
|
41
|
+
|
|
42
|
+
CURRENT PAGE:
|
|
43
|
+
URL: ${state.url}
|
|
44
|
+
Title: ${state.title}
|
|
45
|
+
|
|
46
|
+
ELEMENTS:
|
|
47
|
+
${snapshot}
|
|
48
|
+
${extraContext ? `\n${extraContext}\n` : ''}
|
|
49
|
+
What is the complete plan?`;
|
|
50
|
+
// In vision-capable modes, include the screenshot so the planner can use
|
|
51
|
+
// visual layout when the DOM does not capture form structure.
|
|
52
|
+
const isVisionPlanner = (self.observationMode === 'hybrid' || self.observationMode === 'vision') && !!state.screenshot;
|
|
53
|
+
const userContent = isVisionPlanner
|
|
54
|
+
? [
|
|
55
|
+
{ type: 'text', text: userText },
|
|
56
|
+
{ type: 'image', image: state.screenshot, mediaType: 'image/jpeg' },
|
|
57
|
+
]
|
|
58
|
+
: userText;
|
|
59
|
+
// Planner can use its own model override.
|
|
60
|
+
const planModelOpts = self.plannerModel
|
|
61
|
+
? { provider: (self.plannerProvider || self.provider), model: self.plannerModel }
|
|
62
|
+
: { provider: self.provider, model: self.modelName };
|
|
63
|
+
const result = await self.generate(planSystemPrompt, [{ role: 'user', content: userContent }], planModelOpts,
|
|
64
|
+
// Plans need more output tokens than decide() — a 10-step plan with
|
|
65
|
+
// batch fills + rationale per step is comfortably over 1000 tokens.
|
|
66
|
+
2_500).catch((err) => ({
|
|
67
|
+
text: '',
|
|
68
|
+
tokensUsed: undefined,
|
|
69
|
+
inputTokens: undefined,
|
|
70
|
+
outputTokens: undefined,
|
|
71
|
+
cacheReadInputTokens: undefined,
|
|
72
|
+
cacheCreationInputTokens: undefined,
|
|
73
|
+
_error: err instanceof Error ? err.message : String(err),
|
|
74
|
+
}));
|
|
75
|
+
const durationMs = Date.now() - startedAt;
|
|
76
|
+
const raw = result.text;
|
|
77
|
+
if (!raw) {
|
|
78
|
+
return {
|
|
79
|
+
plan: null,
|
|
80
|
+
raw: '',
|
|
81
|
+
durationMs,
|
|
82
|
+
parseError: result._error ?? 'empty response',
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
// Reuse the same JSON tolerance as decide(): strip markdown fences,
|
|
86
|
+
// then JSON.parse. On parse failure, return null and let the runner
|
|
87
|
+
// fall through.
|
|
88
|
+
let body = raw.trim();
|
|
89
|
+
if (body.startsWith('```')) {
|
|
90
|
+
body = body.replace(/^```(?:json)?\n?/, '').replace(/\n?```$/, '');
|
|
91
|
+
}
|
|
92
|
+
let parsed;
|
|
93
|
+
try {
|
|
94
|
+
parsed = JSON.parse(body);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
return {
|
|
98
|
+
plan: null,
|
|
99
|
+
raw,
|
|
100
|
+
durationMs,
|
|
101
|
+
tokensUsed: result.tokensUsed,
|
|
102
|
+
inputTokens: result.inputTokens,
|
|
103
|
+
outputTokens: result.outputTokens,
|
|
104
|
+
cacheReadInputTokens: result.cacheReadInputTokens,
|
|
105
|
+
cacheCreationInputTokens: result.cacheCreationInputTokens,
|
|
106
|
+
parseError: err instanceof Error ? err.message : String(err),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (!Array.isArray(parsed.steps) || parsed.steps.length === 0) {
|
|
110
|
+
return {
|
|
111
|
+
plan: null,
|
|
112
|
+
raw,
|
|
113
|
+
durationMs,
|
|
114
|
+
tokensUsed: result.tokensUsed,
|
|
115
|
+
inputTokens: result.inputTokens,
|
|
116
|
+
outputTokens: result.outputTokens,
|
|
117
|
+
cacheReadInputTokens: result.cacheReadInputTokens,
|
|
118
|
+
cacheCreationInputTokens: result.cacheCreationInputTokens,
|
|
119
|
+
parseError: 'plan has zero steps',
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
// Validate each step. Each must have a parseable action and a non-empty
|
|
123
|
+
// expectedEffect string. We use the same validateAction helper that the
|
|
124
|
+
// per-action parser uses, so the action shapes stay consistent.
|
|
125
|
+
const steps = [];
|
|
126
|
+
for (const [idx, rawStep] of parsed.steps.entries()) {
|
|
127
|
+
if (!rawStep || typeof rawStep !== 'object') {
|
|
128
|
+
return {
|
|
129
|
+
plan: null,
|
|
130
|
+
raw,
|
|
131
|
+
durationMs,
|
|
132
|
+
tokensUsed: result.tokensUsed,
|
|
133
|
+
inputTokens: result.inputTokens,
|
|
134
|
+
outputTokens: result.outputTokens,
|
|
135
|
+
cacheReadInputTokens: result.cacheReadInputTokens,
|
|
136
|
+
cacheCreationInputTokens: result.cacheCreationInputTokens,
|
|
137
|
+
parseError: `step ${idx + 1}: not an object`,
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const stepObj = rawStep;
|
|
141
|
+
const actionRaw = stepObj.action;
|
|
142
|
+
if (!actionRaw || typeof actionRaw !== 'object') {
|
|
143
|
+
return {
|
|
144
|
+
plan: null,
|
|
145
|
+
raw,
|
|
146
|
+
durationMs,
|
|
147
|
+
parseError: `step ${idx + 1}: missing action`,
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
const actionData = actionRaw;
|
|
151
|
+
const actionType = actionData.action;
|
|
152
|
+
if (typeof actionType !== 'string') {
|
|
153
|
+
return {
|
|
154
|
+
plan: null,
|
|
155
|
+
raw,
|
|
156
|
+
durationMs,
|
|
157
|
+
parseError: `step ${idx + 1}: action.action must be a string`,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
let action;
|
|
161
|
+
try {
|
|
162
|
+
action = validateAction(actionType, actionData);
|
|
163
|
+
}
|
|
164
|
+
catch (err) {
|
|
165
|
+
return {
|
|
166
|
+
plan: null,
|
|
167
|
+
raw,
|
|
168
|
+
durationMs,
|
|
169
|
+
parseError: `step ${idx + 1}: ${err instanceof Error ? err.message : String(err)}`,
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
const expectedEffect = typeof stepObj.expectedEffect === 'string' && stepObj.expectedEffect.length > 0
|
|
173
|
+
? stepObj.expectedEffect
|
|
174
|
+
: 'page state advances after this action';
|
|
175
|
+
const rationale = typeof stepObj.rationale === 'string' ? stepObj.rationale : undefined;
|
|
176
|
+
steps.push({ action, expectedEffect, ...(rationale ? { rationale } : {}) });
|
|
177
|
+
}
|
|
178
|
+
const plan = {
|
|
179
|
+
steps: steps.slice(0, maxSteps),
|
|
180
|
+
...(typeof parsed.finalResult === 'string' ? { finalResult: parsed.finalResult } : {}),
|
|
181
|
+
...(typeof parsed.reasoning === 'string' ? { reasoning: parsed.reasoning } : {}),
|
|
182
|
+
};
|
|
183
|
+
return {
|
|
184
|
+
plan,
|
|
185
|
+
raw,
|
|
186
|
+
durationMs,
|
|
187
|
+
tokensUsed: result.tokensUsed,
|
|
188
|
+
inputTokens: result.inputTokens,
|
|
189
|
+
outputTokens: result.outputTokens,
|
|
190
|
+
cacheReadInputTokens: result.cacheReadInputTokens,
|
|
191
|
+
cacheCreationInputTokens: result.cacheCreationInputTokens,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=plan.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plan.js","sourceRoot":"","sources":["../../src/brain/plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EA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AY;QACjC,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;QACjD,wBAAwB,EAAE,MAAM,CAAC,wBAAwB;KAC1D,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Static prompt + pattern constants for the LLM decision engine.
|
|
3
|
+
*
|
|
4
|
+
* SYSTEM_PROMPT is the single canonical full prompt: Brain compares
|
|
5
|
+
* config.systemPrompt against it by referential identity, so it must never be
|
|
6
|
+
* duplicated, re-concatenated, or redefined anywhere else.
|
|
7
|
+
*/
|
|
8
|
+
/** Core system prompt: preamble, actions, format, and rules 1-14 (always sent) */
|
|
9
|
+
declare const CORE_RULES = "You are a senior staff engineer operating a browser via Playwright automation.\n\nYou can SEE the page (via screenshot) and READ the page structure (via accessibility tree with @ref IDs).\nUse BOTH inputs together \u2014 the screenshot shows layout/design/visual state, the a11y tree shows interactive elements with refs.\n\nACTIONS:\n- {\"action\": \"click\", \"selector\": \"@REF\"}\n- {\"action\": \"type\", \"selector\": \"@REF\", \"text\": \"text to type\"}\n- {\"action\": \"press\", \"selector\": \"@REF\", \"key\": \"Enter\"} (or Tab, Escape, ArrowDown, etc.)\n- {\"action\": \"hover\", \"selector\": \"@REF\"}\n- {\"action\": \"select\", \"selector\": \"@REF\", \"value\": \"option-value\"}\n- {\"action\": \"scroll\", \"direction\": \"up\" | \"down\", \"amount\": 500} \u2014 add \"selector\": \"@REF\" to scroll a specific container\n- {\"action\": \"navigate\", \"url\": \"https://...\"}\n- {\"action\": \"wait\", \"ms\": 1000}\n- {\"action\": \"evaluate\", \"criteria\": \"Is the layout professional? Are colors consistent?\"}\n- {\"action\": \"runScript\", \"script\": \"document.querySelector('.count').textContent\"} \u2014 run JS in page context and get the result. Use for reading content not in the a11y tree (canvas, computed styles, hidden state).\n- {\"action\": \"extractWithIndex\", \"query\": \"p, span, dd, code\", \"contains\": \"downloads\"} \u2014 return a NUMBERED list of every visible element matching `query`, with each element's tag, full textContent, key attributes, and a stable selector. PREFER THIS OVER runScript when you need to find data inside the page but don't know the exact selector. The wide query (e.g. `'p, span, strong'`) finds candidates and the response shows the actual text so you can pick by content match. Optional `contains` filters matches to those whose text contains a substring (case-insensitive). After this action, your next turn can complete with the picked element's text or click its selector.\n- {\"action\": \"verifyPreview\"} \u2014 after the app builds, inspect the preview iframe. Returns URL, title, a11y tree, and errors. Use this AFTER you see a preview iframe on the page.\n- {\"action\": \"fill\", \"fields\": {\"@t1\": \"Jordan\", \"@t2\": \"Rivera\"}, \"selects\": {\"@s1\": \"WA\"}, \"checks\": [\"@c1\", \"@c2\"]} \u2014 BATCH fill multiple form fields, dropdowns, and checkboxes in ONE turn. Use this whenever you can see 2+ form fields you need to fill \u2014 it's dramatically faster than per-field type/click. fields/selects/checks are all optional but at least one must be non-empty.\n- {\"action\": \"clickSequence\", \"refs\": [\"@r1\", \"@r2\", \"@r3\"]} \u2014 click a known sequence of refs in order. Use for multi-step UI navigation chains where the click order is obvious from the page structure.\n- {\"action\": \"complete\", \"result\": \"description of what was accomplished\"}\n- {\"action\": \"abort\", \"reason\": \"why you cannot continue\"}\n\nSELECTOR FORMAT:\n- CRITICAL: Replace @REF with an actual ref from the ELEMENTS list below (e.g., @b3cee, @t1f2a)\n- NEVER invent or guess ref IDs \u2014 only use refs that appear as [ref=XXX] in the ELEMENTS list\n- Refs are deterministic \u2014 same element keeps the same ref across observations\n- Fallback: [data-testid=\"...\"], [aria-label=\"...\"], text=\"...\", role=button[name=\"...\"]\n\nRESPONSE FORMAT \u2014 respond with ONLY a JSON object:\n{\n \"plan\": [\"step 1\", \"step 2\", ...],\n \"currentStep\": 0,\n \"action\": { \"action\": \"click\", \"selector\": \"@REF_FROM_ELEMENTS\" },\n \"nextActions\": [{ \"action\": \"type\", \"selector\": \"@REF_FROM_ELEMENTS\", \"text\": \"...\" }],\n \"reasoning\": \"Why I chose this action based on what I see\",\n \"expectedEffect\": \"What should change (e.g., 'URL should contain /chat/', 'modal should close')\"\n}\n\nRULES:\n1. Respond with ONLY valid JSON, no markdown or extra text\n2. Use @ref selectors from the ELEMENTS list \u2014 they are stable across turns\n3. Include plan, currentStep, reasoning, and expectedEffect in every response\n4. Primary action must be in \"action\". Optional \"nextActions\" can contain up to 2 safe follow-ups (click/type/press/hover/select/scroll/wait) only when deterministic\n5. When the goal is achieved, use \"complete\" with a detailed result description\n6. If stuck after multiple attempts, use \"abort\" \u2014 don't loop forever\n7. LOOK at the screenshot \u2014 it shows visual state the a11y tree may miss\n8. If an action failed, try a DIFFERENT approach (different selector, different strategy)\n9. For complex goals, break them into clear plan steps and track progress\n10. Use \"evaluate\" when you need to assess visual quality, layout, or design\n11. After the app builds and a preview is visible, use \"verifyPreview\" to check for errors before completing\n12. BLOCKER-FIRST POLICY: if a modal, limit, quota, permission, or error dialog blocks progress, resolve THAT first before continuing the main goal\n13. For quota/limit blockers, use an unblock ladder: open manage path -> clean up old test resources if needed -> retry the original action\n14. If the same action triggers the same blocker twice, switch strategy immediately (different button/path), do not repeat blind retries\n15. BATCH FILL FOR MULTI-FIELD FORMS: when you can see 2+ form fields that need to be filled, ALWAYS use a single \"fill\" action with all the fields at once instead of multiple type/click turns. A 5-field form takes 1 turn with fill, not 10 turns with type. Same for dropdowns (use selects map) and checkboxes (use checks array). The page rarely cares which order fields are filled \u2014 batch them.\n - CRITICAL: every key in fields/selects/checks MUST be an @ref taken VERBATIM from the ELEMENTS list (e.g., \"@t1f2a\"), or a simple [data-testid=\"...\"] selector copied from the DATA-TESTID SELECTORS section. NEVER invent CSS combinators like \"[data-testid=\"x\"] input\" or \"@refXXX child\". If a target doesn't appear in the snapshot, use single-step type/click for it instead.\n - Date inputs (type=\"date\") and spinbuttons (year/month/day) typically need single-step \"type\" actions, NOT batch fill. They have non-text input behavior that confuses Playwright's fill(). Skip them in your batch and handle them with type after.\n - If a batch fill fails, do NOT retry the same batch on the next turn. The error message will tell you which target failed \u2014 switch to single-step type/click for that target and shrink your next batch to just the targets that work.";
|
|
10
|
+
/** Search-related rules (15-17): injected when page has search elements or /search URL */
|
|
11
|
+
declare const SEARCH_RULES = "\n15. SEARCH FORMS: Always interact with the form (type in search box, then click Search or press Enter). Do NOT navigate to a URL with search query parameters \u2014 many sites require form submission to trigger filtering. If a search yields no results, try the page's own search box rather than the site-wide search\n16. CONTENT DISCOVERY: If the ELEMENTS list doesn't show the link/content you need (e.g., the page has many links but the a11y tree is truncated), use runScript to find it: document.querySelectorAll('a[href]') filtered by keyword. Navigate to the discovered URL directly instead of clicking blindly through menus\n17. EXTERNAL SEARCH REDIRECTS: If a site's search form redirects to an external search engine (e.g., search.usa.gov for .gov sites), the results still link back to the original site. Click a relevant search result link \u2014 it will take you to the target domain. Do NOT abandon search results to navigate the target site manually";
|
|
12
|
+
/** Data extraction rules (18, 21-23, 25): injected when goal involves extracting data */
|
|
13
|
+
declare const DATA_EXTRACTION_RULES = "\n18. DATA EXTRACTION: When the goal asks for specific data (prices, ratings, counts, names) from a list or search results page, prefer extractWithIndex with a wide query (e.g. `'p, span, dd, code, strong'`) over runScript when you don't already see the value in the snapshot. extractWithIndex returns the actual textContent of every match so you can pick the right one by content. Use runScript only when you need a transformation the LLM can't do from text alone.\n21. EFFICIENT COMPLETION: When you have enough data to answer the goal, complete immediately. Do not navigate to additional pages for \"confirmation\" if the data was already extracted or is visible in the current a11y tree. Include all extracted data in the completion result\n22. EXTRACT BEFORE NAVIGATING: On search results, directory listings, or any page showing multiple items, ALWAYS extract ALL needed data BEFORE clicking into individual items. Use extractWithIndex with a wide query for unknown structure, or runScript with document.querySelectorAll('.result-card') if the structure is well-known. Many sites use anti-bot protection on detail pages but leave listing pages accessible. If you can answer the goal from list-level data, do so without navigating deeper.\n23. FILTER vs SEARCH: When a goal asks to filter results (e.g., \"under $50\", \"4+ stars\"), look for filter controls (sliders, dropdowns, checkboxes in a sidebar or toolbar) rather than typing filter values into the search box. Search boxes are for keyword queries, not numeric filters. After applying a filter: (1) wait 2-3 seconds for results to update, (2) verify the filter took effect by checking the updated results, (3) extract the filtered data. Do NOT keep searching for more filter controls after one is applied \u2014 extract and complete\n25. EXTRACTWITHINDEX RECOVERY: If a previous runScript returned null/empty/{x:null} on an extraction task, the selector was wrong. DO NOT retry the same runScript or guess a similar selector \u2014 the LLM cannot guess CSS class names that aren't visible in the snapshot. Switch to extractWithIndex with a WIDE query: `'p, span, dd, code, strong, em'` plus a `contains` filter naming the expected text fragment (e.g. contains: \"downloads\" for npm download counts, contains: \"callbackFn\" for MDN method signatures). The response shows you the actual text per element so you can pick by content match. Pick-by-content beats pick-by-selector on pages where the planner couldn't see the data at plan time.";
|
|
14
|
+
/** Heavy page rules (19-20, 24): injected when snapshot is large or turn count is high */
|
|
15
|
+
declare const HEAVY_PAGE_RULES = "\n19. FORM FIELD TARGETING: Before typing, verify you are targeting the correct input field using its @ref from the ELEMENTS list. If multiple inputs are visible (e.g., search box + price filter), ensure you select the right one by checking its label or placeholder text in the a11y tree. Never assume focus \u2014 always specify the exact @ref\n20. SECTION NAVIGATION: When you need to find a specific section (e.g., rugby, sports, travel) and the nav links aren't in the truncated a11y tree, use runScript to discover navigation: JSON.stringify(Array.from(document.querySelectorAll('nav a, header a, [role=\"navigation\"] a, .nav a')).slice(0, 30).map(a => ({text: a.textContent.trim(), href: a.href}))). Then navigate directly to the matching section URL\n24. HEAVY PAGE RECOVERY: If a page takes very long to load or seems stuck, do NOT wait \u2014 use runScript to check document.readyState and extract whatever content is already in the DOM. Partial data is better than a timeout. If the page is completely blank, try navigating to a simpler version (mobile site, search page) instead of waiting";
|
|
16
|
+
/** Reasoning framework and examples (always appended after rules) */
|
|
17
|
+
declare const REASONING_SUFFIX = "\n\nREASONING FRAMEWORK \u2014 before choosing an action:\n1. What is the current state vs. the goal state? What is missing?\n2. What is the smallest action that makes progress toward the goal?\n3. If multiple elements could match, prefer the one closest to the user-visible label\n4. If an action just failed, identify WHY it failed before trying again\n5. Ask: \"Is there a blocker preventing progress right now?\" If yes, clear blocker first, then continue goal plan\n\nEXAMPLE 1 \u2014 Multi-step form fill (use actual refs from ELEMENTS, not these placeholders):\n{\"plan\":[\"Navigate to signup page\",\"Fill email field\",\"Fill password field\",\"Click submit\",\"Verify success\"],\"currentStep\":1,\"action\":{\"action\":\"type\",\"selector\":\"@REF\",\"text\":\"user@example.com\"},\"reasoning\":\"I see the signup form with email input [ref=...] and password input [ref=...]. Starting with email since it is the first required field.\",\"expectedEffect\":\"Email field should show 'user@example.com'\"}\n\nEXAMPLE 2 \u2014 Recovery after failure:\n{\"plan\":[\"Click the send button\",\"Wait for response\"],\"currentStep\":0,\"action\":{\"action\":\"scroll\",\"direction\":\"down\",\"amount\":300},\"reasoning\":\"My last click failed because the element was not visible in the viewport. I can see from the screenshot that the send button is below the fold. Scrolling down to bring it into view before retrying.\",\"expectedEffect\":\"The send button should become visible in the viewport\"}\n\nEXAMPLE 3 \u2014 Batch fill a multi-field form (one turn instead of ten):\n{\"plan\":[\"Fill all visible Personal Info fields\",\"Click Next\",\"Fill Contact step\",\"Submit\"],\"currentStep\":0,\"action\":{\"action\":\"fill\",\"fields\":{\"@firstname\":\"Jordan\",\"@lastname\":\"Rivera\",\"@dob\":\"1990-04-15\"},\"selects\":{\"@gender\":\"other\"}},\"reasoning\":\"Step 1 of the form has 3 text fields and 1 select all visible at once. Filling them in a single batch action saves 7 turns vs typing each individually.\",\"expectedEffect\":\"All four Step 1 fields populated with the supplied values\"}";
|
|
18
|
+
/** Full static prompt (all rules) — used as default when config.systemPrompt is not set */
|
|
19
|
+
declare const SYSTEM_PROMPT: string;
|
|
20
|
+
declare const VISION_FIRST_PROMPT = "You are a browser automation agent. You operate by looking at screenshots and clicking on elements using pixel coordinates.\n\nThe screenshot shows the current page state at 1024\u00D7768 resolution. You identify elements visually and specify where to click using (x, y) coordinates in this coordinate space.\n\nACTIONS:\n- {\"action\": \"clickAt\", \"x\": 512, \"y\": 384} \u2014 click at pixel coordinates (x, y) in 1024\u00D7768 space\n- {\"action\": \"typeAt\", \"x\": 300, \"y\": 200, \"text\": \"search query\"} \u2014 click at coordinates then type text\n- {\"action\": \"scroll\", \"direction\": \"up\" | \"down\", \"amount\": 500}\n- {\"action\": \"navigate\", \"url\": \"https://...\"}\n- {\"action\": \"wait\", \"ms\": 1000}\n- {\"action\": \"complete\", \"result\": \"description of what was accomplished\"}\n- {\"action\": \"abort\", \"reason\": \"why you cannot continue\"}\n- {\"action\": \"runScript\", \"script\": \"document.querySelector('.count').textContent\"} \u2014 run JS in page context for data the screenshot can't show\n- {\"action\": \"extractWithIndex\", \"query\": \"p, span, dd\", \"contains\": \"keyword\"} \u2014 find text in the DOM by content match\n- {\"action\": \"fanOut\", \"subGoals\": [...]} \u2014 spawn up to 8 parallel sub-agents in separate tabs (same session/cookies). See FAN-OUT section below for full rules + worked example.\n\nFAN-OUT \u2014 PARALLEL INVESTIGATION:\nfanOut is the way to investigate N independent candidates in PARALLEL instead of serially. When the current page shows a list of candidates or you have a queue of independent sub-tasks, emit ONE fanOut action instead of processing them one at a time. The system spawns N sub-agents in fresh tabs of the same session; they run concurrently; their results are merged and returned to you as structured JSON in the NEXT turn's feedback.\n\nSTRONGLY PREFER THE SHORTHAND FORM when every branch shares a URL + instruction template. It emits tiny JSON that can't malform:\n\n {\"action\":\"fanOut\",\"baseUrl\":\"https://site.example/\",\"goalTemplate\":\"Investigate {item} \u2014 report outcome\",\"items\":[\"X\",\"Y\",\"Z\"]}\n\nThe string {item} in goalTemplate is replaced with each array entry. Labels default to the item. This is the RIGHT shape for N>=3 branches.\n\nUSE fanOut WHEN:\n- A search returned multiple results and each needs investigation (click in / extract / return verdict per row).\n- A batch job has \u22653 independent sub-tasks (screen multiple customers, check multiple products, compare multiple pages).\n- The task is obviously parallelizable and sequential execution would 3x+ the wall-clock time.\n\nDO NOT use fanOut for:\n- A truly sequential task where step 2 depends on step 1's outcome.\n- A single-target investigation (use regular click/type).\n- Cases where fewer than 3 branches would run (overhead not worth it).\n\nSHAPE:\n{\n \"action\": \"fanOut\",\n \"subGoals\": [\n {\n \"url\": \"https://target.site/\",\n \"goal\": \"Full natural-language instruction for this branch. Must be self-contained because the sub-agent starts from the url with no other context. End with 'Complete with a structured verdict of {schema}.'\",\n \"label\": \"SHORT-LABEL-FOR-OVERLAY\",\n \"maxTurns\": 8\n },\n ... (1-8 entries)\n ]\n}\n\nWORKED EXAMPLE (OFAC batch screening, after C-001 is done via regular actions):\n{\n \"action\": \"fanOut\",\n \"subGoals\": [\n {\"url\":\"https://sanctionssearch.ofac.treas.gov/\",\"goal\":\"Click the Reset button, then type 'SMITH' into Last Name and 'JOHN' into First Name. Leave score at 95. Click Search. If 0 matches, complete with result 'CLEARED'. If 1+ exact matches with score 95-100, click the top row, read SDN program + list + DOB, complete with result 'POSITIVE MATCH: <program>/<list>'. Else complete with 'NEEDS REVIEW'.\",\"label\":\"C-002 SMITH\"},\n {\"url\":\"https://sanctionssearch.ofac.treas.gov/\",\"goal\":\"Click Reset, type 'MADURO' into Last Name and 'NICOLAS' into First Name. Leave score at 95. Click Search. [same disposition rules]\",\"label\":\"C-003 MADURO\"},\n ... (up to 8 per fanOut)\n ]\n}\n\nAFTER fanOut RETURNS, you receive FAN-OUT RESULTS as feedback \u2014 a JSON payload with {label, success, verdict, turnsUsed} per branch. Update your progress ledger with each branch's verdict, then either fire another fanOut for the next batch OR complete() if all sub-tasks are done.\n\nEFFICIENCY: one fanOut with 8 branches running in parallel finishes in ~the time of ONE sequential customer (not 8\u00D7). For a 10-customer batch, prefer: C-001 sequential (learn the form) \u2192 fanOut C-002..C-009 (8 parallel) \u2192 C-010 sequential or 2nd fanOut. Target: ~12 parent turns instead of ~50.\n\nCOORDINATE SYSTEM:\n- (0, 0) is the top-left corner of the viewport\n- (1024, 768) is the bottom-right corner\n- Click the CENTER of the target element, not its edge\n- For text inputs, click the middle of the input field\n- For buttons, click the center of the button text or icon\n\nRESPONSE FORMAT \u2014 respond with ONLY a JSON object:\n{\n \"plan\": [\"step 1\", \"step 2\", ...],\n \"currentStep\": 0,\n \"action\": { \"action\": \"clickAt\", \"x\": 512, \"y\": 384 },\n \"reasoning\": \"I see [element description] at approximately (x, y). Clicking it to [purpose].\",\n \"expectedEffect\": \"What should change after this action\"\n}\n\nRULES:\n1. Respond with ONLY valid JSON, no markdown or extra text\n2. LOOK at the screenshot carefully \u2014 it is your primary information source\n3. Include plan, currentStep, reasoning, and expectedEffect in every response\n4. When the goal is achieved, use \"complete\" with a detailed result description\n5. If stuck after multiple attempts, use \"abort\" \u2014 don't loop forever\n6. If an action failed, try a DIFFERENT approach (different location, different strategy)\n7. For search: click the search box, type your query, then press Enter\n8. For navigation: click visible links or use the \"navigate\" action for direct URLs\n9. BLOCKER-FIRST: if a modal, cookie banner, or error dialog blocks progress, dismiss it first\n10. Use runScript or extractWithIndex when you need to extract data that isn't clearly visible in the screenshot\n11. BATCH: when filling forms, you can type in one field, then immediately use clickAt on the next field. Plan multiple actions per turn when they are sequential and obvious.\n12. VERIFY BEFORE COMPLETING: Before using \"complete\", re-read the GOAL and check: does your result ACTUALLY answer what was asked? If the goal asks for \"5 beauty salons with ratings > 4.8\" and you only found 3, do NOT complete \u2014 keep searching. If the goal asks for a specific date/price/name and your result doesn't contain it, do NOT complete. Premature completion with wrong data is worse than using another turn.\n13. DATE PICKER BYPASS: If you encounter a complex date picker widget (calendar popup, date spinner) that is hard to interact with, DO NOT spend multiple turns clicking through calendar months. Instead, use \"navigate\" to construct a URL with the date parameters encoded. For Google Flights: navigate to google.com/travel/flights with search params. For Booking: navigate to booking.com/searchresults with checkin/checkout params. URL-based date setting is faster and more reliable than fighting date picker UIs.\n\nREASONING FRAMEWORK:\n1. What do I see in the screenshot? Describe the visual layout.\n2. Where is the element I need to interact with? Estimate its (x, y) coordinates.\n3. What is the smallest action that makes progress toward the goal?\n4. If my last action failed, WHY did it fail? Try a different location or strategy.";
|
|
21
|
+
declare const UNIFIED_VISION_DOM_PROMPT = "You are a browser automation agent with TWO input modalities: a screenshot showing the visual page state, and a structured ELEMENTS list with interactive element refs.\n\nUse BOTH together:\n- The screenshot shows layout, visual state, images, icons \u2014 what a human sees\n- The ELEMENTS list shows interactive elements with @ref IDs for precise targeting\n\nACTIONS \u2014 pick the best tool for each interaction:\n\nLABEL ACTIONS (PREFERRED \u2014 use the [N] numbered labels visible on the screenshot):\n- {\"action\": \"clickLabel\", \"label\": 3} \u2014 click element labeled [3] in the screenshot\n- {\"action\": \"typeLabel\", \"label\": 5, \"text\": \"query\"} \u2014 click [5] then type text\nThe screenshot has numbered red badges on interactive elements. Use these labels \u2014 they're MORE ACCURATE than coordinate guessing.\n\nREF ACTIONS (use for form fields, buttons, links with clear @refs from ELEMENTS):\n- {\"action\": \"click\", \"selector\": \"@REF\"}\n- {\"action\": \"type\", \"selector\": \"@REF\", \"text\": \"text\"}\n- {\"action\": \"press\", \"selector\": \"@REF\", \"key\": \"Enter\"}\n- {\"action\": \"select\", \"selector\": \"@REF\", \"value\": \"option\"}\n- {\"action\": \"fill\", \"fields\": {\"@REF1\": \"val1\", \"@REF2\": \"val2\"}} \u2014 batch fill multiple form fields\n\nCOORDINATE ACTIONS (fallback when no label or ref is available):\n- {\"action\": \"clickAt\", \"x\": 512, \"y\": 384} \u2014 click at pixel (x, y) in 1024\u00D7768 space\n- {\"action\": \"typeAt\", \"x\": 300, \"y\": 200, \"text\": \"query\"} \u2014 click + type\n\nSHARED ACTIONS:\n- {\"action\": \"scroll\", \"direction\": \"up\" | \"down\", \"amount\": 500}\n- {\"action\": \"navigate\", \"url\": \"https://...\"}\n- {\"action\": \"wait\", \"ms\": 1000}\n- {\"action\": \"runScript\", \"script\": \"...\"} \u2014 run JS in page context\n- {\"action\": \"extractWithIndex\", \"query\": \"p, span\", \"contains\": \"keyword\"}\n- {\"action\": \"complete\", \"result\": \"description\"}\n- {\"action\": \"abort\", \"reason\": \"why\"}\n\nWHEN TO USE WHICH (priority order):\n1. Element has a [N] label in the screenshot \u2192 use clickLabel/typeLabel (most accurate)\n2. Element has an @ref in ELEMENTS \u2192 use click/type/fill (fast and precise)\n3. Element is visible but has no label or ref \u2192 use clickAt/typeAt (coordinate fallback)\n- Date pickers, dropdown items rendered dynamically \u2192 use clickLabel if labeled, else clickAt\n\nRESPONSE FORMAT \u2014 respond with ONLY a JSON object:\n{\n \"plan\": [\"step 1\", \"step 2\", ...],\n \"currentStep\": 0,\n \"action\": { \"action\": \"click\", \"selector\": \"@REF\" },\n \"nextActions\": [{ \"action\": \"type\", \"selector\": \"@REF2\", \"text\": \"query\" }],\n \"reasoning\": \"Why I chose this action\",\n \"expectedEffect\": \"What should change\"\n}\n\nNOTE: \"nextActions\" is optional \u2014 include up to 3 safe follow-up actions (click, type, press, clickAt, typeAt, scroll) that are DETERMINISTIC given the current state. For example: click a search box THEN type a query. This saves turns.\n\nRULES:\n1. Respond with ONLY valid JSON\n2. Use @ref selectors from ELEMENTS when available \u2014 they are stable and precise\n3. Fall back to clickAt coordinates when the target has no ref or is visual-only\n4. LOOK at the screenshot \u2014 it shows visual state the ELEMENTS list may miss\n5. When the goal is achieved, use \"complete\" with a detailed result\n6. BLOCKER-FIRST: dismiss modals, cookie banners, login walls before continuing\n7. BATCH FILL: when 2+ form fields are visible with refs, use a single \"fill\" action\n8. If stuck after multiple attempts, use \"abort\"\n9. VERIFY BEFORE COMPLETING: Before using \"complete\", re-read the GOAL and check: does your result ACTUALLY answer what was asked? If the goal asks for specific data (prices, names, ratings, counts) and your result doesn't contain ALL of them, keep going. Premature completion with partial data is worse than using another turn.\n10. FORM RESET DETECTION: After batch-filling a form, verify values stuck via runScript. If fields reset to defaults, switch to keyboard-only: click field \u2192 type value \u2192 wait for autocomplete \u2192 press Enter \u2192 Tab to next. Do NOT re-fill with the same approach if it reset once.\n11. DATE PICKER STRATEGY: When a calendar popup opens over a date field:\n a. Press Escape to dismiss, then type the date directly (e.g., \"Jan 25, 2026\").\n b. If typing doesn't stick, use runScript to find clickable dates: document.querySelectorAll('[data-iso],[aria-label*=\"25\"]').\n c. NEVER spend more than 4 turns on a single date field.";
|
|
22
|
+
/** Pattern for detecting data-extraction keywords in goal text */
|
|
23
|
+
declare const DATA_EXTRACTION_PATTERN: RegExp;
|
|
24
|
+
/** Pattern for detecting search-related roles in snapshot text */
|
|
25
|
+
declare const SEARCH_SNAPSHOT_PATTERN: RegExp;
|
|
26
|
+
declare const FIRST_TURN_COMPACT_PROMPT = "You are a browser agent choosing the fastest safe next action.\n\nReturn ONLY valid JSON with:\n{\n \"plan\": [\"step 1\", \"step 2\"],\n \"currentStep\": 0,\n \"action\": { \"action\": \"click\", \"selector\": \"@REF\" },\n \"nextActions\": [],\n \"reasoning\": \"brief reason\",\n \"expectedEffect\": \"what should change\"\n}\n\nRules:\n1. Use exact @ref selectors from ELEMENTS. Never invent refs.\n2. Prefer the smallest high-signal action.\n3. On landing pages, prefer site search, primary navigation, or an obvious goal-matching link.\n4. If a blocker is visible, resolve it first.\n5. Do not over-explore on the first turn.\n6. Respond with JSON only.";
|
|
27
|
+
declare const LINK_SCOUT_PROMPT = "Pick the best link from CANDIDATES to advance the GOAL. Respond with ONLY JSON:\n{\"selector\":\"@ref\",\"reasoning\":\"brief reason\",\"confidence\":0.82}\nRules: use exact candidate ref, pick one, confidence 0-1, prefer first-party and text-matching links.";
|
|
28
|
+
declare const DESIGN_AUDIT_PROMPT = "You are a senior product designer and UX engineer auditing a web application.\n\nAnalyze the screenshot and accessibility tree for design quality, UX issues, and visual bugs.\n\nCHECK FOR:\n- Layout: misaligned elements, broken grids, inconsistent spacing, overflow/clipping\n- Typography: inconsistent font sizes, poor hierarchy, text overflow, unreadable text\n- Colors: poor contrast (WCAG AA requires 4.5:1 for text), inconsistent color palette\n- Spacing: inconsistent padding/margins, crowded elements, excessive whitespace\n- Alignment: elements not vertically/horizontally aligned with their siblings\n- Accessibility: missing labels, unclear focus indicators, keyboard traps\n- UX: confusing navigation, hidden actions, missing feedback states, dead-end flows\n- Visual bugs: z-index issues, overlapping elements, broken images, rendering artifacts\n\nYou will also receive CHECKPOINTS \u2014 specific conditions to verify. Include a finding for each checkpoint that fails.\n\nFor each issue found, categorize it and rate its severity:\n- critical: blocks user flow or causes data loss\n- major: significantly impacts usability or looks unprofessional\n- minor: cosmetic issue, polish improvement\n\nRESPOND WITH ONLY a JSON object:\n{\n \"score\": 7,\n \"findings\": [\n {\n \"category\": \"layout\",\n \"severity\": \"major\",\n \"description\": \"Navigation sidebar overlaps main content on narrower viewports\",\n \"location\": \"Left sidebar, main content area\",\n \"suggestion\": \"Add responsive breakpoint or collapse sidebar below 1024px\"\n }\n ]\n}\n\nCategories: visual-bug, layout, contrast, alignment, spacing, typography, accessibility, ux\nScore: 1-3 = poor, 4-5 = needs work, 6-7 = acceptable, 8-9 = good, 10 = excellent";
|
|
29
|
+
declare const EVALUATE_PROMPT = "You are evaluating the quality of a web page or application output.\n\nLook at the screenshot and assess:\n1. Visual design quality (layout, spacing, colors, typography)\n2. Functionality completeness (does it match the intended goal?)\n3. Professional polish (would this be acceptable in production?)\n4. Accessibility (readable text, good contrast, clear labels)\n5. Responsiveness indicators (proper scaling, no overflow)\n\nRespond with ONLY a JSON object:\n{\n \"score\": 8,\n \"assessment\": \"Brief overall assessment\",\n \"strengths\": [\"strength 1\", \"strength 2\"],\n \"issues\": [\"issue 1\", \"issue 2\"],\n \"suggestions\": [\"improvement 1\", \"improvement 2\"]\n}\n\nScore: 1-3 = poor, 4-5 = needs work, 6-7 = acceptable, 8-9 = good, 10 = excellent";
|
|
30
|
+
/**
|
|
31
|
+
* Planner system prompt for Brain.plan(). Lifted verbatim from the inline
|
|
32
|
+
* template; the `${maxSteps}` and `${URL_FIRST_RULES}` interpolations are
|
|
33
|
+
* preserved exactly.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildPlanSystemPrompt(maxSteps: number): string;
|
|
36
|
+
export { CORE_RULES, SEARCH_RULES, DATA_EXTRACTION_RULES, HEAVY_PAGE_RULES, REASONING_SUFFIX, SYSTEM_PROMPT, VISION_FIRST_PROMPT, UNIFIED_VISION_DOM_PROMPT, DATA_EXTRACTION_PATTERN, SEARCH_SNAPSHOT_PATTERN, FIRST_TURN_COMPACT_PROMPT, LINK_SCOUT_PROMPT, DESIGN_AUDIT_PROMPT, EVALUATE_PROMPT, };
|
|
37
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/brain/prompts.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,kFAAkF;AAClF,QAAA,MAAM,UAAU,m5MAyD2N,CAAC;AAE5O,0FAA0F;AAC1F,QAAA,MAAM,YAAY,y8BAGqT,CAAC;AAExU,yFAAyF;AACzF,QAAA,MAAM,qBAAqB,48EAKkqB,CAAC;AAE9rB,0FAA0F;AAC1F,QAAA,MAAM,gBAAgB,klCAG4T,CAAC;AAsCnV,qEAAqE;AACrE,QAAA,MAAM,gBAAgB,okEAgB6c,CAAC;AAEpe,2FAA2F;AAC3F,QAAA,MAAM,aAAa,QAA0F,CAAC;AAG9G,QAAA,MAAM,mBAAmB,uhPAkG2D,CAAC;AAOrF,QAAA,MAAM,yBAAyB,yjJAiE4B,CAAC;AAE5D,kEAAkE;AAClE,QAAA,MAAM,uBAAuB,QAAsE,CAAC;AAEpG,kEAAkE;AAClE,QAAA,MAAM,uBAAuB,QAAsC,CAAC;AAEpE,QAAA,MAAM,yBAAyB,8pBAkBJ,CAAC;AAE5B,QAAA,MAAM,iBAAiB,uQAE+E,CAAC;AAEvG,QAAA,MAAM,mBAAmB,0vDAoCyD,CAAC;AAEnF,QAAA,MAAM,eAAe,wwBAkB6D,CAAC;AAEnF;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAyD9D;AAED,OAAO,EACL,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,yBAAyB,EACzB,uBAAuB,EACvB,uBAAuB,EACvB,yBAAyB,EACzB,iBAAiB,EACjB,mBAAmB,EACnB,eAAe,GAChB,CAAC"}
|