autokap 1.0.2 → 1.0.3

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.
Files changed (83) hide show
  1. package/dist/cli-config.d.ts +13 -0
  2. package/dist/cli-config.js +42 -0
  3. package/dist/cli-utils.d.ts +0 -19
  4. package/dist/cli-utils.js +2 -65
  5. package/dist/cli.d.ts +0 -1
  6. package/dist/cli.js +266 -305
  7. package/package.json +23 -16
  8. package/assets/chrome/ios-statusbar-comparison-reference.jpg +0 -0
  9. package/assets/chrome/ios-statusbar-dark-reference.jpg +0 -0
  10. package/assets/chrome/ios-statusbar-light-reference.jpg +0 -0
  11. package/assets/devices/ipad-pro-11-m4.json +0 -52
  12. package/assets/devices/iphone-16-pro.json +0 -53
  13. package/assets/devices/macbook-air-13.json +0 -45
  14. package/assets/frames/MacBook Air 13.svg +0 -242
  15. package/assets/frames/Status bar - iPhone.png +0 -0
  16. package/assets/frames/Status bar and Menu bar- iPad.png +0 -0
  17. package/assets/frames/iPad Pro M4 11_.png +0 -0
  18. package/assets/frames/iPhone 16 Pro.png +0 -0
  19. package/assets/icons/Cellular Connection.svg +0 -3
  20. package/assets/icons/Union.svg +0 -6
  21. package/assets/icons/Wifi.svg +0 -3
  22. package/assets/icons/battery.svg +0 -5
  23. package/assets/icons/battery_charging.svg +0 -8
  24. package/dist/abort.d.ts +0 -5
  25. package/dist/abort.js +0 -44
  26. package/dist/agent.d.ts +0 -142
  27. package/dist/agent.js +0 -4504
  28. package/dist/browser-bar.d.ts +0 -40
  29. package/dist/browser-bar.js +0 -147
  30. package/dist/clip-orchestrator.d.ts +0 -148
  31. package/dist/clip-orchestrator.js +0 -950
  32. package/dist/clip-postprocess.d.ts +0 -42
  33. package/dist/clip-postprocess.js +0 -192
  34. package/dist/credential-templates.d.ts +0 -5
  35. package/dist/credential-templates.js +0 -60
  36. package/dist/element-capture.d.ts +0 -53
  37. package/dist/element-capture.js +0 -766
  38. package/dist/hybrid-navigator.d.ts +0 -138
  39. package/dist/hybrid-navigator.js +0 -468
  40. package/dist/index.d.ts +0 -15
  41. package/dist/index.js +0 -11
  42. package/dist/llm-usage.d.ts +0 -17
  43. package/dist/llm-usage.js +0 -45
  44. package/dist/mockup-html.d.ts +0 -119
  45. package/dist/mockup-html.js +0 -253
  46. package/dist/mockup.d.ts +0 -94
  47. package/dist/mockup.js +0 -604
  48. package/dist/mouse-animation.d.ts +0 -46
  49. package/dist/mouse-animation.js +0 -100
  50. package/dist/overlay-utils.d.ts +0 -14
  51. package/dist/overlay-utils.js +0 -13
  52. package/dist/posthog.d.ts +0 -4
  53. package/dist/posthog.js +0 -26
  54. package/dist/prompt-cache.d.ts +0 -10
  55. package/dist/prompt-cache.js +0 -24
  56. package/dist/prompts.d.ts +0 -167
  57. package/dist/prompts.js +0 -1165
  58. package/dist/security.d.ts +0 -20
  59. package/dist/security.js +0 -569
  60. package/dist/session-profile.d.ts +0 -86
  61. package/dist/session-profile.js +0 -1471
  62. package/dist/sf-pro-fonts.d.ts +0 -4
  63. package/dist/sf-pro-fonts.js +0 -7
  64. package/dist/status-bar-l10n.d.ts +0 -14
  65. package/dist/status-bar-l10n.js +0 -177
  66. package/dist/status-bar.d.ts +0 -44
  67. package/dist/status-bar.js +0 -336
  68. package/dist/tools.d.ts +0 -4
  69. package/dist/tools.js +0 -578
  70. package/dist/video-agent.d.ts +0 -143
  71. package/dist/video-agent.js +0 -4783
  72. package/dist/video-observation.d.ts +0 -36
  73. package/dist/video-observation.js +0 -192
  74. package/dist/video-planner.d.ts +0 -12
  75. package/dist/video-planner.js +0 -500
  76. package/dist/video-prompts.d.ts +0 -37
  77. package/dist/video-prompts.js +0 -554
  78. package/dist/video-tools.d.ts +0 -3
  79. package/dist/video-tools.js +0 -59
  80. package/dist/video-variant-state.d.ts +0 -29
  81. package/dist/video-variant-state.js +0 -80
  82. package/dist/vision-model.d.ts +0 -17
  83. package/dist/vision-model.js +0 -74
@@ -1,36 +0,0 @@
1
- import { Browser } from './browser.js';
2
- import type { BrowserVideoVerificationBundle } from './browser.js';
3
- import type { BrowserSessionStorageState, BrowserStorageState, CapturePageIdentity, InteractiveElement, VideoAgentConfig, VideoObservationSnapshot, VideoPageSignals } from './types.js';
4
- export declare function buildVideoObservationSummary(params: {
5
- url: string;
6
- title: string;
7
- accessibilityTree: string;
8
- interactiveElements: InteractiveElement[];
9
- pageSignals: VideoPageSignals;
10
- maxAccessibilityChars?: number;
11
- maxElements?: number;
12
- maxVisibleTextChars?: number;
13
- }): string;
14
- export declare function buildVideoObservationSnapshot(params: {
15
- coherenceKey?: string;
16
- interactiveElements: InteractiveElement[];
17
- pageSignals: VideoPageSignals;
18
- pageIdentity?: CapturePageIdentity | null;
19
- }): VideoObservationSnapshot;
20
- export declare function captureVideoObservationSummary(source: Browser | BrowserVideoVerificationBundle, options?: {
21
- maxAccessibilityChars?: number;
22
- maxElements?: number;
23
- maxVisibleTextChars?: number;
24
- }): Promise<string>;
25
- export interface PlanningObservation {
26
- summary: string;
27
- screenshot?: Buffer;
28
- snapshot?: VideoObservationSnapshot;
29
- }
30
- export declare function observePlanningContext(config: Pick<VideoAgentConfig, 'url' | 'viewport' | 'outputScale' | 'lang' | 'theme' | 'abortSignal'> & {
31
- startUrl?: string;
32
- storageState?: BrowserStorageState;
33
- sessionStorage?: BrowserSessionStorageState;
34
- captureScreenshot?: boolean;
35
- pageIdentity?: CapturePageIdentity | null;
36
- }): Promise<PlanningObservation>;
@@ -1,192 +0,0 @@
1
- import { Browser } from './browser.js';
2
- import { throwIfAborted } from './abort.js';
3
- import { dismissOverlaysWithLogging } from './overlay-utils.js';
4
- function summarizeObservationElements(elements, limit = 18) {
5
- const rank = (element) => {
6
- let score = 0;
7
- if (element.visible)
8
- score += 20;
9
- if (element.visibilityState === 'full')
10
- score += 12;
11
- if (element.href)
12
- score += 10;
13
- if (element.role === 'link' || element.tag === 'a')
14
- score += 8;
15
- if (element.role === 'button' || element.tag === 'button')
16
- score += 6;
17
- if (element.inputType)
18
- score += 5;
19
- if (element.text)
20
- score += Math.min(12, element.text.length / 6);
21
- if (element.ariaLabel)
22
- score += 4;
23
- return score;
24
- };
25
- return [...elements]
26
- .sort((a, b) => rank(b) - rank(a))
27
- .slice(0, limit)
28
- .map((element) => {
29
- const label = element.text || element.ariaLabel || '(no label)';
30
- const href = element.href ? ` href=${element.href}` : '';
31
- return `- [${element.role || element.tag}] "${label}"${href}`;
32
- });
33
- }
34
- function formatSignalList(title, values, maxItems = 8) {
35
- if (values.length === 0)
36
- return '';
37
- return `${title}: ${values.slice(0, maxItems).join(' | ')}`;
38
- }
39
- function summarizeVariantControls(signals, limit = 8) {
40
- return signals.variantControls
41
- .slice(0, limit)
42
- .map((control) => {
43
- const options = control.options?.length
44
- ? ` options=${control.options
45
- .slice(0, 5)
46
- .map((option) => `${option.selected ? '*' : ''}${option.label || option.value || '(empty)'}`)
47
- .join(', ')}`
48
- : '';
49
- const href = control.href ? ` href=${control.href}` : '';
50
- return `- [${control.kind}/${control.mechanism}] "${control.label}" selector=${control.selector}${href}${options}`;
51
- });
52
- }
53
- function summarizeStorageHints(signals, limit = 8) {
54
- return signals.storageHints
55
- .slice(0, limit)
56
- .map((hint) => `- [${hint.kind}] ${hint.storage}.${hint.key}=${hint.valueSample || '(empty)'}`);
57
- }
58
- export function buildVideoObservationSummary(params) {
59
- const signalLines = [
60
- `Observed URL: ${params.url}`,
61
- `Observed title: ${params.title || '(untitled)'}`,
62
- params.pageSignals.htmlLang ? `Observed html lang: ${params.pageSignals.htmlLang}` : '',
63
- params.pageSignals.canonicalUrl ? `Canonical URL: ${params.pageSignals.canonicalUrl}` : '',
64
- params.pageSignals.detectedTheme ? `Observed theme: ${params.pageSignals.detectedTheme}` : '',
65
- formatSignalList('Headings', params.pageSignals.headings),
66
- formatSignalList('Navigation labels', params.pageSignals.navLabels, 10),
67
- formatSignalList('Breadcrumbs', params.pageSignals.breadcrumbLabels, 8),
68
- formatSignalList('Locale hints', params.pageSignals.localeHints, 10),
69
- formatSignalList('hreflang links', params.pageSignals.hreflangs, 8),
70
- params.pageSignals.visibleText
71
- ? `Visible text sample: ${params.pageSignals.visibleText.slice(0, params.maxVisibleTextChars ?? 500)}`
72
- : '',
73
- ].filter(Boolean);
74
- const elementLines = summarizeObservationElements(params.interactiveElements, params.maxElements ?? 18);
75
- const controlLines = summarizeVariantControls(params.pageSignals, 8);
76
- const storageLines = summarizeStorageHints(params.pageSignals, 8);
77
- const accessibilitySnippet = params.accessibilityTree.slice(0, params.maxAccessibilityChars ?? 3500);
78
- return [
79
- ...signalLines,
80
- controlLines.length > 0 ? 'Likely variant controls:' : '',
81
- ...controlLines,
82
- storageLines.length > 0 ? 'Likely variant storage keys:' : '',
83
- ...storageLines,
84
- elementLines.length > 0 ? 'Visible interactive elements:' : '',
85
- ...elementLines,
86
- accessibilitySnippet ? `Accessibility tree snippet:\n${accessibilitySnippet}` : '',
87
- ]
88
- .filter(Boolean)
89
- .join('\n');
90
- }
91
- export function buildVideoObservationSnapshot(params) {
92
- return {
93
- coherenceKey: params.coherenceKey,
94
- interactiveElements: params.interactiveElements,
95
- pageSignals: params.pageSignals,
96
- pageIdentity: params.pageIdentity ?? null,
97
- };
98
- }
99
- export async function captureVideoObservationSummary(source, options = {}) {
100
- if (source instanceof Browser) {
101
- const [pageState, pageSignals, pageTitle] = await Promise.all([
102
- source.getPageState(),
103
- source.capturePageSignals(),
104
- source.currentPage.title().catch(() => ''),
105
- ]);
106
- return buildVideoObservationSummary({
107
- url: source.currentPage.url(),
108
- title: pageTitle,
109
- accessibilityTree: pageState.accessibilityTree,
110
- interactiveElements: pageState.interactiveElements,
111
- pageSignals,
112
- ...options,
113
- });
114
- }
115
- return buildVideoObservationSummary({
116
- url: source.url,
117
- title: source.title,
118
- accessibilityTree: source.accessibilityTree,
119
- interactiveElements: source.interactiveElements,
120
- pageSignals: source.pageSignals,
121
- ...options,
122
- });
123
- }
124
- export async function observePlanningContext(config) {
125
- throwIfAborted(config.abortSignal, 'Video planning observation cancelled.');
126
- const browser = await Browser.fromPool({
127
- headed: false,
128
- viewport: config.viewport,
129
- deviceScaleFactor: config.outputScale,
130
- lang: config.lang,
131
- colorScheme: config.theme,
132
- storageState: config.storageState,
133
- });
134
- try {
135
- await browser.prepareSessionStorage(config.sessionStorage, { replace: true });
136
- await browser.navigateTo(config.startUrl ?? config.url);
137
- await dismissOverlaysWithLogging(browser, { context: 'planning observation' });
138
- const [summary, screenshot] = await Promise.all([
139
- captureVideoObservationSummary(browser, {
140
- maxAccessibilityChars: 3500,
141
- maxElements: 18,
142
- maxVisibleTextChars: 500,
143
- }),
144
- config.captureScreenshot
145
- ? browser.takeScreenshotForAI().catch(() => undefined)
146
- : Promise.resolve(undefined),
147
- ]);
148
- const [interactiveElements, pageSignals] = await Promise.all([
149
- browser.getInteractiveElements().catch(() => []),
150
- browser.capturePageSignals().catch(() => ({
151
- url: browser.currentPage.url(),
152
- title: '',
153
- htmlLang: '',
154
- canonicalUrl: '',
155
- hreflangs: [],
156
- headings: [],
157
- navLabels: [],
158
- breadcrumbLabels: [],
159
- visibleText: '',
160
- localeHints: [],
161
- detectedTheme: null,
162
- preferredColorScheme: 'light',
163
- authHints: {
164
- hasPasswordField: false,
165
- hasEmailField: false,
166
- hasAuthForm: false,
167
- loginButtons: [],
168
- logoutButtons: [],
169
- accountMenuLabels: [],
170
- accountLikeText: [],
171
- },
172
- variantControls: [],
173
- storageHints: [],
174
- })),
175
- ]);
176
- return {
177
- summary,
178
- screenshot,
179
- snapshot: buildVideoObservationSnapshot({
180
- interactiveElements,
181
- pageSignals,
182
- pageIdentity: config.pageIdentity ?? null,
183
- }),
184
- };
185
- }
186
- finally {
187
- await browser.close().catch(() => {
188
- // Best effort cleanup.
189
- });
190
- }
191
- }
192
- //# sourceMappingURL=video-observation.js.map
@@ -1,12 +0,0 @@
1
- import type { StepUsage, VideoPlan } from './types.js';
2
- import { type VideoPlannerPromptOptions } from './video-prompts.js';
3
- export { observePlanningContext } from './video-observation.js';
4
- export interface PlannerResult {
5
- plan: VideoPlan;
6
- usage: StepUsage;
7
- }
8
- /**
9
- * Phase 1 of the video pipeline: convert a natural-language script into a
10
- * structured `VideoPlan` using a single LLM call in JSON mode.
11
- */
12
- export declare function planFromScript(script: string, url: string, model: string, apiKey: string, maxRetries?: number, options?: VideoPlannerPromptOptions, abortSignal?: AbortSignal): Promise<PlannerResult>;