autokap 1.1.4 → 1.1.5
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/dist/cli-runner.js +70 -15
- package/dist/cli.js +0 -0
- package/dist/clip-capture-loop.d.ts +12 -0
- package/dist/clip-capture-loop.js +26 -0
- package/dist/web-playwright-local.js +4 -1
- package/package.json +1 -1
- package/dist/agent-action-recovery.d.ts +0 -45
- package/dist/agent-action-recovery.js +0 -370
- package/dist/agent-message-utils.d.ts +0 -21
- package/dist/agent-message-utils.js +0 -77
- package/dist/agent-url-utils.d.ts +0 -30
- package/dist/agent-url-utils.js +0 -138
- package/dist/agent.d.ts +0 -226
- package/dist/agent.js +0 -6666
- package/dist/browser-utils.d.ts +0 -31
- package/dist/browser-utils.js +0 -97
- package/dist/capture-studio-sync.d.ts +0 -23
- package/dist/capture-studio-sync.js +0 -172
- package/dist/clip-begin-frame-recorder.d.ts +0 -44
- package/dist/clip-begin-frame-recorder.js +0 -250
- package/dist/clip-capture-backend.d.ts +0 -25
- package/dist/clip-capture-backend.js +0 -189
- package/dist/clip-frame-recorder.d.ts +0 -63
- package/dist/clip-frame-recorder.js +0 -305
- package/dist/clip-orchestrator.d.ts +0 -148
- package/dist/clip-orchestrator.js +0 -957
- package/dist/clip-runtime.d.ts +0 -18
- package/dist/clip-runtime.js +0 -67
- package/dist/clip-scale.d.ts +0 -10
- package/dist/clip-scale.js +0 -21
- package/dist/clip-screencast-recorder.d.ts +0 -42
- package/dist/clip-screencast-recorder.js +0 -242
- package/dist/clip-sidecar.d.ts +0 -54
- package/dist/clip-sidecar.js +0 -208
- package/dist/cost-resolution-monitor.d.ts +0 -16
- package/dist/cost-resolution-monitor.js +0 -34
- package/dist/credential-templates.d.ts +0 -5
- package/dist/credential-templates.js +0 -60
- package/dist/dom-css-purger.d.ts +0 -65
- package/dist/dom-css-purger.js +0 -333
- package/dist/dom-font-inliner.d.ts +0 -45
- package/dist/dom-font-inliner.js +0 -148
- package/dist/dom-patch-resolver.d.ts +0 -52
- package/dist/dom-patch-resolver.js +0 -242
- package/dist/dom-serializer.d.ts +0 -82
- package/dist/dom-serializer.js +0 -378
- package/dist/element-capture.d.ts +0 -13
- package/dist/element-capture.js +0 -522
- package/dist/fonts-loader.d.ts +0 -14
- package/dist/fonts-loader.js +0 -55
- package/dist/hybrid-navigator.d.ts +0 -138
- package/dist/hybrid-navigator.js +0 -468
- package/dist/legacy/agent-action-recovery.d.ts +0 -45
- package/dist/legacy/agent-action-recovery.js +0 -370
- package/dist/legacy/agent-message-utils.d.ts +0 -21
- package/dist/legacy/agent-message-utils.js +0 -77
- package/dist/legacy/agent-url-utils.d.ts +0 -30
- package/dist/legacy/agent-url-utils.js +0 -138
- package/dist/legacy/agent.d.ts +0 -226
- package/dist/legacy/agent.js +0 -6666
- package/dist/legacy/clip-orchestrator.d.ts +0 -148
- package/dist/legacy/clip-orchestrator.js +0 -957
- package/dist/legacy/credential-templates.d.ts +0 -5
- package/dist/legacy/credential-templates.js +0 -60
- package/dist/legacy/hybrid-navigator.d.ts +0 -138
- package/dist/legacy/hybrid-navigator.js +0 -468
- package/dist/legacy/llm-usage.d.ts +0 -17
- package/dist/legacy/llm-usage.js +0 -45
- package/dist/legacy/prompt-cache.d.ts +0 -10
- package/dist/legacy/prompt-cache.js +0 -24
- package/dist/legacy/prompts.d.ts +0 -175
- package/dist/legacy/prompts.js +0 -1038
- package/dist/legacy/tools.d.ts +0 -4
- package/dist/legacy/tools.js +0 -216
- package/dist/legacy/video-agent.d.ts +0 -143
- package/dist/legacy/video-agent.js +0 -4788
- package/dist/legacy/video-observation.d.ts +0 -36
- package/dist/legacy/video-observation.js +0 -192
- package/dist/legacy/video-planner.d.ts +0 -12
- package/dist/legacy/video-planner.js +0 -501
- package/dist/legacy/video-prompts.d.ts +0 -37
- package/dist/legacy/video-prompts.js +0 -569
- package/dist/legacy/video-tools.d.ts +0 -3
- package/dist/legacy/video-tools.js +0 -59
- package/dist/legacy/video-variant-state.d.ts +0 -29
- package/dist/legacy/video-variant-state.js +0 -80
- package/dist/legacy/vision-model.d.ts +0 -17
- package/dist/legacy/vision-model.js +0 -74
- package/dist/llm-usage.d.ts +0 -17
- package/dist/llm-usage.js +0 -45
- package/dist/overlay-utils.d.ts +0 -14
- package/dist/overlay-utils.js +0 -13
- package/dist/prompt-cache.d.ts +0 -10
- package/dist/prompt-cache.js +0 -24
- package/dist/prompts.d.ts +0 -175
- package/dist/prompts.js +0 -1038
- package/dist/remote-browser.d.ts +0 -215
- package/dist/remote-browser.js +0 -360
- package/dist/svg-browser-bar.d.ts +0 -33
- package/dist/svg-browser-bar.js +0 -206
- package/dist/svg-status-bar.d.ts +0 -36
- package/dist/svg-status-bar.js +0 -597
- package/dist/svg-text.d.ts +0 -61
- package/dist/svg-text.js +0 -118
- package/dist/tools.d.ts +0 -4
- package/dist/tools.js +0 -216
- package/dist/v2/action-verifier.d.ts +0 -29
- package/dist/v2/action-verifier.js +0 -133
- package/dist/v2/alt-text.d.ts +0 -26
- package/dist/v2/alt-text.js +0 -55
- package/dist/v2/benchmark.d.ts +0 -59
- package/dist/v2/benchmark.js +0 -135
- package/dist/v2/capture-strategy.d.ts +0 -30
- package/dist/v2/capture-strategy.js +0 -67
- package/dist/v2/capture-verification.d.ts +0 -35
- package/dist/v2/capture-verification.js +0 -95
- package/dist/v2/circuit-breaker.d.ts +0 -42
- package/dist/v2/circuit-breaker.js +0 -119
- package/dist/v2/cli-runner-local.d.ts +0 -11
- package/dist/v2/cli-runner-local.js +0 -91
- package/dist/v2/cli-runner.d.ts +0 -34
- package/dist/v2/cli-runner.js +0 -300
- package/dist/v2/compiler-prompts.d.ts +0 -27
- package/dist/v2/compiler-prompts.js +0 -123
- package/dist/v2/compiler.d.ts +0 -37
- package/dist/v2/compiler.js +0 -147
- package/dist/v2/explorer.d.ts +0 -41
- package/dist/v2/explorer.js +0 -56
- package/dist/v2/index.d.ts +0 -37
- package/dist/v2/index.js +0 -31
- package/dist/v2/llm-healer.d.ts +0 -62
- package/dist/v2/llm-healer.js +0 -166
- package/dist/v2/llm-provider.d.ts +0 -29
- package/dist/v2/llm-provider.js +0 -80
- package/dist/v2/opcode-runner.d.ts +0 -47
- package/dist/v2/opcode-runner.js +0 -634
- package/dist/v2/overlay-engine.d.ts +0 -24
- package/dist/v2/overlay-engine.js +0 -150
- package/dist/v2/postcondition.d.ts +0 -16
- package/dist/v2/postcondition.js +0 -249
- package/dist/v2/program-patcher.d.ts +0 -25
- package/dist/v2/program-patcher.js +0 -44
- package/dist/v2/recovery-chain.d.ts +0 -30
- package/dist/v2/recovery-chain.js +0 -368
- package/dist/v2/schema.d.ts +0 -2580
- package/dist/v2/schema.js +0 -295
- package/dist/v2/selector-resolver.d.ts +0 -34
- package/dist/v2/selector-resolver.js +0 -181
- package/dist/v2/semantic-resolver.d.ts +0 -35
- package/dist/v2/semantic-resolver.js +0 -161
- package/dist/v2/smart-wait.d.ts +0 -27
- package/dist/v2/smart-wait.js +0 -81
- package/dist/v2/types.d.ts +0 -444
- package/dist/v2/types.js +0 -19
- package/dist/v2/web-playwright-local.d.ts +0 -69
- package/dist/v2/web-playwright-local.js +0 -392
- package/dist/video-agent.d.ts +0 -143
- package/dist/video-agent.js +0 -4788
- package/dist/video-observation.d.ts +0 -36
- package/dist/video-observation.js +0 -192
- package/dist/video-planner.d.ts +0 -12
- package/dist/video-planner.js +0 -501
- package/dist/video-prompts.d.ts +0 -37
- package/dist/video-prompts.js +0 -554
- package/dist/video-tools.d.ts +0 -3
- package/dist/video-tools.js +0 -59
- package/dist/video-variant-state.d.ts +0 -29
- package/dist/video-variant-state.js +0 -80
- package/dist/vision-model.d.ts +0 -17
- package/dist/vision-model.js +0 -74
- package/dist/ws-auth.d.ts +0 -20
- package/dist/ws-auth.js +0 -70
- package/dist/ws-broadcast.d.ts +0 -34
- package/dist/ws-broadcast.js +0 -85
- package/dist/ws-connection-limits.d.ts +0 -12
- package/dist/ws-connection-limits.js +0 -44
- package/dist/ws-handler-utils.d.ts +0 -32
- package/dist/ws-handler-utils.js +0 -139
- package/dist/ws-handler.d.ts +0 -10
- package/dist/ws-handler.js +0 -1793
- package/dist/ws-metrics-server.d.ts +0 -9
- package/dist/ws-metrics-server.js +0 -31
- package/dist/ws-server.d.ts +0 -9
- package/dist/ws-server.js +0 -92
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Message compression and conversation history utilities for the capture agent.
|
|
3
|
-
* Extracted from agent.ts — these are pure functions with no closure dependencies.
|
|
4
|
-
*/
|
|
5
|
-
import type { ChatCompletionMessageParam } from 'openai/resources/chat/completions';
|
|
6
|
-
/**
|
|
7
|
-
* Remove old screenshots from the conversation history, keeping only the most recent ones.
|
|
8
|
-
* Replaces image_url parts with a compact text placeholder.
|
|
9
|
-
*/
|
|
10
|
-
export declare function compressOldScreenshots(messages: ChatCompletionMessageParam[], keepRecentImages?: number): void;
|
|
11
|
-
/**
|
|
12
|
-
* Strip <page_dom>...</page_dom> blocks from old user messages to reduce token count.
|
|
13
|
-
* Keeps the DOM in the most recent `keepRecentWithDom` user messages intact.
|
|
14
|
-
*/
|
|
15
|
-
export declare function compressOldDomBlocks(messages: ChatCompletionMessageParam[], keepRecentWithDom?: number, preservedPrefixMessages?: number): void;
|
|
16
|
-
/**
|
|
17
|
-
* Trim the conversation thread to avoid context window overflow.
|
|
18
|
-
* Always preserves the first `preservedPrefixMessages` entries, then the last maxMessages messages.
|
|
19
|
-
* Also compresses old screenshots and DOM blocks to save tokens.
|
|
20
|
-
*/
|
|
21
|
-
export declare function trimConversationHistory(messages: ChatCompletionMessageParam[], maxMessages?: number, preservedPrefixMessages?: number): void;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Message compression and conversation history utilities for the capture agent.
|
|
3
|
-
* Extracted from agent.ts — these are pure functions with no closure dependencies.
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* Remove old screenshots from the conversation history, keeping only the most recent ones.
|
|
7
|
-
* Replaces image_url parts with a compact text placeholder.
|
|
8
|
-
*/
|
|
9
|
-
export function compressOldScreenshots(messages, keepRecentImages = 3) {
|
|
10
|
-
let imageCount = 0;
|
|
11
|
-
for (let i = messages.length - 1; i >= 1; i--) {
|
|
12
|
-
const msg = messages[i];
|
|
13
|
-
if (msg.role !== 'user' || !Array.isArray(msg.content))
|
|
14
|
-
continue;
|
|
15
|
-
const content = msg.content;
|
|
16
|
-
const hasImage = content.some(p => p.type === 'image_url');
|
|
17
|
-
if (!hasImage)
|
|
18
|
-
continue;
|
|
19
|
-
imageCount++;
|
|
20
|
-
if (imageCount <= keepRecentImages)
|
|
21
|
-
continue;
|
|
22
|
-
msg.content = content.map(p => p.type === 'image_url'
|
|
23
|
-
? { type: 'text', text: '[screenshot removed — older context]' }
|
|
24
|
-
: p);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Strip <page_dom>...</page_dom> blocks from old user messages to reduce token count.
|
|
29
|
-
* Keeps the DOM in the most recent `keepRecentWithDom` user messages intact.
|
|
30
|
-
*/
|
|
31
|
-
export function compressOldDomBlocks(messages, keepRecentWithDom = 6, preservedPrefixMessages = 1) {
|
|
32
|
-
const PAGE_DOM_RE = /<page_dom>[\s\S]*?<\/page_dom>/g;
|
|
33
|
-
const PLACEHOLDER = '<page_dom>[older context — see current iteration for latest DOM]</page_dom>';
|
|
34
|
-
let domMessageCount = 0;
|
|
35
|
-
for (let i = messages.length - 1; i >= preservedPrefixMessages; i--) {
|
|
36
|
-
const msg = messages[i];
|
|
37
|
-
if (msg.role !== 'user')
|
|
38
|
-
continue;
|
|
39
|
-
const contentArr = Array.isArray(msg.content) ? msg.content : null;
|
|
40
|
-
const hasDom = contentArr
|
|
41
|
-
? contentArr.some(p => typeof p === 'object' && 'text' in p && typeof p.text === 'string' && PAGE_DOM_RE.test(p.text))
|
|
42
|
-
: typeof msg.content === 'string' && PAGE_DOM_RE.test(msg.content);
|
|
43
|
-
PAGE_DOM_RE.lastIndex = 0;
|
|
44
|
-
if (!hasDom)
|
|
45
|
-
continue;
|
|
46
|
-
domMessageCount++;
|
|
47
|
-
if (domMessageCount <= keepRecentWithDom)
|
|
48
|
-
continue;
|
|
49
|
-
if (contentArr) {
|
|
50
|
-
for (const part of contentArr) {
|
|
51
|
-
if (typeof part === 'object' && 'text' in part && typeof part.text === 'string') {
|
|
52
|
-
PAGE_DOM_RE.lastIndex = 0;
|
|
53
|
-
part.text = part.text.replace(PAGE_DOM_RE, PLACEHOLDER);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
else if (typeof msg.content === 'string') {
|
|
58
|
-
PAGE_DOM_RE.lastIndex = 0;
|
|
59
|
-
msg.content = msg.content.replace(PAGE_DOM_RE, PLACEHOLDER);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* Trim the conversation thread to avoid context window overflow.
|
|
65
|
-
* Always preserves the first `preservedPrefixMessages` entries, then the last maxMessages messages.
|
|
66
|
-
* Also compresses old screenshots and DOM blocks to save tokens.
|
|
67
|
-
*/
|
|
68
|
-
export function trimConversationHistory(messages, maxMessages = 48, preservedPrefixMessages = 1) {
|
|
69
|
-
compressOldScreenshots(messages, 1);
|
|
70
|
-
compressOldDomBlocks(messages, 6, preservedPrefixMessages);
|
|
71
|
-
if (messages.length <= maxMessages + preservedPrefixMessages)
|
|
72
|
-
return;
|
|
73
|
-
const preservedPrefix = messages.slice(0, preservedPrefixMessages);
|
|
74
|
-
const recent = messages.slice(-(maxMessages));
|
|
75
|
-
messages.splice(0, messages.length, ...preservedPrefix, ...recent);
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=agent-message-utils.js.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* URL matching, click guard, and verification cache utilities for the capture agent.
|
|
3
|
-
* Extracted from agent.ts — these are pure functions with no closure dependencies.
|
|
4
|
-
*/
|
|
5
|
-
import type { VerificationResult, VariantCaptureManifest } from './types.js';
|
|
6
|
-
import type { BrowserVerificationBundle } from './browser.js';
|
|
7
|
-
export declare function urlsRoughlyMatch(expectedUrl: string | undefined, currentUrl: string | undefined): boolean;
|
|
8
|
-
export declare function normalizeStrictComparableUrl(value: string): string;
|
|
9
|
-
export declare function urlsStrictlyMatch(expectedUrl: string | undefined, currentUrl: string | undefined): boolean;
|
|
10
|
-
export declare function normalizeGuardPageUrl(value: unknown): string;
|
|
11
|
-
export declare function buildClickGuardAnchor(params: Record<string, unknown>): string | null;
|
|
12
|
-
export declare function buildClickGuardSignature(params: Record<string, unknown>, currentUrl?: string): string | null;
|
|
13
|
-
export declare function buildVerificationCacheKey(config: {
|
|
14
|
-
prompt: string;
|
|
15
|
-
variantManifest?: VariantCaptureManifest | null;
|
|
16
|
-
currentLang?: string | null;
|
|
17
|
-
currentTheme?: string | null;
|
|
18
|
-
captureCursor?: {
|
|
19
|
-
targetId?: string;
|
|
20
|
-
} | null;
|
|
21
|
-
}, bundle: BrowserVerificationBundle): string;
|
|
22
|
-
export declare function cloneVerificationResult(result: VerificationResult): VerificationResult;
|
|
23
|
-
export declare function summarizeVariantManifestForPlanner(manifest: VariantCaptureManifest | undefined): string;
|
|
24
|
-
export declare function buildPageStateFingerprint(pageState: {
|
|
25
|
-
simplifiedDOM?: string | null;
|
|
26
|
-
interactiveElements: Array<unknown>;
|
|
27
|
-
scrollInfo?: {
|
|
28
|
-
scrollY?: number;
|
|
29
|
-
} | null;
|
|
30
|
-
}, currentUrl: string): string;
|
package/dist/agent-url-utils.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* URL matching, click guard, and verification cache utilities for the capture agent.
|
|
3
|
-
* Extracted from agent.ts — these are pure functions with no closure dependencies.
|
|
4
|
-
*/
|
|
5
|
-
import { createHash } from 'crypto';
|
|
6
|
-
// -- URL matching --
|
|
7
|
-
export function urlsRoughlyMatch(expectedUrl, currentUrl) {
|
|
8
|
-
if (!expectedUrl || !currentUrl)
|
|
9
|
-
return false;
|
|
10
|
-
try {
|
|
11
|
-
const expected = new URL(expectedUrl);
|
|
12
|
-
const current = new URL(currentUrl);
|
|
13
|
-
if (expected.origin !== current.origin)
|
|
14
|
-
return false;
|
|
15
|
-
const expectedPath = expected.pathname || '/';
|
|
16
|
-
const currentPath = current.pathname || '/';
|
|
17
|
-
if (currentPath === expectedPath)
|
|
18
|
-
return true;
|
|
19
|
-
if (currentPath.startsWith(expectedPath) && (expectedPath.endsWith('/') || currentPath[expectedPath.length] === '/')) {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
return currentUrl === expectedUrl;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export function normalizeStrictComparableUrl(value) {
|
|
29
|
-
const parsed = new URL(value);
|
|
30
|
-
const normalizedPath = parsed.pathname.replace(/\/+$/, '') || '/';
|
|
31
|
-
const searchEntries = Array.from(parsed.searchParams.entries()).sort(([aKey, aValue], [bKey, bValue]) => {
|
|
32
|
-
if (aKey === bKey)
|
|
33
|
-
return aValue.localeCompare(bValue);
|
|
34
|
-
return aKey.localeCompare(bKey);
|
|
35
|
-
});
|
|
36
|
-
const normalizedSearch = searchEntries.length > 0
|
|
37
|
-
? `?${new URLSearchParams(searchEntries).toString()}`
|
|
38
|
-
: '';
|
|
39
|
-
return `${parsed.origin}${normalizedPath}${normalizedSearch}`;
|
|
40
|
-
}
|
|
41
|
-
export function urlsStrictlyMatch(expectedUrl, currentUrl) {
|
|
42
|
-
if (!expectedUrl || !currentUrl)
|
|
43
|
-
return false;
|
|
44
|
-
try {
|
|
45
|
-
return normalizeStrictComparableUrl(expectedUrl) === normalizeStrictComparableUrl(currentUrl);
|
|
46
|
-
}
|
|
47
|
-
catch {
|
|
48
|
-
return currentUrl.trim().replace(/\/+$/, '') === expectedUrl.trim().replace(/\/+$/, '');
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
export function normalizeGuardPageUrl(value) {
|
|
52
|
-
if (typeof value !== 'string' || value.trim().length === 0)
|
|
53
|
-
return '';
|
|
54
|
-
try {
|
|
55
|
-
const parsed = new URL(value);
|
|
56
|
-
return `${parsed.origin}${parsed.pathname}`.replace(/\/$/, '') || parsed.origin;
|
|
57
|
-
}
|
|
58
|
-
catch {
|
|
59
|
-
return value.trim().replace(/\/$/, '');
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
// -- Click guards --
|
|
63
|
-
export function buildClickGuardAnchor(params) {
|
|
64
|
-
const parts = [];
|
|
65
|
-
if (typeof params.selector === 'string' && params.selector.trim()) {
|
|
66
|
-
parts.push(`selector:${params.selector.trim()}`);
|
|
67
|
-
}
|
|
68
|
-
if (params.index !== undefined) {
|
|
69
|
-
parts.push(`index:${String(params.index)}`);
|
|
70
|
-
}
|
|
71
|
-
if (typeof params.elementLabel === 'string' && params.elementLabel.trim()) {
|
|
72
|
-
parts.push(`label:${params.elementLabel.trim().toLowerCase()}`);
|
|
73
|
-
}
|
|
74
|
-
if (typeof params.href === 'string' && params.href.trim()) {
|
|
75
|
-
parts.push(`href:${normalizeGuardPageUrl(params.href)}`);
|
|
76
|
-
}
|
|
77
|
-
return parts.length > 0 ? parts.join('|') : null;
|
|
78
|
-
}
|
|
79
|
-
export function buildClickGuardSignature(params, currentUrl) {
|
|
80
|
-
const anchor = buildClickGuardAnchor(params);
|
|
81
|
-
if (!anchor)
|
|
82
|
-
return null;
|
|
83
|
-
const pageKey = normalizeGuardPageUrl(params.preActionUrl ?? params.postActionUrl ?? currentUrl);
|
|
84
|
-
return `click|${pageKey}|${anchor}`;
|
|
85
|
-
}
|
|
86
|
-
// -- Verification cache --
|
|
87
|
-
export function buildVerificationCacheKey(config, bundle) {
|
|
88
|
-
const promptHash = createHash('sha1').update(config.prompt).digest('hex').slice(0, 12);
|
|
89
|
-
return [
|
|
90
|
-
bundle.coherenceKey,
|
|
91
|
-
config.variantManifest?.currentPageId ?? 'main',
|
|
92
|
-
config.currentLang ?? 'default-lang',
|
|
93
|
-
config.currentTheme ?? 'default-theme',
|
|
94
|
-
config.captureCursor?.targetId ?? 'default-target',
|
|
95
|
-
promptHash,
|
|
96
|
-
].join('|');
|
|
97
|
-
}
|
|
98
|
-
export function cloneVerificationResult(result) {
|
|
99
|
-
return {
|
|
100
|
-
...result,
|
|
101
|
-
usage: result.usage.map(u => ({ ...u })),
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
export function summarizeVariantManifestForPlanner(manifest) {
|
|
105
|
-
if (!manifest)
|
|
106
|
-
return '';
|
|
107
|
-
const parts = [
|
|
108
|
-
`expected=${manifest.expectedPageIds.join(',') || 'main'}`,
|
|
109
|
-
`current=${manifest.currentPageId ?? 'main'}`,
|
|
110
|
-
manifest.currentPageIdentity ? `identity=${manifest.currentPageIdentity.summary}` : '',
|
|
111
|
-
`completed=${manifest.completedPages.join(',') || 'none'}`,
|
|
112
|
-
`remaining=${manifest.remainingPages.join(',') || 'none'}`,
|
|
113
|
-
manifest.lastCheckpointId ? `checkpoint=${manifest.lastCheckpointId}` : '',
|
|
114
|
-
];
|
|
115
|
-
if (manifest.captureStatuses) {
|
|
116
|
-
parts.push(`statuses=${Object.entries(manifest.captureStatuses)
|
|
117
|
-
.slice(0, 6)
|
|
118
|
-
.map(([pageId, status]) => `${pageId}:${status}`)
|
|
119
|
-
.join('|') || 'none'}`);
|
|
120
|
-
}
|
|
121
|
-
if (manifest.previousValidatedCaptures.length > 0) {
|
|
122
|
-
parts.push(`validated=${manifest.previousValidatedCaptures
|
|
123
|
-
.slice(-3)
|
|
124
|
-
.map((capture) => `${capture.pageId}${capture.identity ? `[${capture.identity.summary}]` : ''}:${capture.assessment.slice(0, 80)}`)
|
|
125
|
-
.join(' | ')}`);
|
|
126
|
-
}
|
|
127
|
-
return parts.join('; ');
|
|
128
|
-
}
|
|
129
|
-
// -- Page state fingerprint --
|
|
130
|
-
export function buildPageStateFingerprint(pageState, currentUrl) {
|
|
131
|
-
return createHash('sha1')
|
|
132
|
-
.update(pageState.simplifiedDOM || '')
|
|
133
|
-
.update(String(pageState.interactiveElements.length))
|
|
134
|
-
.update(String(pageState.scrollInfo?.scrollY ?? 0))
|
|
135
|
-
.update(currentUrl)
|
|
136
|
-
.digest('hex');
|
|
137
|
-
}
|
|
138
|
-
//# sourceMappingURL=agent-url-utils.js.map
|
package/dist/agent.d.ts
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { Browser } from './browser.js';
|
|
2
|
-
import type { BrowserObservation, BrowserVerificationBundle } from './browser.js';
|
|
3
|
-
import type { AgentConfig, AgentResult, ActionExpectedEffect, ExecutedAction, ActionType, InteractiveElement, OverlayScopeSummary, PageState, VariantCaptureManifest, VerificationResult } from './types.js';
|
|
4
|
-
export declare function buildPromptFingerprint(params: {
|
|
5
|
-
prompt: string;
|
|
6
|
-
url: string;
|
|
7
|
-
pageIdentitySummary?: string | null;
|
|
8
|
-
}): string;
|
|
9
|
-
export declare function inferVariantIdentityFailure(params: {
|
|
10
|
-
pageId?: string | null;
|
|
11
|
-
prompt: string;
|
|
12
|
-
currentUrl: string;
|
|
13
|
-
visibleText: string;
|
|
14
|
-
dialogCount: number;
|
|
15
|
-
pageIdentity?: VariantCaptureManifest["currentPageIdentity"];
|
|
16
|
-
}): string | null;
|
|
17
|
-
/** Build the reasoning body fragment for OpenRouter requests. */
|
|
18
|
-
export declare function resolveProviderReasoningEffort(effort?: AgentConfig['reasoningEffort']): 'xhigh' | 'high' | 'medium' | 'low' | 'none' | null;
|
|
19
|
-
type ProviderBudgetError = {
|
|
20
|
-
status?: number;
|
|
21
|
-
message?: string;
|
|
22
|
-
};
|
|
23
|
-
export declare function extractAffordableMaxTokens(message: string): number | null;
|
|
24
|
-
export declare function isInsufficientCreditsError(error: ProviderBudgetError | null | undefined): boolean;
|
|
25
|
-
export declare function deriveRetryMaxTokensFromBudgetError(error: ProviderBudgetError | null | undefined, requestedMaxTokens: number): number | null;
|
|
26
|
-
export declare function inferDeterministicReadyDecision(params: {
|
|
27
|
-
observation: BrowserObservation;
|
|
28
|
-
assessment: string;
|
|
29
|
-
targetUrl: string;
|
|
30
|
-
skipDialogCheck?: boolean;
|
|
31
|
-
allowSuccess?: boolean;
|
|
32
|
-
}): {
|
|
33
|
-
verified: boolean;
|
|
34
|
-
reason?: string;
|
|
35
|
-
} | null;
|
|
36
|
-
export declare function inferManifestReadyDecision(params: {
|
|
37
|
-
observation: BrowserObservation;
|
|
38
|
-
assessment: string;
|
|
39
|
-
config: AgentConfig;
|
|
40
|
-
bundle: BrowserVerificationBundle;
|
|
41
|
-
}): {
|
|
42
|
-
verified: boolean;
|
|
43
|
-
reason?: string;
|
|
44
|
-
} | null;
|
|
45
|
-
/**
|
|
46
|
-
* Page-signal deterministic verification: accepts when ALL of the following hold:
|
|
47
|
-
* 1. Assessment text parses as positive (caller already believes ready)
|
|
48
|
-
* 2. inferVariantIdentityFailure finds no identity mismatch
|
|
49
|
-
* 3. No loading indicators, readyState === 'complete'
|
|
50
|
-
* 4. No hard variant (lang/theme) mismatch
|
|
51
|
-
* 5. No unexpected dialog blocking the page (unless dialog is the target)
|
|
52
|
-
*
|
|
53
|
-
* Returns { verified: true } when confident, null when inconclusive (→ LLM).
|
|
54
|
-
* NEVER returns { verified: false } — absence of evidence is not evidence of absence.
|
|
55
|
-
*/
|
|
56
|
-
export declare function inferPageSignalReadyDecision(params: {
|
|
57
|
-
observation: BrowserObservation;
|
|
58
|
-
assessment: string;
|
|
59
|
-
config: AgentConfig;
|
|
60
|
-
bundle: BrowserVerificationBundle;
|
|
61
|
-
identityFailure: string | null;
|
|
62
|
-
}): {
|
|
63
|
-
verified: boolean;
|
|
64
|
-
} | null;
|
|
65
|
-
/**
|
|
66
|
-
* Fast-path optimization: extract a PASS/FAIL verdict from LLM text output
|
|
67
|
-
* using keyword matching, avoiding a separate LLM call when the signal is clear.
|
|
68
|
-
*
|
|
69
|
-
* Returns null when uncertain — the caller MUST fall back to an LLM vision call.
|
|
70
|
-
* Do not add more patterns here; expand LLM fallback coverage instead.
|
|
71
|
-
*/
|
|
72
|
-
export declare function parseVerificationDecisionText(content: string): {
|
|
73
|
-
verified: boolean;
|
|
74
|
-
reason?: string;
|
|
75
|
-
} | null;
|
|
76
|
-
export declare function inferActionFromAssistantText(content: string, options?: {
|
|
77
|
-
allowHeuristicWait?: boolean;
|
|
78
|
-
}): {
|
|
79
|
-
name: ActionType;
|
|
80
|
-
args: Record<string, unknown>;
|
|
81
|
-
} | null;
|
|
82
|
-
export declare function executeAction(browser: Browser, action: ActionType, args: Record<string, unknown>, options?: {
|
|
83
|
-
beforeObservation?: BrowserObservation | null;
|
|
84
|
-
fast?: boolean;
|
|
85
|
-
}): Promise<{
|
|
86
|
-
success: boolean;
|
|
87
|
-
error?: string;
|
|
88
|
-
outcome?: string;
|
|
89
|
-
stateChanged?: boolean;
|
|
90
|
-
expectedEffect?: ActionExpectedEffect;
|
|
91
|
-
observedEffects?: string[];
|
|
92
|
-
effectConfirmed?: boolean;
|
|
93
|
-
noEffectReason?: string | null;
|
|
94
|
-
afterObservation?: BrowserObservation | null;
|
|
95
|
-
}>;
|
|
96
|
-
export declare function verifyCaptureReadiness(browser: Browser, config: AgentConfig, apiKey: string, options?: {
|
|
97
|
-
assessment?: string;
|
|
98
|
-
stepNumber?: number;
|
|
99
|
-
}): Promise<VerificationResult>;
|
|
100
|
-
export declare function buildFreshNodeCaptureVerification(params: {
|
|
101
|
-
browser: Browser;
|
|
102
|
-
config: AgentConfig;
|
|
103
|
-
nodeId: string;
|
|
104
|
-
}): Promise<VerificationResult | undefined>;
|
|
105
|
-
export declare function urlsStrictlyMatch(expectedUrl: string | undefined, currentUrl: string | undefined): boolean;
|
|
106
|
-
export declare function getLivePreviewScreenshot(pageState: Pick<PageState, 'cleanScreenshot' | 'screenshot'>): Buffer;
|
|
107
|
-
export declare function analyzeReplayCandidate(recordedActions: ExecutedAction[], params?: {
|
|
108
|
-
currentUrl?: string;
|
|
109
|
-
targetUrl?: string;
|
|
110
|
-
currentViewport?: {
|
|
111
|
-
width: number;
|
|
112
|
-
height: number;
|
|
113
|
-
} | null;
|
|
114
|
-
isAuthenticated?: boolean;
|
|
115
|
-
currentDialogCount?: number | null;
|
|
116
|
-
pageIdentity?: VariantCaptureManifest['currentPageIdentity'] | null;
|
|
117
|
-
ignoreRecordedViewport?: boolean;
|
|
118
|
-
}): {
|
|
119
|
-
replayableActions: ExecutedAction[];
|
|
120
|
-
skipReason: string | null;
|
|
121
|
-
trimmedActionCount: number;
|
|
122
|
-
};
|
|
123
|
-
export declare function findReplayResumeIndex(replayableActions: ExecutedAction[], currentUrl: string | undefined, startIndex?: number, observation?: BrowserObservation | null, pageIdentity?: VariantCaptureManifest['currentPageIdentity'] | null): number | null;
|
|
124
|
-
export declare function sanitizeSemanticContextHint(value: string | null | undefined): string | null;
|
|
125
|
-
export declare function deriveOverlayScope(params: {
|
|
126
|
-
pageState: Pick<PageState, 'akTree'>;
|
|
127
|
-
pageIdentity?: VariantCaptureManifest['currentPageIdentity'] | null;
|
|
128
|
-
prompt?: string;
|
|
129
|
-
currentSubgoal?: string | null;
|
|
130
|
-
}): OverlayScopeSummary | null;
|
|
131
|
-
export declare function guardTapTargetSelection(params: {
|
|
132
|
-
pageState: Pick<PageState, 'akTree'>;
|
|
133
|
-
action: ActionType;
|
|
134
|
-
args: Record<string, unknown>;
|
|
135
|
-
pageIdentity?: VariantCaptureManifest['currentPageIdentity'] | null;
|
|
136
|
-
currentSubgoal?: string | null;
|
|
137
|
-
overlayScope?: OverlayScopeSummary | null;
|
|
138
|
-
}): {
|
|
139
|
-
blocked: boolean;
|
|
140
|
-
reason?: string;
|
|
141
|
-
betterCandidate?: {
|
|
142
|
-
nodeId: string;
|
|
143
|
-
label: string;
|
|
144
|
-
};
|
|
145
|
-
};
|
|
146
|
-
export declare function shouldBlockFocusTool(params: {
|
|
147
|
-
pageState: Pick<PageState, 'akTree'>;
|
|
148
|
-
pageIdentity?: VariantCaptureManifest['currentPageIdentity'] | null;
|
|
149
|
-
currentSubgoal?: string | null;
|
|
150
|
-
overlayScope?: OverlayScopeSummary | null;
|
|
151
|
-
}): string | null;
|
|
152
|
-
export declare function shouldBlockAnalyzeTool(params: {
|
|
153
|
-
overlayScope?: OverlayScopeSummary | null;
|
|
154
|
-
overlayChangedRecently: boolean;
|
|
155
|
-
fingerprint: string;
|
|
156
|
-
lastAnalyzeFingerprint?: string | null;
|
|
157
|
-
lastAnalyzeIteration?: number;
|
|
158
|
-
iteration: number;
|
|
159
|
-
lastExecutionFailed: boolean;
|
|
160
|
-
}): string | null;
|
|
161
|
-
export declare function buildCompactAKTreeSummary(params: {
|
|
162
|
-
pageState: Pick<PageState, 'akTree'>;
|
|
163
|
-
pageIdentity?: VariantCaptureManifest['currentPageIdentity'] | null;
|
|
164
|
-
currentSubgoal?: string | null;
|
|
165
|
-
overlayScope?: OverlayScopeSummary | null;
|
|
166
|
-
lastVerificationFailure?: string;
|
|
167
|
-
}): string;
|
|
168
|
-
export declare function matchRecordedActionToElement(action: Pick<ExecutedAction, 'params'>, interactiveElements: InteractiveElement[]): InteractiveElement | null;
|
|
169
|
-
export declare function resolveReplayActionArgs(action: ExecutedAction, interactiveElements: InteractiveElement[]): {
|
|
170
|
-
args: Record<string, unknown> | null;
|
|
171
|
-
reason: string | null;
|
|
172
|
-
};
|
|
173
|
-
export declare function compactReplayActions(recordedActions: ExecutedAction[], params?: {
|
|
174
|
-
currentUrl?: string;
|
|
175
|
-
targetUrl?: string;
|
|
176
|
-
currentViewport?: {
|
|
177
|
-
width: number;
|
|
178
|
-
height: number;
|
|
179
|
-
} | null;
|
|
180
|
-
/** When true, filter out login/auth actions (session already active). */
|
|
181
|
-
isAuthenticated?: boolean;
|
|
182
|
-
/** When true, drop recorded resize actions and let the orchestrator own the viewport. */
|
|
183
|
-
ignoreRecordedViewport?: boolean;
|
|
184
|
-
}): ExecutedAction[];
|
|
185
|
-
export declare function countRecentNoEffectActions(actionHistory: ExecutedAction[]): number;
|
|
186
|
-
export declare function shouldTriggerRecovery(actionHistory: ExecutedAction[]): boolean;
|
|
187
|
-
export declare function inferPrematureGiveUpCorrection(params: {
|
|
188
|
-
reason: string;
|
|
189
|
-
actionHistory: ExecutedAction[];
|
|
190
|
-
lastVerificationFailure?: string;
|
|
191
|
-
iteration: number;
|
|
192
|
-
maxIterations: number;
|
|
193
|
-
}): string | null;
|
|
194
|
-
export declare function inferSearchScrollLoopGuard(params: {
|
|
195
|
-
actionHistory: ExecutedAction[];
|
|
196
|
-
action: ActionType;
|
|
197
|
-
args: Record<string, unknown>;
|
|
198
|
-
}): string | null;
|
|
199
|
-
export declare function inferRepeatedActionGuard(params: {
|
|
200
|
-
actionHistory: ExecutedAction[];
|
|
201
|
-
action: ActionType;
|
|
202
|
-
args: Record<string, unknown>;
|
|
203
|
-
currentUrl?: string;
|
|
204
|
-
}): string | null;
|
|
205
|
-
export interface WorkflowCacheEntry {
|
|
206
|
-
subgoalName: string;
|
|
207
|
-
actionSummary: string;
|
|
208
|
-
selectors: string[];
|
|
209
|
-
}
|
|
210
|
-
export declare function findReusableWorkflow(workflowCache: WorkflowCacheEntry[], subgoalName: string): WorkflowCacheEntry | null;
|
|
211
|
-
/**
|
|
212
|
-
* Replace base64 image content in older conversation messages with a text placeholder.
|
|
213
|
-
* Keeps only the most recent `keepRecentImages` user messages that contain screenshots.
|
|
214
|
-
* This dramatically reduces token cost on long agent runs (40-60% savings).
|
|
215
|
-
*/
|
|
216
|
-
export { trimConversationHistory } from './agent-message-utils.js';
|
|
217
|
-
export declare function runAgent(browser: Browser, config: AgentConfig, apiKey: string): Promise<AgentResult>;
|
|
218
|
-
/**
|
|
219
|
-
* Replay a previous successful capture's recorded actions instead of running the full AI agent.
|
|
220
|
-
* Falls back to a full runAgent if replay fails or verification doesn't pass.
|
|
221
|
-
* Much cheaper than a full agent run: only 1 verification call vs. N agent iterations.
|
|
222
|
-
*/
|
|
223
|
-
export declare function replayAgent(browser: Browser, config: AgentConfig, apiKey: string, recordedActions: ExecutedAction[], options?: {
|
|
224
|
-
allowFullAgentFallback?: boolean;
|
|
225
|
-
ignoreRecordedViewport?: boolean;
|
|
226
|
-
}): Promise<AgentResult>;
|