libretto 0.2.7 → 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.
@@ -18,6 +18,10 @@ import { getPauseSignalPaths, removeSignalIfExists } from "../core/pause-signals
18
18
  import { installSessionTelemetry } from "../core/session-telemetry.js";
19
19
  const LIBRETTO_WORKFLOW_BRAND = /* @__PURE__ */ Symbol.for("libretto.workflow");
20
20
  const FAILURE_HOLD_POLL_INTERVAL_MS = 250;
21
+ const TSCONFIG_HINT = "TypeScript compilation failed. Pass --tsconfig <path> to run against a specific tsconfig.";
22
+ function isTsxCompileError(error) {
23
+ return error instanceof Error && (error.name === "TransformError" || error.message.startsWith("Cannot resolve tsconfig at path:"));
24
+ }
21
25
  function mirrorStdoutToFile(filePath) {
22
26
  const stdout = process.stdout;
23
27
  const originalWrite = stdout.write.bind(stdout);
@@ -91,8 +95,11 @@ async function loadWorkflowExport(absolutePath, exportName) {
91
95
  try {
92
96
  loadedModule = await import(pathToFileURL(absolutePath).href);
93
97
  } catch (error) {
98
+ const message = error instanceof Error ? error.message : String(error);
99
+ const compileHint = isTsxCompileError(error) ? `
100
+ ${TSCONFIG_HINT}` : "";
94
101
  throw new Error(
95
- `Failed to import integration module at ${absolutePath}: ${error instanceof Error ? error.message : String(error)}`
102
+ `Failed to import integration module at ${absolutePath}: ${message}${compileHint}`
96
103
  );
97
104
  }
98
105
  const targetExport = loadedModule[exportName];
@@ -136,7 +143,6 @@ async function runIntegrationInternal(args, options) {
136
143
  await removeSignalIfExists(signalPaths.resumeSignalPath);
137
144
  await removeSignalIfExists(signalPaths.completedSignalPath);
138
145
  await removeSignalIfExists(signalPaths.failedSignalPath);
139
- await removeSignalIfExists(signalPaths.outputSignalPath);
140
146
  const restoreStdout = mirrorStdoutToFile(signalPaths.outputSignalPath);
141
147
  console.log(
142
148
  `Running integration "${args.exportName}" from ${absolutePath} (${args.headless ? "headless" : "headed"})...`
@@ -191,7 +197,8 @@ async function runIntegrationInternal(args, options) {
191
197
  JSON.stringify(
192
198
  {
193
199
  failedAt: (/* @__PURE__ */ new Date()).toISOString(),
194
- message: errorMessage
200
+ message: errorMessage,
201
+ phase: "workflow"
195
202
  },
196
203
  null,
197
204
  2
@@ -51,7 +51,8 @@ async function main() {
51
51
  JSON.stringify(
52
52
  {
53
53
  failedAt: (/* @__PURE__ */ new Date()).toISOString(),
54
- message
54
+ message,
55
+ phase: "setup"
55
56
  },
56
57
  null,
57
58
  2
package/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var index_exports = {};
20
30
  __export(index_exports, {
@@ -57,6 +67,8 @@ __export(index_exports, {
57
67
  workflow: () => import_workflow.workflow
58
68
  });
59
69
  module.exports = __toCommonJS(index_exports);
70
+ var import_node_path = require("node:path");
71
+ var import_node_url = require("node:url");
60
72
  var import_logger = require("./shared/logger/logger.js");
61
73
  var import_sinks = require("./shared/logger/sinks.js");
62
74
  var import_ai_sdk_adapter = require("./shared/llm/ai-sdk-adapter.js");
@@ -74,6 +86,22 @@ var import_ghost_cursor = require("./shared/visualization/ghost-cursor.js");
74
86
  var import_highlight = require("./shared/visualization/highlight.js");
75
87
  var import_api = require("./shared/run/api.js");
76
88
  var import_workflow = require("./shared/workflow/workflow.js");
89
+ const import_meta = {};
90
+ const isDirectExecution = () => {
91
+ const entryArg = process.argv[1];
92
+ if (!entryArg) {
93
+ return false;
94
+ }
95
+ return (0, import_node_url.pathToFileURL)((0, import_node_path.resolve)(entryArg)).href === import_meta.url;
96
+ };
97
+ if (isDirectExecution()) {
98
+ void import("./cli/index.js").catch((error) => {
99
+ const message = error instanceof Error ? error.stack ?? error.message : String(error);
100
+ process.stderr.write(`${message}
101
+ `);
102
+ process.exitCode = 1;
103
+ });
104
+ }
77
105
  // Annotate the CommonJS export names for ESM import in node:
78
106
  0 && (module.exports = {
79
107
  LIBRETTO_WORKFLOW_BRAND,
package/dist/index.js CHANGED
@@ -1,3 +1,5 @@
1
+ import { resolve } from "node:path";
2
+ import { pathToFileURL } from "node:url";
1
3
  import { Logger, defaultLogger } from "./shared/logger/logger.js";
2
4
  import {
3
5
  createFileLogSink,
@@ -56,6 +58,21 @@ import {
56
58
  LIBRETTO_WORKFLOW_BRAND,
57
59
  workflow
58
60
  } from "./shared/workflow/workflow.js";
61
+ const isDirectExecution = () => {
62
+ const entryArg = process.argv[1];
63
+ if (!entryArg) {
64
+ return false;
65
+ }
66
+ return pathToFileURL(resolve(entryArg)).href === import.meta.url;
67
+ };
68
+ if (isDirectExecution()) {
69
+ void import("./cli/index.js").catch((error) => {
70
+ const message = error instanceof Error ? error.stack ?? error.message : String(error);
71
+ process.stderr.write(`${message}
72
+ `);
73
+ process.exitCode = 1;
74
+ });
75
+ }
59
76
  export {
60
77
  LIBRETTO_WORKFLOW_BRAND,
61
78
  LibrettoWorkflow,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libretto",
3
- "version": "0.2.7",
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,91 +13,19 @@
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
- "scripts": {
92
- "postinstall": "node ./scripts/postinstall.mjs; npx playwright install chromium",
93
- "build": "pnpm run build:runtime && pnpm run build:cli",
94
- "build:runtime": "tsup --config tsup.config.ts",
95
- "build:cli": "tsup --config tsup.cli.config.ts",
96
- "type-check": "tsc --noEmit",
97
- "dev": "tsx src/cli/index.ts",
98
- "test": "pnpm run build && vitest run",
99
- "test:watch": "vitest"
100
- },
101
29
  "peerDependencies": {
102
30
  "@ai-sdk/anthropic": "^3.0.0",
103
31
  "@ai-sdk/google-vertex": "^4.0.0",
@@ -105,11 +33,18 @@
105
33
  "zod": ">=3.0.0"
106
34
  },
107
35
  "peerDependenciesMeta": {
108
- "@ai-sdk/anthropic": { "optional": true },
109
- "@ai-sdk/google-vertex": { "optional": true },
110
- "@ai-sdk/openai": { "optional": true }
36
+ "@ai-sdk/anthropic": {
37
+ "optional": true
38
+ },
39
+ "@ai-sdk/google-vertex": {
40
+ "optional": true
41
+ },
42
+ "@ai-sdk/openai": {
43
+ "optional": true
44
+ }
111
45
  },
112
46
  "devDependencies": {
47
+ "@anthropic-ai/claude-agent-sdk": "^0.2.73",
113
48
  "@ai-sdk/anthropic": "^3.0.53",
114
49
  "@ai-sdk/google-vertex": "^4.0.72",
115
50
  "@ai-sdk/openai": "^3.0.39",
@@ -117,7 +52,6 @@
117
52
  "@types/yargs": "^17.0.33",
118
53
  "openai": "^6.27.0",
119
54
  "tsup": "^8.0.0",
120
- "tsx": "^4.19.2",
121
55
  "typescript": "^5.7.0",
122
56
  "vitest": "^4.0.18",
123
57
  "zod": "^3.25.0"
@@ -125,6 +59,19 @@
125
59
  "dependencies": {
126
60
  "ai": "^6.0.110",
127
61
  "playwright": "^1.52.0",
62
+ "tsx": "^4.19.2",
128
63
  "yargs": "^17.7.2"
64
+ },
65
+ "scripts": {
66
+ "postinstall": "npx playwright install chromium",
67
+ "build": "pnpm run build:runtime && pnpm run build:cli",
68
+ "build:runtime": "tsup --config tsup.config.ts",
69
+ "build:cli": "tsup --config tsup.cli.config.ts",
70
+ "type-check": "tsc --noEmit",
71
+ "test": "pnpm run build && vitest run",
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"
129
76
  }
130
- }
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
- }