@nuanu-ai/agentbrowse 0.2.7 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -8
- package/dist/agentpay-stagehand-llm.d.ts.map +1 -1
- package/dist/agentpay-stagehand-llm.js +5 -1
- package/dist/commands/act.d.ts +6 -2
- package/dist/commands/act.d.ts.map +1 -1
- package/dist/commands/act.js +840 -55
- package/dist/commands/act.test-harness.d.ts +19 -0
- package/dist/commands/act.test-harness.d.ts.map +1 -0
- package/dist/commands/act.test-harness.js +245 -0
- package/dist/commands/action-acceptance.d.ts +90 -0
- package/dist/commands/action-acceptance.d.ts.map +1 -0
- package/dist/commands/action-acceptance.js +1411 -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 +242 -0
- package/dist/commands/action-executor.d.ts +12 -0
- package/dist/commands/action-executor.d.ts.map +1 -0
- package/dist/commands/action-executor.js +45 -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-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/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/captcha-solve.d.ts.map +1 -1
- package/dist/commands/captcha-solve.js +13 -3
- package/dist/commands/click-action-executor.d.ts +10 -0
- package/dist/commands/click-action-executor.d.ts.map +1 -0
- package/dist/commands/click-action-executor.js +68 -0
- package/dist/commands/create-intent.d.ts +6 -0
- package/dist/commands/create-intent.d.ts.map +1 -0
- package/dist/commands/create-intent.js +75 -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 +333 -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 +100 -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 +18 -0
- package/dist/commands/extract.d.ts +3 -2
- package/dist/commands/extract.d.ts.map +1 -1
- package/dist/commands/extract.js +256 -39
- package/dist/commands/fill-secret.d.ts +7 -0
- package/dist/commands/fill-secret.d.ts.map +1 -0
- package/dist/commands/fill-secret.js +371 -0
- package/dist/commands/get-secrets-catalog.d.ts +6 -0
- package/dist/commands/get-secrets-catalog.d.ts.map +1 -0
- package/dist/commands/get-secrets-catalog.js +23 -0
- package/dist/commands/launch.d.ts.map +1 -1
- package/dist/commands/launch.js +41 -7
- package/dist/commands/navigate.d.ts +2 -1
- package/dist/commands/navigate.d.ts.map +1 -1
- package/dist/commands/navigate.js +49 -12
- package/dist/commands/observe-inventory.d.ts +109 -0
- package/dist/commands/observe-inventory.d.ts.map +1 -0
- package/dist/commands/observe-inventory.js +2837 -0
- package/dist/commands/observe-persistence.d.ts +14 -0
- package/dist/commands/observe-persistence.d.ts.map +1 -0
- package/dist/commands/observe-persistence.js +170 -0
- package/dist/commands/observe-projection.d.ts +84 -0
- package/dist/commands/observe-projection.d.ts.map +1 -0
- package/dist/commands/observe-projection.js +140 -0
- package/dist/commands/observe-protected.d.ts +5 -0
- package/dist/commands/observe-protected.d.ts.map +1 -0
- package/dist/commands/observe-protected.js +18 -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 +338 -0
- package/dist/commands/observe-stagehand.d.ts +48 -0
- package/dist/commands/observe-stagehand.d.ts.map +1 -0
- package/dist/commands/observe-stagehand.js +105 -0
- package/dist/commands/observe-surfaces.d.ts +9 -0
- package/dist/commands/observe-surfaces.d.ts.map +1 -0
- package/dist/commands/observe-surfaces.js +195 -0
- package/dist/commands/observe.d.ts +47 -1
- package/dist/commands/observe.d.ts.map +1 -1
- package/dist/commands/observe.js +173 -20
- package/dist/commands/observe.test-harness.d.ts +67 -0
- package/dist/commands/observe.test-harness.d.ts.map +1 -0
- package/dist/commands/observe.test-harness.js +107 -0
- package/dist/commands/poll-intent.d.ts +6 -0
- package/dist/commands/poll-intent.d.ts.map +1 -0
- package/dist/commands/poll-intent.js +57 -0
- package/dist/commands/screenshot.d.ts +2 -1
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/commands/screenshot.js +44 -12
- 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 +91 -0
- package/dist/commands/semantic-observe.d.ts +24 -0
- package/dist/commands/semantic-observe.d.ts.map +1 -0
- package/dist/commands/semantic-observe.js +344 -0
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +75 -2
- 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 +95 -0
- package/dist/control-semantics.d.ts +29 -0
- package/dist/control-semantics.d.ts.map +1 -0
- package/dist/control-semantics.js +299 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +95 -32
- package/dist/output.d.ts +14 -2
- package/dist/output.d.ts.map +1 -1
- package/dist/output.js +17 -29
- package/dist/playwright-runtime.d.ts +35 -0
- package/dist/playwright-runtime.d.ts.map +1 -0
- package/dist/playwright-runtime.js +224 -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 +217 -0
- package/dist/runtime-state.d.ts.map +1 -0
- package/dist/runtime-state.js +629 -0
- package/dist/secrets/backend.d.ts +32 -0
- package/dist/secrets/backend.d.ts.map +1 -0
- package/dist/secrets/backend.js +169 -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/catalog-sync.d.ts +14 -0
- package/dist/secrets/catalog-sync.d.ts.map +1 -0
- package/dist/secrets/catalog-sync.js +35 -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 +11 -0
- package/dist/secrets/fill-ordering.d.ts.map +1 -0
- package/dist/secrets/fill-ordering.js +44 -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 +596 -0
- package/dist/secrets/intent-output.d.ts +11 -0
- package/dist/secrets/intent-output.d.ts.map +1 -0
- package/dist/secrets/intent-output.js +64 -0
- package/dist/secrets/mock-agentpay-backend.d.ts +13 -0
- package/dist/secrets/mock-agentpay-backend.d.ts.map +1 -0
- package/dist/secrets/mock-agentpay-backend.js +87 -0
- package/dist/secrets/mock-agentpay-cabinet.d.ts +43 -0
- package/dist/secrets/mock-agentpay-cabinet.d.ts.map +1 -0
- package/dist/secrets/mock-agentpay-cabinet.js +195 -0
- package/dist/secrets/protected-artifact-guard.d.ts +25 -0
- package/dist/secrets/protected-artifact-guard.d.ts.map +1 -0
- package/dist/secrets/protected-artifact-guard.js +26 -0
- package/dist/secrets/protected-bindings.d.ts +10 -0
- package/dist/secrets/protected-bindings.d.ts.map +1 -0
- package/dist/secrets/protected-bindings.js +17 -0
- package/dist/secrets/protected-field-values.d.ts +13 -0
- package/dist/secrets/protected-field-values.d.ts.map +1 -0
- package/dist/secrets/protected-field-values.js +100 -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 +512 -0
- package/dist/secrets/types.d.ts +84 -0
- package/dist/secrets/types.d.ts.map +1 -0
- package/dist/secrets/types.js +27 -0
- package/dist/session.d.ts +22 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +74 -2
- package/dist/solver/browser-launcher.d.ts.map +1 -1
- package/dist/solver/browser-launcher.js +6 -3
- 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 +0 -5
- package/dist/stagehand.d.ts.map +1 -1
- package/dist/stagehand.js +0 -6
- package/package.json +5 -2
|
@@ -0,0 +1,629 @@
|
|
|
1
|
+
import { resolveCachedSecretCatalogForHost } from './secrets/catalog-applicability.js';
|
|
2
|
+
import { protectedBindingKey } from './secrets/protected-bindings.js';
|
|
3
|
+
import { inferAcceptancePolicyFromFacts, inferAllowedActionsFromFacts, inferAvailabilityFromFacts, inferControlFamilyFromFacts, } from './control-semantics.js';
|
|
4
|
+
export function locatorCandidateKey(candidate) {
|
|
5
|
+
return [
|
|
6
|
+
candidate.strategy,
|
|
7
|
+
candidate.name ?? '',
|
|
8
|
+
candidate.value,
|
|
9
|
+
candidate.attribute ?? '',
|
|
10
|
+
candidate.scope ?? '',
|
|
11
|
+
].join(':');
|
|
12
|
+
}
|
|
13
|
+
function inferLegacyActionMethod(descriptor) {
|
|
14
|
+
const kind = (descriptor.kind ?? '').toLowerCase();
|
|
15
|
+
if (['click', 'fill', 'type', 'select', 'press'].includes(kind)) {
|
|
16
|
+
return kind;
|
|
17
|
+
}
|
|
18
|
+
const stagehandAction = descriptor.stagehandAction;
|
|
19
|
+
if (stagehandAction &&
|
|
20
|
+
typeof stagehandAction === 'object' &&
|
|
21
|
+
!Array.isArray(stagehandAction) &&
|
|
22
|
+
typeof stagehandAction.method === 'string') {
|
|
23
|
+
return (stagehandAction.method ?? '').toLowerCase();
|
|
24
|
+
}
|
|
25
|
+
return '';
|
|
26
|
+
}
|
|
27
|
+
function inferAllowedActions(descriptor) {
|
|
28
|
+
const legacyMethod = inferLegacyActionMethod(descriptor);
|
|
29
|
+
return inferAllowedActionsFromFacts({
|
|
30
|
+
kind: descriptor.kind,
|
|
31
|
+
role: descriptor.semantics?.role,
|
|
32
|
+
label: descriptor.label,
|
|
33
|
+
displayLabel: descriptor.displayLabel,
|
|
34
|
+
placeholder: descriptor.placeholder,
|
|
35
|
+
inputName: descriptor.inputName,
|
|
36
|
+
inputType: descriptor.inputType,
|
|
37
|
+
autocomplete: descriptor.autocomplete,
|
|
38
|
+
states: descriptor.semantics?.states,
|
|
39
|
+
structure: descriptor.structure,
|
|
40
|
+
legacyMethod,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function inferControlFamily(descriptor, allowedActions) {
|
|
44
|
+
return inferControlFamilyFromFacts({
|
|
45
|
+
kind: descriptor.kind,
|
|
46
|
+
role: descriptor.semantics?.role,
|
|
47
|
+
label: descriptor.label,
|
|
48
|
+
displayLabel: descriptor.displayLabel,
|
|
49
|
+
placeholder: descriptor.placeholder,
|
|
50
|
+
inputName: descriptor.inputName,
|
|
51
|
+
inputType: descriptor.inputType,
|
|
52
|
+
autocomplete: descriptor.autocomplete,
|
|
53
|
+
states: descriptor.semantics?.states,
|
|
54
|
+
structure: descriptor.structure,
|
|
55
|
+
legacyMethod: inferLegacyActionMethod(descriptor),
|
|
56
|
+
}, allowedActions);
|
|
57
|
+
}
|
|
58
|
+
function inferAcceptancePolicy(descriptor, allowedActions) {
|
|
59
|
+
return inferAcceptancePolicyFromFacts({
|
|
60
|
+
kind: descriptor.kind,
|
|
61
|
+
role: descriptor.semantics?.role,
|
|
62
|
+
label: descriptor.label,
|
|
63
|
+
displayLabel: descriptor.displayLabel,
|
|
64
|
+
placeholder: descriptor.placeholder,
|
|
65
|
+
inputName: descriptor.inputName,
|
|
66
|
+
inputType: descriptor.inputType,
|
|
67
|
+
autocomplete: descriptor.autocomplete,
|
|
68
|
+
states: descriptor.semantics?.states,
|
|
69
|
+
structure: descriptor.structure,
|
|
70
|
+
legacyMethod: inferLegacyActionMethod(descriptor),
|
|
71
|
+
}, allowedActions);
|
|
72
|
+
}
|
|
73
|
+
function inferAvailability(descriptor) {
|
|
74
|
+
if (descriptor.availability?.state) {
|
|
75
|
+
return descriptor.availability;
|
|
76
|
+
}
|
|
77
|
+
const allowedActions = descriptor.allowedActions ? [...descriptor.allowedActions] : inferAllowedActions(descriptor);
|
|
78
|
+
const controlFamily = descriptor.controlFamily ?? inferControlFamily(descriptor, allowedActions);
|
|
79
|
+
const acceptancePolicy = descriptor.acceptancePolicy ?? inferAcceptancePolicy(descriptor, allowedActions);
|
|
80
|
+
return inferAvailabilityFromFacts(descriptor.semantics?.states, descriptor.context?.hintText, {
|
|
81
|
+
readonlyInteractive: controlFamily === 'select' ||
|
|
82
|
+
controlFamily === 'datepicker' ||
|
|
83
|
+
acceptancePolicy === 'selection' ||
|
|
84
|
+
acceptancePolicy === 'date-selection',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
function normalizeTargetDescriptor(descriptor, ref) {
|
|
88
|
+
const allowedActions = descriptor.allowedActions ? [...descriptor.allowedActions] : inferAllowedActions(descriptor);
|
|
89
|
+
return {
|
|
90
|
+
...descriptor,
|
|
91
|
+
ref,
|
|
92
|
+
capability: descriptor.capability ?? 'actionable',
|
|
93
|
+
lifecycle: descriptor.lifecycle ?? 'live',
|
|
94
|
+
availability: inferAvailability(descriptor),
|
|
95
|
+
allowedActions,
|
|
96
|
+
controlFamily: descriptor.controlFamily ?? inferControlFamily(descriptor, allowedActions),
|
|
97
|
+
acceptancePolicy: descriptor.acceptancePolicy ?? inferAcceptancePolicy(descriptor, allowedActions),
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function targetIdentity(descriptor) {
|
|
101
|
+
const frameKey = descriptor.framePath?.join('>') ??
|
|
102
|
+
(descriptor.frameUrl?.trim() ? `url:${descriptor.frameUrl.trim()}` : 'top');
|
|
103
|
+
const pageKey = descriptor.pageSignature ?? descriptor.pageRef;
|
|
104
|
+
const familyKey = descriptor.controlFamily ?? '';
|
|
105
|
+
const surfaceKey = descriptor.surfaceRef ?? '';
|
|
106
|
+
const structureKey = descriptor.structure
|
|
107
|
+
? [
|
|
108
|
+
descriptor.structure.family ?? '',
|
|
109
|
+
descriptor.structure.variant ?? '',
|
|
110
|
+
descriptor.structure.row ?? '',
|
|
111
|
+
descriptor.structure.column ?? '',
|
|
112
|
+
descriptor.structure.zone ?? '',
|
|
113
|
+
descriptor.structure.cellLabel ?? '',
|
|
114
|
+
].join(':')
|
|
115
|
+
: '';
|
|
116
|
+
const locatorKey = descriptor.locatorCandidates
|
|
117
|
+
.map((candidate) => locatorCandidateKey(candidate))
|
|
118
|
+
.join('|');
|
|
119
|
+
const domKey = descriptor.domSignature?.trim();
|
|
120
|
+
if (domKey && locatorKey) {
|
|
121
|
+
return `${pageKey}|${frameKey}|family|${familyKey}|surface|${surfaceKey}|structure|${structureKey}|dom|${domKey}|locator|${locatorKey}`;
|
|
122
|
+
}
|
|
123
|
+
if (domKey) {
|
|
124
|
+
return `${pageKey}|${frameKey}|family|${familyKey}|surface|${surfaceKey}|structure|${structureKey}|dom|${domKey}`;
|
|
125
|
+
}
|
|
126
|
+
if (locatorKey) {
|
|
127
|
+
return `${pageKey}|${frameKey}|family|${familyKey}|surface|${surfaceKey}|structure|${structureKey}|locator|${locatorKey}`;
|
|
128
|
+
}
|
|
129
|
+
return `${pageKey}|${frameKey}|family|${familyKey}|surface|${surfaceKey}|structure|${structureKey}|fallback|${descriptor.kind ?? ''}|${descriptor.label ?? ''}`;
|
|
130
|
+
}
|
|
131
|
+
function inferSurfaceAvailability(descriptor) {
|
|
132
|
+
return descriptor.availability?.state ? descriptor.availability : { state: 'available' };
|
|
133
|
+
}
|
|
134
|
+
function normalizeSurfaceDescriptor(descriptor, ref) {
|
|
135
|
+
return {
|
|
136
|
+
...descriptor,
|
|
137
|
+
ref,
|
|
138
|
+
lifecycle: descriptor.lifecycle ?? 'live',
|
|
139
|
+
availability: inferSurfaceAvailability(descriptor),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function surfaceIdentity(descriptor) {
|
|
143
|
+
if (descriptor.surfaceId) {
|
|
144
|
+
return descriptor.surfaceId;
|
|
145
|
+
}
|
|
146
|
+
const frameKey = descriptor.framePath?.join('>') ??
|
|
147
|
+
(descriptor.frameUrl?.trim() ? `url:${descriptor.frameUrl.trim()}` : 'top');
|
|
148
|
+
const pageKey = descriptor.pageSignature ?? descriptor.pageRef;
|
|
149
|
+
const locatorKey = descriptor.locatorCandidates
|
|
150
|
+
.map((candidate) => locatorCandidateKey(candidate))
|
|
151
|
+
.join('|');
|
|
152
|
+
if (locatorKey) {
|
|
153
|
+
return `${pageKey}|${frameKey}|surface-locator|${locatorKey}`;
|
|
154
|
+
}
|
|
155
|
+
return `${pageKey}|${frameKey}|surface-fallback|${descriptor.kind ?? ''}|${descriptor.label ?? ''}`;
|
|
156
|
+
}
|
|
157
|
+
function syncTargetCounter(runtime, ref) {
|
|
158
|
+
const match = /^t(\d+)$/.exec(ref);
|
|
159
|
+
if (!match)
|
|
160
|
+
return;
|
|
161
|
+
const nextTarget = Number(match[1]) + 1;
|
|
162
|
+
if (Number.isFinite(nextTarget)) {
|
|
163
|
+
runtime.counters.nextTarget = Math.max(runtime.counters.nextTarget, nextTarget);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
function syncFillCounter(runtime, ref) {
|
|
167
|
+
const match = /^f(\d+)$/.exec(ref);
|
|
168
|
+
if (!match)
|
|
169
|
+
return;
|
|
170
|
+
const nextFill = Number(match[1]) + 1;
|
|
171
|
+
if (Number.isFinite(nextFill)) {
|
|
172
|
+
runtime.counters.nextFill = Math.max(runtime.counters.nextFill, nextFill);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function syncSurfaceCounter(runtime, ref) {
|
|
176
|
+
const match = /^s(\d+)$/.exec(ref);
|
|
177
|
+
if (!match)
|
|
178
|
+
return;
|
|
179
|
+
const nextSurface = Number(match[1]) + 1;
|
|
180
|
+
if (Number.isFinite(nextSurface)) {
|
|
181
|
+
runtime.counters.nextSurface = Math.max(runtime.counters.nextSurface, nextSurface);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
export function createRuntimeState(initialPage = {}) {
|
|
185
|
+
const pageRef = initialPage.pageRef ?? 'p0';
|
|
186
|
+
const now = new Date().toISOString();
|
|
187
|
+
return {
|
|
188
|
+
version: 1,
|
|
189
|
+
currentPageRef: pageRef,
|
|
190
|
+
pages: {
|
|
191
|
+
[pageRef]: {
|
|
192
|
+
pageRef,
|
|
193
|
+
createdAt: now,
|
|
194
|
+
updatedAt: now,
|
|
195
|
+
url: initialPage.url,
|
|
196
|
+
title: initialPage.title,
|
|
197
|
+
openerPageRef: initialPage.openerPageRef,
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
surfaces: {},
|
|
201
|
+
targets: {},
|
|
202
|
+
secretCatalogByHost: {},
|
|
203
|
+
fillableForms: {},
|
|
204
|
+
secretIntentSnapshots: {},
|
|
205
|
+
protectedExposureByPage: {},
|
|
206
|
+
counters: {
|
|
207
|
+
nextPage: pageRef === 'p0' ? 1 : 0,
|
|
208
|
+
nextSurface: 1,
|
|
209
|
+
nextTarget: 1,
|
|
210
|
+
nextFill: 1,
|
|
211
|
+
},
|
|
212
|
+
metrics: {
|
|
213
|
+
stagehandCalls: 0,
|
|
214
|
+
deterministicActions: 0,
|
|
215
|
+
fallbackActions: 0,
|
|
216
|
+
successfulActions: 0,
|
|
217
|
+
failedActions: 0,
|
|
218
|
+
totalActionDurationMs: 0,
|
|
219
|
+
successRate: 0,
|
|
220
|
+
averageActionDurationMs: 0,
|
|
221
|
+
},
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
export function ensureRuntimeState(session) {
|
|
225
|
+
if (!session.runtime) {
|
|
226
|
+
session.runtime = createRuntimeState();
|
|
227
|
+
}
|
|
228
|
+
session.runtime.surfaces ??= {};
|
|
229
|
+
session.runtime.secretCatalogByHost ??= {};
|
|
230
|
+
session.runtime.fillableForms ??= {};
|
|
231
|
+
session.runtime.secretIntentSnapshots ??= {};
|
|
232
|
+
session.runtime.protectedExposureByPage ??= {};
|
|
233
|
+
session.runtime.counters.nextPage ??= 1;
|
|
234
|
+
session.runtime.counters.nextSurface ??= 1;
|
|
235
|
+
session.runtime.counters.nextTarget ??= 1;
|
|
236
|
+
session.runtime.counters.nextFill ??= 1;
|
|
237
|
+
for (const pageRef of Object.keys(session.runtime.pages ?? {})) {
|
|
238
|
+
const match = /^p(\d+)$/.exec(pageRef);
|
|
239
|
+
if (!match) {
|
|
240
|
+
continue;
|
|
241
|
+
}
|
|
242
|
+
const nextPage = Number(match[1]) + 1;
|
|
243
|
+
if (Number.isFinite(nextPage)) {
|
|
244
|
+
session.runtime.counters.nextPage = Math.max(session.runtime.counters.nextPage, nextPage);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
for (const surfaceRef of Object.keys(session.runtime.surfaces ?? {})) {
|
|
248
|
+
syncSurfaceCounter(session.runtime, surfaceRef);
|
|
249
|
+
}
|
|
250
|
+
for (const targetRef of Object.keys(session.runtime.targets ?? {})) {
|
|
251
|
+
syncTargetCounter(session.runtime, targetRef);
|
|
252
|
+
}
|
|
253
|
+
for (const fillRef of Object.keys(session.runtime.fillableForms ?? {})) {
|
|
254
|
+
syncFillCounter(session.runtime, fillRef);
|
|
255
|
+
}
|
|
256
|
+
return session.runtime;
|
|
257
|
+
}
|
|
258
|
+
export function registerPage(session, page = {}) {
|
|
259
|
+
const runtime = ensureRuntimeState(session);
|
|
260
|
+
const pageRef = page.pageRef ?? `p${runtime.counters.nextPage++}`;
|
|
261
|
+
const now = new Date().toISOString();
|
|
262
|
+
const existing = runtime.pages[pageRef];
|
|
263
|
+
const nextPage = {
|
|
264
|
+
pageRef,
|
|
265
|
+
createdAt: existing?.createdAt ?? now,
|
|
266
|
+
updatedAt: now,
|
|
267
|
+
url: page.url ?? existing?.url,
|
|
268
|
+
title: page.title ?? existing?.title,
|
|
269
|
+
targetId: page.targetId ?? existing?.targetId,
|
|
270
|
+
openerPageRef: page.openerPageRef ?? existing?.openerPageRef,
|
|
271
|
+
};
|
|
272
|
+
runtime.pages[pageRef] = nextPage;
|
|
273
|
+
if (page.makeCurrent !== false) {
|
|
274
|
+
runtime.currentPageRef = pageRef;
|
|
275
|
+
}
|
|
276
|
+
return nextPage;
|
|
277
|
+
}
|
|
278
|
+
export function updatePage(session, pageRef, patch) {
|
|
279
|
+
const runtime = ensureRuntimeState(session);
|
|
280
|
+
const current = runtime.pages[pageRef];
|
|
281
|
+
if (!current) {
|
|
282
|
+
throw new Error(`unknown_page_ref: ${pageRef}`);
|
|
283
|
+
}
|
|
284
|
+
const nextPage = {
|
|
285
|
+
...current,
|
|
286
|
+
...patch,
|
|
287
|
+
updatedAt: new Date().toISOString(),
|
|
288
|
+
};
|
|
289
|
+
runtime.pages[pageRef] = nextPage;
|
|
290
|
+
return nextPage;
|
|
291
|
+
}
|
|
292
|
+
export function setCurrentPage(session, pageRef) {
|
|
293
|
+
const runtime = ensureRuntimeState(session);
|
|
294
|
+
if (!runtime.pages[pageRef]) {
|
|
295
|
+
throw new Error(`unknown_page_ref: ${pageRef}`);
|
|
296
|
+
}
|
|
297
|
+
runtime.currentPageRef = pageRef;
|
|
298
|
+
}
|
|
299
|
+
export function createTargetRef(session) {
|
|
300
|
+
const runtime = ensureRuntimeState(session);
|
|
301
|
+
return `t${runtime.counters.nextTarget++}`;
|
|
302
|
+
}
|
|
303
|
+
export function createFillRef(session) {
|
|
304
|
+
const runtime = ensureRuntimeState(session);
|
|
305
|
+
return `f${runtime.counters.nextFill++}`;
|
|
306
|
+
}
|
|
307
|
+
export function createSurfaceRef(session) {
|
|
308
|
+
const runtime = ensureRuntimeState(session);
|
|
309
|
+
return `s${runtime.counters.nextSurface++}`;
|
|
310
|
+
}
|
|
311
|
+
export function saveSurfaces(session, descriptors) {
|
|
312
|
+
const runtime = ensureRuntimeState(session);
|
|
313
|
+
return descriptors.map((descriptor) => {
|
|
314
|
+
const ref = descriptor.ref ?? createSurfaceRef(session);
|
|
315
|
+
const surface = normalizeSurfaceDescriptor(descriptor, ref);
|
|
316
|
+
runtime.surfaces[ref] = surface;
|
|
317
|
+
syncSurfaceCounter(runtime, ref);
|
|
318
|
+
return surface;
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
export function replaceSurfacesForPage(session, pageRef, descriptors, options = {}) {
|
|
322
|
+
const runtime = ensureRuntimeState(session);
|
|
323
|
+
const existingEntries = Object.entries(runtime.surfaces).filter(([, surface]) => surface.pageRef === pageRef);
|
|
324
|
+
const preserveExistingOnEmpty = options.preserveExistingOnEmpty !== false;
|
|
325
|
+
const preserveExisting = options.preserveExisting !== false;
|
|
326
|
+
if (descriptors.length === 0 && preserveExistingOnEmpty) {
|
|
327
|
+
return existingEntries.map(([, surface]) => surface);
|
|
328
|
+
}
|
|
329
|
+
const reusableRefs = new Map();
|
|
330
|
+
for (const [ref, surface] of existingEntries) {
|
|
331
|
+
const identity = surfaceIdentity(surface);
|
|
332
|
+
const refs = reusableRefs.get(identity) ?? [];
|
|
333
|
+
refs.push(ref);
|
|
334
|
+
reusableRefs.set(identity, refs);
|
|
335
|
+
}
|
|
336
|
+
const nextSurfaces = [];
|
|
337
|
+
const reusedRefs = new Set();
|
|
338
|
+
for (const descriptor of descriptors) {
|
|
339
|
+
const normalizedDescriptor = normalizeSurfaceDescriptor({
|
|
340
|
+
...descriptor,
|
|
341
|
+
pageRef,
|
|
342
|
+
}, descriptor.ref ?? '__identity__');
|
|
343
|
+
const identity = surfaceIdentity(normalizedDescriptor);
|
|
344
|
+
const matchedRef = reusableRefs.get(identity)?.shift();
|
|
345
|
+
const ref = descriptor.ref ?? matchedRef ?? createSurfaceRef(session);
|
|
346
|
+
const surface = normalizeSurfaceDescriptor(descriptor, ref);
|
|
347
|
+
runtime.surfaces[ref] = surface;
|
|
348
|
+
syncSurfaceCounter(runtime, ref);
|
|
349
|
+
reusedRefs.add(ref);
|
|
350
|
+
nextSurfaces.push(surface);
|
|
351
|
+
}
|
|
352
|
+
if (!preserveExisting) {
|
|
353
|
+
for (const [ref] of existingEntries) {
|
|
354
|
+
if (!reusedRefs.has(ref)) {
|
|
355
|
+
delete runtime.surfaces[ref];
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return nextSurfaces;
|
|
360
|
+
}
|
|
361
|
+
export function saveTargets(session, descriptors) {
|
|
362
|
+
const runtime = ensureRuntimeState(session);
|
|
363
|
+
return descriptors.map((descriptor) => {
|
|
364
|
+
const ref = descriptor.ref ?? createTargetRef(session);
|
|
365
|
+
const target = normalizeTargetDescriptor(descriptor, ref);
|
|
366
|
+
runtime.targets[ref] = target;
|
|
367
|
+
syncTargetCounter(runtime, ref);
|
|
368
|
+
return target;
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
export function replaceTargetsForPage(session, pageRef, descriptors, options = {}) {
|
|
372
|
+
const runtime = ensureRuntimeState(session);
|
|
373
|
+
const existingEntries = Object.entries(runtime.targets).filter(([, target]) => target.pageRef === pageRef);
|
|
374
|
+
const preserveExistingOnEmpty = options.preserveExistingOnEmpty !== false;
|
|
375
|
+
const preserveExisting = options.preserveExisting !== false;
|
|
376
|
+
if (descriptors.length === 0 && preserveExistingOnEmpty) {
|
|
377
|
+
return existingEntries.map(([, target]) => target);
|
|
378
|
+
}
|
|
379
|
+
function pushReusableRef(map, identity, ref) {
|
|
380
|
+
const refs = map.get(identity) ?? [];
|
|
381
|
+
refs.push(ref);
|
|
382
|
+
map.set(identity, refs);
|
|
383
|
+
}
|
|
384
|
+
function takeReusableRef(map, identity, consumedRefs) {
|
|
385
|
+
const refs = map.get(identity);
|
|
386
|
+
while (refs && refs.length > 0) {
|
|
387
|
+
const candidate = refs.shift();
|
|
388
|
+
if (candidate && !consumedRefs.has(candidate)) {
|
|
389
|
+
return candidate;
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
return undefined;
|
|
393
|
+
}
|
|
394
|
+
const reusableRefs = new Map();
|
|
395
|
+
for (const [ref, target] of existingEntries) {
|
|
396
|
+
pushReusableRef(reusableRefs, targetIdentity(target), ref);
|
|
397
|
+
}
|
|
398
|
+
const nextTargets = [];
|
|
399
|
+
const reusedRefs = new Set();
|
|
400
|
+
for (const descriptor of descriptors) {
|
|
401
|
+
const normalizedDescriptor = normalizeTargetDescriptor({
|
|
402
|
+
...descriptor,
|
|
403
|
+
pageRef,
|
|
404
|
+
}, descriptor.ref ?? '__identity__');
|
|
405
|
+
const identity = targetIdentity(normalizedDescriptor);
|
|
406
|
+
const matchedRef = takeReusableRef(reusableRefs, identity, reusedRefs);
|
|
407
|
+
const ref = descriptor.ref ?? matchedRef ?? createTargetRef(session);
|
|
408
|
+
const target = normalizeTargetDescriptor(descriptor, ref);
|
|
409
|
+
runtime.targets[ref] = target;
|
|
410
|
+
syncTargetCounter(runtime, ref);
|
|
411
|
+
reusedRefs.add(ref);
|
|
412
|
+
nextTargets.push(target);
|
|
413
|
+
}
|
|
414
|
+
if (!preserveExisting) {
|
|
415
|
+
for (const [ref] of existingEntries) {
|
|
416
|
+
if (!reusedRefs.has(ref)) {
|
|
417
|
+
delete runtime.targets[ref];
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
return nextTargets;
|
|
422
|
+
}
|
|
423
|
+
export function getTarget(session, targetRef) {
|
|
424
|
+
const runtime = ensureRuntimeState(session);
|
|
425
|
+
return runtime.targets[targetRef] ?? null;
|
|
426
|
+
}
|
|
427
|
+
export function getSurface(session, surfaceRef) {
|
|
428
|
+
const runtime = ensureRuntimeState(session);
|
|
429
|
+
return runtime.surfaces[surfaceRef] ?? null;
|
|
430
|
+
}
|
|
431
|
+
export function saveSecretCatalog(session, snapshot) {
|
|
432
|
+
const runtime = ensureRuntimeState(session);
|
|
433
|
+
runtime.secretCatalogByHost[snapshot.host] = snapshot;
|
|
434
|
+
return snapshot;
|
|
435
|
+
}
|
|
436
|
+
export function getSecretCatalog(session, host) {
|
|
437
|
+
const runtime = ensureRuntimeState(session);
|
|
438
|
+
return resolveCachedSecretCatalogForHost(host, Object.values(runtime.secretCatalogByHost));
|
|
439
|
+
}
|
|
440
|
+
export function saveFillableForms(session, forms) {
|
|
441
|
+
const runtime = ensureRuntimeState(session);
|
|
442
|
+
for (const form of forms) {
|
|
443
|
+
runtime.fillableForms[form.fillRef] = form;
|
|
444
|
+
syncFillCounter(runtime, form.fillRef);
|
|
445
|
+
}
|
|
446
|
+
return forms.map((form) => runtime.fillableForms[form.fillRef]);
|
|
447
|
+
}
|
|
448
|
+
function fillableFormIdentity(form) {
|
|
449
|
+
const fieldsKey = [...form.fields].map((field) => protectedBindingKey(field)).sort().join('|');
|
|
450
|
+
return [form.pageRef, form.scopeRef ?? '', form.purpose, fieldsKey].join('||');
|
|
451
|
+
}
|
|
452
|
+
export function replaceFillableFormsForPage(session, pageRef, forms, options = {}) {
|
|
453
|
+
const runtime = ensureRuntimeState(session);
|
|
454
|
+
const existingEntries = Object.entries(runtime.fillableForms).filter(([, form]) => form.pageRef === pageRef);
|
|
455
|
+
const preserveExistingOnEmpty = options.preserveExistingOnEmpty !== false;
|
|
456
|
+
if (forms.length === 0 && preserveExistingOnEmpty) {
|
|
457
|
+
return existingEntries.map(([, form]) => form);
|
|
458
|
+
}
|
|
459
|
+
const reusableRefs = new Map();
|
|
460
|
+
for (const [fillRef, form] of existingEntries) {
|
|
461
|
+
const identity = fillableFormIdentity(form);
|
|
462
|
+
const refs = reusableRefs.get(identity) ?? [];
|
|
463
|
+
refs.push(fillRef);
|
|
464
|
+
reusableRefs.set(identity, refs);
|
|
465
|
+
}
|
|
466
|
+
const reusedRefs = new Set();
|
|
467
|
+
const nextForms = [];
|
|
468
|
+
for (const form of forms) {
|
|
469
|
+
const identity = fillableFormIdentity(form);
|
|
470
|
+
const matchedRef = (reusableRefs.get(identity) ?? []).find((ref) => !reusedRefs.has(ref));
|
|
471
|
+
const fillRef = matchedRef ?? createFillRef(session);
|
|
472
|
+
runtime.fillableForms[fillRef] = {
|
|
473
|
+
...form,
|
|
474
|
+
fillRef,
|
|
475
|
+
};
|
|
476
|
+
syncFillCounter(runtime, fillRef);
|
|
477
|
+
reusedRefs.add(fillRef);
|
|
478
|
+
nextForms.push(runtime.fillableForms[fillRef]);
|
|
479
|
+
}
|
|
480
|
+
for (const [fillRef] of existingEntries) {
|
|
481
|
+
if (!reusedRefs.has(fillRef)) {
|
|
482
|
+
delete runtime.fillableForms[fillRef];
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return nextForms;
|
|
486
|
+
}
|
|
487
|
+
export function getFillableForm(session, fillRef) {
|
|
488
|
+
const runtime = ensureRuntimeState(session);
|
|
489
|
+
return runtime.fillableForms[fillRef] ?? null;
|
|
490
|
+
}
|
|
491
|
+
export function saveSecretIntentSnapshot(session, snapshot) {
|
|
492
|
+
const runtime = ensureRuntimeState(session);
|
|
493
|
+
runtime.secretIntentSnapshots[snapshot.intentId] = snapshot;
|
|
494
|
+
return snapshot;
|
|
495
|
+
}
|
|
496
|
+
export function getSecretIntentSnapshot(session, intentId) {
|
|
497
|
+
const runtime = ensureRuntimeState(session);
|
|
498
|
+
return runtime.secretIntentSnapshots[intentId] ?? null;
|
|
499
|
+
}
|
|
500
|
+
export function saveProtectedExposure(session, exposure) {
|
|
501
|
+
const runtime = ensureRuntimeState(session);
|
|
502
|
+
const exposures = runtime.protectedExposureByPage ?? (runtime.protectedExposureByPage = {});
|
|
503
|
+
exposures[exposure.pageRef] = exposure;
|
|
504
|
+
return exposures[exposure.pageRef];
|
|
505
|
+
}
|
|
506
|
+
export function getProtectedExposure(session, pageRef) {
|
|
507
|
+
const runtime = ensureRuntimeState(session);
|
|
508
|
+
return runtime.protectedExposureByPage?.[pageRef] ?? null;
|
|
509
|
+
}
|
|
510
|
+
export function clearProtectedExposure(session, pageRef) {
|
|
511
|
+
const runtime = ensureRuntimeState(session);
|
|
512
|
+
if (!pageRef) {
|
|
513
|
+
runtime.protectedExposureByPage = {};
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
const exposures = runtime.protectedExposureByPage ?? (runtime.protectedExposureByPage = {});
|
|
517
|
+
delete exposures[pageRef];
|
|
518
|
+
}
|
|
519
|
+
export function updateSurface(session, surfaceRef, patch) {
|
|
520
|
+
const runtime = ensureRuntimeState(session);
|
|
521
|
+
const current = runtime.surfaces[surfaceRef];
|
|
522
|
+
if (!current) {
|
|
523
|
+
return null;
|
|
524
|
+
}
|
|
525
|
+
const next = normalizeSurfaceDescriptor({
|
|
526
|
+
...current,
|
|
527
|
+
...patch,
|
|
528
|
+
availability: patch.availability ?? current.availability,
|
|
529
|
+
}, surfaceRef);
|
|
530
|
+
runtime.surfaces[surfaceRef] = next;
|
|
531
|
+
return next;
|
|
532
|
+
}
|
|
533
|
+
export function markSurfaceLifecycle(session, surfaceRef, lifecycle, reason) {
|
|
534
|
+
return updateSurface(session, surfaceRef, {
|
|
535
|
+
lifecycle,
|
|
536
|
+
lifecycleReason: reason,
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
export function setSurfaceAvailability(session, surfaceRef, state, reason) {
|
|
540
|
+
return updateSurface(session, surfaceRef, {
|
|
541
|
+
availability: {
|
|
542
|
+
state,
|
|
543
|
+
reason,
|
|
544
|
+
},
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
export function deleteTarget(session, targetRef) {
|
|
548
|
+
const runtime = ensureRuntimeState(session);
|
|
549
|
+
delete runtime.targets[targetRef];
|
|
550
|
+
}
|
|
551
|
+
export function updateTarget(session, targetRef, patch) {
|
|
552
|
+
const runtime = ensureRuntimeState(session);
|
|
553
|
+
const current = runtime.targets[targetRef];
|
|
554
|
+
if (!current) {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
const next = normalizeTargetDescriptor({
|
|
558
|
+
...current,
|
|
559
|
+
...patch,
|
|
560
|
+
availability: patch.availability ?? current.availability,
|
|
561
|
+
allowedActions: patch.allowedActions ?? current.allowedActions,
|
|
562
|
+
}, targetRef);
|
|
563
|
+
runtime.targets[targetRef] = next;
|
|
564
|
+
return next;
|
|
565
|
+
}
|
|
566
|
+
export function markTargetLifecycle(session, targetRef, lifecycle, reason) {
|
|
567
|
+
return updateTarget(session, targetRef, {
|
|
568
|
+
lifecycle,
|
|
569
|
+
lifecycleReason: reason,
|
|
570
|
+
});
|
|
571
|
+
}
|
|
572
|
+
export function setTargetAvailability(session, targetRef, state, reason) {
|
|
573
|
+
return updateTarget(session, targetRef, {
|
|
574
|
+
availability: {
|
|
575
|
+
state,
|
|
576
|
+
reason,
|
|
577
|
+
},
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
export function listTargets(session) {
|
|
581
|
+
return Object.values(ensureRuntimeState(session).targets);
|
|
582
|
+
}
|
|
583
|
+
export function listSurfaces(session) {
|
|
584
|
+
return Object.values(ensureRuntimeState(session).surfaces);
|
|
585
|
+
}
|
|
586
|
+
export function clearTargets(session, pageRef) {
|
|
587
|
+
const runtime = ensureRuntimeState(session);
|
|
588
|
+
if (!pageRef) {
|
|
589
|
+
runtime.surfaces = {};
|
|
590
|
+
runtime.targets = {};
|
|
591
|
+
runtime.fillableForms = {};
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
for (const [surfaceRef, surface] of Object.entries(runtime.surfaces)) {
|
|
595
|
+
if (surface.pageRef === pageRef) {
|
|
596
|
+
delete runtime.surfaces[surfaceRef];
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
for (const [targetRef, target] of Object.entries(runtime.targets)) {
|
|
600
|
+
if (target.pageRef === pageRef) {
|
|
601
|
+
delete runtime.targets[targetRef];
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
for (const [fillRef, form] of Object.entries(runtime.fillableForms)) {
|
|
605
|
+
if (form.pageRef === pageRef) {
|
|
606
|
+
delete runtime.fillableForms[fillRef];
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
export function incrementMetric(session, metric, by = 1) {
|
|
611
|
+
const runtime = ensureRuntimeState(session);
|
|
612
|
+
runtime.metrics[metric] += by;
|
|
613
|
+
return runtime.metrics[metric];
|
|
614
|
+
}
|
|
615
|
+
export function recordActionResult(session, success, durationMs) {
|
|
616
|
+
const runtime = ensureRuntimeState(session);
|
|
617
|
+
if (success) {
|
|
618
|
+
runtime.metrics.successfulActions += 1;
|
|
619
|
+
}
|
|
620
|
+
else {
|
|
621
|
+
runtime.metrics.failedActions += 1;
|
|
622
|
+
}
|
|
623
|
+
runtime.metrics.totalActionDurationMs += Math.max(0, durationMs);
|
|
624
|
+
const attempts = runtime.metrics.successfulActions + runtime.metrics.failedActions;
|
|
625
|
+
runtime.metrics.successRate = attempts === 0 ? 0 : runtime.metrics.successfulActions / attempts;
|
|
626
|
+
runtime.metrics.averageActionDurationMs =
|
|
627
|
+
attempts === 0 ? 0 : runtime.metrics.totalActionDurationMs / attempts;
|
|
628
|
+
return runtime.metrics;
|
|
629
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { SecretCatalogSnapshot, SecretIntentSnapshot, StoredSecretFieldKey, StoredSecretKind } from './types.js';
|
|
2
|
+
export interface CreateSecretIntentInput {
|
|
3
|
+
fillRef: string;
|
|
4
|
+
storedSecretRef: string;
|
|
5
|
+
host: string;
|
|
6
|
+
pageRef: string;
|
|
7
|
+
scopeRef?: string;
|
|
8
|
+
purpose: string;
|
|
9
|
+
secretKind: StoredSecretKind;
|
|
10
|
+
requestedFieldKeys: StoredSecretFieldKey[];
|
|
11
|
+
}
|
|
12
|
+
export interface CreateSecretIntentResult {
|
|
13
|
+
intent: SecretIntentSnapshot;
|
|
14
|
+
reused: boolean;
|
|
15
|
+
}
|
|
16
|
+
export interface SecretIntentPollResult {
|
|
17
|
+
snapshot: SecretIntentSnapshot;
|
|
18
|
+
deliveredValues?: Partial<Record<StoredSecretFieldKey, string>>;
|
|
19
|
+
}
|
|
20
|
+
export declare class SecretBackendDisabledError extends Error {
|
|
21
|
+
constructor(message?: string);
|
|
22
|
+
}
|
|
23
|
+
export interface SecretBackend {
|
|
24
|
+
kind: 'mock' | 'agentpay_api';
|
|
25
|
+
resolveCatalogHost(urlOrHost: string): string;
|
|
26
|
+
syncSecretCatalog(urlOrHost: string): Promise<SecretCatalogSnapshot>;
|
|
27
|
+
createOrReuseSecretIntent(input: CreateSecretIntentInput): Promise<CreateSecretIntentResult>;
|
|
28
|
+
getSecretIntent(intentId: string): Promise<SecretIntentPollResult | null>;
|
|
29
|
+
}
|
|
30
|
+
export declare function isMockSecretBackendEnabled(): boolean;
|
|
31
|
+
export declare function getSecretBackend(): SecretBackend;
|
|
32
|
+
//# sourceMappingURL=backend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backend.d.ts","sourceRoot":"","sources":["../../src/secrets/backend.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAqCpB,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,gBAAgB,CAAC;IAC7B,kBAAkB,EAAE,oBAAoB,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAAC,CAAC,CAAC;CACjE;AAWD,qBAAa,0BAA2B,SAAQ,KAAK;gBACvC,OAAO,SAA4D;CAIhF;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,GAAG,cAAc,CAAC;IAC9B,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC9C,iBAAiB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;IACrE,yBAAyB,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IAC7F,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;CAC3E;AAyKD,wBAAgB,0BAA0B,IAAI,OAAO,CAEpD;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAYhD"}
|