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,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — Circuit Breaker
|
|
3
|
+
*
|
|
4
|
+
* Three-level circuit breaker to prevent infinite recovery loops:
|
|
5
|
+
* - Per-opcode: max failures before the opcode is abandoned
|
|
6
|
+
* - Per-page: max failures across all opcodes on the same page
|
|
7
|
+
* - Per-run: max total failures across the entire program
|
|
8
|
+
*/
|
|
9
|
+
import type { CircuitBreakerConfig } from './execution-types.js';
|
|
10
|
+
export type BreakerTrip = 'opcode' | 'page' | 'run';
|
|
11
|
+
export interface BreakerState {
|
|
12
|
+
tripped: boolean;
|
|
13
|
+
level?: BreakerTrip;
|
|
14
|
+
reason: string;
|
|
15
|
+
opcodeFailures: number;
|
|
16
|
+
pageFailures: number;
|
|
17
|
+
runFailures: number;
|
|
18
|
+
}
|
|
19
|
+
export declare class CircuitBreaker {
|
|
20
|
+
private config;
|
|
21
|
+
private opcodeFailures;
|
|
22
|
+
private pageFailures;
|
|
23
|
+
private runFailures;
|
|
24
|
+
private currentPageKey;
|
|
25
|
+
constructor(config?: CircuitBreakerConfig);
|
|
26
|
+
/** Set the current page context (URL-based key) */
|
|
27
|
+
setPage(url: string): void;
|
|
28
|
+
/** Record a failure for an opcode. Returns breaker state. */
|
|
29
|
+
recordFailure(opcodeIndex: number, maxPerOpcode?: number): BreakerState;
|
|
30
|
+
/** Record a success for an opcode (resets opcode-level counter) */
|
|
31
|
+
recordSuccess(opcodeIndex: number): void;
|
|
32
|
+
/** Check if the breaker is currently tripped at any level */
|
|
33
|
+
isTripped(): BreakerState;
|
|
34
|
+
/** Get summary of all failure counts */
|
|
35
|
+
getSummary(): {
|
|
36
|
+
opcodeFailures: Record<number, number>;
|
|
37
|
+
pageFailures: Record<string, number>;
|
|
38
|
+
runFailures: number;
|
|
39
|
+
};
|
|
40
|
+
/** Reset all counters */
|
|
41
|
+
reset(): void;
|
|
42
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — Circuit Breaker
|
|
3
|
+
*
|
|
4
|
+
* Three-level circuit breaker to prevent infinite recovery loops:
|
|
5
|
+
* - Per-opcode: max failures before the opcode is abandoned
|
|
6
|
+
* - Per-page: max failures across all opcodes on the same page
|
|
7
|
+
* - Per-run: max total failures across the entire program
|
|
8
|
+
*/
|
|
9
|
+
import { DEFAULT_CIRCUIT_BREAKER } from './execution-types.js';
|
|
10
|
+
export class CircuitBreaker {
|
|
11
|
+
config;
|
|
12
|
+
opcodeFailures = new Map();
|
|
13
|
+
pageFailures = new Map();
|
|
14
|
+
runFailures = 0;
|
|
15
|
+
currentPageKey = null;
|
|
16
|
+
constructor(config = DEFAULT_CIRCUIT_BREAKER) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
}
|
|
19
|
+
/** Set the current page context (URL-based key) */
|
|
20
|
+
setPage(url) {
|
|
21
|
+
this.currentPageKey = new URL(url).pathname;
|
|
22
|
+
}
|
|
23
|
+
/** Record a failure for an opcode. Returns breaker state. */
|
|
24
|
+
recordFailure(opcodeIndex, maxPerOpcode = this.config.maxPerOpcode) {
|
|
25
|
+
// Opcode level
|
|
26
|
+
const opcodeFails = (this.opcodeFailures.get(opcodeIndex) ?? 0) + 1;
|
|
27
|
+
this.opcodeFailures.set(opcodeIndex, opcodeFails);
|
|
28
|
+
// Page level
|
|
29
|
+
const pageKey = this.currentPageKey ?? 'unknown';
|
|
30
|
+
const pageFails = (this.pageFailures.get(pageKey) ?? 0) + 1;
|
|
31
|
+
this.pageFailures.set(pageKey, pageFails);
|
|
32
|
+
// Run level
|
|
33
|
+
this.runFailures++;
|
|
34
|
+
// Check breakers from most specific to least
|
|
35
|
+
if (opcodeFails >= maxPerOpcode) {
|
|
36
|
+
return {
|
|
37
|
+
tripped: true,
|
|
38
|
+
level: 'opcode',
|
|
39
|
+
reason: `opcode ${opcodeIndex} reached ${opcodeFails}/${maxPerOpcode} failures`,
|
|
40
|
+
opcodeFailures: opcodeFails,
|
|
41
|
+
pageFailures: pageFails,
|
|
42
|
+
runFailures: this.runFailures,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (pageFails >= this.config.maxPerPage) {
|
|
46
|
+
return {
|
|
47
|
+
tripped: true,
|
|
48
|
+
level: 'page',
|
|
49
|
+
reason: `page "${pageKey}" reached ${pageFails}/${this.config.maxPerPage} failures`,
|
|
50
|
+
opcodeFailures: opcodeFails,
|
|
51
|
+
pageFailures: pageFails,
|
|
52
|
+
runFailures: this.runFailures,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
if (this.runFailures >= this.config.maxPerRun) {
|
|
56
|
+
return {
|
|
57
|
+
tripped: true,
|
|
58
|
+
level: 'run',
|
|
59
|
+
reason: `run reached ${this.runFailures}/${this.config.maxPerRun} total failures`,
|
|
60
|
+
opcodeFailures: opcodeFails,
|
|
61
|
+
pageFailures: pageFails,
|
|
62
|
+
runFailures: this.runFailures,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
tripped: false,
|
|
67
|
+
reason: `opcode ${opcodeIndex}: ${opcodeFails}/${maxPerOpcode}, page: ${pageFails}/${this.config.maxPerPage}, run: ${this.runFailures}/${this.config.maxPerRun}`,
|
|
68
|
+
opcodeFailures: opcodeFails,
|
|
69
|
+
pageFailures: pageFails,
|
|
70
|
+
runFailures: this.runFailures,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
/** Record a success for an opcode (resets opcode-level counter) */
|
|
74
|
+
recordSuccess(opcodeIndex) {
|
|
75
|
+
this.opcodeFailures.delete(opcodeIndex);
|
|
76
|
+
}
|
|
77
|
+
/** Check if the breaker is currently tripped at any level */
|
|
78
|
+
isTripped() {
|
|
79
|
+
if (this.runFailures >= this.config.maxPerRun) {
|
|
80
|
+
return {
|
|
81
|
+
tripped: true,
|
|
82
|
+
level: 'run',
|
|
83
|
+
reason: `run limit reached: ${this.runFailures}/${this.config.maxPerRun}`,
|
|
84
|
+
opcodeFailures: 0,
|
|
85
|
+
pageFailures: 0,
|
|
86
|
+
runFailures: this.runFailures,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const pageKey = this.currentPageKey ?? 'unknown';
|
|
90
|
+
const pageFails = this.pageFailures.get(pageKey) ?? 0;
|
|
91
|
+
if (pageFails >= this.config.maxPerPage) {
|
|
92
|
+
return {
|
|
93
|
+
tripped: true,
|
|
94
|
+
level: 'page',
|
|
95
|
+
reason: `page limit reached: ${pageFails}/${this.config.maxPerPage}`,
|
|
96
|
+
opcodeFailures: 0,
|
|
97
|
+
pageFailures: pageFails,
|
|
98
|
+
runFailures: this.runFailures,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return { tripped: false, reason: 'ok', opcodeFailures: 0, pageFailures: pageFails, runFailures: this.runFailures };
|
|
102
|
+
}
|
|
103
|
+
/** Get summary of all failure counts */
|
|
104
|
+
getSummary() {
|
|
105
|
+
return {
|
|
106
|
+
opcodeFailures: Object.fromEntries(this.opcodeFailures),
|
|
107
|
+
pageFailures: Object.fromEntries(this.pageFailures),
|
|
108
|
+
runFailures: this.runFailures,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/** Reset all counters */
|
|
112
|
+
reset() {
|
|
113
|
+
this.opcodeFailures.clear();
|
|
114
|
+
this.pageFailures.clear();
|
|
115
|
+
this.runFailures = 0;
|
|
116
|
+
this.currentPageKey = null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=circuit-breaker.js.map
|
package/dist/cli-config.d.ts
CHANGED
|
@@ -5,9 +5,16 @@ export interface AutokapConfig {
|
|
|
5
5
|
}
|
|
6
6
|
declare const DEFAULT_API_BASE_URL = "https://autokap.app";
|
|
7
7
|
declare const DEFAULT_WS_URL = "wss://autokap.app/ws";
|
|
8
|
+
declare const LOCAL_API_BASE_URL = "http://localhost:3000";
|
|
9
|
+
declare const LOCAL_WS_URL = "ws://localhost:3000/ws";
|
|
10
|
+
declare const API_BASE_URL_ENV_VAR = "AUTOKAP_API_BASE_URL";
|
|
11
|
+
declare const WS_URL_ENV_VAR = "AUTOKAP_WS_URL";
|
|
8
12
|
export declare function getConfigDir(): string;
|
|
9
13
|
export declare function getConfigPath(): string;
|
|
14
|
+
export declare function getDefaultApiBaseUrl(): string;
|
|
15
|
+
export declare function getDefaultWsUrl(apiBaseUrl?: string): string;
|
|
10
16
|
export declare function readConfig(): Promise<AutokapConfig | null>;
|
|
11
17
|
export declare function writeConfig(config: AutokapConfig): Promise<void>;
|
|
18
|
+
export declare function deleteConfig(): Promise<void>;
|
|
12
19
|
export declare function requireConfig(): Promise<AutokapConfig>;
|
|
13
|
-
export { DEFAULT_API_BASE_URL, DEFAULT_WS_URL };
|
|
20
|
+
export { DEFAULT_API_BASE_URL, DEFAULT_WS_URL, LOCAL_API_BASE_URL, LOCAL_WS_URL, API_BASE_URL_ENV_VAR, WS_URL_ENV_VAR, };
|
package/dist/cli-config.js
CHANGED
|
@@ -4,22 +4,38 @@ import fs from 'node:fs/promises';
|
|
|
4
4
|
import { logger } from './logger.js';
|
|
5
5
|
const DEFAULT_API_BASE_URL = 'https://autokap.app';
|
|
6
6
|
const DEFAULT_WS_URL = 'wss://autokap.app/ws';
|
|
7
|
+
const LOCAL_API_BASE_URL = 'http://localhost:3000';
|
|
8
|
+
const LOCAL_WS_URL = 'ws://localhost:3000/ws';
|
|
9
|
+
const API_BASE_URL_ENV_VAR = 'AUTOKAP_API_BASE_URL';
|
|
10
|
+
const WS_URL_ENV_VAR = 'AUTOKAP_WS_URL';
|
|
7
11
|
export function getConfigDir() {
|
|
8
12
|
return path.join(os.homedir(), '.autokap');
|
|
9
13
|
}
|
|
10
14
|
export function getConfigPath() {
|
|
11
15
|
return path.join(getConfigDir(), 'config.json');
|
|
12
16
|
}
|
|
17
|
+
export function getDefaultApiBaseUrl() {
|
|
18
|
+
return normalizeUrl(process.env[API_BASE_URL_ENV_VAR]) ?? DEFAULT_API_BASE_URL;
|
|
19
|
+
}
|
|
20
|
+
export function getDefaultWsUrl(apiBaseUrl = getDefaultApiBaseUrl()) {
|
|
21
|
+
return normalizeUrl(process.env[WS_URL_ENV_VAR]) ?? deriveWsUrl(apiBaseUrl);
|
|
22
|
+
}
|
|
13
23
|
export async function readConfig() {
|
|
14
24
|
try {
|
|
15
25
|
const raw = await fs.readFile(getConfigPath(), 'utf-8');
|
|
16
26
|
const parsed = JSON.parse(raw);
|
|
17
27
|
if (!parsed.apiKey)
|
|
18
28
|
return null;
|
|
29
|
+
const envApiBaseUrl = normalizeUrl(process.env[API_BASE_URL_ENV_VAR]);
|
|
30
|
+
const envWsUrl = normalizeUrl(process.env[WS_URL_ENV_VAR]);
|
|
31
|
+
const storedApiBaseUrl = normalizeUrl(parsed.apiBaseUrl) ?? DEFAULT_API_BASE_URL;
|
|
32
|
+
const apiBaseUrl = envApiBaseUrl ?? storedApiBaseUrl;
|
|
33
|
+
const wsUrl = envWsUrl
|
|
34
|
+
?? (envApiBaseUrl ? deriveWsUrl(apiBaseUrl) : normalizeUrl(parsed.wsUrl) ?? deriveWsUrl(apiBaseUrl));
|
|
19
35
|
return {
|
|
20
36
|
apiKey: parsed.apiKey,
|
|
21
|
-
apiBaseUrl
|
|
22
|
-
wsUrl
|
|
37
|
+
apiBaseUrl,
|
|
38
|
+
wsUrl,
|
|
23
39
|
};
|
|
24
40
|
}
|
|
25
41
|
catch {
|
|
@@ -27,16 +43,56 @@ export async function readConfig() {
|
|
|
27
43
|
}
|
|
28
44
|
}
|
|
29
45
|
export async function writeConfig(config) {
|
|
30
|
-
|
|
31
|
-
await fs.
|
|
46
|
+
const dir = getConfigDir();
|
|
47
|
+
await fs.mkdir(dir, { recursive: true });
|
|
48
|
+
const configPath = getConfigPath();
|
|
49
|
+
const normalizedConfig = {
|
|
50
|
+
...config,
|
|
51
|
+
apiBaseUrl: normalizeUrl(config.apiBaseUrl) ?? DEFAULT_API_BASE_URL,
|
|
52
|
+
wsUrl: normalizeUrl(config.wsUrl) ?? deriveWsUrl(config.apiBaseUrl),
|
|
53
|
+
};
|
|
54
|
+
await fs.writeFile(configPath, JSON.stringify(normalizedConfig, null, 2), 'utf-8');
|
|
55
|
+
// Restrict file permissions on Unix (NTFS ignores POSIX modes)
|
|
56
|
+
if (process.platform !== 'win32') {
|
|
57
|
+
await fs.chmod(dir, 0o700);
|
|
58
|
+
await fs.chmod(configPath, 0o600);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export async function deleteConfig() {
|
|
62
|
+
try {
|
|
63
|
+
await fs.rm(getConfigPath());
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
// config file doesn't exist, nothing to do
|
|
67
|
+
}
|
|
32
68
|
}
|
|
33
69
|
export async function requireConfig() {
|
|
34
70
|
const config = await readConfig();
|
|
35
71
|
if (!config) {
|
|
36
|
-
logger.error('Not authenticated. Run `autokap
|
|
72
|
+
logger.error('Not authenticated. Run `npx autokap@latest init --cli-key <key>` first.');
|
|
37
73
|
process.exit(1);
|
|
38
74
|
}
|
|
39
75
|
return config;
|
|
40
76
|
}
|
|
41
|
-
|
|
77
|
+
function normalizeUrl(value) {
|
|
78
|
+
const trimmed = value?.trim();
|
|
79
|
+
if (!trimmed)
|
|
80
|
+
return null;
|
|
81
|
+
return trimmed.replace(/\/+$/, '');
|
|
82
|
+
}
|
|
83
|
+
function deriveWsUrl(apiBaseUrl) {
|
|
84
|
+
try {
|
|
85
|
+
const url = new URL(apiBaseUrl);
|
|
86
|
+
url.protocol = url.protocol === 'https:' ? 'wss:' : url.protocol === 'http:' ? 'ws:' : url.protocol;
|
|
87
|
+
const pathname = url.pathname.replace(/\/+$/, '');
|
|
88
|
+
url.pathname = `${pathname || ''}/ws`;
|
|
89
|
+
url.search = '';
|
|
90
|
+
url.hash = '';
|
|
91
|
+
return url.toString().replace(/\/+$/, '');
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
return DEFAULT_WS_URL;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
export { DEFAULT_API_BASE_URL, DEFAULT_WS_URL, LOCAL_API_BASE_URL, LOCAL_WS_URL, API_BASE_URL_ENV_VAR, WS_URL_ENV_VAR, };
|
|
42
98
|
//# sourceMappingURL=cli-config.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface CliPublicCommandDescriptor {
|
|
2
|
+
id: string;
|
|
3
|
+
command: string;
|
|
4
|
+
summary: string;
|
|
5
|
+
docsDescriptionKey?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const CLI_KEY_TERM = "CLI key";
|
|
8
|
+
export declare const CLI_DEFAULT_INSTALL_COMMAND = "npm install -g autokap";
|
|
9
|
+
export declare const CLI_DEFAULT_SETUP_COMMAND = "npx autokap@latest init --cli-key <your-cli-key>";
|
|
10
|
+
export declare const CLI_ADVANCED_SKILL_COMMAND = "npx autokap@latest skill --agent <agent>";
|
|
11
|
+
export declare const CLI_FALLBACK_PROGRAM_COMMAND = "autokap run <preset-id> --program <file>";
|
|
12
|
+
export declare function buildCliRunCommand(presetId: string, options?: {
|
|
13
|
+
local?: boolean;
|
|
14
|
+
}): string;
|
|
15
|
+
export declare const CLI_PUBLIC_COMMANDS: CliPublicCommandDescriptor[];
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export const CLI_KEY_TERM = "CLI key";
|
|
2
|
+
export const CLI_DEFAULT_INSTALL_COMMAND = "npm install -g autokap";
|
|
3
|
+
export const CLI_DEFAULT_SETUP_COMMAND = "npx autokap@latest init --cli-key <your-cli-key>";
|
|
4
|
+
export const CLI_ADVANCED_SKILL_COMMAND = "npx autokap@latest skill --agent <agent>";
|
|
5
|
+
export const CLI_FALLBACK_PROGRAM_COMMAND = "autokap run <preset-id> --program <file>";
|
|
6
|
+
export function buildCliRunCommand(presetId, options = {}) {
|
|
7
|
+
return `autokap run${options.local ? " --local" : ""} ${presetId}`;
|
|
8
|
+
}
|
|
9
|
+
export const CLI_PUBLIC_COMMANDS = [
|
|
10
|
+
{
|
|
11
|
+
id: "init",
|
|
12
|
+
command: "autokap init",
|
|
13
|
+
summary: "Authenticate and install the AI skill in one step",
|
|
14
|
+
docsDescriptionKey: "cliCmdInit",
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
id: "login",
|
|
18
|
+
command: "autokap login <key>",
|
|
19
|
+
summary: "Authenticate with your CLI key",
|
|
20
|
+
docsDescriptionKey: "cliCmdLogin",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: "logout",
|
|
24
|
+
command: "autokap logout",
|
|
25
|
+
summary: "Remove stored credentials",
|
|
26
|
+
docsDescriptionKey: "cliCmdLogout",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "whoami",
|
|
30
|
+
command: "autokap whoami",
|
|
31
|
+
summary: "Show the account linked to the current CLI key",
|
|
32
|
+
docsDescriptionKey: "cliCmdWhoami",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
id: "ping",
|
|
36
|
+
command: "autokap ping",
|
|
37
|
+
summary: "Verify CLI connection and confirm the stored key is still valid",
|
|
38
|
+
docsDescriptionKey: "cliCmdPing",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
id: "run",
|
|
42
|
+
command: "autokap run <preset-id>",
|
|
43
|
+
summary: "Run a preset capture using local Playwright",
|
|
44
|
+
docsDescriptionKey: "cliCmdRun",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
id: "run-headed",
|
|
48
|
+
command: "autokap run <preset-id> --headed",
|
|
49
|
+
summary: "Show the browser window for debugging",
|
|
50
|
+
docsDescriptionKey: "cliCmdHeaded",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
id: "project-list",
|
|
54
|
+
command: "autokap project list",
|
|
55
|
+
summary: "List accessible projects as JSON",
|
|
56
|
+
docsDescriptionKey: "cliCmdProjectList",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "project-get",
|
|
60
|
+
command: "autokap project get <project-id>",
|
|
61
|
+
summary: "Get a single project as JSON",
|
|
62
|
+
docsDescriptionKey: "cliCmdProjectGet",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: "project-create",
|
|
66
|
+
command: "autokap project create --name <name> --url <url>",
|
|
67
|
+
summary: "Create a project and print its ID",
|
|
68
|
+
docsDescriptionKey: "cliCmdProjectCreate",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
id: "preset-info",
|
|
72
|
+
command: "autokap preset info <preset-id>",
|
|
73
|
+
summary: "Get structured JSON with endpoints, variants, and URL parameters",
|
|
74
|
+
docsDescriptionKey: "cliCmdPresetInfo",
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: "capture-list",
|
|
78
|
+
command: "autokap capture list",
|
|
79
|
+
summary: "List captures as JSON",
|
|
80
|
+
docsDescriptionKey: "cliCmdCaptureList",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
id: "usage",
|
|
84
|
+
command: "autokap usage",
|
|
85
|
+
summary: "Show the current billing-period usage as JSON",
|
|
86
|
+
docsDescriptionKey: "cliCmdUsage",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
id: "endpoints-list",
|
|
90
|
+
command: "autokap endpoints list --preset <id>",
|
|
91
|
+
summary: "List dev link endpoints as JSON or table",
|
|
92
|
+
docsDescriptionKey: "cliCmdEndpointsList",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "endpoints-get",
|
|
96
|
+
command: "autokap endpoints get <endpoint-id>",
|
|
97
|
+
summary: "Get a single dev link endpoint as JSON",
|
|
98
|
+
docsDescriptionKey: "cliCmdEndpointsGet",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "endpoints-export",
|
|
102
|
+
command: "autokap endpoints export --preset <id>",
|
|
103
|
+
summary: "Export dev link endpoints as JSON or CSV",
|
|
104
|
+
docsDescriptionKey: "cliCmdEndpointsExport",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "auth-capture",
|
|
108
|
+
command: "autokap auth capture <project-id>",
|
|
109
|
+
summary: "Capture a browser session for a session account",
|
|
110
|
+
docsDescriptionKey: "cliCmdAuthCapture",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: "auth-account-list",
|
|
114
|
+
command: "autokap auth account list <project-id>",
|
|
115
|
+
summary: "List project credential accounts as JSON",
|
|
116
|
+
docsDescriptionKey: "cliCmdAuthAccountList",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "auth-account-create",
|
|
120
|
+
command: "autokap auth account create <project-id> --name <name>",
|
|
121
|
+
summary: "Create a project credential account and print its ID",
|
|
122
|
+
docsDescriptionKey: "cliCmdAuthAccountCreate",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "auth-account-update",
|
|
126
|
+
command: "autokap auth account update <project-id> --account <name-or-id>",
|
|
127
|
+
summary: "Update a project credential account",
|
|
128
|
+
docsDescriptionKey: "cliCmdAuthAccountUpdate",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "auth-account-delete",
|
|
132
|
+
command: "autokap auth account delete <project-id> --account <name-or-id>",
|
|
133
|
+
summary: "Delete an unused project credential account",
|
|
134
|
+
docsDescriptionKey: "cliCmdAuthAccountDelete",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "auth-session-clear",
|
|
138
|
+
command: "autokap auth session clear <project-id> --account <name-or-id>",
|
|
139
|
+
summary: "Clear the stored browser session for a session account",
|
|
140
|
+
docsDescriptionKey: "cliCmdAuthSessionClear",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "proxy-register",
|
|
144
|
+
command: "autokap proxy register --project <id> --proxy-url <url>",
|
|
145
|
+
summary: "Register a user-side proxy for dev links",
|
|
146
|
+
docsDescriptionKey: "cliCmdProxyRegister",
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: "proxy-verify",
|
|
150
|
+
command: "autokap proxy verify --project <id>",
|
|
151
|
+
summary: "Verify the configured proxy for a project",
|
|
152
|
+
docsDescriptionKey: "cliCmdProxyVerify",
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: "skill",
|
|
156
|
+
command: "autokap skill",
|
|
157
|
+
summary: "Export the AI agent skill bundle",
|
|
158
|
+
docsDescriptionKey: "cliCmdSkill",
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
id: "version",
|
|
162
|
+
command: "autokap --version",
|
|
163
|
+
summary: "Show the installed version",
|
|
164
|
+
docsDescriptionKey: "cliCmdVersion",
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
//# sourceMappingURL=cli-contract.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — CLI command wrapper
|
|
3
|
+
*
|
|
4
|
+
* `autokap run` stays local-first: Playwright runs on the user's machine.
|
|
5
|
+
* The server only provides the compiled program and persists artifacts/results.
|
|
6
|
+
*/
|
|
7
|
+
export declare function runLocal(presetId: string, opts: {
|
|
8
|
+
headed: boolean;
|
|
9
|
+
output?: string;
|
|
10
|
+
program?: string;
|
|
11
|
+
debug?: boolean;
|
|
12
|
+
}): Promise<void>;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — CLI command wrapper
|
|
3
|
+
*
|
|
4
|
+
* `autokap run` stays local-first: Playwright runs on the user's machine.
|
|
5
|
+
* The server only provides the compiled program and persists artifacts/results.
|
|
6
|
+
*/
|
|
7
|
+
import path from 'node:path';
|
|
8
|
+
import fs from 'node:fs/promises';
|
|
9
|
+
import { logger } from './logger.js';
|
|
10
|
+
import { parseProgram } from './execution-schema.js';
|
|
11
|
+
import { runCapture } from './cli-runner.js';
|
|
12
|
+
export async function runLocal(presetId, opts) {
|
|
13
|
+
let program;
|
|
14
|
+
if (opts.program) {
|
|
15
|
+
try {
|
|
16
|
+
const raw = await fs.readFile(opts.program, 'utf-8');
|
|
17
|
+
program = parseProgram(JSON.parse(raw));
|
|
18
|
+
logger.info(`[capture] Loaded program from file: ${opts.program}`);
|
|
19
|
+
}
|
|
20
|
+
catch (err) {
|
|
21
|
+
logger.error(`[capture] Failed to load program: ${err instanceof Error ? err.message : String(err)}`);
|
|
22
|
+
process.exit(1);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const run = await runCapture({
|
|
26
|
+
presetId,
|
|
27
|
+
program,
|
|
28
|
+
headed: opts.headed,
|
|
29
|
+
onProgress: (event) => {
|
|
30
|
+
const prefix = `[capture][${event.variantId}]`;
|
|
31
|
+
switch (event.type) {
|
|
32
|
+
case 'variant_start':
|
|
33
|
+
logger.info(`${prefix} Starting variant`);
|
|
34
|
+
break;
|
|
35
|
+
case 'variant_end':
|
|
36
|
+
logger.info(`${prefix} ${event.status === 'ok' ? 'DONE' : 'FAILED'}: ${event.message}`);
|
|
37
|
+
break;
|
|
38
|
+
case 'opcode_start':
|
|
39
|
+
logger.info(`${prefix}[${event.opcodeIndex}] >> ${event.opcodeKind}: ${event.message}`);
|
|
40
|
+
break;
|
|
41
|
+
case 'opcode_end':
|
|
42
|
+
if (event.status === 'ok') {
|
|
43
|
+
logger.info(`${prefix}[${event.opcodeIndex}] << OK (${event.opcodeKind})`);
|
|
44
|
+
}
|
|
45
|
+
else if (event.status === 'recovered') {
|
|
46
|
+
logger.warn(`${prefix}[${event.opcodeIndex}] << RECOVERED: ${event.message}`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
logger.error(`${prefix}[${event.opcodeIndex}] << FAILED: ${event.message}`);
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
case 'recovery':
|
|
53
|
+
logger.warn(`${prefix}[${event.opcodeIndex}] RECOVERY: ${event.message}`);
|
|
54
|
+
break;
|
|
55
|
+
case 'breaker_trip':
|
|
56
|
+
logger.error(`${prefix} CIRCUIT BREAKER: ${event.message}`);
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
if (run.runResult && opts.output) {
|
|
62
|
+
await persistArtifactsLocally(presetId, opts.output, run.runResult.variantResults);
|
|
63
|
+
}
|
|
64
|
+
if (!run.success) {
|
|
65
|
+
logger.error(`Error: ${run.error ?? run.runResult?.error ?? 'capture failed'}`);
|
|
66
|
+
process.exit(1);
|
|
67
|
+
}
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
async function persistArtifactsLocally(presetId, outputDirOption, variants) {
|
|
71
|
+
const outputDir = path.resolve(outputDirOption);
|
|
72
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
73
|
+
for (const variant of variants) {
|
|
74
|
+
for (let index = 0; index < variant.artifacts.length; index += 1) {
|
|
75
|
+
const artifact = variant.artifacts[index];
|
|
76
|
+
const ext = artifact.mediaMode === 'dom'
|
|
77
|
+
? 'html'
|
|
78
|
+
: artifact.mimeType === 'image/png'
|
|
79
|
+
? 'png'
|
|
80
|
+
: artifact.mimeType === 'image/jpeg'
|
|
81
|
+
? 'jpg'
|
|
82
|
+
: artifact.mimeType.includes('gif')
|
|
83
|
+
? 'gif'
|
|
84
|
+
: artifact.mimeType.includes('mp4')
|
|
85
|
+
? 'mp4'
|
|
86
|
+
: 'webm';
|
|
87
|
+
let suffix = '';
|
|
88
|
+
if (artifact.mediaMode === 'dom') {
|
|
89
|
+
if (artifact.fragmentName && artifact.parentStateName) {
|
|
90
|
+
suffix = `-${artifact.parentStateName}-fragment-${artifact.fragmentName}`;
|
|
91
|
+
}
|
|
92
|
+
else if (artifact.stateName) {
|
|
93
|
+
suffix = `-${artifact.stateName}`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const filePath = path.join(outputDir, `capture-${presetId.slice(0, 8)}-${variant.variantId}${suffix}-${index}.${ext}`);
|
|
97
|
+
await fs.writeFile(filePath, artifact.buffer);
|
|
98
|
+
logger.info(`[capture] Artifact saved locally: ${filePath}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
//# sourceMappingURL=cli-runner-local.js.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Capture Agent — CLI Runner
|
|
3
|
+
*
|
|
4
|
+
* Entry point for deterministic execution from the CLI.
|
|
5
|
+
* Flow:
|
|
6
|
+
* 1. Authenticate via stored CLI key
|
|
7
|
+
* 2. Fetch compiled program from server
|
|
8
|
+
* 3. Validate program against Zod schema
|
|
9
|
+
* 4. Launch local Playwright browser per variant
|
|
10
|
+
* 5. Execute program via opcode-runner
|
|
11
|
+
* 6. Upload artifacts + telemetry to server
|
|
12
|
+
*/
|
|
13
|
+
import { type ProgressEvent } from './opcode-runner.js';
|
|
14
|
+
import type { ExecutionProgram, RunResult } from './execution-types.js';
|
|
15
|
+
export interface CLIRunnerOptions {
|
|
16
|
+
/** Preset ID to run */
|
|
17
|
+
presetId: string;
|
|
18
|
+
/** Override: provide program directly instead of fetching from server */
|
|
19
|
+
program?: ExecutionProgram;
|
|
20
|
+
/** Selector memory map (fetched from server or cached locally) */
|
|
21
|
+
selectorMemory?: Record<string, string[]>;
|
|
22
|
+
/** Show browser window. Default: false (headless) */
|
|
23
|
+
headed?: boolean;
|
|
24
|
+
/** Abort signal for cancellation */
|
|
25
|
+
abortSignal?: AbortSignal;
|
|
26
|
+
/** Progress callback */
|
|
27
|
+
onProgress?: (event: ProgressEvent) => void;
|
|
28
|
+
}
|
|
29
|
+
export interface CLIRunResult {
|
|
30
|
+
success: boolean;
|
|
31
|
+
runResult?: RunResult;
|
|
32
|
+
error?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare function runCapture(options: CLIRunnerOptions): Promise<CLIRunResult>;
|