libretto 0.2.0 → 0.2.2

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.
Files changed (69) hide show
  1. package/README.md +128 -126
  2. package/dist/cli/cli.js +2 -0
  3. package/dist/cli/commands/browser.js +4 -1
  4. package/dist/cli/commands/execution.js +21 -6
  5. package/dist/cli/commands/logs.js +36 -8
  6. package/dist/cli/commands/snapshot.js +14 -7
  7. package/dist/cli/core/browser.js +89 -253
  8. package/dist/cli/core/session-telemetry.js +491 -0
  9. package/dist/cli/core/telemetry.js +18 -6
  10. package/dist/cli/workers/run-integration-runtime.js +19 -1
  11. package/dist/index.cjs +2 -6
  12. package/dist/index.d.cts +2 -5
  13. package/dist/index.d.ts +2 -5
  14. package/dist/index.js +2 -5
  15. package/dist/runtime/download/download.d.cts +2 -2
  16. package/dist/runtime/download/download.d.ts +2 -2
  17. package/dist/runtime/extract/extract.cjs +2 -1
  18. package/dist/runtime/extract/extract.d.cts +5 -5
  19. package/dist/runtime/extract/extract.d.ts +5 -5
  20. package/dist/runtime/extract/extract.js +2 -1
  21. package/dist/runtime/network/network.d.cts +6 -6
  22. package/dist/runtime/network/network.d.ts +6 -6
  23. package/dist/runtime/recovery/agent.cjs +12 -7
  24. package/dist/runtime/recovery/agent.d.cts +2 -2
  25. package/dist/runtime/recovery/agent.d.ts +2 -2
  26. package/dist/runtime/recovery/agent.js +12 -7
  27. package/dist/runtime/recovery/errors.cjs +8 -6
  28. package/dist/runtime/recovery/errors.d.cts +2 -2
  29. package/dist/runtime/recovery/errors.d.ts +2 -2
  30. package/dist/runtime/recovery/errors.js +8 -6
  31. package/dist/runtime/recovery/recovery.cjs +5 -3
  32. package/dist/runtime/recovery/recovery.d.cts +2 -2
  33. package/dist/runtime/recovery/recovery.d.ts +2 -2
  34. package/dist/runtime/recovery/recovery.js +5 -3
  35. package/dist/shared/instrumentation/instrument.d.cts +2 -2
  36. package/dist/shared/instrumentation/instrument.d.ts +2 -2
  37. package/dist/shared/llm/types.d.cts +5 -5
  38. package/dist/shared/llm/types.d.ts +5 -5
  39. package/dist/shared/logger/index.cjs +2 -0
  40. package/dist/shared/logger/index.d.cts +1 -1
  41. package/dist/shared/logger/index.d.ts +1 -1
  42. package/dist/shared/logger/index.js +2 -1
  43. package/dist/shared/logger/logger.cjs +15 -2
  44. package/dist/shared/logger/logger.d.cts +13 -1
  45. package/dist/shared/logger/logger.d.ts +13 -1
  46. package/dist/shared/logger/logger.js +13 -1
  47. package/dist/shared/state/session-state.d.cts +2 -2
  48. package/dist/shared/state/session-state.d.ts +2 -2
  49. package/package.json +15 -11
  50. package/scripts/postinstall.mjs +48 -0
  51. package/skill/SKILL.md +438 -0
  52. package/skill/code-generation-rules.md +190 -0
  53. package/skill/integration-approach-selection.md +174 -0
  54. package/dist/runtime/step/index.cjs +0 -31
  55. package/dist/runtime/step/index.d.cts +0 -7
  56. package/dist/runtime/step/index.d.ts +0 -7
  57. package/dist/runtime/step/index.js +0 -6
  58. package/dist/runtime/step/runner.cjs +0 -208
  59. package/dist/runtime/step/runner.d.cts +0 -16
  60. package/dist/runtime/step/runner.d.ts +0 -16
  61. package/dist/runtime/step/runner.js +0 -187
  62. package/dist/runtime/step/step.cjs +0 -67
  63. package/dist/runtime/step/step.d.cts +0 -23
  64. package/dist/runtime/step/step.d.ts +0 -23
  65. package/dist/runtime/step/step.js +0 -43
  66. package/dist/runtime/step/types.cjs +0 -16
  67. package/dist/runtime/step/types.d.cts +0 -72
  68. package/dist/runtime/step/types.d.ts +0 -72
  69. package/dist/runtime/step/types.js +0 -0
@@ -1,67 +0,0 @@
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 step_exports = {};
20
- __export(step_exports, {
21
- step: () => step
22
- });
23
- module.exports = __toCommonJS(step_exports);
24
- function step(nameOrHandler, handlerOrOptions, maybeOptions) {
25
- let name;
26
- let handler;
27
- let options;
28
- if (typeof nameOrHandler === "string") {
29
- name = nameOrHandler;
30
- handler = handlerOrOptions;
31
- options = maybeOptions ?? {};
32
- } else {
33
- name = `step-${_autoNameCounter++}`;
34
- handler = nameOrHandler;
35
- options = handlerOrOptions ?? {};
36
- }
37
- return {
38
- name,
39
- handler,
40
- options: {
41
- dryRun: options.dryRun ?? "skip",
42
- simulate: options.simulate,
43
- recovery: options.recovery
44
- }
45
- };
46
- }
47
- let _autoNameCounter = 1;
48
- step.extend = function extend(extendOptions) {
49
- return function extendedStep(nameOrHandler, handlerOrOptions, maybeOptions) {
50
- const baseStep = step(nameOrHandler, handlerOrOptions, maybeOptions);
51
- const mergedRecovery = {
52
- ...extendOptions.recovery,
53
- ...baseStep.options.recovery
54
- };
55
- return {
56
- ...baseStep,
57
- options: {
58
- ...baseStep.options,
59
- recovery: mergedRecovery
60
- }
61
- };
62
- };
63
- };
64
- // Annotate the CommonJS export names for ESM import in node:
65
- 0 && (module.exports = {
66
- step
67
- });
@@ -1,23 +0,0 @@
1
- import { StepHandler, StepOptions, Step, RecoveryHandler } from './types.cjs';
2
- import 'playwright';
3
- import '../../shared/logger/logger.cjs';
4
- import '../../shared/llm/types.cjs';
5
- import 'zod';
6
-
7
- /**
8
- * Creates a Step object from a name, handler, and options.
9
- *
10
- * Usage:
11
- * step("login", async ({ page }) => { ... })
12
- * step("login", async ({ page }) => { ... }, { dryRun: "execute" })
13
- * step(async ({ page }) => { ... }) // auto-named
14
- */
15
- declare function step(nameOrHandler: string | StepHandler, handlerOrOptions?: StepHandler | StepOptions, maybeOptions?: StepOptions): Step;
16
- declare namespace step {
17
- var extend: (extendOptions: ExtendOptions) => (nameOrHandler: string | StepHandler, handlerOrOptions?: StepHandler | StepOptions, maybeOptions?: StepOptions) => Step;
18
- }
19
- type ExtendOptions = {
20
- recovery: Record<string, RecoveryHandler>;
21
- };
22
-
23
- export { type ExtendOptions, step };
@@ -1,23 +0,0 @@
1
- import { StepHandler, StepOptions, Step, RecoveryHandler } from './types.js';
2
- import 'playwright';
3
- import '../../shared/logger/logger.js';
4
- import '../../shared/llm/types.js';
5
- import 'zod';
6
-
7
- /**
8
- * Creates a Step object from a name, handler, and options.
9
- *
10
- * Usage:
11
- * step("login", async ({ page }) => { ... })
12
- * step("login", async ({ page }) => { ... }, { dryRun: "execute" })
13
- * step(async ({ page }) => { ... }) // auto-named
14
- */
15
- declare function step(nameOrHandler: string | StepHandler, handlerOrOptions?: StepHandler | StepOptions, maybeOptions?: StepOptions): Step;
16
- declare namespace step {
17
- var extend: (extendOptions: ExtendOptions) => (nameOrHandler: string | StepHandler, handlerOrOptions?: StepHandler | StepOptions, maybeOptions?: StepOptions) => Step;
18
- }
19
- type ExtendOptions = {
20
- recovery: Record<string, RecoveryHandler>;
21
- };
22
-
23
- export { type ExtendOptions, step };
@@ -1,43 +0,0 @@
1
- function step(nameOrHandler, handlerOrOptions, maybeOptions) {
2
- let name;
3
- let handler;
4
- let options;
5
- if (typeof nameOrHandler === "string") {
6
- name = nameOrHandler;
7
- handler = handlerOrOptions;
8
- options = maybeOptions ?? {};
9
- } else {
10
- name = `step-${_autoNameCounter++}`;
11
- handler = nameOrHandler;
12
- options = handlerOrOptions ?? {};
13
- }
14
- return {
15
- name,
16
- handler,
17
- options: {
18
- dryRun: options.dryRun ?? "skip",
19
- simulate: options.simulate,
20
- recovery: options.recovery
21
- }
22
- };
23
- }
24
- let _autoNameCounter = 1;
25
- step.extend = function extend(extendOptions) {
26
- return function extendedStep(nameOrHandler, handlerOrOptions, maybeOptions) {
27
- const baseStep = step(nameOrHandler, handlerOrOptions, maybeOptions);
28
- const mergedRecovery = {
29
- ...extendOptions.recovery,
30
- ...baseStep.options.recovery
31
- };
32
- return {
33
- ...baseStep,
34
- options: {
35
- ...baseStep.options,
36
- recovery: mergedRecovery
37
- }
38
- };
39
- };
40
- };
41
- export {
42
- step
43
- };
@@ -1,16 +0,0 @@
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 __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
- var types_exports = {};
16
- module.exports = __toCommonJS(types_exports);
@@ -1,72 +0,0 @@
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 };
@@ -1,72 +0,0 @@
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