libretto 0.1.5 → 0.2.0
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/README.md +213 -17
- package/bin/libretto.mjs +18 -0
- package/dist/cli/cli.js +201 -0
- package/dist/cli/commands/ai.js +21 -0
- package/dist/cli/commands/browser.js +56 -0
- package/dist/cli/commands/execution.js +407 -0
- package/dist/cli/commands/logs.js +65 -0
- package/dist/cli/commands/snapshot.js +99 -0
- package/dist/cli/core/ai-config.js +149 -0
- package/dist/cli/core/browser.js +687 -0
- package/dist/cli/core/context.js +113 -0
- package/dist/cli/core/pause-signals.js +29 -0
- package/dist/cli/core/session.js +183 -0
- package/dist/cli/core/snapshot-analyzer.js +492 -0
- package/dist/cli/core/telemetry.js +350 -0
- package/dist/cli/index.js +13 -0
- package/dist/cli/workers/run-integration-runtime.js +204 -0
- package/dist/cli/workers/run-integration-worker-protocol.js +0 -0
- package/dist/cli/workers/run-integration-worker.js +83 -0
- package/dist/index.cjs +127 -0
- package/dist/index.d.cts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +110 -0
- package/dist/runtime/download/download.cjs +70 -0
- package/dist/runtime/download/download.d.cts +35 -0
- package/dist/runtime/download/download.d.ts +35 -0
- package/dist/runtime/download/download.js +45 -0
- package/dist/runtime/download/index.cjs +30 -0
- package/dist/runtime/download/index.d.cts +3 -0
- package/dist/runtime/download/index.d.ts +3 -0
- package/dist/runtime/download/index.js +8 -0
- package/dist/runtime/extract/extract.cjs +87 -0
- package/dist/runtime/extract/extract.d.cts +23 -0
- package/dist/runtime/extract/extract.d.ts +23 -0
- package/dist/runtime/extract/extract.js +63 -0
- package/dist/runtime/extract/index.cjs +28 -0
- package/dist/runtime/extract/index.d.cts +5 -0
- package/dist/runtime/extract/index.d.ts +5 -0
- package/dist/runtime/extract/index.js +4 -0
- package/dist/runtime/network/index.cjs +28 -0
- package/dist/runtime/network/index.d.cts +4 -0
- package/dist/runtime/network/index.d.ts +4 -0
- package/dist/runtime/network/index.js +6 -0
- package/dist/runtime/network/network.cjs +91 -0
- package/dist/runtime/network/network.d.cts +28 -0
- package/dist/runtime/network/network.d.ts +28 -0
- package/dist/runtime/network/network.js +67 -0
- package/dist/runtime/recovery/agent.cjs +218 -0
- package/dist/runtime/recovery/agent.d.cts +13 -0
- package/dist/runtime/recovery/agent.d.ts +13 -0
- package/dist/runtime/recovery/agent.js +194 -0
- package/dist/runtime/recovery/errors.cjs +122 -0
- package/dist/runtime/recovery/errors.d.cts +31 -0
- package/dist/runtime/recovery/errors.d.ts +31 -0
- package/dist/runtime/recovery/errors.js +98 -0
- package/dist/runtime/recovery/index.cjs +34 -0
- package/dist/runtime/recovery/index.d.cts +7 -0
- package/dist/runtime/recovery/index.d.ts +7 -0
- package/dist/runtime/recovery/index.js +10 -0
- package/dist/runtime/recovery/recovery.cjs +53 -0
- package/dist/runtime/recovery/recovery.d.cts +12 -0
- package/dist/runtime/recovery/recovery.d.ts +12 -0
- package/dist/runtime/recovery/recovery.js +29 -0
- package/dist/runtime/step/index.cjs +31 -0
- package/dist/runtime/step/index.d.cts +7 -0
- package/dist/runtime/step/index.d.ts +7 -0
- package/dist/runtime/step/index.js +6 -0
- package/dist/runtime/step/runner.cjs +208 -0
- package/dist/runtime/step/runner.d.cts +16 -0
- package/dist/runtime/step/runner.d.ts +16 -0
- package/dist/runtime/step/runner.js +187 -0
- package/dist/runtime/step/step.cjs +67 -0
- package/dist/runtime/step/step.d.cts +23 -0
- package/dist/runtime/step/step.d.ts +23 -0
- package/dist/runtime/step/step.js +43 -0
- package/dist/runtime/step/types.cjs +16 -0
- package/dist/runtime/step/types.d.cts +72 -0
- package/dist/runtime/step/types.d.ts +72 -0
- package/dist/runtime/step/types.js +0 -0
- package/dist/shared/config/config.cjs +44 -0
- package/dist/shared/config/config.d.cts +10 -0
- package/dist/shared/config/config.d.ts +10 -0
- package/dist/shared/config/config.js +18 -0
- package/dist/shared/config/index.cjs +32 -0
- package/dist/shared/config/index.d.cts +1 -0
- package/dist/shared/config/index.d.ts +1 -0
- package/dist/shared/config/index.js +10 -0
- package/dist/shared/debug/index.cjs +32 -0
- package/dist/shared/debug/index.d.cts +2 -0
- package/dist/shared/debug/index.d.ts +2 -0
- package/dist/shared/debug/index.js +10 -0
- package/dist/shared/debug/pause.cjs +56 -0
- package/dist/shared/debug/pause.d.cts +23 -0
- package/dist/shared/debug/pause.d.ts +23 -0
- package/dist/shared/debug/pause.js +30 -0
- package/dist/shared/instrumentation/errors.cjs +81 -0
- package/dist/shared/instrumentation/errors.d.cts +12 -0
- package/dist/shared/instrumentation/errors.d.ts +12 -0
- package/dist/shared/instrumentation/errors.js +57 -0
- package/dist/shared/instrumentation/index.cjs +35 -0
- package/dist/shared/instrumentation/index.d.cts +6 -0
- package/dist/shared/instrumentation/index.d.ts +6 -0
- package/dist/shared/instrumentation/index.js +12 -0
- package/dist/shared/instrumentation/instrument.cjs +206 -0
- package/dist/shared/instrumentation/instrument.d.cts +32 -0
- package/dist/shared/instrumentation/instrument.d.ts +32 -0
- package/dist/shared/instrumentation/instrument.js +190 -0
- package/dist/shared/llm/client.cjs +139 -0
- package/dist/shared/llm/client.d.cts +6 -0
- package/dist/shared/llm/client.d.ts +6 -0
- package/dist/shared/llm/client.js +115 -0
- package/dist/shared/llm/index.cjs +28 -0
- package/dist/shared/llm/index.d.cts +3 -0
- package/dist/shared/llm/index.d.ts +3 -0
- package/dist/shared/llm/index.js +4 -0
- package/dist/shared/llm/types.cjs +16 -0
- package/dist/shared/llm/types.d.cts +34 -0
- package/dist/shared/llm/types.d.ts +34 -0
- package/dist/shared/llm/types.js +0 -0
- package/dist/shared/logger/index.cjs +35 -0
- package/dist/shared/logger/index.d.cts +2 -0
- package/dist/shared/logger/index.d.ts +2 -0
- package/dist/shared/logger/index.js +12 -0
- package/dist/shared/logger/logger.cjs +200 -0
- package/dist/shared/logger/logger.d.cts +70 -0
- package/dist/shared/logger/logger.d.ts +70 -0
- package/dist/shared/logger/logger.js +176 -0
- package/dist/shared/logger/sinks.cjs +160 -0
- package/dist/shared/logger/sinks.d.cts +9 -0
- package/dist/shared/logger/sinks.d.ts +9 -0
- package/dist/shared/logger/sinks.js +124 -0
- package/dist/shared/paths/paths.cjs +104 -0
- package/dist/shared/paths/paths.d.cts +10 -0
- package/dist/shared/paths/paths.d.ts +10 -0
- package/dist/shared/paths/paths.js +73 -0
- package/dist/shared/run/api.cjs +35 -0
- package/dist/shared/run/api.d.cts +3 -0
- package/dist/shared/run/api.d.ts +3 -0
- package/dist/shared/run/api.js +12 -0
- package/dist/shared/run/browser.cjs +98 -0
- package/dist/shared/run/browser.d.cts +22 -0
- package/dist/shared/run/browser.d.ts +22 -0
- package/dist/shared/run/browser.js +74 -0
- package/dist/shared/state/index.cjs +38 -0
- package/dist/shared/state/index.d.cts +2 -0
- package/dist/shared/state/index.d.ts +2 -0
- package/dist/shared/state/index.js +16 -0
- package/dist/shared/state/session-state.cjs +85 -0
- package/dist/shared/state/session-state.d.cts +34 -0
- package/dist/shared/state/session-state.d.ts +34 -0
- package/dist/shared/state/session-state.js +56 -0
- package/dist/shared/visualization/ghost-cursor.cjs +174 -0
- package/dist/shared/visualization/ghost-cursor.d.cts +37 -0
- package/dist/shared/visualization/ghost-cursor.d.ts +37 -0
- package/dist/shared/visualization/ghost-cursor.js +145 -0
- package/dist/shared/visualization/highlight.cjs +134 -0
- package/dist/shared/visualization/highlight.d.cts +22 -0
- package/dist/shared/visualization/highlight.d.ts +22 -0
- package/dist/shared/visualization/highlight.js +108 -0
- package/dist/shared/visualization/index.cjs +45 -0
- package/dist/shared/visualization/index.d.cts +3 -0
- package/dist/shared/visualization/index.d.ts +3 -0
- package/dist/shared/visualization/index.js +24 -0
- package/dist/shared/workflow/workflow.cjs +47 -0
- package/dist/shared/workflow/workflow.d.cts +33 -0
- package/dist/shared/workflow/workflow.d.ts +33 -0
- package/dist/shared/workflow/workflow.js +21 -0
- package/package.json +123 -26
- package/.npmignore +0 -2
- package/bin/libretto +0 -31
- package/lib/connect.js +0 -34
- package/lib/export.js +0 -224
- package/lib/import.js +0 -166
- package/lib/index.js +0 -8
- package/lib/log.js +0 -9
- package/lib/validate.js +0 -20
- package/makefile +0 -8
- package/src/connect.coffee +0 -25
- package/src/export.coffee +0 -222
- package/src/import.coffee +0 -166
- package/src/index.coffee +0 -3
- package/src/log.coffee +0 -3
- package/src/validate.coffee +0 -10
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Page } from 'playwright';
|
|
2
|
+
import { LoggerApi } from '../../shared/logger/logger.cjs';
|
|
3
|
+
import { LLMClient } from '../../shared/llm/types.cjs';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
type StepContext = {
|
|
7
|
+
page: Page;
|
|
8
|
+
logger: LoggerApi;
|
|
9
|
+
config: {
|
|
10
|
+
dryRun: boolean;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
logDir: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
type RecoveryHandler = (ctx: {
|
|
16
|
+
page: Page;
|
|
17
|
+
logger: LoggerApi;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
type StepOptions = {
|
|
20
|
+
/**
|
|
21
|
+
* Behavior in dry-run mode:
|
|
22
|
+
* - "execute": always run, even in dry-run (e.g., login steps)
|
|
23
|
+
* - "skip": skip entirely in dry-run
|
|
24
|
+
* - "simulate": call the simulate function instead
|
|
25
|
+
*
|
|
26
|
+
* Defaults to "skip".
|
|
27
|
+
*/
|
|
28
|
+
dryRun?: "execute" | "skip" | "simulate";
|
|
29
|
+
/**
|
|
30
|
+
* Function to call instead of the handler when dryRun is "simulate".
|
|
31
|
+
*/
|
|
32
|
+
simulate?: (ctx: {
|
|
33
|
+
logger: LoggerApi;
|
|
34
|
+
}) => Promise<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Custom recovery handlers keyed by name.
|
|
37
|
+
* These run after built-in popup recovery on failure.
|
|
38
|
+
*/
|
|
39
|
+
recovery?: Record<string, RecoveryHandler>;
|
|
40
|
+
};
|
|
41
|
+
type StepHandler = (ctx: StepContext) => Promise<any>;
|
|
42
|
+
type Step = {
|
|
43
|
+
name: string;
|
|
44
|
+
handler: StepHandler;
|
|
45
|
+
options: Required<Pick<StepOptions, "dryRun">> & Omit<StepOptions, "dryRun">;
|
|
46
|
+
};
|
|
47
|
+
type RunnerConfig = {
|
|
48
|
+
llmClient?: LLMClient;
|
|
49
|
+
dryRun?: boolean;
|
|
50
|
+
debug?: boolean;
|
|
51
|
+
sessionName?: string;
|
|
52
|
+
logDir?: string;
|
|
53
|
+
};
|
|
54
|
+
type StepHistoryEntry = {
|
|
55
|
+
name: string;
|
|
56
|
+
status: "completed" | "failed" | "skipped" | "simulated";
|
|
57
|
+
duration: number;
|
|
58
|
+
};
|
|
59
|
+
type DebugBundle = {
|
|
60
|
+
timestamp: string;
|
|
61
|
+
step: string;
|
|
62
|
+
error: string;
|
|
63
|
+
stacktrace: string;
|
|
64
|
+
screenshotPath: string;
|
|
65
|
+
domPath: string;
|
|
66
|
+
logPath: string;
|
|
67
|
+
stepHistory: StepHistoryEntry[];
|
|
68
|
+
pageUrl: string;
|
|
69
|
+
visualizationEnabled?: boolean;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type { DebugBundle, RecoveryHandler, RunnerConfig, Step, StepContext, StepHandler, StepHistoryEntry, StepOptions };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Page } from 'playwright';
|
|
2
|
+
import { LoggerApi } from '../../shared/logger/logger.js';
|
|
3
|
+
import { LLMClient } from '../../shared/llm/types.js';
|
|
4
|
+
import 'zod';
|
|
5
|
+
|
|
6
|
+
type StepContext = {
|
|
7
|
+
page: Page;
|
|
8
|
+
logger: LoggerApi;
|
|
9
|
+
config: {
|
|
10
|
+
dryRun: boolean;
|
|
11
|
+
debug: boolean;
|
|
12
|
+
logDir: string;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
type RecoveryHandler = (ctx: {
|
|
16
|
+
page: Page;
|
|
17
|
+
logger: LoggerApi;
|
|
18
|
+
}) => Promise<void>;
|
|
19
|
+
type StepOptions = {
|
|
20
|
+
/**
|
|
21
|
+
* Behavior in dry-run mode:
|
|
22
|
+
* - "execute": always run, even in dry-run (e.g., login steps)
|
|
23
|
+
* - "skip": skip entirely in dry-run
|
|
24
|
+
* - "simulate": call the simulate function instead
|
|
25
|
+
*
|
|
26
|
+
* Defaults to "skip".
|
|
27
|
+
*/
|
|
28
|
+
dryRun?: "execute" | "skip" | "simulate";
|
|
29
|
+
/**
|
|
30
|
+
* Function to call instead of the handler when dryRun is "simulate".
|
|
31
|
+
*/
|
|
32
|
+
simulate?: (ctx: {
|
|
33
|
+
logger: LoggerApi;
|
|
34
|
+
}) => Promise<any>;
|
|
35
|
+
/**
|
|
36
|
+
* Custom recovery handlers keyed by name.
|
|
37
|
+
* These run after built-in popup recovery on failure.
|
|
38
|
+
*/
|
|
39
|
+
recovery?: Record<string, RecoveryHandler>;
|
|
40
|
+
};
|
|
41
|
+
type StepHandler = (ctx: StepContext) => Promise<any>;
|
|
42
|
+
type Step = {
|
|
43
|
+
name: string;
|
|
44
|
+
handler: StepHandler;
|
|
45
|
+
options: Required<Pick<StepOptions, "dryRun">> & Omit<StepOptions, "dryRun">;
|
|
46
|
+
};
|
|
47
|
+
type RunnerConfig = {
|
|
48
|
+
llmClient?: LLMClient;
|
|
49
|
+
dryRun?: boolean;
|
|
50
|
+
debug?: boolean;
|
|
51
|
+
sessionName?: string;
|
|
52
|
+
logDir?: string;
|
|
53
|
+
};
|
|
54
|
+
type StepHistoryEntry = {
|
|
55
|
+
name: string;
|
|
56
|
+
status: "completed" | "failed" | "skipped" | "simulated";
|
|
57
|
+
duration: number;
|
|
58
|
+
};
|
|
59
|
+
type DebugBundle = {
|
|
60
|
+
timestamp: string;
|
|
61
|
+
step: string;
|
|
62
|
+
error: string;
|
|
63
|
+
stacktrace: string;
|
|
64
|
+
screenshotPath: string;
|
|
65
|
+
domPath: string;
|
|
66
|
+
logPath: string;
|
|
67
|
+
stepHistory: StepHistoryEntry[];
|
|
68
|
+
pageUrl: string;
|
|
69
|
+
visualizationEnabled?: boolean;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type { DebugBundle, RecoveryHandler, RunnerConfig, Step, StepContext, StepHandler, StepHistoryEntry, StepOptions };
|
|
File without changes
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var config_exports = {};
|
|
20
|
+
__export(config_exports, {
|
|
21
|
+
isDebugMode: () => isDebugMode,
|
|
22
|
+
isDryRun: () => isDryRun,
|
|
23
|
+
shouldPauseBeforeMutation: () => shouldPauseBeforeMutation
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(config_exports);
|
|
26
|
+
function isDebugMode() {
|
|
27
|
+
return process.env.LIBRETTO_DEBUG === "true";
|
|
28
|
+
}
|
|
29
|
+
function isDryRun() {
|
|
30
|
+
const explicit = process.env.LIBRETTO_DRY_RUN;
|
|
31
|
+
if (explicit !== void 0) {
|
|
32
|
+
return explicit === "true";
|
|
33
|
+
}
|
|
34
|
+
return process.env.NODE_ENV === "development";
|
|
35
|
+
}
|
|
36
|
+
function shouldPauseBeforeMutation() {
|
|
37
|
+
return isDryRun() && isDebugMode();
|
|
38
|
+
}
|
|
39
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
40
|
+
0 && (module.exports = {
|
|
41
|
+
isDebugMode,
|
|
42
|
+
isDryRun,
|
|
43
|
+
shouldPauseBeforeMutation
|
|
44
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime configuration for libretto.
|
|
3
|
+
*
|
|
4
|
+
* Values are derived from environment variables only.
|
|
5
|
+
*/
|
|
6
|
+
declare function isDebugMode(): boolean;
|
|
7
|
+
declare function isDryRun(): boolean;
|
|
8
|
+
declare function shouldPauseBeforeMutation(): boolean;
|
|
9
|
+
|
|
10
|
+
export { isDebugMode, isDryRun, shouldPauseBeforeMutation };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime configuration for libretto.
|
|
3
|
+
*
|
|
4
|
+
* Values are derived from environment variables only.
|
|
5
|
+
*/
|
|
6
|
+
declare function isDebugMode(): boolean;
|
|
7
|
+
declare function isDryRun(): boolean;
|
|
8
|
+
declare function shouldPauseBeforeMutation(): boolean;
|
|
9
|
+
|
|
10
|
+
export { isDebugMode, isDryRun, shouldPauseBeforeMutation };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
function isDebugMode() {
|
|
2
|
+
return process.env.LIBRETTO_DEBUG === "true";
|
|
3
|
+
}
|
|
4
|
+
function isDryRun() {
|
|
5
|
+
const explicit = process.env.LIBRETTO_DRY_RUN;
|
|
6
|
+
if (explicit !== void 0) {
|
|
7
|
+
return explicit === "true";
|
|
8
|
+
}
|
|
9
|
+
return process.env.NODE_ENV === "development";
|
|
10
|
+
}
|
|
11
|
+
function shouldPauseBeforeMutation() {
|
|
12
|
+
return isDryRun() && isDebugMode();
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
isDebugMode,
|
|
16
|
+
isDryRun,
|
|
17
|
+
shouldPauseBeforeMutation
|
|
18
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var config_exports = {};
|
|
20
|
+
__export(config_exports, {
|
|
21
|
+
isDebugMode: () => import_config.isDebugMode,
|
|
22
|
+
isDryRun: () => import_config.isDryRun,
|
|
23
|
+
shouldPauseBeforeMutation: () => import_config.shouldPauseBeforeMutation
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(config_exports);
|
|
26
|
+
var import_config = require("./config.js");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
isDebugMode,
|
|
30
|
+
isDryRun,
|
|
31
|
+
shouldPauseBeforeMutation
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isDebugMode, isDryRun, shouldPauseBeforeMutation } from './config.cjs';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { isDebugMode, isDryRun, shouldPauseBeforeMutation } from './config.js';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var debug_exports = {};
|
|
20
|
+
__export(debug_exports, {
|
|
21
|
+
DebugPauseSignal: () => import_pause.DebugPauseSignal,
|
|
22
|
+
debugPause: () => import_pause.debugPause,
|
|
23
|
+
isDebugPauseSignal: () => import_pause.isDebugPauseSignal
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(debug_exports);
|
|
26
|
+
var import_pause = require("./pause.js");
|
|
27
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
28
|
+
0 && (module.exports = {
|
|
29
|
+
DebugPauseSignal,
|
|
30
|
+
debugPause,
|
|
31
|
+
isDebugPauseSignal
|
|
32
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var pause_exports = {};
|
|
20
|
+
__export(pause_exports, {
|
|
21
|
+
DebugPauseSignal: () => DebugPauseSignal,
|
|
22
|
+
debugPause: () => debugPause,
|
|
23
|
+
isDebugPauseSignal: () => isDebugPauseSignal
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(pause_exports);
|
|
26
|
+
class DebugPauseSignal extends Error {
|
|
27
|
+
details;
|
|
28
|
+
constructor(details) {
|
|
29
|
+
super(`Workflow paused at ${details.url}`);
|
|
30
|
+
this.name = "DebugPauseSignal";
|
|
31
|
+
this.details = details;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function isDebugPauseSignal(error) {
|
|
35
|
+
if (!error || typeof error !== "object") return false;
|
|
36
|
+
const candidate = error;
|
|
37
|
+
if (candidate.name !== "DebugPauseSignal") return false;
|
|
38
|
+
return typeof candidate.details?.sessionName === "string" && typeof candidate.details?.pausedAt === "string" && typeof candidate.details?.url === "string";
|
|
39
|
+
}
|
|
40
|
+
async function debugPause(context) {
|
|
41
|
+
const url = context.page.url();
|
|
42
|
+
const details = {
|
|
43
|
+
sessionName: context.session,
|
|
44
|
+
pausedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
45
|
+
url
|
|
46
|
+
};
|
|
47
|
+
console.log(`[debugPause] Paused at ${url}`);
|
|
48
|
+
console.log("[debugPause] Signaling pause to supervisor...");
|
|
49
|
+
throw new DebugPauseSignal(details);
|
|
50
|
+
}
|
|
51
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
52
|
+
0 && (module.exports = {
|
|
53
|
+
DebugPauseSignal,
|
|
54
|
+
debugPause,
|
|
55
|
+
isDebugPauseSignal
|
|
56
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Page } from 'playwright';
|
|
2
|
+
|
|
3
|
+
type DebugPauseContext = {
|
|
4
|
+
page: Page;
|
|
5
|
+
session: string;
|
|
6
|
+
};
|
|
7
|
+
type DebugPauseDetails = {
|
|
8
|
+
sessionName: string;
|
|
9
|
+
pausedAt: string;
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
declare class DebugPauseSignal extends Error {
|
|
13
|
+
readonly details: DebugPauseDetails;
|
|
14
|
+
constructor(details: DebugPauseDetails);
|
|
15
|
+
}
|
|
16
|
+
declare function isDebugPauseSignal(error: unknown): error is DebugPauseSignal;
|
|
17
|
+
/**
|
|
18
|
+
* Signals a workflow pause to the caller.
|
|
19
|
+
* This always throws a typed signal that supervisors can intercept.
|
|
20
|
+
*/
|
|
21
|
+
declare function debugPause(context: DebugPauseContext): Promise<never>;
|
|
22
|
+
|
|
23
|
+
export { type DebugPauseContext, type DebugPauseDetails, DebugPauseSignal, debugPause, isDebugPauseSignal };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Page } from 'playwright';
|
|
2
|
+
|
|
3
|
+
type DebugPauseContext = {
|
|
4
|
+
page: Page;
|
|
5
|
+
session: string;
|
|
6
|
+
};
|
|
7
|
+
type DebugPauseDetails = {
|
|
8
|
+
sessionName: string;
|
|
9
|
+
pausedAt: string;
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
declare class DebugPauseSignal extends Error {
|
|
13
|
+
readonly details: DebugPauseDetails;
|
|
14
|
+
constructor(details: DebugPauseDetails);
|
|
15
|
+
}
|
|
16
|
+
declare function isDebugPauseSignal(error: unknown): error is DebugPauseSignal;
|
|
17
|
+
/**
|
|
18
|
+
* Signals a workflow pause to the caller.
|
|
19
|
+
* This always throws a typed signal that supervisors can intercept.
|
|
20
|
+
*/
|
|
21
|
+
declare function debugPause(context: DebugPauseContext): Promise<never>;
|
|
22
|
+
|
|
23
|
+
export { type DebugPauseContext, type DebugPauseDetails, DebugPauseSignal, debugPause, isDebugPauseSignal };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
class DebugPauseSignal extends Error {
|
|
2
|
+
details;
|
|
3
|
+
constructor(details) {
|
|
4
|
+
super(`Workflow paused at ${details.url}`);
|
|
5
|
+
this.name = "DebugPauseSignal";
|
|
6
|
+
this.details = details;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function isDebugPauseSignal(error) {
|
|
10
|
+
if (!error || typeof error !== "object") return false;
|
|
11
|
+
const candidate = error;
|
|
12
|
+
if (candidate.name !== "DebugPauseSignal") return false;
|
|
13
|
+
return typeof candidate.details?.sessionName === "string" && typeof candidate.details?.pausedAt === "string" && typeof candidate.details?.url === "string";
|
|
14
|
+
}
|
|
15
|
+
async function debugPause(context) {
|
|
16
|
+
const url = context.page.url();
|
|
17
|
+
const details = {
|
|
18
|
+
sessionName: context.session,
|
|
19
|
+
pausedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
20
|
+
url
|
|
21
|
+
};
|
|
22
|
+
console.log(`[debugPause] Paused at ${url}`);
|
|
23
|
+
console.log("[debugPause] Signaling pause to supervisor...");
|
|
24
|
+
throw new DebugPauseSignal(details);
|
|
25
|
+
}
|
|
26
|
+
export {
|
|
27
|
+
DebugPauseSignal,
|
|
28
|
+
debugPause,
|
|
29
|
+
isDebugPauseSignal
|
|
30
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
enrichTimeoutError: () => enrichTimeoutError
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(errors_exports);
|
|
24
|
+
async function enrichTimeoutError(err, locator, page) {
|
|
25
|
+
const reasons = [];
|
|
26
|
+
try {
|
|
27
|
+
const visible = await locator.isVisible().catch(() => null);
|
|
28
|
+
if (visible === false) {
|
|
29
|
+
reasons.push("Element is not visible");
|
|
30
|
+
}
|
|
31
|
+
if (typeof locator.isInViewport === "function") {
|
|
32
|
+
const inViewport = await locator.isInViewport().catch(() => null);
|
|
33
|
+
if (inViewport === false) {
|
|
34
|
+
reasons.push("Element is outside of the viewport");
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const enabled = await locator.isEnabled().catch(() => null);
|
|
38
|
+
if (enabled === false) {
|
|
39
|
+
reasons.push("Element is not enabled (disabled)");
|
|
40
|
+
}
|
|
41
|
+
if (reasons.length === 0) {
|
|
42
|
+
const box = await locator.boundingBox().catch(() => null);
|
|
43
|
+
if (box) {
|
|
44
|
+
const centerX = box.x + box.width / 2;
|
|
45
|
+
const centerY = box.y + box.height / 2;
|
|
46
|
+
const interceptInfo = await page.evaluate(
|
|
47
|
+
({ x, y }) => {
|
|
48
|
+
const els = document.elementsFromPoint(x, y);
|
|
49
|
+
if (!els || els.length < 2) return null;
|
|
50
|
+
const topEl = els[0];
|
|
51
|
+
if (!topEl) return null;
|
|
52
|
+
const tag = topEl.tagName.toLowerCase();
|
|
53
|
+
const id = topEl.id ? `#${topEl.id}` : "";
|
|
54
|
+
const cls = topEl.className ? `.${String(topEl.className).split(/\s+/).slice(0, 2).join(".")}` : "";
|
|
55
|
+
const text = (topEl.textContent || "").trim().slice(0, 40);
|
|
56
|
+
return {
|
|
57
|
+
tag,
|
|
58
|
+
preview: `<${tag}${id}${cls}>${text ? ` "${text}"` : ""}`
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
{ x: centerX, y: centerY }
|
|
62
|
+
).catch(() => null);
|
|
63
|
+
if (interceptInfo) {
|
|
64
|
+
reasons.push(
|
|
65
|
+
`Element may be intercepted by ${interceptInfo.preview}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
}
|
|
72
|
+
if (reasons.length > 0) {
|
|
73
|
+
const enrichment = `
|
|
74
|
+
[libretto diagnostics] ${reasons.join("; ")}`;
|
|
75
|
+
err.message = (err.message || "") + enrichment;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
79
|
+
0 && (module.exports = {
|
|
80
|
+
enrichTimeoutError
|
|
81
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Locator, Page } from 'playwright';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Enrich a timeout error from a pointer action (click/dblclick/hover) with
|
|
5
|
+
* diagnostic information about why the action may have failed.
|
|
6
|
+
*
|
|
7
|
+
* Mutates err.message in-place to append the enrichment.
|
|
8
|
+
* Best-effort: if any probe fails, we skip that check silently.
|
|
9
|
+
*/
|
|
10
|
+
declare function enrichTimeoutError(err: any, locator: Locator, page: Page): Promise<void>;
|
|
11
|
+
|
|
12
|
+
export { enrichTimeoutError };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Locator, Page } from 'playwright';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Enrich a timeout error from a pointer action (click/dblclick/hover) with
|
|
5
|
+
* diagnostic information about why the action may have failed.
|
|
6
|
+
*
|
|
7
|
+
* Mutates err.message in-place to append the enrichment.
|
|
8
|
+
* Best-effort: if any probe fails, we skip that check silently.
|
|
9
|
+
*/
|
|
10
|
+
declare function enrichTimeoutError(err: any, locator: Locator, page: Page): Promise<void>;
|
|
11
|
+
|
|
12
|
+
export { enrichTimeoutError };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
async function enrichTimeoutError(err, locator, page) {
|
|
2
|
+
const reasons = [];
|
|
3
|
+
try {
|
|
4
|
+
const visible = await locator.isVisible().catch(() => null);
|
|
5
|
+
if (visible === false) {
|
|
6
|
+
reasons.push("Element is not visible");
|
|
7
|
+
}
|
|
8
|
+
if (typeof locator.isInViewport === "function") {
|
|
9
|
+
const inViewport = await locator.isInViewport().catch(() => null);
|
|
10
|
+
if (inViewport === false) {
|
|
11
|
+
reasons.push("Element is outside of the viewport");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const enabled = await locator.isEnabled().catch(() => null);
|
|
15
|
+
if (enabled === false) {
|
|
16
|
+
reasons.push("Element is not enabled (disabled)");
|
|
17
|
+
}
|
|
18
|
+
if (reasons.length === 0) {
|
|
19
|
+
const box = await locator.boundingBox().catch(() => null);
|
|
20
|
+
if (box) {
|
|
21
|
+
const centerX = box.x + box.width / 2;
|
|
22
|
+
const centerY = box.y + box.height / 2;
|
|
23
|
+
const interceptInfo = await page.evaluate(
|
|
24
|
+
({ x, y }) => {
|
|
25
|
+
const els = document.elementsFromPoint(x, y);
|
|
26
|
+
if (!els || els.length < 2) return null;
|
|
27
|
+
const topEl = els[0];
|
|
28
|
+
if (!topEl) return null;
|
|
29
|
+
const tag = topEl.tagName.toLowerCase();
|
|
30
|
+
const id = topEl.id ? `#${topEl.id}` : "";
|
|
31
|
+
const cls = topEl.className ? `.${String(topEl.className).split(/\s+/).slice(0, 2).join(".")}` : "";
|
|
32
|
+
const text = (topEl.textContent || "").trim().slice(0, 40);
|
|
33
|
+
return {
|
|
34
|
+
tag,
|
|
35
|
+
preview: `<${tag}${id}${cls}>${text ? ` "${text}"` : ""}`
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
{ x: centerX, y: centerY }
|
|
39
|
+
).catch(() => null);
|
|
40
|
+
if (interceptInfo) {
|
|
41
|
+
reasons.push(
|
|
42
|
+
`Element may be intercepted by ${interceptInfo.preview}`
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
} catch {
|
|
48
|
+
}
|
|
49
|
+
if (reasons.length > 0) {
|
|
50
|
+
const enrichment = `
|
|
51
|
+
[libretto diagnostics] ${reasons.join("; ")}`;
|
|
52
|
+
err.message = (err.message || "") + enrichment;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
enrichTimeoutError
|
|
57
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var instrumentation_exports = {};
|
|
20
|
+
__export(instrumentation_exports, {
|
|
21
|
+
enrichTimeoutError: () => import_errors.enrichTimeoutError,
|
|
22
|
+
installInstrumentation: () => import_instrument.installInstrumentation,
|
|
23
|
+
instrumentContext: () => import_instrument.instrumentContext,
|
|
24
|
+
instrumentPage: () => import_instrument.instrumentPage
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(instrumentation_exports);
|
|
27
|
+
var import_instrument = require("./instrument.js");
|
|
28
|
+
var import_errors = require("./errors.js");
|
|
29
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
30
|
+
0 && (module.exports = {
|
|
31
|
+
enrichTimeoutError,
|
|
32
|
+
installInstrumentation,
|
|
33
|
+
instrumentContext,
|
|
34
|
+
instrumentPage
|
|
35
|
+
});
|