@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 @@
|
|
|
1
|
+
{"version":3,"file":"protected-fill.d.ts","sourceRoot":"","sources":["../src/protected-fill.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { fillProtectedFormBrowser, } from "./protected-fill-browser.js";
|
|
2
|
+
import { buildProtectedExactValueProfile as buildProtectedExactValueProfileInternal } from "./secrets/protected-exact-value-redaction.js";
|
|
3
|
+
/** Fills a previously observed protected form with caller-provided protected values. */
|
|
4
|
+
export async function fillProtectedForm(params) {
|
|
5
|
+
return (await fillProtectedFormBrowser({
|
|
6
|
+
session: params.session,
|
|
7
|
+
fillableForm: params.fillableForm,
|
|
8
|
+
protectedValues: params.protectedValues,
|
|
9
|
+
fieldPolicies: params.fieldPolicies,
|
|
10
|
+
}));
|
|
11
|
+
}
|
|
12
|
+
export function buildProtectedExposureArtifacts(params) {
|
|
13
|
+
const filteredProtectedValues = Object.fromEntries(Object.entries(params.protectedValues).filter((entry) => {
|
|
14
|
+
const value = entry[1];
|
|
15
|
+
return typeof value === "string" && value.length > 0;
|
|
16
|
+
}));
|
|
17
|
+
return {
|
|
18
|
+
exactValueProfile: buildProtectedExactValueProfileInternal(filteredProtectedValues),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BrowserSessionState } from './browser-session-state.js';
|
|
2
|
+
import { type BrowsePayloadBudgetMetrics, type BrowseRuntimeMetrics } from './runtime-state.js';
|
|
3
|
+
type NumericBrowseRuntimeMetricKey = Exclude<{
|
|
4
|
+
[K in keyof BrowseRuntimeMetrics]: BrowseRuntimeMetrics[K] extends number | undefined ? K : never;
|
|
5
|
+
}[keyof BrowseRuntimeMetrics], undefined>;
|
|
6
|
+
type LlmUsageLike = Partial<{
|
|
7
|
+
prompt_tokens: number;
|
|
8
|
+
completion_tokens: number;
|
|
9
|
+
total_tokens: number;
|
|
10
|
+
cached_input_tokens: number;
|
|
11
|
+
reasoning_tokens: number;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function incrementMetric(session: BrowserSessionState, metric: NumericBrowseRuntimeMetricKey, by?: number): number;
|
|
14
|
+
export declare function recordActionResult(session: BrowserSessionState, success: boolean, durationMs: number): BrowseRuntimeMetrics;
|
|
15
|
+
export declare function recordLlmUsage(session: BrowserSessionState, params: {
|
|
16
|
+
purpose: string;
|
|
17
|
+
usage?: LlmUsageLike | null;
|
|
18
|
+
inputChars?: number;
|
|
19
|
+
promptTokens?: number;
|
|
20
|
+
completionTokens?: number;
|
|
21
|
+
totalTokens?: number;
|
|
22
|
+
cachedInputTokens?: number;
|
|
23
|
+
reasoningTokens?: number;
|
|
24
|
+
}): BrowseRuntimeMetrics;
|
|
25
|
+
export declare function recordPayloadBudget(session: BrowserSessionState, patch: Partial<BrowsePayloadBudgetMetrics>): BrowseRuntimeMetrics;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=runtime-metrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-metrics.d.ts","sourceRoot":"","sources":["../src/runtime-metrics.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAKL,KAAK,0BAA0B,EAC/B,KAAK,oBAAoB,EAC1B,MAAM,oBAAoB,CAAC;AAE5B,KAAK,6BAA6B,GAAG,OAAO,CAC1C;KACG,CAAC,IAAI,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,CAAC,CAAC,SAAS,MAAM,GAAG,SAAS,GACjF,CAAC,GACD,KAAK;CACV,CAAC,MAAM,oBAAoB,CAAC,EAC7B,SAAS,CACV,CAAC;AAEF,KAAK,YAAY,GAAG,OAAO,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;CAC1B,CAAC,CAAC;AAEH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,6BAA6B,EACrC,EAAE,SAAI,GACL,MAAM,CAIR;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,MAAM,GACjB,oBAAoB,CAetB;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE;IACN,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,GACA,oBAAoB,CAmCtB;AAED,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,mBAAmB,EAC5B,KAAK,EAAE,OAAO,CAAC,0BAA0B,CAAC,GACzC,oBAAoB,CAgBtB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createLlmUsageBucket, createPayloadBudgetMetrics, ensureMetricsExtensions, ensureRuntimeState, } from './runtime-state.js';
|
|
2
|
+
export function incrementMetric(session, metric, by = 1) {
|
|
3
|
+
const runtime = ensureRuntimeState(session);
|
|
4
|
+
runtime.metrics[metric] = (runtime.metrics[metric] ?? 0) + by;
|
|
5
|
+
return runtime.metrics[metric] ?? 0;
|
|
6
|
+
}
|
|
7
|
+
export function recordActionResult(session, success, durationMs) {
|
|
8
|
+
const runtime = ensureRuntimeState(session);
|
|
9
|
+
ensureMetricsExtensions(runtime.metrics);
|
|
10
|
+
if (success) {
|
|
11
|
+
runtime.metrics.successfulActions += 1;
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
runtime.metrics.failedActions += 1;
|
|
15
|
+
}
|
|
16
|
+
runtime.metrics.totalActionDurationMs += Math.max(0, durationMs);
|
|
17
|
+
const attempts = runtime.metrics.successfulActions + runtime.metrics.failedActions;
|
|
18
|
+
runtime.metrics.successRate = attempts === 0 ? 0 : runtime.metrics.successfulActions / attempts;
|
|
19
|
+
runtime.metrics.averageActionDurationMs =
|
|
20
|
+
attempts === 0 ? 0 : runtime.metrics.totalActionDurationMs / attempts;
|
|
21
|
+
return runtime.metrics;
|
|
22
|
+
}
|
|
23
|
+
export function recordLlmUsage(session, params) {
|
|
24
|
+
const runtime = ensureRuntimeState(session);
|
|
25
|
+
ensureMetricsExtensions(runtime.metrics);
|
|
26
|
+
const promptTokens = params.promptTokens ?? params.usage?.prompt_tokens ?? 0;
|
|
27
|
+
const completionTokens = params.completionTokens ?? params.usage?.completion_tokens ?? 0;
|
|
28
|
+
const totalTokens = params.totalTokens ??
|
|
29
|
+
params.usage?.total_tokens ??
|
|
30
|
+
(promptTokens > 0 || completionTokens > 0 ? promptTokens + completionTokens : 0);
|
|
31
|
+
const cachedInputTokens = params.cachedInputTokens ?? params.usage?.cached_input_tokens ?? 0;
|
|
32
|
+
const reasoningTokens = params.reasoningTokens ?? params.usage?.reasoning_tokens ?? 0;
|
|
33
|
+
const inputChars = params.inputChars ?? 0;
|
|
34
|
+
runtime.metrics.llmCalls = (runtime.metrics.llmCalls ?? 0) + 1;
|
|
35
|
+
runtime.metrics.llmPromptTokens = (runtime.metrics.llmPromptTokens ?? 0) + promptTokens;
|
|
36
|
+
runtime.metrics.llmCompletionTokens =
|
|
37
|
+
(runtime.metrics.llmCompletionTokens ?? 0) + completionTokens;
|
|
38
|
+
runtime.metrics.llmTotalTokens = (runtime.metrics.llmTotalTokens ?? 0) + totalTokens;
|
|
39
|
+
runtime.metrics.llmCachedInputTokens =
|
|
40
|
+
(runtime.metrics.llmCachedInputTokens ?? 0) + cachedInputTokens;
|
|
41
|
+
runtime.metrics.llmReasoningTokens = (runtime.metrics.llmReasoningTokens ?? 0) + reasoningTokens;
|
|
42
|
+
const purposeKey = params.purpose.trim().length > 0 ? params.purpose.trim() : 'unknown';
|
|
43
|
+
const bucket = runtime.metrics.llmUsageByPurpose?.[purposeKey] ?? createLlmUsageBucket();
|
|
44
|
+
bucket.calls += 1;
|
|
45
|
+
bucket.inputChars += inputChars;
|
|
46
|
+
bucket.promptTokens += promptTokens;
|
|
47
|
+
bucket.completionTokens += completionTokens;
|
|
48
|
+
bucket.totalTokens += totalTokens;
|
|
49
|
+
bucket.cachedInputTokens += cachedInputTokens;
|
|
50
|
+
bucket.reasoningTokens += reasoningTokens;
|
|
51
|
+
runtime.metrics.llmUsageByPurpose[purposeKey] = bucket;
|
|
52
|
+
return runtime.metrics;
|
|
53
|
+
}
|
|
54
|
+
export function recordPayloadBudget(session, patch) {
|
|
55
|
+
const runtime = ensureRuntimeState(session);
|
|
56
|
+
ensureMetricsExtensions(runtime.metrics);
|
|
57
|
+
const payloadBudget = runtime.metrics.payloadBudget ?? createPayloadBudgetMetrics();
|
|
58
|
+
for (const [key, value] of Object.entries(patch)) {
|
|
59
|
+
if (!Number.isFinite(value)) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
payloadBudget[key] += value ?? 0;
|
|
63
|
+
}
|
|
64
|
+
runtime.metrics.payloadBudget = payloadBudget;
|
|
65
|
+
return runtime.metrics;
|
|
66
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { BrowserSessionState } from './browser-session-state.js';
|
|
2
|
+
import { type BrowsePageState } from './runtime-state.js';
|
|
3
|
+
export declare function registerPage(session: BrowserSessionState, page?: Partial<Omit<BrowsePageState, 'pageRef' | 'createdAt' | 'updatedAt'>> & {
|
|
4
|
+
pageRef?: string;
|
|
5
|
+
makeCurrent?: boolean;
|
|
6
|
+
}): BrowsePageState;
|
|
7
|
+
export declare function updatePage(session: BrowserSessionState, pageRef: string, patch: Partial<Omit<BrowsePageState, 'pageRef' | 'createdAt' | 'updatedAt'>>): BrowsePageState;
|
|
8
|
+
export declare function getPageScopeEpoch(session: BrowserSessionState, pageRef: string): number;
|
|
9
|
+
export declare function bumpPageScopeEpoch(session: BrowserSessionState, pageRef: string): number;
|
|
10
|
+
export declare function setCurrentPage(session: BrowserSessionState, pageRef: string): void;
|
|
11
|
+
//# sourceMappingURL=runtime-page-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-page-state.d.ts","sourceRoot":"","sources":["../src/runtime-page-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAsB,KAAK,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE9E,wBAAgB,YAAY,CAC1B,OAAO,EAAE,mBAAmB,EAC5B,IAAI,GAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC,CAAC,GAAG;IAC5E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;CAClB,GACL,eAAe,CAsBjB;AAED,wBAAgB,UAAU,CACxB,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,SAAS,GAAG,WAAW,GAAG,WAAW,CAAC,CAAC,GAC3E,eAAe,CAejB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAGvF;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAcxF;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAMlF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ensureRuntimeState } from './runtime-state.js';
|
|
2
|
+
export function registerPage(session, page = {}) {
|
|
3
|
+
const runtime = ensureRuntimeState(session);
|
|
4
|
+
const pageRef = page.pageRef ?? `p${runtime.counters.nextPage++}`;
|
|
5
|
+
const now = new Date().toISOString();
|
|
6
|
+
const existing = runtime.pages[pageRef];
|
|
7
|
+
const nextPage = {
|
|
8
|
+
pageRef,
|
|
9
|
+
createdAt: existing?.createdAt ?? now,
|
|
10
|
+
updatedAt: now,
|
|
11
|
+
url: page.url ?? existing?.url,
|
|
12
|
+
title: page.title ?? existing?.title,
|
|
13
|
+
targetId: page.targetId ?? existing?.targetId,
|
|
14
|
+
openerPageRef: page.openerPageRef ?? existing?.openerPageRef,
|
|
15
|
+
scopeEpoch: existing?.scopeEpoch ?? 0,
|
|
16
|
+
};
|
|
17
|
+
runtime.pages[pageRef] = nextPage;
|
|
18
|
+
if (page.makeCurrent !== false) {
|
|
19
|
+
runtime.currentPageRef = pageRef;
|
|
20
|
+
}
|
|
21
|
+
return nextPage;
|
|
22
|
+
}
|
|
23
|
+
export function updatePage(session, pageRef, patch) {
|
|
24
|
+
const runtime = ensureRuntimeState(session);
|
|
25
|
+
const current = runtime.pages[pageRef];
|
|
26
|
+
if (!current) {
|
|
27
|
+
throw new Error(`unknown_page_ref: ${pageRef}`);
|
|
28
|
+
}
|
|
29
|
+
const nextPage = {
|
|
30
|
+
...current,
|
|
31
|
+
...patch,
|
|
32
|
+
scopeEpoch: patch.scopeEpoch ?? current.scopeEpoch ?? 0,
|
|
33
|
+
updatedAt: new Date().toISOString(),
|
|
34
|
+
};
|
|
35
|
+
runtime.pages[pageRef] = nextPage;
|
|
36
|
+
return nextPage;
|
|
37
|
+
}
|
|
38
|
+
export function getPageScopeEpoch(session, pageRef) {
|
|
39
|
+
const runtime = ensureRuntimeState(session);
|
|
40
|
+
return runtime.pages[pageRef]?.scopeEpoch ?? 0;
|
|
41
|
+
}
|
|
42
|
+
export function bumpPageScopeEpoch(session, pageRef) {
|
|
43
|
+
const runtime = ensureRuntimeState(session);
|
|
44
|
+
const current = runtime.pages[pageRef];
|
|
45
|
+
if (!current) {
|
|
46
|
+
throw new Error(`unknown_page_ref: ${pageRef}`);
|
|
47
|
+
}
|
|
48
|
+
const nextEpoch = (current.scopeEpoch ?? 0) + 1;
|
|
49
|
+
runtime.pages[pageRef] = {
|
|
50
|
+
...current,
|
|
51
|
+
scopeEpoch: nextEpoch,
|
|
52
|
+
updatedAt: new Date().toISOString(),
|
|
53
|
+
};
|
|
54
|
+
return nextEpoch;
|
|
55
|
+
}
|
|
56
|
+
export function setCurrentPage(session, pageRef) {
|
|
57
|
+
const runtime = ensureRuntimeState(session);
|
|
58
|
+
if (!runtime.pages[pageRef]) {
|
|
59
|
+
throw new Error(`unknown_page_ref: ${pageRef}`);
|
|
60
|
+
}
|
|
61
|
+
runtime.currentPageRef = pageRef;
|
|
62
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { BrowserSessionState } from './browser-session-state.js';
|
|
2
|
+
import type { PersistedFillableForm } from './secrets/types.js';
|
|
3
|
+
import { type ProtectedExposureState } from './runtime-state.js';
|
|
4
|
+
export declare function saveFillableForms(session: BrowserSessionState, forms: ReadonlyArray<PersistedFillableForm>): PersistedFillableForm[];
|
|
5
|
+
export declare function replaceFillableFormsForPage(session: BrowserSessionState, pageRef: string, forms: ReadonlyArray<Omit<PersistedFillableForm, 'fillRef'>>, options?: {
|
|
6
|
+
preserveExistingOnEmpty?: boolean;
|
|
7
|
+
}): PersistedFillableForm[];
|
|
8
|
+
export declare function markFillableFormsUnknownForPage(session: BrowserSessionState, pageRef: string): PersistedFillableForm[];
|
|
9
|
+
export declare function markFillableFormsAbsentForPage(session: BrowserSessionState, pageRef: string): PersistedFillableForm[];
|
|
10
|
+
export declare function getFillableForm(session: BrowserSessionState, fillRef: string): PersistedFillableForm | null;
|
|
11
|
+
export declare function saveProtectedExposure(session: BrowserSessionState, exposure: ProtectedExposureState): ProtectedExposureState;
|
|
12
|
+
export declare function getProtectedExposure(session: BrowserSessionState, pageRef: string): ProtectedExposureState | null;
|
|
13
|
+
export declare function clearProtectedExposure(session: BrowserSessionState, pageRef?: string): void;
|
|
14
|
+
//# sourceMappingURL=runtime-protected-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-protected-state.d.ts","sourceRoot":"","sources":["../src/runtime-protected-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,KAAK,EAAwB,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAEtF,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAyC5B,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,mBAAmB,EAC5B,KAAK,EAAE,aAAa,CAAC,qBAAqB,CAAC,GAC1C,qBAAqB,EAAE,CAYzB;AAED,wBAAgB,2BAA2B,CACzC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC,EAC5D,OAAO,GAAE;IACP,uBAAuB,CAAC,EAAE,OAAO,CAAC;CAC9B,GACL,qBAAqB,EAAE,CAgDzB;AAED,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,MAAM,GACd,qBAAqB,EAAE,CAuBzB;AAED,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,MAAM,GACd,qBAAqB,EAAE,CAmBzB;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,MAAM,GACd,qBAAqB,GAAG,IAAI,CAI9B;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,mBAAmB,EAC5B,QAAQ,EAAE,sBAAsB,GAC/B,sBAAsB,CAKxB;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,mBAAmB,EAC5B,OAAO,EAAE,MAAM,GACd,sBAAsB,GAAG,IAAI,CAG/B;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAS3F"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { logicalProtectedBindingKey } from './secrets/protected-bindings.js';
|
|
2
|
+
import { createFillRef, ensureRuntimeState, } from './runtime-state.js';
|
|
3
|
+
function syncFillCounter(runtime, ref) {
|
|
4
|
+
const match = /^f(\d+)$/.exec(ref);
|
|
5
|
+
if (!match)
|
|
6
|
+
return;
|
|
7
|
+
const nextFill = Number(match[1]) + 1;
|
|
8
|
+
if (Number.isFinite(nextFill)) {
|
|
9
|
+
runtime.counters.nextFill = Math.max(runtime.counters.nextFill, nextFill);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function fillableFormIdentity(form) {
|
|
13
|
+
const fieldsKey = [...form.fields]
|
|
14
|
+
.map((field) => logicalProtectedBindingKey(field))
|
|
15
|
+
.sort()
|
|
16
|
+
.join('|');
|
|
17
|
+
return [form.pageRef, form.scopeRef ?? '', form.purpose, fieldsKey].join('||');
|
|
18
|
+
}
|
|
19
|
+
function normalizeFillableForm(runtime, form) {
|
|
20
|
+
const pageScopeEpoch = runtime.pages[form.pageRef]?.scopeEpoch ?? 0;
|
|
21
|
+
const scopeEpoch = form.scopeEpoch ?? pageScopeEpoch;
|
|
22
|
+
const presence = form.presence === 'absent'
|
|
23
|
+
? 'absent'
|
|
24
|
+
: form.presence === 'unknown' || scopeEpoch < pageScopeEpoch
|
|
25
|
+
? 'unknown'
|
|
26
|
+
: 'present';
|
|
27
|
+
return {
|
|
28
|
+
...form,
|
|
29
|
+
scopeEpoch,
|
|
30
|
+
presence,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function saveFillableForms(session, forms) {
|
|
34
|
+
const runtime = ensureRuntimeState(session);
|
|
35
|
+
for (const form of forms) {
|
|
36
|
+
const pageScopeEpoch = runtime.pages[form.pageRef]?.scopeEpoch ?? 0;
|
|
37
|
+
runtime.fillableForms[form.fillRef] = {
|
|
38
|
+
...form,
|
|
39
|
+
presence: form.presence ?? 'present',
|
|
40
|
+
scopeEpoch: form.scopeEpoch ?? pageScopeEpoch,
|
|
41
|
+
};
|
|
42
|
+
syncFillCounter(runtime, form.fillRef);
|
|
43
|
+
}
|
|
44
|
+
return forms.map((form) => getFillableForm(session, form.fillRef));
|
|
45
|
+
}
|
|
46
|
+
export function replaceFillableFormsForPage(session, pageRef, forms, options = {}) {
|
|
47
|
+
const runtime = ensureRuntimeState(session);
|
|
48
|
+
const pageScopeEpoch = runtime.pages[pageRef]?.scopeEpoch ?? 0;
|
|
49
|
+
const existingEntries = Object.entries(runtime.fillableForms).filter(([, form]) => form.pageRef === pageRef);
|
|
50
|
+
const preserveExistingOnEmpty = options.preserveExistingOnEmpty !== false;
|
|
51
|
+
if (forms.length === 0 && preserveExistingOnEmpty) {
|
|
52
|
+
return existingEntries.map(([, form]) => form);
|
|
53
|
+
}
|
|
54
|
+
const reusableRefs = new Map();
|
|
55
|
+
for (const [fillRef, form] of existingEntries) {
|
|
56
|
+
if (form.presence === 'absent') {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
const identity = fillableFormIdentity(form);
|
|
60
|
+
const refs = reusableRefs.get(identity) ?? [];
|
|
61
|
+
refs.push(fillRef);
|
|
62
|
+
reusableRefs.set(identity, refs);
|
|
63
|
+
}
|
|
64
|
+
const reusedRefs = new Set();
|
|
65
|
+
const nextForms = [];
|
|
66
|
+
for (const form of forms) {
|
|
67
|
+
const identity = fillableFormIdentity(form);
|
|
68
|
+
const matchedRef = (reusableRefs.get(identity) ?? []).find((ref) => !reusedRefs.has(ref));
|
|
69
|
+
const fillRef = matchedRef ?? createFillRef(session);
|
|
70
|
+
runtime.fillableForms[fillRef] = {
|
|
71
|
+
...form,
|
|
72
|
+
fillRef,
|
|
73
|
+
presence: 'present',
|
|
74
|
+
scopeEpoch: pageScopeEpoch,
|
|
75
|
+
};
|
|
76
|
+
syncFillCounter(runtime, fillRef);
|
|
77
|
+
reusedRefs.add(fillRef);
|
|
78
|
+
nextForms.push(runtime.fillableForms[fillRef]);
|
|
79
|
+
}
|
|
80
|
+
for (const [fillRef, form] of existingEntries) {
|
|
81
|
+
if (!reusedRefs.has(fillRef) && form.presence !== 'absent') {
|
|
82
|
+
delete runtime.fillableForms[fillRef];
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return nextForms;
|
|
86
|
+
}
|
|
87
|
+
export function markFillableFormsUnknownForPage(session, pageRef) {
|
|
88
|
+
const runtime = ensureRuntimeState(session);
|
|
89
|
+
const pageScopeEpoch = runtime.pages[pageRef]?.scopeEpoch ?? 0;
|
|
90
|
+
const nextForms = [];
|
|
91
|
+
for (const [fillRef, form] of Object.entries(runtime.fillableForms)) {
|
|
92
|
+
if (form.pageRef !== pageRef) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (form.presence === 'absent') {
|
|
96
|
+
nextForms.push(runtime.fillableForms[fillRef]);
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
runtime.fillableForms[fillRef] = {
|
|
100
|
+
...form,
|
|
101
|
+
presence: 'unknown',
|
|
102
|
+
scopeEpoch: pageScopeEpoch,
|
|
103
|
+
};
|
|
104
|
+
nextForms.push(runtime.fillableForms[fillRef]);
|
|
105
|
+
}
|
|
106
|
+
return nextForms;
|
|
107
|
+
}
|
|
108
|
+
export function markFillableFormsAbsentForPage(session, pageRef) {
|
|
109
|
+
const runtime = ensureRuntimeState(session);
|
|
110
|
+
const pageScopeEpoch = runtime.pages[pageRef]?.scopeEpoch ?? 0;
|
|
111
|
+
const nextForms = [];
|
|
112
|
+
for (const [fillRef, form] of Object.entries(runtime.fillableForms)) {
|
|
113
|
+
if (form.pageRef !== pageRef) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
runtime.fillableForms[fillRef] = {
|
|
117
|
+
...form,
|
|
118
|
+
presence: 'absent',
|
|
119
|
+
scopeEpoch: pageScopeEpoch,
|
|
120
|
+
};
|
|
121
|
+
nextForms.push(runtime.fillableForms[fillRef]);
|
|
122
|
+
}
|
|
123
|
+
return nextForms;
|
|
124
|
+
}
|
|
125
|
+
export function getFillableForm(session, fillRef) {
|
|
126
|
+
const runtime = ensureRuntimeState(session);
|
|
127
|
+
const form = runtime.fillableForms[fillRef];
|
|
128
|
+
return form ? normalizeFillableForm(runtime, form) : null;
|
|
129
|
+
}
|
|
130
|
+
export function saveProtectedExposure(session, exposure) {
|
|
131
|
+
const runtime = ensureRuntimeState(session);
|
|
132
|
+
const exposures = runtime.protectedExposureByPage ?? (runtime.protectedExposureByPage = {});
|
|
133
|
+
exposures[exposure.pageRef] = exposure;
|
|
134
|
+
return exposures[exposure.pageRef];
|
|
135
|
+
}
|
|
136
|
+
export function getProtectedExposure(session, pageRef) {
|
|
137
|
+
const runtime = ensureRuntimeState(session);
|
|
138
|
+
return runtime.protectedExposureByPage?.[pageRef] ?? null;
|
|
139
|
+
}
|
|
140
|
+
export function clearProtectedExposure(session, pageRef) {
|
|
141
|
+
const runtime = ensureRuntimeState(session);
|
|
142
|
+
if (!pageRef) {
|
|
143
|
+
runtime.protectedExposureByPage = {};
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
const exposures = runtime.protectedExposureByPage ?? (runtime.protectedExposureByPage = {});
|
|
147
|
+
delete exposures[pageRef];
|
|
148
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type RuntimeSource = 'dom' | 'stagehand';
|
|
2
|
+
export type RuntimeResolution = {
|
|
3
|
+
source: RuntimeSource;
|
|
4
|
+
degraded: boolean;
|
|
5
|
+
degradationReason?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function domRuntimeResolution(): RuntimeResolution;
|
|
8
|
+
export declare function stagehandRuntimeResolution(degradationReason?: string): RuntimeResolution;
|
|
9
|
+
//# sourceMappingURL=runtime-resolution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime-resolution.d.ts","sourceRoot":"","sources":["../src/runtime-resolution.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,WAAW,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG;IAC9B,MAAM,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,wBAAgB,oBAAoB,IAAI,iBAAiB,CAKxD;AAED,wBAAgB,0BAA0B,CAAC,iBAAiB,CAAC,EAAE,MAAM,GAAG,iBAAiB,CAaxF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function domRuntimeResolution() {
|
|
2
|
+
return {
|
|
3
|
+
source: 'dom',
|
|
4
|
+
degraded: false,
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export function stagehandRuntimeResolution(degradationReason) {
|
|
8
|
+
if (!degradationReason) {
|
|
9
|
+
return {
|
|
10
|
+
source: 'stagehand',
|
|
11
|
+
degraded: false,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
source: 'stagehand',
|
|
16
|
+
degraded: true,
|
|
17
|
+
degradationReason,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import type { BrowserSessionState } from "./browser-session-state.js";
|
|
2
|
+
import type { PersistedFillableForm, SecretCatalogSnapshot } from "./secrets/types.js";
|
|
3
|
+
export type LocatorStrategy = "role" | "label" | "placeholder" | "text" | "title" | "testId" | "css" | "xpath";
|
|
4
|
+
export interface LocatorCandidate {
|
|
5
|
+
strategy: LocatorStrategy;
|
|
6
|
+
value: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
attribute?: "data-testid" | "data-test-id";
|
|
9
|
+
scope?: "root" | "surface";
|
|
10
|
+
}
|
|
11
|
+
export declare function locatorCandidateKey(candidate: Pick<LocatorCandidate, "strategy" | "value" | "name" | "attribute" | "scope">): string;
|
|
12
|
+
export interface TargetSemantics {
|
|
13
|
+
role?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
states?: Record<string, string | boolean | number>;
|
|
16
|
+
source?: "dom" | "stagehand" | "aria-snapshot" | "cdp-ax";
|
|
17
|
+
}
|
|
18
|
+
export type TargetCapability = "actionable" | "scope" | "informational";
|
|
19
|
+
export type TargetLifecycle = "live" | "stale" | "invalidated";
|
|
20
|
+
export type TargetAvailability = "available" | "gated" | "surface-inactive" | "hidden";
|
|
21
|
+
export type TargetAllowedAction = "click" | "fill" | "type" | "select" | "press";
|
|
22
|
+
export type TargetControlFamily = "text-input" | "select" | "datepicker" | "structured-grid" | "trigger";
|
|
23
|
+
export type TargetAcceptancePolicy = "value-change" | "selection" | "toggle" | "disclosure" | "date-selection" | "submit" | "navigation" | "generic-click";
|
|
24
|
+
export interface TargetAvailabilityState {
|
|
25
|
+
state: TargetAvailability;
|
|
26
|
+
reason?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface TargetContextNode {
|
|
29
|
+
kind?: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
text?: string;
|
|
32
|
+
selector?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface TargetVisualContext {
|
|
35
|
+
emphasis?: "muted" | "normal" | "strong";
|
|
36
|
+
fill?: "none" | "light" | "mid" | "dark";
|
|
37
|
+
outlined?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface TargetStructure {
|
|
40
|
+
family?: "structured-grid";
|
|
41
|
+
variant?: "date-cell" | "seat-cell" | "grid-cell";
|
|
42
|
+
row?: string;
|
|
43
|
+
column?: string;
|
|
44
|
+
zone?: string;
|
|
45
|
+
cellLabel?: string;
|
|
46
|
+
}
|
|
47
|
+
export interface TargetContext {
|
|
48
|
+
item?: TargetContextNode;
|
|
49
|
+
group?: TargetContextNode;
|
|
50
|
+
container?: TargetContextNode;
|
|
51
|
+
landmark?: TargetContextNode;
|
|
52
|
+
layout?: {
|
|
53
|
+
lane?: "left" | "center" | "right";
|
|
54
|
+
band?: "top" | "middle" | "bottom";
|
|
55
|
+
};
|
|
56
|
+
hintText?: string;
|
|
57
|
+
visual?: TargetVisualContext;
|
|
58
|
+
}
|
|
59
|
+
export interface TargetValidationEvidence {
|
|
60
|
+
invalid?: boolean;
|
|
61
|
+
required?: boolean;
|
|
62
|
+
message?: string;
|
|
63
|
+
errorStyling?: boolean;
|
|
64
|
+
}
|
|
65
|
+
export interface TargetDescriptor {
|
|
66
|
+
ref: string;
|
|
67
|
+
pageRef: string;
|
|
68
|
+
framePath?: string[];
|
|
69
|
+
frameUrl?: string;
|
|
70
|
+
kind?: string;
|
|
71
|
+
label?: string;
|
|
72
|
+
displayLabel?: string;
|
|
73
|
+
placeholder?: string;
|
|
74
|
+
inputName?: string;
|
|
75
|
+
inputType?: string;
|
|
76
|
+
autocomplete?: string;
|
|
77
|
+
ariaAutocomplete?: string;
|
|
78
|
+
surfaceKind?: string;
|
|
79
|
+
controlsSurfaceSelector?: string;
|
|
80
|
+
validation?: TargetValidationEvidence;
|
|
81
|
+
capability: TargetCapability;
|
|
82
|
+
lifecycle: TargetLifecycle;
|
|
83
|
+
availability: TargetAvailabilityState;
|
|
84
|
+
allowedActions: TargetAllowedAction[];
|
|
85
|
+
controlFamily?: TargetControlFamily;
|
|
86
|
+
acceptancePolicy?: TargetAcceptancePolicy;
|
|
87
|
+
surfaceRef?: string;
|
|
88
|
+
ownerRef?: string;
|
|
89
|
+
locatorCandidates: LocatorCandidate[];
|
|
90
|
+
semantics?: TargetSemantics;
|
|
91
|
+
structure?: TargetStructure;
|
|
92
|
+
context?: TargetContext;
|
|
93
|
+
stagehandAction?: unknown;
|
|
94
|
+
createdAt: number;
|
|
95
|
+
pageSignature?: string;
|
|
96
|
+
domSignature?: string;
|
|
97
|
+
lifecycleReason?: string;
|
|
98
|
+
}
|
|
99
|
+
type TargetDescriptorInput = Omit<TargetDescriptor, "ref" | "capability" | "lifecycle" | "availability" | "allowedActions"> & {
|
|
100
|
+
ref?: string;
|
|
101
|
+
capability?: TargetCapability;
|
|
102
|
+
lifecycle?: TargetLifecycle;
|
|
103
|
+
availability?: TargetAvailabilityState;
|
|
104
|
+
allowedActions?: TargetAllowedAction[];
|
|
105
|
+
};
|
|
106
|
+
export interface BrowsePageState {
|
|
107
|
+
pageRef: string;
|
|
108
|
+
createdAt: string;
|
|
109
|
+
updatedAt: string;
|
|
110
|
+
url?: string;
|
|
111
|
+
title?: string;
|
|
112
|
+
targetId?: string;
|
|
113
|
+
openerPageRef?: string;
|
|
114
|
+
scopeEpoch: number;
|
|
115
|
+
}
|
|
116
|
+
export type ExtractScopeLifetime = "durable" | "snapshot";
|
|
117
|
+
export interface SurfaceDescriptor {
|
|
118
|
+
ref: string;
|
|
119
|
+
surfaceId: string;
|
|
120
|
+
pageRef: string;
|
|
121
|
+
framePath?: string[];
|
|
122
|
+
frameUrl?: string;
|
|
123
|
+
kind?: string;
|
|
124
|
+
label?: string;
|
|
125
|
+
parentSurfaceRef?: string;
|
|
126
|
+
childSurfaceRefs?: string[];
|
|
127
|
+
targetRefs?: string[];
|
|
128
|
+
lifecycle: TargetLifecycle;
|
|
129
|
+
availability: TargetAvailabilityState;
|
|
130
|
+
locatorCandidates: LocatorCandidate[];
|
|
131
|
+
createdAt: number;
|
|
132
|
+
pageSignature?: string;
|
|
133
|
+
lifecycleReason?: string;
|
|
134
|
+
extractScopeLifetime?: ExtractScopeLifetime;
|
|
135
|
+
scopeEpoch?: number;
|
|
136
|
+
}
|
|
137
|
+
type SurfaceDescriptorInput = Omit<SurfaceDescriptor, "ref" | "lifecycle" | "availability"> & {
|
|
138
|
+
ref?: string;
|
|
139
|
+
lifecycle?: TargetLifecycle;
|
|
140
|
+
availability?: TargetAvailabilityState;
|
|
141
|
+
};
|
|
142
|
+
export interface BrowseRuntimeMetrics {
|
|
143
|
+
stagehandCalls: number;
|
|
144
|
+
deterministicActions: number;
|
|
145
|
+
fallbackActions: number;
|
|
146
|
+
observeAxAttempts: number;
|
|
147
|
+
observeAxHits: number;
|
|
148
|
+
observeFallbackUses: number;
|
|
149
|
+
successfulActions: number;
|
|
150
|
+
failedActions: number;
|
|
151
|
+
totalActionDurationMs: number;
|
|
152
|
+
successRate: number;
|
|
153
|
+
averageActionDurationMs: number;
|
|
154
|
+
llmCalls?: number;
|
|
155
|
+
llmPromptTokens?: number;
|
|
156
|
+
llmCompletionTokens?: number;
|
|
157
|
+
llmTotalTokens?: number;
|
|
158
|
+
llmCachedInputTokens?: number;
|
|
159
|
+
llmReasoningTokens?: number;
|
|
160
|
+
llmUsageByPurpose?: Record<string, BrowseLlmUsageBucket>;
|
|
161
|
+
payloadBudget?: BrowsePayloadBudgetMetrics;
|
|
162
|
+
}
|
|
163
|
+
export interface BrowseLlmUsageBucket {
|
|
164
|
+
calls: number;
|
|
165
|
+
inputChars: number;
|
|
166
|
+
promptTokens: number;
|
|
167
|
+
completionTokens: number;
|
|
168
|
+
totalTokens: number;
|
|
169
|
+
cachedInputTokens: number;
|
|
170
|
+
reasoningTokens: number;
|
|
171
|
+
}
|
|
172
|
+
export interface BrowsePayloadBudgetMetrics {
|
|
173
|
+
observeRerankCandidatesSeen: number;
|
|
174
|
+
observeRerankCandidatesSent: number;
|
|
175
|
+
extractSnapshotLinesSeen: number;
|
|
176
|
+
extractSnapshotLinesSent: number;
|
|
177
|
+
protectedBindingsSeen: number;
|
|
178
|
+
protectedBindingsSent: number;
|
|
179
|
+
}
|
|
180
|
+
export type ProtectedExactValueMatcher = "text" | "digits" | "email" | "expiry";
|
|
181
|
+
export interface ProtectedExactValueRule {
|
|
182
|
+
matcher: ProtectedExactValueMatcher;
|
|
183
|
+
digest: string;
|
|
184
|
+
normalizedLength: number;
|
|
185
|
+
}
|
|
186
|
+
export interface ProtectedExactValueProfile {
|
|
187
|
+
version: 1;
|
|
188
|
+
rules: ProtectedExactValueRule[];
|
|
189
|
+
}
|
|
190
|
+
export interface ProtectedExposureState {
|
|
191
|
+
pageRef: string;
|
|
192
|
+
scopeRef?: string;
|
|
193
|
+
fillRef: string;
|
|
194
|
+
requestId: string;
|
|
195
|
+
activatedAt: string;
|
|
196
|
+
exactValueProfile?: ProtectedExactValueProfile;
|
|
197
|
+
reason: "protected_fill_success" | "protected_fill_binding_stale" | "protected_fill_validation_failed" | "protected_fill_unexpected_error";
|
|
198
|
+
}
|
|
199
|
+
export interface BrowseRuntimeState {
|
|
200
|
+
version: 1;
|
|
201
|
+
currentPageRef: string;
|
|
202
|
+
pages: Record<string, BrowsePageState>;
|
|
203
|
+
surfaces: Record<string, SurfaceDescriptor>;
|
|
204
|
+
targets: Record<string, TargetDescriptor>;
|
|
205
|
+
secretCatalogByHost: Record<string, SecretCatalogSnapshot>;
|
|
206
|
+
fillableForms: Record<string, PersistedFillableForm>;
|
|
207
|
+
protectedExposureByPage?: Record<string, ProtectedExposureState>;
|
|
208
|
+
counters: {
|
|
209
|
+
nextPage: number;
|
|
210
|
+
nextSurface: number;
|
|
211
|
+
nextTarget: number;
|
|
212
|
+
nextFill: number;
|
|
213
|
+
};
|
|
214
|
+
metrics: BrowseRuntimeMetrics;
|
|
215
|
+
}
|
|
216
|
+
export declare function createPayloadBudgetMetrics(): BrowsePayloadBudgetMetrics;
|
|
217
|
+
export declare function createLlmUsageBucket(): BrowseLlmUsageBucket;
|
|
218
|
+
export declare function ensureMetricsExtensions(metrics: BrowseRuntimeMetrics): void;
|
|
219
|
+
export declare function createRuntimeState(initialPage?: Partial<Omit<BrowsePageState, "pageRef" | "createdAt" | "updatedAt">> & {
|
|
220
|
+
pageRef?: string;
|
|
221
|
+
}): BrowseRuntimeState;
|
|
222
|
+
export declare function ensureRuntimeState(session: BrowserSessionState): BrowseRuntimeState;
|
|
223
|
+
export declare function createTargetRef(session: BrowserSessionState): string;
|
|
224
|
+
export declare function createFillRef(session: BrowserSessionState): string;
|
|
225
|
+
export declare function createSurfaceRef(session: BrowserSessionState): string;
|
|
226
|
+
export declare function saveSurfaces(session: BrowserSessionState, descriptors: ReadonlyArray<SurfaceDescriptorInput>): SurfaceDescriptor[];
|
|
227
|
+
export declare function replaceSurfacesForPage(session: BrowserSessionState, pageRef: string, descriptors: ReadonlyArray<SurfaceDescriptorInput>, options?: {
|
|
228
|
+
preserveExistingOnEmpty?: boolean;
|
|
229
|
+
preserveExisting?: boolean;
|
|
230
|
+
}): SurfaceDescriptor[];
|
|
231
|
+
export declare function saveTargets(session: BrowserSessionState, descriptors: ReadonlyArray<TargetDescriptorInput>): TargetDescriptor[];
|
|
232
|
+
export declare function replaceTargetsForPage(session: BrowserSessionState, pageRef: string, descriptors: ReadonlyArray<TargetDescriptorInput>, options?: {
|
|
233
|
+
preserveExistingOnEmpty?: boolean;
|
|
234
|
+
preserveExisting?: boolean;
|
|
235
|
+
}): TargetDescriptor[];
|
|
236
|
+
export declare function getTarget(session: BrowserSessionState, targetRef: string): TargetDescriptor | null;
|
|
237
|
+
export declare function getSurface(session: BrowserSessionState, surfaceRef: string): SurfaceDescriptor | null;
|
|
238
|
+
export declare function saveSecretCatalog(session: BrowserSessionState, snapshot: SecretCatalogSnapshot): SecretCatalogSnapshot;
|
|
239
|
+
export declare function getSecretCatalog(session: BrowserSessionState, host: string): SecretCatalogSnapshot | null;
|
|
240
|
+
export declare function updateSurface(session: BrowserSessionState, surfaceRef: string, patch: Partial<Omit<SurfaceDescriptor, "ref" | "createdAt">>): SurfaceDescriptor | null;
|
|
241
|
+
export declare function markSurfaceLifecycle(session: BrowserSessionState, surfaceRef: string, lifecycle: TargetLifecycle, reason?: string): SurfaceDescriptor | null;
|
|
242
|
+
export declare function setSurfaceAvailability(session: BrowserSessionState, surfaceRef: string, state: TargetAvailability, reason?: string): SurfaceDescriptor | null;
|
|
243
|
+
export declare function deleteTarget(session: BrowserSessionState, targetRef: string): void;
|
|
244
|
+
export declare function updateTarget(session: BrowserSessionState, targetRef: string, patch: Partial<Omit<TargetDescriptor, "ref" | "createdAt">>): TargetDescriptor | null;
|
|
245
|
+
export declare function markTargetLifecycle(session: BrowserSessionState, targetRef: string, lifecycle: TargetLifecycle, reason?: string): TargetDescriptor | null;
|
|
246
|
+
export declare function setTargetAvailability(session: BrowserSessionState, targetRef: string, state: TargetAvailability, reason?: string): TargetDescriptor | null;
|
|
247
|
+
export declare function listTargets(session: BrowserSessionState): TargetDescriptor[];
|
|
248
|
+
export declare function listSurfaces(session: BrowserSessionState): SurfaceDescriptor[];
|
|
249
|
+
export declare function clearTargets(session: BrowserSessionState, pageRef?: string): void;
|
|
250
|
+
export {};
|
|
251
|
+
//# sourceMappingURL=runtime-state.d.ts.map
|