libretto 0.5.3-experimental.5 → 0.5.3
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 +114 -37
- package/README.template.md +160 -0
- package/dist/cli/cli.js +22 -97
- package/dist/cli/commands/browser.js +86 -59
- package/dist/cli/commands/deploy.js +148 -0
- package/dist/cli/commands/execution.js +218 -96
- package/dist/cli/commands/init.js +34 -29
- package/dist/cli/commands/logs.js +4 -5
- package/dist/cli/commands/shared.js +30 -29
- package/dist/cli/commands/snapshot.js +26 -39
- package/dist/cli/core/ai-config.js +21 -4
- package/dist/cli/core/api-snapshot-analyzer.js +15 -5
- package/dist/cli/core/browser.js +207 -37
- package/dist/cli/core/context.js +4 -1
- package/dist/cli/core/deploy-artifact.js +687 -0
- package/dist/cli/core/session-telemetry.js +434 -174
- package/dist/cli/core/session.js +21 -8
- package/dist/cli/core/snapshot-analyzer.js +14 -31
- package/dist/cli/core/snapshot-api-config.js +2 -6
- package/dist/cli/core/telemetry.js +20 -4
- package/dist/cli/framework/simple-cli.js +144 -43
- package/dist/cli/router.js +16 -21
- package/dist/cli/workers/run-integration-runtime.js +25 -45
- package/dist/cli/workers/run-integration-worker-protocol.js +3 -2
- package/dist/cli/workers/run-integration-worker.js +1 -4
- package/dist/index.d.ts +1 -2
- package/dist/index.js +13 -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 +17 -69
- 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/dom-semantics.d.ts +8 -0
- package/dist/shared/dom-semantics.js +69 -0
- 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/run/api.js +3 -1
- package/dist/shared/run/browser.js +47 -3
- 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 +36 -14
- package/dist/shared/visualization/highlight.js +9 -6
- package/dist/shared/workflow/workflow.d.ts +18 -10
- package/dist/shared/workflow/workflow.js +50 -5
- package/package.json +14 -6
- package/scripts/generate-changelog.ts +132 -0
- package/scripts/postinstall.mjs +4 -3
- package/scripts/skills-libretto.mjs +2 -88
- package/scripts/summarize-evals.mjs +32 -10
- package/skills/libretto/SKILL.md +132 -62
- package/skills/libretto/references/action-logs.md +101 -0
- package/skills/libretto/references/auth-profiles.md +1 -2
- package/skills/libretto/references/code-generation-rules.md +176 -0
- package/skills/libretto/references/configuration-file-reference.md +53 -0
- package/skills/libretto/references/pages-and-page-targeting.md +1 -1
- package/skills/libretto/references/site-security-review.md +143 -0
- package/src/cli/cli.ts +23 -110
- package/src/cli/commands/browser.ts +94 -70
- package/src/cli/commands/deploy.ts +198 -0
- package/src/cli/commands/execution.ts +251 -111
- package/src/cli/commands/init.ts +37 -33
- package/src/cli/commands/logs.ts +7 -7
- package/src/cli/commands/shared.ts +36 -37
- package/src/cli/commands/snapshot.ts +44 -59
- package/src/cli/core/ai-config.ts +24 -4
- package/src/cli/core/api-snapshot-analyzer.ts +17 -6
- package/src/cli/core/browser.ts +260 -49
- package/src/cli/core/context.ts +7 -2
- package/src/cli/core/deploy-artifact.ts +938 -0
- package/src/cli/core/session-telemetry.ts +449 -197
- package/src/cli/core/session.ts +21 -7
- package/src/cli/core/snapshot-analyzer.ts +26 -46
- package/src/cli/core/snapshot-api-config.ts +170 -175
- package/src/cli/core/telemetry.ts +39 -4
- package/src/cli/framework/simple-cli.ts +281 -98
- package/src/cli/router.ts +15 -21
- package/src/cli/workers/run-integration-runtime.ts +35 -57
- package/src/cli/workers/run-integration-worker-protocol.ts +2 -1
- package/src/cli/workers/run-integration-worker.ts +1 -4
- package/src/index.ts +77 -67
- package/src/runtime/download/download.ts +62 -58
- package/src/runtime/download/index.ts +5 -5
- package/src/runtime/extract/extract.ts +71 -61
- package/src/runtime/network/index.ts +3 -3
- package/src/runtime/network/network.ts +99 -93
- package/src/runtime/recovery/agent.ts +217 -212
- package/src/runtime/recovery/errors.ts +107 -104
- package/src/runtime/recovery/index.ts +3 -3
- package/src/runtime/recovery/recovery.ts +38 -35
- package/src/shared/condense-dom/condense-dom.ts +27 -82
- package/src/shared/config/config.ts +0 -19
- package/src/shared/config/index.ts +0 -5
- package/src/shared/debug/pause.ts +57 -51
- package/src/shared/dom-semantics.ts +68 -0
- package/src/shared/instrumentation/errors.ts +64 -62
- package/src/shared/instrumentation/index.ts +5 -5
- package/src/shared/instrumentation/instrument.ts +339 -209
- package/src/shared/llm/ai-sdk-adapter.ts +58 -55
- package/src/shared/llm/client.ts +181 -174
- package/src/shared/llm/types.ts +39 -39
- package/src/shared/logger/index.ts +11 -4
- package/src/shared/logger/logger.ts +312 -306
- package/src/shared/logger/sinks.ts +118 -114
- package/src/shared/paths/paths.ts +50 -49
- package/src/shared/paths/repo-root.ts +17 -17
- package/src/shared/run/api.ts +5 -1
- package/src/shared/run/browser.ts +65 -3
- package/src/shared/state/index.ts +9 -9
- package/src/shared/state/session-state.ts +46 -43
- package/src/shared/visualization/ghost-cursor.ts +180 -149
- package/src/shared/visualization/highlight.ts +89 -86
- package/src/shared/visualization/index.ts +13 -13
- package/src/shared/workflow/workflow.ts +107 -30
- package/scripts/check-skills-sync.mjs +0 -23
- package/scripts/prepare-release.sh +0 -97
- package/skills/libretto/references/reverse-engineering-network-requests.md +0 -75
- package/skills/libretto/references/user-action-log.md +0 -31
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
appendFileSync,
|
|
3
|
+
existsSync,
|
|
4
|
+
readFileSync,
|
|
5
|
+
writeFileSync,
|
|
6
|
+
} from "node:fs";
|
|
2
7
|
import type { Page } from "playwright";
|
|
3
8
|
import {
|
|
4
9
|
getSessionActionsLogPath,
|
|
@@ -21,7 +26,12 @@ export type NetworkLogEntry = {
|
|
|
21
26
|
|
|
22
27
|
export function readNetworkLog(
|
|
23
28
|
session: string,
|
|
24
|
-
opts: {
|
|
29
|
+
opts: {
|
|
30
|
+
last?: number;
|
|
31
|
+
filter?: string;
|
|
32
|
+
method?: string;
|
|
33
|
+
pageId?: string;
|
|
34
|
+
} = {},
|
|
25
35
|
): NetworkLogEntry[] {
|
|
26
36
|
assertSessionStateExistsOrThrow(session);
|
|
27
37
|
const logPath = getSessionNetworkLogPath(session);
|
|
@@ -86,6 +96,15 @@ export type ActionLogEntry = {
|
|
|
86
96
|
action: string;
|
|
87
97
|
source: "user" | "agent";
|
|
88
98
|
selector?: string;
|
|
99
|
+
bestSemanticSelector?: string;
|
|
100
|
+
targetSelector?: string;
|
|
101
|
+
ancestorSelectors?: string[];
|
|
102
|
+
nearbyText?: string;
|
|
103
|
+
composedPath?: string[];
|
|
104
|
+
coordinates?: {
|
|
105
|
+
x: number;
|
|
106
|
+
y: number;
|
|
107
|
+
};
|
|
89
108
|
value?: string;
|
|
90
109
|
url?: string;
|
|
91
110
|
duration?: number;
|
|
@@ -99,7 +118,10 @@ export function parentLogAction(
|
|
|
99
118
|
): void {
|
|
100
119
|
try {
|
|
101
120
|
const record = { ts: new Date().toISOString(), ...entry };
|
|
102
|
-
appendFileSync(
|
|
121
|
+
appendFileSync(
|
|
122
|
+
getSessionActionsLogPath(session),
|
|
123
|
+
JSON.stringify(record) + "\n",
|
|
124
|
+
);
|
|
103
125
|
} catch {}
|
|
104
126
|
}
|
|
105
127
|
|
|
@@ -139,6 +161,11 @@ export function readActionLog(
|
|
|
139
161
|
(e) =>
|
|
140
162
|
re.test(e.action) ||
|
|
141
163
|
re.test(e.selector || "") ||
|
|
164
|
+
re.test(e.bestSemanticSelector || "") ||
|
|
165
|
+
re.test(e.targetSelector || "") ||
|
|
166
|
+
re.test((e.ancestorSelectors || []).join(" ")) ||
|
|
167
|
+
re.test(e.nearbyText || "") ||
|
|
168
|
+
re.test((e.composedPath || []).join(" ")) ||
|
|
142
169
|
re.test(e.value || "") ||
|
|
143
170
|
re.test(e.url || ""),
|
|
144
171
|
);
|
|
@@ -158,8 +185,16 @@ export function readActionLog(
|
|
|
158
185
|
export function formatActionEntry(e: ActionLogEntry): string {
|
|
159
186
|
const time = e.ts.replace(/.*T/, "").replace(/\.\d+Z$/, "");
|
|
160
187
|
const src = e.source.toUpperCase().padEnd(5);
|
|
188
|
+
const displaySelector = e.bestSemanticSelector || e.selector;
|
|
161
189
|
const parts = [`[${time}]`, `[${src}]`, e.action];
|
|
162
|
-
if (
|
|
190
|
+
if (displaySelector) parts.push(displaySelector);
|
|
191
|
+
if (e.targetSelector && e.targetSelector !== displaySelector) {
|
|
192
|
+
parts.push(`target=${e.targetSelector}`);
|
|
193
|
+
}
|
|
194
|
+
if (e.nearbyText) parts.push(`text="${e.nearbyText}"`);
|
|
195
|
+
if (e.coordinates) {
|
|
196
|
+
parts.push(`@(${e.coordinates.x},${e.coordinates.y})`);
|
|
197
|
+
}
|
|
163
198
|
if (e.value) parts.push(`"${e.value}"`);
|
|
164
199
|
if (e.url) parts.push(e.url);
|
|
165
200
|
if (e.duration != null) parts.push(`${e.duration}ms`);
|