autokap 1.0.6 → 1.0.7

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 (130) hide show
  1. package/assets/chrome/ios-statusbar-comparison-reference.jpg +0 -0
  2. package/assets/chrome/ios-statusbar-dark-reference.jpg +0 -0
  3. package/assets/chrome/ios-statusbar-light-reference.jpg +0 -0
  4. package/assets/devices/ipad-pro-11-m4.json +52 -0
  5. package/assets/devices/iphone-16-pro.json +53 -0
  6. package/assets/devices/macbook-air-13.json +45 -0
  7. package/assets/frames/MacBook Air 13.svg +242 -0
  8. package/assets/frames/Status bar - iPhone.png +0 -0
  9. Menu bar- iPad.png +0 -0
  10. package/assets/frames/iPad Pro M4 11_.png +0 -0
  11. package/assets/frames/iPhone 16 Pro.png +0 -0
  12. package/assets/icons/Cellular Connection.svg +3 -0
  13. package/assets/icons/Union.svg +6 -0
  14. package/assets/icons/Wifi.svg +3 -0
  15. package/assets/icons/battery.svg +5 -0
  16. package/assets/icons/battery_charging.svg +8 -0
  17. package/dist/abort.d.ts +5 -0
  18. package/dist/abort.js +44 -0
  19. package/dist/agent.d.ts +142 -0
  20. package/dist/agent.js +4511 -0
  21. package/dist/billing-operation-logging.d.ts +38 -0
  22. package/dist/billing-operation-logging.js +248 -0
  23. package/dist/browser-bar.d.ts +40 -0
  24. package/dist/browser-bar.js +147 -0
  25. package/dist/browser.d.ts +25 -0
  26. package/dist/browser.js +177 -9
  27. package/dist/capture-alt-text.d.ts +12 -0
  28. package/dist/capture-alt-text.js +51 -0
  29. package/dist/capture-encryption.d.ts +10 -0
  30. package/dist/capture-encryption.js +41 -0
  31. package/dist/capture-language-preflight.d.ts +41 -0
  32. package/dist/capture-language-preflight.js +286 -0
  33. package/dist/capture-llm-page-identity.d.ts +15 -0
  34. package/dist/capture-llm-page-identity.js +116 -0
  35. package/dist/capture-model-resolution.d.ts +9 -0
  36. package/dist/capture-model-resolution.js +21 -0
  37. package/dist/capture-page-identity.d.ts +9 -0
  38. package/dist/capture-page-identity.js +219 -0
  39. package/dist/capture-preset-credentials.d.ts +12 -0
  40. package/dist/capture-preset-credentials.js +57 -0
  41. package/dist/capture-request-plan.d.ts +58 -0
  42. package/dist/capture-request-plan.js +216 -0
  43. package/dist/capture-run-optimizer.d.ts +139 -0
  44. package/dist/capture-run-optimizer.js +848 -0
  45. package/dist/capture-selector-memory.d.ts +26 -0
  46. package/dist/capture-selector-memory.js +327 -0
  47. package/dist/capture-session-profile-encryption.d.ts +2 -0
  48. package/dist/capture-session-profile-encryption.js +22 -0
  49. package/dist/capture-step-timeout.d.ts +10 -0
  50. package/dist/capture-step-timeout.js +30 -0
  51. package/dist/capture-studio-sync.d.ts +22 -0
  52. package/dist/capture-studio-sync.js +166 -0
  53. package/dist/capture-variant-state.d.ts +54 -0
  54. package/dist/capture-variant-state.js +156 -0
  55. package/dist/cli.js +15 -0
  56. package/dist/clip-orchestrator.d.ts +148 -0
  57. package/dist/clip-orchestrator.js +950 -0
  58. package/dist/clip-postprocess.d.ts +42 -0
  59. package/dist/clip-postprocess.js +192 -0
  60. package/dist/cost-logging.d.ts +27 -0
  61. package/dist/cost-logging.js +128 -0
  62. package/dist/credential-templates.d.ts +5 -0
  63. package/dist/credential-templates.js +60 -0
  64. package/dist/element-capture.d.ts +53 -0
  65. package/dist/element-capture.js +766 -0
  66. package/dist/hybrid-navigator.d.ts +138 -0
  67. package/dist/hybrid-navigator.js +468 -0
  68. package/dist/index.d.ts +15 -0
  69. package/dist/index.js +11 -0
  70. package/dist/llm-usage.d.ts +17 -0
  71. package/dist/llm-usage.js +45 -0
  72. package/dist/mockup-html.d.ts +119 -0
  73. package/dist/mockup-html.js +253 -0
  74. package/dist/mockup.d.ts +94 -0
  75. package/dist/mockup.js +608 -0
  76. package/dist/mouse-animation.d.ts +46 -0
  77. package/dist/mouse-animation.js +100 -0
  78. package/dist/overlay-utils.d.ts +14 -0
  79. package/dist/overlay-utils.js +13 -0
  80. package/dist/posthog.d.ts +4 -0
  81. package/dist/posthog.js +26 -0
  82. package/dist/prompt-cache.d.ts +10 -0
  83. package/dist/prompt-cache.js +24 -0
  84. package/dist/prompts.d.ts +167 -0
  85. package/dist/prompts.js +1165 -0
  86. package/dist/remote-browser.d.ts +191 -0
  87. package/dist/remote-browser.js +305 -0
  88. package/dist/security.d.ts +20 -0
  89. package/dist/security.js +569 -0
  90. package/dist/server-capture-runtime.d.ts +123 -0
  91. package/dist/server-capture-runtime.js +638 -0
  92. package/dist/server-credit-usage.d.ts +12 -0
  93. package/dist/server-credit-usage.js +41 -0
  94. package/dist/server-posthog.d.ts +2 -0
  95. package/dist/server-posthog.js +16 -0
  96. package/dist/server-project-webhooks.d.ts +45 -0
  97. package/dist/server-project-webhooks.js +97 -0
  98. package/dist/server-screenshot-watermark.d.ts +7 -0
  99. package/dist/server-screenshot-watermark.js +38 -0
  100. package/dist/session-profile.d.ts +86 -0
  101. package/dist/session-profile.js +1373 -0
  102. package/dist/sf-pro-fonts.d.ts +4 -0
  103. package/dist/sf-pro-fonts.js +7 -0
  104. package/dist/status-bar-l10n.d.ts +14 -0
  105. package/dist/status-bar-l10n.js +177 -0
  106. package/dist/status-bar.d.ts +44 -0
  107. package/dist/status-bar.js +336 -0
  108. package/dist/tools.d.ts +4 -0
  109. package/dist/tools.js +578 -0
  110. package/dist/video-agent.d.ts +143 -0
  111. package/dist/video-agent.js +4783 -0
  112. package/dist/video-observation.d.ts +36 -0
  113. package/dist/video-observation.js +192 -0
  114. package/dist/video-planner.d.ts +12 -0
  115. package/dist/video-planner.js +500 -0
  116. package/dist/video-prompts.d.ts +37 -0
  117. package/dist/video-prompts.js +554 -0
  118. package/dist/video-tools.d.ts +3 -0
  119. package/dist/video-tools.js +59 -0
  120. package/dist/video-variant-state.d.ts +29 -0
  121. package/dist/video-variant-state.js +80 -0
  122. package/dist/vision-model.d.ts +17 -0
  123. package/dist/vision-model.js +74 -0
  124. package/dist/ws-auth.d.ts +20 -0
  125. package/dist/ws-auth.js +67 -0
  126. package/dist/ws-handler.d.ts +10 -0
  127. package/dist/ws-handler.js +1663 -0
  128. package/dist/ws-server.d.ts +9 -0
  129. package/dist/ws-server.js +52 -0
  130. package/package.json +93 -39
@@ -0,0 +1,156 @@
1
+ import { inferCapturePageIdentity } from "./capture-page-identity.js";
2
+ function normalizePageId(pageId) {
3
+ return pageId ?? "main";
4
+ }
5
+ export function createVariantCaptureState(pageRuns, precomputedIdentities) {
6
+ const pageIdentities = precomputedIdentities ?? Object.fromEntries(pageRuns.map((pageRun) => [
7
+ normalizePageId(pageRun.pageId),
8
+ inferCapturePageIdentity(pageRun),
9
+ ]));
10
+ return {
11
+ expectedPageIds: pageRuns.map((pageRun) => normalizePageId(pageRun.pageId)),
12
+ pageIdentities,
13
+ validatedCaptures: [],
14
+ captureStatuses: Object.fromEntries(pageRuns.map((pageRun) => [normalizePageId(pageRun.pageId), "pending"])),
15
+ lastCheckpointId: null,
16
+ blockedReasons: {},
17
+ recoveryAttempts: {},
18
+ repairHistory: [],
19
+ };
20
+ }
21
+ export function buildVariantManifestContext(params) {
22
+ const currentPageId = normalizePageId(params.currentPageRun.pageId);
23
+ const completedPages = params.state.validatedCaptures.map((capture) => capture.pageId);
24
+ return {
25
+ expectedPageIds: [...params.state.expectedPageIds],
26
+ currentPageId,
27
+ currentPageIdentity: params.state.pageIdentities[currentPageId] ?? null,
28
+ completedPages,
29
+ remainingPages: params.state.expectedPageIds.filter((pageId) => !completedPages.includes(pageId)),
30
+ previousValidatedCaptures: [...params.state.validatedCaptures],
31
+ captureStatuses: { ...params.state.captureStatuses },
32
+ lastCheckpointId: params.state.lastCheckpointId,
33
+ blockedReason: params.state.blockedReasons[currentPageId] ?? null,
34
+ recoveryAttempts: { ...params.state.recoveryAttempts },
35
+ repairHistory: [...params.state.repairHistory],
36
+ };
37
+ }
38
+ export function recordValidatedVariantCapture(params) {
39
+ const pageId = normalizePageId(params.capture.pageId);
40
+ const duplicateOfPageId = params.capture.fingerprint
41
+ ? params.state.validatedCaptures.find((existing) => existing.pageId !== pageId
42
+ && existing.fingerprint
43
+ && existing.fingerprint === params.capture.fingerprint)?.pageId ?? null
44
+ : null;
45
+ const nextValidated = [
46
+ ...params.state.validatedCaptures.filter((existing) => existing.pageId !== pageId),
47
+ {
48
+ ...params.capture,
49
+ pageId,
50
+ },
51
+ ];
52
+ return {
53
+ state: {
54
+ expectedPageIds: [...params.state.expectedPageIds],
55
+ pageIdentities: { ...params.state.pageIdentities },
56
+ validatedCaptures: nextValidated,
57
+ captureStatuses: {
58
+ ...params.state.captureStatuses,
59
+ [pageId]: "completed",
60
+ },
61
+ lastCheckpointId: params.checkpointId ?? params.state.lastCheckpointId,
62
+ blockedReasons: {
63
+ ...params.state.blockedReasons,
64
+ [pageId]: null,
65
+ },
66
+ recoveryAttempts: { ...params.state.recoveryAttempts },
67
+ repairHistory: [...params.state.repairHistory],
68
+ },
69
+ duplicateOfPageId,
70
+ };
71
+ }
72
+ export function validateVariantCaptureState(state) {
73
+ const missingPages = state.expectedPageIds.filter((pageId) => !state.validatedCaptures.some((capture) => capture.pageId === pageId)
74
+ && state.captureStatuses[pageId] !== "blocked");
75
+ const blockedPages = state.expectedPageIds
76
+ .filter((pageId) => state.captureStatuses[pageId] === "blocked")
77
+ .map((pageId) => ({ pageId, reason: state.blockedReasons[pageId] ?? null }));
78
+ const duplicatePageIds = [];
79
+ const seenFingerprints = new Map();
80
+ for (const capture of state.validatedCaptures) {
81
+ if (!capture.fingerprint)
82
+ continue;
83
+ const existingPageId = seenFingerprints.get(capture.fingerprint);
84
+ if (existingPageId && existingPageId !== capture.pageId) {
85
+ duplicatePageIds.push({ pageId: capture.pageId, duplicateOfPageId: existingPageId });
86
+ continue;
87
+ }
88
+ seenFingerprints.set(capture.fingerprint, capture.pageId);
89
+ }
90
+ return {
91
+ ok: missingPages.length === 0 && blockedPages.length === 0 && duplicatePageIds.length === 0,
92
+ missingPages,
93
+ blockedPages,
94
+ duplicatePageIds,
95
+ };
96
+ }
97
+ export function hasValidatedVariantPage(state, pageId) {
98
+ const normalized = normalizePageId(pageId);
99
+ return state.validatedCaptures.some((capture) => capture.pageId === normalized);
100
+ }
101
+ export function getVariantCaptureStatus(state, pageId) {
102
+ const normalized = normalizePageId(pageId);
103
+ return state.captureStatuses[normalized] ?? "pending";
104
+ }
105
+ export function markVariantCaptureInProgress(state, pageId) {
106
+ const normalized = normalizePageId(pageId);
107
+ return {
108
+ ...state,
109
+ captureStatuses: {
110
+ ...state.captureStatuses,
111
+ [normalized]: "in_progress",
112
+ },
113
+ blockedReasons: {
114
+ ...state.blockedReasons,
115
+ [normalized]: null,
116
+ },
117
+ };
118
+ }
119
+ export function markVariantCaptureBlocked(params) {
120
+ const normalized = normalizePageId(params.pageId);
121
+ return {
122
+ ...params.state,
123
+ captureStatuses: {
124
+ ...params.state.captureStatuses,
125
+ [normalized]: "blocked",
126
+ },
127
+ blockedReasons: {
128
+ ...params.state.blockedReasons,
129
+ [normalized]: params.reason,
130
+ },
131
+ };
132
+ }
133
+ export function recordVariantRecoveryAttempt(state, pageId) {
134
+ const normalized = normalizePageId(pageId);
135
+ return {
136
+ ...state,
137
+ recoveryAttempts: {
138
+ ...state.recoveryAttempts,
139
+ [normalized]: (state.recoveryAttempts[normalized] ?? 0) + 1,
140
+ },
141
+ };
142
+ }
143
+ export function recordVariantRepair(params) {
144
+ const nextHistory = [...params.state.repairHistory, params.repair];
145
+ return {
146
+ ...params.state,
147
+ repairHistory: nextHistory.slice(-12),
148
+ };
149
+ }
150
+ export function recordVariantCheckpoint(params) {
151
+ return {
152
+ ...params.state,
153
+ lastCheckpointId: params.checkpoint.id,
154
+ };
155
+ }
156
+ //# sourceMappingURL=capture-variant-state.js.map
package/dist/cli.js CHANGED
@@ -10,6 +10,7 @@ import { Browser } from './browser.js';
10
10
  import { logger } from './logger.js';
11
11
  import { writeConfig, requireConfig, DEFAULT_API_BASE_URL, DEFAULT_WS_URL, } from './cli-config.js';
12
12
  import { replaceSkillPlaceholders } from './cli-utils.js';
13
+ import { buildRemoteBrowserClientHello, } from './remote-browser.js';
13
14
  // ── Program definition ──────────────────────────────────────────────
14
15
  export const program = new Command();
15
16
  program
@@ -79,6 +80,7 @@ program
79
80
  await cleanup();
80
81
  });
81
82
  ws.on('open', () => {
83
+ ws.send(JSON.stringify(buildRemoteBrowserClientHello(version)));
82
84
  logger.success('Connected to AutoKap server');
83
85
  });
84
86
  ws.on('message', async (data) => {
@@ -178,6 +180,12 @@ async function executeBrowserCommand(browser, method, params) {
178
180
  case 'closeContext':
179
181
  await browser.closeContext();
180
182
  return null;
183
+ case 'recreateContext':
184
+ await browser.recreateContext(params);
185
+ return null;
186
+ case 'setDeviceScaleFactor':
187
+ await browser.setDeviceScaleFactor(params.deviceScaleFactor);
188
+ return null;
181
189
  // Navigation
182
190
  case 'navigateTo':
183
191
  await browser.navigateTo(params.url);
@@ -306,6 +314,13 @@ async function executeBrowserCommand(browser, method, params) {
306
314
  // Storage
307
315
  case 'exportStorageState': return await browser.exportStorageState();
308
316
  case 'exportSessionStorage': return await browser.exportSessionStorage();
317
+ case 'reloadCurrentPage':
318
+ await browser.reloadCurrentPage(params);
319
+ return null;
320
+ case 'writeStorageHintCandidate':
321
+ return await browser.writeStorageHintCandidate(params);
322
+ case 'probeSelector':
323
+ return await browser.probeSelector(params.selector);
309
324
  case 'prepareSessionStorage':
310
325
  await browser.prepareSessionStorage(params.bundle, params);
311
326
  return null;
@@ -0,0 +1,148 @@
1
+ import type { ClipDefinition, ClipOptions, LoginCredentials, VideoPlan, StepUsage, VideoPhase } from './types.js';
2
+ export interface ClipTarget {
3
+ id: string;
4
+ label: string;
5
+ viewport: {
6
+ width: number;
7
+ height: number;
8
+ };
9
+ }
10
+ export interface ClipOrchestratorConfig {
11
+ url: string;
12
+ clips: ClipDefinition[];
13
+ targets: ClipTarget[];
14
+ outputScale?: number;
15
+ langs: string[];
16
+ themes: Array<'light' | 'dark'>;
17
+ clipOptions?: ClipOptions;
18
+ credentials?: LoginCredentials;
19
+ model: string;
20
+ apiKey: string;
21
+ runId: string;
22
+ presetId?: string;
23
+ projectId?: string;
24
+ langInstructions?: string;
25
+ themeInstructions?: string;
26
+ navigationInstructions?: string;
27
+ abortSignal?: AbortSignal;
28
+ /** Fallback model used when the primary model fails to produce tool calls (e.g. in repair lane). */
29
+ fallbackModel?: string;
30
+ /** Per-clip timeout in milliseconds. Default: 180_000 (3 minutes). */
31
+ perClipTimeoutMs?: number;
32
+ }
33
+ export interface ClipVariantResult {
34
+ clipId: string;
35
+ clipName: string;
36
+ clipScript: string;
37
+ targetId: string;
38
+ targetLabel: string;
39
+ viewportWidth: number;
40
+ viewportHeight: number;
41
+ lang: string;
42
+ theme: string;
43
+ success: boolean;
44
+ gifPath?: string;
45
+ mp4Path?: string;
46
+ thumbnailPath?: string;
47
+ durationMs: number;
48
+ fileSizeBytes?: number;
49
+ plan?: VideoPlan;
50
+ stepsExecuted: number;
51
+ assessment: string;
52
+ failedPhase?: 'preflight' | 'planning' | 'dry_run' | 'recording' | 'postprocess';
53
+ failedStepIndex?: number;
54
+ failedSubphase?: string;
55
+ usage: StepUsage[];
56
+ }
57
+ export interface ClipOrchestratorResult {
58
+ results: ClipVariantResult[];
59
+ totalClips: number;
60
+ successCount: number;
61
+ }
62
+ export interface ClipOrchestratorCallbacks {
63
+ onClipStart?: (data: {
64
+ clipId: string;
65
+ clipName: string;
66
+ variantId: string;
67
+ target: {
68
+ width: number;
69
+ height: number;
70
+ };
71
+ lang: string;
72
+ theme: string;
73
+ clipIndex: number;
74
+ totalClips: number;
75
+ }) => void;
76
+ onClipPhase?: (data: {
77
+ clipId: string;
78
+ variantId: string;
79
+ phase: VideoPhase;
80
+ }) => void;
81
+ onClipStep?: (data: {
82
+ clipId: string;
83
+ variantId: string;
84
+ stepIndex: number;
85
+ total: number;
86
+ description: string;
87
+ phase: 'dry_run' | 'recording';
88
+ }) => void;
89
+ onClipStepResult?: (data: {
90
+ clipId: string;
91
+ variantId: string;
92
+ stepIndex: number;
93
+ ok: boolean;
94
+ reason?: string;
95
+ }) => void;
96
+ onClipRecordingDone?: (data: {
97
+ clipId: string;
98
+ variantId: string;
99
+ success: boolean;
100
+ gifPath?: string;
101
+ mp4Path?: string;
102
+ thumbnailPath?: string;
103
+ durationMs: number;
104
+ fileSizeBytes?: number;
105
+ lang: string;
106
+ theme: string;
107
+ targetId: string;
108
+ targetLabel: string;
109
+ assessment?: string;
110
+ failedPhase?: 'preflight' | 'planning' | 'dry_run' | 'recording' | 'postprocess';
111
+ failedStepIndex?: number;
112
+ failedSubphase?: string;
113
+ }) => void;
114
+ onClipPostprocessStart?: (data: {
115
+ clipId: string;
116
+ variantId: string;
117
+ }) => void;
118
+ onClipPostprocessDone?: (data: {
119
+ clipId: string;
120
+ variantId: string;
121
+ success: boolean;
122
+ gifPath?: string;
123
+ mp4Path?: string;
124
+ }) => void;
125
+ onClipsAllDone?: (data: {
126
+ totalClips: number;
127
+ successCount: number;
128
+ }) => void;
129
+ onLog?: (entry: {
130
+ level: string;
131
+ message: string;
132
+ timestamp: number;
133
+ }) => void;
134
+ /** Emit a live Playwright screenshot (base64 JPEG) for real-time preview in the UI. */
135
+ onScreenshot?: (base64: string) => void;
136
+ }
137
+ /**
138
+ * Run the clip capture pipeline for all clips × targets × langs × themes.
139
+ *
140
+ * Hybrid pipeline:
141
+ * 1. For each (clip, target, lang) — navigate once with the screenshot agent
142
+ * 2. Share the navigation session across theme variants (light/dark)
143
+ * 3. For each variant: plan → validate selectors → record → post-process
144
+ *
145
+ * Navigation sharing: themes only affect `colorScheme` (a Playwright setting),
146
+ * so the same navigation session (cookies, localStorage, URL) is reused.
147
+ */
148
+ export declare function runClipOrchestrator(config: ClipOrchestratorConfig, callbacks?: ClipOrchestratorCallbacks): Promise<ClipOrchestratorResult>;