@nuanu-ai/agentbrowse 0.2.46 → 0.2.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +69 -10
- package/dist/agentpay-gateway.d.ts +9 -0
- package/dist/agentpay-gateway.d.ts.map +1 -1
- package/dist/agentpay-gateway.js +30 -0
- package/dist/agentpay-stagehand-llm.d.ts.map +1 -1
- package/dist/agentpay-stagehand-llm.js +9 -1
- package/dist/command-api-tracing.d.ts +19 -0
- package/dist/command-api-tracing.d.ts.map +1 -0
- package/dist/command-api-tracing.js +137 -0
- package/dist/commands/act.d.ts.map +1 -1
- package/dist/commands/act.js +822 -670
- package/dist/commands/act.test-harness.d.ts +6 -0
- package/dist/commands/act.test-harness.d.ts.map +1 -1
- package/dist/commands/act.test-harness.js +44 -1
- package/dist/commands/action-acceptance.d.ts.map +1 -1
- package/dist/commands/action-acceptance.js +115 -0
- package/dist/commands/captcha-solve.d.ts.map +1 -1
- package/dist/commands/captcha-solve.js +83 -16
- package/dist/commands/click-action-executor.d.ts +0 -1
- package/dist/commands/click-action-executor.d.ts.map +1 -1
- package/dist/commands/click-action-executor.js +31 -77
- package/dist/commands/close.d.ts +3 -3
- package/dist/commands/close.d.ts.map +1 -1
- package/dist/commands/close.js +178 -0
- package/dist/commands/descriptor-validation.d.ts.map +1 -1
- package/dist/commands/descriptor-validation.js +75 -57
- package/dist/commands/end-session.d.ts +25 -0
- package/dist/commands/end-session.d.ts.map +1 -0
- package/dist/commands/end-session.js +161 -0
- package/dist/commands/extract-stagehand-executor.js +1 -1
- package/dist/commands/extract.d.ts.map +1 -1
- package/dist/commands/extract.js +339 -202
- package/dist/commands/fill-secret.d.ts +3 -3
- package/dist/commands/fill-secret.d.ts.map +1 -1
- package/dist/commands/fill-secret.js +419 -234
- package/dist/commands/get-secrets-catalog.d.ts.map +1 -1
- package/dist/commands/get-secrets-catalog.js +66 -5
- package/dist/commands/interaction-kernel.d.ts +46 -0
- package/dist/commands/interaction-kernel.d.ts.map +1 -0
- package/dist/commands/interaction-kernel.js +215 -0
- package/dist/commands/launch.d.ts +0 -2
- package/dist/commands/launch.d.ts.map +1 -1
- package/dist/commands/launch.js +109 -17
- package/dist/commands/navigate.d.ts.map +1 -1
- package/dist/commands/navigate.js +188 -45
- package/dist/commands/observe-accessibility.d.ts.map +1 -1
- package/dist/commands/observe-accessibility.js +50 -39
- package/dist/commands/observe-dom-label-contract.d.ts.map +1 -1
- package/dist/commands/observe-dom-label-contract.js +5 -0
- package/dist/commands/observe-inventory.d.ts +13 -0
- package/dist/commands/observe-inventory.d.ts.map +1 -1
- package/dist/commands/observe-inventory.js +320 -65
- package/dist/commands/observe-persistence.d.ts.map +1 -1
- package/dist/commands/observe-persistence.js +3 -0
- package/dist/commands/observe-projection.d.ts +1 -0
- package/dist/commands/observe-projection.d.ts.map +1 -1
- package/dist/commands/observe-projection.js +7 -2
- package/dist/commands/observe-protected.d.ts +1 -0
- package/dist/commands/observe-protected.d.ts.map +1 -1
- package/dist/commands/observe-protected.js +9 -4
- package/dist/commands/observe-semantics.d.ts.map +1 -1
- package/dist/commands/observe-semantics.js +5 -2
- package/dist/commands/observe-stagehand.d.ts +1 -0
- package/dist/commands/observe-stagehand.d.ts.map +1 -1
- package/dist/commands/observe-stagehand.js +2 -0
- package/dist/commands/observe.d.ts +2 -0
- package/dist/commands/observe.d.ts.map +1 -1
- package/dist/commands/observe.js +387 -203
- package/dist/commands/observe.test-harness.d.ts +8 -0
- package/dist/commands/observe.test-harness.d.ts.map +1 -1
- package/dist/commands/observe.test-harness.js +48 -1
- package/dist/commands/poll-secret.d.ts +6 -0
- package/dist/commands/poll-secret.d.ts.map +1 -0
- package/dist/commands/poll-secret.js +159 -0
- package/dist/commands/request-secret.d.ts +6 -0
- package/dist/commands/request-secret.d.ts.map +1 -0
- package/dist/commands/request-secret.js +284 -0
- package/dist/commands/screenshot.d.ts.map +1 -1
- package/dist/commands/screenshot.js +172 -7
- package/dist/commands/select-action-executor.d.ts.map +1 -1
- package/dist/commands/semantic-observe.d.ts +4 -0
- package/dist/commands/semantic-observe.d.ts.map +1 -1
- package/dist/commands/semantic-observe.js +388 -17
- package/dist/commands/start-session.d.ts +31 -0
- package/dist/commands/start-session.d.ts.map +1 -0
- package/dist/commands/start-session.js +347 -0
- package/dist/commands/status.d.ts +2 -1
- package/dist/commands/status.d.ts.map +1 -1
- package/dist/commands/status.js +166 -144
- package/dist/control-semantics.d.ts +1 -0
- package/dist/control-semantics.d.ts.map +1 -1
- package/dist/control-semantics.js +51 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +144 -45
- package/dist/otel-exporter.d.ts +58 -0
- package/dist/otel-exporter.d.ts.map +1 -0
- package/dist/otel-exporter.js +263 -0
- package/dist/otel-projector.d.ts +75 -0
- package/dist/otel-projector.d.ts.map +1 -0
- package/dist/otel-projector.js +409 -0
- package/dist/owned-browser.d.ts +1 -1
- package/dist/owned-browser.d.ts.map +1 -1
- package/dist/owned-browser.js +13 -1
- package/dist/owned-process.d.ts +2 -0
- package/dist/owned-process.d.ts.map +1 -1
- package/dist/owned-process.js +7 -3
- package/dist/playwright-runtime.d.ts +1 -1
- package/dist/playwright-runtime.d.ts.map +1 -1
- package/dist/playwright-runtime.js +8 -8
- package/dist/run-observability.d.ts +25 -0
- package/dist/run-observability.d.ts.map +1 -0
- package/dist/run-observability.js +115 -0
- package/dist/run-store.d.ts +274 -0
- package/dist/run-store.d.ts.map +1 -0
- package/dist/run-store.js +631 -0
- package/dist/runtime-metrics.d.ts +27 -0
- package/dist/runtime-metrics.d.ts.map +1 -0
- package/dist/runtime-metrics.js +66 -0
- package/dist/runtime-page-state.d.ts +11 -0
- package/dist/runtime-page-state.d.ts.map +1 -0
- package/dist/runtime-page-state.js +62 -0
- package/dist/runtime-protected-state.d.ts +16 -0
- package/dist/runtime-protected-state.d.ts.map +1 -0
- package/dist/runtime-protected-state.js +157 -0
- package/dist/runtime-state.d.ts +10 -44
- package/dist/runtime-state.d.ts.map +1 -1
- package/dist/runtime-state.js +57 -222
- package/dist/secrets/backend.d.ts +65 -16
- package/dist/secrets/backend.d.ts.map +1 -1
- package/dist/secrets/backend.js +135 -95
- package/dist/secrets/catalog-sync.d.ts.map +1 -1
- package/dist/secrets/catalog-sync.js +4 -1
- package/dist/secrets/form-matcher.d.ts +5 -5
- package/dist/secrets/form-matcher.d.ts.map +1 -1
- package/dist/secrets/form-matcher.js +292 -164
- package/dist/secrets/intent-output.d.ts +6 -10
- package/dist/secrets/intent-output.d.ts.map +1 -1
- package/dist/secrets/intent-output.js +4 -58
- package/dist/secrets/mock-agentpay-cabinet.d.ts +38 -27
- package/dist/secrets/mock-agentpay-cabinet.d.ts.map +1 -1
- package/dist/secrets/mock-agentpay-cabinet.js +177 -111
- package/dist/secrets/protected-artifact-guard.d.ts +2 -2
- package/dist/secrets/protected-artifact-guard.d.ts.map +1 -1
- package/dist/secrets/protected-artifact-guard.js +2 -2
- package/dist/secrets/protected-bindings.d.ts +1 -1
- package/dist/secrets/protected-bindings.d.ts.map +1 -1
- package/dist/secrets/protected-bindings.js +6 -0
- package/dist/secrets/protected-field-semantics.d.ts +9 -0
- package/dist/secrets/protected-field-semantics.d.ts.map +1 -0
- package/dist/secrets/protected-field-semantics.js +154 -0
- package/dist/secrets/protected-field-values.d.ts.map +1 -1
- package/dist/secrets/protected-field-values.js +3 -3
- package/dist/secrets/protected-fill.d.ts +1 -1
- package/dist/secrets/protected-fill.d.ts.map +1 -1
- package/dist/secrets/protected-fill.js +45 -149
- package/dist/secrets/protected-value-adapters.d.ts +2 -1
- package/dist/secrets/protected-value-adapters.d.ts.map +1 -1
- package/dist/secrets/protected-value-adapters.js +80 -1
- package/dist/secrets/request-output.d.ts +11 -0
- package/dist/secrets/request-output.d.ts.map +1 -0
- package/dist/secrets/request-output.js +75 -0
- package/dist/secrets/types.d.ts +15 -9
- package/dist/secrets/types.d.ts.map +1 -1
- package/dist/secrets/types.js +3 -0
- package/dist/session-event-exporter.d.ts +36 -0
- package/dist/session-event-exporter.d.ts.map +1 -0
- package/dist/session-event-exporter.js +428 -0
- package/dist/session.d.ts +16 -7
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +150 -23
- package/dist/sessions-backend.d.ts +354 -0
- package/dist/sessions-backend.d.ts.map +1 -0
- package/dist/sessions-backend.js +126 -0
- package/dist/solver/browser-launcher.d.ts +1 -1
- package/dist/solver/browser-launcher.d.ts.map +1 -1
- package/dist/solver/browser-launcher.js +39 -13
- package/dist/solver/captcha-solver.d.ts.map +1 -1
- package/dist/solver/captcha-solver.js +8 -1
- package/dist/solver/types.d.ts +1 -0
- package/dist/solver/types.d.ts.map +1 -1
- package/dist/workflow-session-completion.d.ts +33 -0
- package/dist/workflow-session-completion.d.ts.map +1 -0
- package/dist/workflow-session-completion.js +156 -0
- package/package.json +9 -1
- package/dist/commands/create-intent.d.ts +0 -6
- package/dist/commands/create-intent.d.ts.map +0 -1
- package/dist/commands/create-intent.js +0 -75
- package/dist/commands/poll-intent.d.ts +0 -6
- package/dist/commands/poll-intent.d.ts.map +0 -1
- package/dist/commands/poll-intent.js +0 -57
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-secrets-catalog.d.ts","sourceRoot":"","sources":["../../src/commands/get-secrets-catalog.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"get-secrets-catalog.d.ts","sourceRoot":"","sources":["../../src/commands/get-secrets-catalog.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAYnD,wBAAsB,iBAAiB,CAAC,OAAO,EAAE,aAAa,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8EjG"}
|
|
@@ -2,9 +2,39 @@
|
|
|
2
2
|
* browse get-secrets-catalog [url] — Refresh stored-secret catalog metadata for a host.
|
|
3
3
|
*/
|
|
4
4
|
import { saveSession } from '../session.js';
|
|
5
|
+
import { withApiTraceContext } from '../command-api-tracing.js';
|
|
5
6
|
import { outputContractFailure, outputJSON } from '../output.js';
|
|
7
|
+
import { exportRunStepToOtlpHttpJsonBestEffort } from '../otel-exporter.js';
|
|
8
|
+
import { appendCommandLifecycleEventBestEffort, captureStepSnapshotBestEffort, } from '../run-observability.js';
|
|
9
|
+
import { finishRunStep, startRunStep } from '../run-store.js';
|
|
6
10
|
import { getCurrentSessionPageUrl, syncSecretCatalogForUrl } from '../secrets/catalog-sync.js';
|
|
7
11
|
export async function getSecretsCatalog(session, urlOrHost) {
|
|
12
|
+
const syncStep = session.activeRunId
|
|
13
|
+
? startRunStep({
|
|
14
|
+
runId: session.activeRunId,
|
|
15
|
+
command: 'get-secrets-catalog',
|
|
16
|
+
input: {
|
|
17
|
+
...(urlOrHost ? { urlOrHost } : {}),
|
|
18
|
+
},
|
|
19
|
+
refs: {
|
|
20
|
+
pageRef: session.runtime?.currentPageRef,
|
|
21
|
+
},
|
|
22
|
+
})
|
|
23
|
+
: null;
|
|
24
|
+
captureStepSnapshotBestEffort({
|
|
25
|
+
session,
|
|
26
|
+
step: syncStep,
|
|
27
|
+
phase: 'before',
|
|
28
|
+
pageRef: session.runtime?.currentPageRef,
|
|
29
|
+
});
|
|
30
|
+
appendCommandLifecycleEventBestEffort({
|
|
31
|
+
step: syncStep,
|
|
32
|
+
phase: 'started',
|
|
33
|
+
attributes: {
|
|
34
|
+
pageRef: session.runtime?.currentPageRef,
|
|
35
|
+
hasExplicitUrlOrHost: Boolean(urlOrHost),
|
|
36
|
+
},
|
|
37
|
+
});
|
|
8
38
|
const syncInput = urlOrHost ?? getCurrentSessionPageUrl(session);
|
|
9
39
|
if (!syncInput) {
|
|
10
40
|
return outputContractFailure({
|
|
@@ -14,10 +44,41 @@ export async function getSecretsCatalog(session, urlOrHost) {
|
|
|
14
44
|
reason: 'Provide a URL explicitly or create page context first by navigating or observing.',
|
|
15
45
|
});
|
|
16
46
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
47
|
+
return withApiTraceContext({
|
|
48
|
+
runId: session.activeRunId,
|
|
49
|
+
stepId: syncStep?.stepId,
|
|
50
|
+
command: 'get-secrets-catalog',
|
|
51
|
+
}, async () => {
|
|
52
|
+
const snapshot = await syncSecretCatalogForUrl(session, syncInput);
|
|
53
|
+
saveSession(session);
|
|
54
|
+
captureStepSnapshotBestEffort({
|
|
55
|
+
session,
|
|
56
|
+
step: syncStep,
|
|
57
|
+
phase: 'after',
|
|
58
|
+
pageRef: session.runtime?.currentPageRef,
|
|
59
|
+
});
|
|
60
|
+
appendCommandLifecycleEventBestEffort({
|
|
61
|
+
step: syncStep,
|
|
62
|
+
phase: 'completed',
|
|
63
|
+
attributes: {
|
|
64
|
+
outcomeType: 'secret_catalog_synced',
|
|
65
|
+
host: snapshot.host,
|
|
66
|
+
storedSecretCount: snapshot.storedSecrets.length,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
if (session.activeRunId && syncStep?.stepId) {
|
|
70
|
+
finishRunStep({
|
|
71
|
+
runId: session.activeRunId,
|
|
72
|
+
stepId: syncStep.stepId,
|
|
73
|
+
success: true,
|
|
74
|
+
outcomeType: 'secret_catalog_synced',
|
|
75
|
+
message: 'Stored-secret catalog synced.',
|
|
76
|
+
});
|
|
77
|
+
await exportRunStepToOtlpHttpJsonBestEffort(session.activeRunId, syncStep.stepId);
|
|
78
|
+
}
|
|
79
|
+
outputJSON({
|
|
80
|
+
success: true,
|
|
81
|
+
...snapshot,
|
|
82
|
+
});
|
|
22
83
|
});
|
|
23
84
|
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { Locator, Page } from 'playwright-core';
|
|
2
|
+
import type { LocatorCandidate, SurfaceDescriptor, TargetDescriptor } from '../runtime-state.js';
|
|
3
|
+
import { type LocatorRoot } from './action-fallbacks.js';
|
|
4
|
+
export type InteractionResolutionAction = 'click' | 'fill' | 'type' | 'select' | 'press';
|
|
5
|
+
export type SharedBindingStaleReason = 'page_signature_mismatch' | 'dom_signature_mismatch' | 'locator_resolution_failed';
|
|
6
|
+
export type PreparedLocatorCandidateResolution = {
|
|
7
|
+
resolved: boolean;
|
|
8
|
+
sawDisabledTarget: boolean;
|
|
9
|
+
sawReadonlyTarget: boolean;
|
|
10
|
+
};
|
|
11
|
+
export declare function targetUsesSurfaceAsPrimaryLocator(target: Pick<TargetDescriptor, 'locatorCandidates'>, surface: Pick<SurfaceDescriptor, 'locatorCandidates'>): boolean;
|
|
12
|
+
export declare function resolveInteractionRoots(page: Page, target: Pick<TargetDescriptor, 'framePath' | 'locatorCandidates'>, surface: SurfaceDescriptor | null, attempts: string[], options?: {
|
|
13
|
+
recordSelfTargetReuse?: boolean;
|
|
14
|
+
}): Promise<{
|
|
15
|
+
baseRoot: LocatorRoot;
|
|
16
|
+
locatorRoot: LocatorRoot;
|
|
17
|
+
surfaceRoot: Locator | null;
|
|
18
|
+
}>;
|
|
19
|
+
export declare function resolveScopedLocatorRootForCandidate(baseRoot: LocatorRoot, defaultRoot: LocatorRoot, surfaceRoot: Locator | null, scope: LocatorCandidate['scope']): LocatorRoot | null;
|
|
20
|
+
export declare function prepareEditableInteractionLocator(locator: Locator, action: InteractionResolutionAction, strategy: string, attempts: string[], options?: {
|
|
21
|
+
allowReadonlyFallback?: boolean;
|
|
22
|
+
allowDescendantPressFallback?: boolean;
|
|
23
|
+
isUserActionable?: (locator: Locator) => Promise<boolean>;
|
|
24
|
+
}): Promise<{
|
|
25
|
+
locator: Locator | null;
|
|
26
|
+
blockedReason?: 'disabled' | 'readonly';
|
|
27
|
+
}>;
|
|
28
|
+
export declare function assertStoredBindingStillValid(page: Page, locator: Locator, target: Pick<TargetDescriptor, 'pageSignature' | 'domSignature'>, stage: string, options?: {
|
|
29
|
+
onReason?: (reason: SharedBindingStaleReason, stage: string) => Promise<boolean | void> | boolean | void;
|
|
30
|
+
errorForReason?: (reason: SharedBindingStaleReason, stage: string) => string;
|
|
31
|
+
}): Promise<void>;
|
|
32
|
+
export declare function resolvePreparedLocatorCandidates(params: {
|
|
33
|
+
target: Pick<TargetDescriptor, 'locatorCandidates' | 'controlFamily'>;
|
|
34
|
+
action: InteractionResolutionAction;
|
|
35
|
+
baseRoot: LocatorRoot;
|
|
36
|
+
locatorRoot: LocatorRoot;
|
|
37
|
+
surfaceRoot: Locator | null;
|
|
38
|
+
attempts: string[];
|
|
39
|
+
prepareOptions?: {
|
|
40
|
+
allowReadonlyFallback?: boolean;
|
|
41
|
+
allowDescendantPressFallback?: boolean;
|
|
42
|
+
isUserActionable?: (locator: Locator) => Promise<boolean>;
|
|
43
|
+
};
|
|
44
|
+
onPreparedLocator: (locator: Locator, strategy: LocatorCandidate['strategy']) => Promise<boolean>;
|
|
45
|
+
}): Promise<PreparedLocatorCandidateResolution>;
|
|
46
|
+
//# sourceMappingURL=interaction-kernel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interaction-kernel.d.ts","sourceRoot":"","sources":["../../src/commands/interaction-kernel.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { locatorCandidateKey } from '../runtime-state.js';
|
|
2
|
+
import { rankLocatorCandidates } from './action-acceptance.js';
|
|
3
|
+
import { buildLocator, resolveLocatorRoot } from './action-fallbacks.js';
|
|
4
|
+
import { normalizePageSignature, readLocatorDomSignature } from './descriptor-validation.js';
|
|
5
|
+
import { resolveSurfaceScopeRoot } from './target-resolution.js';
|
|
6
|
+
function defaultLocatorVisibility(locator) {
|
|
7
|
+
return locator.isVisible().catch(() => false);
|
|
8
|
+
}
|
|
9
|
+
export function targetUsesSurfaceAsPrimaryLocator(target, surface) {
|
|
10
|
+
const surfaceCandidates = new Set(surface.locatorCandidates.map(locatorCandidateKey));
|
|
11
|
+
return target.locatorCandidates.some((candidate) => surfaceCandidates.has(locatorCandidateKey(candidate)));
|
|
12
|
+
}
|
|
13
|
+
export async function resolveInteractionRoots(page, target, surface, attempts, options) {
|
|
14
|
+
const baseRoot = resolveLocatorRoot(page, target.framePath ?? surface?.framePath);
|
|
15
|
+
if (!surface) {
|
|
16
|
+
return {
|
|
17
|
+
baseRoot,
|
|
18
|
+
locatorRoot: baseRoot,
|
|
19
|
+
surfaceRoot: null,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const surfaceRoot = await resolveSurfaceScopeRoot(page, surface, attempts);
|
|
23
|
+
if (surfaceRoot) {
|
|
24
|
+
if (targetUsesSurfaceAsPrimaryLocator(target, surface)) {
|
|
25
|
+
if (options?.recordSelfTargetReuse) {
|
|
26
|
+
attempts.push('surface.resolve.self-target');
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
baseRoot,
|
|
30
|
+
locatorRoot: baseRoot,
|
|
31
|
+
surfaceRoot,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
baseRoot,
|
|
36
|
+
locatorRoot: surfaceRoot,
|
|
37
|
+
surfaceRoot,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
attempts.push('surface.resolve.fallback:page');
|
|
41
|
+
return {
|
|
42
|
+
baseRoot,
|
|
43
|
+
locatorRoot: baseRoot,
|
|
44
|
+
surfaceRoot: null,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function resolveScopedLocatorRootForCandidate(baseRoot, defaultRoot, surfaceRoot, scope) {
|
|
48
|
+
if (scope === 'root') {
|
|
49
|
+
return baseRoot;
|
|
50
|
+
}
|
|
51
|
+
if (scope === 'surface') {
|
|
52
|
+
return surfaceRoot;
|
|
53
|
+
}
|
|
54
|
+
return defaultRoot;
|
|
55
|
+
}
|
|
56
|
+
export async function prepareEditableInteractionLocator(locator, action, strategy, attempts, options) {
|
|
57
|
+
const isUserActionable = options?.isUserActionable ?? defaultLocatorVisibility;
|
|
58
|
+
const count = await locator.count().catch(() => 0);
|
|
59
|
+
if (count === 0) {
|
|
60
|
+
attempts.push(`resolve.skip:${strategy}:empty`);
|
|
61
|
+
return { locator: null };
|
|
62
|
+
}
|
|
63
|
+
if (action !== 'click' && count > 1) {
|
|
64
|
+
attempts.push(`resolve.skip:${strategy}:ambiguous:${count}`);
|
|
65
|
+
return { locator: null };
|
|
66
|
+
}
|
|
67
|
+
let resolvedLocator = locator.first();
|
|
68
|
+
if (action === 'click' && count > 1) {
|
|
69
|
+
const visibleCandidates = [];
|
|
70
|
+
for (let index = 0; index < count; index += 1) {
|
|
71
|
+
const candidate = locator.nth(index);
|
|
72
|
+
const visible = await isUserActionable(candidate).catch(() => false);
|
|
73
|
+
if (!visible) {
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
visibleCandidates.push(candidate);
|
|
77
|
+
}
|
|
78
|
+
if (visibleCandidates.length === 1) {
|
|
79
|
+
attempts.push(`resolve.visible-unique:${strategy}`);
|
|
80
|
+
resolvedLocator = visibleCandidates[0] ?? locator.first();
|
|
81
|
+
}
|
|
82
|
+
else if (visibleCandidates.length > 1) {
|
|
83
|
+
attempts.push(`resolve.skip:${strategy}:ambiguous-visible:${visibleCandidates.length}`);
|
|
84
|
+
return { locator: null };
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
attempts.push(`resolve.skip:${strategy}:hidden`);
|
|
88
|
+
return { locator: null };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
const visible = await isUserActionable(resolvedLocator).catch(() => false);
|
|
92
|
+
if (!visible) {
|
|
93
|
+
attempts.push(`resolve.skip:${strategy}:hidden`);
|
|
94
|
+
return { locator: null };
|
|
95
|
+
}
|
|
96
|
+
const disabled = await resolvedLocator.isDisabled?.().catch(() => false);
|
|
97
|
+
if (disabled) {
|
|
98
|
+
attempts.push(`resolve.skip:${strategy}:disabled`);
|
|
99
|
+
return { locator: null, blockedReason: 'disabled' };
|
|
100
|
+
}
|
|
101
|
+
const shouldRecoverDescendantEditable = action === 'fill' ||
|
|
102
|
+
action === 'type' ||
|
|
103
|
+
(action === 'press' && options?.allowDescendantPressFallback);
|
|
104
|
+
if (!shouldRecoverDescendantEditable) {
|
|
105
|
+
return { locator: resolvedLocator };
|
|
106
|
+
}
|
|
107
|
+
const editable = await resolvedLocator.isEditable().catch(() => false);
|
|
108
|
+
if (editable) {
|
|
109
|
+
return { locator: resolvedLocator };
|
|
110
|
+
}
|
|
111
|
+
const descendantSelector = action === 'press' && options?.allowDescendantPressFallback
|
|
112
|
+
? 'input:not([type="hidden"]), textarea, select, [contenteditable="true"], [role="textbox"], [role="combobox"]'
|
|
113
|
+
: 'input:not([type="hidden"]), textarea, select, [contenteditable="true"]';
|
|
114
|
+
const descendantCandidates = resolvedLocator.locator(descendantSelector);
|
|
115
|
+
const descendantCount = await descendantCandidates.count().catch(() => 0);
|
|
116
|
+
const candidateDescendants = [];
|
|
117
|
+
for (let index = 0; index < descendantCount; index += 1) {
|
|
118
|
+
const descendant = descendantCandidates.nth(index);
|
|
119
|
+
const descendantVisible = await isUserActionable(descendant).catch(() => false);
|
|
120
|
+
if (!descendantVisible) {
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (action !== 'press' || !options?.allowDescendantPressFallback) {
|
|
124
|
+
const descendantEditable = await descendant.isEditable().catch(() => false);
|
|
125
|
+
if (!descendantEditable) {
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
candidateDescendants.push(descendant);
|
|
130
|
+
}
|
|
131
|
+
if (candidateDescendants.length === 1) {
|
|
132
|
+
attempts.push(action === 'press' && options?.allowDescendantPressFallback
|
|
133
|
+
? `resolve.descendant-press:${strategy}`
|
|
134
|
+
: `resolve.descendant-editable:${strategy}`);
|
|
135
|
+
return { locator: candidateDescendants[0] ?? null };
|
|
136
|
+
}
|
|
137
|
+
if (candidateDescendants.length > 1) {
|
|
138
|
+
attempts.push(`resolve.skip:${strategy}:descendant-ambiguous:${candidateDescendants.length}`);
|
|
139
|
+
return { locator: null };
|
|
140
|
+
}
|
|
141
|
+
if (options?.allowReadonlyFallback) {
|
|
142
|
+
attempts.push(`resolve.readonly-fallback:${strategy}`);
|
|
143
|
+
return { locator: resolvedLocator };
|
|
144
|
+
}
|
|
145
|
+
attempts.push(`resolve.skip:${strategy}:readonly`);
|
|
146
|
+
return { locator: null, blockedReason: 'readonly' };
|
|
147
|
+
}
|
|
148
|
+
export async function assertStoredBindingStillValid(page, locator, target, stage, options) {
|
|
149
|
+
const errorForReason = options?.errorForReason ??
|
|
150
|
+
((reason, errorStage) => `binding_stale:${reason}:${errorStage}`);
|
|
151
|
+
if (target.pageSignature && normalizePageSignature(page.url()) !== target.pageSignature) {
|
|
152
|
+
const handled = await options?.onReason?.('page_signature_mismatch', stage);
|
|
153
|
+
if (handled === true) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
throw new Error(errorForReason('page_signature_mismatch', stage));
|
|
157
|
+
}
|
|
158
|
+
const liveCount = await locator.count().catch(() => 0);
|
|
159
|
+
if (liveCount === 0) {
|
|
160
|
+
const handled = await options?.onReason?.('locator_resolution_failed', stage);
|
|
161
|
+
if (handled === true) {
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
throw new Error(errorForReason('locator_resolution_failed', stage));
|
|
165
|
+
}
|
|
166
|
+
if (!target.domSignature) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const liveSignature = await readLocatorDomSignature(locator).catch(() => null);
|
|
170
|
+
if (liveSignature && liveSignature !== target.domSignature) {
|
|
171
|
+
const handled = await options?.onReason?.('dom_signature_mismatch', stage);
|
|
172
|
+
if (handled === true) {
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
throw new Error(errorForReason('dom_signature_mismatch', stage));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export async function resolvePreparedLocatorCandidates(params) {
|
|
179
|
+
let sawDisabledTarget = false;
|
|
180
|
+
let sawReadonlyTarget = false;
|
|
181
|
+
for (const candidate of rankLocatorCandidates(params.target.locatorCandidates, params.action)) {
|
|
182
|
+
const candidateRoot = resolveScopedLocatorRootForCandidate(params.baseRoot, params.locatorRoot, params.surfaceRoot, candidate.scope);
|
|
183
|
+
if (!candidateRoot) {
|
|
184
|
+
params.attempts.push(`resolve.skip:${candidate.strategy}:surface-unavailable`);
|
|
185
|
+
continue;
|
|
186
|
+
}
|
|
187
|
+
const locator = buildLocator(candidateRoot, candidate);
|
|
188
|
+
if (!locator) {
|
|
189
|
+
continue;
|
|
190
|
+
}
|
|
191
|
+
const preparedLocator = await prepareEditableInteractionLocator(locator, params.action, candidate.strategy, params.attempts, params.prepareOptions);
|
|
192
|
+
if (preparedLocator.blockedReason === 'disabled') {
|
|
193
|
+
sawDisabledTarget = true;
|
|
194
|
+
}
|
|
195
|
+
if (preparedLocator.blockedReason === 'readonly') {
|
|
196
|
+
sawReadonlyTarget = true;
|
|
197
|
+
}
|
|
198
|
+
if (!preparedLocator.locator) {
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
const resolved = await params.onPreparedLocator(preparedLocator.locator, candidate.strategy);
|
|
202
|
+
if (resolved) {
|
|
203
|
+
return {
|
|
204
|
+
resolved: true,
|
|
205
|
+
sawDisabledTarget,
|
|
206
|
+
sawReadonlyTarget,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
return {
|
|
211
|
+
resolved: false,
|
|
212
|
+
sawDisabledTarget,
|
|
213
|
+
sawReadonlyTarget,
|
|
214
|
+
};
|
|
215
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* browse launch [url] — Start browser session, optionally navigate.
|
|
3
3
|
*/
|
|
4
|
-
import type { SecretCatalogSummary } from '../secrets/catalog-sync.js';
|
|
5
4
|
export type LaunchCliOptions = {
|
|
6
5
|
compact?: boolean;
|
|
7
6
|
profile?: string;
|
|
@@ -17,7 +16,6 @@ export type LaunchSuccessResult = {
|
|
|
17
16
|
cdpUrl: string;
|
|
18
17
|
url: string;
|
|
19
18
|
title: string;
|
|
20
|
-
secretCatalog?: SecretCatalogSummary;
|
|
21
19
|
};
|
|
22
20
|
export type LaunchFailureResult = {
|
|
23
21
|
success: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/commands/launch.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"launch.d.ts","sourceRoot":"","sources":["../../src/commands/launch.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgCH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,IAAI,CAAC;IACd,OAAO,EAAE,SAAS,CAAC;IACnB,mBAAmB,EAAE,IAAI,CAAC;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,KAAK,CAAC;IACf,KAAK,EAAE,uBAAuB,CAAC;IAC/B,WAAW,EAAE,SAAS,CAAC;IACvB,OAAO,EAAE,wBAAwB,CAAC;IAClC,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG,mBAAmB,GAAG,mBAAmB,CAAC;AAErE,wBAAsB,MAAM,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAgBzF"}
|
package/dist/commands/launch.js
CHANGED
|
@@ -4,20 +4,23 @@
|
|
|
4
4
|
import { readConfig } from '../solver/config.js';
|
|
5
5
|
import { ensureProfile } from '../solver/profile-manager.js';
|
|
6
6
|
import { launchSolver } from '../solver/browser-launcher.js';
|
|
7
|
-
import { buildOwnedSession, isOwnedSession, loadSession, saveSession } from '../session.js';
|
|
7
|
+
import { buildOwnedSession, isOwnedSession, isSessionAlive, loadSession, saveSession, } from '../session.js';
|
|
8
8
|
import { applyAgentpayGatewayEnv, tryResolveAgentpayGatewayConfig } from '../agentpay-gateway.js';
|
|
9
9
|
import { connectPlaywright, disconnectPlaywright, syncLaunchPage } from '../playwright-runtime.js';
|
|
10
|
-
import { summarizeSecretCatalog, syncSecretCatalogForUrl } from '../secrets/catalog-sync.js';
|
|
11
10
|
import { closeOwnedBrowser } from '../owned-browser.js';
|
|
12
11
|
import { cleanupManagedBrowserPids } from '../owned-process.js';
|
|
12
|
+
import { deleteLocalRun, finishRunRecord, pruneLocalRuns } from '../run-store.js';
|
|
13
13
|
import { info } from '../output.js';
|
|
14
|
+
import { clearWorkflowState, completeWorkflowSessionRemote, } from '../workflow-session-completion.js';
|
|
14
15
|
const DEFAULT_PROFILE = 'default';
|
|
15
16
|
const COMPACT_WINDOW = {
|
|
16
17
|
width: 1280,
|
|
17
18
|
height: 900,
|
|
18
19
|
};
|
|
19
20
|
export async function launch(url, opts) {
|
|
20
|
-
const
|
|
21
|
+
const existingSession = loadSession();
|
|
22
|
+
pruneLocalRunsBestEffort('launch', existingSession?.activeRunId);
|
|
23
|
+
const cleanupFailure = await cleanupOwnedSession(existingSession);
|
|
21
24
|
if (cleanupFailure) {
|
|
22
25
|
return cleanupFailure;
|
|
23
26
|
}
|
|
@@ -28,14 +31,22 @@ export async function launch(url, opts) {
|
|
|
28
31
|
const noProxy = opts?.noProxy ?? false;
|
|
29
32
|
return launchManaged(url, profileName, headless, compact, proxyOverride, noProxy);
|
|
30
33
|
}
|
|
31
|
-
async function cleanupOwnedSession() {
|
|
32
|
-
const existingSession = loadSession();
|
|
34
|
+
async function cleanupOwnedSession(existingSession) {
|
|
33
35
|
const excludePids = new Set();
|
|
36
|
+
const workflowCleanupFailure = await cleanupPreviousWorkflowState(existingSession);
|
|
37
|
+
if (workflowCleanupFailure) {
|
|
38
|
+
return workflowCleanupFailure;
|
|
39
|
+
}
|
|
34
40
|
if (isOwnedSession(existingSession)) {
|
|
35
41
|
excludePids.add(existingSession.pid);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
42
|
+
if (await isSessionAlive(existingSession)) {
|
|
43
|
+
const closeResult = await closeOwnedBrowser(existingSession);
|
|
44
|
+
if (!closeResult.success) {
|
|
45
|
+
return buildLaunchFailure(new Error(closeResult.reason));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
info(`[launch] previous managed browser pid ${existingSession.pid} was already gone; closing active workflow context before relaunch`);
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
52
|
// Phase-1 ownership removed port-global prekill, so launch needs a second guardrail
|
|
@@ -49,6 +60,95 @@ async function cleanupOwnedSession() {
|
|
|
49
60
|
}
|
|
50
61
|
return null;
|
|
51
62
|
}
|
|
63
|
+
async function cleanupPreviousWorkflowState(existingSession) {
|
|
64
|
+
if (!existingSession) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
if (existingSession.intentSessionId) {
|
|
68
|
+
const remoteCompletion = await completeWorkflowSessionRemote({
|
|
69
|
+
session: existingSession,
|
|
70
|
+
stepId: undefined,
|
|
71
|
+
command: 'launch',
|
|
72
|
+
terminalStatus: 'canceled',
|
|
73
|
+
runStatus: 'aborted',
|
|
74
|
+
summary: 'Workflow session canceled because a new launch replaced the current browser session.',
|
|
75
|
+
outcomeType: 'workflow_session_canceled',
|
|
76
|
+
message: 'Workflow session canceled because a new launch replaced the current browser session.',
|
|
77
|
+
reason: 'A new launch command replaced the previous browser session.',
|
|
78
|
+
allowMissingStep: true,
|
|
79
|
+
});
|
|
80
|
+
if (!remoteCompletion.success) {
|
|
81
|
+
if (isStaleWorkflowBindingFailure(remoteCompletion.error)) {
|
|
82
|
+
info(`[launch] clearing stale workflow binding before relaunch: ${remoteCompletion.reason}`);
|
|
83
|
+
deleteStaleRunBestEffort('launch', existingSession.activeRunId);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
return buildLaunchFailure(new Error(`Active workflow session cleanup blocked relaunch: ${remoteCompletion.reason}`));
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
await finalizeRunBestEffort('launch', existingSession.activeRunId, {
|
|
91
|
+
status: 'aborted',
|
|
92
|
+
finalOutcome: {
|
|
93
|
+
success: false,
|
|
94
|
+
outcomeType: 'replaced_by_launch',
|
|
95
|
+
message: 'Previous run was replaced by a new launch.',
|
|
96
|
+
reason: 'A new launch started while the previous browser session was still active.',
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
persistClearedWorkflowStateBestEffort('launch', existingSession);
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
function isStaleWorkflowBindingFailure(error) {
|
|
103
|
+
return error === 'workflow_run_unavailable' || error === 'workflow_step_unavailable';
|
|
104
|
+
}
|
|
105
|
+
function pruneLocalRunsBestEffort(command, activeRunId) {
|
|
106
|
+
try {
|
|
107
|
+
const result = pruneLocalRuns({ activeRunId });
|
|
108
|
+
if (result.deletedRunIds.length > 0) {
|
|
109
|
+
info(`[${command}] pruned stale local run${result.deletedRunIds.length === 1 ? '' : 's'} ${result.deletedRunIds.join(', ')}`);
|
|
110
|
+
}
|
|
111
|
+
if (result.failedRunIds.length > 0) {
|
|
112
|
+
info(`[${command}] failed to prune local run${result.failedRunIds.length === 1 ? '' : 's'} ${result.failedRunIds.map((entry) => `${entry.runId}: ${entry.reason}`).join('; ')}`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (error) {
|
|
116
|
+
info(`[${command}] local run prune failed: ${formatUnknownError(error)}`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async function finalizeRunBestEffort(command, runId, options) {
|
|
120
|
+
if (!runId) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
try {
|
|
124
|
+
finishRunRecord(runId, options);
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
info(`[${command}] failed to finalize local run ${runId}: ${formatUnknownError(error)}`);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function deleteStaleRunBestEffort(command, runId) {
|
|
131
|
+
if (!runId) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const deleted = deleteLocalRun(runId);
|
|
136
|
+
if (deleted) {
|
|
137
|
+
info(`[${command}] deleted stale local run ${runId}`);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
info(`[${command}] failed to delete stale local run ${runId}: ${formatUnknownError(error)}`);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function persistClearedWorkflowStateBestEffort(command, session) {
|
|
145
|
+
try {
|
|
146
|
+
saveSession(clearWorkflowState(session));
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
info(`[${command}] failed to persist cleared workflow state: ${formatUnknownError(error)}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
52
152
|
function buildLaunchFailure(err) {
|
|
53
153
|
return {
|
|
54
154
|
success: false,
|
|
@@ -62,7 +162,6 @@ async function launchManaged(url, profileName, headless, compact, proxyOverride,
|
|
|
62
162
|
let session;
|
|
63
163
|
let browser = null;
|
|
64
164
|
let runtimeProxy;
|
|
65
|
-
let secretCatalogSummary;
|
|
66
165
|
try {
|
|
67
166
|
const baseProfile = ensureProfile(profileName);
|
|
68
167
|
const config = readConfig();
|
|
@@ -125,16 +224,10 @@ async function launchManaged(url, profileName, headless, compact, proxyOverride,
|
|
|
125
224
|
}
|
|
126
225
|
finally {
|
|
127
226
|
if (browser) {
|
|
128
|
-
disconnectPlaywright(browser);
|
|
227
|
+
await disconnectPlaywright(browser);
|
|
129
228
|
}
|
|
130
229
|
await session.disconnect();
|
|
131
230
|
}
|
|
132
|
-
if (url) {
|
|
133
|
-
const snapshot = await syncSecretCatalogForUrl(persistedSession, currentUrl || url);
|
|
134
|
-
if (snapshot) {
|
|
135
|
-
secretCatalogSummary = summarizeSecretCatalog(snapshot);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
231
|
saveSession(persistedSession);
|
|
139
232
|
return {
|
|
140
233
|
success: true,
|
|
@@ -144,7 +237,6 @@ async function launchManaged(url, profileName, headless, compact, proxyOverride,
|
|
|
144
237
|
cdpUrl: session.cdpUrl,
|
|
145
238
|
url: currentUrl,
|
|
146
239
|
title,
|
|
147
|
-
secretCatalog: secretCatalogSummary,
|
|
148
240
|
};
|
|
149
241
|
}
|
|
150
242
|
function formatUnknownError(err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/commands/navigate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"navigate.d.ts","sourceRoot":"","sources":["../../src/commands/navigate.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAwFnD,wBAAsB,QAAQ,CAAC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8JvF"}
|