@nuanu-ai/agentbrowse 0.2.46 → 0.2.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -10
- package/dist/agentpay-gateway.d.ts +9 -0
- package/dist/agentpay-gateway.d.ts.map +1 -1
- package/dist/agentpay-gateway.js +30 -0
- package/dist/agentpay-stagehand-llm.d.ts.map +1 -1
- package/dist/agentpay-stagehand-llm.js +9 -1
- package/dist/command-api-tracing.d.ts +19 -0
- package/dist/command-api-tracing.d.ts.map +1 -0
- package/dist/command-api-tracing.js +137 -0
- package/dist/commands/act.d.ts.map +1 -1
- package/dist/commands/act.js +822 -670
- package/dist/commands/act.test-harness.d.ts +6 -0
- package/dist/commands/act.test-harness.d.ts.map +1 -1
- package/dist/commands/act.test-harness.js +44 -1
- package/dist/commands/action-acceptance.d.ts.map +1 -1
- package/dist/commands/action-acceptance.js +115 -0
- package/dist/commands/captcha-solve.d.ts.map +1 -1
- package/dist/commands/captcha-solve.js +83 -16
- package/dist/commands/click-action-executor.d.ts +0 -1
- package/dist/commands/click-action-executor.d.ts.map +1 -1
- package/dist/commands/click-action-executor.js +31 -77
- package/dist/commands/close.d.ts +3 -3
- package/dist/commands/close.d.ts.map +1 -1
- package/dist/commands/close.js +178 -0
- package/dist/commands/descriptor-validation.d.ts.map +1 -1
- package/dist/commands/descriptor-validation.js +75 -57
- package/dist/commands/end-session.d.ts +25 -0
- package/dist/commands/end-session.d.ts.map +1 -0
- package/dist/commands/end-session.js +161 -0
- package/dist/commands/extract-stagehand-executor.js +1 -1
- package/dist/commands/extract.d.ts.map +1 -1
- package/dist/commands/extract.js +339 -202
- package/dist/commands/fill-secret.d.ts +3 -3
- package/dist/commands/fill-secret.d.ts.map +1 -1
- package/dist/commands/fill-secret.js +419 -234
- package/dist/commands/get-secrets-catalog.d.ts.map +1 -1
- package/dist/commands/get-secrets-catalog.js +66 -5
- 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 +0 -2
- package/dist/commands/launch.d.ts.map +1 -1
- package/dist/commands/launch.js +109 -17
- package/dist/commands/navigate.d.ts.map +1 -1
- package/dist/commands/navigate.js +188 -45
- package/dist/commands/observe-accessibility.d.ts.map +1 -1
- package/dist/commands/observe-accessibility.js +50 -39
- package/dist/commands/observe-dom-label-contract.d.ts.map +1 -1
- package/dist/commands/observe-dom-label-contract.js +5 -0
- package/dist/commands/observe-inventory.d.ts +13 -0
- package/dist/commands/observe-inventory.d.ts.map +1 -1
- package/dist/commands/observe-inventory.js +320 -65
- package/dist/commands/observe-persistence.d.ts.map +1 -1
- package/dist/commands/observe-persistence.js +3 -0
- package/dist/commands/observe-projection.d.ts +1 -0
- package/dist/commands/observe-projection.d.ts.map +1 -1
- package/dist/commands/observe-projection.js +7 -2
- package/dist/commands/observe-protected.d.ts +1 -0
- package/dist/commands/observe-protected.d.ts.map +1 -1
- package/dist/commands/observe-protected.js +9 -4
- package/dist/commands/observe-semantics.d.ts.map +1 -1
- package/dist/commands/observe-semantics.js +5 -2
- package/dist/commands/observe-stagehand.d.ts +1 -0
- package/dist/commands/observe-stagehand.d.ts.map +1 -1
- package/dist/commands/observe-stagehand.js +2 -0
- package/dist/commands/observe.d.ts +2 -0
- package/dist/commands/observe.d.ts.map +1 -1
- package/dist/commands/observe.js +387 -203
- package/dist/commands/observe.test-harness.d.ts +8 -0
- package/dist/commands/observe.test-harness.d.ts.map +1 -1
- package/dist/commands/observe.test-harness.js +48 -1
- package/dist/commands/poll-secret.d.ts +6 -0
- package/dist/commands/poll-secret.d.ts.map +1 -0
- package/dist/commands/poll-secret.js +159 -0
- package/dist/commands/request-secret.d.ts +6 -0
- package/dist/commands/request-secret.d.ts.map +1 -0
- package/dist/commands/request-secret.js +284 -0
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/commands/screenshot.js +172 -7
- package/dist/commands/select-action-executor.d.ts.map +1 -1
- package/dist/commands/semantic-observe.d.ts +4 -0
- package/dist/commands/semantic-observe.d.ts.map +1 -1
- package/dist/commands/semantic-observe.js +388 -17
- package/dist/commands/start-session.d.ts +31 -0
- package/dist/commands/start-session.d.ts.map +1 -0
- package/dist/commands/start-session.js +347 -0
- package/dist/commands/status.d.ts +2 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +166 -144
- package/dist/control-semantics.d.ts +1 -0
- package/dist/control-semantics.d.ts.map +1 -1
- package/dist/control-semantics.js +51 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +144 -45
- package/dist/otel-exporter.d.ts +58 -0
- package/dist/otel-exporter.d.ts.map +1 -0
- package/dist/otel-exporter.js +263 -0
- package/dist/otel-projector.d.ts +75 -0
- package/dist/otel-projector.d.ts.map +1 -0
- package/dist/otel-projector.js +409 -0
- package/dist/owned-browser.d.ts +1 -1
- package/dist/owned-browser.d.ts.map +1 -1
- package/dist/owned-browser.js +13 -1
- package/dist/owned-process.d.ts +2 -0
- package/dist/owned-process.d.ts.map +1 -1
- package/dist/owned-process.js +7 -3
- package/dist/playwright-runtime.d.ts +1 -1
- package/dist/playwright-runtime.d.ts.map +1 -1
- package/dist/playwright-runtime.js +8 -8
- package/dist/run-observability.d.ts +25 -0
- package/dist/run-observability.d.ts.map +1 -0
- package/dist/run-observability.js +115 -0
- package/dist/run-store.d.ts +274 -0
- package/dist/run-store.d.ts.map +1 -0
- package/dist/run-store.js +631 -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 +16 -0
- package/dist/runtime-protected-state.d.ts.map +1 -0
- package/dist/runtime-protected-state.js +157 -0
- package/dist/runtime-state.d.ts +10 -44
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/runtime-state.js +57 -222
- package/dist/secrets/backend.d.ts +65 -16
- package/dist/secrets/backend.d.ts.map +1 -1
- package/dist/secrets/backend.js +135 -95
- package/dist/secrets/catalog-sync.d.ts.map +1 -1
- package/dist/secrets/catalog-sync.js +4 -1
- package/dist/secrets/form-matcher.d.ts +5 -5
- package/dist/secrets/form-matcher.d.ts.map +1 -1
- package/dist/secrets/form-matcher.js +292 -164
- package/dist/secrets/intent-output.d.ts +6 -10
- package/dist/secrets/intent-output.d.ts.map +1 -1
- package/dist/secrets/intent-output.js +4 -58
- package/dist/secrets/mock-agentpay-cabinet.d.ts +38 -27
- package/dist/secrets/mock-agentpay-cabinet.d.ts.map +1 -1
- package/dist/secrets/mock-agentpay-cabinet.js +177 -111
- package/dist/secrets/protected-artifact-guard.d.ts +2 -2
- package/dist/secrets/protected-artifact-guard.d.ts.map +1 -1
- package/dist/secrets/protected-artifact-guard.js +2 -2
- package/dist/secrets/protected-bindings.d.ts +1 -1
- package/dist/secrets/protected-bindings.d.ts.map +1 -1
- package/dist/secrets/protected-bindings.js +6 -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.map +1 -1
- package/dist/secrets/protected-field-values.js +3 -3
- package/dist/secrets/protected-fill.d.ts +1 -1
- package/dist/secrets/protected-fill.d.ts.map +1 -1
- package/dist/secrets/protected-fill.js +45 -149
- package/dist/secrets/protected-value-adapters.d.ts +2 -1
- package/dist/secrets/protected-value-adapters.d.ts.map +1 -1
- package/dist/secrets/protected-value-adapters.js +80 -1
- package/dist/secrets/request-output.d.ts +11 -0
- package/dist/secrets/request-output.d.ts.map +1 -0
- package/dist/secrets/request-output.js +75 -0
- package/dist/secrets/types.d.ts +15 -9
- package/dist/secrets/types.d.ts.map +1 -1
- package/dist/secrets/types.js +3 -0
- package/dist/session-event-exporter.d.ts +36 -0
- package/dist/session-event-exporter.d.ts.map +1 -0
- package/dist/session-event-exporter.js +428 -0
- package/dist/session.d.ts +16 -7
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +150 -23
- package/dist/sessions-backend.d.ts +354 -0
- package/dist/sessions-backend.d.ts.map +1 -0
- package/dist/sessions-backend.js +126 -0
- package/dist/solver/browser-launcher.d.ts +1 -1
- package/dist/solver/browser-launcher.d.ts.map +1 -1
- package/dist/solver/browser-launcher.js +39 -13
- package/dist/solver/captcha-solver.d.ts.map +1 -1
- package/dist/solver/captcha-solver.js +8 -1
- package/dist/solver/types.d.ts +1 -0
- package/dist/solver/types.d.ts.map +1 -1
- package/dist/workflow-session-completion.d.ts +33 -0
- package/dist/workflow-session-completion.d.ts.map +1 -0
- package/dist/workflow-session-completion.js +156 -0
- package/package.json +9 -1
- package/dist/commands/create-intent.d.ts +0 -6
- package/dist/commands/create-intent.d.ts.map +0 -1
- package/dist/commands/create-intent.js +0 -75
- package/dist/commands/poll-intent.d.ts +0 -6
- package/dist/commands/poll-intent.d.ts.map +0 -1
- package/dist/commands/poll-intent.js +0 -57
package/README.md
CHANGED
|
@@ -60,6 +60,14 @@ agentbrowse launch https://example.com
|
|
|
60
60
|
agentbrowse launch https://example.com --headless
|
|
61
61
|
```
|
|
62
62
|
|
|
63
|
+
When the starting page is already known, prefer `launch <url>` directly to
|
|
64
|
+
that page. Avoid `launch` on a blank tab followed immediately by
|
|
65
|
+
`start-session` and `navigate`, because the first workflow session and timeline
|
|
66
|
+
will otherwise begin on the current page state, often `about:blank`.
|
|
67
|
+
|
|
68
|
+
If an older workflow session is still open in the persisted browser context,
|
|
69
|
+
`launch` cancels that session first before replacing the browser record.
|
|
70
|
+
|
|
63
71
|
By default, `launch` runs in headful mode. Use `--headless` only when you
|
|
64
72
|
intentionally want a hidden browser:
|
|
65
73
|
|
|
@@ -70,7 +78,30 @@ agentbrowse launch https://example.com --headless
|
|
|
70
78
|
If you want to state the default mode explicitly in scripts, use
|
|
71
79
|
`--headful`.
|
|
72
80
|
|
|
73
|
-
|
|
81
|
+
Start workflow session on the current browser, optionally with an explicit
|
|
82
|
+
operator-facing name:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
agentbrowse start-session
|
|
86
|
+
agentbrowse start-session "Acme checkout smoke"
|
|
87
|
+
agentbrowse start-session "Acme checkout smoke" --merchant-name "Acme"
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If a previous workflow session is still active in the persisted browser
|
|
91
|
+
context, re-running `start-session` cancels that older session first and then
|
|
92
|
+
binds a fresh one.
|
|
93
|
+
|
|
94
|
+
Complete the active workflow session without closing the browser:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
agentbrowse end-session
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Use `end-session` for the normal successful workflow close-out. Do not rely on
|
|
101
|
+
`close` to mark a run successful.
|
|
102
|
+
|
|
103
|
+
Navigate current session when you intentionally change URL after the workflow
|
|
104
|
+
already started:
|
|
74
105
|
|
|
75
106
|
```bash
|
|
76
107
|
agentbrowse navigate https://example.com/checkout
|
|
@@ -112,22 +143,26 @@ Inspect or close the current session:
|
|
|
112
143
|
|
|
113
144
|
```bash
|
|
114
145
|
agentbrowse status
|
|
146
|
+
agentbrowse end-session
|
|
115
147
|
agentbrowse close
|
|
116
148
|
```
|
|
117
149
|
|
|
118
|
-
Refresh stored-secret metadata for the current page or a specific URL
|
|
150
|
+
Refresh stored-secret metadata for the current page or a specific URL after
|
|
151
|
+
`start-session`:
|
|
119
152
|
|
|
120
153
|
```bash
|
|
121
154
|
agentbrowse get-secrets-catalog
|
|
122
155
|
agentbrowse get-secrets-catalog https://example.com/checkout
|
|
123
156
|
```
|
|
124
157
|
|
|
125
|
-
Create and complete a protected stored-secret fill
|
|
158
|
+
Create and complete a protected stored-secret fill after `start-session` and
|
|
159
|
+
`observe`:
|
|
126
160
|
|
|
127
161
|
```bash
|
|
128
|
-
agentbrowse
|
|
129
|
-
agentbrowse poll-
|
|
130
|
-
agentbrowse fill-secret f12
|
|
162
|
+
agentbrowse request-secret f12 ss_card_visa --merchant-name "Acme"
|
|
163
|
+
agentbrowse poll-secret sr_123
|
|
164
|
+
agentbrowse fill-secret f12 sr_123
|
|
165
|
+
agentbrowse end-session
|
|
131
166
|
```
|
|
132
167
|
|
|
133
168
|
Solve captcha when the active session supports it:
|
|
@@ -151,6 +186,8 @@ overrides.
|
|
|
151
186
|
## Runtime model
|
|
152
187
|
|
|
153
188
|
- `agentbrowse` persists the active browser session under `~/.agentpay`
|
|
189
|
+
- browser bootstrap lives in `~/.agentpay/browse-session.json`
|
|
190
|
+
- workflow/run context lives in `~/.agentpay/browse-workflow.json`
|
|
154
191
|
- `agentbrowse init` persists AgentPay gateway configuration for future runs
|
|
155
192
|
- mock stored secrets for live/manual runs come from one canonical file:
|
|
156
193
|
`~/.agentpay/mock-stored-secrets.json`
|
|
@@ -158,14 +195,35 @@ overrides.
|
|
|
158
195
|
not an additional runtime config source
|
|
159
196
|
- all commands require AgentPay gateway configuration; prefer `agentbrowse init`
|
|
160
197
|
and use env vars only as runtime overrides
|
|
198
|
+
- `launch` is technical browser bootstrap only; it does not start workflow telemetry, but when the first working page is already known, prefer `launch <url>` so the workflow starts on the real page instead of `about:blank`
|
|
199
|
+
- `launch` fail-closes an older active workflow session before replacing the persisted browser context
|
|
200
|
+
- `start-session` starts the active workflow/run context on top of the current browser session
|
|
201
|
+
- `start-session` creates the backend product session through `POST /api/sessions`
|
|
202
|
+
- `start-session` may optionally attach `merchant_name` when the vendor is already known from the visible page or task context
|
|
203
|
+
- re-running `start-session` fail-closes the older active workflow session through `POST /api/sessions/:id/complete` before creating a new one
|
|
204
|
+
- page/runtime commands such as `navigate`, `observe`, `act`, `extract`, `screenshot`, `status`, `solve-captcha`, `request-secret`, `poll-secret`, and `fill-secret` require that active product session; `launch` alone is not enough
|
|
205
|
+
- use `navigate` for explicit later URL transitions inside an active workflow session, not as a mandatory first step when the initial page is already known
|
|
206
|
+
- `end-session` completes the active workflow session through `POST /api/sessions/:id/complete` and keeps the browser session alive
|
|
207
|
+
- normal successful workflow close-out should use `end-session`; `close` is browser teardown and cancels any still-active workflow session instead of completing it successfully
|
|
208
|
+
- `POST /api/sessions/:id/complete` is the only terminal session transition; ordinary `POST /api/sessions/:id/events` exports are non-terminal by contract
|
|
209
|
+
- the same `start-session` request also carries the current telemetry envelope in the same OTLP structure that browse-cli already exports today
|
|
210
|
+
- backend fan-out forwards that telemetry envelope through the existing telemetry ingest/index/forward path instead of inventing a new telemetry schema from product session fields
|
|
211
|
+
- after `start-session`, ordinary workflow-relevant command step exports go through `POST /api/sessions/:id/events`
|
|
212
|
+
- `status` stays local to the CLI as a diagnostic probe and does not emit workflow session events
|
|
213
|
+
- `close` auto-cancels an active workflow session through `POST /api/sessions/:id/complete` before deleting the local browser session record
|
|
214
|
+
- protected requests are session-bound:
|
|
215
|
+
- `get-secrets-catalog(url?)` reads host-filtered catalog metadata through `GET /api/sessions/:id/secrets/catalog`
|
|
216
|
+
- `request-secret` creates or reuses one request through `POST /api/sessions/:id/secret-requests` and must send `--merchant-name "<vendor>"`
|
|
217
|
+
- `poll-secret` reads request state through `GET /api/sessions/:id/secret-requests/:requestId`
|
|
218
|
+
- `fill-secret` claims the approved one-time payload through `POST /api/sessions/:id/secret-requests/:requestId/claim-secret`
|
|
161
219
|
- the external AI agent remains the orchestration owner
|
|
162
220
|
- `agentbrowse` is a single-step browser toolset, not an internal reactive form loop
|
|
163
221
|
- runtime may enrich `observe` output with semantic hints and validation evidence, but it should not silently auto-submit, auto-retry, or maintain hidden durable field-state machines on behalf of the agent
|
|
164
|
-
- protected fills use an explicit
|
|
222
|
+
- protected fills use an explicit session-first request flow:
|
|
165
223
|
- `get-secrets-catalog(url?)`
|
|
166
|
-
- `
|
|
167
|
-
- `poll-
|
|
168
|
-
- `fill-secret(fillRef,
|
|
224
|
+
- `request-secret(fillRef, storedSecretRef, --merchant-name name)`
|
|
225
|
+
- `poll-secret(requestId)`
|
|
226
|
+
- `fill-secret(fillRef, requestId)`
|
|
169
227
|
- main workflow is:
|
|
170
228
|
- `observe(goal?)`
|
|
171
229
|
- `act(targetRef, action, value?)`
|
|
@@ -203,5 +261,6 @@ See package docs:
|
|
|
203
261
|
|
|
204
262
|
- [Package docs index](https://github.com/nuanu-ai/mercuryo-agent-pay/tree/main/packages/browse-cli/docs)
|
|
205
263
|
- [CLI usage guide](https://github.com/nuanu-ai/mercuryo-agent-pay/blob/main/packages/browse-cli/docs/testing/cli-usage-guide.md)
|
|
264
|
+
- [Tracked PoCs](https://github.com/nuanu-ai/mercuryo-agent-pay/tree/main/packages/browse-cli/poc)
|
|
206
265
|
|
|
207
266
|
Releases are published automatically from `main` after checks pass. `@nuanu-ai/agentbrowse` is the only CLI package published by the current npm release workflow.
|
|
@@ -5,5 +5,14 @@ export interface AgentpayGatewayConfig {
|
|
|
5
5
|
export declare function tryResolveAgentpayGatewayConfig(): AgentpayGatewayConfig | null;
|
|
6
6
|
export declare function resolveAgentpayGatewayConfig(): AgentpayGatewayConfig;
|
|
7
7
|
export declare function applyAgentpayGatewayEnv(gateway: AgentpayGatewayConfig): void;
|
|
8
|
+
export declare function buildAgentpayTelemetryTracesUrl(apiUrl: string): string;
|
|
9
|
+
export declare function buildAgentpaySessionsUrl(apiUrl: string): string;
|
|
10
|
+
export declare function buildAgentpaySessionUrl(apiUrl: string, sessionId: string): string;
|
|
11
|
+
export declare function buildAgentpaySessionSecretsCatalogUrl(apiUrl: string, sessionId: string): string;
|
|
12
|
+
export declare function buildAgentpaySessionEventsUrl(apiUrl: string, sessionId: string): string;
|
|
13
|
+
export declare function buildAgentpayCompleteSessionUrl(apiUrl: string, sessionId: string): string;
|
|
14
|
+
export declare function buildAgentpaySessionSecretRequestsUrl(apiUrl: string, sessionId: string): string;
|
|
15
|
+
export declare function buildAgentpaySessionSecretRequestUrl(apiUrl: string, sessionId: string, requestId: string): string;
|
|
16
|
+
export declare function buildAgentpayClaimSecretUrl(apiUrl: string, sessionId: string, requestId: string): string;
|
|
8
17
|
export declare function preflightAgentpayGateway(): Promise<AgentpayGatewayConfig>;
|
|
9
18
|
//# sourceMappingURL=agentpay-gateway.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentpay-gateway.d.ts","sourceRoot":"","sources":["../src/agentpay-gateway.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;
|
|
1
|
+
{"version":3,"file":"agentpay-gateway.d.ts","sourceRoot":"","sources":["../src/agentpay-gateway.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,qBAAqB;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAgBD,wBAAgB,+BAA+B,IAAI,qBAAqB,GAAG,IAAI,CAgB9E;AAED,wBAAgB,4BAA4B,IAAI,qBAAqB,CAMpE;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,qBAAqB,GAAG,IAAI,CAG5E;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE/D;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEjF;AAED,wBAAgB,qCAAqC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/F;AAED,wBAAgB,6BAA6B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEvF;AAED,wBAAgB,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEzF;AAED,wBAAgB,qCAAqC,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAE/F;AAED,wBAAgB,oCAAoC,CAClD,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CAER;AAED,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAChB,MAAM,CAKR;AAED,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,qBAAqB,CAAC,CAI/E"}
|
package/dist/agentpay-gateway.js
CHANGED
|
@@ -9,6 +9,9 @@ function trimOrUndefined(value) {
|
|
|
9
9
|
function normalizeApiUrl(value) {
|
|
10
10
|
return value.replace(/\/$/, '');
|
|
11
11
|
}
|
|
12
|
+
function appendApiPath(apiUrl, suffix) {
|
|
13
|
+
return `${normalizeApiUrl(apiUrl)}${suffix.startsWith('/') ? suffix : `/${suffix}`}`;
|
|
14
|
+
}
|
|
12
15
|
export function tryResolveAgentpayGatewayConfig() {
|
|
13
16
|
const solverConfig = readConfig();
|
|
14
17
|
const apiKey = trimOrUndefined(process.env.AGENTPAY_API_KEY) || trimOrUndefined(solverConfig.agentpay?.apiKey);
|
|
@@ -34,6 +37,33 @@ export function applyAgentpayGatewayEnv(gateway) {
|
|
|
34
37
|
process.env.AGENTPAY_API_KEY = gateway.apiKey;
|
|
35
38
|
process.env.AGENTPAY_API_URL = gateway.apiUrl;
|
|
36
39
|
}
|
|
40
|
+
export function buildAgentpayTelemetryTracesUrl(apiUrl) {
|
|
41
|
+
return appendApiPath(apiUrl, '/telemetry/traces');
|
|
42
|
+
}
|
|
43
|
+
export function buildAgentpaySessionsUrl(apiUrl) {
|
|
44
|
+
return appendApiPath(apiUrl, '/sessions');
|
|
45
|
+
}
|
|
46
|
+
export function buildAgentpaySessionUrl(apiUrl, sessionId) {
|
|
47
|
+
return appendApiPath(apiUrl, `/sessions/${sessionId}`);
|
|
48
|
+
}
|
|
49
|
+
export function buildAgentpaySessionSecretsCatalogUrl(apiUrl, sessionId) {
|
|
50
|
+
return appendApiPath(apiUrl, `/sessions/${sessionId}/secrets/catalog`);
|
|
51
|
+
}
|
|
52
|
+
export function buildAgentpaySessionEventsUrl(apiUrl, sessionId) {
|
|
53
|
+
return appendApiPath(apiUrl, `/sessions/${sessionId}/events`);
|
|
54
|
+
}
|
|
55
|
+
export function buildAgentpayCompleteSessionUrl(apiUrl, sessionId) {
|
|
56
|
+
return appendApiPath(apiUrl, `/sessions/${sessionId}/complete`);
|
|
57
|
+
}
|
|
58
|
+
export function buildAgentpaySessionSecretRequestsUrl(apiUrl, sessionId) {
|
|
59
|
+
return appendApiPath(apiUrl, `/sessions/${sessionId}/secret-requests`);
|
|
60
|
+
}
|
|
61
|
+
export function buildAgentpaySessionSecretRequestUrl(apiUrl, sessionId, requestId) {
|
|
62
|
+
return appendApiPath(apiUrl, `/sessions/${sessionId}/secret-requests/${requestId}`);
|
|
63
|
+
}
|
|
64
|
+
export function buildAgentpayClaimSecretUrl(apiUrl, sessionId, requestId) {
|
|
65
|
+
return appendApiPath(apiUrl, `/sessions/${sessionId}/secret-requests/${requestId}/claim-secret`);
|
|
66
|
+
}
|
|
37
67
|
export async function preflightAgentpayGateway() {
|
|
38
68
|
const gateway = resolveAgentpayGatewayConfig();
|
|
39
69
|
applyAgentpayGatewayEnv(gateway);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentpay-stagehand-llm.d.ts","sourceRoot":"","sources":["../src/agentpay-stagehand-llm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"agentpay-stagehand-llm.d.ts","sourceRoot":"","sources":["../src/agentpay-stagehand-llm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,YAAY,EACZ,KAAK,2BAA2B,EAChC,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAEjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAoBnE,qBAAa,sCAAuC,SAAQ,KAAK;IAC/D,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;gBAGjC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE;QACN,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;KAC3B;CAWJ;AAsDD,qBAAa,0BAA2B,SAAQ,SAAS;IAI3C,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,IAAI,EAAG,UAAU,CAAU;IAC3B,aAAa,KAAM;gBAEU,OAAO,EAAE,qBAAqB;IAKrD,oBAAoB,CAAC,CAAC,EAC1B,IAAI,EAAE,2BAA2B,GAAG;QAClC,OAAO,EAAE;YACP,cAAc,EAAE;gBACd,IAAI,EAAE,MAAM,CAAC;gBACb,MAAM,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;aAC5C,CAAC;SACH,CAAC;KACH,GACA,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAC1B,oBAAoB,CAAC,CAAC,GAAG,WAAW,EAAE,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,CAAC,CAAC;CAyG3F;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,qBAAqB,GAC7B,0BAA0B,CAE5B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LLMClient, toJsonSchema, } from '@browserbasehq/stagehand';
|
|
2
|
+
import { tracedFetch } from './command-api-tracing.js';
|
|
2
3
|
export class AgentpayStructuredOutputTruncatedError extends Error {
|
|
3
4
|
status;
|
|
4
5
|
provider;
|
|
@@ -102,7 +103,7 @@ export class AgentpayStagehandLlmClient extends LLMClient {
|
|
|
102
103
|
const result = await withRetry(async () => {
|
|
103
104
|
let response;
|
|
104
105
|
try {
|
|
105
|
-
response = await
|
|
106
|
+
response = await tracedFetch(url, {
|
|
106
107
|
method: 'POST',
|
|
107
108
|
headers: {
|
|
108
109
|
Authorization: `Bearer ${this.gateway.apiKey}`,
|
|
@@ -111,6 +112,13 @@ export class AgentpayStagehandLlmClient extends LLMClient {
|
|
|
111
112
|
},
|
|
112
113
|
body: JSON.stringify(body),
|
|
113
114
|
signal: AbortSignal.timeout(45_000),
|
|
115
|
+
}, {
|
|
116
|
+
spanName: 'agentpay.llm.structured_chat',
|
|
117
|
+
attributes: {
|
|
118
|
+
'agentbrowse.api.system': 'agentpay',
|
|
119
|
+
'agentbrowse.api.purpose': body.purpose,
|
|
120
|
+
'agentbrowse.api.route': '/tools/llm/structured-chat',
|
|
121
|
+
},
|
|
114
122
|
});
|
|
115
123
|
}
|
|
116
124
|
catch (err) {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type ApiTraceContext = {
|
|
2
|
+
runId?: string;
|
|
3
|
+
stepId?: string;
|
|
4
|
+
command: string;
|
|
5
|
+
};
|
|
6
|
+
type TracedFetchOptions = {
|
|
7
|
+
spanName: string;
|
|
8
|
+
attributes?: Record<string, unknown>;
|
|
9
|
+
fetchImpl?: typeof fetch;
|
|
10
|
+
};
|
|
11
|
+
type TracedStepOperationOptions = {
|
|
12
|
+
spanName: string;
|
|
13
|
+
attributes?: Record<string, unknown>;
|
|
14
|
+
};
|
|
15
|
+
export declare function withApiTraceContext<T>(context: ApiTraceContext, run: () => Promise<T>): Promise<T>;
|
|
16
|
+
export declare function tracedStepOperation<T>(run: () => Promise<T> | T, options?: TracedStepOperationOptions): Promise<T>;
|
|
17
|
+
export declare function tracedFetch(input: RequestInfo | URL, init?: RequestInit, options?: TracedFetchOptions): Promise<Response>;
|
|
18
|
+
export {};
|
|
19
|
+
//# sourceMappingURL=command-api-tracing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-api-tracing.d.ts","sourceRoot":"","sources":["../src/command-api-tracing.ts"],"names":[],"mappings":"AAGA,KAAK,eAAe,GAAG;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B,CAAC;AAEF,KAAK,0BAA0B,GAAG;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACtC,CAAC;AAoEF,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,OAAO,EAAE,eAAe,EACxB,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GACpB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAED,wBAAsB,mBAAmB,CAAC,CAAC,EACzC,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,EACzB,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,CAAC,CAAC,CAqCZ;AAED,wBAAsB,WAAW,CAC/B,KAAK,EAAE,WAAW,GAAG,GAAG,EACxB,IAAI,CAAC,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,QAAQ,CAAC,CAuCnB"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { appendStepChildSpan } from './run-store.js';
|
|
3
|
+
const apiTraceContextStorage = new AsyncLocalStorage();
|
|
4
|
+
function sanitizeTraceUrl(value) {
|
|
5
|
+
try {
|
|
6
|
+
const parsed = new URL(value);
|
|
7
|
+
parsed.username = '';
|
|
8
|
+
parsed.password = '';
|
|
9
|
+
parsed.search = '';
|
|
10
|
+
parsed.hash = '';
|
|
11
|
+
return parsed.toString();
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function resolveMethod(input, init) {
|
|
18
|
+
const initMethod = init?.method?.trim();
|
|
19
|
+
if (initMethod) {
|
|
20
|
+
return initMethod.toUpperCase();
|
|
21
|
+
}
|
|
22
|
+
if (typeof Request !== 'undefined' && input instanceof Request) {
|
|
23
|
+
return input.method.toUpperCase();
|
|
24
|
+
}
|
|
25
|
+
return 'GET';
|
|
26
|
+
}
|
|
27
|
+
function resolveUrl(input) {
|
|
28
|
+
if (input instanceof URL) {
|
|
29
|
+
return input.toString();
|
|
30
|
+
}
|
|
31
|
+
if (typeof input === 'string') {
|
|
32
|
+
return input;
|
|
33
|
+
}
|
|
34
|
+
if (typeof Request !== 'undefined' && input instanceof Request) {
|
|
35
|
+
return input.url;
|
|
36
|
+
}
|
|
37
|
+
return String(input);
|
|
38
|
+
}
|
|
39
|
+
function buildTraceAttributes(context, input, init, extraAttributes) {
|
|
40
|
+
const url = resolveUrl(input);
|
|
41
|
+
const method = resolveMethod(input, init);
|
|
42
|
+
let hostname;
|
|
43
|
+
let pathname;
|
|
44
|
+
try {
|
|
45
|
+
const parsed = new URL(url);
|
|
46
|
+
hostname = parsed.host;
|
|
47
|
+
pathname = parsed.pathname;
|
|
48
|
+
}
|
|
49
|
+
catch { }
|
|
50
|
+
return {
|
|
51
|
+
'agentbrowse.api.command': context.command,
|
|
52
|
+
'http.request.method': method,
|
|
53
|
+
'url.full': sanitizeTraceUrl(url),
|
|
54
|
+
...(hostname ? { 'server.address': hostname } : {}),
|
|
55
|
+
...(pathname ? { 'url.path': pathname } : {}),
|
|
56
|
+
...(extraAttributes ?? {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export async function withApiTraceContext(context, run) {
|
|
60
|
+
return apiTraceContextStorage.run(context, run);
|
|
61
|
+
}
|
|
62
|
+
export async function tracedStepOperation(run, options) {
|
|
63
|
+
const context = apiTraceContextStorage.getStore();
|
|
64
|
+
if (!context?.runId || !context.stepId || !options?.spanName) {
|
|
65
|
+
return run();
|
|
66
|
+
}
|
|
67
|
+
const startedAt = new Date().toISOString();
|
|
68
|
+
const attributes = {
|
|
69
|
+
'agentbrowse.api.command': context.command,
|
|
70
|
+
...(options.attributes ?? {}),
|
|
71
|
+
};
|
|
72
|
+
try {
|
|
73
|
+
const result = await run();
|
|
74
|
+
appendStepChildSpan({
|
|
75
|
+
runId: context.runId,
|
|
76
|
+
stepId: context.stepId,
|
|
77
|
+
name: options.spanName,
|
|
78
|
+
startedAt,
|
|
79
|
+
endedAt: new Date().toISOString(),
|
|
80
|
+
statusCode: 'ok',
|
|
81
|
+
attributes,
|
|
82
|
+
});
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
appendStepChildSpan({
|
|
87
|
+
runId: context.runId,
|
|
88
|
+
stepId: context.stepId,
|
|
89
|
+
name: options.spanName,
|
|
90
|
+
startedAt,
|
|
91
|
+
endedAt: new Date().toISOString(),
|
|
92
|
+
statusCode: 'error',
|
|
93
|
+
statusMessage: error instanceof Error ? error.message : String(error),
|
|
94
|
+
attributes,
|
|
95
|
+
});
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
export async function tracedFetch(input, init, options) {
|
|
100
|
+
const fetchImpl = options?.fetchImpl ?? fetch;
|
|
101
|
+
const context = apiTraceContextStorage.getStore();
|
|
102
|
+
if (!context?.runId || !context.stepId || !options?.spanName) {
|
|
103
|
+
return fetchImpl(input, init);
|
|
104
|
+
}
|
|
105
|
+
const startedAt = new Date().toISOString();
|
|
106
|
+
const attributes = buildTraceAttributes(context, input, init, options.attributes);
|
|
107
|
+
try {
|
|
108
|
+
const response = await fetchImpl(input, init);
|
|
109
|
+
appendStepChildSpan({
|
|
110
|
+
runId: context.runId,
|
|
111
|
+
stepId: context.stepId,
|
|
112
|
+
name: options.spanName,
|
|
113
|
+
startedAt,
|
|
114
|
+
endedAt: new Date().toISOString(),
|
|
115
|
+
statusCode: response.ok ? 'ok' : 'error',
|
|
116
|
+
...(response.ok ? {} : { statusMessage: `http_${response.status}` }),
|
|
117
|
+
attributes: {
|
|
118
|
+
...attributes,
|
|
119
|
+
'http.response.status_code': response.status,
|
|
120
|
+
},
|
|
121
|
+
});
|
|
122
|
+
return response;
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
appendStepChildSpan({
|
|
126
|
+
runId: context.runId,
|
|
127
|
+
stepId: context.stepId,
|
|
128
|
+
name: options.spanName,
|
|
129
|
+
startedAt,
|
|
130
|
+
endedAt: new Date().toISOString(),
|
|
131
|
+
statusCode: 'error',
|
|
132
|
+
statusMessage: error instanceof Error ? error.message : String(error),
|
|
133
|
+
attributes,
|
|
134
|
+
});
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/commands/act.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/commands/act.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAiCnD,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAiNxF,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC1C,YAAY,EAAE,YAAY,EAAE,CAAC;AAkR7B,wBAAsB,GAAG,CACvB,OAAO,EAAE,aAAa,EACtB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CA01Bf"}
|