libretto 0.3.0 → 0.3.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 +51 -125
- package/dist/cli/cli.js +298 -0
- package/dist/cli/commands/ai.js +21 -0
- package/dist/cli/commands/browser.js +103 -0
- package/dist/cli/commands/execution.js +490 -0
- package/dist/cli/commands/init.js +166 -0
- package/dist/cli/commands/logs.js +93 -0
- package/dist/cli/commands/snapshot.js +217 -0
- package/dist/cli/core/ai-config.js +156 -0
- package/dist/cli/core/browser.js +669 -0
- package/dist/cli/core/context.js +117 -0
- package/dist/cli/core/pause-signals.js +29 -0
- package/dist/cli/core/session-telemetry.js +491 -0
- package/dist/cli/core/session.js +183 -0
- package/dist/cli/core/snapshot-analyzer.js +570 -0
- package/dist/cli/core/telemetry.js +362 -0
- package/dist/cli/index.js +14 -0
- package/dist/cli/workers/run-integration-runtime.js +234 -0
- package/dist/cli/workers/run-integration-worker-protocol.js +12 -0
- package/dist/cli/workers/run-integration-worker.js +67 -0
- package/dist/index.cjs +144 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +114 -0
- package/dist/runtime/download/download.cjs +70 -0
- package/dist/runtime/download/download.d.cts +35 -0
- package/dist/runtime/download/download.d.ts +35 -0
- package/dist/runtime/download/download.js +45 -0
- package/dist/runtime/download/index.cjs +30 -0
- package/dist/runtime/download/index.d.cts +3 -0
- package/dist/runtime/download/index.d.ts +3 -0
- package/dist/runtime/download/index.js +8 -0
- package/dist/runtime/extract/extract.cjs +88 -0
- package/dist/runtime/extract/extract.d.cts +23 -0
- package/dist/runtime/extract/extract.d.ts +23 -0
- package/dist/runtime/extract/extract.js +64 -0
- package/dist/runtime/extract/index.cjs +28 -0
- package/dist/runtime/extract/index.d.cts +5 -0
- package/dist/runtime/extract/index.d.ts +5 -0
- package/dist/runtime/extract/index.js +4 -0
- package/dist/runtime/network/index.cjs +28 -0
- package/dist/runtime/network/index.d.cts +4 -0
- package/dist/runtime/network/index.d.ts +4 -0
- package/dist/runtime/network/index.js +6 -0
- package/dist/runtime/network/network.cjs +91 -0
- package/dist/runtime/network/network.d.cts +28 -0
- package/dist/runtime/network/network.d.ts +28 -0
- package/dist/runtime/network/network.js +67 -0
- package/dist/runtime/recovery/agent.cjs +223 -0
- package/dist/runtime/recovery/agent.d.cts +13 -0
- package/dist/runtime/recovery/agent.d.ts +13 -0
- package/dist/runtime/recovery/agent.js +199 -0
- package/dist/runtime/recovery/errors.cjs +124 -0
- package/dist/runtime/recovery/errors.d.cts +31 -0
- package/dist/runtime/recovery/errors.d.ts +31 -0
- package/dist/runtime/recovery/errors.js +100 -0
- package/dist/runtime/recovery/index.cjs +34 -0
- package/dist/runtime/recovery/index.d.cts +7 -0
- package/dist/runtime/recovery/index.d.ts +7 -0
- package/dist/runtime/recovery/index.js +10 -0
- package/dist/runtime/recovery/recovery.cjs +55 -0
- package/dist/runtime/recovery/recovery.d.cts +12 -0
- package/dist/runtime/recovery/recovery.d.ts +12 -0
- package/dist/runtime/recovery/recovery.js +31 -0
- package/dist/shared/config/config.cjs +44 -0
- package/dist/shared/config/config.d.cts +10 -0
- package/dist/shared/config/config.d.ts +10 -0
- package/dist/shared/config/config.js +18 -0
- package/dist/shared/config/index.cjs +32 -0
- package/dist/shared/config/index.d.cts +1 -0
- package/dist/shared/config/index.d.ts +1 -0
- package/dist/shared/config/index.js +10 -0
- package/dist/shared/debug/index.cjs +30 -0
- package/dist/shared/debug/index.d.cts +1 -0
- package/dist/shared/debug/index.d.ts +1 -0
- package/dist/shared/debug/index.js +5 -0
- package/dist/shared/debug/pause.cjs +90 -0
- package/dist/shared/debug/pause.d.cts +16 -0
- package/dist/shared/debug/pause.d.ts +16 -0
- package/dist/shared/debug/pause.js +55 -0
- package/dist/shared/instrumentation/errors.cjs +81 -0
- package/dist/shared/instrumentation/errors.d.cts +12 -0
- package/dist/shared/instrumentation/errors.d.ts +12 -0
- package/dist/shared/instrumentation/errors.js +57 -0
- package/dist/shared/instrumentation/index.cjs +35 -0
- package/dist/shared/instrumentation/index.d.cts +6 -0
- package/dist/shared/instrumentation/index.d.ts +6 -0
- package/dist/shared/instrumentation/index.js +12 -0
- package/dist/shared/instrumentation/instrument.cjs +206 -0
- package/dist/shared/instrumentation/instrument.d.cts +32 -0
- package/dist/shared/instrumentation/instrument.d.ts +32 -0
- package/dist/shared/instrumentation/instrument.js +190 -0
- package/dist/shared/llm/ai-sdk-adapter.cjs +67 -0
- package/dist/shared/llm/ai-sdk-adapter.d.cts +22 -0
- package/dist/shared/llm/ai-sdk-adapter.d.ts +22 -0
- package/dist/shared/llm/ai-sdk-adapter.js +43 -0
- package/dist/shared/llm/client.cjs +139 -0
- package/dist/shared/llm/client.d.cts +6 -0
- package/dist/shared/llm/client.d.ts +6 -0
- package/dist/shared/llm/client.js +115 -0
- package/dist/shared/llm/index.cjs +31 -0
- package/dist/shared/llm/index.d.cts +5 -0
- package/dist/shared/llm/index.d.ts +5 -0
- package/dist/shared/llm/index.js +6 -0
- package/dist/shared/llm/types.cjs +16 -0
- package/dist/shared/llm/types.d.cts +66 -0
- package/dist/shared/llm/types.d.ts +66 -0
- package/dist/shared/llm/types.js +0 -0
- package/dist/shared/logger/index.cjs +37 -0
- package/dist/shared/logger/index.d.cts +2 -0
- package/dist/shared/logger/index.d.ts +2 -0
- package/dist/shared/logger/index.js +13 -0
- package/dist/shared/logger/logger.cjs +232 -0
- package/dist/shared/logger/logger.d.cts +86 -0
- package/dist/shared/logger/logger.d.ts +86 -0
- package/dist/shared/logger/logger.js +207 -0
- package/dist/shared/logger/sinks.cjs +160 -0
- package/dist/shared/logger/sinks.d.cts +9 -0
- package/dist/shared/logger/sinks.d.ts +9 -0
- package/dist/shared/logger/sinks.js +124 -0
- package/dist/shared/paths/paths.cjs +104 -0
- package/dist/shared/paths/paths.d.cts +10 -0
- package/dist/shared/paths/paths.d.ts +10 -0
- package/dist/shared/paths/paths.js +73 -0
- package/dist/shared/run/api.cjs +28 -0
- package/dist/shared/run/api.d.cts +2 -0
- package/dist/shared/run/api.d.ts +2 -0
- package/dist/shared/run/api.js +4 -0
- package/dist/shared/run/browser.cjs +98 -0
- package/dist/shared/run/browser.d.cts +22 -0
- package/dist/shared/run/browser.d.ts +22 -0
- package/dist/shared/run/browser.js +74 -0
- package/dist/shared/state/index.cjs +38 -0
- package/dist/shared/state/index.d.cts +2 -0
- package/dist/shared/state/index.d.ts +2 -0
- package/dist/shared/state/index.js +16 -0
- package/dist/shared/state/session-state.cjs +92 -0
- package/dist/shared/state/session-state.d.cts +40 -0
- package/dist/shared/state/session-state.d.ts +40 -0
- package/dist/shared/state/session-state.js +62 -0
- package/dist/shared/visualization/ghost-cursor.cjs +174 -0
- package/dist/shared/visualization/ghost-cursor.d.cts +37 -0
- package/dist/shared/visualization/ghost-cursor.d.ts +37 -0
- package/dist/shared/visualization/ghost-cursor.js +145 -0
- package/dist/shared/visualization/highlight.cjs +134 -0
- package/dist/shared/visualization/highlight.d.cts +22 -0
- package/dist/shared/visualization/highlight.d.ts +22 -0
- package/dist/shared/visualization/highlight.js +108 -0
- package/dist/shared/visualization/index.cjs +45 -0
- package/dist/shared/visualization/index.d.cts +3 -0
- package/dist/shared/visualization/index.d.ts +3 -0
- package/dist/shared/visualization/index.js +24 -0
- package/dist/shared/workflow/workflow.cjs +47 -0
- package/dist/shared/workflow/workflow.d.cts +21 -0
- package/dist/shared/workflow/workflow.d.ts +21 -0
- package/dist/shared/workflow/workflow.js +21 -0
- package/package.json +37 -95
- package/bin/libretto.mjs +0 -18
- package/scripts/postinstall.mjs +0 -48
- /package/{skill → .agents/skills/libretto}/SKILL.md +0 -0
- /package/{skill → .agents/skills/libretto}/code-generation-rules.md +0 -0
- /package/{skill → .agents/skills/libretto}/integration-approach-selection.md +0 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
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
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var index_exports = {};
|
|
30
|
+
__export(index_exports, {
|
|
31
|
+
LIBRETTO_WORKFLOW_BRAND: () => import_workflow.LIBRETTO_WORKFLOW_BRAND,
|
|
32
|
+
LibrettoWorkflow: () => import_workflow.LibrettoWorkflow,
|
|
33
|
+
Logger: () => import_logger.Logger,
|
|
34
|
+
SESSION_STATE_VERSION: () => import_state.SESSION_STATE_VERSION,
|
|
35
|
+
SessionStateFileSchema: () => import_state.SessionStateFileSchema,
|
|
36
|
+
SessionStatusSchema: () => import_state.SessionStatusSchema,
|
|
37
|
+
attemptWithRecovery: () => import_recovery.attemptWithRecovery,
|
|
38
|
+
clearHighlights: () => import_highlight.clearHighlights,
|
|
39
|
+
createFileLogSink: () => import_sinks.createFileLogSink,
|
|
40
|
+
createLLMClientFromModel: () => import_ai_sdk_adapter.createLLMClientFromModel,
|
|
41
|
+
defaultLogger: () => import_logger.defaultLogger,
|
|
42
|
+
detectSubmissionError: () => import_errors.detectSubmissionError,
|
|
43
|
+
downloadAndSave: () => import_download.downloadAndSave,
|
|
44
|
+
downloadViaClick: () => import_download.downloadViaClick,
|
|
45
|
+
ensureGhostCursor: () => import_ghost_cursor.ensureGhostCursor,
|
|
46
|
+
ensureHighlightLayer: () => import_highlight.ensureHighlightLayer,
|
|
47
|
+
executeRecoveryAgent: () => import_agent.executeRecoveryAgent,
|
|
48
|
+
extractFromPage: () => import_extract.extractFromPage,
|
|
49
|
+
ghostClick: () => import_ghost_cursor.ghostClick,
|
|
50
|
+
hideGhostCursor: () => import_ghost_cursor.hideGhostCursor,
|
|
51
|
+
installInstrumentation: () => import_instrument.installInstrumentation,
|
|
52
|
+
instrumentContext: () => import_instrument.instrumentContext,
|
|
53
|
+
instrumentPage: () => import_instrument.instrumentPage,
|
|
54
|
+
isDebugMode: () => import_config.isDebugMode,
|
|
55
|
+
isDryRun: () => import_config.isDryRun,
|
|
56
|
+
jsonlConsoleSink: () => import_sinks.jsonlConsoleSink,
|
|
57
|
+
launchBrowser: () => import_api.launchBrowser,
|
|
58
|
+
moveGhostCursor: () => import_ghost_cursor.moveGhostCursor,
|
|
59
|
+
pageRequest: () => import_network.pageRequest,
|
|
60
|
+
parseSessionStateContent: () => import_state.parseSessionStateContent,
|
|
61
|
+
parseSessionStateData: () => import_state.parseSessionStateData,
|
|
62
|
+
pause: () => import_pause.pause,
|
|
63
|
+
prettyConsoleSink: () => import_sinks.prettyConsoleSink,
|
|
64
|
+
serializeSessionState: () => import_state.serializeSessionState,
|
|
65
|
+
shouldPauseBeforeMutation: () => import_config.shouldPauseBeforeMutation,
|
|
66
|
+
showHighlight: () => import_highlight.showHighlight,
|
|
67
|
+
workflow: () => import_workflow.workflow
|
|
68
|
+
});
|
|
69
|
+
module.exports = __toCommonJS(index_exports);
|
|
70
|
+
var import_node_path = require("node:path");
|
|
71
|
+
var import_node_url = require("node:url");
|
|
72
|
+
var import_logger = require("./shared/logger/logger.js");
|
|
73
|
+
var import_sinks = require("./shared/logger/sinks.js");
|
|
74
|
+
var import_ai_sdk_adapter = require("./shared/llm/ai-sdk-adapter.js");
|
|
75
|
+
var import_state = require("./shared/state/index.js");
|
|
76
|
+
var import_agent = require("./runtime/recovery/agent.js");
|
|
77
|
+
var import_recovery = require("./runtime/recovery/recovery.js");
|
|
78
|
+
var import_errors = require("./runtime/recovery/errors.js");
|
|
79
|
+
var import_extract = require("./runtime/extract/extract.js");
|
|
80
|
+
var import_network = require("./runtime/network/network.js");
|
|
81
|
+
var import_download = require("./runtime/download/download.js");
|
|
82
|
+
var import_pause = require("./shared/debug/pause.js");
|
|
83
|
+
var import_config = require("./shared/config/config.js");
|
|
84
|
+
var import_instrument = require("./shared/instrumentation/instrument.js");
|
|
85
|
+
var import_ghost_cursor = require("./shared/visualization/ghost-cursor.js");
|
|
86
|
+
var import_highlight = require("./shared/visualization/highlight.js");
|
|
87
|
+
var import_api = require("./shared/run/api.js");
|
|
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
|
+
}
|
|
105
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
106
|
+
0 && (module.exports = {
|
|
107
|
+
LIBRETTO_WORKFLOW_BRAND,
|
|
108
|
+
LibrettoWorkflow,
|
|
109
|
+
Logger,
|
|
110
|
+
SESSION_STATE_VERSION,
|
|
111
|
+
SessionStateFileSchema,
|
|
112
|
+
SessionStatusSchema,
|
|
113
|
+
attemptWithRecovery,
|
|
114
|
+
clearHighlights,
|
|
115
|
+
createFileLogSink,
|
|
116
|
+
createLLMClientFromModel,
|
|
117
|
+
defaultLogger,
|
|
118
|
+
detectSubmissionError,
|
|
119
|
+
downloadAndSave,
|
|
120
|
+
downloadViaClick,
|
|
121
|
+
ensureGhostCursor,
|
|
122
|
+
ensureHighlightLayer,
|
|
123
|
+
executeRecoveryAgent,
|
|
124
|
+
extractFromPage,
|
|
125
|
+
ghostClick,
|
|
126
|
+
hideGhostCursor,
|
|
127
|
+
installInstrumentation,
|
|
128
|
+
instrumentContext,
|
|
129
|
+
instrumentPage,
|
|
130
|
+
isDebugMode,
|
|
131
|
+
isDryRun,
|
|
132
|
+
jsonlConsoleSink,
|
|
133
|
+
launchBrowser,
|
|
134
|
+
moveGhostCursor,
|
|
135
|
+
pageRequest,
|
|
136
|
+
parseSessionStateContent,
|
|
137
|
+
parseSessionStateData,
|
|
138
|
+
pause,
|
|
139
|
+
prettyConsoleSink,
|
|
140
|
+
serializeSessionState,
|
|
141
|
+
shouldPauseBeforeMutation,
|
|
142
|
+
showHighlight,
|
|
143
|
+
workflow
|
|
144
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { LogOptions, Logger, LoggerApi, LoggerSink, MinimalLogger, defaultLogger } from './shared/logger/logger.cjs';
|
|
2
|
+
export { createFileLogSink, jsonlConsoleSink, prettyConsoleSink } from './shared/logger/sinks.cjs';
|
|
3
|
+
export { LLMClient, Message, MessageContentPart } from './shared/llm/types.cjs';
|
|
4
|
+
export { createLLMClientFromModel } from './shared/llm/ai-sdk-adapter.cjs';
|
|
5
|
+
export { SESSION_STATE_VERSION, SessionState, SessionStateFile, SessionStateFileSchema, SessionStatus, SessionStatusSchema, parseSessionStateContent, parseSessionStateData, serializeSessionState } from './shared/state/session-state.cjs';
|
|
6
|
+
export { executeRecoveryAgent } from './runtime/recovery/agent.cjs';
|
|
7
|
+
export { attemptWithRecovery } from './runtime/recovery/recovery.cjs';
|
|
8
|
+
export { DetectedSubmissionError, KnownSubmissionError, detectSubmissionError } from './runtime/recovery/errors.cjs';
|
|
9
|
+
export { ExtractOptions, extractFromPage } from './runtime/extract/extract.cjs';
|
|
10
|
+
export { PageRequestOptions, RequestConfig, pageRequest } from './runtime/network/network.cjs';
|
|
11
|
+
export { DownloadResult, DownloadViaClickOptions, SaveDownloadOptions, downloadAndSave, downloadViaClick } from './runtime/download/download.cjs';
|
|
12
|
+
export { pause } from './shared/debug/pause.cjs';
|
|
13
|
+
export { isDebugMode, isDryRun, shouldPauseBeforeMutation } from './shared/config/config.cjs';
|
|
14
|
+
export { InstrumentationOptions, InstrumentedPage, installInstrumentation, instrumentContext, instrumentPage } from './shared/instrumentation/instrument.cjs';
|
|
15
|
+
export { GhostCursorOptions, ensureGhostCursor, ghostClick, hideGhostCursor, moveGhostCursor } from './shared/visualization/ghost-cursor.cjs';
|
|
16
|
+
export { HighlightOptions, clearHighlights, ensureHighlightLayer, showHighlight } from './shared/visualization/highlight.cjs';
|
|
17
|
+
export { BrowserSession, LaunchBrowserArgs, launchBrowser } from './shared/run/browser.cjs';
|
|
18
|
+
export { LIBRETTO_WORKFLOW_BRAND, LibrettoWorkflow, LibrettoWorkflowContext, LibrettoWorkflowHandler, LibrettoWorkflowMetadata, workflow } from './shared/workflow/workflow.cjs';
|
|
19
|
+
import 'zod';
|
|
20
|
+
import 'ai';
|
|
21
|
+
import 'playwright';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export { LogOptions, Logger, LoggerApi, LoggerSink, MinimalLogger, defaultLogger } from './shared/logger/logger.js';
|
|
2
|
+
export { createFileLogSink, jsonlConsoleSink, prettyConsoleSink } from './shared/logger/sinks.js';
|
|
3
|
+
export { LLMClient, Message, MessageContentPart } from './shared/llm/types.js';
|
|
4
|
+
export { createLLMClientFromModel } from './shared/llm/ai-sdk-adapter.js';
|
|
5
|
+
export { SESSION_STATE_VERSION, SessionState, SessionStateFile, SessionStateFileSchema, SessionStatus, SessionStatusSchema, parseSessionStateContent, parseSessionStateData, serializeSessionState } from './shared/state/session-state.js';
|
|
6
|
+
export { executeRecoveryAgent } from './runtime/recovery/agent.js';
|
|
7
|
+
export { attemptWithRecovery } from './runtime/recovery/recovery.js';
|
|
8
|
+
export { DetectedSubmissionError, KnownSubmissionError, detectSubmissionError } from './runtime/recovery/errors.js';
|
|
9
|
+
export { ExtractOptions, extractFromPage } from './runtime/extract/extract.js';
|
|
10
|
+
export { PageRequestOptions, RequestConfig, pageRequest } from './runtime/network/network.js';
|
|
11
|
+
export { DownloadResult, DownloadViaClickOptions, SaveDownloadOptions, downloadAndSave, downloadViaClick } from './runtime/download/download.js';
|
|
12
|
+
export { pause } from './shared/debug/pause.js';
|
|
13
|
+
export { isDebugMode, isDryRun, shouldPauseBeforeMutation } from './shared/config/config.js';
|
|
14
|
+
export { InstrumentationOptions, InstrumentedPage, installInstrumentation, instrumentContext, instrumentPage } from './shared/instrumentation/instrument.js';
|
|
15
|
+
export { GhostCursorOptions, ensureGhostCursor, ghostClick, hideGhostCursor, moveGhostCursor } from './shared/visualization/ghost-cursor.js';
|
|
16
|
+
export { HighlightOptions, clearHighlights, ensureHighlightLayer, showHighlight } from './shared/visualization/highlight.js';
|
|
17
|
+
export { BrowserSession, LaunchBrowserArgs, launchBrowser } from './shared/run/browser.js';
|
|
18
|
+
export { LIBRETTO_WORKFLOW_BRAND, LibrettoWorkflow, LibrettoWorkflowContext, LibrettoWorkflowHandler, LibrettoWorkflowMetadata, workflow } from './shared/workflow/workflow.js';
|
|
19
|
+
import 'zod';
|
|
20
|
+
import 'ai';
|
|
21
|
+
import 'playwright';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { resolve } from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { Logger, defaultLogger } from "./shared/logger/logger.js";
|
|
4
|
+
import {
|
|
5
|
+
createFileLogSink,
|
|
6
|
+
prettyConsoleSink,
|
|
7
|
+
jsonlConsoleSink
|
|
8
|
+
} from "./shared/logger/sinks.js";
|
|
9
|
+
import { createLLMClientFromModel } from "./shared/llm/ai-sdk-adapter.js";
|
|
10
|
+
import {
|
|
11
|
+
SESSION_STATE_VERSION,
|
|
12
|
+
SessionStatusSchema,
|
|
13
|
+
SessionStateFileSchema,
|
|
14
|
+
parseSessionStateData,
|
|
15
|
+
parseSessionStateContent,
|
|
16
|
+
serializeSessionState
|
|
17
|
+
} from "./shared/state/index.js";
|
|
18
|
+
import { executeRecoveryAgent } from "./runtime/recovery/agent.js";
|
|
19
|
+
import { attemptWithRecovery } from "./runtime/recovery/recovery.js";
|
|
20
|
+
import {
|
|
21
|
+
detectSubmissionError
|
|
22
|
+
} from "./runtime/recovery/errors.js";
|
|
23
|
+
import { extractFromPage } from "./runtime/extract/extract.js";
|
|
24
|
+
import {
|
|
25
|
+
pageRequest
|
|
26
|
+
} from "./runtime/network/network.js";
|
|
27
|
+
import {
|
|
28
|
+
downloadViaClick,
|
|
29
|
+
downloadAndSave
|
|
30
|
+
} from "./runtime/download/download.js";
|
|
31
|
+
import { pause } from "./shared/debug/pause.js";
|
|
32
|
+
import {
|
|
33
|
+
isDebugMode,
|
|
34
|
+
isDryRun,
|
|
35
|
+
shouldPauseBeforeMutation
|
|
36
|
+
} from "./shared/config/config.js";
|
|
37
|
+
import {
|
|
38
|
+
instrumentPage,
|
|
39
|
+
installInstrumentation,
|
|
40
|
+
instrumentContext
|
|
41
|
+
} from "./shared/instrumentation/instrument.js";
|
|
42
|
+
import {
|
|
43
|
+
ensureGhostCursor,
|
|
44
|
+
moveGhostCursor,
|
|
45
|
+
ghostClick,
|
|
46
|
+
hideGhostCursor
|
|
47
|
+
} from "./shared/visualization/ghost-cursor.js";
|
|
48
|
+
import {
|
|
49
|
+
ensureHighlightLayer,
|
|
50
|
+
showHighlight,
|
|
51
|
+
clearHighlights
|
|
52
|
+
} from "./shared/visualization/highlight.js";
|
|
53
|
+
import {
|
|
54
|
+
launchBrowser
|
|
55
|
+
} from "./shared/run/api.js";
|
|
56
|
+
import {
|
|
57
|
+
LibrettoWorkflow,
|
|
58
|
+
LIBRETTO_WORKFLOW_BRAND,
|
|
59
|
+
workflow
|
|
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
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
LIBRETTO_WORKFLOW_BRAND,
|
|
78
|
+
LibrettoWorkflow,
|
|
79
|
+
Logger,
|
|
80
|
+
SESSION_STATE_VERSION,
|
|
81
|
+
SessionStateFileSchema,
|
|
82
|
+
SessionStatusSchema,
|
|
83
|
+
attemptWithRecovery,
|
|
84
|
+
clearHighlights,
|
|
85
|
+
createFileLogSink,
|
|
86
|
+
createLLMClientFromModel,
|
|
87
|
+
defaultLogger,
|
|
88
|
+
detectSubmissionError,
|
|
89
|
+
downloadAndSave,
|
|
90
|
+
downloadViaClick,
|
|
91
|
+
ensureGhostCursor,
|
|
92
|
+
ensureHighlightLayer,
|
|
93
|
+
executeRecoveryAgent,
|
|
94
|
+
extractFromPage,
|
|
95
|
+
ghostClick,
|
|
96
|
+
hideGhostCursor,
|
|
97
|
+
installInstrumentation,
|
|
98
|
+
instrumentContext,
|
|
99
|
+
instrumentPage,
|
|
100
|
+
isDebugMode,
|
|
101
|
+
isDryRun,
|
|
102
|
+
jsonlConsoleSink,
|
|
103
|
+
launchBrowser,
|
|
104
|
+
moveGhostCursor,
|
|
105
|
+
pageRequest,
|
|
106
|
+
parseSessionStateContent,
|
|
107
|
+
parseSessionStateData,
|
|
108
|
+
pause,
|
|
109
|
+
prettyConsoleSink,
|
|
110
|
+
serializeSessionState,
|
|
111
|
+
shouldPauseBeforeMutation,
|
|
112
|
+
showHighlight,
|
|
113
|
+
workflow
|
|
114
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var download_exports = {};
|
|
20
|
+
__export(download_exports, {
|
|
21
|
+
downloadAndSave: () => downloadAndSave,
|
|
22
|
+
downloadViaClick: () => downloadViaClick
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(download_exports);
|
|
25
|
+
var import_promises = require("node:fs/promises");
|
|
26
|
+
var import_node_path = require("node:path");
|
|
27
|
+
async function downloadViaClick(page, selector, options) {
|
|
28
|
+
const { logger, timeout = 3e4 } = options ?? {};
|
|
29
|
+
const startTime = Date.now();
|
|
30
|
+
const downloadPromise = page.waitForEvent("download", { timeout });
|
|
31
|
+
await page.locator(selector).click();
|
|
32
|
+
const download = await downloadPromise;
|
|
33
|
+
const filename = download.suggestedFilename();
|
|
34
|
+
const readStream = await download.createReadStream();
|
|
35
|
+
if (!readStream) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
`Download stream unavailable for "${filename}". The browser may have been closed before the download completed.`
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const chunks = [];
|
|
41
|
+
for await (const chunk of readStream) {
|
|
42
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
43
|
+
}
|
|
44
|
+
const buffer = Buffer.concat(chunks);
|
|
45
|
+
const duration = Date.now() - startTime;
|
|
46
|
+
logger?.info("download:click", {
|
|
47
|
+
selector,
|
|
48
|
+
filename,
|
|
49
|
+
size: buffer.length,
|
|
50
|
+
duration
|
|
51
|
+
});
|
|
52
|
+
return { buffer, filename };
|
|
53
|
+
}
|
|
54
|
+
async function downloadAndSave(page, selector, options) {
|
|
55
|
+
const { savePath, ...downloadOpts } = options ?? {};
|
|
56
|
+
const { buffer, filename } = await downloadViaClick(page, selector, downloadOpts);
|
|
57
|
+
const dest = (0, import_node_path.resolve)(savePath ?? filename);
|
|
58
|
+
await (0, import_promises.writeFile)(dest, buffer);
|
|
59
|
+
options?.logger?.info("download:saved", {
|
|
60
|
+
filename,
|
|
61
|
+
savedTo: dest,
|
|
62
|
+
size: buffer.length
|
|
63
|
+
});
|
|
64
|
+
return { buffer, filename, savedTo: dest };
|
|
65
|
+
}
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
downloadAndSave,
|
|
69
|
+
downloadViaClick
|
|
70
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Page } from 'playwright';
|
|
2
|
+
import { MinimalLogger } from '../../shared/logger/logger.cjs';
|
|
3
|
+
|
|
4
|
+
type DownloadResult = {
|
|
5
|
+
/** The raw file contents. */
|
|
6
|
+
buffer: Buffer;
|
|
7
|
+
/** The filename suggested by the server (Content-Disposition header or URL). */
|
|
8
|
+
filename: string;
|
|
9
|
+
};
|
|
10
|
+
type DownloadViaClickOptions = {
|
|
11
|
+
logger?: MinimalLogger;
|
|
12
|
+
/** Timeout in milliseconds for waiting on the download event. Defaults to 30 000. */
|
|
13
|
+
timeout?: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Triggers a file download by clicking a DOM element and intercepts the
|
|
17
|
+
* resulting download using Playwright's download event.
|
|
18
|
+
*
|
|
19
|
+
* The download promise is registered **before** the click so the event is
|
|
20
|
+
* never missed.
|
|
21
|
+
*/
|
|
22
|
+
declare function downloadViaClick(page: Page, selector: string, options?: DownloadViaClickOptions): Promise<DownloadResult>;
|
|
23
|
+
type SaveDownloadOptions = DownloadViaClickOptions & {
|
|
24
|
+
/** Absolute or relative path to save the file to. When omitted the suggested filename is used in the current working directory. */
|
|
25
|
+
savePath?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Convenience wrapper around {@link downloadViaClick} that also writes the
|
|
29
|
+
* downloaded file to disk.
|
|
30
|
+
*/
|
|
31
|
+
declare function downloadAndSave(page: Page, selector: string, options?: SaveDownloadOptions): Promise<DownloadResult & {
|
|
32
|
+
savedTo: string;
|
|
33
|
+
}>;
|
|
34
|
+
|
|
35
|
+
export { type DownloadResult, type DownloadViaClickOptions, type SaveDownloadOptions, downloadAndSave, downloadViaClick };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Page } from 'playwright';
|
|
2
|
+
import { MinimalLogger } from '../../shared/logger/logger.js';
|
|
3
|
+
|
|
4
|
+
type DownloadResult = {
|
|
5
|
+
/** The raw file contents. */
|
|
6
|
+
buffer: Buffer;
|
|
7
|
+
/** The filename suggested by the server (Content-Disposition header or URL). */
|
|
8
|
+
filename: string;
|
|
9
|
+
};
|
|
10
|
+
type DownloadViaClickOptions = {
|
|
11
|
+
logger?: MinimalLogger;
|
|
12
|
+
/** Timeout in milliseconds for waiting on the download event. Defaults to 30 000. */
|
|
13
|
+
timeout?: number;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Triggers a file download by clicking a DOM element and intercepts the
|
|
17
|
+
* resulting download using Playwright's download event.
|
|
18
|
+
*
|
|
19
|
+
* The download promise is registered **before** the click so the event is
|
|
20
|
+
* never missed.
|
|
21
|
+
*/
|
|
22
|
+
declare function downloadViaClick(page: Page, selector: string, options?: DownloadViaClickOptions): Promise<DownloadResult>;
|
|
23
|
+
type SaveDownloadOptions = DownloadViaClickOptions & {
|
|
24
|
+
/** Absolute or relative path to save the file to. When omitted the suggested filename is used in the current working directory. */
|
|
25
|
+
savePath?: string;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Convenience wrapper around {@link downloadViaClick} that also writes the
|
|
29
|
+
* downloaded file to disk.
|
|
30
|
+
*/
|
|
31
|
+
declare function downloadAndSave(page: Page, selector: string, options?: SaveDownloadOptions): Promise<DownloadResult & {
|
|
32
|
+
savedTo: string;
|
|
33
|
+
}>;
|
|
34
|
+
|
|
35
|
+
export { type DownloadResult, type DownloadViaClickOptions, type SaveDownloadOptions, downloadAndSave, downloadViaClick };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { writeFile } from "node:fs/promises";
|
|
2
|
+
import { resolve } from "node:path";
|
|
3
|
+
async function downloadViaClick(page, selector, options) {
|
|
4
|
+
const { logger, timeout = 3e4 } = options ?? {};
|
|
5
|
+
const startTime = Date.now();
|
|
6
|
+
const downloadPromise = page.waitForEvent("download", { timeout });
|
|
7
|
+
await page.locator(selector).click();
|
|
8
|
+
const download = await downloadPromise;
|
|
9
|
+
const filename = download.suggestedFilename();
|
|
10
|
+
const readStream = await download.createReadStream();
|
|
11
|
+
if (!readStream) {
|
|
12
|
+
throw new Error(
|
|
13
|
+
`Download stream unavailable for "${filename}". The browser may have been closed before the download completed.`
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
const chunks = [];
|
|
17
|
+
for await (const chunk of readStream) {
|
|
18
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
19
|
+
}
|
|
20
|
+
const buffer = Buffer.concat(chunks);
|
|
21
|
+
const duration = Date.now() - startTime;
|
|
22
|
+
logger?.info("download:click", {
|
|
23
|
+
selector,
|
|
24
|
+
filename,
|
|
25
|
+
size: buffer.length,
|
|
26
|
+
duration
|
|
27
|
+
});
|
|
28
|
+
return { buffer, filename };
|
|
29
|
+
}
|
|
30
|
+
async function downloadAndSave(page, selector, options) {
|
|
31
|
+
const { savePath, ...downloadOpts } = options ?? {};
|
|
32
|
+
const { buffer, filename } = await downloadViaClick(page, selector, downloadOpts);
|
|
33
|
+
const dest = resolve(savePath ?? filename);
|
|
34
|
+
await writeFile(dest, buffer);
|
|
35
|
+
options?.logger?.info("download:saved", {
|
|
36
|
+
filename,
|
|
37
|
+
savedTo: dest,
|
|
38
|
+
size: buffer.length
|
|
39
|
+
});
|
|
40
|
+
return { buffer, filename, savedTo: dest };
|
|
41
|
+
}
|
|
42
|
+
export {
|
|
43
|
+
downloadAndSave,
|
|
44
|
+
downloadViaClick
|
|
45
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var download_exports = {};
|
|
20
|
+
__export(download_exports, {
|
|
21
|
+
downloadAndSave: () => import_download.downloadAndSave,
|
|
22
|
+
downloadViaClick: () => import_download.downloadViaClick
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(download_exports);
|
|
25
|
+
var import_download = require("./download.js");
|
|
26
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
+
0 && (module.exports = {
|
|
28
|
+
downloadAndSave,
|
|
29
|
+
downloadViaClick
|
|
30
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var extract_exports = {};
|
|
20
|
+
__export(extract_exports, {
|
|
21
|
+
extractFromPage: () => extractFromPage
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(extract_exports);
|
|
24
|
+
var import_logger = require("../../shared/logger/logger.js");
|
|
25
|
+
async function extractFromPage(options) {
|
|
26
|
+
const { page, instruction, schema, selector, logger = import_logger.defaultLogger, llmClient } = options;
|
|
27
|
+
let screenshot;
|
|
28
|
+
let domContent;
|
|
29
|
+
if (selector) {
|
|
30
|
+
const element = page.locator(selector);
|
|
31
|
+
await element.waitFor({ state: "visible", timeout: 1e4 });
|
|
32
|
+
const screenshotBuffer = await element.screenshot();
|
|
33
|
+
screenshot = screenshotBuffer.toString("base64");
|
|
34
|
+
try {
|
|
35
|
+
domContent = await element.innerHTML();
|
|
36
|
+
if (domContent.length > 3e4) {
|
|
37
|
+
domContent = domContent.slice(0, 3e4) + "\n... [truncated]";
|
|
38
|
+
}
|
|
39
|
+
} catch {
|
|
40
|
+
domContent = void 0;
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
const cdpClient = await page.context().newCDPSession(page);
|
|
44
|
+
await cdpClient.send("Page.enable");
|
|
45
|
+
const { data } = await cdpClient.send("Page.captureScreenshot", {
|
|
46
|
+
format: "png"
|
|
47
|
+
});
|
|
48
|
+
screenshot = data;
|
|
49
|
+
try {
|
|
50
|
+
const htmlContent = await page.content();
|
|
51
|
+
domContent = htmlContent.length > 5e4 ? htmlContent.slice(0, 5e4) + "\n... [truncated]" : htmlContent;
|
|
52
|
+
} catch {
|
|
53
|
+
domContent = void 0;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const prompt = `You are analyzing a screenshot${selector ? " of a specific element" : ""} from a web page to extract structured data.
|
|
57
|
+
|
|
58
|
+
Instruction: ${instruction}
|
|
59
|
+
|
|
60
|
+
${domContent ? `Here is the HTML content for additional context:
|
|
61
|
+
<html>
|
|
62
|
+
${domContent}
|
|
63
|
+
</html>` : ""}
|
|
64
|
+
|
|
65
|
+
Extract the requested information from the screenshot and return it in the specified format. Be precise and only extract what is visible.`;
|
|
66
|
+
const result = await llmClient.generateObjectFromMessages({
|
|
67
|
+
schema,
|
|
68
|
+
messages: [
|
|
69
|
+
{
|
|
70
|
+
role: "user",
|
|
71
|
+
content: [
|
|
72
|
+
{ type: "text", text: prompt },
|
|
73
|
+
{ type: "image", image: `data:image/png;base64,${screenshot}` }
|
|
74
|
+
]
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
temperature: 0
|
|
78
|
+
});
|
|
79
|
+
logger.info("extractFromPage completed", {
|
|
80
|
+
selector,
|
|
81
|
+
instruction: instruction.slice(0, 100)
|
|
82
|
+
});
|
|
83
|
+
return result;
|
|
84
|
+
}
|
|
85
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
86
|
+
0 && (module.exports = {
|
|
87
|
+
extractFromPage
|
|
88
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Page } from 'playwright';
|
|
2
|
+
import z from 'zod';
|
|
3
|
+
import { MinimalLogger } from '../../shared/logger/logger.cjs';
|
|
4
|
+
import { LLMClient } from '../../shared/llm/types.cjs';
|
|
5
|
+
|
|
6
|
+
type ExtractOptions<T extends z.ZodType> = {
|
|
7
|
+
page: Page;
|
|
8
|
+
instruction: string;
|
|
9
|
+
schema: T;
|
|
10
|
+
llmClient: LLMClient;
|
|
11
|
+
logger?: MinimalLogger;
|
|
12
|
+
/** Optional CSS selector to scope extraction to a specific element. */
|
|
13
|
+
selector?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Generic AI-powered data extraction from page elements.
|
|
17
|
+
* Takes a screenshot (full-page via CDP or scoped to an element),
|
|
18
|
+
* captures DOM content, and uses an LLM to extract structured data
|
|
19
|
+
* matching the provided Zod schema.
|
|
20
|
+
*/
|
|
21
|
+
declare function extractFromPage<T extends z.ZodType>(options: ExtractOptions<T>): Promise<z.infer<T>>;
|
|
22
|
+
|
|
23
|
+
export { type ExtractOptions, extractFromPage };
|