@bastani/atomic 0.8.26-alpha.6 → 0.8.26-alpha.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +29 -0
- package/README.md +5 -5
- package/dist/builtin/intercom/CHANGELOG.md +12 -0
- package/dist/builtin/intercom/package.json +2 -2
- package/dist/builtin/mcp/CHANGELOG.md +12 -0
- package/dist/builtin/mcp/package.json +3 -3
- package/dist/builtin/subagents/CHANGELOG.md +12 -0
- package/dist/builtin/subagents/agents/codebase-online-researcher.md +9 -9
- package/dist/builtin/subagents/agents/debugger.md +6 -6
- package/dist/builtin/subagents/package.json +4 -4
- package/dist/builtin/subagents/prompts/parallel-handoff-plan.md +1 -1
- package/dist/builtin/subagents/skills/browser/EXAMPLES.md +151 -0
- package/dist/builtin/subagents/skills/browser/LICENSE.txt +21 -0
- package/dist/builtin/subagents/skills/browser/REFERENCE.md +451 -0
- package/dist/builtin/subagents/skills/browser/SKILL.md +170 -0
- package/dist/builtin/subagents/skills/subagent/SKILL.md +4 -4
- package/dist/builtin/web-access/CHANGELOG.md +12 -0
- package/dist/builtin/web-access/package.json +2 -2
- package/dist/builtin/workflows/CHANGELOG.md +17 -0
- package/dist/builtin/workflows/builtin/deep-research-codebase.ts +4 -1
- package/dist/builtin/workflows/builtin/goal.ts +127 -99
- package/dist/builtin/workflows/builtin/open-claude-design.ts +224 -147
- package/dist/builtin/workflows/builtin/ralph.ts +160 -197
- package/dist/builtin/workflows/package.json +2 -2
- package/dist/builtin/workflows/skills/research-codebase/SKILL.md +1 -1
- package/dist/builtin/workflows/src/extension/wiring.ts +13 -1
- package/dist/builtin/workflows/src/runs/foreground/executor.ts +12 -6
- package/dist/builtin/workflows/src/runs/foreground/stage-runner.ts +2 -2
- package/dist/builtin/workflows/src/shared/authoring-contract.d.ts +2 -2
- package/dist/builtin/workflows/src/shared/types.ts +3 -3
- package/dist/builtin/workflows/src/tui/stage-chat-view.ts +2 -1
- package/dist/core/agent-session.d.ts +33 -6
- package/dist/core/agent-session.d.ts.map +1 -1
- package/dist/core/agent-session.js +155 -182
- package/dist/core/agent-session.js.map +1 -1
- package/dist/core/atomic-guide-command.d.ts.map +1 -1
- package/dist/core/atomic-guide-command.js +1 -1
- package/dist/core/atomic-guide-command.js.map +1 -1
- package/dist/core/compaction/branch-summarization.d.ts +1 -1
- package/dist/core/compaction/branch-summarization.d.ts.map +1 -1
- package/dist/core/compaction/branch-summarization.js +6 -3
- package/dist/core/compaction/branch-summarization.js.map +1 -1
- package/dist/core/compaction/compaction.d.ts.map +1 -1
- package/dist/core/compaction/compaction.js +23 -10
- package/dist/core/compaction/compaction.js.map +1 -1
- package/dist/core/compaction/context-compaction.d.ts +61 -0
- package/dist/core/compaction/context-compaction.d.ts.map +1 -0
- package/dist/core/compaction/context-compaction.js +602 -0
- package/dist/core/compaction/context-compaction.js.map +1 -0
- package/dist/core/compaction/index.d.ts +1 -0
- package/dist/core/compaction/index.d.ts.map +1 -1
- package/dist/core/compaction/index.js +1 -0
- package/dist/core/compaction/index.js.map +1 -1
- package/dist/core/extensions/types.d.ts +3 -2
- package/dist/core/extensions/types.d.ts.map +1 -1
- package/dist/core/extensions/types.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/session-manager.d.ts +41 -1
- package/dist/core/session-manager.d.ts.map +1 -1
- package/dist/core/session-manager.js +146 -7
- package/dist/core/session-manager.js.map +1 -1
- package/dist/core/slash-commands.d.ts.map +1 -1
- package/dist/core/slash-commands.js +1 -1
- package/dist/core/slash-commands.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/modes/index.d.ts +1 -1
- package/dist/modes/index.d.ts.map +1 -1
- package/dist/modes/index.js.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.d.ts.map +1 -1
- package/dist/modes/interactive/components/chat-session-host.js +17 -0
- package/dist/modes/interactive/components/chat-session-host.js.map +1 -1
- package/dist/modes/interactive/components/context-compaction-summary-message.d.ts +17 -0
- package/dist/modes/interactive/components/context-compaction-summary-message.d.ts.map +1 -0
- package/dist/modes/interactive/components/context-compaction-summary-message.js +83 -0
- package/dist/modes/interactive/components/context-compaction-summary-message.js.map +1 -0
- package/dist/modes/interactive/components/index.d.ts +1 -0
- package/dist/modes/interactive/components/index.d.ts.map +1 -1
- package/dist/modes/interactive/components/index.js +1 -0
- package/dist/modes/interactive/components/index.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts +1 -0
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +72 -8
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-client.d.ts +13 -8
- package/dist/modes/rpc/rpc-client.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-client.js +8 -1
- package/dist/modes/rpc/rpc-client.js.map +1 -1
- package/dist/modes/rpc/rpc-mode.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-mode.js +4 -0
- package/dist/modes/rpc/rpc-mode.js.map +1 -1
- package/dist/modes/rpc/rpc-types.d.ts +14 -3
- package/dist/modes/rpc/rpc-types.d.ts.map +1 -1
- package/dist/modes/rpc/rpc-types.js.map +1 -1
- package/docs/compaction.md +89 -37
- package/docs/custom-provider.md +11 -9
- package/docs/extensions.md +44 -40
- package/docs/index.md +2 -9
- package/docs/json.md +15 -12
- package/docs/packages.md +2 -0
- package/docs/providers.md +4 -1
- package/docs/quickstart.md +5 -12
- package/docs/rpc.md +38 -23
- package/docs/sdk.md +3 -10
- package/docs/session-format.md +26 -13
- package/docs/sessions.md +3 -3
- package/docs/settings.md +2 -2
- package/docs/skills.md +1 -15
- package/docs/termux.md +9 -10
- package/docs/themes.md +2 -2
- package/docs/tmux.md +3 -3
- package/docs/tui.md +19 -32
- package/docs/usage.md +2 -2
- package/docs/workflows.md +44 -2
- package/package.json +4 -12
- package/dist/builtin/subagents/skills/browser-use/SKILL.md +0 -234
- package/dist/builtin/subagents/skills/browser-use/references/cdp-python.md +0 -76
- package/dist/builtin/subagents/skills/browser-use/references/multi-session.md +0 -92
- package/node_modules/@earendil-works/pi-tui/README.md +0 -779
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts +0 -54
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js +0 -632
- package/node_modules/@earendil-works/pi-tui/dist/autocomplete.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts +0 -22
- package/node_modules/@earendil-works/pi-tui/dist/components/box.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/box.js +0 -104
- package/node_modules/@earendil-works/pi-tui/dist/components/box.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts +0 -22
- package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js +0 -35
- package/node_modules/@earendil-works/pi-tui/dist/components/cancellable-loader.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts +0 -249
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js +0 -1857
- package/node_modules/@earendil-works/pi-tui/dist/components/editor.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts +0 -28
- package/node_modules/@earendil-works/pi-tui/dist/components/image.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js +0 -89
- package/node_modules/@earendil-works/pi-tui/dist/components/image.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts +0 -37
- package/node_modules/@earendil-works/pi-tui/dist/components/input.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/input.js +0 -378
- package/node_modules/@earendil-works/pi-tui/dist/components/input.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts +0 -31
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.js +0 -69
- package/node_modules/@earendil-works/pi-tui/dist/components/loader.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts +0 -96
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js +0 -644
- package/node_modules/@earendil-works/pi-tui/dist/components/markdown.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts +0 -50
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js +0 -159
- package/node_modules/@earendil-works/pi-tui/dist/components/select-list.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts +0 -50
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js +0 -185
- package/node_modules/@earendil-works/pi-tui/dist/components/settings-list.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts +0 -12
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js +0 -23
- package/node_modules/@earendil-works/pi-tui/dist/components/spacer.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts +0 -19
- package/node_modules/@earendil-works/pi-tui/dist/components/text.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/text.js +0 -89
- package/node_modules/@earendil-works/pi-tui/dist/components/text.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts +0 -13
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js +0 -51
- package/node_modules/@earendil-works/pi-tui/dist/components/truncated-text.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts +0 -39
- package/node_modules/@earendil-works/pi-tui/dist/editor-component.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/editor-component.js +0 -2
- package/node_modules/@earendil-works/pi-tui/dist/editor-component.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts +0 -16
- package/node_modules/@earendil-works/pi-tui/dist/fuzzy.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js +0 -110
- package/node_modules/@earendil-works/pi-tui/dist/fuzzy.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts +0 -23
- package/node_modules/@earendil-works/pi-tui/dist/index.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/index.js +0 -32
- package/node_modules/@earendil-works/pi-tui/dist/index.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts +0 -193
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js +0 -174
- package/node_modules/@earendil-works/pi-tui/dist/keybindings.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts +0 -184
- package/node_modules/@earendil-works/pi-tui/dist/keys.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/keys.js +0 -1173
- package/node_modules/@earendil-works/pi-tui/dist/keys.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts +0 -28
- package/node_modules/@earendil-works/pi-tui/dist/kill-ring.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js +0 -44
- package/node_modules/@earendil-works/pi-tui/dist/kill-ring.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts +0 -3
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js +0 -53
- package/node_modules/@earendil-works/pi-tui/dist/native-modifiers.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts +0 -50
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js +0 -361
- package/node_modules/@earendil-works/pi-tui/dist/stdin-buffer.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts +0 -90
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js +0 -366
- package/node_modules/@earendil-works/pi-tui/dist/terminal-image.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts +0 -113
- package/node_modules/@earendil-works/pi-tui/dist/terminal.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js +0 -472
- package/node_modules/@earendil-works/pi-tui/dist/terminal.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts +0 -227
- package/node_modules/@earendil-works/pi-tui/dist/tui.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/tui.js +0 -1106
- package/node_modules/@earendil-works/pi-tui/dist/tui.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts +0 -17
- package/node_modules/@earendil-works/pi-tui/dist/undo-stack.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js +0 -25
- package/node_modules/@earendil-works/pi-tui/dist/undo-stack.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts +0 -84
- package/node_modules/@earendil-works/pi-tui/dist/utils.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/utils.js +0 -1029
- package/node_modules/@earendil-works/pi-tui/dist/utils.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts +0 -25
- package/node_modules/@earendil-works/pi-tui/dist/word-navigation.d.ts.map +0 -1
- package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js +0 -96
- package/node_modules/@earendil-works/pi-tui/dist/word-navigation.js.map +0 -1
- package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-arm64/darwin-modifiers.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/darwin/prebuilds/darwin-x64/darwin-modifiers.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-arm64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/pi-tui/native/win32/prebuilds/win32-x64/win32-console-mode.node +0 -0
- package/node_modules/@earendil-works/pi-tui/package.json +0 -47
- package/node_modules/get-east-asian-width/index.d.ts +0 -60
- package/node_modules/get-east-asian-width/index.js +0 -30
- package/node_modules/get-east-asian-width/license +0 -9
- package/node_modules/get-east-asian-width/lookup-data.js +0 -21
- package/node_modules/get-east-asian-width/lookup.js +0 -138
- package/node_modules/get-east-asian-width/package.json +0 -71
- package/node_modules/get-east-asian-width/readme.md +0 -65
- package/node_modules/get-east-asian-width/utilities.js +0 -24
- package/node_modules/marked/LICENSE.md +0 -44
- package/node_modules/marked/README.md +0 -106
- package/node_modules/marked/bin/main.js +0 -282
- package/node_modules/marked/bin/marked.js +0 -15
- package/node_modules/marked/lib/marked.cjs +0 -2211
- package/node_modules/marked/lib/marked.cjs.map +0 -7
- package/node_modules/marked/lib/marked.d.cts +0 -728
- package/node_modules/marked/lib/marked.d.ts +0 -728
- package/node_modules/marked/lib/marked.esm.js +0 -2189
- package/node_modules/marked/lib/marked.esm.js.map +0 -7
- package/node_modules/marked/lib/marked.umd.js +0 -2213
- package/node_modules/marked/lib/marked.umd.js.map +0 -7
- package/node_modules/marked/man/marked.1 +0 -111
- package/node_modules/marked/man/marked.1.md +0 -92
- package/node_modules/marked/marked.min.js +0 -69
- package/node_modules/marked/package.json +0 -111
package/docs/workflows.md
CHANGED
|
@@ -154,7 +154,7 @@ For the builtin result tables below, `deep-research-codebase`, `goal`, and `ralp
|
|
|
154
154
|
| `deep-research-codebase` | Scout + research-history chain → parallel specialist waves → aggregator. Indexes the whole repo and synthesizes findings. | Broad or cross-cutting research before you decide what to change. Prefer `/skill:research-codebase` for one subsystem. |
|
|
155
155
|
| `goal` | Persisted goal ledger → bounded worker turns → receipts → three-reviewer gate → deterministic reducer → final report. | Small-to-medium scope changes when you can identify the work surface, state the exact outcome, and name the validation that proves it is done — for example tests, lint/typecheck, docs builds, or observable behavior. |
|
|
156
156
|
| `ralph` | RFC planning → sub-agent orchestration → simplification → parallel review → optional final-stage PR handoff. | Larger migrations, broad refactors, multi-package changes, and spec-to-reviewed-change work where you want Atomic to plan the approach, delegate implementation through sub-agents, simplify, review, iterate, and optionally allow only the final `pull-request` stage to attempt PR creation with `create_pr=true`. |
|
|
157
|
-
| `open-claude-design` | Design-system onboarding → reference import → HTML generation → impeccable-driven refinement → quality gate → rich HTML handoff. Renders a live `preview.html` you can iterate against (opens through `browser
|
|
157
|
+
| `open-claude-design` | Design-system onboarding → reference import → HTML generation → impeccable-driven refinement → quality gate → rich HTML handoff. Renders a live `preview.html` you can iterate against (opens through `browser` when available). | UI, page, component, theme, or design-token work that benefits from generation + critique loops. |
|
|
158
158
|
|
|
159
159
|
### `deep-research-codebase`
|
|
160
160
|
|
|
@@ -1020,6 +1020,25 @@ Builder basics:
|
|
|
1020
1020
|
|
|
1021
1021
|
Author workflows to create at least one tracked stage by calling `ctx.task()`, `ctx.chain()`, `ctx.parallel()`, `ctx.stage()`, or `ctx.workflow()` in the run body so each run has graph nodes to inspect, attach to, interrupt, resume, and render.
|
|
1022
1022
|
|
|
1023
|
+
### Guiding Principles
|
|
1024
|
+
|
|
1025
|
+
- Stage prompts should be locally scoped: describe only the current stage's objective, inputs, expected outputs, and success criteria.
|
|
1026
|
+
- Avoid references to other stages unless the current stage explicitly receives and needs that information.
|
|
1027
|
+
- Avoid workflow-specific or stage-specific vocabulary that is not explained inside the current prompt.
|
|
1028
|
+
- Use clear software engineering terminology in self-described prompts.
|
|
1029
|
+
- Avoid hard-coded regular expressions for condition matching when gating reviews or model outputs.
|
|
1030
|
+
- Prefer structured output schemas for review/gate decisions whenever model output needs to be evaluated.
|
|
1031
|
+
- Treat atomic workflow units as language model stages, not deterministic tools.
|
|
1032
|
+
- When deterministic gates are needed, create small dedicated stages that instruct a model to run a specific tool or perform a specific check. This keeps gates adaptive to the current codebase while preserving explicit workflow structure.
|
|
1033
|
+
|
|
1034
|
+
### Context engineering guidance
|
|
1035
|
+
|
|
1036
|
+
Workflow guidance should also cover the context passed between stages:
|
|
1037
|
+
|
|
1038
|
+
- Prefer creating files or artifacts for substantial handoffs, then instruct the next stage to read the file, instead of dumping large text output directly into the next stage prompt or context.
|
|
1039
|
+
- Prefer forked context for non-reviewer stages so long-running implementation work can preserve coherency and continuity.
|
|
1040
|
+
- Prefer a clean context window for reviewer stages so earlier implementation stages do not bias the reviewer. Reviewers should evaluate the supplied artifacts, changed files, tests, and explicit criteria as independently as possible.
|
|
1041
|
+
|
|
1023
1042
|
### Inputs
|
|
1024
1043
|
|
|
1025
1044
|
Inputs are declared with TypeBox `Type.*` schemas passed to `.input(key, schema)`. `Type` is re-exported from `@bastani/workflows` (along with the `Static` and `TSchema` type helpers), so you do not import from `typebox` directly in workflow files. Workflow packages still declare `typebox` as a peer dependency so the SDK's shipped types resolve under `tsc` — see [Programmatic Usage](#programmatic-usage). Common input schemas map to picker kinds and accepted runtime values:
|
|
@@ -1480,6 +1499,20 @@ registry.get("alpha");
|
|
|
1480
1499
|
|
|
1481
1500
|
A workflow is an information-flow system, not just a list of prompts. Most workflow failures come from missing, stale, oversized, or poorly-routed context. Design every stage boundary deliberately.
|
|
1482
1501
|
|
|
1502
|
+
### Locally Scoped Stage Prompts
|
|
1503
|
+
|
|
1504
|
+
Stage prompts should be local contracts, not miniature descriptions of the entire workflow runtime. Write prompts as if the stage could be executed independently from a fresh session with only the listed inputs. Include:
|
|
1505
|
+
|
|
1506
|
+
- the stage's current objective and what is out of scope for this stage
|
|
1507
|
+
- the exact files, artifacts, child outputs, or user inputs it may use
|
|
1508
|
+
- the expected output format or structured-output tool/schema it must return
|
|
1509
|
+
- the checks, tools, or deterministic commands it should run when relevant
|
|
1510
|
+
- the success criteria that let this stage stop
|
|
1511
|
+
|
|
1512
|
+
Avoid unrelated workflow internals such as reducer algorithms, future PR stages, sibling reviewer names, loop implementation details, or project-specific nicknames unless they are explicitly part of the current stage contract. If a term such as a gate name, ledger field, or workflow nickname is necessary, define it in the prompt before using it.
|
|
1513
|
+
|
|
1514
|
+
Choose context mode deliberately. Use `context: "fork"` or `forkFromSessionFile` for coherent long-running implementation stages that need continuity from their own earlier work. Use `context: "fresh"` for unbiased reviewer, evaluator, and gate stages so they inspect the current files and explicit artifacts rather than inheriting the implementer's assumptions. When continuity is needed across fresh stages, pass it explicitly through files, declared outputs, and `reads`.
|
|
1515
|
+
|
|
1483
1516
|
### Context Fundamentals
|
|
1484
1517
|
|
|
1485
1518
|
Treat context as a finite attention budget. Include only information needed for the current decision, place critical constraints near the beginning or end of prompts, and use progressive disclosure instead of loading every possible reference up front.
|
|
@@ -1523,6 +1556,8 @@ A good compressed handoff includes:
|
|
|
1523
1556
|
|
|
1524
1557
|
Use `output`, `outputMode: "file-only"`, `reads`, and `chainDir` for large research bundles, logs, or reviewer outputs. Keep summaries compact and let downstream stages read full artifacts only when needed. In the downstream stage prompt, explicitly say something like `Read the file at ${artifactPath} before continuing.` Do not inject full session tails, all previous stage outputs, or every prior review round into later prompts by default; pass the latest relevant artifact paths and make older history discoverable from a ledger or index file.
|
|
1525
1558
|
|
|
1559
|
+
Substantial handoffs should travel through files or durable artifacts instead of hidden transcript assumptions. This keeps stage prompts small, makes review/audit possible, and lets later stages reread the authoritative material without depending on what a previous model happened to summarize.
|
|
1560
|
+
|
|
1526
1561
|
```ts
|
|
1527
1562
|
const researchPath = ".atomic/workflows/runs/context-demo/research.md";
|
|
1528
1563
|
await ctx.task("researcher", {
|
|
@@ -1586,6 +1621,10 @@ Build validation into the workflow instead of waiting for a final manual check.
|
|
|
1586
1621
|
- reviewer stages: fresh-context reviewers that inspect artifacts and current files
|
|
1587
1622
|
- LLM-as-judge stages: direct scoring, pairwise comparison, or rubric-based grading for subjective outputs
|
|
1588
1623
|
|
|
1624
|
+
Prefer structured output schemas or structured-output tools for model review and gate decisions. Do not make correctness depend on brittle regular-expression matching against free-form prose such as “looks good”, “approved”, or “PASS”. A schema with explicit booleans/enums, findings arrays, confidence, evidence fields, and error reporting is easier to validate, replay, and safely default to “not approved” when malformed.
|
|
1625
|
+
|
|
1626
|
+
Use small dedicated model stages for adaptive gates when deterministic code alone cannot decide what to check. For example, a stage can read an artifact, inspect the repo, run a named tool or command, and then emit a structured decision. Keep that stage's prompt narrow: tell it the specific check to perform, the files/tools it may use, and the structured decision it must return.
|
|
1627
|
+
|
|
1589
1628
|
When using LLM judges, mitigate bias by defining score anchors, asking for evidence, calibrating against examples, and keeping length/order effects in mind. Track pass rates and failures over time for reusable workflows.
|
|
1590
1629
|
|
|
1591
1630
|
### Tools, MCP, Memory, and Hosted Execution
|
|
@@ -1618,12 +1657,13 @@ Before implementing or shipping a non-trivial workflow, answer these questions:
|
|
|
1618
1657
|
- **Inputs:** Which values should be declared as inputs? What is the narrowest schema type? Which defaults are safe?
|
|
1619
1658
|
- **Starter pattern:** Which [workflow starter pattern](#workflow-starter-patterns) best matches the task, and where does the actual design intentionally diverge?
|
|
1620
1659
|
- **Stage decomposition:** For each stage, what question does it answer, what context does it need, what output should it return, and what model/tool/MCP requirements does it have?
|
|
1660
|
+
- **Local stage contract:** Can this stage prompt stand alone with its current objective, inputs/artifacts, expected outputs, tools/checks, and success criteria, without unexplained workflow internals or future-stage assumptions?
|
|
1621
1661
|
- **Information flow:** For every edge between stages, is `previous` enough, or should the handoff use structured returns, files, `reads`, `output`, or `outputMode`?
|
|
1622
1662
|
- **Output contract:** Which outputs should be declared with `.output(...)`, which stage/task/child results should `.run()` return for those keys, and what runtime type must each value have? If another workflow may call this workflow as a child, which non-default outputs should the parent rely on?
|
|
1623
1663
|
- **Context size:** Can downstream stages succeed from the handoff alone? Should large transcripts, logs, or research bundles be summarized or saved as artifacts?
|
|
1624
1664
|
- **Control flow:** Should the workflow use `ctx.chain`, `ctx.parallel`, `ctx.ui`, bounded loops, `failFast`, or `fallbackModels`?
|
|
1625
1665
|
- **User experience:** Are stage names readable in status and graph views? Is the final output compact? Are important artifacts saved with stable paths?
|
|
1626
|
-
- **Validation:** What success criteria, review gates, deterministic checks, or evaluator stages prove the workflow did the right thing?
|
|
1666
|
+
- **Validation:** What success criteria, review gates, deterministic checks, or evaluator stages prove the workflow did the right thing? Are model gates schema-backed instead of regex/prose-matched, and do adaptive gates run as focused model stages with explicit tool/check instructions?
|
|
1627
1667
|
|
|
1628
1668
|
Good workflows are information-flow systems, not just prompt sequences. Keep stage prompts focused, preserve evidence with file paths or artifacts, and pass only the context each downstream stage needs.
|
|
1629
1669
|
|
|
@@ -1639,4 +1679,6 @@ Good workflows are information-flow systems, not just prompt sequences. Keep sta
|
|
|
1639
1679
|
- Do not expect named workflow runs to block the chat turn; they are background tasks.
|
|
1640
1680
|
- Do not call `kill` when the user asks to interrupt or pause resumably.
|
|
1641
1681
|
- Keep stage names readable because they appear in workflow status and UI.
|
|
1682
|
+
- Do not write stage prompts that depend on hidden workflow-wide awareness; make each model stage locally scoped and self-described.
|
|
1683
|
+
- Do not parse model gate decisions from ad-hoc prose with regular expressions; use structured output schemas/tools or a focused checking stage that returns a structured decision.
|
|
1642
1684
|
- Return compact structured output and save large artifacts to files.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bastani/atomic",
|
|
3
|
-
"version": "0.8.26-alpha.
|
|
3
|
+
"version": "0.8.26-alpha.8",
|
|
4
4
|
"description": "Atomic coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"atomicConfig": {
|
|
@@ -63,16 +63,13 @@
|
|
|
63
63
|
"copy-builtin-workflows": "bun run copy-builtin-packages",
|
|
64
64
|
"docs:check": "bun run scripts/validate-docs-links.ts",
|
|
65
65
|
"verify:workflow-types": "bun run scripts/verify-workflow-sdk-types.ts",
|
|
66
|
-
"verify:bundled-pi-tui": "bun run scripts/verify-bundled-pi-tui-install.ts",
|
|
67
66
|
"test": "vitest --run",
|
|
68
|
-
"prepack": "bun run scripts/materialize-bundled-pi-tui.ts",
|
|
69
|
-
"postpack": "bun run scripts/materialize-bundled-pi-tui.ts --clean",
|
|
70
67
|
"prepublishOnly": "bun run clean && bun run build"
|
|
71
68
|
},
|
|
72
69
|
"dependencies": {
|
|
73
|
-
"@earendil-works/pi-agent-core": "^0.78.
|
|
74
|
-
"@earendil-works/pi-ai": "^0.78.
|
|
75
|
-
"@earendil-works/pi-tui": "^0.78.
|
|
70
|
+
"@earendil-works/pi-agent-core": "^0.78.1",
|
|
71
|
+
"@earendil-works/pi-ai": "^0.78.1",
|
|
72
|
+
"@earendil-works/pi-tui": "^0.78.1",
|
|
76
73
|
"@modelcontextprotocol/ext-apps": "^1.7.2",
|
|
77
74
|
"@modelcontextprotocol/sdk": "^1.25.1",
|
|
78
75
|
"@mozilla/readability": "^0.6.0",
|
|
@@ -97,11 +94,6 @@
|
|
|
97
94
|
"yaml": "^2.9.0",
|
|
98
95
|
"zod": "^3.25.0 || ^4.0.0"
|
|
99
96
|
},
|
|
100
|
-
"bundleDependencies": [
|
|
101
|
-
"@earendil-works/pi-tui",
|
|
102
|
-
"get-east-asian-width",
|
|
103
|
-
"marked"
|
|
104
|
-
],
|
|
105
97
|
"overrides": {
|
|
106
98
|
"rimraf": "6.1.2",
|
|
107
99
|
"gaxios": {
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: browser-use
|
|
3
|
-
description: Automates browser interactions for web testing, form filling, screenshots, and data extraction. Use when the user needs to navigate websites, interact with web pages, fill forms, take screenshots, or extract information from web pages.
|
|
4
|
-
allowed-tools: Bash(browser-use:*)
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
# Browser Automation with browser-use CLI
|
|
8
|
-
|
|
9
|
-
The `browser-use` command provides fast, persistent browser automation. A background daemon keeps the browser open across commands, giving ~50ms latency per call.
|
|
10
|
-
|
|
11
|
-
## Prerequisites
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
browser-use doctor # Verify installation
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
For setup details, see https://github.com/browser-use/browser-use/blob/main/browser_use/skill_cli/README.md
|
|
18
|
-
|
|
19
|
-
## Core Workflow
|
|
20
|
-
|
|
21
|
-
1. **Navigate**: `browser-use open <url>` — launches headless browser and opens page
|
|
22
|
-
2. **Inspect**: `browser-use state` — returns clickable elements with indices
|
|
23
|
-
3. **Interact**: use indices from state (`browser-use click 5`, `browser-use input 3 "text"`)
|
|
24
|
-
4. **Verify**: `browser-use state` or `browser-use screenshot` to confirm
|
|
25
|
-
5. **Repeat**: browser stays open between commands
|
|
26
|
-
|
|
27
|
-
If a command fails, run `browser-use close` first to clear any broken session, then retry.
|
|
28
|
-
|
|
29
|
-
To use the user's existing Chrome (preserves logins/cookies): run `browser-use connect` first.
|
|
30
|
-
To use a cloud browser instead: run `browser-use cloud connect` first.
|
|
31
|
-
After either, commands work the same way.
|
|
32
|
-
|
|
33
|
-
### If `browser-use connect` fails
|
|
34
|
-
|
|
35
|
-
When `browser-use connect` cannot find a running Chrome with remote debugging, prompt the user with two options:
|
|
36
|
-
|
|
37
|
-
1. **Use their real Chrome browser** — they need to enable remote debugging first:
|
|
38
|
-
- Open `chrome://inspect/#remote-debugging` in Chrome, or relaunch Chrome with `--remote-debugging-port=9222`
|
|
39
|
-
- Then retry `browser-use connect`
|
|
40
|
-
2. **Use managed Chromium with their Chrome profile** — no Chrome setup needed:
|
|
41
|
-
- Run `browser-use profile list` to show available profiles
|
|
42
|
-
- Ask which profile they want, then use `browser-use --profile "ProfileName" open <url>`
|
|
43
|
-
- This launches a separate Chromium instance with their profile data (cookies, logins, extensions)
|
|
44
|
-
|
|
45
|
-
Let the user choose — don't assume one path over the other.
|
|
46
|
-
|
|
47
|
-
## Browser Modes
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
browser-use open <url> # Default: headless Chromium (no setup needed)
|
|
51
|
-
browser-use --headed open <url> # Visible window (for debugging)
|
|
52
|
-
browser-use connect # Connect to user's Chrome (preserves logins/cookies)
|
|
53
|
-
browser-use cloud connect # Cloud browser (zero-config, requires API key)
|
|
54
|
-
browser-use --profile "Default" open <url> # Real Chrome with specific profile
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
After `connect` or `cloud connect`, all subsequent commands go to that browser — no extra flags needed.
|
|
58
|
-
|
|
59
|
-
## Commands
|
|
60
|
-
|
|
61
|
-
```bash
|
|
62
|
-
# Navigation
|
|
63
|
-
browser-use open <url> # Navigate to URL
|
|
64
|
-
browser-use back # Go back in history
|
|
65
|
-
browser-use scroll down # Scroll down (--amount N for pixels)
|
|
66
|
-
browser-use scroll up # Scroll up
|
|
67
|
-
browser-use tab list # List all tabs
|
|
68
|
-
browser-use tab new [url] # Open a new tab (blank or with URL)
|
|
69
|
-
browser-use tab switch <index> # Switch to tab by index
|
|
70
|
-
browser-use tab close <index> [index...] # Close one or more tabs
|
|
71
|
-
|
|
72
|
-
# Page State — always run state first to get element indices
|
|
73
|
-
browser-use state # URL, title, clickable elements with indices
|
|
74
|
-
browser-use screenshot [path.png] # Screenshot (base64 if no path, --full for full page)
|
|
75
|
-
|
|
76
|
-
# Interactions — use indices from state
|
|
77
|
-
browser-use click <index> # Click element by index
|
|
78
|
-
browser-use click <x> <y> # Click at pixel coordinates
|
|
79
|
-
browser-use type "text" # Type into focused element
|
|
80
|
-
browser-use input <index> "text" # Click element, clear existing text, then type
|
|
81
|
-
browser-use input <index> "" # Clear a field without typing new text
|
|
82
|
-
browser-use keys "Enter" # Send keyboard keys (also "Control+a", etc.)
|
|
83
|
-
browser-use select <index> "option" # Select dropdown option
|
|
84
|
-
browser-use upload <index> <path> # Upload file to file input
|
|
85
|
-
browser-use hover <index> # Hover over element
|
|
86
|
-
browser-use dblclick <index> # Double-click element
|
|
87
|
-
browser-use rightclick <index> # Right-click element
|
|
88
|
-
|
|
89
|
-
# Data Extraction
|
|
90
|
-
browser-use eval "js code" # Execute JavaScript, return result
|
|
91
|
-
browser-use get title # Page title
|
|
92
|
-
browser-use get html [--selector "h1"] # Page HTML (or scoped to selector)
|
|
93
|
-
browser-use get text <index> # Element text content
|
|
94
|
-
browser-use get value <index> # Input/textarea value
|
|
95
|
-
browser-use get attributes <index> # Element attributes
|
|
96
|
-
browser-use get bbox <index> # Bounding box (x, y, width, height)
|
|
97
|
-
|
|
98
|
-
# Wait
|
|
99
|
-
browser-use wait selector "css" # Wait for element (--state visible|hidden|attached|detached, --timeout ms)
|
|
100
|
-
browser-use wait text "text" # Wait for text to appear
|
|
101
|
-
|
|
102
|
-
# Cookies
|
|
103
|
-
browser-use cookies get [--url <url>] # Get cookies (optionally filtered)
|
|
104
|
-
browser-use cookies set <name> <value> # Set cookie (--domain, --secure, --http-only, --same-site, --expires)
|
|
105
|
-
browser-use cookies clear [--url <url>] # Clear cookies
|
|
106
|
-
browser-use cookies export <file> # Export to JSON
|
|
107
|
-
browser-use cookies import <file> # Import from JSON
|
|
108
|
-
|
|
109
|
-
# Session
|
|
110
|
-
browser-use close # Close browser and stop daemon
|
|
111
|
-
browser-use sessions # List active sessions
|
|
112
|
-
browser-use close --all # Close all sessions
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
For advanced browser control (CDP, device emulation, tab activation), see `references/cdp-python.md`.
|
|
116
|
-
|
|
117
|
-
## Cloud API
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
browser-use cloud connect # Provision cloud browser and connect (zero-config)
|
|
121
|
-
browser-use cloud login <api-key> # Save API key (or set BROWSER_USE_API_KEY)
|
|
122
|
-
browser-use cloud logout # Remove API key
|
|
123
|
-
browser-use cloud v2 GET /browsers # REST passthrough (v2 or v3)
|
|
124
|
-
browser-use cloud v2 POST /tasks '{"task":"...","url":"..."}'
|
|
125
|
-
browser-use cloud v2 poll <task-id> # Poll task until done
|
|
126
|
-
browser-use cloud v2 --help # Show API endpoints
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
`cloud connect` provisions a cloud browser with a persistent profile (auto-created on first use), connects via CDP, and prints a live URL. `browser-use close` disconnects AND stops the cloud browser. For custom browser settings (proxy, timeout, specific profile), use `cloud v2 POST /browsers` directly with the desired parameters.
|
|
130
|
-
|
|
131
|
-
### Agent Self-Registration
|
|
132
|
-
|
|
133
|
-
Only use this if you don't already have an API key (check `browser-use doctor` to see if api_key is set). If already logged in, skip this entirely.
|
|
134
|
-
|
|
135
|
-
1. `browser-use cloud signup` — get a challenge
|
|
136
|
-
2. Solve the challenge
|
|
137
|
-
3. `browser-use cloud signup --verify <challenge-id> <answer>` — verify and save API key
|
|
138
|
-
4. `browser-use cloud signup --claim` — generate URL for a human to claim the account
|
|
139
|
-
|
|
140
|
-
## Tunnels
|
|
141
|
-
|
|
142
|
-
```bash
|
|
143
|
-
browser-use tunnel <port> # Start Cloudflare tunnel (idempotent)
|
|
144
|
-
browser-use tunnel list # Show active tunnels
|
|
145
|
-
browser-use tunnel stop <port> # Stop tunnel
|
|
146
|
-
browser-use tunnel stop --all # Stop all tunnels
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
## Profile Management
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
browser-use profile list # List detected browsers and profiles
|
|
153
|
-
browser-use profile sync --all # Sync profiles to cloud
|
|
154
|
-
browser-use profile update # Download/update profile-use binary
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
## Command Chaining
|
|
158
|
-
|
|
159
|
-
Commands can be chained with `&&`. The browser persists via the daemon, so chaining is safe and efficient.
|
|
160
|
-
|
|
161
|
-
```bash
|
|
162
|
-
browser-use open https://example.com && browser-use state
|
|
163
|
-
browser-use input 5 "user@example.com" && browser-use input 6 "password" && browser-use click 7
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
Chain when you don't need intermediate output. Run separately when you need to parse `state` to discover indices first.
|
|
167
|
-
|
|
168
|
-
## Common Workflows
|
|
169
|
-
|
|
170
|
-
### Authenticated Browsing
|
|
171
|
-
|
|
172
|
-
When a task requires an authenticated site (Gmail, GitHub, internal tools), use Chrome profiles:
|
|
173
|
-
|
|
174
|
-
```bash
|
|
175
|
-
browser-use profile list # Check available profiles
|
|
176
|
-
# Ask the user which profile to use, then:
|
|
177
|
-
browser-use --profile "Default" open https://github.com # Already logged in
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
### Exposing Local Dev Servers
|
|
181
|
-
|
|
182
|
-
```bash
|
|
183
|
-
browser-use tunnel 3000 # → https://abc.trycloudflare.com
|
|
184
|
-
browser-use open https://abc.trycloudflare.com # Browse the tunnel
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
## Multiple Browsers
|
|
188
|
-
|
|
189
|
-
For subagent workflows or running multiple browsers in parallel, use `--session NAME`. Each session gets its own browser. See `references/multi-session.md`.
|
|
190
|
-
|
|
191
|
-
## Configuration
|
|
192
|
-
|
|
193
|
-
```bash
|
|
194
|
-
browser-use config list # Show all config values
|
|
195
|
-
browser-use config set cloud_connect_proxy jp # Set a value
|
|
196
|
-
browser-use config get cloud_connect_proxy # Get a value
|
|
197
|
-
browser-use config unset cloud_connect_timeout # Remove a value
|
|
198
|
-
browser-use doctor # Shows config + diagnostics
|
|
199
|
-
browser-use setup # Interactive post-install setup
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
Config stored in `~/.browser-use/config.json`.
|
|
203
|
-
|
|
204
|
-
## Global Options
|
|
205
|
-
|
|
206
|
-
| Option | Description |
|
|
207
|
-
|--------|-------------|
|
|
208
|
-
| `--headed` | Show browser window |
|
|
209
|
-
| `--profile [NAME]` | Use real Chrome (bare `--profile` uses "Default") |
|
|
210
|
-
| `--cdp-url <url>` | Connect via CDP URL (`http://` or `ws://`) |
|
|
211
|
-
| `--session NAME` | Target a named session (default: "default") |
|
|
212
|
-
| `--json` | Output as JSON |
|
|
213
|
-
| `--mcp` | Run as MCP server via stdin/stdout |
|
|
214
|
-
|
|
215
|
-
## Tips
|
|
216
|
-
|
|
217
|
-
1. **Always run `state` first** to see available elements and their indices
|
|
218
|
-
2. **Use `--headed` for debugging** to see what the browser is doing
|
|
219
|
-
3. **Sessions persist** — browser stays open between commands
|
|
220
|
-
4. **CLI aliases**: `bu`, `browser`, and `browseruse` all work
|
|
221
|
-
5. **If commands fail**, run `browser-use close` first, then retry
|
|
222
|
-
|
|
223
|
-
## Troubleshooting
|
|
224
|
-
|
|
225
|
-
- **Browser won't start?** `browser-use close` then `browser-use --headed open <url>`
|
|
226
|
-
- **Element not found?** `browser-use scroll down` then `browser-use state`
|
|
227
|
-
- **Run diagnostics:** `browser-use doctor`
|
|
228
|
-
|
|
229
|
-
## Cleanup
|
|
230
|
-
|
|
231
|
-
```bash
|
|
232
|
-
browser-use close # Close browser session
|
|
233
|
-
browser-use tunnel stop --all # Stop tunnels (if any)
|
|
234
|
-
```
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
# Raw CDP & Python Session Reference
|
|
2
|
-
|
|
3
|
-
The CLI commands handle most browser interactions. Use `browser-use python` with raw CDP when you need browser-level control the CLI doesn't expose — activating a tab so the user sees it, intercepting network requests, emulating devices, or working with Chrome target IDs directly.
|
|
4
|
-
|
|
5
|
-
## How the Python session works
|
|
6
|
-
|
|
7
|
-
`browser-use python "statement"` executes one Python statement per call. Variables persist across calls — set a value in one call, use it in the next.
|
|
8
|
-
|
|
9
|
-
A `browser` object is pre-injected with sync wrappers for common operations (`browser.goto()`, `browser.click()`, etc.). For anything beyond those, two internals give you full access:
|
|
10
|
-
|
|
11
|
-
- `browser._run(coroutine)` — run any async coroutine synchronously (60s timeout)
|
|
12
|
-
- `browser._session` — the raw `BrowserSession` with full CDP client access
|
|
13
|
-
|
|
14
|
-
## Getting a CDP client
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
browser-use python "cdp = browser._run(browser._session.get_or_create_cdp_session())"
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
After this, `cdp` persists across calls. Use `cdp.cdp_client.send.<Domain>.<method>()` for any CDP command and `cdp.session_id` for the session parameter.
|
|
21
|
-
|
|
22
|
-
## Recipes
|
|
23
|
-
|
|
24
|
-
### Activate a tab (make it visible to the user)
|
|
25
|
-
|
|
26
|
-
The CLI's `tab switch` only changes the agent's internal focus — Chrome's visible tab doesn't change. To actually show the user a specific tab:
|
|
27
|
-
|
|
28
|
-
```bash
|
|
29
|
-
# Get all targets to find the target ID
|
|
30
|
-
browser-use python "targets = browser._session.session_manager.get_all_page_targets()"
|
|
31
|
-
browser-use python "print([(i, t.url) for i, t in enumerate(targets)])"
|
|
32
|
-
|
|
33
|
-
# Activate target at index 1 so the user sees it
|
|
34
|
-
browser-use python "cdp = browser._run(browser._session.get_or_create_cdp_session(target_id=None, focus=False))"
|
|
35
|
-
browser-use python "browser._run(cdp.cdp_client.send.Target.activateTarget(params={'targetId': targets[1].target_id}))"
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### List all tabs with target IDs
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
browser-use python "targets = browser._session.session_manager.get_all_page_targets()"
|
|
42
|
-
browser-use python "
|
|
43
|
-
for i, t in enumerate(targets):
|
|
44
|
-
print(f'{i}: {t.target_id[:12]}... {t.url}')
|
|
45
|
-
"
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
### Run JavaScript and get the result
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
browser-use python "cdp = browser._run(browser._session.get_or_create_cdp_session())"
|
|
52
|
-
browser-use python "result = browser._run(cdp.cdp_client.send.Runtime.evaluate(params={'expression': 'document.title', 'returnByValue': True}, session_id=cdp.session_id))"
|
|
53
|
-
browser-use python "print(result['result']['value'])"
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
### Emulate a mobile device
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
browser-use python "cdp = browser._run(browser._session.get_or_create_cdp_session())"
|
|
60
|
-
browser-use python "browser._run(cdp.cdp_client.send.Emulation.setDeviceMetricsOverride(params={'width': 375, 'height': 812, 'deviceScaleFactor': 3, 'mobile': True}, session_id=cdp.session_id))"
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
### Get cookies via CDP
|
|
64
|
-
|
|
65
|
-
```bash
|
|
66
|
-
browser-use python "cdp = browser._run(browser._session.get_or_create_cdp_session())"
|
|
67
|
-
browser-use python "cookies = browser._run(cdp.cdp_client.send.Network.getCookies(params={}, session_id=cdp.session_id))"
|
|
68
|
-
browser-use python "print(cookies)"
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## Tips
|
|
72
|
-
|
|
73
|
-
- Each `browser-use python` call is one statement. Multi-line strings work for `for` loops and `if` blocks, but you can't mix statements and expressions. Use multiple calls.
|
|
74
|
-
- Variables persist: set `cdp = ...` in one call, use `cdp` in the next.
|
|
75
|
-
- The `browser._run()` bridge has a 60-second timeout. For long operations, increase it or use the async internals directly.
|
|
76
|
-
- All CDP domains are available via `cdp.cdp_client.send.<Domain>.<method>()`. See the [Chrome DevTools Protocol docs](https://chromedevtools.github.io/devtools-protocol/) for the full API.
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# Multiple Browser Sessions
|
|
2
|
-
|
|
3
|
-
## Why use multiple sessions
|
|
4
|
-
|
|
5
|
-
When you need more than one browser at a time:
|
|
6
|
-
- Cloud browser for scraping + local Chrome for authenticated tasks
|
|
7
|
-
- Two different Chrome profiles simultaneously
|
|
8
|
-
- Isolated browser for testing that won't affect the user's browsing
|
|
9
|
-
- Running a headed browser for debugging while headless runs in background
|
|
10
|
-
|
|
11
|
-
## How sessions are isolated
|
|
12
|
-
|
|
13
|
-
Each `--session NAME` gets:
|
|
14
|
-
- Its own daemon process
|
|
15
|
-
- Its own Unix socket (`~/.browser-use/{name}.sock`)
|
|
16
|
-
- Its own PID file and state file
|
|
17
|
-
- Its own browser instance (completely independent)
|
|
18
|
-
- Its own tab ownership state (multi-agent locks don't cross sessions)
|
|
19
|
-
|
|
20
|
-
## The `--session` flag
|
|
21
|
-
|
|
22
|
-
Must be passed on every command targeting that session:
|
|
23
|
-
|
|
24
|
-
```bash
|
|
25
|
-
browser-use --session work open <url> # goes to 'work' daemon
|
|
26
|
-
browser-use --session work state # reads from 'work' daemon
|
|
27
|
-
browser-use state # goes to 'default' daemon (different browser)
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
If you forget `--session`, the command goes to the `default` session. This is the most common mistake — you'll interact with the wrong browser.
|
|
31
|
-
|
|
32
|
-
## Combining sessions with browser modes
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
# Session 1: cloud browser
|
|
36
|
-
browser-use --session cloud cloud connect
|
|
37
|
-
|
|
38
|
-
# Session 2: connect to user's Chrome
|
|
39
|
-
browser-use --session chrome connect
|
|
40
|
-
|
|
41
|
-
# Session 3: headed Chromium for debugging
|
|
42
|
-
browser-use --session debug --headed open <url>
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Each session is fully independent. The cloud session talks to a remote browser, the chrome session talks to the user's Chrome, and the debug session manages its own Chromium — all running simultaneously.
|
|
46
|
-
|
|
47
|
-
## Listing and managing sessions
|
|
48
|
-
|
|
49
|
-
```bash
|
|
50
|
-
browser-use sessions
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Output:
|
|
54
|
-
```
|
|
55
|
-
SESSION PHASE PID CONFIG
|
|
56
|
-
cloud running 12345 cloud
|
|
57
|
-
chrome running 12346 cdp
|
|
58
|
-
debug ready 12347 headed
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
PHASE shows the daemon lifecycle state: `initializing`, `ready`, `starting`, `running`, `shutting_down`, `stopped`, `failed`.
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
browser-use --session cloud close # close one session
|
|
65
|
-
browser-use close --all # close every session
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Common patterns
|
|
69
|
-
|
|
70
|
-
**Cloud + local authenticated:**
|
|
71
|
-
```bash
|
|
72
|
-
browser-use --session scraper cloud connect
|
|
73
|
-
browser-use --session scraper open https://example.com
|
|
74
|
-
# ... scrape data ...
|
|
75
|
-
|
|
76
|
-
browser-use --session auth --profile "Default" open https://github.com
|
|
77
|
-
browser-use --session auth state
|
|
78
|
-
# ... interact with authenticated site ...
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
**Throwaway test browser:**
|
|
82
|
-
```bash
|
|
83
|
-
browser-use --session test --headed open https://localhost:3000
|
|
84
|
-
# ... test, debug, inspect ...
|
|
85
|
-
browser-use --session test close # done, clean up
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**Environment variable:**
|
|
89
|
-
```bash
|
|
90
|
-
export BROWSER_USE_SESSION=work
|
|
91
|
-
browser-use open <url> # uses 'work' session without --session flag
|
|
92
|
-
```
|