libretto 0.3.0 → 0.3.1

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 (162) hide show
  1. package/README.md +41 -125
  2. package/dist/cli/cli.js +298 -0
  3. package/dist/cli/commands/ai.js +21 -0
  4. package/dist/cli/commands/browser.js +82 -0
  5. package/dist/cli/commands/execution.js +490 -0
  6. package/dist/cli/commands/init.js +166 -0
  7. package/dist/cli/commands/logs.js +93 -0
  8. package/dist/cli/commands/snapshot.js +106 -0
  9. package/dist/cli/core/ai-config.js +149 -0
  10. package/dist/cli/core/browser.js +652 -0
  11. package/dist/cli/core/context.js +117 -0
  12. package/dist/cli/core/pause-signals.js +29 -0
  13. package/dist/cli/core/session-telemetry.js +491 -0
  14. package/dist/cli/core/session.js +183 -0
  15. package/dist/cli/core/snapshot-analyzer.js +492 -0
  16. package/dist/cli/core/telemetry.js +362 -0
  17. package/dist/cli/index.js +13 -0
  18. package/dist/cli/workers/run-integration-runtime.js +234 -0
  19. package/dist/cli/workers/run-integration-worker-protocol.js +12 -0
  20. package/dist/cli/workers/run-integration-worker.js +67 -0
  21. package/dist/index.cjs +144 -0
  22. package/dist/index.d.cts +21 -0
  23. package/dist/index.d.ts +21 -0
  24. package/dist/index.js +114 -0
  25. package/dist/runtime/download/download.cjs +70 -0
  26. package/dist/runtime/download/download.d.cts +35 -0
  27. package/dist/runtime/download/download.d.ts +35 -0
  28. package/dist/runtime/download/download.js +45 -0
  29. package/dist/runtime/download/index.cjs +30 -0
  30. package/dist/runtime/download/index.d.cts +3 -0
  31. package/dist/runtime/download/index.d.ts +3 -0
  32. package/dist/runtime/download/index.js +8 -0
  33. package/dist/runtime/extract/extract.cjs +88 -0
  34. package/dist/runtime/extract/extract.d.cts +23 -0
  35. package/dist/runtime/extract/extract.d.ts +23 -0
  36. package/dist/runtime/extract/extract.js +64 -0
  37. package/dist/runtime/extract/index.cjs +28 -0
  38. package/dist/runtime/extract/index.d.cts +5 -0
  39. package/dist/runtime/extract/index.d.ts +5 -0
  40. package/dist/runtime/extract/index.js +4 -0
  41. package/dist/runtime/network/index.cjs +28 -0
  42. package/dist/runtime/network/index.d.cts +4 -0
  43. package/dist/runtime/network/index.d.ts +4 -0
  44. package/dist/runtime/network/index.js +6 -0
  45. package/dist/runtime/network/network.cjs +91 -0
  46. package/dist/runtime/network/network.d.cts +28 -0
  47. package/dist/runtime/network/network.d.ts +28 -0
  48. package/dist/runtime/network/network.js +67 -0
  49. package/dist/runtime/recovery/agent.cjs +223 -0
  50. package/dist/runtime/recovery/agent.d.cts +13 -0
  51. package/dist/runtime/recovery/agent.d.ts +13 -0
  52. package/dist/runtime/recovery/agent.js +199 -0
  53. package/dist/runtime/recovery/errors.cjs +124 -0
  54. package/dist/runtime/recovery/errors.d.cts +31 -0
  55. package/dist/runtime/recovery/errors.d.ts +31 -0
  56. package/dist/runtime/recovery/errors.js +100 -0
  57. package/dist/runtime/recovery/index.cjs +34 -0
  58. package/dist/runtime/recovery/index.d.cts +7 -0
  59. package/dist/runtime/recovery/index.d.ts +7 -0
  60. package/dist/runtime/recovery/index.js +10 -0
  61. package/dist/runtime/recovery/recovery.cjs +55 -0
  62. package/dist/runtime/recovery/recovery.d.cts +12 -0
  63. package/dist/runtime/recovery/recovery.d.ts +12 -0
  64. package/dist/runtime/recovery/recovery.js +31 -0
  65. package/dist/shared/config/config.cjs +44 -0
  66. package/dist/shared/config/config.d.cts +10 -0
  67. package/dist/shared/config/config.d.ts +10 -0
  68. package/dist/shared/config/config.js +18 -0
  69. package/dist/shared/config/index.cjs +32 -0
  70. package/dist/shared/config/index.d.cts +1 -0
  71. package/dist/shared/config/index.d.ts +1 -0
  72. package/dist/shared/config/index.js +10 -0
  73. package/dist/shared/debug/index.cjs +30 -0
  74. package/dist/shared/debug/index.d.cts +1 -0
  75. package/dist/shared/debug/index.d.ts +1 -0
  76. package/dist/shared/debug/index.js +5 -0
  77. package/dist/shared/debug/pause.cjs +90 -0
  78. package/dist/shared/debug/pause.d.cts +16 -0
  79. package/dist/shared/debug/pause.d.ts +16 -0
  80. package/dist/shared/debug/pause.js +55 -0
  81. package/dist/shared/instrumentation/errors.cjs +81 -0
  82. package/dist/shared/instrumentation/errors.d.cts +12 -0
  83. package/dist/shared/instrumentation/errors.d.ts +12 -0
  84. package/dist/shared/instrumentation/errors.js +57 -0
  85. package/dist/shared/instrumentation/index.cjs +35 -0
  86. package/dist/shared/instrumentation/index.d.cts +6 -0
  87. package/dist/shared/instrumentation/index.d.ts +6 -0
  88. package/dist/shared/instrumentation/index.js +12 -0
  89. package/dist/shared/instrumentation/instrument.cjs +206 -0
  90. package/dist/shared/instrumentation/instrument.d.cts +32 -0
  91. package/dist/shared/instrumentation/instrument.d.ts +32 -0
  92. package/dist/shared/instrumentation/instrument.js +190 -0
  93. package/dist/shared/llm/ai-sdk-adapter.cjs +67 -0
  94. package/dist/shared/llm/ai-sdk-adapter.d.cts +22 -0
  95. package/dist/shared/llm/ai-sdk-adapter.d.ts +22 -0
  96. package/dist/shared/llm/ai-sdk-adapter.js +43 -0
  97. package/dist/shared/llm/client.cjs +139 -0
  98. package/dist/shared/llm/client.d.cts +6 -0
  99. package/dist/shared/llm/client.d.ts +6 -0
  100. package/dist/shared/llm/client.js +115 -0
  101. package/dist/shared/llm/index.cjs +31 -0
  102. package/dist/shared/llm/index.d.cts +5 -0
  103. package/dist/shared/llm/index.d.ts +5 -0
  104. package/dist/shared/llm/index.js +6 -0
  105. package/dist/shared/llm/types.cjs +16 -0
  106. package/dist/shared/llm/types.d.cts +66 -0
  107. package/dist/shared/llm/types.d.ts +66 -0
  108. package/dist/shared/llm/types.js +0 -0
  109. package/dist/shared/logger/index.cjs +37 -0
  110. package/dist/shared/logger/index.d.cts +2 -0
  111. package/dist/shared/logger/index.d.ts +2 -0
  112. package/dist/shared/logger/index.js +13 -0
  113. package/dist/shared/logger/logger.cjs +232 -0
  114. package/dist/shared/logger/logger.d.cts +86 -0
  115. package/dist/shared/logger/logger.d.ts +86 -0
  116. package/dist/shared/logger/logger.js +207 -0
  117. package/dist/shared/logger/sinks.cjs +160 -0
  118. package/dist/shared/logger/sinks.d.cts +9 -0
  119. package/dist/shared/logger/sinks.d.ts +9 -0
  120. package/dist/shared/logger/sinks.js +124 -0
  121. package/dist/shared/paths/paths.cjs +104 -0
  122. package/dist/shared/paths/paths.d.cts +10 -0
  123. package/dist/shared/paths/paths.d.ts +10 -0
  124. package/dist/shared/paths/paths.js +73 -0
  125. package/dist/shared/run/api.cjs +28 -0
  126. package/dist/shared/run/api.d.cts +2 -0
  127. package/dist/shared/run/api.d.ts +2 -0
  128. package/dist/shared/run/api.js +4 -0
  129. package/dist/shared/run/browser.cjs +98 -0
  130. package/dist/shared/run/browser.d.cts +22 -0
  131. package/dist/shared/run/browser.d.ts +22 -0
  132. package/dist/shared/run/browser.js +74 -0
  133. package/dist/shared/state/index.cjs +38 -0
  134. package/dist/shared/state/index.d.cts +2 -0
  135. package/dist/shared/state/index.d.ts +2 -0
  136. package/dist/shared/state/index.js +16 -0
  137. package/dist/shared/state/session-state.cjs +85 -0
  138. package/dist/shared/state/session-state.d.cts +34 -0
  139. package/dist/shared/state/session-state.d.ts +34 -0
  140. package/dist/shared/state/session-state.js +56 -0
  141. package/dist/shared/visualization/ghost-cursor.cjs +174 -0
  142. package/dist/shared/visualization/ghost-cursor.d.cts +37 -0
  143. package/dist/shared/visualization/ghost-cursor.d.ts +37 -0
  144. package/dist/shared/visualization/ghost-cursor.js +145 -0
  145. package/dist/shared/visualization/highlight.cjs +134 -0
  146. package/dist/shared/visualization/highlight.d.cts +22 -0
  147. package/dist/shared/visualization/highlight.d.ts +22 -0
  148. package/dist/shared/visualization/highlight.js +108 -0
  149. package/dist/shared/visualization/index.cjs +45 -0
  150. package/dist/shared/visualization/index.d.cts +3 -0
  151. package/dist/shared/visualization/index.d.ts +3 -0
  152. package/dist/shared/visualization/index.js +24 -0
  153. package/dist/shared/workflow/workflow.cjs +47 -0
  154. package/dist/shared/workflow/workflow.d.cts +21 -0
  155. package/dist/shared/workflow/workflow.d.ts +21 -0
  156. package/dist/shared/workflow/workflow.js +21 -0
  157. package/package.json +11 -70
  158. package/bin/libretto.mjs +0 -18
  159. package/scripts/postinstall.mjs +0 -48
  160. /package/{skill → .agents/skills/libretto}/SKILL.md +0 -0
  161. /package/{skill → .agents/skills/libretto}/code-generation-rules.md +0 -0
  162. /package/{skill → .agents/skills/libretto}/integration-approach-selection.md +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libretto",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "AI-powered browser automation library and CLI built on Playwright",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -13,79 +13,17 @@
13
13
  },
14
14
  "files": [
15
15
  "dist",
16
- "bin",
17
- "scripts",
18
- "skill"
16
+ ".agents/skills/libretto"
19
17
  ],
20
18
  "bin": {
21
- "libretto": "./bin/libretto.mjs",
22
- "libretto-cli": "./bin/libretto.mjs"
19
+ "libretto": "./dist/cli/index.js",
20
+ "libretto-cli": "./dist/cli/index.js"
23
21
  },
24
22
  "exports": {
25
23
  ".": {
26
24
  "types": "./dist/index.d.ts",
27
25
  "import": "./dist/index.js",
28
26
  "require": "./dist/index.cjs"
29
- },
30
- "./logger": {
31
- "types": "./dist/shared/logger/index.d.ts",
32
- "import": "./dist/shared/logger/index.js",
33
- "require": "./dist/shared/logger/index.cjs"
34
- },
35
- "./recovery": {
36
- "types": "./dist/runtime/recovery/index.d.ts",
37
- "import": "./dist/runtime/recovery/index.js",
38
- "require": "./dist/runtime/recovery/index.cjs"
39
- },
40
- "./extract": {
41
- "types": "./dist/runtime/extract/index.d.ts",
42
- "import": "./dist/runtime/extract/index.js",
43
- "require": "./dist/runtime/extract/index.cjs"
44
- },
45
- "./network": {
46
- "types": "./dist/runtime/network/index.d.ts",
47
- "import": "./dist/runtime/network/index.js",
48
- "require": "./dist/runtime/network/index.cjs"
49
- },
50
- "./download": {
51
- "types": "./dist/runtime/download/index.d.ts",
52
- "import": "./dist/runtime/download/index.js",
53
- "require": "./dist/runtime/download/index.cjs"
54
- },
55
- "./debug": {
56
- "types": "./dist/shared/debug/index.d.ts",
57
- "import": "./dist/shared/debug/index.js",
58
- "require": "./dist/shared/debug/index.cjs"
59
- },
60
- "./config": {
61
- "types": "./dist/shared/config/index.d.ts",
62
- "import": "./dist/shared/config/index.js",
63
- "require": "./dist/shared/config/index.cjs"
64
- },
65
- "./instrumentation": {
66
- "types": "./dist/shared/instrumentation/index.d.ts",
67
- "import": "./dist/shared/instrumentation/index.js",
68
- "require": "./dist/shared/instrumentation/index.cjs"
69
- },
70
- "./visualization": {
71
- "types": "./dist/shared/visualization/index.d.ts",
72
- "import": "./dist/shared/visualization/index.js",
73
- "require": "./dist/shared/visualization/index.cjs"
74
- },
75
- "./llm": {
76
- "types": "./dist/shared/llm/index.d.ts",
77
- "import": "./dist/shared/llm/index.js",
78
- "require": "./dist/shared/llm/index.cjs"
79
- },
80
- "./state": {
81
- "types": "./dist/shared/state/index.d.ts",
82
- "import": "./dist/shared/state/index.js",
83
- "require": "./dist/shared/state/index.cjs"
84
- },
85
- "./run": {
86
- "types": "./dist/shared/run/api.d.ts",
87
- "import": "./dist/shared/run/api.js",
88
- "require": "./dist/shared/run/api.cjs"
89
27
  }
90
28
  },
91
29
  "peerDependencies": {
@@ -106,6 +44,7 @@
106
44
  }
107
45
  },
108
46
  "devDependencies": {
47
+ "@anthropic-ai/claude-agent-sdk": "^0.2.73",
109
48
  "@ai-sdk/anthropic": "^3.0.53",
110
49
  "@ai-sdk/google-vertex": "^4.0.72",
111
50
  "@ai-sdk/openai": "^3.0.39",
@@ -113,7 +52,6 @@
113
52
  "@types/yargs": "^17.0.33",
114
53
  "openai": "^6.27.0",
115
54
  "tsup": "^8.0.0",
116
- "tsx": "^4.19.2",
117
55
  "typescript": "^5.7.0",
118
56
  "vitest": "^4.0.18",
119
57
  "zod": "^3.25.0"
@@ -121,16 +59,19 @@
121
59
  "dependencies": {
122
60
  "ai": "^6.0.110",
123
61
  "playwright": "^1.52.0",
62
+ "tsx": "^4.19.2",
124
63
  "yargs": "^17.7.2"
125
64
  },
126
65
  "scripts": {
127
- "postinstall": "node ./scripts/postinstall.mjs; npx playwright install chromium",
66
+ "postinstall": "npx playwright install chromium",
128
67
  "build": "pnpm run build:runtime && pnpm run build:cli",
129
68
  "build:runtime": "tsup --config tsup.config.ts",
130
69
  "build:cli": "tsup --config tsup.cli.config.ts",
131
70
  "type-check": "tsc --noEmit",
132
- "dev": "tsx src/cli/index.ts",
133
71
  "test": "pnpm run build && vitest run",
134
- "test:watch": "vitest"
72
+ "eval": "pnpm run build && vitest run --config vitest.evals.config.ts",
73
+ "benchmark": "pnpm run build && tsx benchmarks/run.ts",
74
+ "test:watch": "vitest",
75
+ "cli": "node dist/index.js"
135
76
  }
136
77
  }
package/bin/libretto.mjs DELETED
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
- import { existsSync } from "node:fs";
3
- import { dirname, join } from "node:path";
4
- import { fileURLToPath } from "node:url";
5
- import { execSync } from "node:child_process";
6
-
7
- const __dirname = dirname(fileURLToPath(import.meta.url));
8
- const cliRoot = join(__dirname, "..");
9
- const distEntry = join(cliRoot, "dist", "cli", "index.js");
10
-
11
- if (!existsSync(distEntry)) {
12
- // Build from the libretto monorepo root (builds core then CLI in order)
13
- const monorepoRoot = join(cliRoot, "..", "..");
14
- console.error("[libretto] dist not found, building...");
15
- execSync("pnpm build", { cwd: monorepoRoot, stdio: "inherit" });
16
- }
17
-
18
- await import(distEntry);
@@ -1,48 +0,0 @@
1
- import { cpSync, existsSync, lstatSync, mkdirSync } from "node:fs";
2
- import { dirname, join, resolve } from "node:path";
3
- import { fileURLToPath } from "node:url";
4
-
5
- function isDirectory(path) {
6
- if (!existsSync(path)) return false;
7
- return lstatSync(path).isDirectory();
8
- }
9
-
10
- function log(message) {
11
- console.log(`[libretto postinstall] ${message}`);
12
- }
13
-
14
- function main() {
15
- const packageDir = resolve(dirname(fileURLToPath(import.meta.url)), "..");
16
- const initCwd = process.env.INIT_CWD ? resolve(process.env.INIT_CWD) : null;
17
- const installRoot = initCwd ?? process.cwd();
18
-
19
- const sourceSkillDir = join(packageDir, "skill");
20
- if (!isDirectory(sourceSkillDir)) {
21
- log(`Skipped: source skill directory not found at "${sourceSkillDir}".`);
22
- return;
23
- }
24
-
25
- const targets = [
26
- join(installRoot, ".agents", "skills"),
27
- join(installRoot, ".claude", "skills"),
28
- ];
29
-
30
- for (const skillsRoot of targets) {
31
- if (!isDirectory(skillsRoot)) {
32
- log(`Skipped: "${skillsRoot}" does not exist.`);
33
- continue;
34
- }
35
-
36
- const destinationSkillDir = join(skillsRoot, "libretto");
37
- mkdirSync(destinationSkillDir, { recursive: true });
38
- cpSync(sourceSkillDir, destinationSkillDir, { recursive: true, force: true });
39
- log(`Synced skill "libretto" to "${skillsRoot}/libretto".`);
40
- }
41
- }
42
-
43
- try {
44
- main();
45
- } catch (error) {
46
- const message = error instanceof Error ? error.message : String(error);
47
- console.warn(`[libretto postinstall] Warning: ${message}`);
48
- }
File without changes