libretto 0.4.4 → 0.5.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 (152) hide show
  1. package/dist/cli/cli.js +20 -19
  2. package/dist/cli/commands/ai.js +1 -1
  3. package/dist/cli/commands/browser.js +3 -3
  4. package/dist/cli/commands/execution.js +3 -3
  5. package/dist/cli/commands/logs.js +1 -1
  6. package/dist/cli/core/browser.js +11 -6
  7. package/dist/cli/core/context.js +4 -18
  8. package/dist/cli/core/session.js +2 -2
  9. package/dist/cli/core/snapshot-analyzer.js +2 -2
  10. package/dist/cli/router.js +1 -1
  11. package/dist/cli/workers/run-integration-runtime.js +2 -2
  12. package/dist/shared/paths/paths.js +2 -1
  13. package/dist/shared/paths/repo-root.d.ts +3 -0
  14. package/dist/shared/paths/repo-root.js +24 -0
  15. package/package.json +6 -7
  16. package/scripts/postinstall.mjs +12 -3
  17. package/skills/libretto/SKILL.md +93 -404
  18. package/skills/libretto/references/auth-profiles.md +30 -0
  19. package/skills/libretto/references/pages-and-page-targeting.md +29 -0
  20. package/skills/libretto/references/reverse-engineering-network-requests.md +39 -0
  21. package/skills/libretto/references/user-action-log.md +31 -0
  22. package/src/cli/cli.ts +173 -0
  23. package/src/cli/commands/ai.ts +35 -0
  24. package/src/cli/commands/browser.ts +165 -0
  25. package/src/cli/commands/execution.ts +691 -0
  26. package/src/cli/commands/init.ts +327 -0
  27. package/src/cli/commands/logs.ts +128 -0
  28. package/src/cli/commands/shared.ts +70 -0
  29. package/src/cli/commands/snapshot.ts +327 -0
  30. package/src/cli/core/ai-config.ts +255 -0
  31. package/src/cli/core/api-snapshot-analyzer.ts +97 -0
  32. package/src/cli/core/browser.ts +839 -0
  33. package/src/cli/core/context.ts +122 -0
  34. package/src/cli/core/pause-signals.ts +35 -0
  35. package/src/cli/core/session-telemetry.ts +553 -0
  36. package/src/cli/core/session.ts +209 -0
  37. package/src/cli/core/snapshot-analyzer.ts +875 -0
  38. package/src/cli/core/snapshot-api-config.ts +236 -0
  39. package/src/cli/core/telemetry.ts +446 -0
  40. package/src/cli/framework/simple-cli.ts +1273 -0
  41. package/src/cli/index.ts +13 -0
  42. package/src/cli/router.ts +28 -0
  43. package/src/cli/workers/run-integration-runtime.ts +311 -0
  44. package/src/cli/workers/run-integration-worker-protocol.ts +14 -0
  45. package/src/cli/workers/run-integration-worker.ts +75 -0
  46. package/src/index.ts +120 -0
  47. package/src/runtime/download/download.ts +100 -0
  48. package/src/runtime/download/index.ts +7 -0
  49. package/src/runtime/extract/extract.ts +92 -0
  50. package/src/runtime/extract/index.ts +1 -0
  51. package/src/runtime/network/index.ts +5 -0
  52. package/src/runtime/network/network.ts +113 -0
  53. package/src/runtime/recovery/agent.ts +256 -0
  54. package/src/runtime/recovery/errors.ts +152 -0
  55. package/src/runtime/recovery/index.ts +7 -0
  56. package/src/runtime/recovery/recovery.ts +50 -0
  57. package/{dist/shared/condense-dom/condense-dom.cjs → src/shared/condense-dom/condense-dom.ts} +243 -115
  58. package/src/shared/config/config.ts +22 -0
  59. package/src/shared/config/index.ts +5 -0
  60. package/src/shared/debug/index.ts +1 -0
  61. package/src/shared/debug/pause.ts +85 -0
  62. package/src/shared/instrumentation/errors.ts +82 -0
  63. package/src/shared/instrumentation/index.ts +9 -0
  64. package/src/shared/instrumentation/instrument.ts +276 -0
  65. package/src/shared/llm/ai-sdk-adapter.ts +78 -0
  66. package/src/shared/llm/client.ts +217 -0
  67. package/src/shared/llm/index.ts +3 -0
  68. package/src/shared/llm/types.ts +63 -0
  69. package/src/shared/logger/index.ts +6 -0
  70. package/src/shared/logger/logger.ts +352 -0
  71. package/src/shared/logger/sinks.ts +144 -0
  72. package/src/shared/paths/paths.ts +109 -0
  73. package/src/shared/paths/repo-root.ts +27 -0
  74. package/src/shared/run/api.ts +2 -0
  75. package/src/shared/run/browser.ts +98 -0
  76. package/src/shared/state/index.ts +11 -0
  77. package/src/shared/state/session-state.ts +74 -0
  78. package/src/shared/visualization/ghost-cursor.ts +200 -0
  79. package/src/shared/visualization/highlight.ts +146 -0
  80. package/src/shared/visualization/index.ts +18 -0
  81. package/src/shared/workflow/workflow.ts +42 -0
  82. package/dist/index.cjs +0 -144
  83. package/dist/index.d.cts +0 -21
  84. package/dist/runtime/download/download.cjs +0 -70
  85. package/dist/runtime/download/download.d.cts +0 -35
  86. package/dist/runtime/download/index.cjs +0 -30
  87. package/dist/runtime/download/index.d.cts +0 -3
  88. package/dist/runtime/extract/extract.cjs +0 -88
  89. package/dist/runtime/extract/extract.d.cts +0 -23
  90. package/dist/runtime/extract/index.cjs +0 -28
  91. package/dist/runtime/extract/index.d.cts +0 -5
  92. package/dist/runtime/network/index.cjs +0 -28
  93. package/dist/runtime/network/index.d.cts +0 -4
  94. package/dist/runtime/network/network.cjs +0 -91
  95. package/dist/runtime/network/network.d.cts +0 -28
  96. package/dist/runtime/recovery/agent.cjs +0 -223
  97. package/dist/runtime/recovery/agent.d.cts +0 -13
  98. package/dist/runtime/recovery/errors.cjs +0 -124
  99. package/dist/runtime/recovery/errors.d.cts +0 -31
  100. package/dist/runtime/recovery/index.cjs +0 -34
  101. package/dist/runtime/recovery/index.d.cts +0 -7
  102. package/dist/runtime/recovery/recovery.cjs +0 -55
  103. package/dist/runtime/recovery/recovery.d.cts +0 -12
  104. package/dist/shared/condense-dom/condense-dom.d.cts +0 -34
  105. package/dist/shared/config/config.cjs +0 -44
  106. package/dist/shared/config/config.d.cts +0 -10
  107. package/dist/shared/config/index.cjs +0 -32
  108. package/dist/shared/config/index.d.cts +0 -1
  109. package/dist/shared/debug/index.cjs +0 -28
  110. package/dist/shared/debug/index.d.cts +0 -1
  111. package/dist/shared/debug/pause.cjs +0 -86
  112. package/dist/shared/debug/pause.d.cts +0 -12
  113. package/dist/shared/instrumentation/errors.cjs +0 -81
  114. package/dist/shared/instrumentation/errors.d.cts +0 -12
  115. package/dist/shared/instrumentation/index.cjs +0 -35
  116. package/dist/shared/instrumentation/index.d.cts +0 -6
  117. package/dist/shared/instrumentation/instrument.cjs +0 -206
  118. package/dist/shared/instrumentation/instrument.d.cts +0 -32
  119. package/dist/shared/llm/ai-sdk-adapter.cjs +0 -71
  120. package/dist/shared/llm/ai-sdk-adapter.d.cts +0 -22
  121. package/dist/shared/llm/client.cjs +0 -218
  122. package/dist/shared/llm/client.d.cts +0 -13
  123. package/dist/shared/llm/index.cjs +0 -31
  124. package/dist/shared/llm/index.d.cts +0 -5
  125. package/dist/shared/llm/types.cjs +0 -16
  126. package/dist/shared/llm/types.d.cts +0 -67
  127. package/dist/shared/logger/index.cjs +0 -37
  128. package/dist/shared/logger/index.d.cts +0 -2
  129. package/dist/shared/logger/logger.cjs +0 -232
  130. package/dist/shared/logger/logger.d.cts +0 -86
  131. package/dist/shared/logger/sinks.cjs +0 -160
  132. package/dist/shared/logger/sinks.d.cts +0 -9
  133. package/dist/shared/paths/paths.cjs +0 -104
  134. package/dist/shared/paths/paths.d.cts +0 -10
  135. package/dist/shared/run/api.cjs +0 -28
  136. package/dist/shared/run/api.d.cts +0 -2
  137. package/dist/shared/run/browser.cjs +0 -98
  138. package/dist/shared/run/browser.d.cts +0 -22
  139. package/dist/shared/state/index.cjs +0 -38
  140. package/dist/shared/state/index.d.cts +0 -2
  141. package/dist/shared/state/session-state.cjs +0 -92
  142. package/dist/shared/state/session-state.d.cts +0 -40
  143. package/dist/shared/visualization/ghost-cursor.cjs +0 -174
  144. package/dist/shared/visualization/ghost-cursor.d.cts +0 -37
  145. package/dist/shared/visualization/highlight.cjs +0 -134
  146. package/dist/shared/visualization/highlight.d.cts +0 -22
  147. package/dist/shared/visualization/index.cjs +0 -45
  148. package/dist/shared/visualization/index.d.cts +0 -3
  149. package/dist/shared/workflow/workflow.cjs +0 -47
  150. package/dist/shared/workflow/workflow.d.cts +0 -21
  151. package/skills/libretto/code-generation-rules.md +0 -223
  152. package/skills/libretto/integration-approach-selection.md +0 -174
@@ -1,232 +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 logger_exports = {};
20
- __export(logger_exports, {
21
- Logger: () => Logger,
22
- defaultLogger: () => defaultLogger
23
- });
24
- module.exports = __toCommonJS(logger_exports);
25
- function generateId() {
26
- return Math.random().toString(36).substring(2, 15);
27
- }
28
- const defaultLogger = {
29
- info(event, data) {
30
- console.log(`[INFO] ${event}`, data ?? "");
31
- },
32
- warn(event, data) {
33
- console.warn(`[WARN] ${event}`, data ?? "");
34
- },
35
- error(event, data) {
36
- console.error(`[ERROR] ${event}`, data ?? "");
37
- }
38
- };
39
- const sinkLifecycleState = /* @__PURE__ */ new WeakMap();
40
- function getSinkLifecycleState(sink) {
41
- const existingState = sinkLifecycleState.get(sink);
42
- if (existingState) {
43
- return existingState;
44
- }
45
- const initialState = { closed: false };
46
- sinkLifecycleState.set(sink, initialState);
47
- return initialState;
48
- }
49
- function isSinkClosedOrClosing(sink) {
50
- const state = sinkLifecycleState.get(sink);
51
- return Boolean(state?.closed || state?.closing);
52
- }
53
- async function closeSinkOnce(sink) {
54
- if (!sink.close) {
55
- return;
56
- }
57
- const state = getSinkLifecycleState(sink);
58
- if (state.closed) {
59
- return;
60
- }
61
- if (state.closing) {
62
- return state.closing;
63
- }
64
- state.closing = (async () => {
65
- try {
66
- await sink.close?.();
67
- } catch {
68
- } finally {
69
- state.closed = true;
70
- state.closing = void 0;
71
- }
72
- })();
73
- return state.closing;
74
- }
75
- function isObject(value) {
76
- return typeof value === "object" && value !== null;
77
- }
78
- function removeUndefined(data) {
79
- if (typeof data === "object" && data !== null) {
80
- return Object.fromEntries(
81
- Object.entries(data).filter(([_, value]) => value !== void 0)
82
- );
83
- }
84
- return data;
85
- }
86
- class Logger {
87
- constructor(scopes = [], sinks = [], scopeData = {}) {
88
- this.scopes = scopes;
89
- this.sinks = sinks;
90
- this.scopeData = scopeData;
91
- this.prefix = scopes.join(".");
92
- }
93
- prefix;
94
- entry(entry) {
95
- this.sinks.forEach((sink) => {
96
- if (isSinkClosedOrClosing(sink)) {
97
- return;
98
- }
99
- sink.write({
100
- id: generateId(),
101
- scope: this.prefix,
102
- level: entry.level,
103
- event: entry.event,
104
- data: removeUndefined({ ...this.scopeData, ...entry.data }),
105
- options: entry.options
106
- });
107
- });
108
- }
109
- log(event, data, options) {
110
- this.entry({ level: "log", event, data, options });
111
- }
112
- error(event, dataOrError, options) {
113
- const data = dataOrError instanceof Error ? {
114
- error: {
115
- type: dataOrError.constructor.name,
116
- message: dataOrError.message,
117
- stack: dataOrError.stack || null
118
- }
119
- } : isObject(dataOrError) && dataOrError.error instanceof Error ? {
120
- ...dataOrError,
121
- error: {
122
- type: dataOrError.error.constructor.name,
123
- message: dataOrError.error.message,
124
- stack: dataOrError.error.stack || null
125
- }
126
- } : isObject(dataOrError) ? dataOrError : dataOrError !== void 0 ? { error: dataOrError } : void 0;
127
- this.entry({
128
- level: "error",
129
- event,
130
- data,
131
- options
132
- });
133
- if (dataOrError instanceof Error) {
134
- return dataOrError;
135
- }
136
- if (isObject(dataOrError) && dataOrError.error instanceof Error) {
137
- return dataOrError.error;
138
- }
139
- let message = event;
140
- if (data !== void 0) {
141
- try {
142
- message += "\n" + JSON.stringify(data, void 0, 2);
143
- } catch {
144
- message += "\n[Unserializable error data]";
145
- }
146
- }
147
- return new Error(message);
148
- }
149
- warn(event, dataOrError, options) {
150
- const data = dataOrError instanceof Error ? {
151
- error: {
152
- type: dataOrError.constructor.name,
153
- message: dataOrError.message,
154
- stack: dataOrError.stack || null
155
- }
156
- } : isObject(dataOrError) && dataOrError.error instanceof Error ? {
157
- ...dataOrError,
158
- error: {
159
- type: dataOrError.error.constructor.name,
160
- message: dataOrError.error.message,
161
- stack: dataOrError.error.stack || null
162
- }
163
- } : isObject(dataOrError) ? dataOrError : dataOrError !== void 0 ? { error: dataOrError } : void 0;
164
- this.entry({
165
- level: "warn",
166
- event,
167
- data,
168
- options
169
- });
170
- }
171
- info(event, dataOrError, options) {
172
- const data = dataOrError instanceof Error ? {
173
- error: {
174
- type: dataOrError.constructor.name,
175
- message: dataOrError.message,
176
- stack: dataOrError.stack || null
177
- }
178
- } : isObject(dataOrError) && dataOrError.error instanceof Error ? {
179
- ...dataOrError,
180
- error: {
181
- type: dataOrError.error.constructor.name,
182
- message: dataOrError.error.message,
183
- stack: dataOrError.error.stack || null
184
- }
185
- } : isObject(dataOrError) ? dataOrError : dataOrError !== void 0 ? { error: dataOrError } : void 0;
186
- this.entry({
187
- level: "info",
188
- event,
189
- data,
190
- options
191
- });
192
- }
193
- withScope(scope, context = {}) {
194
- return new Logger([...this.scopes, scope], this.sinks, {
195
- ...this.scopeData,
196
- ...context
197
- });
198
- }
199
- withContext(context) {
200
- return new Logger(this.scopes, this.sinks, {
201
- ...this.scopeData,
202
- ...context
203
- });
204
- }
205
- withSink(sink) {
206
- return new Logger(this.scopes, [...this.sinks, sink]);
207
- }
208
- async flush() {
209
- for (let i = this.sinks.length - 1; i >= 0; i--) {
210
- const sink = this.sinks[i];
211
- if (!sink) continue;
212
- if (isSinkClosedOrClosing(sink)) continue;
213
- try {
214
- await sink.flush?.();
215
- } catch {
216
- }
217
- }
218
- }
219
- async close() {
220
- await this.flush();
221
- for (let i = this.sinks.length - 1; i >= 0; i--) {
222
- const sink = this.sinks[i];
223
- if (!sink) continue;
224
- await closeSinkOnce(sink);
225
- }
226
- }
227
- }
228
- // Annotate the CommonJS export names for ESM import in node:
229
- 0 && (module.exports = {
230
- Logger,
231
- defaultLogger
232
- });
@@ -1,86 +0,0 @@
1
- type LogOptions = {
2
- timestamp?: Date;
3
- };
4
- /**
5
- * Minimal logger interface accepted by public-facing runtime functions.
6
- * Any logger with info/warn/error methods satisfies this — no need to
7
- * implement withScope, withContext, flush, etc.
8
- */
9
- type MinimalLogger = {
10
- info: (event: string, data?: any) => void;
11
- warn: (event: string, data?: any) => void;
12
- error: (event: string, data?: any) => any;
13
- };
14
- /** Default console logger used when callers omit the logger option. */
15
- declare const defaultLogger: MinimalLogger;
16
- type LoggerApi = {
17
- log: (event: string, data?: Record<string, any>, options?: LogOptions) => void;
18
- /**
19
- * Logs an error and returns an Error object that can be thrown
20
- *
21
- * either pass in an Error directly as data or as { error: Error, ...other_data }
22
- */
23
- error: (event: string, data?: Error | ({
24
- error: Error;
25
- } & Record<string, any>) | unknown, options?: LogOptions) => Error;
26
- warn: (event: string, data?: Error | ({
27
- error: Error;
28
- } & Record<string, any>) | unknown, options?: LogOptions) => void;
29
- info: (event: string, data?: Error | ({
30
- error: Error;
31
- } & Record<string, any>) | unknown, options?: LogOptions) => void;
32
- /**
33
- * Context passed in will be attached to all entries in this scope.
34
- */
35
- withScope: (scope: string, context?: Record<string, any>) => LoggerApi;
36
- /**
37
- * Context passed in will be attached to all entries.
38
- */
39
- withContext: (context: Record<string, any>) => LoggerApi;
40
- /**
41
- * Flushes all sinks in reverse order (most recently added first).
42
- */
43
- flush: () => Promise<void>;
44
- };
45
- type LoggerSink = {
46
- write: (args: {
47
- id: string;
48
- scope: string;
49
- level: "log" | "error" | "warn" | "info";
50
- event: string;
51
- data: Record<string, any>;
52
- options?: LogOptions;
53
- }) => void;
54
- flush?: () => Promise<void>;
55
- close?: () => Promise<void>;
56
- };
57
- declare class Logger implements LoggerApi {
58
- private readonly scopes;
59
- private readonly sinks;
60
- private readonly scopeData;
61
- private readonly prefix;
62
- constructor(scopes?: string[], sinks?: LoggerSink[], scopeData?: Record<string, any>);
63
- entry(entry: {
64
- level: "log" | "error" | "warn" | "info";
65
- event: string;
66
- data?: Record<string, any>;
67
- options?: LogOptions;
68
- }): void;
69
- log(event: string, data?: Record<string, any>, options?: LogOptions): void;
70
- error(event: string, dataOrError?: Error | ({
71
- error: Error;
72
- } & Record<string, any>) | unknown, options?: LogOptions): Error;
73
- warn(event: string, dataOrError?: Error | ({
74
- error: Error;
75
- } & Record<string, any>) | unknown, options?: LogOptions): void;
76
- info(event: string, dataOrError?: Error | ({
77
- error: Error;
78
- } & Record<string, any>) | unknown, options?: LogOptions): void;
79
- withScope(scope: string, context?: Record<string, any>): LoggerApi;
80
- withContext(context: Record<string, any>): LoggerApi;
81
- withSink(sink: LoggerSink): Logger;
82
- flush(): Promise<void>;
83
- close(): Promise<void>;
84
- }
85
-
86
- export { type LogOptions, Logger, type LoggerApi, type LoggerSink, type MinimalLogger, defaultLogger };
@@ -1,160 +0,0 @@
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 sinks_exports = {};
30
- __export(sinks_exports, {
31
- createFileLogSink: () => createFileLogSink,
32
- jsonlConsoleSink: () => jsonlConsoleSink,
33
- prettyConsoleSink: () => prettyConsoleSink
34
- });
35
- module.exports = __toCommonJS(sinks_exports);
36
- var fs = __toESM(require("node:fs"), 1);
37
- var path = __toESM(require("node:path"), 1);
38
- function createFileLogSink({
39
- filePath
40
- }) {
41
- fs.mkdirSync(path.dirname(filePath), { recursive: true });
42
- const writeStream = fs.createWriteStream(filePath, { flags: "a" });
43
- return {
44
- write: ({ id, scope, level, event, data, options }) => {
45
- if (writeStream.destroyed || writeStream.writableEnded) {
46
- return;
47
- }
48
- const timestamp = options?.timestamp || /* @__PURE__ */ new Date();
49
- const logEntry = {
50
- timestamp: timestamp.toISOString(),
51
- id,
52
- level,
53
- scope,
54
- event,
55
- data
56
- };
57
- const jsonLine = JSON.stringify(logEntry) + "\n";
58
- try {
59
- writeStream.write(jsonLine, (error) => {
60
- if (error) {
61
- console.error("Failed to write to log file:", error);
62
- console[level]({ id, scope, event, data, timestamp });
63
- }
64
- });
65
- } catch (error) {
66
- console.error("Failed to write to log file:", error);
67
- console[level]({ id, scope, event, data, timestamp });
68
- }
69
- },
70
- flush: () => new Promise((resolve, reject) => {
71
- if (!writeStream.writable || writeStream.writableEnded || writeStream.destroyed) {
72
- resolve();
73
- return;
74
- }
75
- writeStream.write("", (error) => {
76
- if (error) {
77
- reject(error);
78
- } else {
79
- resolve();
80
- }
81
- });
82
- }),
83
- close: () => new Promise((resolve) => {
84
- if (writeStream.destroyed || writeStream.closed) {
85
- resolve();
86
- return;
87
- }
88
- let settled = false;
89
- const done = () => {
90
- if (settled) return;
91
- settled = true;
92
- resolve();
93
- };
94
- writeStream.once("finish", done);
95
- writeStream.once("close", done);
96
- writeStream.once("error", done);
97
- try {
98
- writeStream.end();
99
- } catch {
100
- done();
101
- }
102
- })
103
- };
104
- }
105
- const colors = {
106
- reset: "\x1B[0m",
107
- gray: "\x1B[90m",
108
- red: "\x1B[31m",
109
- yellow: "\x1B[33m",
110
- blue: "\x1B[34m",
111
- cyan: "\x1B[36m"
112
- };
113
- function formatTimestamp(date) {
114
- return date.toISOString().replace("T", " ").replace("Z", "");
115
- }
116
- const prettyConsoleSink = {
117
- write: ({ scope, level, event, data, options }) => {
118
- const timestamp = `${colors.gray}${formatTimestamp(options?.timestamp || /* @__PURE__ */ new Date())}${colors.reset}`;
119
- const levelColor = level === "error" ? colors.red : level === "warn" ? colors.yellow : colors.blue;
120
- const coloredScope = scope ? `${colors.cyan}[${scope}]${colors.reset}` : "";
121
- const logPrefix = `${timestamp} ${levelColor}${level.toUpperCase()}${colors.reset} ${coloredScope} ${event}`;
122
- if (level === "error" && data.error) {
123
- const { error, ...otherData } = data;
124
- console.error(logPrefix);
125
- if (error.stack) {
126
- console.error(` ${error.stack}`);
127
- } else if (error.type && error.message) {
128
- console.error(` ${error.type}: ${error.message}`);
129
- }
130
- if (Object.keys(otherData).length > 0) {
131
- console.error(JSON.stringify(otherData, null, 2));
132
- }
133
- } else {
134
- console[level](logPrefix);
135
- if (Object.keys(data).length > 0) {
136
- console[level](JSON.stringify(data, null, 2));
137
- }
138
- }
139
- }
140
- };
141
- const jsonlConsoleSink = {
142
- write: ({ id, scope, level, event, data, options }) => {
143
- const timestamp = options?.timestamp || /* @__PURE__ */ new Date();
144
- const logEntry = {
145
- timestamp: timestamp.toISOString(),
146
- id,
147
- level,
148
- scope: scope || void 0,
149
- event,
150
- data
151
- };
152
- console.log(JSON.stringify(logEntry));
153
- }
154
- };
155
- // Annotate the CommonJS export names for ESM import in node:
156
- 0 && (module.exports = {
157
- createFileLogSink,
158
- jsonlConsoleSink,
159
- prettyConsoleSink
160
- });
@@ -1,9 +0,0 @@
1
- import { LoggerSink } from './logger.cjs';
2
-
3
- declare function createFileLogSink({ filePath, }: {
4
- filePath: string;
5
- }): LoggerSink;
6
- declare const prettyConsoleSink: LoggerSink;
7
- declare const jsonlConsoleSink: LoggerSink;
8
-
9
- export { createFileLogSink, jsonlConsoleSink, prettyConsoleSink };
@@ -1,104 +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 paths_exports = {};
20
- __export(paths_exports, {
21
- ensureLibrettoPauseSignalDir: () => ensureLibrettoPauseSignalDir,
22
- ensureLibrettoRunnerLogDir: () => ensureLibrettoRunnerLogDir,
23
- ensureLibrettoSessionStatePath: () => ensureLibrettoSessionStatePath,
24
- getLibrettoPauseSignalDir: () => getLibrettoPauseSignalDir,
25
- getLibrettoPausedSignalPath: () => getLibrettoPausedSignalPath,
26
- getLibrettoResumeSignalPath: () => getLibrettoResumeSignalPath,
27
- getPauseSignalPathForDir: () => getPauseSignalPathForDir,
28
- getRunnerLogPathForDir: () => getRunnerLogPathForDir
29
- });
30
- module.exports = __toCommonJS(paths_exports);
31
- var import_node_fs = require("node:fs");
32
- var import_node_path = require("node:path");
33
- const LIBRETTO_DIRNAME = ".libretto";
34
- const LIBRETTO_SESSIONS_DIRNAME = "sessions";
35
- const SESSION_STATE_FILENAME = "state.json";
36
- const RUNNER_LOG_DIRNAME = "logs";
37
- const RUNNER_LOG_FILENAME = "logs.jsonl";
38
- const PAUSED_SIGNAL_SUFFIX = "paused";
39
- const RESUME_SIGNAL_SUFFIX = "resume";
40
- function getLibrettoRoot(cwd = process.cwd()) {
41
- return (0, import_node_path.join)(cwd, LIBRETTO_DIRNAME);
42
- }
43
- function getLibrettoSessionsDir(cwd = process.cwd()) {
44
- return (0, import_node_path.join)(getLibrettoRoot(cwd), LIBRETTO_SESSIONS_DIRNAME);
45
- }
46
- function getLibrettoSessionDir(sessionName, cwd = process.cwd()) {
47
- return (0, import_node_path.join)(getLibrettoSessionsDir(cwd), sessionName);
48
- }
49
- function getLibrettoSessionStatePath(sessionName, cwd = process.cwd()) {
50
- return (0, import_node_path.join)(getLibrettoSessionDir(sessionName, cwd), SESSION_STATE_FILENAME);
51
- }
52
- function getLibrettoPauseSignalDir(sessionName, cwd = process.cwd()) {
53
- return getLibrettoSessionDir(sessionName, cwd);
54
- }
55
- function getLibrettoRunnerLogDir(sessionName, cwd = process.cwd()) {
56
- return (0, import_node_path.join)(getLibrettoSessionDir(sessionName, cwd), RUNNER_LOG_DIRNAME);
57
- }
58
- function getRunnerLogPathForDir(logDir) {
59
- return (0, import_node_path.join)(logDir, RUNNER_LOG_FILENAME);
60
- }
61
- function getPauseSignalPathForDir(signalDir, sessionName, signal) {
62
- const suffix = signal === "paused" ? PAUSED_SIGNAL_SUFFIX : RESUME_SIGNAL_SUFFIX;
63
- return (0, import_node_path.join)(signalDir, `${sessionName}.${suffix}`);
64
- }
65
- function getLibrettoPausedSignalPath(sessionName, cwd = process.cwd()) {
66
- return getPauseSignalPathForDir(
67
- getLibrettoPauseSignalDir(sessionName, cwd),
68
- sessionName,
69
- "paused"
70
- );
71
- }
72
- function getLibrettoResumeSignalPath(sessionName, cwd = process.cwd()) {
73
- return getPauseSignalPathForDir(
74
- getLibrettoPauseSignalDir(sessionName, cwd),
75
- sessionName,
76
- "resume"
77
- );
78
- }
79
- function ensureLibrettoSessionStatePath(sessionName, cwd = process.cwd()) {
80
- const filePath = getLibrettoSessionStatePath(sessionName, cwd);
81
- (0, import_node_fs.mkdirSync)((0, import_node_path.dirname)(filePath), { recursive: true });
82
- return filePath;
83
- }
84
- function ensureLibrettoPauseSignalDir(sessionName, cwd = process.cwd()) {
85
- const dir = getLibrettoPauseSignalDir(sessionName, cwd);
86
- (0, import_node_fs.mkdirSync)(dir, { recursive: true });
87
- return dir;
88
- }
89
- function ensureLibrettoRunnerLogDir(sessionName, cwd = process.cwd()) {
90
- const dir = getLibrettoRunnerLogDir(sessionName, cwd);
91
- (0, import_node_fs.mkdirSync)(dir, { recursive: true });
92
- return dir;
93
- }
94
- // Annotate the CommonJS export names for ESM import in node:
95
- 0 && (module.exports = {
96
- ensureLibrettoPauseSignalDir,
97
- ensureLibrettoRunnerLogDir,
98
- ensureLibrettoSessionStatePath,
99
- getLibrettoPauseSignalDir,
100
- getLibrettoPausedSignalPath,
101
- getLibrettoResumeSignalPath,
102
- getPauseSignalPathForDir,
103
- getRunnerLogPathForDir
104
- });
@@ -1,10 +0,0 @@
1
- declare function getLibrettoPauseSignalDir(sessionName: string, cwd?: string): string;
2
- declare function getRunnerLogPathForDir(logDir: string): string;
3
- declare function getPauseSignalPathForDir(signalDir: string, sessionName: string, signal: "paused" | "resume"): string;
4
- declare function getLibrettoPausedSignalPath(sessionName: string, cwd?: string): string;
5
- declare function getLibrettoResumeSignalPath(sessionName: string, cwd?: string): string;
6
- declare function ensureLibrettoSessionStatePath(sessionName: string, cwd?: string): string;
7
- declare function ensureLibrettoPauseSignalDir(sessionName: string, cwd?: string): string;
8
- declare function ensureLibrettoRunnerLogDir(sessionName: string, cwd?: string): string;
9
-
10
- export { ensureLibrettoPauseSignalDir, ensureLibrettoRunnerLogDir, ensureLibrettoSessionStatePath, getLibrettoPauseSignalDir, getLibrettoPausedSignalPath, getLibrettoResumeSignalPath, getPauseSignalPathForDir, getRunnerLogPathForDir };
@@ -1,28 +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 api_exports = {};
20
- __export(api_exports, {
21
- launchBrowser: () => import_browser.launchBrowser
22
- });
23
- module.exports = __toCommonJS(api_exports);
24
- var import_browser = require("./browser.js");
25
- // Annotate the CommonJS export names for ESM import in node:
26
- 0 && (module.exports = {
27
- launchBrowser
28
- });
@@ -1,2 +0,0 @@
1
- export { BrowserSession, LaunchBrowserArgs, launchBrowser } from './browser.cjs';
2
- import 'playwright';