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,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight internal HTTP server that exposes WS server metrics
|
|
3
|
+
* for the monitoring cron running in the Next.js process.
|
|
4
|
+
*
|
|
5
|
+
* Binds to 127.0.0.1 only — not exposed externally.
|
|
6
|
+
*/
|
|
7
|
+
import { type Server } from 'node:http';
|
|
8
|
+
import type { WebSocketServer } from 'ws';
|
|
9
|
+
export declare function startMetricsServer(wss: WebSocketServer): Server;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lightweight internal HTTP server that exposes WS server metrics
|
|
3
|
+
* for the monitoring cron running in the Next.js process.
|
|
4
|
+
*
|
|
5
|
+
* Binds to 127.0.0.1 only — not exposed externally.
|
|
6
|
+
*/
|
|
7
|
+
import { createServer } from 'node:http';
|
|
8
|
+
import { browserPool } from './browser-pool.js';
|
|
9
|
+
import { logger } from './logger.js';
|
|
10
|
+
const METRICS_PORT = parseInt(process.env.METRICS_PORT ?? '3002', 10);
|
|
11
|
+
export function startMetricsServer(wss) {
|
|
12
|
+
const server = createServer((req, res) => {
|
|
13
|
+
if (req.method === 'GET' && req.url === '/metrics') {
|
|
14
|
+
const poolStats = browserPool.getStats();
|
|
15
|
+
const payload = {
|
|
16
|
+
browserPool: poolStats,
|
|
17
|
+
wsConnections: wss.clients.size,
|
|
18
|
+
};
|
|
19
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
20
|
+
res.end(JSON.stringify(payload));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
res.writeHead(404);
|
|
24
|
+
res.end();
|
|
25
|
+
});
|
|
26
|
+
server.listen(METRICS_PORT, '127.0.0.1', () => {
|
|
27
|
+
logger.info(`[Metrics] Internal metrics server on 127.0.0.1:${METRICS_PORT}/metrics`);
|
|
28
|
+
});
|
|
29
|
+
return server;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ws-metrics-server.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AutoKap WebSocket server — runs alongside Next.js on the VPS.
|
|
4
|
+
* Accepts CLI connections and orchestrates captures using RemoteBrowser.
|
|
5
|
+
*
|
|
6
|
+
* Usage: node dist/ws-server.js
|
|
7
|
+
* Env: WS_PORT (default 3001), SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, OPENROUTER_API_KEY
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* AutoKap WebSocket server — runs alongside Next.js on the VPS.
|
|
4
|
+
* Accepts CLI connections and orchestrates captures using RemoteBrowser.
|
|
5
|
+
*
|
|
6
|
+
* Usage: node dist/ws-server.js
|
|
7
|
+
* Env: WS_PORT (default 3001), SUPABASE_URL, SUPABASE_SERVICE_ROLE_KEY, OPENROUTER_API_KEY
|
|
8
|
+
*/
|
|
9
|
+
import { config as loadEnv } from 'dotenv';
|
|
10
|
+
import { WebSocketServer } from 'ws';
|
|
11
|
+
import { handleConnection } from './ws-handler.js';
|
|
12
|
+
import { logger } from './logger.js';
|
|
13
|
+
import { MAX_CONNECTIONS_PER_IP, getIpConnectionCount, incrementIpConnections, decrementIpConnections, } from './ws-connection-limits.js';
|
|
14
|
+
import { startMetricsServer } from './ws-metrics-server.js';
|
|
15
|
+
import { validateRequiredEnv } from './env-validation.js';
|
|
16
|
+
loadEnv();
|
|
17
|
+
validateRequiredEnv();
|
|
18
|
+
const PORT = parseInt(process.env.WS_PORT ?? '3001', 10);
|
|
19
|
+
function getClientIp(req) {
|
|
20
|
+
return req.headers['x-real-ip'] ?? req.socket.remoteAddress ?? 'unknown';
|
|
21
|
+
}
|
|
22
|
+
const wss = new WebSocketServer({
|
|
23
|
+
port: PORT,
|
|
24
|
+
path: '/ws',
|
|
25
|
+
maxPayload: 10 * 1024 * 1024, // 10 MB max message (screenshots can be large)
|
|
26
|
+
});
|
|
27
|
+
wss.on('connection', (ws, req) => {
|
|
28
|
+
const ip = getClientIp(req);
|
|
29
|
+
// Per-IP rate limit
|
|
30
|
+
const ipCount = getIpConnectionCount(ip);
|
|
31
|
+
if (ipCount >= MAX_CONNECTIONS_PER_IP) {
|
|
32
|
+
logger.warn(`[WS] Rejecting connection from ${ip} — IP limit reached (${ipCount})`);
|
|
33
|
+
ws.close(4029, 'Too many connections');
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
incrementIpConnections(ip);
|
|
37
|
+
logger.info(`[WS] New connection from ${ip}`);
|
|
38
|
+
handleConnection(ws, req).catch(err => {
|
|
39
|
+
logger.error(`[WS] Unhandled error: ${err.message}`);
|
|
40
|
+
try {
|
|
41
|
+
ws.close(5000, 'Internal error');
|
|
42
|
+
}
|
|
43
|
+
catch { /* ignore */ }
|
|
44
|
+
});
|
|
45
|
+
ws.on('close', () => {
|
|
46
|
+
decrementIpConnections(ip);
|
|
47
|
+
logger.info(`[WS] Connection closed from ${ip}`);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
wss.on('error', (err) => {
|
|
51
|
+
logger.error(`[WS] Server error: ${err.message}`);
|
|
52
|
+
});
|
|
53
|
+
// Heartbeat — detect dead connections (NAT timeout, network drops)
|
|
54
|
+
const PING_INTERVAL_MS = 30_000;
|
|
55
|
+
const PONG_TIMEOUT_MS = 10_000;
|
|
56
|
+
const aliveMap = new WeakMap();
|
|
57
|
+
const heartbeatInterval = setInterval(() => {
|
|
58
|
+
for (const ws of wss.clients) {
|
|
59
|
+
if (aliveMap.get(ws) === false) {
|
|
60
|
+
logger.warn('[WS] Terminating unresponsive connection');
|
|
61
|
+
ws.terminate();
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
aliveMap.set(ws, false);
|
|
65
|
+
ws.ping();
|
|
66
|
+
}
|
|
67
|
+
}, PING_INTERVAL_MS);
|
|
68
|
+
wss.on('connection', (ws) => {
|
|
69
|
+
aliveMap.set(ws, true);
|
|
70
|
+
ws.on('pong', () => { aliveMap.set(ws, true); });
|
|
71
|
+
});
|
|
72
|
+
heartbeatInterval.unref();
|
|
73
|
+
logger.success(`AutoKap WS server listening on port ${PORT} (path: /ws)`);
|
|
74
|
+
// Internal metrics endpoint for the monitoring cron
|
|
75
|
+
const metricsServer = startMetricsServer(wss);
|
|
76
|
+
// Graceful shutdown
|
|
77
|
+
process.on('SIGTERM', () => {
|
|
78
|
+
logger.info('[WS] SIGTERM received, closing...');
|
|
79
|
+
metricsServer.close();
|
|
80
|
+
wss.close(() => {
|
|
81
|
+
logger.info('[WS] Server closed');
|
|
82
|
+
process.exit(0);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
process.on('SIGINT', () => {
|
|
86
|
+
logger.info('[WS] SIGINT received, closing...');
|
|
87
|
+
metricsServer.close();
|
|
88
|
+
wss.close(() => {
|
|
89
|
+
process.exit(0);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=ws-server.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autokap",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "AI-powered CLI tool for capturing clean screenshots of websites",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -14,14 +14,22 @@
|
|
|
14
14
|
"types": "./dist/browser.d.ts",
|
|
15
15
|
"default": "./dist/browser.js"
|
|
16
16
|
},
|
|
17
|
-
"./agent": {
|
|
18
|
-
"types": "./dist/agent.d.ts",
|
|
19
|
-
"default": "./dist/agent.js"
|
|
20
|
-
},
|
|
21
17
|
"./cookie-dismiss": {
|
|
22
18
|
"types": "./dist/cookie-dismiss.d.ts",
|
|
23
19
|
"default": "./dist/cookie-dismiss.js"
|
|
24
20
|
},
|
|
21
|
+
"./dom-serializer": {
|
|
22
|
+
"types": "./dist/dom-serializer.d.ts",
|
|
23
|
+
"default": "./dist/dom-serializer.js"
|
|
24
|
+
},
|
|
25
|
+
"./dom-css-purger": {
|
|
26
|
+
"types": "./dist/dom-css-purger.d.ts",
|
|
27
|
+
"default": "./dist/dom-css-purger.js"
|
|
28
|
+
},
|
|
29
|
+
"./dom-font-inliner": {
|
|
30
|
+
"types": "./dist/dom-font-inliner.d.ts",
|
|
31
|
+
"default": "./dist/dom-font-inliner.js"
|
|
32
|
+
},
|
|
25
33
|
"./logger": {
|
|
26
34
|
"types": "./dist/logger.d.ts",
|
|
27
35
|
"default": "./dist/logger.js"
|
|
@@ -30,6 +38,22 @@
|
|
|
30
38
|
"types": "./dist/types.d.ts",
|
|
31
39
|
"default": "./dist/types.js"
|
|
32
40
|
},
|
|
41
|
+
"./execution-schema": {
|
|
42
|
+
"types": "./dist/execution-schema.d.ts",
|
|
43
|
+
"default": "./dist/execution-schema.js"
|
|
44
|
+
},
|
|
45
|
+
"./execution-types": {
|
|
46
|
+
"types": "./dist/execution-types.d.ts",
|
|
47
|
+
"default": "./dist/execution-types.js"
|
|
48
|
+
},
|
|
49
|
+
"./alt-text": {
|
|
50
|
+
"types": "./dist/alt-text.d.ts",
|
|
51
|
+
"default": "./dist/alt-text.js"
|
|
52
|
+
},
|
|
53
|
+
"./llm-provider": {
|
|
54
|
+
"types": "./dist/llm-provider.d.ts",
|
|
55
|
+
"default": "./dist/llm-provider.js"
|
|
56
|
+
},
|
|
33
57
|
"./mockup": {
|
|
34
58
|
"types": "./dist/mockup.d.ts",
|
|
35
59
|
"default": "./dist/mockup.js"
|
|
@@ -50,90 +74,140 @@
|
|
|
50
74
|
"types": "./dist/status-bar-l10n.d.ts",
|
|
51
75
|
"default": "./dist/status-bar-l10n.js"
|
|
52
76
|
},
|
|
53
|
-
"./element-capture": {
|
|
54
|
-
"types": "./dist/element-capture.d.ts",
|
|
55
|
-
"default": "./dist/element-capture.js"
|
|
56
|
-
},
|
|
57
|
-
"./prompts": {
|
|
58
|
-
"types": "./dist/prompts.d.ts",
|
|
59
|
-
"default": "./dist/prompts.js"
|
|
60
|
-
},
|
|
61
77
|
"./session-profile": {
|
|
62
78
|
"types": "./dist/session-profile.d.ts",
|
|
63
79
|
"default": "./dist/session-profile.js"
|
|
64
80
|
},
|
|
65
|
-
"./tools": {
|
|
66
|
-
"types": "./dist/tools.d.ts",
|
|
67
|
-
"default": "./dist/tools.js"
|
|
68
|
-
},
|
|
69
81
|
"./security": {
|
|
70
82
|
"types": "./dist/security.d.ts",
|
|
71
83
|
"default": "./dist/security.js"
|
|
72
84
|
},
|
|
73
|
-
"./video-agent": {
|
|
74
|
-
"types": "./dist/video-agent.d.ts",
|
|
75
|
-
"default": "./dist/video-agent.js"
|
|
76
|
-
},
|
|
77
|
-
"./video-planner": {
|
|
78
|
-
"types": "./dist/video-planner.d.ts",
|
|
79
|
-
"default": "./dist/video-planner.js"
|
|
80
|
-
},
|
|
81
85
|
"./mouse-animation": {
|
|
82
86
|
"types": "./dist/mouse-animation.d.ts",
|
|
83
87
|
"default": "./dist/mouse-animation.js"
|
|
84
88
|
},
|
|
85
|
-
"./clip-orchestrator": {
|
|
86
|
-
"types": "./dist/clip-orchestrator.d.ts",
|
|
87
|
-
"default": "./dist/clip-orchestrator.js"
|
|
88
|
-
},
|
|
89
89
|
"./clip-postprocess": {
|
|
90
90
|
"types": "./dist/clip-postprocess.d.ts",
|
|
91
91
|
"default": "./dist/clip-postprocess.js"
|
|
92
92
|
},
|
|
93
|
-
"./
|
|
94
|
-
"types": "./dist/
|
|
95
|
-
"default": "./dist/
|
|
93
|
+
"./capture-alt-text": {
|
|
94
|
+
"types": "./dist/capture-alt-text.d.ts",
|
|
95
|
+
"default": "./dist/capture-alt-text.js"
|
|
96
|
+
},
|
|
97
|
+
"./version": {
|
|
98
|
+
"types": "./dist/version.d.ts",
|
|
99
|
+
"default": "./dist/version.js"
|
|
100
|
+
},
|
|
101
|
+
"./capture-encryption": {
|
|
102
|
+
"types": "./dist/capture-encryption.d.ts",
|
|
103
|
+
"default": "./dist/capture-encryption.js"
|
|
104
|
+
},
|
|
105
|
+
"./capture-model-resolution": {
|
|
106
|
+
"types": "./dist/capture-model-resolution.d.ts",
|
|
107
|
+
"default": "./dist/capture-model-resolution.js"
|
|
108
|
+
},
|
|
109
|
+
"./capture-preset-credentials": {
|
|
110
|
+
"types": "./dist/capture-preset-credentials.d.ts",
|
|
111
|
+
"default": "./dist/capture-preset-credentials.js"
|
|
112
|
+
},
|
|
113
|
+
"./capture-selector-memory": {
|
|
114
|
+
"types": "./dist/capture-selector-memory.d.ts",
|
|
115
|
+
"default": "./dist/capture-selector-memory.js"
|
|
116
|
+
},
|
|
117
|
+
"./capture-session-profile-encryption": {
|
|
118
|
+
"types": "./dist/capture-session-profile-encryption.d.ts",
|
|
119
|
+
"default": "./dist/capture-session-profile-encryption.js"
|
|
120
|
+
},
|
|
121
|
+
"./capture-run-optimizer": {
|
|
122
|
+
"types": "./dist/capture-run-optimizer.d.ts",
|
|
123
|
+
"default": "./dist/capture-run-optimizer.js"
|
|
124
|
+
},
|
|
125
|
+
"./capture-request-plan": {
|
|
126
|
+
"types": "./dist/capture-request-plan.d.ts",
|
|
127
|
+
"default": "./dist/capture-request-plan.js"
|
|
128
|
+
},
|
|
129
|
+
"./capture-viewport-lock": {
|
|
130
|
+
"types": "./dist/capture-viewport-lock.d.ts",
|
|
131
|
+
"default": "./dist/capture-viewport-lock.js"
|
|
132
|
+
},
|
|
133
|
+
"./capture-page-identity": {
|
|
134
|
+
"types": "./dist/capture-page-identity.d.ts",
|
|
135
|
+
"default": "./dist/capture-page-identity.js"
|
|
136
|
+
},
|
|
137
|
+
"./capture-transition-engine": {
|
|
138
|
+
"types": "./dist/capture-transition-engine.d.ts",
|
|
139
|
+
"default": "./dist/capture-transition-engine.js"
|
|
140
|
+
},
|
|
141
|
+
"./capture-variant-state": {
|
|
142
|
+
"types": "./dist/capture-variant-state.d.ts",
|
|
143
|
+
"default": "./dist/capture-variant-state.js"
|
|
144
|
+
},
|
|
145
|
+
"./capture-llm-page-identity": {
|
|
146
|
+
"types": "./dist/capture-llm-page-identity.d.ts",
|
|
147
|
+
"default": "./dist/capture-llm-page-identity.js"
|
|
148
|
+
},
|
|
149
|
+
"./capture-step-timeout": {
|
|
150
|
+
"types": "./dist/capture-step-timeout.d.ts",
|
|
151
|
+
"default": "./dist/capture-step-timeout.js"
|
|
152
|
+
},
|
|
153
|
+
"./capture-language-preflight": {
|
|
154
|
+
"types": "./dist/capture-language-preflight.d.ts",
|
|
155
|
+
"default": "./dist/capture-language-preflight.js"
|
|
156
|
+
},
|
|
157
|
+
"./cost-logging": {
|
|
158
|
+
"types": "./dist/cost-logging.d.ts",
|
|
159
|
+
"default": "./dist/cost-logging.js"
|
|
160
|
+
},
|
|
161
|
+
"./billing-operation-logging": {
|
|
162
|
+
"types": "./dist/billing-operation-logging.d.ts",
|
|
163
|
+
"default": "./dist/billing-operation-logging.js"
|
|
164
|
+
},
|
|
165
|
+
"./server-credit-usage": {
|
|
166
|
+
"types": "./dist/server-credit-usage.d.ts",
|
|
167
|
+
"default": "./dist/server-credit-usage.js"
|
|
168
|
+
},
|
|
169
|
+
"./server-posthog": {
|
|
170
|
+
"types": "./dist/server-posthog.d.ts",
|
|
171
|
+
"default": "./dist/server-posthog.js"
|
|
172
|
+
},
|
|
173
|
+
"./server-screenshot-watermark": {
|
|
174
|
+
"types": "./dist/server-screenshot-watermark.d.ts",
|
|
175
|
+
"default": "./dist/server-screenshot-watermark.js"
|
|
176
|
+
},
|
|
177
|
+
"./capture-studio-sync": {
|
|
178
|
+
"types": "./dist/capture-studio-sync.d.ts",
|
|
179
|
+
"default": "./dist/capture-studio-sync.js"
|
|
180
|
+
},
|
|
181
|
+
"./cli-contract": {
|
|
182
|
+
"types": "./dist/cli-contract.d.ts",
|
|
183
|
+
"default": "./dist/cli-contract.js"
|
|
184
|
+
},
|
|
185
|
+
"./provider-config": {
|
|
186
|
+
"types": "./dist/provider-config.d.ts",
|
|
187
|
+
"default": "./dist/provider-config.js"
|
|
96
188
|
}
|
|
97
189
|
},
|
|
98
190
|
"bin": {
|
|
99
|
-
"autokap": "
|
|
191
|
+
"autokap": "dist/cli.js"
|
|
100
192
|
},
|
|
101
193
|
"scripts": {
|
|
102
|
-
"
|
|
103
|
-
"dev": "cd web && npm run dev",
|
|
104
|
-
"dev:lib:watch": "tsc -w --preserveWatchOutput",
|
|
105
|
-
"start": "cd web && npm run start",
|
|
106
|
-
"rebuild": "tsc && cd web && npx tsc --noEmit",
|
|
107
|
-
"typecheck": "tsc --noEmit",
|
|
108
|
-
"test": "vitest run",
|
|
109
|
-
"test:watch": "vitest",
|
|
110
|
-
"test:billing-limits": "node --test --import tsx scripts/billing-plan-limits.test.ts",
|
|
111
|
-
"deploy": "bash deploy.sh",
|
|
112
|
-
"sync-env": "bash scripts/sync-env.sh",
|
|
113
|
-
"screenshot:benchmark": "tsx scripts/screenshot-benchmark.ts",
|
|
114
|
-
"video:smoke": "tsx scripts/video-smoke-test.ts",
|
|
115
|
-
"video:regression": "tsx scripts/video-regression.ts"
|
|
194
|
+
"postinstall": "node -e \"try{require('child_process').execSync('npx playwright install chromium',{stdio:'inherit'})}catch(e){console.warn('AutoKap: Playwright Chromium install failed. Run `npx playwright install chromium` manually.',e.message||'')}\""
|
|
116
195
|
},
|
|
117
196
|
"engines": {
|
|
118
197
|
"node": ">=20"
|
|
119
198
|
},
|
|
120
199
|
"files": [
|
|
121
|
-
"dist
|
|
122
|
-
"dist
|
|
123
|
-
"dist
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
130
|
-
"
|
|
131
|
-
"
|
|
132
|
-
"dist/cookie-dismiss.d.ts",
|
|
133
|
-
"dist/logger.js",
|
|
134
|
-
"dist/logger.d.ts",
|
|
135
|
-
"dist/types.js",
|
|
136
|
-
"dist/types.d.ts",
|
|
200
|
+
"dist/**/*.js",
|
|
201
|
+
"dist/**/*.d.ts",
|
|
202
|
+
"!dist/**/*.js.map",
|
|
203
|
+
"assets/chrome",
|
|
204
|
+
"assets/devices",
|
|
205
|
+
"assets/frames/iPad*",
|
|
206
|
+
"assets/frames/iPhone*",
|
|
207
|
+
"assets/frames/MacBook*",
|
|
208
|
+
"assets/frames/Status*",
|
|
209
|
+
"assets/icons",
|
|
210
|
+
"assets/cursors",
|
|
137
211
|
"assets/skill"
|
|
138
212
|
],
|
|
139
213
|
"keywords": [
|
|
@@ -148,21 +222,18 @@
|
|
|
148
222
|
],
|
|
149
223
|
"author": "AutoKap",
|
|
150
224
|
"license": "ISC",
|
|
151
|
-
"homepage": "https://autokap.
|
|
225
|
+
"homepage": "https://app.autokap.com",
|
|
152
226
|
"dependencies": {
|
|
153
227
|
"chalk": "^5.6.2",
|
|
154
228
|
"commander": "^14.0.3",
|
|
229
|
+
"dotenv": "^17.3.1",
|
|
230
|
+
"openai": "^6.25.0",
|
|
155
231
|
"playwright": "^1.58.2",
|
|
156
|
-
"
|
|
157
|
-
"
|
|
232
|
+
"posthog-node": "^5.26.2",
|
|
233
|
+
"sharp": "^0.34.5"
|
|
158
234
|
},
|
|
159
235
|
"devDependencies": {
|
|
160
|
-
"@supabase/supabase-js": "^2.100.1",
|
|
161
236
|
"@types/node": "^25.3.3",
|
|
162
|
-
"@types/ws": "^8.18.1",
|
|
163
|
-
"dotenv": "^17.3.1",
|
|
164
|
-
"openai": "^6.25.0",
|
|
165
|
-
"posthog-node": "^5.26.2",
|
|
166
237
|
"tsx": "^4.21.0",
|
|
167
238
|
"typescript": "^5.9.3",
|
|
168
239
|
"vitest": "^4.0.18"
|