libretto 0.2.6 → 0.3.0

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.
Files changed (160) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +12 -12
  3. package/skill/SKILL.md +20 -18
  4. package/skill/code-generation-rules.md +3 -3
  5. package/skill/integration-approach-selection.md +3 -3
  6. package/dist/cli/cli.js +0 -209
  7. package/dist/cli/commands/ai.js +0 -21
  8. package/dist/cli/commands/browser.js +0 -82
  9. package/dist/cli/commands/execution.js +0 -461
  10. package/dist/cli/commands/init.js +0 -95
  11. package/dist/cli/commands/logs.js +0 -93
  12. package/dist/cli/commands/snapshot.js +0 -106
  13. package/dist/cli/core/ai-config.js +0 -149
  14. package/dist/cli/core/browser.js +0 -648
  15. package/dist/cli/core/context.js +0 -118
  16. package/dist/cli/core/pause-signals.js +0 -29
  17. package/dist/cli/core/session-telemetry.js +0 -491
  18. package/dist/cli/core/session.js +0 -183
  19. package/dist/cli/core/snapshot-analyzer.js +0 -492
  20. package/dist/cli/core/telemetry.js +0 -362
  21. package/dist/cli/index.js +0 -13
  22. package/dist/cli/workers/run-integration-runtime.js +0 -227
  23. package/dist/cli/workers/run-integration-worker-protocol.js +0 -12
  24. package/dist/cli/workers/run-integration-worker.js +0 -66
  25. package/dist/index.cjs +0 -116
  26. package/dist/index.d.cts +0 -21
  27. package/dist/index.d.ts +0 -21
  28. package/dist/index.js +0 -97
  29. package/dist/runtime/download/download.cjs +0 -70
  30. package/dist/runtime/download/download.d.cts +0 -35
  31. package/dist/runtime/download/download.d.ts +0 -35
  32. package/dist/runtime/download/download.js +0 -45
  33. package/dist/runtime/download/index.cjs +0 -30
  34. package/dist/runtime/download/index.d.cts +0 -3
  35. package/dist/runtime/download/index.d.ts +0 -3
  36. package/dist/runtime/download/index.js +0 -8
  37. package/dist/runtime/extract/extract.cjs +0 -88
  38. package/dist/runtime/extract/extract.d.cts +0 -23
  39. package/dist/runtime/extract/extract.d.ts +0 -23
  40. package/dist/runtime/extract/extract.js +0 -64
  41. package/dist/runtime/extract/index.cjs +0 -28
  42. package/dist/runtime/extract/index.d.cts +0 -5
  43. package/dist/runtime/extract/index.d.ts +0 -5
  44. package/dist/runtime/extract/index.js +0 -4
  45. package/dist/runtime/network/index.cjs +0 -28
  46. package/dist/runtime/network/index.d.cts +0 -4
  47. package/dist/runtime/network/index.d.ts +0 -4
  48. package/dist/runtime/network/index.js +0 -6
  49. package/dist/runtime/network/network.cjs +0 -91
  50. package/dist/runtime/network/network.d.cts +0 -28
  51. package/dist/runtime/network/network.d.ts +0 -28
  52. package/dist/runtime/network/network.js +0 -67
  53. package/dist/runtime/recovery/agent.cjs +0 -223
  54. package/dist/runtime/recovery/agent.d.cts +0 -13
  55. package/dist/runtime/recovery/agent.d.ts +0 -13
  56. package/dist/runtime/recovery/agent.js +0 -199
  57. package/dist/runtime/recovery/errors.cjs +0 -124
  58. package/dist/runtime/recovery/errors.d.cts +0 -31
  59. package/dist/runtime/recovery/errors.d.ts +0 -31
  60. package/dist/runtime/recovery/errors.js +0 -100
  61. package/dist/runtime/recovery/index.cjs +0 -34
  62. package/dist/runtime/recovery/index.d.cts +0 -7
  63. package/dist/runtime/recovery/index.d.ts +0 -7
  64. package/dist/runtime/recovery/index.js +0 -10
  65. package/dist/runtime/recovery/recovery.cjs +0 -55
  66. package/dist/runtime/recovery/recovery.d.cts +0 -12
  67. package/dist/runtime/recovery/recovery.d.ts +0 -12
  68. package/dist/runtime/recovery/recovery.js +0 -31
  69. package/dist/shared/config/config.cjs +0 -44
  70. package/dist/shared/config/config.d.cts +0 -10
  71. package/dist/shared/config/config.d.ts +0 -10
  72. package/dist/shared/config/config.js +0 -18
  73. package/dist/shared/config/index.cjs +0 -32
  74. package/dist/shared/config/index.d.cts +0 -1
  75. package/dist/shared/config/index.d.ts +0 -1
  76. package/dist/shared/config/index.js +0 -10
  77. package/dist/shared/debug/index.cjs +0 -30
  78. package/dist/shared/debug/index.d.cts +0 -1
  79. package/dist/shared/debug/index.d.ts +0 -1
  80. package/dist/shared/debug/index.js +0 -5
  81. package/dist/shared/debug/pause.cjs +0 -90
  82. package/dist/shared/debug/pause.d.cts +0 -16
  83. package/dist/shared/debug/pause.d.ts +0 -16
  84. package/dist/shared/debug/pause.js +0 -55
  85. package/dist/shared/instrumentation/errors.cjs +0 -81
  86. package/dist/shared/instrumentation/errors.d.cts +0 -12
  87. package/dist/shared/instrumentation/errors.d.ts +0 -12
  88. package/dist/shared/instrumentation/errors.js +0 -57
  89. package/dist/shared/instrumentation/index.cjs +0 -35
  90. package/dist/shared/instrumentation/index.d.cts +0 -6
  91. package/dist/shared/instrumentation/index.d.ts +0 -6
  92. package/dist/shared/instrumentation/index.js +0 -12
  93. package/dist/shared/instrumentation/instrument.cjs +0 -206
  94. package/dist/shared/instrumentation/instrument.d.cts +0 -32
  95. package/dist/shared/instrumentation/instrument.d.ts +0 -32
  96. package/dist/shared/instrumentation/instrument.js +0 -190
  97. package/dist/shared/llm/ai-sdk-adapter.cjs +0 -67
  98. package/dist/shared/llm/ai-sdk-adapter.d.cts +0 -22
  99. package/dist/shared/llm/ai-sdk-adapter.d.ts +0 -22
  100. package/dist/shared/llm/ai-sdk-adapter.js +0 -43
  101. package/dist/shared/llm/client.cjs +0 -139
  102. package/dist/shared/llm/client.d.cts +0 -6
  103. package/dist/shared/llm/client.d.ts +0 -6
  104. package/dist/shared/llm/client.js +0 -115
  105. package/dist/shared/llm/index.cjs +0 -31
  106. package/dist/shared/llm/index.d.cts +0 -5
  107. package/dist/shared/llm/index.d.ts +0 -5
  108. package/dist/shared/llm/index.js +0 -6
  109. package/dist/shared/llm/types.cjs +0 -16
  110. package/dist/shared/llm/types.d.cts +0 -66
  111. package/dist/shared/llm/types.d.ts +0 -66
  112. package/dist/shared/llm/types.js +0 -0
  113. package/dist/shared/logger/index.cjs +0 -37
  114. package/dist/shared/logger/index.d.cts +0 -2
  115. package/dist/shared/logger/index.d.ts +0 -2
  116. package/dist/shared/logger/index.js +0 -13
  117. package/dist/shared/logger/logger.cjs +0 -213
  118. package/dist/shared/logger/logger.d.cts +0 -82
  119. package/dist/shared/logger/logger.d.ts +0 -82
  120. package/dist/shared/logger/logger.js +0 -188
  121. package/dist/shared/logger/sinks.cjs +0 -160
  122. package/dist/shared/logger/sinks.d.cts +0 -9
  123. package/dist/shared/logger/sinks.d.ts +0 -9
  124. package/dist/shared/logger/sinks.js +0 -124
  125. package/dist/shared/paths/paths.cjs +0 -104
  126. package/dist/shared/paths/paths.d.cts +0 -10
  127. package/dist/shared/paths/paths.d.ts +0 -10
  128. package/dist/shared/paths/paths.js +0 -73
  129. package/dist/shared/run/api.cjs +0 -28
  130. package/dist/shared/run/api.d.cts +0 -2
  131. package/dist/shared/run/api.d.ts +0 -2
  132. package/dist/shared/run/api.js +0 -4
  133. package/dist/shared/run/browser.cjs +0 -98
  134. package/dist/shared/run/browser.d.cts +0 -22
  135. package/dist/shared/run/browser.d.ts +0 -22
  136. package/dist/shared/run/browser.js +0 -74
  137. package/dist/shared/state/index.cjs +0 -38
  138. package/dist/shared/state/index.d.cts +0 -2
  139. package/dist/shared/state/index.d.ts +0 -2
  140. package/dist/shared/state/index.js +0 -16
  141. package/dist/shared/state/session-state.cjs +0 -85
  142. package/dist/shared/state/session-state.d.cts +0 -34
  143. package/dist/shared/state/session-state.d.ts +0 -34
  144. package/dist/shared/state/session-state.js +0 -56
  145. package/dist/shared/visualization/ghost-cursor.cjs +0 -174
  146. package/dist/shared/visualization/ghost-cursor.d.cts +0 -37
  147. package/dist/shared/visualization/ghost-cursor.d.ts +0 -37
  148. package/dist/shared/visualization/ghost-cursor.js +0 -145
  149. package/dist/shared/visualization/highlight.cjs +0 -134
  150. package/dist/shared/visualization/highlight.d.cts +0 -22
  151. package/dist/shared/visualization/highlight.d.ts +0 -22
  152. package/dist/shared/visualization/highlight.js +0 -108
  153. package/dist/shared/visualization/index.cjs +0 -45
  154. package/dist/shared/visualization/index.d.cts +0 -3
  155. package/dist/shared/visualization/index.d.ts +0 -3
  156. package/dist/shared/visualization/index.js +0 -24
  157. package/dist/shared/workflow/workflow.cjs +0 -47
  158. package/dist/shared/workflow/workflow.d.cts +0 -21
  159. package/dist/shared/workflow/workflow.d.ts +0 -21
  160. package/dist/shared/workflow/workflow.js +0 -21
package/dist/index.cjs DELETED
@@ -1,116 +0,0 @@
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 index_exports = {};
20
- __export(index_exports, {
21
- LIBRETTO_WORKFLOW_BRAND: () => import_workflow.LIBRETTO_WORKFLOW_BRAND,
22
- LibrettoWorkflow: () => import_workflow.LibrettoWorkflow,
23
- Logger: () => import_logger.Logger,
24
- SESSION_STATE_VERSION: () => import_state.SESSION_STATE_VERSION,
25
- SessionStateFileSchema: () => import_state.SessionStateFileSchema,
26
- SessionStatusSchema: () => import_state.SessionStatusSchema,
27
- attemptWithRecovery: () => import_recovery.attemptWithRecovery,
28
- clearHighlights: () => import_highlight.clearHighlights,
29
- createFileLogSink: () => import_sinks.createFileLogSink,
30
- createLLMClientFromModel: () => import_ai_sdk_adapter.createLLMClientFromModel,
31
- defaultLogger: () => import_logger.defaultLogger,
32
- detectSubmissionError: () => import_errors.detectSubmissionError,
33
- downloadAndSave: () => import_download.downloadAndSave,
34
- downloadViaClick: () => import_download.downloadViaClick,
35
- ensureGhostCursor: () => import_ghost_cursor.ensureGhostCursor,
36
- ensureHighlightLayer: () => import_highlight.ensureHighlightLayer,
37
- executeRecoveryAgent: () => import_agent.executeRecoveryAgent,
38
- extractFromPage: () => import_extract.extractFromPage,
39
- ghostClick: () => import_ghost_cursor.ghostClick,
40
- hideGhostCursor: () => import_ghost_cursor.hideGhostCursor,
41
- installInstrumentation: () => import_instrument.installInstrumentation,
42
- instrumentContext: () => import_instrument.instrumentContext,
43
- instrumentPage: () => import_instrument.instrumentPage,
44
- isDebugMode: () => import_config.isDebugMode,
45
- isDryRun: () => import_config.isDryRun,
46
- jsonlConsoleSink: () => import_sinks.jsonlConsoleSink,
47
- launchBrowser: () => import_api.launchBrowser,
48
- moveGhostCursor: () => import_ghost_cursor.moveGhostCursor,
49
- pageRequest: () => import_network.pageRequest,
50
- parseSessionStateContent: () => import_state.parseSessionStateContent,
51
- parseSessionStateData: () => import_state.parseSessionStateData,
52
- pause: () => import_pause.pause,
53
- prettyConsoleSink: () => import_sinks.prettyConsoleSink,
54
- serializeSessionState: () => import_state.serializeSessionState,
55
- shouldPauseBeforeMutation: () => import_config.shouldPauseBeforeMutation,
56
- showHighlight: () => import_highlight.showHighlight,
57
- workflow: () => import_workflow.workflow
58
- });
59
- module.exports = __toCommonJS(index_exports);
60
- var import_logger = require("./shared/logger/logger.js");
61
- var import_sinks = require("./shared/logger/sinks.js");
62
- var import_ai_sdk_adapter = require("./shared/llm/ai-sdk-adapter.js");
63
- var import_state = require("./shared/state/index.js");
64
- var import_agent = require("./runtime/recovery/agent.js");
65
- var import_recovery = require("./runtime/recovery/recovery.js");
66
- var import_errors = require("./runtime/recovery/errors.js");
67
- var import_extract = require("./runtime/extract/extract.js");
68
- var import_network = require("./runtime/network/network.js");
69
- var import_download = require("./runtime/download/download.js");
70
- var import_pause = require("./shared/debug/pause.js");
71
- var import_config = require("./shared/config/config.js");
72
- var import_instrument = require("./shared/instrumentation/instrument.js");
73
- var import_ghost_cursor = require("./shared/visualization/ghost-cursor.js");
74
- var import_highlight = require("./shared/visualization/highlight.js");
75
- var import_api = require("./shared/run/api.js");
76
- var import_workflow = require("./shared/workflow/workflow.js");
77
- // Annotate the CommonJS export names for ESM import in node:
78
- 0 && (module.exports = {
79
- LIBRETTO_WORKFLOW_BRAND,
80
- LibrettoWorkflow,
81
- Logger,
82
- SESSION_STATE_VERSION,
83
- SessionStateFileSchema,
84
- SessionStatusSchema,
85
- attemptWithRecovery,
86
- clearHighlights,
87
- createFileLogSink,
88
- createLLMClientFromModel,
89
- defaultLogger,
90
- detectSubmissionError,
91
- downloadAndSave,
92
- downloadViaClick,
93
- ensureGhostCursor,
94
- ensureHighlightLayer,
95
- executeRecoveryAgent,
96
- extractFromPage,
97
- ghostClick,
98
- hideGhostCursor,
99
- installInstrumentation,
100
- instrumentContext,
101
- instrumentPage,
102
- isDebugMode,
103
- isDryRun,
104
- jsonlConsoleSink,
105
- launchBrowser,
106
- moveGhostCursor,
107
- pageRequest,
108
- parseSessionStateContent,
109
- parseSessionStateData,
110
- pause,
111
- prettyConsoleSink,
112
- serializeSessionState,
113
- shouldPauseBeforeMutation,
114
- showHighlight,
115
- workflow
116
- });
package/dist/index.d.cts DELETED
@@ -1,21 +0,0 @@
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 DELETED
@@ -1,21 +0,0 @@
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 DELETED
@@ -1,97 +0,0 @@
1
- import { Logger, defaultLogger } from "./shared/logger/logger.js";
2
- import {
3
- createFileLogSink,
4
- prettyConsoleSink,
5
- jsonlConsoleSink
6
- } from "./shared/logger/sinks.js";
7
- import { createLLMClientFromModel } from "./shared/llm/ai-sdk-adapter.js";
8
- import {
9
- SESSION_STATE_VERSION,
10
- SessionStatusSchema,
11
- SessionStateFileSchema,
12
- parseSessionStateData,
13
- parseSessionStateContent,
14
- serializeSessionState
15
- } from "./shared/state/index.js";
16
- import { executeRecoveryAgent } from "./runtime/recovery/agent.js";
17
- import { attemptWithRecovery } from "./runtime/recovery/recovery.js";
18
- import {
19
- detectSubmissionError
20
- } from "./runtime/recovery/errors.js";
21
- import { extractFromPage } from "./runtime/extract/extract.js";
22
- import {
23
- pageRequest
24
- } from "./runtime/network/network.js";
25
- import {
26
- downloadViaClick,
27
- downloadAndSave
28
- } from "./runtime/download/download.js";
29
- import { pause } from "./shared/debug/pause.js";
30
- import {
31
- isDebugMode,
32
- isDryRun,
33
- shouldPauseBeforeMutation
34
- } from "./shared/config/config.js";
35
- import {
36
- instrumentPage,
37
- installInstrumentation,
38
- instrumentContext
39
- } from "./shared/instrumentation/instrument.js";
40
- import {
41
- ensureGhostCursor,
42
- moveGhostCursor,
43
- ghostClick,
44
- hideGhostCursor
45
- } from "./shared/visualization/ghost-cursor.js";
46
- import {
47
- ensureHighlightLayer,
48
- showHighlight,
49
- clearHighlights
50
- } from "./shared/visualization/highlight.js";
51
- import {
52
- launchBrowser
53
- } from "./shared/run/api.js";
54
- import {
55
- LibrettoWorkflow,
56
- LIBRETTO_WORKFLOW_BRAND,
57
- workflow
58
- } from "./shared/workflow/workflow.js";
59
- export {
60
- LIBRETTO_WORKFLOW_BRAND,
61
- LibrettoWorkflow,
62
- Logger,
63
- SESSION_STATE_VERSION,
64
- SessionStateFileSchema,
65
- SessionStatusSchema,
66
- attemptWithRecovery,
67
- clearHighlights,
68
- createFileLogSink,
69
- createLLMClientFromModel,
70
- defaultLogger,
71
- detectSubmissionError,
72
- downloadAndSave,
73
- downloadViaClick,
74
- ensureGhostCursor,
75
- ensureHighlightLayer,
76
- executeRecoveryAgent,
77
- extractFromPage,
78
- ghostClick,
79
- hideGhostCursor,
80
- installInstrumentation,
81
- instrumentContext,
82
- instrumentPage,
83
- isDebugMode,
84
- isDryRun,
85
- jsonlConsoleSink,
86
- launchBrowser,
87
- moveGhostCursor,
88
- pageRequest,
89
- parseSessionStateContent,
90
- parseSessionStateData,
91
- pause,
92
- prettyConsoleSink,
93
- serializeSessionState,
94
- shouldPauseBeforeMutation,
95
- showHighlight,
96
- workflow
97
- };
@@ -1,70 +0,0 @@
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
- });
@@ -1,35 +0,0 @@
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 };
@@ -1,35 +0,0 @@
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 };
@@ -1,45 +0,0 @@
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
- };
@@ -1,30 +0,0 @@
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
- });
@@ -1,3 +0,0 @@
1
- export { DownloadResult, DownloadViaClickOptions, SaveDownloadOptions, downloadAndSave, downloadViaClick } from './download.cjs';
2
- import 'playwright';
3
- import '../../shared/logger/logger.cjs';
@@ -1,3 +0,0 @@
1
- export { DownloadResult, DownloadViaClickOptions, SaveDownloadOptions, downloadAndSave, downloadViaClick } from './download.js';
2
- import 'playwright';
3
- import '../../shared/logger/logger.js';
@@ -1,8 +0,0 @@
1
- import {
2
- downloadViaClick,
3
- downloadAndSave
4
- } from "./download.js";
5
- export {
6
- downloadAndSave,
7
- downloadViaClick
8
- };
@@ -1,88 +0,0 @@
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
- });
@@ -1,23 +0,0 @@
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 };
@@ -1,23 +0,0 @@
1
- import { Page } from 'playwright';
2
- import z from 'zod';
3
- import { MinimalLogger } from '../../shared/logger/logger.js';
4
- import { LLMClient } from '../../shared/llm/types.js';
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 };