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,80 @@
1
+ import { evaluateRequestedLanguageState, evaluateRequestedThemeState as evaluateRequestedThemeStateRich, } from './session-profile.js';
2
+ function normalizeConfidenceScore(confidence) {
3
+ switch (confidence) {
4
+ case 'high':
5
+ return 1;
6
+ case 'medium':
7
+ return 0.78;
8
+ case 'low':
9
+ default:
10
+ return 0.58;
11
+ }
12
+ }
13
+ export function scoreLocaleSignals(signals, requestedLang) {
14
+ if (!requestedLang)
15
+ return { score: 1, reasons: [], ambiguous: false };
16
+ const languageState = evaluateRequestedLanguageState({
17
+ currentUrl: signals.url,
18
+ requestedLang,
19
+ signals,
20
+ });
21
+ if (languageState.active) {
22
+ return {
23
+ score: normalizeConfidenceScore(languageState.confidence),
24
+ reasons: languageState.reasons,
25
+ ambiguous: false,
26
+ };
27
+ }
28
+ if (languageState.ambiguous) {
29
+ return {
30
+ score: languageState.confidence === 'high' ? 0.45 : languageState.confidence === 'medium' ? 0.32 : 0.18,
31
+ reasons: languageState.reasons,
32
+ ambiguous: true,
33
+ };
34
+ }
35
+ return {
36
+ score: 0,
37
+ reasons: languageState.reasons,
38
+ ambiguous: false,
39
+ };
40
+ }
41
+ export function evaluateRequestedThemeState(signals, requestedTheme) {
42
+ const themeState = evaluateRequestedThemeStateRich({
43
+ requestedTheme,
44
+ signals,
45
+ });
46
+ return {
47
+ detected: themeState.detected,
48
+ active: themeState.active,
49
+ ambiguous: themeState.ambiguous,
50
+ reason: themeState.reasons.join('; ') || 'no_theme_signal',
51
+ };
52
+ }
53
+ export async function detectVariantStateDeterministic(browser, requestedLang, requestedTheme) {
54
+ const signals = await browser.capturePageSignals();
55
+ const languageState = evaluateRequestedLanguageState({
56
+ currentUrl: signals.url,
57
+ requestedLang,
58
+ signals,
59
+ });
60
+ const themeState = evaluateRequestedThemeStateRich({
61
+ requestedTheme,
62
+ signals,
63
+ });
64
+ return {
65
+ lang: {
66
+ requested: requestedLang,
67
+ detected: languageState.detected,
68
+ active: requestedLang ? languageState.active : true,
69
+ ambiguous: requestedLang ? languageState.ambiguous : false,
70
+ },
71
+ theme: {
72
+ requested: requestedTheme,
73
+ detected: themeState.detected,
74
+ active: requestedTheme ? themeState.active : true,
75
+ ambiguous: requestedTheme ? themeState.ambiguous : false,
76
+ },
77
+ pageSignals: signals,
78
+ };
79
+ }
80
+ //# sourceMappingURL=video-variant-state.js.map
@@ -0,0 +1,17 @@
1
+ export declare class VisionModelUnsupportedError extends Error {
2
+ requestedModel: string;
3
+ fallbackModel?: string;
4
+ constructor(requestedModel: string, fallbackModel?: string);
5
+ }
6
+ export declare function isImageInputUnsupportedError(err: unknown): boolean;
7
+ export declare function buildVisionModelUnavailableMessage(requestedModel: string, fallbackModel?: string): string;
8
+ export declare function callVisionCapableModel<T>(params: {
9
+ primaryModel: string;
10
+ fallbackModel?: string;
11
+ callModel: (model: string) => Promise<T>;
12
+ onFallbackActivated?: (model: string, reason: string) => void;
13
+ }): Promise<{
14
+ result: T;
15
+ model: string;
16
+ fellBack: boolean;
17
+ }>;
@@ -0,0 +1,74 @@
1
+ export class VisionModelUnsupportedError extends Error {
2
+ requestedModel;
3
+ fallbackModel;
4
+ constructor(requestedModel, fallbackModel) {
5
+ super(buildVisionModelUnavailableMessage(requestedModel, fallbackModel));
6
+ this.name = 'VisionModelUnsupportedError';
7
+ this.requestedModel = requestedModel;
8
+ this.fallbackModel = fallbackModel;
9
+ }
10
+ }
11
+ function extractNestedErrorMessage(err) {
12
+ if (!err || typeof err !== 'object')
13
+ return '';
14
+ const errorRecord = err;
15
+ const directMessage = typeof errorRecord.message === 'string' ? errorRecord.message : '';
16
+ const nestedError = errorRecord.error;
17
+ const nestedMessage = nestedError && typeof nestedError === 'object' && typeof nestedError.message === 'string'
18
+ ? nestedError.message
19
+ : '';
20
+ if (nestedMessage && nestedMessage === directMessage)
21
+ return directMessage;
22
+ return [directMessage, nestedMessage].filter(Boolean).join(' ');
23
+ }
24
+ export function isImageInputUnsupportedError(err) {
25
+ if (!err || typeof err !== 'object')
26
+ return false;
27
+ const errorRecord = err;
28
+ const status = typeof errorRecord.status === 'number' ? errorRecord.status : undefined;
29
+ const message = extractNestedErrorMessage(err).toLowerCase();
30
+ if (!message)
31
+ return false;
32
+ const mentionsImageEndpoint = message.includes('no endpoints found that support image input')
33
+ || message.includes('no providers that support image input')
34
+ || (message.includes('image input') && message.includes('no') && message.includes('support'))
35
+ || (message.includes('image input') && message.includes('endpoint') && message.includes('no'));
36
+ if (!mentionsImageEndpoint)
37
+ return false;
38
+ return status === undefined || status === 400 || status === 404 || status === 422;
39
+ }
40
+ export function buildVisionModelUnavailableMessage(requestedModel, fallbackModel) {
41
+ const fallbackHint = fallbackModel && fallbackModel !== requestedModel
42
+ ? ` Automatic fallback to "${fallbackModel}" also failed or was unavailable.`
43
+ : '';
44
+ return `The model "${requestedModel}" has no available endpoint that supports image input.${fallbackHint} Configure a vision-capable default/fallback model or retry later if the provider is degraded.`;
45
+ }
46
+ export async function callVisionCapableModel(params) {
47
+ const { primaryModel, fallbackModel, callModel, onFallbackActivated } = params;
48
+ let fallbackReason = '';
49
+ try {
50
+ const result = await callModel(primaryModel);
51
+ return { result, model: primaryModel, fellBack: false };
52
+ }
53
+ catch (err) {
54
+ if (!isImageInputUnsupportedError(err)) {
55
+ throw err;
56
+ }
57
+ fallbackReason = extractNestedErrorMessage(err) || 'image input unsupported';
58
+ if (!fallbackModel || fallbackModel === primaryModel) {
59
+ throw new VisionModelUnsupportedError(primaryModel, fallbackModel);
60
+ }
61
+ }
62
+ try {
63
+ const result = await callModel(fallbackModel);
64
+ onFallbackActivated?.(fallbackModel, fallbackReason);
65
+ return { result, model: fallbackModel, fellBack: true };
66
+ }
67
+ catch (fallbackErr) {
68
+ if (isImageInputUnsupportedError(fallbackErr)) {
69
+ throw new VisionModelUnsupportedError(primaryModel, fallbackModel);
70
+ }
71
+ throw fallbackErr;
72
+ }
73
+ }
74
+ //# sourceMappingURL=vision-model.js.map
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Lightweight auth module for the WS server.
3
+ * Mirrors web/lib/cli-auth.ts + web/lib/api-keys.ts logic
4
+ * but runs outside the Next.js context.
5
+ */
6
+ import { type SupabaseClient } from '@supabase/supabase-js';
7
+ export interface WsAuthResult {
8
+ userId: string;
9
+ apiKeyId: string;
10
+ scopes: string[];
11
+ projectId: string | null;
12
+ }
13
+ export declare function getSupabase(): SupabaseClient;
14
+ export declare function validateApiKey(rawKey: string): Promise<WsAuthResult | null>;
15
+ /**
16
+ * Check that the key has the required scope.
17
+ * CLI keys (scopes = []) have implicit full access — skip the check.
18
+ * API keys must have the scope explicitly listed.
19
+ */
20
+ export declare function requireScope(scopes: string[], required: string): void;
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Lightweight auth module for the WS server.
3
+ * Mirrors web/lib/cli-auth.ts + web/lib/api-keys.ts logic
4
+ * but runs outside the Next.js context.
5
+ */
6
+ import crypto from 'node:crypto';
7
+ import { createClient } from '@supabase/supabase-js';
8
+ // ── Supabase service client ────────────────────────────────────────
9
+ let _client = null;
10
+ export function getSupabase() {
11
+ if (!_client) {
12
+ const url = process.env.SUPABASE_URL ?? process.env.NEXT_PUBLIC_SUPABASE_URL;
13
+ const key = process.env.SUPABASE_SERVICE_ROLE_KEY;
14
+ if (!url || !key) {
15
+ throw new Error('Missing SUPABASE_URL or SUPABASE_SERVICE_ROLE_KEY');
16
+ }
17
+ _client = createClient(url, key);
18
+ }
19
+ return _client;
20
+ }
21
+ // ── Key validation ─────────────────────────────────────────────────
22
+ const VALID_PREFIXES = ['ak_cli_', 'ak_api_', 'ak_live_'];
23
+ function isValidKeyFormat(key) {
24
+ return VALID_PREFIXES.some(p => key.startsWith(p));
25
+ }
26
+ function hashKey(key) {
27
+ return crypto.createHash('sha256').update(key).digest('hex');
28
+ }
29
+ export async function validateApiKey(rawKey) {
30
+ if (!isValidKeyFormat(rawKey))
31
+ return null;
32
+ const hash = hashKey(rawKey);
33
+ const supabase = getSupabase();
34
+ const { data, error } = await supabase
35
+ .from('api_keys')
36
+ .select('id, user_id, scopes, project_id')
37
+ .eq('key_hash', hash)
38
+ .eq('revoked', false)
39
+ .single();
40
+ if (error || !data)
41
+ return null;
42
+ // Update last_used_at (fire-and-forget)
43
+ supabase
44
+ .from('api_keys')
45
+ .update({ last_used_at: new Date().toISOString() })
46
+ .eq('id', data.id)
47
+ .then(() => { });
48
+ return {
49
+ userId: data.user_id,
50
+ apiKeyId: data.id,
51
+ scopes: data.scopes ?? [],
52
+ projectId: data.project_id ?? null,
53
+ };
54
+ }
55
+ /**
56
+ * Check that the key has the required scope.
57
+ * CLI keys (scopes = []) have implicit full access — skip the check.
58
+ * API keys must have the scope explicitly listed.
59
+ */
60
+ export function requireScope(scopes, required) {
61
+ if (scopes.length === 0)
62
+ return; // CLI keys: full access
63
+ if (!scopes.includes(required)) {
64
+ throw new Error(`Missing required scope: ${required}`);
65
+ }
66
+ }
67
+ //# sourceMappingURL=ws-auth.js.map
@@ -0,0 +1,10 @@
1
+ /**
2
+ * WS handler — orchestrates a capture run for a single CLI connection.
3
+ *
4
+ * The CLI stays a thin RPC adapter around a local Playwright browser.
5
+ * The orchestration stays server-side and reuses shared capture helpers
6
+ * so the WS flow does not drift from the HTTP capture flow.
7
+ */
8
+ import type { WebSocket } from 'ws';
9
+ import type { IncomingMessage } from 'node:http';
10
+ export declare function handleConnection(ws: WebSocket, req: IncomingMessage): Promise<void>;