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,16 @@
1
+ import { PostHog } from 'posthog-node';
2
+ let client = null;
3
+ export function getServerPostHog() {
4
+ const key = process.env.POSTHOG_API_KEY;
5
+ if (!key)
6
+ return null;
7
+ if (!client) {
8
+ client = new PostHog(key, {
9
+ host: process.env.POSTHOG_HOST ?? 'https://eu.i.posthog.com',
10
+ flushAt: 5,
11
+ flushInterval: 10_000,
12
+ });
13
+ }
14
+ return client;
15
+ }
16
+ //# sourceMappingURL=server-posthog.js.map
@@ -0,0 +1,45 @@
1
+ import type { SupabaseClient } from '@supabase/supabase-js';
2
+ export interface ProjectWebhookConfig {
3
+ project_id: string;
4
+ url: string;
5
+ signing_secret: string | null;
6
+ created_at: string;
7
+ updated_at: string;
8
+ }
9
+ export interface CaptureWebhookPayloadResult {
10
+ url: string;
11
+ lang: string;
12
+ theme: 'light' | 'dark';
13
+ captureType?: 'fullpage' | 'element';
14
+ elementName?: string;
15
+ targetId?: string;
16
+ targetLabel?: string;
17
+ deviceFrame?: string;
18
+ success: boolean;
19
+ assessment: string;
20
+ iterations: number;
21
+ finalScreenshotUrl?: string;
22
+ }
23
+ export interface CaptureWebhookPayload {
24
+ event: 'capture.completed';
25
+ run_id: string;
26
+ project_id: string;
27
+ preset_id: string | null;
28
+ completed_at: string;
29
+ total_captures: number;
30
+ success_count: number;
31
+ results: CaptureWebhookPayloadResult[];
32
+ }
33
+ export declare function getProjectWebhookConfig(supabase: SupabaseClient, projectId: string): Promise<ProjectWebhookConfig | null>;
34
+ export declare function buildCaptureWebhookPayload(params: {
35
+ runId: string;
36
+ projectId: string;
37
+ presetId?: string | null;
38
+ completedAt?: string;
39
+ results: CaptureWebhookPayloadResult[];
40
+ }): CaptureWebhookPayload;
41
+ export declare function dispatchProjectCaptureWebhook(params: {
42
+ config: ProjectWebhookConfig;
43
+ payload: CaptureWebhookPayload;
44
+ }): Promise<void>;
45
+ export declare function encryptProjectWebhookSigningSecret(plaintext: string): string;
@@ -0,0 +1,97 @@
1
+ import crypto from 'node:crypto';
2
+ import { decrypt, encrypt, isEncryptedEnvelope, } from './capture-encryption.js';
3
+ function getWebhookEncryptionSecret() {
4
+ const secret = process.env.WEBHOOK_SECRET_ENCRYPTION_SECRET;
5
+ if (!secret) {
6
+ throw new Error('Missing WEBHOOK_SECRET_ENCRYPTION_SECRET for webhook secret encryption');
7
+ }
8
+ return secret;
9
+ }
10
+ function decryptSigningSecret(stored) {
11
+ if (!stored)
12
+ return null;
13
+ try {
14
+ const parsed = JSON.parse(stored);
15
+ if (isEncryptedEnvelope(parsed)) {
16
+ return decrypt(parsed, getWebhookEncryptionSecret());
17
+ }
18
+ }
19
+ catch {
20
+ // Plaintext fallback for legacy rows.
21
+ }
22
+ return stored;
23
+ }
24
+ export async function getProjectWebhookConfig(supabase, projectId) {
25
+ const { data, error } = await supabase
26
+ .from('project_webhooks')
27
+ .select('*')
28
+ .eq('project_id', projectId)
29
+ .maybeSingle();
30
+ if (error) {
31
+ if (error.code === '42P01') {
32
+ return null;
33
+ }
34
+ throw new Error(error.message);
35
+ }
36
+ if (!data)
37
+ return null;
38
+ const config = data;
39
+ return {
40
+ ...config,
41
+ signing_secret: decryptSigningSecret(config.signing_secret),
42
+ };
43
+ }
44
+ export function buildCaptureWebhookPayload(params) {
45
+ return {
46
+ event: 'capture.completed',
47
+ run_id: params.runId,
48
+ project_id: params.projectId,
49
+ preset_id: params.presetId ?? null,
50
+ completed_at: params.completedAt ?? new Date().toISOString(),
51
+ total_captures: params.results.length,
52
+ success_count: params.results.filter((result) => result.success).length,
53
+ results: params.results.map((result) => ({
54
+ url: result.url,
55
+ lang: result.lang,
56
+ theme: result.theme,
57
+ captureType: result.captureType,
58
+ elementName: result.elementName,
59
+ targetId: result.targetId,
60
+ targetLabel: result.targetLabel,
61
+ deviceFrame: result.deviceFrame,
62
+ success: result.success,
63
+ assessment: result.assessment,
64
+ iterations: result.iterations,
65
+ finalScreenshotUrl: result.finalScreenshotUrl,
66
+ })),
67
+ };
68
+ }
69
+ export async function dispatchProjectCaptureWebhook(params) {
70
+ const body = JSON.stringify(params.payload);
71
+ const timestamp = Math.floor(Date.now() / 1000).toString();
72
+ const headers = {
73
+ 'Content-Type': 'application/json',
74
+ 'X-AutoKap-Event': params.payload.event,
75
+ 'X-AutoKap-Timestamp': timestamp,
76
+ };
77
+ if (params.config.signing_secret) {
78
+ const signature = crypto
79
+ .createHmac('sha256', params.config.signing_secret)
80
+ .update(`${timestamp}.${body}`, 'utf8')
81
+ .digest('hex');
82
+ headers['X-AutoKap-Signature'] = signature;
83
+ }
84
+ const response = await fetch(params.config.url, {
85
+ method: 'POST',
86
+ headers,
87
+ body,
88
+ });
89
+ if (!response.ok) {
90
+ const responseText = await response.text().catch(() => '');
91
+ throw new Error(`Webhook responded with ${response.status}${responseText ? `: ${responseText.slice(0, 300)}` : ''}`);
92
+ }
93
+ }
94
+ export function encryptProjectWebhookSigningSecret(plaintext) {
95
+ return JSON.stringify(encrypt(plaintext, getWebhookEncryptionSecret()));
96
+ }
97
+ //# sourceMappingURL=server-project-webhooks.js.map
@@ -0,0 +1,7 @@
1
+ export interface WatermarkBillingPlan {
2
+ entitlements: {
3
+ watermarkScreenshots: boolean;
4
+ };
5
+ }
6
+ export declare function applyScreenshotWatermark(buffer: Buffer, label?: string): Promise<Buffer>;
7
+ export declare function applyPlanScreenshotWatermark(plan: WatermarkBillingPlan, buffer: Buffer): Promise<Buffer>;
@@ -0,0 +1,38 @@
1
+ import sharp from 'sharp';
2
+ function escapeXml(value) {
3
+ return value
4
+ .replaceAll('&', '&amp;')
5
+ .replaceAll('<', '&lt;')
6
+ .replaceAll('>', '&gt;')
7
+ .replaceAll('"', '&quot;')
8
+ .replaceAll('\'', '&apos;');
9
+ }
10
+ export async function applyScreenshotWatermark(buffer, label = 'AutoKap Free') {
11
+ const image = sharp(buffer);
12
+ const metadata = await image.metadata();
13
+ const width = metadata.width ?? 1440;
14
+ const height = metadata.height ?? 900;
15
+ const fontSize = Math.max(18, Math.round(Math.min(width, height) * 0.035));
16
+ const tileGap = fontSize * 4;
17
+ const safeLabel = escapeXml(label);
18
+ const tiles = [];
19
+ for (let y = -height; y < height * 2; y += tileGap) {
20
+ for (let x = -width; x < width * 2; x += tileGap * 1.6) {
21
+ tiles.push(`<text x="${x}" y="${y}" fill="rgba(255,255,255,0.18)" font-family="Arial, sans-serif" font-size="${fontSize}" font-weight="700">${safeLabel}</text>`);
22
+ }
23
+ }
24
+ const overlay = Buffer.from(`<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg">
25
+ <rect x="0" y="0" width="${width}" height="${height}" fill="rgba(0,0,0,0.02)" />
26
+ <g transform="rotate(-24 ${width / 2} ${height / 2})">
27
+ ${tiles.join('')}
28
+ </g>
29
+ </svg>`);
30
+ return image.composite([{ input: overlay }]).png().toBuffer();
31
+ }
32
+ export async function applyPlanScreenshotWatermark(plan, buffer) {
33
+ if (!plan.entitlements.watermarkScreenshots) {
34
+ return buffer;
35
+ }
36
+ return applyScreenshotWatermark(buffer);
37
+ }
38
+ //# sourceMappingURL=server-screenshot-watermark.js.map
@@ -0,0 +1,86 @@
1
+ import { Browser } from './browser.js';
2
+ import type { AgentContextEntry, AgentRunHint, LoginCredentials, SessionProfileAuthState, SessionValidationDiagnostic, SessionValidationDiagnosticConfidence, SessionProfileValidationStatus, ValidatedSessionProfile, VideoPageSignals } from './types.js';
3
+ export interface SessionValidationResult {
4
+ validationStatus: Exclude<SessionProfileValidationStatus, 'repaired'>;
5
+ authState: SessionProfileAuthState;
6
+ authMatches: boolean;
7
+ langMatches: boolean | null;
8
+ themeMatches: boolean | null;
9
+ urlMatches: boolean;
10
+ authDiagnostic: SessionValidationDiagnostic;
11
+ langDiagnostic: SessionValidationDiagnostic;
12
+ themeDiagnostic: SessionValidationDiagnostic;
13
+ urlDiagnostic: SessionValidationDiagnostic;
14
+ detectedLang: string | null;
15
+ detectedTheme: 'light' | 'dark' | null;
16
+ accountLabel: string | null;
17
+ issues: Array<'auth' | 'lang' | 'theme' | 'url'>;
18
+ summary: string;
19
+ }
20
+ export interface RequestedLanguageState {
21
+ requested: string | null;
22
+ detected: string | null;
23
+ active: boolean;
24
+ ambiguous: boolean;
25
+ confidence: SessionValidationDiagnosticConfidence;
26
+ reasons: string[];
27
+ }
28
+ export interface RequestedThemeState {
29
+ requested: 'light' | 'dark' | null;
30
+ detected: 'light' | 'dark' | null;
31
+ active: boolean;
32
+ ambiguous: boolean;
33
+ confidence: SessionValidationDiagnosticConfidence;
34
+ reasons: string[];
35
+ }
36
+ export interface DeterministicSelectorUpdate {
37
+ stepSignature: string;
38
+ selector: string;
39
+ source: 'deterministic';
40
+ success: boolean;
41
+ }
42
+ export declare function evaluateRequestedLanguageState(params: {
43
+ currentUrl: string;
44
+ requestedLang?: string;
45
+ signals: VideoPageSignals;
46
+ }): RequestedLanguageState;
47
+ export declare function evaluateRequestedThemeState(params: {
48
+ requestedTheme?: 'light' | 'dark';
49
+ signals: VideoPageSignals;
50
+ }): RequestedThemeState;
51
+ export declare function buildAgentRunHints(entries: AgentContextEntry[]): AgentRunHint[];
52
+ export declare function validateSessionProfile(params: {
53
+ currentUrl: string;
54
+ startUrl?: string;
55
+ requestedLang?: string;
56
+ requestedTheme?: 'light' | 'dark';
57
+ signals: VideoPageSignals;
58
+ profile?: ValidatedSessionProfile;
59
+ }): SessionValidationResult;
60
+ export declare function collectValidatedSessionProfile(browser: Browser, params: {
61
+ requestedLang?: string;
62
+ requestedTheme?: 'light' | 'dark';
63
+ startUrl?: string;
64
+ existingProfile?: ValidatedSessionProfile;
65
+ includeStorageSnapshots?: boolean;
66
+ }): Promise<{
67
+ profile: ValidatedSessionProfile;
68
+ validation: SessionValidationResult;
69
+ }>;
70
+ export declare function performDeterministicSessionRepair(browser: Browser, params: {
71
+ startUrl?: string;
72
+ requestedLang?: string;
73
+ requestedTheme?: 'light' | 'dark';
74
+ credentials?: LoginCredentials;
75
+ profile?: ValidatedSessionProfile;
76
+ selectorMemory?: Record<string, string[]>;
77
+ }): Promise<{
78
+ repaired: boolean;
79
+ validation: SessionValidationResult;
80
+ pathUsed: string | null;
81
+ updates: DeterministicSelectorUpdate[];
82
+ }>;
83
+ export declare function buildProfileSelectorUpdates(signals: VideoPageSignals, params: {
84
+ requestedLang?: string;
85
+ requestedTheme?: 'light' | 'dark';
86
+ }): DeterministicSelectorUpdate[];