libretto 0.4.4 → 0.5.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.
- package/README.md +106 -36
- package/dist/cli/cli.js +39 -113
- package/dist/cli/commands/ai.js +1 -1
- package/dist/cli/commands/browser.js +87 -60
- package/dist/cli/commands/execution.js +201 -88
- package/dist/cli/commands/init.js +30 -8
- package/dist/cli/commands/logs.js +5 -6
- package/dist/cli/commands/shared.js +30 -29
- package/dist/cli/commands/snapshot.js +26 -39
- package/dist/cli/core/ai-config.js +9 -2
- package/dist/cli/core/api-snapshot-analyzer.js +15 -5
- package/dist/cli/core/browser.js +141 -33
- package/dist/cli/core/context.js +7 -18
- package/dist/cli/core/session-telemetry.js +5 -2
- package/dist/cli/core/session.js +23 -10
- package/dist/cli/core/snapshot-analyzer.js +16 -33
- package/dist/cli/core/snapshot-api-config.js +2 -6
- package/dist/cli/core/telemetry.js +10 -2
- package/dist/cli/framework/simple-cli.js +45 -25
- package/dist/cli/router.js +14 -21
- package/dist/cli/workers/run-integration-runtime.js +26 -7
- package/dist/cli/workers/run-integration-worker-protocol.js +3 -1
- package/dist/cli/workers/run-integration-worker.js +1 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.js +7 -10
- package/dist/runtime/download/download.js +5 -1
- package/dist/runtime/extract/extract.js +11 -2
- package/dist/runtime/network/network.js +8 -1
- package/dist/runtime/recovery/agent.js +6 -2
- package/dist/runtime/recovery/errors.js +3 -1
- package/dist/runtime/recovery/recovery.js +3 -1
- package/dist/shared/condense-dom/condense-dom.js +6 -13
- package/dist/shared/config/config.d.ts +1 -9
- package/dist/shared/config/config.js +0 -18
- package/dist/shared/config/index.d.ts +2 -1
- package/dist/shared/config/index.js +0 -10
- package/dist/shared/debug/pause.js +9 -3
- package/dist/shared/instrumentation/instrument.js +101 -5
- package/dist/shared/llm/ai-sdk-adapter.js +3 -1
- package/dist/shared/llm/client.js +3 -1
- package/dist/shared/logger/index.js +4 -1
- package/dist/shared/paths/paths.js +2 -1
- package/dist/shared/paths/repo-root.d.ts +3 -0
- package/dist/shared/paths/repo-root.js +24 -0
- package/dist/shared/run/api.js +3 -1
- package/dist/shared/run/browser.js +7 -2
- package/dist/shared/state/session-state.d.ts +2 -1
- package/dist/shared/state/session-state.js +5 -2
- package/dist/shared/visualization/ghost-cursor.js +19 -10
- package/dist/shared/visualization/highlight.js +9 -6
- package/dist/shared/workflow/workflow.d.ts +4 -5
- package/dist/shared/workflow/workflow.js +3 -5
- package/package.json +11 -8
- package/scripts/check-skills-sync.mjs +25 -0
- package/scripts/compare-eval-summary.mjs +47 -0
- package/scripts/postinstall.mjs +26 -17
- package/scripts/prepare-release.sh +97 -0
- package/scripts/skills-libretto.mjs +103 -0
- package/scripts/summarize-evals.mjs +135 -0
- package/scripts/sync-skills.mjs +12 -0
- package/skills/libretto/SKILL.md +130 -377
- package/skills/libretto/references/auth-profiles.md +30 -0
- package/skills/libretto/{code-generation-rules.md → references/code-generation-rules.md} +27 -42
- package/skills/libretto/references/configuration-file-reference.md +53 -0
- package/skills/libretto/references/pages-and-page-targeting.md +29 -0
- package/skills/libretto/references/site-security-review.md +143 -0
- package/src/cli/cli.ts +86 -0
- package/src/cli/commands/ai.ts +35 -0
- package/src/cli/commands/browser.ts +189 -0
- package/src/cli/commands/execution.ts +822 -0
- package/src/cli/commands/init.ts +350 -0
- package/src/cli/commands/logs.ts +128 -0
- package/src/cli/commands/shared.ts +69 -0
- package/src/cli/commands/snapshot.ts +312 -0
- package/src/cli/core/ai-config.ts +264 -0
- package/src/cli/core/api-snapshot-analyzer.ts +108 -0
- package/src/cli/core/browser.ts +976 -0
- package/src/cli/core/context.ts +127 -0
- package/src/cli/core/pause-signals.ts +35 -0
- package/src/cli/core/session-telemetry.ts +564 -0
- package/src/cli/core/session.ts +223 -0
- package/src/cli/core/snapshot-analyzer.ts +855 -0
- package/src/cli/core/snapshot-api-config.ts +231 -0
- package/src/cli/core/telemetry.ts +459 -0
- package/src/cli/framework/simple-cli.ts +1340 -0
- package/src/cli/index.ts +13 -0
- package/src/cli/router.ts +20 -0
- package/src/cli/workers/run-integration-runtime.ts +338 -0
- package/src/cli/workers/run-integration-worker-protocol.ts +16 -0
- package/src/cli/workers/run-integration-worker.ts +72 -0
- package/src/index.ts +127 -0
- package/src/runtime/download/download.ts +104 -0
- package/src/runtime/download/index.ts +7 -0
- package/src/runtime/extract/extract.ts +102 -0
- package/src/runtime/extract/index.ts +1 -0
- package/src/runtime/network/index.ts +5 -0
- package/src/runtime/network/network.ts +119 -0
- package/{dist/runtime/recovery/agent.cjs → src/runtime/recovery/agent.ts} +114 -76
- package/src/runtime/recovery/errors.ts +155 -0
- package/src/runtime/recovery/index.ts +7 -0
- package/src/runtime/recovery/recovery.ts +53 -0
- package/{dist/shared/condense-dom/condense-dom.cjs → src/shared/condense-dom/condense-dom.ts} +249 -124
- package/src/shared/config/config.ts +3 -0
- package/src/shared/config/index.ts +0 -0
- package/src/shared/debug/index.ts +1 -0
- package/src/shared/debug/pause.ts +91 -0
- package/src/shared/instrumentation/errors.ts +84 -0
- package/src/shared/instrumentation/index.ts +9 -0
- package/src/shared/instrumentation/instrument.ts +406 -0
- package/src/shared/llm/ai-sdk-adapter.ts +81 -0
- package/{dist/shared/llm/client.cjs → src/shared/llm/client.ts} +86 -80
- package/src/shared/llm/index.ts +3 -0
- package/src/shared/llm/types.ts +63 -0
- package/src/shared/logger/index.ts +13 -0
- package/src/shared/logger/logger.ts +358 -0
- package/src/shared/logger/sinks.ts +148 -0
- package/src/shared/paths/paths.ts +110 -0
- package/src/shared/paths/repo-root.ts +27 -0
- package/src/shared/run/api.ts +6 -0
- package/src/shared/run/browser.ts +107 -0
- package/src/shared/state/index.ts +11 -0
- package/src/shared/state/session-state.ts +77 -0
- package/src/shared/visualization/ghost-cursor.ts +213 -0
- package/src/shared/visualization/highlight.ts +149 -0
- package/src/shared/visualization/index.ts +18 -0
- package/src/shared/workflow/workflow.ts +36 -0
- package/dist/index.cjs +0 -144
- package/dist/index.d.cts +0 -21
- package/dist/runtime/download/download.cjs +0 -70
- package/dist/runtime/download/download.d.cts +0 -35
- package/dist/runtime/download/index.cjs +0 -30
- package/dist/runtime/download/index.d.cts +0 -3
- package/dist/runtime/extract/extract.cjs +0 -88
- package/dist/runtime/extract/extract.d.cts +0 -23
- package/dist/runtime/extract/index.cjs +0 -28
- package/dist/runtime/extract/index.d.cts +0 -5
- package/dist/runtime/network/index.cjs +0 -28
- package/dist/runtime/network/index.d.cts +0 -4
- package/dist/runtime/network/network.cjs +0 -91
- package/dist/runtime/network/network.d.cts +0 -28
- package/dist/runtime/recovery/agent.d.cts +0 -13
- package/dist/runtime/recovery/errors.cjs +0 -124
- package/dist/runtime/recovery/errors.d.cts +0 -31
- package/dist/runtime/recovery/index.cjs +0 -34
- package/dist/runtime/recovery/index.d.cts +0 -7
- package/dist/runtime/recovery/recovery.cjs +0 -55
- package/dist/runtime/recovery/recovery.d.cts +0 -12
- package/dist/shared/condense-dom/condense-dom.d.cts +0 -34
- package/dist/shared/config/config.cjs +0 -44
- package/dist/shared/config/config.d.cts +0 -10
- package/dist/shared/config/index.cjs +0 -32
- package/dist/shared/config/index.d.cts +0 -1
- package/dist/shared/debug/index.cjs +0 -28
- package/dist/shared/debug/index.d.cts +0 -1
- package/dist/shared/debug/pause.cjs +0 -86
- package/dist/shared/debug/pause.d.cts +0 -12
- package/dist/shared/instrumentation/errors.cjs +0 -81
- package/dist/shared/instrumentation/errors.d.cts +0 -12
- package/dist/shared/instrumentation/index.cjs +0 -35
- package/dist/shared/instrumentation/index.d.cts +0 -6
- package/dist/shared/instrumentation/instrument.cjs +0 -206
- package/dist/shared/instrumentation/instrument.d.cts +0 -32
- package/dist/shared/llm/ai-sdk-adapter.cjs +0 -71
- package/dist/shared/llm/ai-sdk-adapter.d.cts +0 -22
- package/dist/shared/llm/client.d.cts +0 -13
- package/dist/shared/llm/index.cjs +0 -31
- package/dist/shared/llm/index.d.cts +0 -5
- package/dist/shared/llm/types.cjs +0 -16
- package/dist/shared/llm/types.d.cts +0 -67
- package/dist/shared/logger/index.cjs +0 -37
- package/dist/shared/logger/index.d.cts +0 -2
- package/dist/shared/logger/logger.cjs +0 -232
- package/dist/shared/logger/logger.d.cts +0 -86
- package/dist/shared/logger/sinks.cjs +0 -160
- package/dist/shared/logger/sinks.d.cts +0 -9
- package/dist/shared/paths/paths.cjs +0 -104
- package/dist/shared/paths/paths.d.cts +0 -10
- package/dist/shared/run/api.cjs +0 -28
- package/dist/shared/run/api.d.cts +0 -2
- package/dist/shared/run/browser.cjs +0 -98
- package/dist/shared/run/browser.d.cts +0 -22
- package/dist/shared/state/index.cjs +0 -38
- package/dist/shared/state/index.d.cts +0 -2
- package/dist/shared/state/session-state.cjs +0 -92
- package/dist/shared/state/session-state.d.cts +0 -40
- package/dist/shared/visualization/ghost-cursor.cjs +0 -174
- package/dist/shared/visualization/ghost-cursor.d.cts +0 -37
- package/dist/shared/visualization/highlight.cjs +0 -134
- package/dist/shared/visualization/highlight.d.cts +0 -22
- package/dist/shared/visualization/index.cjs +0 -45
- package/dist/shared/visualization/index.d.cts +0 -3
- package/dist/shared/workflow/workflow.cjs +0 -47
- package/dist/shared/workflow/workflow.d.cts +0 -21
- package/skills/libretto/integration-approach-selection.md +0 -174
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import {
|
|
3
|
+
runClose as runCloseWithLogger,
|
|
4
|
+
runCloseAll as runCloseAllWithLogger,
|
|
5
|
+
runConnect as runConnectWithLogger,
|
|
6
|
+
runOpen,
|
|
7
|
+
runPages,
|
|
8
|
+
runSave,
|
|
9
|
+
} from "../core/browser.js";
|
|
10
|
+
import { createLoggerForSession, withSessionLogger } from "../core/context.js";
|
|
11
|
+
import {
|
|
12
|
+
assertSessionAvailableForStart,
|
|
13
|
+
validateSessionName,
|
|
14
|
+
} from "../core/session.js";
|
|
15
|
+
import { SimpleCLI } from "../framework/simple-cli.js";
|
|
16
|
+
import {
|
|
17
|
+
sessionOption,
|
|
18
|
+
withAutoSession,
|
|
19
|
+
withRequiredSession,
|
|
20
|
+
} from "./shared.js";
|
|
21
|
+
|
|
22
|
+
export function parseViewportArg(
|
|
23
|
+
viewportArg: string | undefined,
|
|
24
|
+
): { width: number; height: number } | undefined {
|
|
25
|
+
if (!viewportArg) return undefined;
|
|
26
|
+
|
|
27
|
+
const match = viewportArg.match(/^(\d+)x(\d+)$/i);
|
|
28
|
+
if (!match) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
"Invalid --viewport format. Expected WIDTHxHEIGHT (e.g. 1920x1080).",
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const width = Number(match[1]);
|
|
35
|
+
const height = Number(match[2]);
|
|
36
|
+
if (width < 1 || height < 1) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
"Invalid --viewport dimensions. Width and height must be at least 1.",
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return { width, height };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export const openInput = SimpleCLI.input({
|
|
46
|
+
positionals: [
|
|
47
|
+
SimpleCLI.positional("url", z.string().optional(), {
|
|
48
|
+
help: "URL to open",
|
|
49
|
+
}),
|
|
50
|
+
],
|
|
51
|
+
named: {
|
|
52
|
+
session: sessionOption(),
|
|
53
|
+
headed: SimpleCLI.flag({ help: "Run browser in headed mode" }),
|
|
54
|
+
headless: SimpleCLI.flag({ help: "Run browser in headless mode" }),
|
|
55
|
+
viewport: SimpleCLI.option(z.string().optional(), {
|
|
56
|
+
help: "Viewport size as WIDTHxHEIGHT (e.g. 1920x1080)",
|
|
57
|
+
}),
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
.refine(
|
|
61
|
+
(input) => Boolean(input.url),
|
|
62
|
+
`Usage: libretto open <url> [--headless] [--viewport WxH] [--session <name>]`,
|
|
63
|
+
)
|
|
64
|
+
.refine(
|
|
65
|
+
(input) => !(input.headed && input.headless),
|
|
66
|
+
"Cannot pass both --headed and --headless.",
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
export const openCommand = SimpleCLI.command({
|
|
70
|
+
description: "Launch browser and open URL (headed by default)",
|
|
71
|
+
})
|
|
72
|
+
.input(openInput)
|
|
73
|
+
.use(withAutoSession())
|
|
74
|
+
.handle(async ({ input, ctx }) => {
|
|
75
|
+
assertSessionAvailableForStart(ctx.session, ctx.logger);
|
|
76
|
+
const headed = input.headed || !input.headless;
|
|
77
|
+
const viewport = parseViewportArg(input.viewport);
|
|
78
|
+
await runOpen(input.url!, headed, ctx.session, ctx.logger, { viewport });
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
export const connectInput = SimpleCLI.input({
|
|
82
|
+
positionals: [
|
|
83
|
+
SimpleCLI.positional("cdpUrl", z.string().optional(), {
|
|
84
|
+
help: "CDP endpoint URL (e.g. http://127.0.0.1:9222)",
|
|
85
|
+
}),
|
|
86
|
+
],
|
|
87
|
+
named: {
|
|
88
|
+
session: sessionOption(),
|
|
89
|
+
},
|
|
90
|
+
}).refine(
|
|
91
|
+
(input) => Boolean(input.cdpUrl),
|
|
92
|
+
`Usage: libretto connect <cdp-url> --session <name>`,
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
export const connectCommand = SimpleCLI.command({
|
|
96
|
+
description: "Connect to an existing Chrome DevTools Protocol (CDP) endpoint",
|
|
97
|
+
})
|
|
98
|
+
.input(connectInput)
|
|
99
|
+
.use(withAutoSession())
|
|
100
|
+
.handle(async ({ input, ctx }) => {
|
|
101
|
+
await runConnectWithLogger(input.cdpUrl!, ctx.session, ctx.logger);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
export const saveInput = SimpleCLI.input({
|
|
105
|
+
positionals: [
|
|
106
|
+
SimpleCLI.positional("urlOrDomain", z.string().optional(), {
|
|
107
|
+
help: "URL or domain to save",
|
|
108
|
+
}),
|
|
109
|
+
],
|
|
110
|
+
named: {
|
|
111
|
+
session: sessionOption(),
|
|
112
|
+
},
|
|
113
|
+
}).refine(
|
|
114
|
+
(input) => Boolean(input.urlOrDomain),
|
|
115
|
+
`Usage: libretto save <url|domain> --session <name>`,
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
export const saveCommand = SimpleCLI.command({
|
|
119
|
+
description: "Save current browser session",
|
|
120
|
+
})
|
|
121
|
+
.input(saveInput)
|
|
122
|
+
.use(withRequiredSession())
|
|
123
|
+
.handle(async ({ input, ctx }) => {
|
|
124
|
+
await runSave(input.urlOrDomain!, ctx.session, ctx.logger);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
export const pagesInput = SimpleCLI.input({
|
|
128
|
+
positionals: [],
|
|
129
|
+
named: {
|
|
130
|
+
session: sessionOption(),
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
export const pagesCommand = SimpleCLI.command({
|
|
135
|
+
description: "List open pages in the session",
|
|
136
|
+
})
|
|
137
|
+
.input(pagesInput)
|
|
138
|
+
.use(withRequiredSession())
|
|
139
|
+
.handle(async ({ ctx }) => {
|
|
140
|
+
await runPages(ctx.session, ctx.logger);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
export const closeInput = SimpleCLI.input({
|
|
144
|
+
positionals: [],
|
|
145
|
+
named: {
|
|
146
|
+
session: sessionOption(),
|
|
147
|
+
all: SimpleCLI.flag({
|
|
148
|
+
help: "Close all tracked sessions in this workspace",
|
|
149
|
+
}),
|
|
150
|
+
force: SimpleCLI.flag({
|
|
151
|
+
help: "Force kill sessions that ignore SIGTERM (requires --all)",
|
|
152
|
+
}),
|
|
153
|
+
},
|
|
154
|
+
}).refine(
|
|
155
|
+
(input) => input.all || input.session,
|
|
156
|
+
`Usage: libretto close --session <name>\nUsage: libretto close --all [--force]`,
|
|
157
|
+
);
|
|
158
|
+
|
|
159
|
+
export const closeCommand = SimpleCLI.command({
|
|
160
|
+
description: "Close the browser",
|
|
161
|
+
})
|
|
162
|
+
.input(closeInput)
|
|
163
|
+
.handle(async ({ input }) => {
|
|
164
|
+
if (input.force && !input.all) {
|
|
165
|
+
throw new Error(`Usage: libretto close --all [--force]`);
|
|
166
|
+
}
|
|
167
|
+
if (input.all) {
|
|
168
|
+
const logger = createLoggerForSession("cli");
|
|
169
|
+
await runCloseAllWithLogger(logger, { force: input.force });
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
validateSessionName(input.session!);
|
|
173
|
+
const logger = createLoggerForSession(input.session!);
|
|
174
|
+
await runCloseWithLogger(input.session!, logger);
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export const browserCommands = {
|
|
178
|
+
open: openCommand,
|
|
179
|
+
connect: connectCommand,
|
|
180
|
+
save: saveCommand,
|
|
181
|
+
pages: pagesCommand,
|
|
182
|
+
close: closeCommand,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
export async function runClose(session: string): Promise<void> {
|
|
186
|
+
await withSessionLogger(session, async (logger) => {
|
|
187
|
+
await runCloseWithLogger(session, logger);
|
|
188
|
+
});
|
|
189
|
+
}
|