@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,149 @@
|
|
|
1
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
2
|
+
import { recordDiagnosticChildSpanBestEffort } from './diagnostics.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
|
+
recordDiagnosticChildSpanBestEffort({
|
|
75
|
+
step: {
|
|
76
|
+
runId: context.runId,
|
|
77
|
+
stepId: context.stepId,
|
|
78
|
+
command: context.command,
|
|
79
|
+
},
|
|
80
|
+
name: options.spanName,
|
|
81
|
+
startedAt,
|
|
82
|
+
endedAt: new Date().toISOString(),
|
|
83
|
+
statusCode: 'ok',
|
|
84
|
+
attributes,
|
|
85
|
+
});
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
recordDiagnosticChildSpanBestEffort({
|
|
90
|
+
step: {
|
|
91
|
+
runId: context.runId,
|
|
92
|
+
stepId: context.stepId,
|
|
93
|
+
command: context.command,
|
|
94
|
+
},
|
|
95
|
+
name: options.spanName,
|
|
96
|
+
startedAt,
|
|
97
|
+
endedAt: new Date().toISOString(),
|
|
98
|
+
statusCode: 'error',
|
|
99
|
+
statusMessage: error instanceof Error ? error.message : String(error),
|
|
100
|
+
attributes,
|
|
101
|
+
});
|
|
102
|
+
throw error;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
export async function tracedFetch(input, init, options) {
|
|
106
|
+
const fetchImpl = options?.fetchImpl ?? fetch;
|
|
107
|
+
const context = apiTraceContextStorage.getStore();
|
|
108
|
+
if (!context?.runId || !context.stepId || !options?.spanName) {
|
|
109
|
+
return fetchImpl(input, init);
|
|
110
|
+
}
|
|
111
|
+
const startedAt = new Date().toISOString();
|
|
112
|
+
const attributes = buildTraceAttributes(context, input, init, options.attributes);
|
|
113
|
+
try {
|
|
114
|
+
const response = await fetchImpl(input, init);
|
|
115
|
+
recordDiagnosticChildSpanBestEffort({
|
|
116
|
+
step: {
|
|
117
|
+
runId: context.runId,
|
|
118
|
+
stepId: context.stepId,
|
|
119
|
+
command: context.command,
|
|
120
|
+
},
|
|
121
|
+
name: options.spanName,
|
|
122
|
+
startedAt,
|
|
123
|
+
endedAt: new Date().toISOString(),
|
|
124
|
+
statusCode: response.ok ? 'ok' : 'error',
|
|
125
|
+
...(response.ok ? {} : { statusMessage: `http_${response.status}` }),
|
|
126
|
+
attributes: {
|
|
127
|
+
...attributes,
|
|
128
|
+
'http.response.status_code': response.status,
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
return response;
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
recordDiagnosticChildSpanBestEffort({
|
|
135
|
+
step: {
|
|
136
|
+
runId: context.runId,
|
|
137
|
+
stepId: context.stepId,
|
|
138
|
+
command: context.command,
|
|
139
|
+
},
|
|
140
|
+
name: options.spanName,
|
|
141
|
+
startedAt,
|
|
142
|
+
endedAt: new Date().toISOString(),
|
|
143
|
+
statusCode: 'error',
|
|
144
|
+
statusMessage: error instanceof Error ? error.message : String(error),
|
|
145
|
+
attributes,
|
|
146
|
+
});
|
|
147
|
+
throw error;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-name.d.ts","sourceRoot":"","sources":["../src/command-name.ts"],"names":[],"mappings":"AAOA,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wBAAgB,aAAa,CAAC,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAEvD"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const DEFAULT_BROWSE_COMMAND = 'agentbrowse';
|
|
2
|
+
function normalizeCommandName(value, fallback) {
|
|
3
|
+
const normalized = value?.trim().replace(/\s+/g, ' ');
|
|
4
|
+
return normalized && normalized.length > 0 ? normalized : fallback;
|
|
5
|
+
}
|
|
6
|
+
export function browseCommandName() {
|
|
7
|
+
return normalizeCommandName(process.env.AGENTBROWSE_COMMAND, DEFAULT_BROWSE_COMMAND);
|
|
8
|
+
}
|
|
9
|
+
export function browseCommand(...args) {
|
|
10
|
+
return [browseCommandName(), ...args].join(' ');
|
|
11
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* browse act <targetRef> <action> [value] — Perform a deterministic action on a stored target.
|
|
3
|
+
*/
|
|
4
|
+
import type { BrowserCommandSession } from '../browser-session-state.js';
|
|
5
|
+
import { type BrowseContractFailure, type BrowseResult } from '../output.js';
|
|
6
|
+
import { BROWSE_ACTIONS, type BrowseAction, isBrowseAction } from './browse-actions.js';
|
|
7
|
+
/** Stable top-level error codes returned by `act(...)`. */
|
|
8
|
+
export declare const ACT_ERROR_CODES: readonly ["act_failed", "action_not_allowed_for_target", "browser_connection_failed", "no_observable_progress", "stale_target", "stale_target_ref", "target_disabled", "target_gated", "target_not_actionable", "target_readonly", "target_surface_inactive", "target_surface_not_live", "target_surface_unavailable", "unknown_target_ref", "validation_blocked"];
|
|
9
|
+
/** Stable outcome categories emitted by `act(...)`. */
|
|
10
|
+
export declare const ACT_OUTCOME_TYPES: readonly ["action_completed", "binding_stale", "blocked", "partial_progress", "unsupported"];
|
|
11
|
+
export type ActErrorCode = (typeof ACT_ERROR_CODES)[number];
|
|
12
|
+
export type ActOutcomeType = (typeof ACT_OUTCOME_TYPES)[number];
|
|
13
|
+
/** Successful deterministic action result. */
|
|
14
|
+
export type ActSuccessResult = BrowseResult & {
|
|
15
|
+
success: true;
|
|
16
|
+
targetRef: string;
|
|
17
|
+
action: BrowseAction;
|
|
18
|
+
};
|
|
19
|
+
/** Contract-time failure raised before a browser action is attempted. */
|
|
20
|
+
export type ActPreflightFailureResult = BrowseContractFailure & {
|
|
21
|
+
success: false;
|
|
22
|
+
failureSurface: 'contract';
|
|
23
|
+
error: ActErrorCode;
|
|
24
|
+
outcomeType: Extract<ActOutcomeType, 'binding_stale' | 'blocked' | 'unsupported'>;
|
|
25
|
+
targetRef: string;
|
|
26
|
+
action: BrowseAction;
|
|
27
|
+
};
|
|
28
|
+
/** Runtime failure raised after AgentBrowse attempted the browser action. */
|
|
29
|
+
export type ActExecutionFailureResult = BrowseResult & {
|
|
30
|
+
success: false;
|
|
31
|
+
failureSurface: 'output';
|
|
32
|
+
error: ActErrorCode;
|
|
33
|
+
outcomeType: Extract<ActOutcomeType, 'binding_stale' | 'blocked'>;
|
|
34
|
+
targetRef: string;
|
|
35
|
+
action: BrowseAction;
|
|
36
|
+
};
|
|
37
|
+
export type ActFailureResult = ActPreflightFailureResult | ActExecutionFailureResult;
|
|
38
|
+
export type ActResult = ActSuccessResult | ActFailureResult;
|
|
39
|
+
export { BROWSE_ACTIONS, isBrowseAction };
|
|
40
|
+
export type { BrowseAction };
|
|
41
|
+
export declare function actBrowser(session: BrowserCommandSession, targetRef: string, action: BrowseAction, value?: string): Promise<ActResult>;
|
|
42
|
+
export declare function act(session: BrowserCommandSession, targetRef: string, action: BrowseAction, value?: string): Promise<void>;
|
|
43
|
+
//# sourceMappingURL=act.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"act.d.ts","sourceRoot":"","sources":["../../src/commands/act.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAYzE,OAAO,EAIL,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AA6BtB,OAAO,EAAE,cAAc,EAAE,KAAK,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA4CxF,2DAA2D;AAC3D,eAAO,MAAM,eAAe,oWAgBlB,CAAC;AAEX,uDAAuD;AACvD,eAAO,MAAM,iBAAiB,8FAMpB,CAAC;AAEX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAC5D,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEhE,8CAA8C;AAC9C,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG;IAC5C,OAAO,EAAE,IAAI,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,yEAAyE;AACzE,MAAM,MAAM,yBAAyB,GAAG,qBAAqB,GAAG;IAC9D,OAAO,EAAE,KAAK,CAAC;IACf,cAAc,EAAE,UAAU,CAAC;IAC3B,KAAK,EAAE,YAAY,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC,cAAc,EAAE,eAAe,GAAG,SAAS,GAAG,aAAa,CAAC,CAAC;IAClF,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,yBAAyB,GAAG,YAAY,GAAG;IACrD,OAAO,EAAE,KAAK,CAAC;IACf,cAAc,EAAE,QAAQ,CAAC;IACzB,KAAK,EAAE,YAAY,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC,cAAc,EAAE,eAAe,GAAG,SAAS,CAAC,CAAC;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,yBAAyB,GAAG,yBAAyB,CAAC;AAErF,MAAM,MAAM,SAAS,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;AAmK5D,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,CAAC;AAC1C,YAAY,EAAE,YAAY,EAAE,CAAC;AA+Q7B,wBAAsB,UAAU,CAC9B,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,SAAS,CAAC,CAg2BpB;AAED,wBAAsB,GAAG,CACvB,OAAO,EAAE,qBAAqB,EAC9B,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,YAAY,EACpB,KAAK,CAAC,EAAE,MAAM,GACb,OAAO,CAAC,IAAI,CAAC,CAaf"}
|