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.
- package/README.md +128 -126
- package/dist/cli/cli.js +2 -0
- package/dist/cli/commands/browser.js +4 -1
- package/dist/cli/commands/execution.js +21 -6
- package/dist/cli/commands/logs.js +36 -8
- package/dist/cli/commands/snapshot.js +14 -7
- package/dist/cli/core/browser.js +89 -253
- package/dist/cli/core/session-telemetry.js +491 -0
- package/dist/cli/core/telemetry.js +18 -6
- package/dist/cli/workers/run-integration-runtime.js +19 -1
- package/dist/index.cjs +2 -6
- package/dist/index.d.cts +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.js +2 -5
- package/dist/runtime/download/download.d.cts +2 -2
- package/dist/runtime/download/download.d.ts +2 -2
- package/dist/runtime/extract/extract.cjs +2 -1
- package/dist/runtime/extract/extract.d.cts +5 -5
- package/dist/runtime/extract/extract.d.ts +5 -5
- package/dist/runtime/extract/extract.js +2 -1
- package/dist/runtime/network/network.d.cts +6 -6
- package/dist/runtime/network/network.d.ts +6 -6
- package/dist/runtime/recovery/agent.cjs +12 -7
- package/dist/runtime/recovery/agent.d.cts +2 -2
- package/dist/runtime/recovery/agent.d.ts +2 -2
- package/dist/runtime/recovery/agent.js +12 -7
- package/dist/runtime/recovery/errors.cjs +8 -6
- package/dist/runtime/recovery/errors.d.cts +2 -2
- package/dist/runtime/recovery/errors.d.ts +2 -2
- package/dist/runtime/recovery/errors.js +8 -6
- package/dist/runtime/recovery/recovery.cjs +5 -3
- package/dist/runtime/recovery/recovery.d.cts +2 -2
- package/dist/runtime/recovery/recovery.d.ts +2 -2
- package/dist/runtime/recovery/recovery.js +5 -3
- package/dist/shared/instrumentation/instrument.d.cts +2 -2
- package/dist/shared/instrumentation/instrument.d.ts +2 -2
- package/dist/shared/llm/types.d.cts +5 -5
- package/dist/shared/llm/types.d.ts +5 -5
- package/dist/shared/logger/index.cjs +2 -0
- package/dist/shared/logger/index.d.cts +1 -1
- package/dist/shared/logger/index.d.ts +1 -1
- package/dist/shared/logger/index.js +2 -1
- package/dist/shared/logger/logger.cjs +15 -2
- package/dist/shared/logger/logger.d.cts +13 -1
- package/dist/shared/logger/logger.d.ts +13 -1
- package/dist/shared/logger/logger.js +13 -1
- package/dist/shared/state/session-state.d.cts +2 -2
- package/dist/shared/state/session-state.d.ts +2 -2
- package/package.json +15 -11
- package/scripts/postinstall.mjs +48 -0
- package/skill/SKILL.md +438 -0
- package/skill/code-generation-rules.md +190 -0
- package/skill/integration-approach-selection.md +174 -0
- package/dist/runtime/step/index.cjs +0 -31
- package/dist/runtime/step/index.d.cts +0 -7
- package/dist/runtime/step/index.d.ts +0 -7
- package/dist/runtime/step/index.js +0 -6
- package/dist/runtime/step/runner.cjs +0 -208
- package/dist/runtime/step/runner.d.cts +0 -16
- package/dist/runtime/step/runner.d.ts +0 -16
- package/dist/runtime/step/runner.js +0 -187
- package/dist/runtime/step/step.cjs +0 -67
- package/dist/runtime/step/step.d.cts +0 -23
- package/dist/runtime/step/step.d.ts +0 -23
- package/dist/runtime/step/step.js +0 -43
- package/dist/runtime/step/types.cjs +0 -16
- package/dist/runtime/step/types.d.cts +0 -72
- package/dist/runtime/step/types.d.ts +0 -72
- package/dist/runtime/step/types.js +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import z from 'zod';
|
|
2
2
|
|
|
3
3
|
type MessageContentPart = {
|
|
4
4
|
type: "text";
|
|
@@ -19,16 +19,16 @@ type Message = {
|
|
|
19
19
|
* recovery agents, and error detection.
|
|
20
20
|
*/
|
|
21
21
|
interface LLMClient {
|
|
22
|
-
generateObject<T extends ZodType>(opts: {
|
|
22
|
+
generateObject<T extends z.ZodType>(opts: {
|
|
23
23
|
prompt: string;
|
|
24
24
|
schema: T;
|
|
25
25
|
temperature?: number;
|
|
26
|
-
}): Promise<infer<T>>;
|
|
27
|
-
generateObjectFromMessages<T extends ZodType>(opts: {
|
|
26
|
+
}): Promise<z.infer<T>>;
|
|
27
|
+
generateObjectFromMessages<T extends z.ZodType>(opts: {
|
|
28
28
|
messages: Message[];
|
|
29
29
|
schema: T;
|
|
30
30
|
temperature?: number;
|
|
31
|
-
}): Promise<infer<T>>;
|
|
31
|
+
}): Promise<z.infer<T>>;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export type { LLMClient, Message, MessageContentPart };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import z from 'zod';
|
|
2
2
|
|
|
3
3
|
type MessageContentPart = {
|
|
4
4
|
type: "text";
|
|
@@ -19,16 +19,16 @@ type Message = {
|
|
|
19
19
|
* recovery agents, and error detection.
|
|
20
20
|
*/
|
|
21
21
|
interface LLMClient {
|
|
22
|
-
generateObject<T extends ZodType>(opts: {
|
|
22
|
+
generateObject<T extends z.ZodType>(opts: {
|
|
23
23
|
prompt: string;
|
|
24
24
|
schema: T;
|
|
25
25
|
temperature?: number;
|
|
26
|
-
}): Promise<infer<T>>;
|
|
27
|
-
generateObjectFromMessages<T extends ZodType>(opts: {
|
|
26
|
+
}): Promise<z.infer<T>>;
|
|
27
|
+
generateObjectFromMessages<T extends z.ZodType>(opts: {
|
|
28
28
|
messages: Message[];
|
|
29
29
|
schema: T;
|
|
30
30
|
temperature?: number;
|
|
31
|
-
}): Promise<infer<T>>;
|
|
31
|
+
}): Promise<z.infer<T>>;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
export type { LLMClient, Message, MessageContentPart };
|
|
@@ -20,6 +20,7 @@ var logger_exports = {};
|
|
|
20
20
|
__export(logger_exports, {
|
|
21
21
|
Logger: () => import_logger.Logger,
|
|
22
22
|
createFileLogSink: () => import_sinks.createFileLogSink,
|
|
23
|
+
defaultLogger: () => import_logger.defaultLogger,
|
|
23
24
|
jsonlConsoleSink: () => import_sinks.jsonlConsoleSink,
|
|
24
25
|
prettyConsoleSink: () => import_sinks.prettyConsoleSink
|
|
25
26
|
});
|
|
@@ -30,6 +31,7 @@ var import_sinks = require("./sinks.js");
|
|
|
30
31
|
0 && (module.exports = {
|
|
31
32
|
Logger,
|
|
32
33
|
createFileLogSink,
|
|
34
|
+
defaultLogger,
|
|
33
35
|
jsonlConsoleSink,
|
|
34
36
|
prettyConsoleSink
|
|
35
37
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { LogOptions, Logger, LoggerApi, LoggerSink } from './logger.cjs';
|
|
1
|
+
export { LogOptions, Logger, LoggerApi, LoggerSink, MinimalLogger, defaultLogger } from './logger.cjs';
|
|
2
2
|
export { createFileLogSink, jsonlConsoleSink, prettyConsoleSink } from './sinks.cjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { LogOptions, Logger, LoggerApi, LoggerSink } from './logger.js';
|
|
1
|
+
export { LogOptions, Logger, LoggerApi, LoggerSink, MinimalLogger, defaultLogger } from './logger.js';
|
|
2
2
|
export { createFileLogSink, jsonlConsoleSink, prettyConsoleSink } from './sinks.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Logger } from "./logger.js";
|
|
1
|
+
import { Logger, defaultLogger } from "./logger.js";
|
|
2
2
|
import {
|
|
3
3
|
createFileLogSink,
|
|
4
4
|
prettyConsoleSink,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
export {
|
|
8
8
|
Logger,
|
|
9
9
|
createFileLogSink,
|
|
10
|
+
defaultLogger,
|
|
10
11
|
jsonlConsoleSink,
|
|
11
12
|
prettyConsoleSink
|
|
12
13
|
};
|
|
@@ -18,12 +18,24 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var logger_exports = {};
|
|
20
20
|
__export(logger_exports, {
|
|
21
|
-
Logger: () => Logger
|
|
21
|
+
Logger: () => Logger,
|
|
22
|
+
defaultLogger: () => defaultLogger
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(logger_exports);
|
|
24
25
|
function generateId() {
|
|
25
26
|
return Math.random().toString(36).substring(2, 15);
|
|
26
27
|
}
|
|
28
|
+
const defaultLogger = {
|
|
29
|
+
info(event, data) {
|
|
30
|
+
console.log(`[INFO] ${event}`, data ?? "");
|
|
31
|
+
},
|
|
32
|
+
warn(event, data) {
|
|
33
|
+
console.warn(`[WARN] ${event}`, data ?? "");
|
|
34
|
+
},
|
|
35
|
+
error(event, data) {
|
|
36
|
+
console.error(`[ERROR] ${event}`, data ?? "");
|
|
37
|
+
}
|
|
38
|
+
};
|
|
27
39
|
const sinkLifecycleState = /* @__PURE__ */ new WeakMap();
|
|
28
40
|
function getSinkLifecycleState(sink) {
|
|
29
41
|
const existingState = sinkLifecycleState.get(sink);
|
|
@@ -196,5 +208,6 @@ class Logger {
|
|
|
196
208
|
}
|
|
197
209
|
// Annotate the CommonJS export names for ESM import in node:
|
|
198
210
|
0 && (module.exports = {
|
|
199
|
-
Logger
|
|
211
|
+
Logger,
|
|
212
|
+
defaultLogger
|
|
200
213
|
});
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
type LogOptions = {
|
|
2
2
|
timestamp?: Date;
|
|
3
3
|
};
|
|
4
|
+
/**
|
|
5
|
+
* Minimal logger interface accepted by public-facing runtime functions.
|
|
6
|
+
* Any logger with info/warn/error methods satisfies this — no need to
|
|
7
|
+
* implement withScope, withContext, flush, etc.
|
|
8
|
+
*/
|
|
9
|
+
type MinimalLogger = {
|
|
10
|
+
info: (event: string, data?: Record<string, any>) => void;
|
|
11
|
+
warn: (event: string, data?: any) => void;
|
|
12
|
+
error: (event: string, data?: any) => any;
|
|
13
|
+
};
|
|
14
|
+
/** Default console logger used when callers omit the logger option. */
|
|
15
|
+
declare const defaultLogger: MinimalLogger;
|
|
4
16
|
type LoggerApi = {
|
|
5
17
|
log: (event: string, data?: Record<string, any>, options?: LogOptions) => void;
|
|
6
18
|
/**
|
|
@@ -67,4 +79,4 @@ declare class Logger implements LoggerApi {
|
|
|
67
79
|
close(): Promise<void>;
|
|
68
80
|
}
|
|
69
81
|
|
|
70
|
-
export { type LogOptions, Logger, type LoggerApi, type LoggerSink };
|
|
82
|
+
export { type LogOptions, Logger, type LoggerApi, type LoggerSink, type MinimalLogger, defaultLogger };
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
type LogOptions = {
|
|
2
2
|
timestamp?: Date;
|
|
3
3
|
};
|
|
4
|
+
/**
|
|
5
|
+
* Minimal logger interface accepted by public-facing runtime functions.
|
|
6
|
+
* Any logger with info/warn/error methods satisfies this — no need to
|
|
7
|
+
* implement withScope, withContext, flush, etc.
|
|
8
|
+
*/
|
|
9
|
+
type MinimalLogger = {
|
|
10
|
+
info: (event: string, data?: Record<string, any>) => void;
|
|
11
|
+
warn: (event: string, data?: any) => void;
|
|
12
|
+
error: (event: string, data?: any) => any;
|
|
13
|
+
};
|
|
14
|
+
/** Default console logger used when callers omit the logger option. */
|
|
15
|
+
declare const defaultLogger: MinimalLogger;
|
|
4
16
|
type LoggerApi = {
|
|
5
17
|
log: (event: string, data?: Record<string, any>, options?: LogOptions) => void;
|
|
6
18
|
/**
|
|
@@ -67,4 +79,4 @@ declare class Logger implements LoggerApi {
|
|
|
67
79
|
close(): Promise<void>;
|
|
68
80
|
}
|
|
69
81
|
|
|
70
|
-
export { type LogOptions, Logger, type LoggerApi, type LoggerSink };
|
|
82
|
+
export { type LogOptions, Logger, type LoggerApi, type LoggerSink, type MinimalLogger, defaultLogger };
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
function generateId() {
|
|
2
2
|
return Math.random().toString(36).substring(2, 15);
|
|
3
3
|
}
|
|
4
|
+
const defaultLogger = {
|
|
5
|
+
info(event, data) {
|
|
6
|
+
console.log(`[INFO] ${event}`, data ?? "");
|
|
7
|
+
},
|
|
8
|
+
warn(event, data) {
|
|
9
|
+
console.warn(`[WARN] ${event}`, data ?? "");
|
|
10
|
+
},
|
|
11
|
+
error(event, data) {
|
|
12
|
+
console.error(`[ERROR] ${event}`, data ?? "");
|
|
13
|
+
}
|
|
14
|
+
};
|
|
4
15
|
const sinkLifecycleState = /* @__PURE__ */ new WeakMap();
|
|
5
16
|
function getSinkLifecycleState(sink) {
|
|
6
17
|
const existingState = sinkLifecycleState.get(sink);
|
|
@@ -172,5 +183,6 @@ class Logger {
|
|
|
172
183
|
}
|
|
173
184
|
}
|
|
174
185
|
export {
|
|
175
|
-
Logger
|
|
186
|
+
Logger,
|
|
187
|
+
defaultLogger
|
|
176
188
|
};
|
|
@@ -15,14 +15,14 @@ declare const SessionStateFileSchema: z.ZodObject<{
|
|
|
15
15
|
pid: number;
|
|
16
16
|
session: string;
|
|
17
17
|
startedAt: string;
|
|
18
|
-
status?: "
|
|
18
|
+
status?: "active" | "paused" | "completed" | "failed" | "exited" | undefined;
|
|
19
19
|
}, {
|
|
20
20
|
version: 1;
|
|
21
21
|
port: number;
|
|
22
22
|
pid: number;
|
|
23
23
|
session: string;
|
|
24
24
|
startedAt: string;
|
|
25
|
-
status?: "
|
|
25
|
+
status?: "active" | "paused" | "completed" | "failed" | "exited" | undefined;
|
|
26
26
|
}>;
|
|
27
27
|
type SessionStatus = z.infer<typeof SessionStatusSchema>;
|
|
28
28
|
type SessionStateFile = z.infer<typeof SessionStateFileSchema>;
|
|
@@ -15,14 +15,14 @@ declare const SessionStateFileSchema: z.ZodObject<{
|
|
|
15
15
|
pid: number;
|
|
16
16
|
session: string;
|
|
17
17
|
startedAt: string;
|
|
18
|
-
status?: "
|
|
18
|
+
status?: "active" | "paused" | "completed" | "failed" | "exited" | undefined;
|
|
19
19
|
}, {
|
|
20
20
|
version: 1;
|
|
21
21
|
port: number;
|
|
22
22
|
pid: number;
|
|
23
23
|
session: string;
|
|
24
24
|
startedAt: string;
|
|
25
|
-
status?: "
|
|
25
|
+
status?: "active" | "paused" | "completed" | "failed" | "exited" | undefined;
|
|
26
26
|
}>;
|
|
27
27
|
type SessionStatus = z.infer<typeof SessionStatusSchema>;
|
|
28
28
|
type SessionStateFile = z.infer<typeof SessionStateFileSchema>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "libretto",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "AI-powered browser automation library and CLI built on Playwright",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -13,7 +13,9 @@
|
|
|
13
13
|
},
|
|
14
14
|
"files": [
|
|
15
15
|
"dist",
|
|
16
|
-
"bin"
|
|
16
|
+
"bin",
|
|
17
|
+
"scripts",
|
|
18
|
+
"skill"
|
|
17
19
|
],
|
|
18
20
|
"bin": {
|
|
19
21
|
"libretto": "./bin/libretto.mjs",
|
|
@@ -25,11 +27,6 @@
|
|
|
25
27
|
"import": "./dist/index.js",
|
|
26
28
|
"require": "./dist/index.cjs"
|
|
27
29
|
},
|
|
28
|
-
"./step": {
|
|
29
|
-
"types": "./dist/runtime/step/index.d.ts",
|
|
30
|
-
"import": "./dist/runtime/step/index.js",
|
|
31
|
-
"require": "./dist/runtime/step/index.cjs"
|
|
32
|
-
},
|
|
33
30
|
"./logger": {
|
|
34
31
|
"types": "./dist/shared/logger/index.d.ts",
|
|
35
32
|
"import": "./dist/shared/logger/index.js",
|
|
@@ -98,7 +95,7 @@
|
|
|
98
95
|
"build:cli": "tsup --config tsup.cli.config.ts",
|
|
99
96
|
"type-check": "tsc --noEmit",
|
|
100
97
|
"dev": "tsx src/cli/index.ts",
|
|
101
|
-
"test": "vitest run",
|
|
98
|
+
"test": "pnpm run build && vitest run",
|
|
102
99
|
"test:watch": "vitest"
|
|
103
100
|
},
|
|
104
101
|
"peerDependencies": {
|
|
@@ -108,9 +105,15 @@
|
|
|
108
105
|
"zod": ">=3.0.0"
|
|
109
106
|
},
|
|
110
107
|
"peerDependenciesMeta": {
|
|
111
|
-
"@ai-sdk/anthropic": {
|
|
112
|
-
|
|
113
|
-
|
|
108
|
+
"@ai-sdk/anthropic": {
|
|
109
|
+
"optional": true
|
|
110
|
+
},
|
|
111
|
+
"@ai-sdk/google-vertex": {
|
|
112
|
+
"optional": true
|
|
113
|
+
},
|
|
114
|
+
"@ai-sdk/openai": {
|
|
115
|
+
"optional": true
|
|
116
|
+
}
|
|
114
117
|
},
|
|
115
118
|
"devDependencies": {
|
|
116
119
|
"@ai-sdk/anthropic": "^3.0.53",
|
|
@@ -118,6 +121,7 @@
|
|
|
118
121
|
"@ai-sdk/openai": "^3.0.39",
|
|
119
122
|
"@types/node": "^25.3.3",
|
|
120
123
|
"@types/yargs": "^17.0.33",
|
|
124
|
+
"openai": "^6.27.0",
|
|
121
125
|
"tsup": "^8.0.0",
|
|
122
126
|
"tsx": "^4.19.2",
|
|
123
127
|
"typescript": "^5.7.0",
|
|
@@ -0,0 +1,48 @@
|
|
|
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
|
+
}
|