@mercuryo-ai/agentbrowse 0.2.50
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 +15 -0
- package/README.md +335 -0
- package/dist/assistive-runtime.d.ts +110 -0
- package/dist/assistive-runtime.d.ts.map +1 -0
- package/dist/assistive-runtime.js +79 -0
- package/dist/assistive-runtime.test-support.d.ts +7 -0
- package/dist/assistive-runtime.test-support.d.ts.map +1 -0
- package/dist/assistive-runtime.test-support.js +106 -0
- package/dist/assistive-stagehand.d.ts +12 -0
- package/dist/assistive-stagehand.d.ts.map +1 -0
- package/dist/assistive-stagehand.js +10 -0
- package/dist/browser-session-state.d.ts +95 -0
- package/dist/browser-session-state.d.ts.map +1 -0
- package/dist/browser-session-state.js +279 -0
- package/dist/client-bindings.d.ts +10 -0
- package/dist/client-bindings.d.ts.map +1 -0
- package/dist/client-bindings.js +18 -0
- package/dist/client.d.ts +49 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +63 -0
- package/dist/command-api-tracing.d.ts +20 -0
- package/dist/command-api-tracing.d.ts.map +1 -0
- package/dist/command-api-tracing.js +149 -0
- package/dist/command-name.d.ts +3 -0
- package/dist/command-name.d.ts.map +1 -0
- package/dist/command-name.js +11 -0
- package/dist/commands/act.d.ts +43 -0
- package/dist/commands/act.d.ts.map +1 -0
- package/dist/commands/act.js +1107 -0
- package/dist/commands/action-acceptance.d.ts +93 -0
- package/dist/commands/action-acceptance.d.ts.map +1 -0
- package/dist/commands/action-acceptance.js +1938 -0
- package/dist/commands/action-artifacts.d.ts +33 -0
- package/dist/commands/action-artifacts.d.ts.map +1 -0
- package/dist/commands/action-artifacts.js +104 -0
- package/dist/commands/action-execution-guards.d.ts +5 -0
- package/dist/commands/action-execution-guards.d.ts.map +1 -0
- package/dist/commands/action-execution-guards.js +3 -0
- package/dist/commands/action-executor-helpers.d.ts +21 -0
- package/dist/commands/action-executor-helpers.d.ts.map +1 -0
- package/dist/commands/action-executor-helpers.js +265 -0
- package/dist/commands/action-executor.d.ts +14 -0
- package/dist/commands/action-executor.d.ts.map +1 -0
- package/dist/commands/action-executor.js +46 -0
- package/dist/commands/action-fallbacks.d.ts +6 -0
- package/dist/commands/action-fallbacks.d.ts.map +1 -0
- package/dist/commands/action-fallbacks.js +43 -0
- package/dist/commands/action-result-resolution.d.ts +17 -0
- package/dist/commands/action-result-resolution.d.ts.map +1 -0
- package/dist/commands/action-result-resolution.js +132 -0
- package/dist/commands/action-value-projection.d.ts +32 -0
- package/dist/commands/action-value-projection.d.ts.map +1 -0
- package/dist/commands/action-value-projection.js +151 -0
- package/dist/commands/attach.d.ts +41 -0
- package/dist/commands/attach.d.ts.map +1 -0
- package/dist/commands/attach.js +103 -0
- package/dist/commands/browse-actions.d.ts +4 -0
- package/dist/commands/browse-actions.d.ts.map +1 -0
- package/dist/commands/browse-actions.js +4 -0
- package/dist/commands/browser-status.d.ts +57 -0
- package/dist/commands/browser-status.d.ts.map +1 -0
- package/dist/commands/browser-status.js +243 -0
- package/dist/commands/click-action-executor.d.ts +12 -0
- package/dist/commands/click-action-executor.d.ts.map +1 -0
- package/dist/commands/click-action-executor.js +111 -0
- package/dist/commands/click-activation-policy.d.ts +5 -0
- package/dist/commands/click-activation-policy.d.ts.map +1 -0
- package/dist/commands/click-activation-policy.js +13 -0
- package/dist/commands/close.d.ts +26 -0
- package/dist/commands/close.d.ts.map +1 -0
- package/dist/commands/close.js +124 -0
- package/dist/commands/datepicker-action-executor.d.ts +12 -0
- package/dist/commands/datepicker-action-executor.d.ts.map +1 -0
- package/dist/commands/datepicker-action-executor.js +218 -0
- package/dist/commands/descriptor-validation.d.ts +27 -0
- package/dist/commands/descriptor-validation.d.ts.map +1 -0
- package/dist/commands/descriptor-validation.js +192 -0
- package/dist/commands/extract-scope-resolution.d.ts +20 -0
- package/dist/commands/extract-scope-resolution.d.ts.map +1 -0
- package/dist/commands/extract-scope-resolution.js +109 -0
- package/dist/commands/extract-scoped-dialog-text.d.ts +3 -0
- package/dist/commands/extract-scoped-dialog-text.d.ts.map +1 -0
- package/dist/commands/extract-scoped-dialog-text.js +210 -0
- package/dist/commands/extract-snapshot-sanitizer.d.ts +5 -0
- package/dist/commands/extract-snapshot-sanitizer.d.ts.map +1 -0
- package/dist/commands/extract-snapshot-sanitizer.js +98 -0
- package/dist/commands/extract-stagehand-executor.d.ts +17 -0
- package/dist/commands/extract-stagehand-executor.d.ts.map +1 -0
- package/dist/commands/extract-stagehand-executor.js +112 -0
- package/dist/commands/extract.d.ts +57 -0
- package/dist/commands/extract.d.ts.map +1 -0
- package/dist/commands/extract.js +668 -0
- package/dist/commands/interaction-kernel.d.ts +46 -0
- package/dist/commands/interaction-kernel.d.ts.map +1 -0
- package/dist/commands/interaction-kernel.js +215 -0
- package/dist/commands/launch.d.ts +41 -0
- package/dist/commands/launch.d.ts.map +1 -0
- package/dist/commands/launch.js +182 -0
- package/dist/commands/navigate.d.ts +31 -0
- package/dist/commands/navigate.d.ts.map +1 -0
- package/dist/commands/navigate.js +202 -0
- package/dist/commands/observe-accessibility.d.ts +22 -0
- package/dist/commands/observe-accessibility.d.ts.map +1 -0
- package/dist/commands/observe-accessibility.js +566 -0
- package/dist/commands/observe-display-label.d.ts +4 -0
- package/dist/commands/observe-display-label.d.ts.map +1 -0
- package/dist/commands/observe-display-label.js +26 -0
- package/dist/commands/observe-dom-label-contract.d.ts +2 -0
- package/dist/commands/observe-dom-label-contract.d.ts.map +1 -0
- package/dist/commands/observe-dom-label-contract.js +564 -0
- package/dist/commands/observe-fallback-semantics.d.ts +6 -0
- package/dist/commands/observe-fallback-semantics.d.ts.map +1 -0
- package/dist/commands/observe-fallback-semantics.js +86 -0
- package/dist/commands/observe-inventory.d.ts +149 -0
- package/dist/commands/observe-inventory.d.ts.map +1 -0
- package/dist/commands/observe-inventory.js +3545 -0
- package/dist/commands/observe-label-policy.d.ts +8 -0
- package/dist/commands/observe-label-policy.d.ts.map +1 -0
- package/dist/commands/observe-label-policy.js +21 -0
- package/dist/commands/observe-page-state.d.ts +11 -0
- package/dist/commands/observe-page-state.d.ts.map +1 -0
- package/dist/commands/observe-page-state.js +89 -0
- package/dist/commands/observe-persistence.d.ts +15 -0
- package/dist/commands/observe-persistence.d.ts.map +1 -0
- package/dist/commands/observe-persistence.js +238 -0
- package/dist/commands/observe-projection.d.ts +119 -0
- package/dist/commands/observe-projection.d.ts.map +1 -0
- package/dist/commands/observe-projection.js +726 -0
- package/dist/commands/observe-protected.d.ts +6 -0
- package/dist/commands/observe-protected.d.ts.map +1 -0
- package/dist/commands/observe-protected.js +31 -0
- package/dist/commands/observe-semantics.d.ts +10 -0
- package/dist/commands/observe-semantics.d.ts.map +1 -0
- package/dist/commands/observe-semantics.js +535 -0
- package/dist/commands/observe-signals.d.ts +48 -0
- package/dist/commands/observe-signals.d.ts.map +1 -0
- package/dist/commands/observe-signals.js +461 -0
- package/dist/commands/observe-stagehand.d.ts +49 -0
- package/dist/commands/observe-stagehand.d.ts.map +1 -0
- package/dist/commands/observe-stagehand.js +94 -0
- package/dist/commands/observe-surfaces.d.ts +11 -0
- package/dist/commands/observe-surfaces.d.ts.map +1 -0
- package/dist/commands/observe-surfaces.js +290 -0
- package/dist/commands/observe.d.ts +113 -0
- package/dist/commands/observe.d.ts.map +1 -0
- package/dist/commands/observe.js +556 -0
- package/dist/commands/screenshot.d.ts +37 -0
- package/dist/commands/screenshot.d.ts.map +1 -0
- package/dist/commands/screenshot.js +269 -0
- package/dist/commands/select-action-executor.d.ts +10 -0
- package/dist/commands/select-action-executor.d.ts.map +1 -0
- package/dist/commands/select-action-executor.js +156 -0
- package/dist/commands/semantic-observe-lexical.d.ts +31 -0
- package/dist/commands/semantic-observe-lexical.d.ts.map +1 -0
- package/dist/commands/semantic-observe-lexical.js +186 -0
- package/dist/commands/semantic-observe.d.ts +37 -0
- package/dist/commands/semantic-observe.d.ts.map +1 -0
- package/dist/commands/semantic-observe.js +1339 -0
- package/dist/commands/structured-grid-action-executor.d.ts +3 -0
- package/dist/commands/structured-grid-action-executor.d.ts.map +1 -0
- package/dist/commands/structured-grid-action-executor.js +4 -0
- package/dist/commands/target-resolution.d.ts +4 -0
- package/dist/commands/target-resolution.d.ts.map +1 -0
- package/dist/commands/target-resolution.js +33 -0
- package/dist/commands/text-input-action-executor.d.ts +5 -0
- package/dist/commands/text-input-action-executor.d.ts.map +1 -0
- package/dist/commands/text-input-action-executor.js +116 -0
- package/dist/commands/user-actionable.d.ts +4 -0
- package/dist/commands/user-actionable.d.ts.map +1 -0
- package/dist/commands/user-actionable.js +216 -0
- package/dist/control-semantics.d.ts +30 -0
- package/dist/control-semantics.d.ts.map +1 -0
- package/dist/control-semantics.js +419 -0
- package/dist/diagnostics.d.ts +132 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +120 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +350 -0
- package/dist/library.d.ts +17 -0
- package/dist/library.d.ts.map +1 -0
- package/dist/library.js +14 -0
- package/dist/output.d.ts +32 -0
- package/dist/output.d.ts.map +1 -0
- package/dist/output.js +33 -0
- package/dist/owned-browser.d.ts +12 -0
- package/dist/owned-browser.d.ts.map +1 -0
- package/dist/owned-browser.js +69 -0
- package/dist/owned-process.d.ts +19 -0
- package/dist/owned-process.d.ts.map +1 -0
- package/dist/owned-process.js +145 -0
- package/dist/playwright-runtime.d.ts +43 -0
- package/dist/playwright-runtime.d.ts.map +1 -0
- package/dist/playwright-runtime.js +339 -0
- package/dist/protected-fill-browser.d.ts +22 -0
- package/dist/protected-fill-browser.d.ts.map +1 -0
- package/dist/protected-fill-browser.js +52 -0
- package/dist/protected-fill.d.ts +82 -0
- package/dist/protected-fill.d.ts.map +1 -0
- package/dist/protected-fill.js +20 -0
- package/dist/runtime-metrics.d.ts +27 -0
- package/dist/runtime-metrics.d.ts.map +1 -0
- package/dist/runtime-metrics.js +66 -0
- package/dist/runtime-page-state.d.ts +11 -0
- package/dist/runtime-page-state.d.ts.map +1 -0
- package/dist/runtime-page-state.js +62 -0
- package/dist/runtime-protected-state.d.ts +14 -0
- package/dist/runtime-protected-state.d.ts.map +1 -0
- package/dist/runtime-protected-state.js +148 -0
- package/dist/runtime-resolution.d.ts +9 -0
- package/dist/runtime-resolution.d.ts.map +1 -0
- package/dist/runtime-resolution.js +19 -0
- package/dist/runtime-state.d.ts +251 -0
- package/dist/runtime-state.d.ts.map +1 -0
- package/dist/runtime-state.js +599 -0
- package/dist/secrets/catalog-applicability.d.ts +5 -0
- package/dist/secrets/catalog-applicability.d.ts.map +1 -0
- package/dist/secrets/catalog-applicability.js +59 -0
- package/dist/secrets/field-policy.d.ts +3 -0
- package/dist/secrets/field-policy.d.ts.map +1 -0
- package/dist/secrets/field-policy.js +3 -0
- package/dist/secrets/fill-ordering.d.ts +10 -0
- package/dist/secrets/fill-ordering.d.ts.map +1 -0
- package/dist/secrets/fill-ordering.js +41 -0
- package/dist/secrets/form-matcher.d.ts +60 -0
- package/dist/secrets/form-matcher.d.ts.map +1 -0
- package/dist/secrets/form-matcher.js +948 -0
- package/dist/secrets/protected-artifact-guard.d.ts +39 -0
- package/dist/secrets/protected-artifact-guard.d.ts.map +1 -0
- package/dist/secrets/protected-artifact-guard.js +44 -0
- package/dist/secrets/protected-bindings.d.ts +14 -0
- package/dist/secrets/protected-bindings.d.ts.map +1 -0
- package/dist/secrets/protected-bindings.js +29 -0
- package/dist/secrets/protected-exact-value-redaction.d.ts +14 -0
- package/dist/secrets/protected-exact-value-redaction.d.ts.map +1 -0
- package/dist/secrets/protected-exact-value-redaction.js +360 -0
- package/dist/secrets/protected-field-semantics.d.ts +9 -0
- package/dist/secrets/protected-field-semantics.d.ts.map +1 -0
- package/dist/secrets/protected-field-semantics.js +154 -0
- package/dist/secrets/protected-field-values.d.ts +15 -0
- package/dist/secrets/protected-field-values.d.ts.map +1 -0
- package/dist/secrets/protected-field-values.js +131 -0
- package/dist/secrets/protected-fill.d.ts +47 -0
- package/dist/secrets/protected-fill.d.ts.map +1 -0
- package/dist/secrets/protected-fill.js +446 -0
- package/dist/secrets/protected-value-adapters.d.ts +4 -0
- package/dist/secrets/protected-value-adapters.d.ts.map +1 -0
- package/dist/secrets/protected-value-adapters.js +118 -0
- package/dist/secrets/types.d.ts +70 -0
- package/dist/secrets/types.d.ts.map +1 -0
- package/dist/secrets/types.js +30 -0
- package/dist/session.d.ts +19 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +120 -0
- package/dist/solver/browser-launcher.d.ts +14 -0
- package/dist/solver/browser-launcher.d.ts.map +1 -0
- package/dist/solver/browser-launcher.js +799 -0
- package/dist/solver/config.d.ts +18 -0
- package/dist/solver/config.d.ts.map +1 -0
- package/dist/solver/config.js +67 -0
- package/dist/solver/fingerprint.d.ts +9 -0
- package/dist/solver/fingerprint.d.ts.map +1 -0
- package/dist/solver/fingerprint.js +96 -0
- package/dist/solver/profile-manager.d.ts +8 -0
- package/dist/solver/profile-manager.d.ts.map +1 -0
- package/dist/solver/profile-manager.js +74 -0
- package/dist/solver/turnstile-challenge.d.ts +3 -0
- package/dist/solver/turnstile-challenge.d.ts.map +1 -0
- package/dist/solver/turnstile-challenge.js +173 -0
- package/dist/solver/types.d.ts +67 -0
- package/dist/solver/types.d.ts.map +1 -0
- package/dist/solver/types.js +1 -0
- package/dist/stagehand-runtime.d.ts +4 -0
- package/dist/stagehand-runtime.d.ts.map +1 -0
- package/dist/stagehand-runtime.js +10 -0
- package/dist/stagehand.d.ts +15 -0
- package/dist/stagehand.d.ts.map +1 -0
- package/dist/stagehand.js +19 -0
- package/dist/testing.d.ts +5 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +4 -0
- package/dist/update-check.d.ts +14 -0
- package/dist/update-check.d.ts.map +1 -0
- package/dist/update-check.js +182 -0
- package/dist/workflow-session-state.d.ts +30 -0
- package/dist/workflow-session-state.d.ts.map +1 -0
- package/dist/workflow-session-state.js +74 -0
- package/docs/README.md +25 -0
- package/docs/api-reference.md +242 -0
- package/docs/assistive-runtime.md +148 -0
- package/docs/configuration.md +287 -0
- package/docs/getting-started.md +237 -0
- package/docs/integration-checklist.md +36 -0
- package/docs/protected-fill.md +112 -0
- package/docs/testing.md +50 -0
- package/docs/troubleshooting.md +71 -0
- package/examples/README.md +18 -0
- package/examples/attach.ts +27 -0
- package/examples/basic.ts +36 -0
- package/examples/extract.ts +50 -0
- package/package.json +83 -0
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
# AgentBrowse Configuration Guide
|
|
2
|
+
|
|
3
|
+
This guide covers the parts of AgentBrowse that you may want to configure:
|
|
4
|
+
|
|
5
|
+
- browser session persistence
|
|
6
|
+
- proxy launch settings
|
|
7
|
+
- diagnostics hooks
|
|
8
|
+
- client-scoped runtime configuration
|
|
9
|
+
|
|
10
|
+
## Start With The Simplest Default
|
|
11
|
+
|
|
12
|
+
Most applications can start with this mental model:
|
|
13
|
+
|
|
14
|
+
1. call `launch(...)` or `attach(...)`
|
|
15
|
+
2. keep the returned `session` in memory
|
|
16
|
+
3. pass that `session` into later calls
|
|
17
|
+
|
|
18
|
+
You only need more configuration when you want one of these:
|
|
19
|
+
|
|
20
|
+
- custom LLM integration
|
|
21
|
+
- custom diagnostics or tracing
|
|
22
|
+
- session restore across process runs
|
|
23
|
+
- proxy launch
|
|
24
|
+
|
|
25
|
+
## Attach To An Existing Browser
|
|
26
|
+
|
|
27
|
+
If you already have a CDP websocket URL, you do not need `launch(...)`.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { attach } from '@mercuryo-ai/agentbrowse';
|
|
31
|
+
|
|
32
|
+
const attached = await attach('ws://127.0.0.1:9222/devtools/browser/browser-id');
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
You can also label an attached session:
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
const attached = await attach(remoteCdpUrl, {
|
|
39
|
+
provider: 'browserbase',
|
|
40
|
+
});
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
That provider label is metadata only. AgentBrowse still treats this as a
|
|
44
|
+
generic CDP-attached browser session.
|
|
45
|
+
|
|
46
|
+
## Client Configuration
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { createAgentbrowseClient } from '@mercuryo-ai/agentbrowse';
|
|
50
|
+
|
|
51
|
+
const client = createAgentbrowseClient({
|
|
52
|
+
assistiveRuntime: { /* ... */ },
|
|
53
|
+
diagnostics: { /* ... */ },
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
This is the best default when you embed AgentBrowse into a larger app because:
|
|
58
|
+
|
|
59
|
+
- it keeps configuration local to your app or tenant
|
|
60
|
+
- it is safer for parallel tests
|
|
61
|
+
- it avoids process-global configuration collisions
|
|
62
|
+
|
|
63
|
+
For small scripts, process-global configure helpers also exist, but client
|
|
64
|
+
configuration is the cleaner embedded pattern.
|
|
65
|
+
|
|
66
|
+
## Browser Session Persistence
|
|
67
|
+
|
|
68
|
+
Persistence is optional. Use it when you want to restore a browser session
|
|
69
|
+
after a process restart.
|
|
70
|
+
|
|
71
|
+
### Default Store
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { loadBrowserSession, saveBrowserSession } from '@mercuryo-ai/agentbrowse';
|
|
75
|
+
|
|
76
|
+
saveBrowserSession(session);
|
|
77
|
+
const restored = loadBrowserSession();
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Default path:
|
|
81
|
+
|
|
82
|
+
`~/.agentbrowse/browse-session.json`
|
|
83
|
+
|
|
84
|
+
### Custom Store
|
|
85
|
+
|
|
86
|
+
For embedded apps, prefer an explicit store root:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { createBrowserSessionStore } from '@mercuryo-ai/agentbrowse';
|
|
90
|
+
|
|
91
|
+
const store = createBrowserSessionStore({
|
|
92
|
+
rootDir: '/tmp/my-app/browser-state',
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
store.save(session);
|
|
96
|
+
const restored = store.load();
|
|
97
|
+
store.delete();
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
This avoids hidden machine-level coupling to `~/.agentbrowse`.
|
|
101
|
+
|
|
102
|
+
## Proxy Configuration
|
|
103
|
+
|
|
104
|
+
The clearest way to use a proxy is to pass it directly to `launch(...)`.
|
|
105
|
+
|
|
106
|
+
```ts
|
|
107
|
+
import { launch } from '@mercuryo-ai/agentbrowse';
|
|
108
|
+
|
|
109
|
+
const launchResult = await launch('https://example.com', {
|
|
110
|
+
useProxy: true,
|
|
111
|
+
proxy: 'http://user:pass@proxy.example:8080',
|
|
112
|
+
});
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Current launch behavior is:
|
|
116
|
+
|
|
117
|
+
- if `useProxy` is not `true`, launch is direct
|
|
118
|
+
- if `useProxy` is `true` and `proxy` is provided, that explicit proxy is used
|
|
119
|
+
- if `useProxy` is `true` and `proxy` is omitted, AgentBrowse falls back to
|
|
120
|
+
`defaults.proxy` from `~/.agentbrowse/config.json`
|
|
121
|
+
|
|
122
|
+
For embedded library usage, prefer explicit launch options over machine-level
|
|
123
|
+
config files.
|
|
124
|
+
|
|
125
|
+
## Diagnostics
|
|
126
|
+
|
|
127
|
+
AgentBrowse is quiet by default. It does not write traces or diagnostics to
|
|
128
|
+
disk unless you provide hooks.
|
|
129
|
+
|
|
130
|
+
Client-scoped example:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { createAgentbrowseClient } from '@mercuryo-ai/agentbrowse';
|
|
134
|
+
|
|
135
|
+
const client = createAgentbrowseClient({
|
|
136
|
+
diagnostics: {
|
|
137
|
+
startStep(input) {
|
|
138
|
+
return {
|
|
139
|
+
finish() {
|
|
140
|
+
// your tracing or logging hook
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Use diagnostics when you need:
|
|
149
|
+
|
|
150
|
+
- integration with your own tracing system
|
|
151
|
+
- deeper command-level debugging
|
|
152
|
+
- custom artifact collection
|
|
153
|
+
|
|
154
|
+
If you do not need that, you can ignore diagnostics completely.
|
|
155
|
+
|
|
156
|
+
### Diagnostics Contract
|
|
157
|
+
|
|
158
|
+
Diagnostics hooks are intentionally low-level. They are designed to let your
|
|
159
|
+
application map AgentBrowse command activity into its own tracing, logging, or
|
|
160
|
+
artifact pipeline.
|
|
161
|
+
|
|
162
|
+
#### `startStep(input)`
|
|
163
|
+
|
|
164
|
+
Called when a command starts.
|
|
165
|
+
|
|
166
|
+
Important fields on `input`:
|
|
167
|
+
|
|
168
|
+
- `runId`
|
|
169
|
+
Stable run identifier for the surrounding browser workflow.
|
|
170
|
+
- `command`
|
|
171
|
+
The AgentBrowse command name such as `observe`, `act`, or `extract`.
|
|
172
|
+
- `input`
|
|
173
|
+
Command-specific input metadata. Examples:
|
|
174
|
+
`targetUrl`, `instruction`, `scopeRef`, extraction schema summary.
|
|
175
|
+
- `refs`
|
|
176
|
+
Stable runtime refs such as `pageRef`, `targetRef`, `surfaceRef`, `fillRef`,
|
|
177
|
+
and `requestId`.
|
|
178
|
+
- `protectedStep`
|
|
179
|
+
`true` when the current step is happening in a protected-value context.
|
|
180
|
+
|
|
181
|
+
Return a `DiagnosticStepHandle`:
|
|
182
|
+
|
|
183
|
+
```ts
|
|
184
|
+
{
|
|
185
|
+
runId: 'run_123',
|
|
186
|
+
stepId: 'step_observe_1',
|
|
187
|
+
command: 'observe',
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
That handle is then passed back into later diagnostics hooks for the same step.
|
|
192
|
+
|
|
193
|
+
#### `finishStep(input)`
|
|
194
|
+
|
|
195
|
+
Called when a command finishes.
|
|
196
|
+
|
|
197
|
+
Important fields:
|
|
198
|
+
|
|
199
|
+
- `step`
|
|
200
|
+
The handle returned from `startStep(...)`
|
|
201
|
+
- `success`
|
|
202
|
+
Whether the command succeeded
|
|
203
|
+
- `outcomeType`
|
|
204
|
+
High-level outcome classification
|
|
205
|
+
- `message`
|
|
206
|
+
Human-readable command summary
|
|
207
|
+
- `reason`
|
|
208
|
+
Extra failure detail when available
|
|
209
|
+
- `artifactManifestId`
|
|
210
|
+
Optional link to a separately recorded artifact manifest
|
|
211
|
+
|
|
212
|
+
#### `captureSnapshot(input)`
|
|
213
|
+
|
|
214
|
+
Called for before/after/point-in-time snapshots.
|
|
215
|
+
|
|
216
|
+
Important fields:
|
|
217
|
+
|
|
218
|
+
- `phase`
|
|
219
|
+
One of `before`, `after`, or `point-in-time`
|
|
220
|
+
- `pageRef`
|
|
221
|
+
- `url`
|
|
222
|
+
- `title`
|
|
223
|
+
- `artifactRefs`
|
|
224
|
+
Optional file paths for screenshot, HTML, trace, or log artifacts
|
|
225
|
+
|
|
226
|
+
#### `recordCommandEvent(input)`
|
|
227
|
+
|
|
228
|
+
Called for lifecycle events:
|
|
229
|
+
|
|
230
|
+
- `started`
|
|
231
|
+
- `completed`
|
|
232
|
+
- `failed`
|
|
233
|
+
|
|
234
|
+
Use `attributes` for structured tracing tags or log enrichment.
|
|
235
|
+
|
|
236
|
+
#### `recordChildSpan(input)`
|
|
237
|
+
|
|
238
|
+
Called for nested client-side work such as LLM rerank spans.
|
|
239
|
+
|
|
240
|
+
Important fields:
|
|
241
|
+
|
|
242
|
+
- `name`
|
|
243
|
+
- `kind`
|
|
244
|
+
- `startedAt`
|
|
245
|
+
- `endedAt`
|
|
246
|
+
- `statusCode`
|
|
247
|
+
- `statusMessage`
|
|
248
|
+
- `attributes`
|
|
249
|
+
|
|
250
|
+
#### `recordArtifactManifest(input)`
|
|
251
|
+
|
|
252
|
+
Called when AgentBrowse has a grouped artifact manifest for a step.
|
|
253
|
+
|
|
254
|
+
The manifest includes:
|
|
255
|
+
|
|
256
|
+
- `screenshots`
|
|
257
|
+
- `htmlSnapshots`
|
|
258
|
+
- `traces`
|
|
259
|
+
- `logs`
|
|
260
|
+
- `suppressed`
|
|
261
|
+
|
|
262
|
+
Each artifact entry includes its local path plus optional storage metadata.
|
|
263
|
+
|
|
264
|
+
### Mapping To External Tracing
|
|
265
|
+
|
|
266
|
+
Typical mapping strategy:
|
|
267
|
+
|
|
268
|
+
- map `runId` to your trace or workflow id
|
|
269
|
+
- map `stepId` to a span or operation id
|
|
270
|
+
- copy `command`, `outcomeType`, and `refs` into structured attributes
|
|
271
|
+
- treat `captureSnapshot(...)` and `recordArtifactManifest(...)` as artifact
|
|
272
|
+
enrichment, not as the main step identity
|
|
273
|
+
|
|
274
|
+
Diagnostics hooks are best-effort. AgentBrowse continues its command flow even
|
|
275
|
+
if your diagnostics implementation throws.
|
|
276
|
+
|
|
277
|
+
## Process-Global Convenience Helpers
|
|
278
|
+
|
|
279
|
+
AgentBrowse still exposes process-global convenience functions such as:
|
|
280
|
+
|
|
281
|
+
- `configureAgentbrowseAssistiveRuntime(...)`
|
|
282
|
+
- `configureAgentbrowseDiagnostics(...)`
|
|
283
|
+
|
|
284
|
+
These are useful for small scripts and quick experiments.
|
|
285
|
+
|
|
286
|
+
For embedded production usage, client-scoped configuration is the better
|
|
287
|
+
default.
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# AgentBrowse Getting Started
|
|
2
|
+
|
|
3
|
+
This guide is for a developer who wants to embed `@mercuryo-ai/agentbrowse` as a
|
|
4
|
+
library into their own application.
|
|
5
|
+
|
|
6
|
+
Read the package README first. This page is the practical follow-up: it turns
|
|
7
|
+
the high-level overview into a simple working model for the main APIs.
|
|
8
|
+
|
|
9
|
+
## Mental Model
|
|
10
|
+
|
|
11
|
+
The normal flow is:
|
|
12
|
+
|
|
13
|
+
1. `launch(...)` starts a managed browser, or `attach(...)` connects to an
|
|
14
|
+
existing CDP browser, and returns a `session`
|
|
15
|
+
2. `observe(session)` inspects the current page
|
|
16
|
+
3. `act(session, targetRef, ...)` interacts with targets returned by `observe`
|
|
17
|
+
4. `extract(session, schema)` returns structured JSON from the page when
|
|
18
|
+
you need data instead of actions
|
|
19
|
+
5. `close(session)` ends the browser session
|
|
20
|
+
|
|
21
|
+
The `session` is the key object in the whole API. It is the handle that keeps
|
|
22
|
+
the browser connection and runtime state together between calls.
|
|
23
|
+
|
|
24
|
+
At a high level, AgentBrowse has three kinds of behavior:
|
|
25
|
+
|
|
26
|
+
- normal browser execution for `launch`, `navigate`, `observe`, `act`,
|
|
27
|
+
`status`, `screenshot`, and `close`
|
|
28
|
+
- assistive page understanding for `extract` and some goal-based
|
|
29
|
+
`observe(session, goal)` calls
|
|
30
|
+
- protected fill for applying sensitive values you already have through a
|
|
31
|
+
guarded form execution path
|
|
32
|
+
|
|
33
|
+
Most applications pair these browser primitives with their own orchestration,
|
|
34
|
+
approval, secret, or payment logic.
|
|
35
|
+
|
|
36
|
+
## Managed Launch Note
|
|
37
|
+
|
|
38
|
+
`launch(...)` uses a managed browser session. For that path, the package pulls
|
|
39
|
+
in `puppeteer` for the stealth-enabled connection layer.
|
|
40
|
+
|
|
41
|
+
This is there to reduce unnecessary captcha or anti-bot challenge pages during
|
|
42
|
+
browser startup on sensitive sites.
|
|
43
|
+
|
|
44
|
+
After launch, the normal page interaction flow still runs over Playwright CDP.
|
|
45
|
+
|
|
46
|
+
## Basic Example
|
|
47
|
+
|
|
48
|
+
```ts
|
|
49
|
+
import { act, close, launch, observe } from '@mercuryo-ai/agentbrowse';
|
|
50
|
+
|
|
51
|
+
const launchResult = await launch('https://example.com/login');
|
|
52
|
+
if (!launchResult.success) {
|
|
53
|
+
throw new Error(launchResult.reason ?? launchResult.message);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const { session } = launchResult;
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
const observeResult = await observe(session);
|
|
60
|
+
if (!observeResult.success) {
|
|
61
|
+
throw new Error(observeResult.reason ?? observeResult.message);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const emailTarget = observeResult.targets.find((target) =>
|
|
65
|
+
target.label?.toLowerCase().includes('email')
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (!emailTarget?.ref) {
|
|
69
|
+
throw new Error('Could not find an email field.');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const fillResult = await act(session, emailTarget.ref, 'fill', 'user@example.com');
|
|
73
|
+
if (!fillResult.success) {
|
|
74
|
+
throw new Error(fillResult.reason ?? fillResult.message);
|
|
75
|
+
}
|
|
76
|
+
} finally {
|
|
77
|
+
await close(session);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## What Each Main Command Is For
|
|
82
|
+
|
|
83
|
+
### `launch(url?, options?)`
|
|
84
|
+
|
|
85
|
+
Starts a new browser session. If you pass a URL, AgentBrowse opens it during
|
|
86
|
+
launch.
|
|
87
|
+
|
|
88
|
+
Success result includes:
|
|
89
|
+
|
|
90
|
+
- `session`
|
|
91
|
+
- current `url`
|
|
92
|
+
- current `title`
|
|
93
|
+
|
|
94
|
+
### `attach(cdpUrl, options?)`
|
|
95
|
+
|
|
96
|
+
Connects AgentBrowse to an already running browser over CDP.
|
|
97
|
+
|
|
98
|
+
This is the right entrypoint when:
|
|
99
|
+
|
|
100
|
+
- your app launched Chrome itself;
|
|
101
|
+
- your infrastructure gives you a CDP websocket URL;
|
|
102
|
+
- you are reusing a cloud browser session.
|
|
103
|
+
|
|
104
|
+
Success result includes:
|
|
105
|
+
|
|
106
|
+
- `session`
|
|
107
|
+
- current `url`
|
|
108
|
+
- current `title`
|
|
109
|
+
|
|
110
|
+
### `observe(session, goal?)`
|
|
111
|
+
|
|
112
|
+
Reads the current page and returns what AgentBrowse found.
|
|
113
|
+
|
|
114
|
+
Typical things in the result:
|
|
115
|
+
|
|
116
|
+
- `targets`
|
|
117
|
+
- `scopes`
|
|
118
|
+
- `signals`
|
|
119
|
+
- `fillableForms`
|
|
120
|
+
|
|
121
|
+
Use `observe(session)` when you want a general inventory of the page.
|
|
122
|
+
|
|
123
|
+
Use `observe(session, goal)` when you want a focused answer such as:
|
|
124
|
+
|
|
125
|
+
- `"find the checkout total"`
|
|
126
|
+
- `"find the email field"`
|
|
127
|
+
- `"find the primary continue button"`
|
|
128
|
+
|
|
129
|
+
`observe(session)` and `observe(session, goal)` share the same API, but they
|
|
130
|
+
serve different intents:
|
|
131
|
+
|
|
132
|
+
- `observe(session)` is for general page inspection
|
|
133
|
+
- `observe(session, goal)` is for a focused question
|
|
134
|
+
|
|
135
|
+
### `act(session, targetRef, action, value?)`
|
|
136
|
+
|
|
137
|
+
Executes a browser action against a `targetRef` returned by `observe(...)`.
|
|
138
|
+
|
|
139
|
+
Typical actions:
|
|
140
|
+
|
|
141
|
+
- `click`
|
|
142
|
+
- `fill`
|
|
143
|
+
- `type`
|
|
144
|
+
- `select`
|
|
145
|
+
- `press`
|
|
146
|
+
|
|
147
|
+
### `extract(session, schema, scopeRef?)`
|
|
148
|
+
|
|
149
|
+
Returns structured JSON that matches the schema you provide.
|
|
150
|
+
|
|
151
|
+
Pass either:
|
|
152
|
+
|
|
153
|
+
- a plain schema object such as `{ total: 'number', currency: 'string' }`
|
|
154
|
+
- a Zod schema
|
|
155
|
+
|
|
156
|
+
This is the right tool when you want data, not a browser action.
|
|
157
|
+
|
|
158
|
+
`extract(...)` currently needs an assistive runtime, so you must configure one
|
|
159
|
+
before calling it.
|
|
160
|
+
|
|
161
|
+
### `status(session)`
|
|
162
|
+
|
|
163
|
+
Returns local browser/runtime diagnostics for an existing session.
|
|
164
|
+
|
|
165
|
+
Use it when you want to know whether the browser is still reachable and what
|
|
166
|
+
page AgentBrowse believes it is on.
|
|
167
|
+
|
|
168
|
+
### `close(session)`
|
|
169
|
+
|
|
170
|
+
Closes the browser session.
|
|
171
|
+
|
|
172
|
+
## How To Handle Results
|
|
173
|
+
|
|
174
|
+
All main commands use the same broad pattern:
|
|
175
|
+
|
|
176
|
+
```ts
|
|
177
|
+
const result = await observe(session);
|
|
178
|
+
|
|
179
|
+
if (!result.success) {
|
|
180
|
+
throw new Error(result.reason ?? result.message);
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
If `success` is `true`, the rest of the fields describe the successful outcome.
|
|
185
|
+
|
|
186
|
+
If `success` is `false`, the result tells you:
|
|
187
|
+
|
|
188
|
+
- `error`
|
|
189
|
+
- `message`
|
|
190
|
+
- `reason`
|
|
191
|
+
|
|
192
|
+
You can usually log `message` and use `reason` for debugging or developer logs.
|
|
193
|
+
|
|
194
|
+
## When To Use Assistive Features
|
|
195
|
+
|
|
196
|
+
You do not need an assistive runtime for:
|
|
197
|
+
|
|
198
|
+
- `launch`
|
|
199
|
+
- `attach`
|
|
200
|
+
- `observe(session)` without a goal
|
|
201
|
+
- `navigate`
|
|
202
|
+
- `act`
|
|
203
|
+
- `status`
|
|
204
|
+
- `screenshot`
|
|
205
|
+
- `close`
|
|
206
|
+
|
|
207
|
+
You do need it for:
|
|
208
|
+
|
|
209
|
+
- `extract`
|
|
210
|
+
- better quality goal-based `observe(session, goal)`
|
|
211
|
+
|
|
212
|
+
See:
|
|
213
|
+
|
|
214
|
+
- [Assistive Runtime Guide](./assistive-runtime.md)
|
|
215
|
+
|
|
216
|
+
## Persistence
|
|
217
|
+
|
|
218
|
+
If your process is long-lived, you can keep the `session` in memory and ignore
|
|
219
|
+
disk persistence completely.
|
|
220
|
+
|
|
221
|
+
If you want to restore a browser session between process runs, use:
|
|
222
|
+
|
|
223
|
+
- `saveBrowserSession(session)`
|
|
224
|
+
- `loadBrowserSession()`
|
|
225
|
+
- `createBrowserSessionStore({ rootDir })`
|
|
226
|
+
|
|
227
|
+
See:
|
|
228
|
+
|
|
229
|
+
- [Configuration Guide](./configuration.md)
|
|
230
|
+
|
|
231
|
+
## Next Docs
|
|
232
|
+
|
|
233
|
+
- [API Reference](./api-reference.md)
|
|
234
|
+
- [Configuration Guide](./configuration.md)
|
|
235
|
+
- [Assistive Runtime Guide](./assistive-runtime.md)
|
|
236
|
+
- [Protected Fill Guide](./protected-fill.md)
|
|
237
|
+
- [Troubleshooting](./troubleshooting.md)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# AgentBrowse Integration Checklist
|
|
2
|
+
|
|
3
|
+
Use this checklist when integrating the current `@mercuryo-ai/agentbrowse`
|
|
4
|
+
contract into another package or service.
|
|
5
|
+
|
|
6
|
+
## Core Assumptions
|
|
7
|
+
|
|
8
|
+
- use `observeResult.targets` as the default flat inventory
|
|
9
|
+
- use `target.ref` as the input to `act(...)`
|
|
10
|
+
- pass a plain schema object or a Zod schema to `extract(...)`
|
|
11
|
+
- branch on stable top-level `error` codes, not on `reason`
|
|
12
|
+
- treat `reason` as human-readable diagnostics, not as a stable switch key
|
|
13
|
+
|
|
14
|
+
## Assistive Runtime
|
|
15
|
+
|
|
16
|
+
- the assistive runtime adapter receives `args.options`
|
|
17
|
+
- provider adapters should map `messages`, optional `response_model`, optional
|
|
18
|
+
`image`, and optional `temperature` / `maxOutputTokens`
|
|
19
|
+
- assistive adapters return `{ data, usage? }`
|
|
20
|
+
|
|
21
|
+
## Testing
|
|
22
|
+
|
|
23
|
+
- use `@mercuryo-ai/agentbrowse/testing` for the stable fetch-backed assistive
|
|
24
|
+
runtime helper
|
|
25
|
+
- do not depend on internal fixtures or unexported runtime-state helpers
|
|
26
|
+
|
|
27
|
+
## Packaging
|
|
28
|
+
|
|
29
|
+
- the root library entrypoint does not load `.env`
|
|
30
|
+
- the CLI entrypoint is the only place that loads dotenv support
|
|
31
|
+
- published examples and docs are part of the package contract
|
|
32
|
+
|
|
33
|
+
## Versioning Expectation
|
|
34
|
+
|
|
35
|
+
AgentBrowse is still pre-1.0. Treat minor updates as contract-bearing changes
|
|
36
|
+
and verify this checklist whenever you move to a newer release.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# AgentBrowse Protected Fill Guide
|
|
2
|
+
|
|
3
|
+
Protected fill solves a specific problem:
|
|
4
|
+
|
|
5
|
+
You already have sensitive values from your own approval or secret-management
|
|
6
|
+
flow, and you want AgentBrowse to apply those values to a previously observed
|
|
7
|
+
form in a guarded way.
|
|
8
|
+
|
|
9
|
+
Normal fill and protected fill solve different problems.
|
|
10
|
+
|
|
11
|
+
## When To Use Protected Fill
|
|
12
|
+
|
|
13
|
+
Use protected fill when all of these are true:
|
|
14
|
+
|
|
15
|
+
- you already observed the page and have a form description
|
|
16
|
+
- you already have the sensitive values in your own application
|
|
17
|
+
- you want AgentBrowse to apply them through a typed execution path
|
|
18
|
+
|
|
19
|
+
Examples:
|
|
20
|
+
|
|
21
|
+
- card number, expiry, CVV
|
|
22
|
+
- password or one-time code
|
|
23
|
+
- any field set that should not be treated like ordinary page text input
|
|
24
|
+
|
|
25
|
+
## When A Normal `act(..., 'fill', value)` Is Enough
|
|
26
|
+
|
|
27
|
+
Use ordinary `act(..., 'fill', value)` when:
|
|
28
|
+
|
|
29
|
+
- the value is not sensitive
|
|
30
|
+
- you are filling one simple field directly
|
|
31
|
+
- you do not need form-level guarded execution
|
|
32
|
+
|
|
33
|
+
## What Protected Fill Adds
|
|
34
|
+
|
|
35
|
+
Compared with a normal fill action, protected fill works with:
|
|
36
|
+
|
|
37
|
+
- a previously observed `fillableForm`
|
|
38
|
+
- structured `protectedValues` keyed by field meaning
|
|
39
|
+
- optional `fieldPolicies`
|
|
40
|
+
- typed execution outcomes
|
|
41
|
+
|
|
42
|
+
It also validates that the previously observed form bindings still make sense
|
|
43
|
+
before applying values.
|
|
44
|
+
|
|
45
|
+
## Import
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { fillProtectedForm } from '@mercuryo-ai/agentbrowse/protected-fill';
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Example
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
import { observe } from '@mercuryo-ai/agentbrowse';
|
|
55
|
+
import { fillProtectedForm } from '@mercuryo-ai/agentbrowse/protected-fill';
|
|
56
|
+
|
|
57
|
+
const observeResult = await observe(session);
|
|
58
|
+
if (!observeResult.success) {
|
|
59
|
+
throw new Error(observeResult.reason ?? observeResult.message);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const fillableForm = observeResult.fillableForms.find((form) => form.purpose === 'payment_card');
|
|
63
|
+
if (!fillableForm) {
|
|
64
|
+
throw new Error('Could not find a payment_card form.');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const result = await fillProtectedForm({
|
|
68
|
+
session,
|
|
69
|
+
fillableForm,
|
|
70
|
+
protectedValues: {
|
|
71
|
+
card_number: '4111111111111111',
|
|
72
|
+
exp_month: '12',
|
|
73
|
+
exp_year: '2030',
|
|
74
|
+
cvv: '123',
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
if (!result.success) {
|
|
79
|
+
throw new Error(result.reason ?? result.message);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Where It Fits
|
|
84
|
+
|
|
85
|
+
Protected fill handles the browser execution step.
|
|
86
|
+
|
|
87
|
+
Applications usually pair it with their own:
|
|
88
|
+
|
|
89
|
+
- secret storage
|
|
90
|
+
- approval flow
|
|
91
|
+
- policy decisions
|
|
92
|
+
- claims or grants
|
|
93
|
+
|
|
94
|
+
## What You Need Before Calling It
|
|
95
|
+
|
|
96
|
+
Before protected fill, you usually need:
|
|
97
|
+
|
|
98
|
+
1. a launched browser `session`
|
|
99
|
+
2. a `fillableForm` produced by `observe(...)`
|
|
100
|
+
3. the sensitive values from your own trusted source
|
|
101
|
+
|
|
102
|
+
## Result Shape
|
|
103
|
+
|
|
104
|
+
Protected fill returns a typed result that tells you whether the fill:
|
|
105
|
+
|
|
106
|
+
- succeeded
|
|
107
|
+
- failed because bindings became stale
|
|
108
|
+
- failed validation
|
|
109
|
+
- failed for another execution reason
|
|
110
|
+
|
|
111
|
+
That makes it safer than treating every sensitive field as a raw one-off
|
|
112
|
+
string fill.
|
package/docs/testing.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# AgentBrowse Testing Guide
|
|
2
|
+
|
|
3
|
+
Use the published testing subpath when your package wraps AgentBrowse and you
|
|
4
|
+
need a stable assistive-runtime helper in tests.
|
|
5
|
+
|
|
6
|
+
## Testing Export
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
import {
|
|
10
|
+
installFetchBackedTestAssistiveRuntime,
|
|
11
|
+
uninstallTestAssistiveRuntime,
|
|
12
|
+
} from '@mercuryo-ai/agentbrowse/testing';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## What It Does
|
|
16
|
+
|
|
17
|
+
`installFetchBackedTestAssistiveRuntime(...)` installs a process-global
|
|
18
|
+
assistive runtime that sends structured chat requests over `fetch`.
|
|
19
|
+
|
|
20
|
+
Use it when:
|
|
21
|
+
|
|
22
|
+
- your tests wrap `extract(...)`
|
|
23
|
+
- your tests cover goal-based `observe(session, goal)`
|
|
24
|
+
- your package wants to exercise the current public assistive runtime contract
|
|
25
|
+
|
|
26
|
+
## Example
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import {
|
|
30
|
+
installFetchBackedTestAssistiveRuntime,
|
|
31
|
+
uninstallTestAssistiveRuntime,
|
|
32
|
+
} from '@mercuryo-ai/agentbrowse/testing';
|
|
33
|
+
|
|
34
|
+
beforeEach(() => {
|
|
35
|
+
installFetchBackedTestAssistiveRuntime({
|
|
36
|
+
apiUrl: 'http://127.0.0.1:8787/api',
|
|
37
|
+
apiKey: 'test-key',
|
|
38
|
+
model: 'test-model',
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
uninstallTestAssistiveRuntime();
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Scope
|
|
48
|
+
|
|
49
|
+
This helper is for the assistive runtime contract. It does not mock browser
|
|
50
|
+
sessions, pages, or observed target inventories.
|