autokap 1.0.6 → 1.0.8
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/assets/chrome/ios-statusbar-comparison-reference.jpg +0 -0
- package/assets/chrome/ios-statusbar-dark-reference.jpg +0 -0
- package/assets/chrome/ios-statusbar-light-reference.jpg +0 -0
- package/assets/cursors/macos.svg +4 -0
- package/assets/cursors/windows.svg +15 -0
- package/assets/devices/ipad-pro-11-m4.json +52 -0
- package/assets/devices/iphone-16-pro.json +53 -0
- package/assets/devices/macbook-air-13.json +45 -0
- package/assets/frames/MacBook Air 13.svg +242 -0
- package/assets/frames/Status bar - iPhone.png +0 -0
- Menu bar- iPad.png +0 -0
- package/assets/frames/iPad Pro M4 11_.png +0 -0
- package/assets/frames/iPhone 16 Pro.png +0 -0
- package/assets/icons/Cellular Connection.svg +3 -0
- package/assets/icons/Union.svg +6 -0
- package/assets/icons/Wifi.svg +3 -0
- package/assets/icons/battery.svg +5 -0
- package/assets/icons/battery_charging.svg +8 -0
- package/assets/skill/OPCODE-REFERENCE.md +607 -0
- package/assets/skill/README.md +39 -0
- package/assets/skill/SKILL.md +453 -468
- package/assets/skill/STUDIO-SKILL.md +476 -0
- package/assets/skill/references/examples.md +104 -0
- package/assets/skill/references/interactive-demo.md +225 -0
- package/assets/skill/references/mock-data.md +178 -0
- package/dist/abort.d.ts +5 -0
- package/dist/abort.js +44 -0
- package/dist/action-verifier.d.ts +29 -0
- package/dist/action-verifier.js +133 -0
- package/dist/agent-action-recovery.d.ts +45 -0
- package/dist/agent-action-recovery.js +370 -0
- package/dist/agent-message-utils.d.ts +21 -0
- package/dist/agent-message-utils.js +77 -0
- package/dist/agent-url-utils.d.ts +30 -0
- package/dist/agent-url-utils.js +138 -0
- package/dist/agent.d.ts +226 -0
- package/dist/agent.js +6666 -0
- package/dist/ak-tree.d.ts +39 -0
- package/dist/ak-tree.js +368 -0
- package/dist/alt-text.d.ts +26 -0
- package/dist/alt-text.js +55 -0
- package/dist/auth-capture.d.ts +17 -0
- package/dist/auth-capture.js +164 -0
- package/dist/benchmark.d.ts +59 -0
- package/dist/benchmark.js +135 -0
- package/dist/billing-operation-logging.d.ts +38 -0
- package/dist/billing-operation-logging.js +248 -0
- package/dist/browser-bar.d.ts +48 -0
- package/dist/browser-bar.js +284 -0
- package/dist/browser-pool.d.ts +7 -0
- package/dist/browser-pool.js +15 -5
- package/dist/browser-utils.d.ts +31 -0
- package/dist/browser-utils.js +97 -0
- package/dist/browser.d.ts +76 -1
- package/dist/browser.js +1657 -39
- package/dist/capture-alt-text.d.ts +12 -0
- package/dist/capture-alt-text.js +52 -0
- package/dist/capture-encryption.d.ts +10 -0
- package/dist/capture-encryption.js +41 -0
- package/dist/capture-language-preflight.d.ts +41 -0
- package/dist/capture-language-preflight.js +300 -0
- package/dist/capture-llm-page-identity.d.ts +15 -0
- package/dist/capture-llm-page-identity.js +128 -0
- package/dist/capture-model-resolution.d.ts +9 -0
- package/dist/capture-model-resolution.js +21 -0
- package/dist/capture-page-identity.d.ts +7 -0
- package/dist/capture-page-identity.js +352 -0
- package/dist/capture-preset-credentials.d.ts +62 -0
- package/dist/capture-preset-credentials.js +184 -0
- package/dist/capture-request-plan.d.ts +58 -0
- package/dist/capture-request-plan.js +264 -0
- package/dist/capture-run-optimizer.d.ts +139 -0
- package/dist/capture-run-optimizer.js +863 -0
- package/dist/capture-selector-memory.d.ts +31 -0
- package/dist/capture-selector-memory.js +345 -0
- package/dist/capture-session-profile-encryption.d.ts +2 -0
- package/dist/capture-session-profile-encryption.js +22 -0
- package/dist/capture-step-timeout.d.ts +10 -0
- package/dist/capture-step-timeout.js +30 -0
- package/dist/capture-strategy.d.ts +36 -0
- package/dist/capture-strategy.js +95 -0
- package/dist/capture-studio-sync.d.ts +23 -0
- package/dist/capture-studio-sync.js +172 -0
- package/dist/capture-surface-contract.d.ts +36 -0
- package/dist/capture-surface-contract.js +299 -0
- package/dist/capture-transition-engine.d.ts +28 -0
- package/dist/capture-transition-engine.js +292 -0
- package/dist/capture-variant-state.d.ts +56 -0
- package/dist/capture-variant-state.js +182 -0
- package/dist/capture-verification.d.ts +35 -0
- package/dist/capture-verification.js +95 -0
- package/dist/capture-viewport-lock.d.ts +48 -0
- package/dist/capture-viewport-lock.js +74 -0
- package/dist/circuit-breaker.d.ts +42 -0
- package/dist/circuit-breaker.js +119 -0
- package/dist/cli-config.d.ts +8 -1
- package/dist/cli-config.js +62 -6
- package/dist/cli-contract.d.ts +15 -0
- package/dist/cli-contract.js +167 -0
- package/dist/cli-runner-local.d.ts +12 -0
- package/dist/cli-runner-local.js +102 -0
- package/dist/cli-runner.d.ts +34 -0
- package/dist/cli-runner.js +433 -0
- package/dist/cli-utils.d.ts +0 -1
- package/dist/cli-utils.js +2 -5
- package/dist/cli.js +1005 -252
- package/dist/clip-orchestrator.d.ts +148 -0
- package/dist/clip-orchestrator.js +957 -0
- package/dist/clip-postprocess.d.ts +42 -0
- package/dist/clip-postprocess.js +201 -0
- package/dist/cookie-dismiss.d.ts +2 -0
- package/dist/cookie-dismiss.js +48 -13
- package/dist/cost-logging.d.ts +35 -0
- package/dist/cost-logging.js +242 -0
- package/dist/cost-resolution-monitor.d.ts +16 -0
- package/dist/cost-resolution-monitor.js +34 -0
- package/dist/credential-templates.d.ts +5 -0
- package/dist/credential-templates.js +60 -0
- package/dist/cursor-overlay-script.d.ts +6 -0
- package/dist/cursor-overlay-script.js +169 -0
- package/dist/dom-css-purger.d.ts +65 -0
- package/dist/dom-css-purger.js +333 -0
- package/dist/dom-font-inliner.d.ts +45 -0
- package/dist/dom-font-inliner.js +148 -0
- package/dist/dom-patch-resolver.d.ts +52 -0
- package/dist/dom-patch-resolver.js +242 -0
- package/dist/dom-serializer.d.ts +82 -0
- package/dist/dom-serializer.js +378 -0
- package/dist/element-capture.d.ts +13 -0
- package/dist/element-capture.js +522 -0
- package/dist/env-validation.d.ts +5 -0
- package/dist/env-validation.js +29 -0
- package/dist/execution-schema.d.ts +4423 -0
- package/dist/execution-schema.js +507 -0
- package/dist/execution-types.d.ts +886 -0
- package/dist/execution-types.js +65 -0
- package/dist/fonts-loader.d.ts +14 -0
- package/dist/fonts-loader.js +55 -0
- package/dist/hybrid-navigator.d.ts +138 -0
- package/dist/hybrid-navigator.js +468 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +17 -0
- package/dist/legacy/agent-action-recovery.d.ts +45 -0
- package/dist/legacy/agent-action-recovery.js +370 -0
- package/dist/legacy/agent-message-utils.d.ts +21 -0
- package/dist/legacy/agent-message-utils.js +77 -0
- package/dist/legacy/agent-url-utils.d.ts +30 -0
- package/dist/legacy/agent-url-utils.js +138 -0
- package/dist/legacy/agent.d.ts +226 -0
- package/dist/legacy/agent.js +6666 -0
- package/dist/legacy/clip-orchestrator.d.ts +148 -0
- package/dist/legacy/clip-orchestrator.js +957 -0
- package/dist/legacy/credential-templates.d.ts +5 -0
- package/dist/legacy/credential-templates.js +60 -0
- package/dist/legacy/hybrid-navigator.d.ts +138 -0
- package/dist/legacy/hybrid-navigator.js +468 -0
- package/dist/legacy/llm-usage.d.ts +17 -0
- package/dist/legacy/llm-usage.js +45 -0
- package/dist/legacy/prompt-cache.d.ts +10 -0
- package/dist/legacy/prompt-cache.js +24 -0
- package/dist/legacy/prompts.d.ts +175 -0
- package/dist/legacy/prompts.js +1038 -0
- package/dist/legacy/tools.d.ts +4 -0
- package/dist/legacy/tools.js +216 -0
- package/dist/legacy/video-agent.d.ts +143 -0
- package/dist/legacy/video-agent.js +4788 -0
- package/dist/legacy/video-observation.d.ts +36 -0
- package/dist/legacy/video-observation.js +192 -0
- package/dist/legacy/video-planner.d.ts +12 -0
- package/dist/legacy/video-planner.js +501 -0
- package/dist/legacy/video-prompts.d.ts +37 -0
- package/dist/legacy/video-prompts.js +569 -0
- package/dist/legacy/video-tools.d.ts +3 -0
- package/dist/legacy/video-tools.js +59 -0
- package/dist/legacy/video-variant-state.d.ts +29 -0
- package/dist/legacy/video-variant-state.js +80 -0
- package/dist/legacy/vision-model.d.ts +17 -0
- package/dist/legacy/vision-model.js +74 -0
- package/dist/llm-healer.d.ts +63 -0
- package/dist/llm-healer.js +166 -0
- package/dist/llm-provider.d.ts +29 -0
- package/dist/llm-provider.js +80 -0
- package/dist/llm-usage.d.ts +17 -0
- package/dist/llm-usage.js +45 -0
- package/dist/logger.d.ts +6 -2
- package/dist/logger.js +15 -1
- package/dist/mockup-html.d.ts +119 -0
- package/dist/mockup-html.js +263 -0
- package/dist/mockup.d.ts +187 -0
- package/dist/mockup.js +869 -0
- package/dist/mouse-animation.d.ts +46 -0
- package/dist/mouse-animation.js +114 -0
- package/dist/opcode-actions.d.ts +42 -0
- package/dist/opcode-actions.js +511 -0
- package/dist/opcode-runner.d.ts +51 -0
- package/dist/opcode-runner.js +770 -0
- package/dist/openrouter-client.d.ts +40 -0
- package/dist/openrouter-client.js +16 -0
- package/dist/overlay-engine.d.ts +24 -0
- package/dist/overlay-engine.js +176 -0
- package/dist/overlay-utils.d.ts +14 -0
- package/dist/overlay-utils.js +13 -0
- package/dist/postcondition.d.ts +16 -0
- package/dist/postcondition.js +269 -0
- package/dist/posthog.d.ts +4 -0
- package/dist/posthog.js +26 -0
- package/dist/program-patcher.d.ts +25 -0
- package/dist/program-patcher.js +44 -0
- package/dist/prompt-cache.d.ts +10 -0
- package/dist/prompt-cache.js +24 -0
- package/dist/prompts.d.ts +175 -0
- package/dist/prompts.js +1038 -0
- package/dist/provider-config.d.ts +12 -0
- package/dist/provider-config.js +15 -0
- package/dist/recovery-chain.d.ts +37 -0
- package/dist/recovery-chain.js +350 -0
- package/dist/remote-browser.d.ts +215 -0
- package/dist/remote-browser.js +360 -0
- package/dist/safari-browser-bar.d.ts +15 -0
- package/dist/safari-browser-bar.js +95 -0
- package/dist/safari-toolbar-asset.d.ts +15 -0
- package/dist/safari-toolbar-asset.js +12 -0
- package/dist/security.d.ts +21 -0
- package/dist/security.js +608 -0
- package/dist/selector-resolver.d.ts +34 -0
- package/dist/selector-resolver.js +181 -0
- package/dist/semantic-resolver.d.ts +35 -0
- package/dist/semantic-resolver.js +161 -0
- package/dist/server-capture-runtime.d.ts +125 -0
- package/dist/server-capture-runtime.js +585 -0
- package/dist/server-credit-usage.d.ts +12 -0
- package/dist/server-credit-usage.js +41 -0
- package/dist/server-posthog.d.ts +2 -0
- package/dist/server-posthog.js +16 -0
- package/dist/server-project-webhooks.d.ts +59 -0
- package/dist/server-project-webhooks.js +123 -0
- package/dist/server-screenshot-watermark.d.ts +7 -0
- package/dist/server-screenshot-watermark.js +60 -0
- package/dist/session-profile.d.ts +86 -0
- package/dist/session-profile.js +1536 -0
- package/dist/sf-pro-fonts.d.ts +4 -0
- package/dist/sf-pro-fonts.js +7 -0
- package/dist/sf-pro-symbols.d.ts +1 -0
- package/dist/sf-pro-symbols.js +55 -0
- package/dist/skill-packaging.d.ts +28 -0
- package/dist/skill-packaging.js +169 -0
- package/dist/smart-wait.d.ts +27 -0
- package/dist/smart-wait.js +81 -0
- package/dist/status-bar-l10n.d.ts +14 -0
- package/dist/status-bar-l10n.js +177 -0
- package/dist/status-bar-render.d.ts +20 -0
- package/dist/status-bar-render.js +410 -0
- package/dist/status-bar.d.ts +53 -0
- package/dist/status-bar.js +620 -0
- package/dist/svg-browser-bar.d.ts +33 -0
- package/dist/svg-browser-bar.js +206 -0
- package/dist/svg-status-bar.d.ts +36 -0
- package/dist/svg-status-bar.js +597 -0
- package/dist/svg-text.d.ts +61 -0
- package/dist/svg-text.js +118 -0
- package/dist/tools.d.ts +4 -0
- package/dist/tools.js +216 -0
- package/dist/types.d.ts +240 -5
- package/dist/types.js +23 -1
- package/dist/v2/action-verifier.d.ts +29 -0
- package/dist/v2/action-verifier.js +133 -0
- package/dist/v2/alt-text.d.ts +26 -0
- package/dist/v2/alt-text.js +55 -0
- package/dist/v2/benchmark.d.ts +59 -0
- package/dist/v2/benchmark.js +135 -0
- package/dist/v2/capture-strategy.d.ts +30 -0
- package/dist/v2/capture-strategy.js +67 -0
- package/dist/v2/capture-verification.d.ts +35 -0
- package/dist/v2/capture-verification.js +95 -0
- package/dist/v2/circuit-breaker.d.ts +42 -0
- package/dist/v2/circuit-breaker.js +119 -0
- package/dist/v2/cli-runner-local.d.ts +11 -0
- package/dist/v2/cli-runner-local.js +91 -0
- package/dist/v2/cli-runner.d.ts +34 -0
- package/dist/v2/cli-runner.js +300 -0
- package/dist/v2/compiler-prompts.d.ts +27 -0
- package/dist/v2/compiler-prompts.js +123 -0
- package/dist/v2/compiler.d.ts +37 -0
- package/dist/v2/compiler.js +147 -0
- package/dist/v2/explorer.d.ts +41 -0
- package/dist/v2/explorer.js +56 -0
- package/dist/v2/index.d.ts +37 -0
- package/dist/v2/index.js +31 -0
- package/dist/v2/llm-healer.d.ts +62 -0
- package/dist/v2/llm-healer.js +166 -0
- package/dist/v2/llm-provider.d.ts +29 -0
- package/dist/v2/llm-provider.js +80 -0
- package/dist/v2/opcode-runner.d.ts +47 -0
- package/dist/v2/opcode-runner.js +634 -0
- package/dist/v2/overlay-engine.d.ts +24 -0
- package/dist/v2/overlay-engine.js +150 -0
- package/dist/v2/postcondition.d.ts +16 -0
- package/dist/v2/postcondition.js +249 -0
- package/dist/v2/program-patcher.d.ts +25 -0
- package/dist/v2/program-patcher.js +44 -0
- package/dist/v2/recovery-chain.d.ts +30 -0
- package/dist/v2/recovery-chain.js +368 -0
- package/dist/v2/schema.d.ts +2580 -0
- package/dist/v2/schema.js +295 -0
- package/dist/v2/selector-resolver.d.ts +34 -0
- package/dist/v2/selector-resolver.js +181 -0
- package/dist/v2/semantic-resolver.d.ts +35 -0
- package/dist/v2/semantic-resolver.js +161 -0
- package/dist/v2/smart-wait.d.ts +27 -0
- package/dist/v2/smart-wait.js +81 -0
- package/dist/v2/types.d.ts +444 -0
- package/dist/v2/types.js +19 -0
- package/dist/v2/web-playwright-local.d.ts +69 -0
- package/dist/v2/web-playwright-local.js +392 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/video-agent.d.ts +143 -0
- package/dist/video-agent.js +4788 -0
- package/dist/video-observation.d.ts +36 -0
- package/dist/video-observation.js +192 -0
- package/dist/video-planner.d.ts +12 -0
- package/dist/video-planner.js +501 -0
- package/dist/video-prompts.d.ts +37 -0
- package/dist/video-prompts.js +554 -0
- package/dist/video-tools.d.ts +3 -0
- package/dist/video-tools.js +59 -0
- package/dist/video-variant-state.d.ts +29 -0
- package/dist/video-variant-state.js +80 -0
- package/dist/vision-model.d.ts +17 -0
- package/dist/vision-model.js +74 -0
- package/dist/web-playwright-local.d.ts +126 -0
- package/dist/web-playwright-local.js +819 -0
- package/dist/ws-auth.d.ts +20 -0
- package/dist/ws-auth.js +70 -0
- package/dist/ws-broadcast.d.ts +34 -0
- package/dist/ws-broadcast.js +85 -0
- package/dist/ws-connection-limits.d.ts +12 -0
- package/dist/ws-connection-limits.js +44 -0
- package/dist/ws-handler-utils.d.ts +32 -0
- package/dist/ws-handler-utils.js +139 -0
- package/dist/ws-handler.d.ts +10 -0
- package/dist/ws-handler.js +1793 -0
- package/dist/ws-metrics-server.d.ts +9 -0
- package/dist/ws-metrics-server.js +31 -0
- package/dist/ws-server.d.ts +9 -0
- package/dist/ws-server.js +92 -0
- package/package.json +142 -71
|
@@ -0,0 +1,59 @@
|
|
|
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
|
+
/** IDs of screenshot_endpoints affected by this capture run (for proxy cache invalidation). */
|
|
33
|
+
affected_endpoint_ids: string[];
|
|
34
|
+
}
|
|
35
|
+
export interface EndpointChangedWebhookPayload {
|
|
36
|
+
event: 'endpoint.changed';
|
|
37
|
+
project_id: string;
|
|
38
|
+
preset_id: string | null;
|
|
39
|
+
timestamp: string;
|
|
40
|
+
created_endpoint_ids: string[];
|
|
41
|
+
deleted_endpoint_ids: string[];
|
|
42
|
+
/** Full list of currently active endpoint IDs for the project. */
|
|
43
|
+
current_endpoint_ids: string[];
|
|
44
|
+
}
|
|
45
|
+
export type WebhookPayload = CaptureWebhookPayload | EndpointChangedWebhookPayload;
|
|
46
|
+
export declare function getProjectWebhookConfig(supabase: SupabaseClient, projectId: string): Promise<ProjectWebhookConfig | null>;
|
|
47
|
+
export declare function buildCaptureWebhookPayload(params: {
|
|
48
|
+
runId: string;
|
|
49
|
+
projectId: string;
|
|
50
|
+
presetId?: string | null;
|
|
51
|
+
completedAt?: string;
|
|
52
|
+
results: CaptureWebhookPayloadResult[];
|
|
53
|
+
affectedEndpointIds?: string[];
|
|
54
|
+
}): CaptureWebhookPayload;
|
|
55
|
+
export declare function dispatchProjectCaptureWebhook(params: {
|
|
56
|
+
config: ProjectWebhookConfig;
|
|
57
|
+
payload: WebhookPayload;
|
|
58
|
+
}): Promise<void>;
|
|
59
|
+
export declare function encryptProjectWebhookSigningSecret(plaintext: string): string;
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
affected_endpoint_ids: params.affectedEndpointIds ?? [],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const WEBHOOK_RETRY_DELAYS = [0, 1_000, 3_000, 9_000];
|
|
71
|
+
const WEBHOOK_TIMEOUT_MS = 10_000;
|
|
72
|
+
export async function dispatchProjectCaptureWebhook(params) {
|
|
73
|
+
const body = JSON.stringify(params.payload);
|
|
74
|
+
const timestamp = Math.floor(Date.now() / 1000).toString();
|
|
75
|
+
const headers = {
|
|
76
|
+
'Content-Type': 'application/json',
|
|
77
|
+
'X-AutoKap-Event': params.payload.event,
|
|
78
|
+
'X-AutoKap-Timestamp': timestamp,
|
|
79
|
+
};
|
|
80
|
+
if (params.config.signing_secret) {
|
|
81
|
+
const signature = crypto
|
|
82
|
+
.createHmac('sha256', params.config.signing_secret)
|
|
83
|
+
.update(`${timestamp}.${body}`, 'utf8')
|
|
84
|
+
.digest('hex');
|
|
85
|
+
headers['X-AutoKap-Signature'] = signature;
|
|
86
|
+
}
|
|
87
|
+
let lastError = null;
|
|
88
|
+
for (let attempt = 0; attempt < WEBHOOK_RETRY_DELAYS.length; attempt++) {
|
|
89
|
+
if (attempt > 0) {
|
|
90
|
+
await new Promise((resolve) => setTimeout(resolve, WEBHOOK_RETRY_DELAYS[attempt]));
|
|
91
|
+
}
|
|
92
|
+
try {
|
|
93
|
+
const response = await fetch(params.config.url, {
|
|
94
|
+
method: 'POST',
|
|
95
|
+
headers,
|
|
96
|
+
body,
|
|
97
|
+
signal: AbortSignal.timeout(WEBHOOK_TIMEOUT_MS),
|
|
98
|
+
});
|
|
99
|
+
if (response.ok)
|
|
100
|
+
return;
|
|
101
|
+
// Don't retry on 4xx client errors (except 429 rate limiting)
|
|
102
|
+
if (response.status >= 400 && response.status < 500 && response.status !== 429) {
|
|
103
|
+
const responseText = await response.text().catch(() => '');
|
|
104
|
+
throw new Error(`Webhook responded with ${response.status}${responseText ? `: ${responseText.slice(0, 300)}` : ''}`);
|
|
105
|
+
}
|
|
106
|
+
// 5xx or 429 — retry
|
|
107
|
+
const responseText = await response.text().catch(() => '');
|
|
108
|
+
lastError = new Error(`Webhook responded with ${response.status}${responseText ? `: ${responseText.slice(0, 300)}` : ''}`);
|
|
109
|
+
}
|
|
110
|
+
catch (error) {
|
|
111
|
+
lastError = error;
|
|
112
|
+
// Network errors and timeouts are retryable
|
|
113
|
+
if (error.name === 'AbortError') {
|
|
114
|
+
lastError = new Error(`Webhook timed out after ${WEBHOOK_TIMEOUT_MS}ms`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
throw lastError ?? new Error('Webhook delivery failed after retries');
|
|
119
|
+
}
|
|
120
|
+
export function encryptProjectWebhookSigningSecret(plaintext) {
|
|
121
|
+
return JSON.stringify(encrypt(plaintext, getWebhookEncryptionSecret()));
|
|
122
|
+
}
|
|
123
|
+
//# 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,60 @@
|
|
|
1
|
+
import sharp from 'sharp';
|
|
2
|
+
function escapeXml(value) {
|
|
3
|
+
return value
|
|
4
|
+
.replaceAll('&', '&')
|
|
5
|
+
.replaceAll('<', '<')
|
|
6
|
+
.replaceAll('>', '>')
|
|
7
|
+
.replaceAll('"', '"')
|
|
8
|
+
.replaceAll('\'', ''');
|
|
9
|
+
}
|
|
10
|
+
/** LRU cache for watermark SVG overlays — avoids regenerating tiles for repeated dimensions. */
|
|
11
|
+
const SVG_CACHE_MAX = 20;
|
|
12
|
+
const svgOverlayCache = new Map();
|
|
13
|
+
function getOrBuildSvgOverlay(width, height, label) {
|
|
14
|
+
const cacheKey = `${width}:${height}:${label}`;
|
|
15
|
+
const cached = svgOverlayCache.get(cacheKey);
|
|
16
|
+
if (cached) {
|
|
17
|
+
// Move to end (LRU refresh)
|
|
18
|
+
svgOverlayCache.delete(cacheKey);
|
|
19
|
+
svgOverlayCache.set(cacheKey, cached);
|
|
20
|
+
return cached;
|
|
21
|
+
}
|
|
22
|
+
const fontSize = Math.max(18, Math.round(Math.min(width, height) * 0.035));
|
|
23
|
+
const tileGap = fontSize * 4;
|
|
24
|
+
const safeLabel = escapeXml(label);
|
|
25
|
+
const tiles = [];
|
|
26
|
+
for (let y = -height; y < height * 2; y += tileGap) {
|
|
27
|
+
for (let x = -width; x < width * 2; x += tileGap * 1.6) {
|
|
28
|
+
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>`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const overlay = Buffer.from(`<svg width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg">
|
|
32
|
+
<rect x="0" y="0" width="${width}" height="${height}" fill="rgba(0,0,0,0.02)" />
|
|
33
|
+
<g transform="rotate(-24 ${width / 2} ${height / 2})">
|
|
34
|
+
${tiles.join('')}
|
|
35
|
+
</g>
|
|
36
|
+
</svg>`);
|
|
37
|
+
// Evict oldest entry if cache is full
|
|
38
|
+
if (svgOverlayCache.size >= SVG_CACHE_MAX) {
|
|
39
|
+
const firstKey = svgOverlayCache.keys().next().value;
|
|
40
|
+
if (firstKey !== undefined)
|
|
41
|
+
svgOverlayCache.delete(firstKey);
|
|
42
|
+
}
|
|
43
|
+
svgOverlayCache.set(cacheKey, overlay);
|
|
44
|
+
return overlay;
|
|
45
|
+
}
|
|
46
|
+
export async function applyScreenshotWatermark(buffer, label = 'AutoKap Free') {
|
|
47
|
+
const image = sharp(buffer);
|
|
48
|
+
const metadata = await image.metadata();
|
|
49
|
+
const width = metadata.width ?? 1440;
|
|
50
|
+
const height = metadata.height ?? 900;
|
|
51
|
+
const overlay = getOrBuildSvgOverlay(width, height, label);
|
|
52
|
+
return image.composite([{ input: overlay }]).png().toBuffer();
|
|
53
|
+
}
|
|
54
|
+
export async function applyPlanScreenshotWatermark(plan, buffer) {
|
|
55
|
+
if (!plan.entitlements.watermarkScreenshots) {
|
|
56
|
+
return buffer;
|
|
57
|
+
}
|
|
58
|
+
return applyScreenshotWatermark(buffer);
|
|
59
|
+
}
|
|
60
|
+
//# 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[];
|