autokap 1.0.7 → 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/cursors/macos.svg +4 -0
- package/assets/cursors/windows.svg +15 -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/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 +92 -8
- package/dist/agent.js +2936 -781
- 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/browser-bar.d.ts +14 -6
- package/dist/browser-bar.js +145 -8
- 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 +51 -1
- package/dist/browser.js +1481 -31
- package/dist/capture-alt-text.js +2 -1
- package/dist/capture-language-preflight.js +14 -0
- package/dist/capture-llm-page-identity.js +22 -10
- package/dist/capture-page-identity.d.ts +5 -7
- package/dist/capture-page-identity.js +211 -78
- package/dist/capture-preset-credentials.d.ts +50 -0
- package/dist/capture-preset-credentials.js +127 -0
- package/dist/capture-request-plan.d.ts +2 -2
- package/dist/capture-request-plan.js +64 -16
- package/dist/capture-run-optimizer.js +48 -33
- package/dist/capture-selector-memory.d.ts +5 -0
- package/dist/capture-selector-memory.js +18 -0
- package/dist/capture-strategy.d.ts +36 -0
- package/dist/capture-strategy.js +95 -0
- package/dist/capture-studio-sync.d.ts +1 -0
- package/dist/capture-studio-sync.js +9 -3
- 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 +2 -0
- package/dist/capture-variant-state.js +26 -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 -267
- package/dist/clip-orchestrator.js +9 -2
- package/dist/clip-postprocess.js +25 -16
- package/dist/cookie-dismiss.d.ts +2 -0
- package/dist/cookie-dismiss.js +48 -13
- package/dist/cost-logging.d.ts +8 -0
- package/dist/cost-logging.js +160 -46
- package/dist/cost-resolution-monitor.d.ts +16 -0
- package/dist/cost-resolution-monitor.js +34 -0
- package/dist/credential-templates.js +2 -2
- 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 +1 -41
- package/dist/element-capture.js +202 -446
- 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.js +12 -12
- package/dist/index.d.ts +9 -6
- package/dist/index.js +10 -4
- 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/logger.d.ts +6 -2
- package/dist/logger.js +15 -1
- package/dist/mockup-html.js +35 -25
- package/dist/mockup.d.ts +95 -2
- package/dist/mockup.js +427 -166
- package/dist/mouse-animation.d.ts +2 -2
- package/dist/mouse-animation.js +34 -20
- 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/postcondition.d.ts +16 -0
- package/dist/postcondition.js +269 -0
- package/dist/program-patcher.d.ts +25 -0
- package/dist/program-patcher.js +44 -0
- package/dist/prompts.d.ts +13 -5
- package/dist/prompts.js +224 -351
- 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 +28 -4
- package/dist/remote-browser.js +60 -5
- 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 +2 -1
- package/dist/security.js +49 -10
- 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 +5 -3
- package/dist/server-capture-runtime.js +42 -95
- package/dist/server-credit-usage.d.ts +2 -2
- package/dist/server-project-webhooks.d.ts +15 -1
- package/dist/server-project-webhooks.js +34 -8
- package/dist/server-screenshot-watermark.js +27 -5
- package/dist/session-profile.js +164 -1
- 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-render.d.ts +20 -0
- package/dist/status-bar-render.js +410 -0
- package/dist/status-bar.d.ts +9 -0
- package/dist/status-bar.js +298 -14
- 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.js +89 -451
- 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.js +18 -13
- package/dist/video-planner.js +2 -1
- package/dist/video-prompts.js +3 -3
- package/dist/web-playwright-local.d.ts +126 -0
- package/dist/web-playwright-local.js +819 -0
- package/dist/ws-auth.js +4 -1
- 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.js +294 -164
- package/dist/ws-metrics-server.d.ts +9 -0
- package/dist/ws-metrics-server.js +31 -0
- package/dist/ws-server.js +41 -1
- package/package.json +51 -34
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — Benchmark Harness
|
|
3
|
+
*
|
|
4
|
+
* Runs the same preset repeatedly, comparing:
|
|
5
|
+
* - Total LLM cost
|
|
6
|
+
* - Total wall-clock time
|
|
7
|
+
* - Success rate
|
|
8
|
+
* - Recovery rate (how often healing was needed)
|
|
9
|
+
*
|
|
10
|
+
* Useful for tracking determinism, recovery rate, and runtime cost over time.
|
|
11
|
+
*/
|
|
12
|
+
import type { ExecutionProgram, RunResult } from './execution-types.js';
|
|
13
|
+
export interface BenchmarkPreset {
|
|
14
|
+
name: string;
|
|
15
|
+
presetId: string;
|
|
16
|
+
program: ExecutionProgram;
|
|
17
|
+
/** Expected behavior description for manual verification */
|
|
18
|
+
expectedBehavior: string;
|
|
19
|
+
/** Difficulty tier */
|
|
20
|
+
tier: 'simple' | 'multi_step' | 'auth_required' | 'clip' | 'video';
|
|
21
|
+
}
|
|
22
|
+
export interface BenchmarkRunResult {
|
|
23
|
+
presetName: string;
|
|
24
|
+
tier: string;
|
|
25
|
+
success: boolean;
|
|
26
|
+
totalDurationMs: number;
|
|
27
|
+
llmCostEur: number;
|
|
28
|
+
llmCallCount: number;
|
|
29
|
+
totalOpcodes: number;
|
|
30
|
+
recoveredOpcodes: number;
|
|
31
|
+
failedOpcodes: number;
|
|
32
|
+
healerInvocations: number;
|
|
33
|
+
circuitBreakerTrips: number;
|
|
34
|
+
variantCount: number;
|
|
35
|
+
successfulVariants: number;
|
|
36
|
+
error?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface BenchmarkSummary {
|
|
39
|
+
totalPresets: number;
|
|
40
|
+
successCount: number;
|
|
41
|
+
failCount: number;
|
|
42
|
+
successRate: number;
|
|
43
|
+
averageDurationMs: number;
|
|
44
|
+
averageLlmCostEur: number;
|
|
45
|
+
totalLlmCostEur: number;
|
|
46
|
+
deterministicRate: number;
|
|
47
|
+
recoveryRate: number;
|
|
48
|
+
results: BenchmarkRunResult[];
|
|
49
|
+
byTier: Record<string, {
|
|
50
|
+
total: number;
|
|
51
|
+
success: number;
|
|
52
|
+
rate: number;
|
|
53
|
+
}>;
|
|
54
|
+
}
|
|
55
|
+
export type RunFn = (program: ExecutionProgram) => Promise<RunResult>;
|
|
56
|
+
export declare function runBenchmark(presets: BenchmarkPreset[], runCapture: RunFn, options?: {
|
|
57
|
+
runs?: number;
|
|
58
|
+
}): Promise<BenchmarkSummary>;
|
|
59
|
+
export declare function formatBenchmarkSummary(summary: BenchmarkSummary): string;
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — Benchmark Harness
|
|
3
|
+
*
|
|
4
|
+
* Runs the same preset repeatedly, comparing:
|
|
5
|
+
* - Total LLM cost
|
|
6
|
+
* - Total wall-clock time
|
|
7
|
+
* - Success rate
|
|
8
|
+
* - Recovery rate (how often healing was needed)
|
|
9
|
+
*
|
|
10
|
+
* Useful for tracking determinism, recovery rate, and runtime cost over time.
|
|
11
|
+
*/
|
|
12
|
+
import { logger } from './logger.js';
|
|
13
|
+
export async function runBenchmark(presets, runCapture, options) {
|
|
14
|
+
const runsPerPreset = options?.runs ?? 1;
|
|
15
|
+
const results = [];
|
|
16
|
+
for (const preset of presets) {
|
|
17
|
+
logger.info(`[Benchmark] Running "${preset.name}" (${preset.tier}) — ${runsPerPreset} run(s)`);
|
|
18
|
+
for (let run = 0; run < runsPerPreset; run++) {
|
|
19
|
+
try {
|
|
20
|
+
const runResult = await runCapture(preset.program);
|
|
21
|
+
results.push({
|
|
22
|
+
presetName: preset.name,
|
|
23
|
+
tier: preset.tier,
|
|
24
|
+
success: runResult.success,
|
|
25
|
+
totalDurationMs: runResult.totalDurationMs,
|
|
26
|
+
llmCostEur: runResult.telemetry.llmCostEur,
|
|
27
|
+
llmCallCount: runResult.telemetry.llmCallCount,
|
|
28
|
+
totalOpcodes: runResult.telemetry.totalOpcodes,
|
|
29
|
+
recoveredOpcodes: runResult.telemetry.recoveredOpcodes,
|
|
30
|
+
failedOpcodes: runResult.telemetry.failedOpcodes,
|
|
31
|
+
healerInvocations: runResult.telemetry.healerInvocations,
|
|
32
|
+
circuitBreakerTrips: runResult.telemetry.circuitBreakerTrips,
|
|
33
|
+
variantCount: runResult.variantResults.length,
|
|
34
|
+
successfulVariants: runResult.variantResults.filter(v => v.success).length,
|
|
35
|
+
error: runResult.error,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
results.push({
|
|
40
|
+
presetName: preset.name,
|
|
41
|
+
tier: preset.tier,
|
|
42
|
+
success: false,
|
|
43
|
+
totalDurationMs: 0,
|
|
44
|
+
llmCostEur: 0,
|
|
45
|
+
llmCallCount: 0,
|
|
46
|
+
totalOpcodes: 0,
|
|
47
|
+
recoveredOpcodes: 0,
|
|
48
|
+
failedOpcodes: 0,
|
|
49
|
+
healerInvocations: 0,
|
|
50
|
+
circuitBreakerTrips: 0,
|
|
51
|
+
variantCount: 0,
|
|
52
|
+
successfulVariants: 0,
|
|
53
|
+
error: err instanceof Error ? err.message : String(err),
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return computeSummary(results);
|
|
59
|
+
}
|
|
60
|
+
// ── Summary computation ─────────────────────────────────────────────
|
|
61
|
+
function computeSummary(results) {
|
|
62
|
+
const total = results.length;
|
|
63
|
+
const successCount = results.filter(r => r.success).length;
|
|
64
|
+
const failCount = total - successCount;
|
|
65
|
+
const totalDuration = results.reduce((sum, r) => sum + r.totalDurationMs, 0);
|
|
66
|
+
const totalLlmCost = results.reduce((sum, r) => sum + r.llmCostEur, 0);
|
|
67
|
+
const totalOpcodes = results.reduce((sum, r) => sum + r.totalOpcodes, 0);
|
|
68
|
+
const totalRecovered = results.reduce((sum, r) => sum + r.recoveredOpcodes, 0);
|
|
69
|
+
const deterministicRuns = results.filter(r => r.llmCallCount === 0 && r.success).length;
|
|
70
|
+
// By tier
|
|
71
|
+
const byTier = {};
|
|
72
|
+
for (const result of results) {
|
|
73
|
+
if (!byTier[result.tier])
|
|
74
|
+
byTier[result.tier] = { total: 0, success: 0, rate: 0 };
|
|
75
|
+
byTier[result.tier].total++;
|
|
76
|
+
if (result.success)
|
|
77
|
+
byTier[result.tier].success++;
|
|
78
|
+
}
|
|
79
|
+
for (const tier of Object.values(byTier)) {
|
|
80
|
+
tier.rate = tier.total > 0 ? tier.success / tier.total : 0;
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
totalPresets: total,
|
|
84
|
+
successCount,
|
|
85
|
+
failCount,
|
|
86
|
+
successRate: total > 0 ? successCount / total : 0,
|
|
87
|
+
averageDurationMs: total > 0 ? totalDuration / total : 0,
|
|
88
|
+
averageLlmCostEur: total > 0 ? totalLlmCost / total : 0,
|
|
89
|
+
totalLlmCostEur: totalLlmCost,
|
|
90
|
+
deterministicRate: total > 0 ? deterministicRuns / total : 0,
|
|
91
|
+
recoveryRate: totalOpcodes > 0 ? totalRecovered / totalOpcodes : 0,
|
|
92
|
+
results,
|
|
93
|
+
byTier,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
// ── Pretty printer ──────────────────────────────────────────────────
|
|
97
|
+
export function formatBenchmarkSummary(summary) {
|
|
98
|
+
const lines = [];
|
|
99
|
+
lines.push('═══════════════════════════════════════════════════');
|
|
100
|
+
lines.push(' Capture Benchmark Summary');
|
|
101
|
+
lines.push('═══════════════════════════════════════════════════');
|
|
102
|
+
lines.push(` Total presets: ${summary.totalPresets}`);
|
|
103
|
+
lines.push(` Success: ${summary.successCount}/${summary.totalPresets} (${(summary.successRate * 100).toFixed(1)}%)`);
|
|
104
|
+
lines.push(` Deterministic rate: ${(summary.deterministicRate * 100).toFixed(1)}% (no LLM needed)`);
|
|
105
|
+
lines.push(` Recovery rate: ${(summary.recoveryRate * 100).toFixed(1)}% of opcodes`);
|
|
106
|
+
lines.push(` Avg duration: ${(summary.averageDurationMs / 1000).toFixed(1)}s`);
|
|
107
|
+
lines.push(` Avg LLM cost: ${summary.averageLlmCostEur.toFixed(4)} EUR`);
|
|
108
|
+
lines.push(` Total LLM cost: ${summary.totalLlmCostEur.toFixed(4)} EUR`);
|
|
109
|
+
lines.push('───────────────────────────────────────────────────');
|
|
110
|
+
for (const [tier, stats] of Object.entries(summary.byTier)) {
|
|
111
|
+
lines.push(` ${tier.padEnd(18)} ${stats.success}/${stats.total} (${(stats.rate * 100).toFixed(0)}%)`);
|
|
112
|
+
}
|
|
113
|
+
lines.push('───────────────────────────────────────────────────');
|
|
114
|
+
for (const result of summary.results) {
|
|
115
|
+
const status = result.success ? 'OK' : 'FAIL';
|
|
116
|
+
const duration = `${(result.totalDurationMs / 1000).toFixed(1)}s`;
|
|
117
|
+
const cost = result.llmCostEur > 0 ? `${result.llmCostEur.toFixed(4)}EUR` : 'free';
|
|
118
|
+
lines.push(` [${status}] ${result.presetName.padEnd(30)} ${duration.padStart(6)} ${cost.padStart(10)}${result.error ? ` — ${result.error.slice(0, 50)}` : ''}`);
|
|
119
|
+
}
|
|
120
|
+
lines.push('═══════════════════════════════════════════════════');
|
|
121
|
+
// Health check
|
|
122
|
+
const simpleStats = summary.byTier['simple'];
|
|
123
|
+
const multiStats = summary.byTier['multi_step'];
|
|
124
|
+
const simpleOk = !simpleStats || simpleStats.rate >= 0.95;
|
|
125
|
+
const multiOk = !multiStats || multiStats.rate >= 0.80;
|
|
126
|
+
const costOk = summary.averageLlmCostEur < 0.05;
|
|
127
|
+
lines.push('');
|
|
128
|
+
lines.push(' Health Checklist:');
|
|
129
|
+
lines.push(` ${simpleOk ? '[x]' : '[ ]'} Simple scenarios > 95% (${simpleStats ? (simpleStats.rate * 100).toFixed(0) : 'N/A'}%)`);
|
|
130
|
+
lines.push(` ${multiOk ? '[x]' : '[ ]'} Multi-step > 80% (${multiStats ? (multiStats.rate * 100).toFixed(0) : 'N/A'}%)`);
|
|
131
|
+
lines.push(` ${costOk ? '[x]' : '[ ]'} Avg cost < 0.05 EUR (${summary.averageLlmCostEur.toFixed(4)} EUR)`);
|
|
132
|
+
lines.push('');
|
|
133
|
+
return lines.join('\n');
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=benchmark.js.map
|
package/dist/browser-bar.d.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser bar — dispatches between coded browser chrome styles (Chrome, Safari, …).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and address bar width are computed from the target width.
|
|
4
|
+
* Chrome: pixel-perfect from toolbar4.svg (ref 2160×129, two-row layout).
|
|
5
|
+
* Safari: ref 1500×52, single-row toolbar with SF Pro Symbols icons.
|
|
7
6
|
*
|
|
8
7
|
* Dynamic content (page title, URL, favicon) overlaid as HTML.
|
|
9
8
|
* SF Pro embedded fonts for cross-OS rendering.
|
|
10
|
-
*
|
|
11
|
-
* Reference: 2160×129 @ 1.5× (toolbar4.svg)
|
|
12
9
|
*/
|
|
10
|
+
export type BrowserBarStyle = 'chrome' | 'safari';
|
|
13
11
|
export interface BrowserBarConfig {
|
|
14
12
|
url?: string;
|
|
15
13
|
pageTitle?: string;
|
|
16
14
|
tabIconUrl?: string;
|
|
17
15
|
colorScheme?: 'light' | 'dark';
|
|
16
|
+
/** Which coded browser chrome to draw. Defaults to 'chrome' when unset. */
|
|
17
|
+
style?: BrowserBarStyle;
|
|
18
18
|
}
|
|
19
19
|
export interface BrowserBarZoneRect {
|
|
20
20
|
x: number;
|
|
@@ -38,3 +38,11 @@ export interface BrowserBarRenderOptions {
|
|
|
38
38
|
pixelScale?: number;
|
|
39
39
|
}
|
|
40
40
|
export declare function generateBrowserBarHtml(options: BrowserBarRenderOptions): string;
|
|
41
|
+
export declare function generateBrowserBarSvg(options: BrowserBarRenderOptions): string;
|
|
42
|
+
export declare function generateChromeBrowserBarHtml(options: BrowserBarRenderOptions): string;
|
|
43
|
+
/**
|
|
44
|
+
* Generate a self-contained SVG string for the Chrome browser bar.
|
|
45
|
+
* Used by the sharp compositing pipeline (no Playwright).
|
|
46
|
+
* Returns an SVG at the target width×height with embedded fonts.
|
|
47
|
+
*/
|
|
48
|
+
export declare function generateChromeBrowserBarSvg(options: BrowserBarRenderOptions): string;
|
package/dist/browser-bar.js
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Browser bar — dispatches between coded browser chrome styles (Chrome, Safari, …).
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and address bar width are computed from the target width.
|
|
4
|
+
* Chrome: pixel-perfect from toolbar4.svg (ref 2160×129, two-row layout).
|
|
5
|
+
* Safari: ref 1500×52, single-row toolbar with SF Pro Symbols icons.
|
|
7
6
|
*
|
|
8
7
|
* Dynamic content (page title, URL, favicon) overlaid as HTML.
|
|
9
8
|
* SF Pro embedded fonts for cross-OS rendering.
|
|
10
|
-
*
|
|
11
|
-
* Reference: 2160×129 @ 1.5× (toolbar4.svg)
|
|
12
9
|
*/
|
|
13
10
|
import { SF_PRO_TEXT_REGULAR, SF_PRO_TEXT_SEMIBOLD, } from './sf-pro-fonts.js';
|
|
11
|
+
import { generateSafariBrowserBarHtml, generateSafariBrowserBarSvg, } from './safari-browser-bar.js';
|
|
12
|
+
// ── Dispatcher ───────────────────────────────────────────────────────────
|
|
13
|
+
export function generateBrowserBarHtml(options) {
|
|
14
|
+
return options.config.style === 'safari'
|
|
15
|
+
? generateSafariBrowserBarHtml(options)
|
|
16
|
+
: generateChromeBrowserBarHtml(options);
|
|
17
|
+
}
|
|
18
|
+
export function generateBrowserBarSvg(options) {
|
|
19
|
+
return options.config.style === 'safari'
|
|
20
|
+
? generateSafariBrowserBarSvg(options)
|
|
21
|
+
: generateChromeBrowserBarSvg(options);
|
|
22
|
+
}
|
|
14
23
|
// ── SF Pro ───────────────────────────────────────────────────────────────
|
|
15
24
|
const SF = `<style>
|
|
16
25
|
@font-face{font-family:'SF Pro Text';src:local('SF Pro Text'),local('.SFNSText'),url('${SF_PRO_TEXT_REGULAR}') format('woff2');font-weight:400;font-style:normal}
|
|
@@ -26,8 +35,8 @@ const ADDR_BAR_ML = 174; // address bar left x (was 234 with home icon)
|
|
|
26
35
|
const ADDR_BAR_MR = 126; // address bar right margin (2160-2034)
|
|
27
36
|
const PROFILE_MR = 102; // profile rect x=2058 → margin 102
|
|
28
37
|
const EAR_R_MR = 16.5; // right ear margin
|
|
29
|
-
// ──
|
|
30
|
-
export function
|
|
38
|
+
// ── Chrome generator (HTML) ──────────────────────────────────────────────
|
|
39
|
+
export function generateChromeBrowserBarHtml(options) {
|
|
31
40
|
const { config, width, height, pixelScale = 1 } = options;
|
|
32
41
|
const title = esc(config.pageTitle || 'New Tab');
|
|
33
42
|
const rawUrl = config.url || 'example.com';
|
|
@@ -144,4 +153,132 @@ function esc(s) {
|
|
|
144
153
|
function attr(s) {
|
|
145
154
|
return s.replace(/&/g, '&').replace(/"/g, '"');
|
|
146
155
|
}
|
|
156
|
+
// ── Chrome generator (SVG, for sharp compositing — no Playwright) ──────
|
|
157
|
+
// Produces a self-contained SVG string rasterizable by @resvg/resvg-js.
|
|
158
|
+
/** SF Pro font CSS for embedding inside SVG <defs><style>. No local() — resvg only supports url(). */
|
|
159
|
+
const SVG_BB_FONT_CSS = `
|
|
160
|
+
@font-face{font-family:'SF Pro Text';src:url('${SF_PRO_TEXT_REGULAR}') format('woff2');font-weight:400;font-style:normal}
|
|
161
|
+
@font-face{font-family:'SF Pro Text';src:url('${SF_PRO_TEXT_SEMIBOLD}') format('woff2');font-weight:600;font-style:normal}
|
|
162
|
+
`;
|
|
163
|
+
const SVG_BB_FF = "'SF Pro Text',system-ui,sans-serif";
|
|
164
|
+
/**
|
|
165
|
+
* Generate a self-contained SVG string for the Chrome browser bar.
|
|
166
|
+
* Used by the sharp compositing pipeline (no Playwright).
|
|
167
|
+
* Returns an SVG at the target width×height with embedded fonts.
|
|
168
|
+
*/
|
|
169
|
+
export function generateChromeBrowserBarSvg(options) {
|
|
170
|
+
const { config, width, height } = options;
|
|
171
|
+
const title = esc(config.pageTitle || 'New Tab');
|
|
172
|
+
const rawUrl = config.url || 'example.com';
|
|
173
|
+
const url = esc(rawUrl.replace(/^https?:\/\//, '').replace(/\/$/, ''));
|
|
174
|
+
const icon = config.tabIconUrl;
|
|
175
|
+
const isDark = config.colorScheme === 'dark';
|
|
176
|
+
// Scale: fit reference height into target height
|
|
177
|
+
const s = height / REF_H;
|
|
178
|
+
const iw = Math.round(width / s);
|
|
179
|
+
// Dynamic right-anchored positions
|
|
180
|
+
const dx = iw - REF_W;
|
|
181
|
+
const tabOverflowX = iw - TAB_OVERFLOW_MR;
|
|
182
|
+
const addrBarW = iw - ADDR_BAR_ML - ADDR_BAR_MR;
|
|
183
|
+
const profileX = iw - PROFILE_MR;
|
|
184
|
+
const earRX = iw - EAR_R_MR;
|
|
185
|
+
// Color tokens
|
|
186
|
+
const tabStripBg = isDark ? '#1F2020' : '#DEDEDE';
|
|
187
|
+
const tabBg = isDark ? '#3C3C3C' : '#FFFFFF';
|
|
188
|
+
const toolbarBg = isDark ? '#3C3C3C' : '#FFFFFF';
|
|
189
|
+
const addrBarBg = isDark ? '#282828' : '#F1F1F1';
|
|
190
|
+
const addrIconBg = isDark ? '#3C3C3C' : '#FFFFFF';
|
|
191
|
+
const borderColor = isDark ? '#454746' : '#CFCFCF';
|
|
192
|
+
const textColor = isDark ? '#E3E3E3' : '#1D1D1D';
|
|
193
|
+
const textSec = isDark ? '#C7C7C7' : '#5F6368';
|
|
194
|
+
const iconActive = isDark ? '#C7C7C7' : '#5F6368';
|
|
195
|
+
const iconDis = isDark ? '#7B7B7B' : '#BBBFC4';
|
|
196
|
+
// Tab favicon — inline SVG globe fallback (no <img> in pure SVG)
|
|
197
|
+
const tabFavicon = icon
|
|
198
|
+
? `<image href="${attr(icon)}" x="153.5" y="19.5" width="21" height="21" preserveAspectRatio="xMidYMid meet"/>`
|
|
199
|
+
: `<g transform="translate(152,18)"><svg width="24" height="24" viewBox="0 0 16 16" fill="none"><circle cx="8" cy="8" r="6.5" stroke="${iconActive}" stroke-width="1.2"/><ellipse cx="8" cy="8" rx="3" ry="6.5" stroke="${iconActive}" stroke-width="1.2"/><line x1="1.5" y1="8" x2="14.5" y2="8" stroke="${iconActive}" stroke-width="1.2"/></svg></g>`;
|
|
200
|
+
// Page title — clipPath with gradient mask for fade-out
|
|
201
|
+
const titleClipId = 'bb_svg_title_clip';
|
|
202
|
+
const titleMaskId = 'bb_svg_title_mask';
|
|
203
|
+
const titleGradId = 'bb_svg_title_grad';
|
|
204
|
+
const titleX = 187;
|
|
205
|
+
const titleY = 15;
|
|
206
|
+
const titleW = 260;
|
|
207
|
+
const titleH = 30;
|
|
208
|
+
// URL in address bar
|
|
209
|
+
const urlX = ADDR_BAR_ML + 58;
|
|
210
|
+
const urlW = addrBarW - 58 - 18;
|
|
211
|
+
const urlClipId = 'bb_svg_url_clip';
|
|
212
|
+
// Build the full SVG at reference dimensions, then use viewBox to scale.
|
|
213
|
+
// fill="none" is critical — without it, elements that only define stroke
|
|
214
|
+
// (e.g. traffic light border circles) inherit the default fill="black"
|
|
215
|
+
// and hide the colored circles underneath.
|
|
216
|
+
return `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${width}" height="${height}" viewBox="0 0 ${iw} ${REF_H}" fill="none">
|
|
217
|
+
<defs>
|
|
218
|
+
<style>${SVG_BB_FONT_CSS}</style>
|
|
219
|
+
<linearGradient id="bb_profile_grad" x1="${profileX + 15}" y1="109.5" x2="${profileX + 15}" y2="79.5" gradientUnits="userSpaceOnUse">
|
|
220
|
+
<stop stop-color="#D5D8E4"/><stop offset="0.45" stop-color="#D1CAD6"/><stop offset="1" stop-color="#B7BAD1"/>
|
|
221
|
+
</linearGradient>
|
|
222
|
+
<mask id="bb_mask_toolbar" fill="white">
|
|
223
|
+
<path d="M0 76C0 67.1634 7.16344 60 16 60H${iw - 16}C${iw - 7.16} 60 ${iw} 67.1634 ${iw} 76V129H0V76Z"/>
|
|
224
|
+
</mask>
|
|
225
|
+
<clipPath id="bb_clip_toolbar">
|
|
226
|
+
<path d="M0 76C0 67.1634 7.16344 60 16 60H${iw - 16}C${iw - 7.16} 60 ${iw} 67.1634 ${iw} 76V129H0V76Z"/>
|
|
227
|
+
</clipPath>
|
|
228
|
+
<clipPath id="${titleClipId}"><rect x="${titleX}" y="${titleY}" width="${titleW}" height="${titleH}"/></clipPath>
|
|
229
|
+
<linearGradient id="${titleGradId}" x1="${titleX}" y1="0" x2="${titleX + titleW}" y2="0" gradientUnits="userSpaceOnUse">
|
|
230
|
+
<stop offset="0.85" stop-color="white"/><stop offset="1" stop-color="white" stop-opacity="0"/>
|
|
231
|
+
</linearGradient>
|
|
232
|
+
<mask id="${titleMaskId}"><rect x="${titleX}" y="${titleY}" width="${titleW}" height="${titleH}" fill="url(#${titleGradId})"/></mask>
|
|
233
|
+
<clipPath id="${urlClipId}"><rect x="${urlX}" y="69" width="${urlW}" height="51"/></clipPath>
|
|
234
|
+
</defs>
|
|
235
|
+
<!-- TAB STRIP -->
|
|
236
|
+
<g>
|
|
237
|
+
<rect width="${iw}" height="60" fill="${tabStripBg}"/>
|
|
238
|
+
<circle cx="40.5" cy="30.75" r="9" fill="#EC6A5E"/>
|
|
239
|
+
<circle cx="40.5" cy="30.75" r="8.25" stroke="#1F1F1F" stroke-opacity="0.06" stroke-width="1.5"/>
|
|
240
|
+
<circle cx="70.5" cy="30.75" r="9" fill="#F4BF4F"/>
|
|
241
|
+
<circle cx="70.5" cy="30.75" r="8.25" stroke="#1F1F1F" stroke-opacity="0.06" stroke-width="1.5"/>
|
|
242
|
+
<circle cx="100.5" cy="30.75" r="9" fill="#61C554"/>
|
|
243
|
+
<circle cx="100.5" cy="30.75" r="8.25" stroke="#1F1F1F" stroke-opacity="0.06" stroke-width="1.5"/>
|
|
244
|
+
<path d="M120 60C129.941 60 138 51.9411 138 42V60H120Z" fill="${tabBg}"/>
|
|
245
|
+
<path d="M138 24C138 15.7157 144.716 9 153 9H471C479.284 9 486 15.7157 486 24V60H138V24Z" fill="${tabBg}"/>
|
|
246
|
+
<path d="M457.668 35.5689L456.431 34.3314L460.762 30.0001L456.431 25.6689L457.668 24.4314L461.999 28.7626L466.331 24.4314L467.568 25.6689L463.237 30.0001L467.568 34.3314L466.331 35.5689L461.999 31.2376L457.668 35.5689Z" fill="${textColor}"/>
|
|
247
|
+
<path d="M504 60C494.059 60 486 51.9411 486 42V60H504Z" fill="${tabBg}"/>
|
|
248
|
+
<path d="M513.327 31.1749H506.877V28.8249H513.327V22.3499H515.677V28.8249H522.152V31.1749H515.677V37.6249H513.327V31.1749Z" fill="${iconActive}"/>
|
|
249
|
+
<rect x="${tabOverflowX}" y="9" width="42" height="42" rx="15" fill="${tabBg}"/>
|
|
250
|
+
<path d="M${tabOverflowX + 21} 33.95L${tabOverflowX + 14.4} 27.35L${tabOverflowX + 16.07} 25.675L${tabOverflowX + 21} 30.625L${tabOverflowX + 25.92} 25.7L${tabOverflowX + 27.6} 27.375L${tabOverflowX + 21} 33.95Z" fill="${textColor}"/>
|
|
251
|
+
</g>
|
|
252
|
+
<!-- BOTTOM EARS -->
|
|
253
|
+
<path d="M16.5 60C7.3873 60 0 67.3873 0 76.5V60H16.5Z" fill="${tabStripBg}"/>
|
|
254
|
+
<path d="M${earRX} 60C${earRX + 9.11} 60 ${iw} 67.3873 ${iw} 76.5V60H${earRX}Z" fill="${tabStripBg}"/>
|
|
255
|
+
<!-- TOOLBAR -->
|
|
256
|
+
<g clip-path="url(#bb_clip_toolbar)">
|
|
257
|
+
<path d="M0 76C0 67.1634 7.16344 60 16 60H${iw - 16}C${iw - 7.16} 60 ${iw} 67.1634 ${iw} 76V129H0V76Z" fill="${toolbarBg}"/>
|
|
258
|
+
<path d="M28.3125 95.625L34.5938 101.906L33 103.5L24 94.5L33 85.5L34.5938 87.0938L28.3125 93.375H42V95.625H28.3125Z" fill="${iconDis}"/>
|
|
259
|
+
<path d="M91.6875 95.625L85.4062 101.906L87 103.5L96 94.5L87 85.5L85.4062 87.0938L91.6875 93.375H78V95.625H91.6875Z" fill="${iconDis}"/>
|
|
260
|
+
<path d="M141 103.5C138.5 103.5 136.375 102.625 134.625 100.875C132.875 99.125 132 97 132 94.5C132 92 132.875 89.875 134.625 88.125C136.375 86.375 138.5 85.5 141 85.5C142.354 85.5 143.609 85.7812 144.766 86.3438C145.922 86.9062 146.917 87.6562 147.75 88.5938V85.5H150V93H142.5V90.75H146.594C145.99 89.8333 145.198 89.1042 144.219 88.5625C143.24 88.0208 142.167 87.75 141 87.75C139.125 87.75 137.531 88.4062 136.219 89.7188C134.906 91.0312 134.25 92.625 134.25 94.5C134.25 96.375 134.906 97.9688 136.219 99.2812C137.531 100.594 139.125 101.25 141 101.25C142.75 101.25 144.25 100.672 145.5 99.5156C146.75 98.3594 147.469 96.9375 147.656 95.25H149.969C149.781 97.5833 148.833 99.5417 147.125 101.125C145.417 102.708 143.375 103.5 141 103.5Z" fill="${iconActive}"/>
|
|
261
|
+
<rect x="${ADDR_BAR_ML}" y="69" width="${addrBarW}" height="51" rx="25.5" fill="${addrBarBg}"/>
|
|
262
|
+
<rect x="${ADDR_BAR_ML + 7.5}" y="76.5" width="36" height="36" rx="18" fill="${addrIconBg}"/>
|
|
263
|
+
<g transform="translate(${ADDR_BAR_ML + 16.5},${76.5 + 9}) scale(1.5)">
|
|
264
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M9.5 6.70898C10.8806 6.70898 11.9998 7.82848 12 9.20898C12 10.5897 10.8807 11.709 9.5 11.709C8.11929 11.709 7 10.5897 7 9.20898C7.00024 7.82848 8.11944 6.70898 9.5 6.70898ZM9.5 8.20898C8.94786 8.20898 8.50024 8.6569 8.5 9.20898C8.5 9.76127 8.94772 10.209 9.5 10.209C10.0523 10.209 10.5 9.76127 10.5 9.20898C10.4998 8.6569 10.0521 8.20898 9.5 8.20898Z" fill="${iconActive}"/>
|
|
265
|
+
<path d="M6 10H0V8.5H6V10Z" fill="${iconActive}"/>
|
|
266
|
+
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.5 0C3.88071 0 5 1.11929 5 2.5C5 3.88071 3.88071 5 2.5 5C1.11929 5 0 3.88071 0 2.5C0 1.11929 1.11929 0 2.5 0ZM2.5 1.5C1.94772 1.5 1.5 1.94772 1.5 2.5C1.5 3.05228 1.94772 3.5 2.5 3.5C3.05228 3.5 3.5 3.05228 3.5 2.5C3.5 1.94772 3.05228 1.5 2.5 1.5Z" fill="${iconActive}"/>
|
|
267
|
+
<path d="M12 3.20898H6V1.70898H12V3.20898Z" fill="${iconActive}"/>
|
|
268
|
+
</g>
|
|
269
|
+
<path transform="translate(${dx},0)" d="M1994 100.344L1998 97.9688L2002.03 100.344L2000.97 95.8438L2004.44 92.875L1999.84 92.4688L1998 88.1875L1996.16 92.4688L1991.56 92.875L1995.06 95.8438L1994 100.344ZM1990.59 105L1992.56 96.6875L1986 91.0938L1994.62 90.3438L1998 82.5L2001.38 90.375L2010 91.0938L2003.44 96.6875L2005.41 105L1998 100.594L1990.59 105Z" fill="${iconActive}"/>
|
|
270
|
+
<rect x="${profileX}" y="79.5" width="30" height="30" rx="15" fill="url(#bb_profile_grad)"/>
|
|
271
|
+
<rect x="${profileX + 0.75}" y="80.25" width="28.5" height="28.5" rx="14.25" stroke="#1F1F1F" stroke-opacity="0.06" stroke-width="1.5"/>
|
|
272
|
+
<path transform="translate(${dx},0)" d="M2127 105.404C2126.38 105.404 2125.85 105.183 2125.41 104.743C2124.97 104.302 2124.75 103.773 2124.75 103.154C2124.75 102.535 2124.97 102.005 2125.41 101.565C2125.85 101.124 2126.38 100.904 2127 100.904C2127.62 100.904 2128.15 101.124 2128.59 101.565C2129.03 102.005 2129.25 102.535 2129.25 103.154C2129.25 103.773 2129.03 104.302 2128.59 104.743C2128.15 105.183 2127.62 105.404 2127 105.404ZM2127 96.7499C2126.38 96.7499 2125.85 96.5296 2125.41 96.089C2124.97 95.6484 2124.75 95.1187 2124.75 94.5C2124.75 93.8812 2124.97 93.3516 2125.41 92.9109C2125.85 92.4703 2126.38 92.25 2127 92.25C2127.62 92.25 2128.15 92.4703 2128.59 92.9109C2129.03 93.3516 2129.25 93.8812 2129.25 94.5C2129.25 95.1187 2129.03 95.6484 2128.59 96.089C2128.15 96.5296 2127.62 96.7499 2127 96.7499ZM2127 88.0961C2126.38 88.0961 2125.85 87.8758 2125.41 87.4351C2124.97 86.9945 2124.75 86.4649 2124.75 85.8461C2124.75 85.2274 2124.97 84.6977 2125.41 84.2571C2125.85 83.8165 2126.38 83.5962 2127 83.5962C2127.62 83.5962 2128.15 83.8165 2128.59 84.2571C2129.03 84.6977 2129.25 85.2274 2129.25 85.8461C2129.25 86.4649 2129.03 86.9945 2128.59 87.4351C2128.15 87.8758 2127.62 88.0961 2127 88.0961Z" fill="${iconActive}"/>
|
|
273
|
+
</g>
|
|
274
|
+
<!-- TOOLBAR BORDER -->
|
|
275
|
+
<path d="M0 60H${iw}H0M${iw} 130.5H0V127.5H${iw}V130.5ZM${iw} 127.5M0 129V60V129M0 129M${iw} 60V129V60" fill="${borderColor}" mask="url(#bb_mask_toolbar)"/>
|
|
276
|
+
<!-- DYNAMIC TEXT OVERLAYS -->
|
|
277
|
+
${tabFavicon}
|
|
278
|
+
<text mask="url(#${titleMaskId})" x="${titleX}" y="${titleY + titleH / 2 + 1}" font-family="${SVG_BB_FF}" font-size="18" font-weight="400" fill="${textColor}" dominant-baseline="central">${title}</text>
|
|
279
|
+
<g clip-path="url(#${urlClipId})">
|
|
280
|
+
<text x="${urlX}" y="${69 + 51 / 2 + 1}" font-family="${SVG_BB_FF}" font-size="19.5" font-weight="400" fill="${textSec}" dominant-baseline="central">${url}</text>
|
|
281
|
+
</g>
|
|
282
|
+
</svg>`;
|
|
283
|
+
}
|
|
147
284
|
//# sourceMappingURL=browser-bar.js.map
|
package/dist/browser-pool.d.ts
CHANGED
|
@@ -27,6 +27,13 @@ declare class BrowserPool {
|
|
|
27
27
|
releaseContext(context: BrowserContext): Promise<void>;
|
|
28
28
|
private ensureBrowser;
|
|
29
29
|
private launchBrowser;
|
|
30
|
+
/** Read-only snapshot of pool state for monitoring. */
|
|
31
|
+
getStats(): {
|
|
32
|
+
activeContexts: number;
|
|
33
|
+
queueLength: number;
|
|
34
|
+
captureCount: number;
|
|
35
|
+
maxConcurrent: number;
|
|
36
|
+
};
|
|
30
37
|
private restartBrowser;
|
|
31
38
|
}
|
|
32
39
|
/** Shared browser pool for server-side (web API) captures. */
|
package/dist/browser-pool.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { chromium } from 'playwright';
|
|
2
2
|
/** Chromium flags for server-side headless operation (used by pool and standalone launches). */
|
|
3
3
|
export const CHROMIUM_ARGS = [
|
|
4
|
-
//
|
|
5
|
-
'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
// Linux/Docker-only: required when running Chromium as root or with limited /dev/shm
|
|
5
|
+
...(process.platform === 'linux' ? [
|
|
6
|
+
'--no-sandbox',
|
|
7
|
+
'--disable-setuid-sandbox',
|
|
8
|
+
'--disable-dev-shm-usage',
|
|
9
|
+
] : []),
|
|
9
10
|
// No GPU on headless servers
|
|
10
11
|
'--disable-gpu',
|
|
11
12
|
'--disable-gpu-sandbox',
|
|
@@ -107,6 +108,15 @@ class BrowserPool {
|
|
|
107
108
|
this.browser = null;
|
|
108
109
|
});
|
|
109
110
|
}
|
|
111
|
+
/** Read-only snapshot of pool state for monitoring. */
|
|
112
|
+
getStats() {
|
|
113
|
+
return {
|
|
114
|
+
activeContexts: this.activeContexts,
|
|
115
|
+
queueLength: this.queue.length,
|
|
116
|
+
captureCount: this.captureCount,
|
|
117
|
+
maxConcurrent: MAX_CONCURRENT,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
110
120
|
async restartBrowser() {
|
|
111
121
|
const old = this.browser;
|
|
112
122
|
this.browser = null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone utility functions extracted from browser.ts.
|
|
3
|
+
* These have no class dependencies and can be safely imported anywhere.
|
|
4
|
+
*/
|
|
5
|
+
import type { OutscaleConfig } from './types.js';
|
|
6
|
+
export declare function normalizeViewportDimension(value: number): number;
|
|
7
|
+
export declare function normalizeDeviceScaleFactor(value?: number): number;
|
|
8
|
+
export declare function resolveRecordedVideoSize(viewport: {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
}): {
|
|
12
|
+
width: number;
|
|
13
|
+
height: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Map a BCP-47 language tag to a Playwright-compatible locale string.
|
|
17
|
+
*/
|
|
18
|
+
export declare function langToLocale(lang: string): string;
|
|
19
|
+
export declare function escapeCssAttributeValue(value: string): string;
|
|
20
|
+
export declare function escapeCssIdentifier(value: string): string;
|
|
21
|
+
export declare function withHelperTimeout<T>(label: string, timeoutMs: number | undefined, work: () => Promise<T>): Promise<T>;
|
|
22
|
+
export declare function formatUrlForSummary(rawUrl: string): string;
|
|
23
|
+
export declare function resolveEffectivePadding(config: OutscaleConfig, bbox: {
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}): {
|
|
27
|
+
top: number;
|
|
28
|
+
right: number;
|
|
29
|
+
bottom: number;
|
|
30
|
+
left: number;
|
|
31
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Standalone utility functions extracted from browser.ts.
|
|
3
|
+
* These have no class dependencies and can be safely imported anywhere.
|
|
4
|
+
*/
|
|
5
|
+
// -- Viewport & device utilities --
|
|
6
|
+
export function normalizeViewportDimension(value) {
|
|
7
|
+
if (!Number.isFinite(value))
|
|
8
|
+
return 1;
|
|
9
|
+
return Math.max(1, Math.round(value));
|
|
10
|
+
}
|
|
11
|
+
export function normalizeDeviceScaleFactor(value) {
|
|
12
|
+
if (!Number.isFinite(value))
|
|
13
|
+
return 2;
|
|
14
|
+
return Math.max(0.5, Math.min(4, Number(value)));
|
|
15
|
+
}
|
|
16
|
+
export function resolveRecordedVideoSize(viewport) {
|
|
17
|
+
const width = Math.max(2, Math.round(viewport.width)) & ~1;
|
|
18
|
+
const height = Math.max(2, Math.round(viewport.height)) & ~1;
|
|
19
|
+
return { width, height };
|
|
20
|
+
}
|
|
21
|
+
// -- Locale --
|
|
22
|
+
/**
|
|
23
|
+
* Map a BCP-47 language tag to a Playwright-compatible locale string.
|
|
24
|
+
*/
|
|
25
|
+
export function langToLocale(lang) {
|
|
26
|
+
if (!lang)
|
|
27
|
+
return 'en-US';
|
|
28
|
+
if (lang.includes('-') || lang.includes('_'))
|
|
29
|
+
return lang;
|
|
30
|
+
const map = {
|
|
31
|
+
en: 'en-US', fr: 'fr-FR', de: 'de-DE', es: 'es-ES',
|
|
32
|
+
it: 'it-IT', pt: 'pt-PT', nl: 'nl-NL', ja: 'ja-JP',
|
|
33
|
+
zh: 'zh-CN', ko: 'ko-KR', ar: 'ar-SA', ru: 'ru-RU',
|
|
34
|
+
pl: 'pl-PL', sv: 'sv-SE', da: 'da-DK', fi: 'fi-FI',
|
|
35
|
+
no: 'nb-NO', tr: 'tr-TR', cs: 'cs-CZ', hu: 'hu-HU',
|
|
36
|
+
};
|
|
37
|
+
return map[lang] ?? lang;
|
|
38
|
+
}
|
|
39
|
+
// -- CSS utilities --
|
|
40
|
+
export function escapeCssAttributeValue(value) {
|
|
41
|
+
return value
|
|
42
|
+
.replace(/\\/g, '\\\\')
|
|
43
|
+
.replace(/"/g, '\\"');
|
|
44
|
+
}
|
|
45
|
+
export function escapeCssIdentifier(value) {
|
|
46
|
+
return value.replace(/(^-?\d)|[^a-zA-Z0-9_-]/g, (match) => `\\${match}`);
|
|
47
|
+
}
|
|
48
|
+
// -- Timeout utility --
|
|
49
|
+
export async function withHelperTimeout(label, timeoutMs, work) {
|
|
50
|
+
if (!timeoutMs || timeoutMs <= 0) {
|
|
51
|
+
return work();
|
|
52
|
+
}
|
|
53
|
+
let timer = null;
|
|
54
|
+
try {
|
|
55
|
+
return await Promise.race([
|
|
56
|
+
work(),
|
|
57
|
+
new Promise((_, reject) => {
|
|
58
|
+
timer = setTimeout(() => reject(new Error(`${label} timed out after ${timeoutMs}ms`)), timeoutMs);
|
|
59
|
+
}),
|
|
60
|
+
]);
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
if (timer)
|
|
64
|
+
clearTimeout(timer);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// -- URL formatting --
|
|
68
|
+
export function formatUrlForSummary(rawUrl) {
|
|
69
|
+
try {
|
|
70
|
+
const url = new URL(rawUrl);
|
|
71
|
+
return `${url.pathname || '/'}${url.search}${url.hash}` || rawUrl;
|
|
72
|
+
}
|
|
73
|
+
catch {
|
|
74
|
+
return rawUrl;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// -- Padding resolution --
|
|
78
|
+
export function resolveEffectivePadding(config, bbox) {
|
|
79
|
+
let top = 0, right = 0, bottom = 0, left = 0;
|
|
80
|
+
if (config.paddingPercent != null) {
|
|
81
|
+
top = bottom = (config.paddingPercent / 100) * bbox.height;
|
|
82
|
+
left = right = (config.paddingPercent / 100) * bbox.width;
|
|
83
|
+
}
|
|
84
|
+
if (config.padding != null) {
|
|
85
|
+
top = right = bottom = left = config.padding;
|
|
86
|
+
}
|
|
87
|
+
if (config.paddingTop != null)
|
|
88
|
+
top = config.paddingTop;
|
|
89
|
+
if (config.paddingRight != null)
|
|
90
|
+
right = config.paddingRight;
|
|
91
|
+
if (config.paddingBottom != null)
|
|
92
|
+
bottom = config.paddingBottom;
|
|
93
|
+
if (config.paddingLeft != null)
|
|
94
|
+
left = config.paddingLeft;
|
|
95
|
+
return { top, right, bottom, left };
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=browser-utils.js.map
|