libretto 0.1.5 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/README.md +215 -17
  2. package/bin/libretto.mjs +18 -0
  3. package/dist/cli/cli.js +203 -0
  4. package/dist/cli/commands/ai.js +21 -0
  5. package/dist/cli/commands/browser.js +59 -0
  6. package/dist/cli/commands/execution.js +422 -0
  7. package/dist/cli/commands/logs.js +93 -0
  8. package/dist/cli/commands/snapshot.js +106 -0
  9. package/dist/cli/core/ai-config.js +149 -0
  10. package/dist/cli/core/browser.js +523 -0
  11. package/dist/cli/core/context.js +113 -0
  12. package/dist/cli/core/pause-signals.js +29 -0
  13. package/dist/cli/core/session-telemetry.js +491 -0
  14. package/dist/cli/core/session.js +183 -0
  15. package/dist/cli/core/snapshot-analyzer.js +492 -0
  16. package/dist/cli/core/telemetry.js +362 -0
  17. package/dist/cli/index.js +13 -0
  18. package/dist/cli/workers/run-integration-runtime.js +222 -0
  19. package/dist/cli/workers/run-integration-worker-protocol.js +0 -0
  20. package/dist/cli/workers/run-integration-worker.js +83 -0
  21. package/dist/index.cjs +123 -0
  22. package/dist/index.d.cts +19 -0
  23. package/dist/index.d.ts +19 -0
  24. package/dist/index.js +107 -0
  25. package/dist/runtime/download/download.cjs +70 -0
  26. package/dist/runtime/download/download.d.cts +35 -0
  27. package/dist/runtime/download/download.d.ts +35 -0
  28. package/dist/runtime/download/download.js +45 -0
  29. package/dist/runtime/download/index.cjs +30 -0
  30. package/dist/runtime/download/index.d.cts +3 -0
  31. package/dist/runtime/download/index.d.ts +3 -0
  32. package/dist/runtime/download/index.js +8 -0
  33. package/dist/runtime/extract/extract.cjs +88 -0
  34. package/dist/runtime/extract/extract.d.cts +23 -0
  35. package/dist/runtime/extract/extract.d.ts +23 -0
  36. package/dist/runtime/extract/extract.js +64 -0
  37. package/dist/runtime/extract/index.cjs +28 -0
  38. package/dist/runtime/extract/index.d.cts +5 -0
  39. package/dist/runtime/extract/index.d.ts +5 -0
  40. package/dist/runtime/extract/index.js +4 -0
  41. package/dist/runtime/network/index.cjs +28 -0
  42. package/dist/runtime/network/index.d.cts +4 -0
  43. package/dist/runtime/network/index.d.ts +4 -0
  44. package/dist/runtime/network/index.js +6 -0
  45. package/dist/runtime/network/network.cjs +91 -0
  46. package/dist/runtime/network/network.d.cts +28 -0
  47. package/dist/runtime/network/network.d.ts +28 -0
  48. package/dist/runtime/network/network.js +67 -0
  49. package/dist/runtime/recovery/agent.cjs +223 -0
  50. package/dist/runtime/recovery/agent.d.cts +13 -0
  51. package/dist/runtime/recovery/agent.d.ts +13 -0
  52. package/dist/runtime/recovery/agent.js +199 -0
  53. package/dist/runtime/recovery/errors.cjs +124 -0
  54. package/dist/runtime/recovery/errors.d.cts +31 -0
  55. package/dist/runtime/recovery/errors.d.ts +31 -0
  56. package/dist/runtime/recovery/errors.js +100 -0
  57. package/dist/runtime/recovery/index.cjs +34 -0
  58. package/dist/runtime/recovery/index.d.cts +7 -0
  59. package/dist/runtime/recovery/index.d.ts +7 -0
  60. package/dist/runtime/recovery/index.js +10 -0
  61. package/dist/runtime/recovery/recovery.cjs +55 -0
  62. package/dist/runtime/recovery/recovery.d.cts +12 -0
  63. package/dist/runtime/recovery/recovery.d.ts +12 -0
  64. package/dist/runtime/recovery/recovery.js +31 -0
  65. package/dist/shared/config/config.cjs +44 -0
  66. package/dist/shared/config/config.d.cts +10 -0
  67. package/dist/shared/config/config.d.ts +10 -0
  68. package/dist/shared/config/config.js +18 -0
  69. package/dist/shared/config/index.cjs +32 -0
  70. package/dist/shared/config/index.d.cts +1 -0
  71. package/dist/shared/config/index.d.ts +1 -0
  72. package/dist/shared/config/index.js +10 -0
  73. package/dist/shared/debug/index.cjs +32 -0
  74. package/dist/shared/debug/index.d.cts +2 -0
  75. package/dist/shared/debug/index.d.ts +2 -0
  76. package/dist/shared/debug/index.js +10 -0
  77. package/dist/shared/debug/pause.cjs +56 -0
  78. package/dist/shared/debug/pause.d.cts +23 -0
  79. package/dist/shared/debug/pause.d.ts +23 -0
  80. package/dist/shared/debug/pause.js +30 -0
  81. package/dist/shared/instrumentation/errors.cjs +81 -0
  82. package/dist/shared/instrumentation/errors.d.cts +12 -0
  83. package/dist/shared/instrumentation/errors.d.ts +12 -0
  84. package/dist/shared/instrumentation/errors.js +57 -0
  85. package/dist/shared/instrumentation/index.cjs +35 -0
  86. package/dist/shared/instrumentation/index.d.cts +6 -0
  87. package/dist/shared/instrumentation/index.d.ts +6 -0
  88. package/dist/shared/instrumentation/index.js +12 -0
  89. package/dist/shared/instrumentation/instrument.cjs +206 -0
  90. package/dist/shared/instrumentation/instrument.d.cts +32 -0
  91. package/dist/shared/instrumentation/instrument.d.ts +32 -0
  92. package/dist/shared/instrumentation/instrument.js +190 -0
  93. package/dist/shared/llm/client.cjs +139 -0
  94. package/dist/shared/llm/client.d.cts +6 -0
  95. package/dist/shared/llm/client.d.ts +6 -0
  96. package/dist/shared/llm/client.js +115 -0
  97. package/dist/shared/llm/index.cjs +28 -0
  98. package/dist/shared/llm/index.d.cts +3 -0
  99. package/dist/shared/llm/index.d.ts +3 -0
  100. package/dist/shared/llm/index.js +4 -0
  101. package/dist/shared/llm/types.cjs +16 -0
  102. package/dist/shared/llm/types.d.cts +34 -0
  103. package/dist/shared/llm/types.d.ts +34 -0
  104. package/dist/shared/llm/types.js +0 -0
  105. package/dist/shared/logger/index.cjs +37 -0
  106. package/dist/shared/logger/index.d.cts +2 -0
  107. package/dist/shared/logger/index.d.ts +2 -0
  108. package/dist/shared/logger/index.js +13 -0
  109. package/dist/shared/logger/logger.cjs +213 -0
  110. package/dist/shared/logger/logger.d.cts +82 -0
  111. package/dist/shared/logger/logger.d.ts +82 -0
  112. package/dist/shared/logger/logger.js +188 -0
  113. package/dist/shared/logger/sinks.cjs +160 -0
  114. package/dist/shared/logger/sinks.d.cts +9 -0
  115. package/dist/shared/logger/sinks.d.ts +9 -0
  116. package/dist/shared/logger/sinks.js +124 -0
  117. package/dist/shared/paths/paths.cjs +104 -0
  118. package/dist/shared/paths/paths.d.cts +10 -0
  119. package/dist/shared/paths/paths.d.ts +10 -0
  120. package/dist/shared/paths/paths.js +73 -0
  121. package/dist/shared/run/api.cjs +35 -0
  122. package/dist/shared/run/api.d.cts +3 -0
  123. package/dist/shared/run/api.d.ts +3 -0
  124. package/dist/shared/run/api.js +12 -0
  125. package/dist/shared/run/browser.cjs +98 -0
  126. package/dist/shared/run/browser.d.cts +22 -0
  127. package/dist/shared/run/browser.d.ts +22 -0
  128. package/dist/shared/run/browser.js +74 -0
  129. package/dist/shared/state/index.cjs +38 -0
  130. package/dist/shared/state/index.d.cts +2 -0
  131. package/dist/shared/state/index.d.ts +2 -0
  132. package/dist/shared/state/index.js +16 -0
  133. package/dist/shared/state/session-state.cjs +85 -0
  134. package/dist/shared/state/session-state.d.cts +34 -0
  135. package/dist/shared/state/session-state.d.ts +34 -0
  136. package/dist/shared/state/session-state.js +56 -0
  137. package/dist/shared/visualization/ghost-cursor.cjs +174 -0
  138. package/dist/shared/visualization/ghost-cursor.d.cts +37 -0
  139. package/dist/shared/visualization/ghost-cursor.d.ts +37 -0
  140. package/dist/shared/visualization/ghost-cursor.js +145 -0
  141. package/dist/shared/visualization/highlight.cjs +134 -0
  142. package/dist/shared/visualization/highlight.d.cts +22 -0
  143. package/dist/shared/visualization/highlight.d.ts +22 -0
  144. package/dist/shared/visualization/highlight.js +108 -0
  145. package/dist/shared/visualization/index.cjs +45 -0
  146. package/dist/shared/visualization/index.d.cts +3 -0
  147. package/dist/shared/visualization/index.d.ts +3 -0
  148. package/dist/shared/visualization/index.js +24 -0
  149. package/dist/shared/workflow/workflow.cjs +47 -0
  150. package/dist/shared/workflow/workflow.d.cts +33 -0
  151. package/dist/shared/workflow/workflow.d.ts +33 -0
  152. package/dist/shared/workflow/workflow.js +21 -0
  153. package/package.json +125 -26
  154. package/.npmignore +0 -2
  155. package/bin/libretto +0 -31
  156. package/lib/connect.js +0 -34
  157. package/lib/export.js +0 -224
  158. package/lib/import.js +0 -166
  159. package/lib/index.js +0 -8
  160. package/lib/log.js +0 -9
  161. package/lib/validate.js +0 -20
  162. package/makefile +0 -8
  163. package/src/connect.coffee +0 -25
  164. package/src/export.coffee +0 -222
  165. package/src/import.coffee +0 -166
  166. package/src/index.coffee +0 -3
  167. package/src/log.coffee +0 -3
  168. package/src/validate.coffee +0 -10
@@ -0,0 +1,45 @@
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 visualization_exports = {};
20
+ __export(visualization_exports, {
21
+ clearHighlights: () => import_highlight.clearHighlights,
22
+ ensureGhostCursor: () => import_ghost_cursor.ensureGhostCursor,
23
+ ensureHighlightLayer: () => import_highlight.ensureHighlightLayer,
24
+ getGhostCursorPosition: () => import_ghost_cursor.getGhostCursorPosition,
25
+ ghostClick: () => import_ghost_cursor.ghostClick,
26
+ hideGhostCursor: () => import_ghost_cursor.hideGhostCursor,
27
+ moveGhostCursor: () => import_ghost_cursor.moveGhostCursor,
28
+ moveGhostCursorWithDistance: () => import_ghost_cursor.moveGhostCursorWithDistance,
29
+ showHighlight: () => import_highlight.showHighlight
30
+ });
31
+ module.exports = __toCommonJS(visualization_exports);
32
+ var import_ghost_cursor = require("./ghost-cursor.js");
33
+ var import_highlight = require("./highlight.js");
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ clearHighlights,
37
+ ensureGhostCursor,
38
+ ensureHighlightLayer,
39
+ getGhostCursorPosition,
40
+ ghostClick,
41
+ hideGhostCursor,
42
+ moveGhostCursor,
43
+ moveGhostCursorWithDistance,
44
+ showHighlight
45
+ });
@@ -0,0 +1,3 @@
1
+ export { GhostCursorOptions, GhostCursorStyle, ensureGhostCursor, getGhostCursorPosition, ghostClick, hideGhostCursor, moveGhostCursor, moveGhostCursorWithDistance } from './ghost-cursor.cjs';
2
+ export { HighlightOptions, ShowHighlightParams, clearHighlights, ensureHighlightLayer, showHighlight } from './highlight.cjs';
3
+ import 'playwright';
@@ -0,0 +1,3 @@
1
+ export { GhostCursorOptions, GhostCursorStyle, ensureGhostCursor, getGhostCursorPosition, ghostClick, hideGhostCursor, moveGhostCursor, moveGhostCursorWithDistance } from './ghost-cursor.js';
2
+ export { HighlightOptions, ShowHighlightParams, clearHighlights, ensureHighlightLayer, showHighlight } from './highlight.js';
3
+ import 'playwright';
@@ -0,0 +1,24 @@
1
+ import {
2
+ ensureGhostCursor,
3
+ moveGhostCursor,
4
+ moveGhostCursorWithDistance,
5
+ ghostClick,
6
+ hideGhostCursor,
7
+ getGhostCursorPosition
8
+ } from "./ghost-cursor.js";
9
+ import {
10
+ ensureHighlightLayer,
11
+ showHighlight,
12
+ clearHighlights
13
+ } from "./highlight.js";
14
+ export {
15
+ clearHighlights,
16
+ ensureGhostCursor,
17
+ ensureHighlightLayer,
18
+ getGhostCursorPosition,
19
+ ghostClick,
20
+ hideGhostCursor,
21
+ moveGhostCursor,
22
+ moveGhostCursorWithDistance,
23
+ showHighlight
24
+ };
@@ -0,0 +1,47 @@
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 workflow_exports = {};
20
+ __export(workflow_exports, {
21
+ LIBRETTO_WORKFLOW_BRAND: () => LIBRETTO_WORKFLOW_BRAND,
22
+ LibrettoWorkflow: () => LibrettoWorkflow,
23
+ workflow: () => workflow
24
+ });
25
+ module.exports = __toCommonJS(workflow_exports);
26
+ const LIBRETTO_WORKFLOW_BRAND = /* @__PURE__ */ Symbol.for("libretto.workflow");
27
+ class LibrettoWorkflow {
28
+ [LIBRETTO_WORKFLOW_BRAND] = true;
29
+ metadata;
30
+ handler;
31
+ constructor(metadata, handler) {
32
+ this.metadata = metadata;
33
+ this.handler = handler;
34
+ }
35
+ async run(ctx, input) {
36
+ return this.handler(ctx, input);
37
+ }
38
+ }
39
+ function workflow(metadata, handler) {
40
+ return new LibrettoWorkflow(metadata, handler);
41
+ }
42
+ // Annotate the CommonJS export names for ESM import in node:
43
+ 0 && (module.exports = {
44
+ LIBRETTO_WORKFLOW_BRAND,
45
+ LibrettoWorkflow,
46
+ workflow
47
+ });
@@ -0,0 +1,33 @@
1
+ import { Page, BrowserContext, Browser } from 'playwright';
2
+
3
+ declare const LIBRETTO_WORKFLOW_BRAND: unique symbol;
4
+ type LibrettoAuthProfile = {
5
+ type: "local";
6
+ domain: string;
7
+ };
8
+ type LibrettoWorkflowMetadata = {
9
+ authProfile?: LibrettoAuthProfile;
10
+ };
11
+ type LibrettoWorkflowContext = {
12
+ logger: unknown;
13
+ page: Page;
14
+ context: BrowserContext;
15
+ browser: Browser;
16
+ session: string;
17
+ integrationPath: string;
18
+ exportName: string;
19
+ headless: boolean;
20
+ debug: boolean;
21
+ pause: () => Promise<void>;
22
+ };
23
+ type LibrettoWorkflowHandler<Input = unknown, Output = unknown> = (ctx: LibrettoWorkflowContext, input: Input) => Promise<Output>;
24
+ declare class LibrettoWorkflow<Input = unknown, Output = unknown> {
25
+ readonly [LIBRETTO_WORKFLOW_BRAND] = true;
26
+ readonly metadata: LibrettoWorkflowMetadata;
27
+ private readonly handler;
28
+ constructor(metadata: LibrettoWorkflowMetadata, handler: LibrettoWorkflowHandler<Input, Output>);
29
+ run(ctx: LibrettoWorkflowContext, input: Input): Promise<Output>;
30
+ }
31
+ declare function workflow<Input = unknown, Output = unknown>(metadata: LibrettoWorkflowMetadata, handler: LibrettoWorkflowHandler<Input, Output>): LibrettoWorkflow<Input, Output>;
32
+
33
+ export { LIBRETTO_WORKFLOW_BRAND, type LibrettoAuthProfile, LibrettoWorkflow, type LibrettoWorkflowContext, type LibrettoWorkflowHandler, type LibrettoWorkflowMetadata, workflow };
@@ -0,0 +1,33 @@
1
+ import { Page, BrowserContext, Browser } from 'playwright';
2
+
3
+ declare const LIBRETTO_WORKFLOW_BRAND: unique symbol;
4
+ type LibrettoAuthProfile = {
5
+ type: "local";
6
+ domain: string;
7
+ };
8
+ type LibrettoWorkflowMetadata = {
9
+ authProfile?: LibrettoAuthProfile;
10
+ };
11
+ type LibrettoWorkflowContext = {
12
+ logger: unknown;
13
+ page: Page;
14
+ context: BrowserContext;
15
+ browser: Browser;
16
+ session: string;
17
+ integrationPath: string;
18
+ exportName: string;
19
+ headless: boolean;
20
+ debug: boolean;
21
+ pause: () => Promise<void>;
22
+ };
23
+ type LibrettoWorkflowHandler<Input = unknown, Output = unknown> = (ctx: LibrettoWorkflowContext, input: Input) => Promise<Output>;
24
+ declare class LibrettoWorkflow<Input = unknown, Output = unknown> {
25
+ readonly [LIBRETTO_WORKFLOW_BRAND] = true;
26
+ readonly metadata: LibrettoWorkflowMetadata;
27
+ private readonly handler;
28
+ constructor(metadata: LibrettoWorkflowMetadata, handler: LibrettoWorkflowHandler<Input, Output>);
29
+ run(ctx: LibrettoWorkflowContext, input: Input): Promise<Output>;
30
+ }
31
+ declare function workflow<Input = unknown, Output = unknown>(metadata: LibrettoWorkflowMetadata, handler: LibrettoWorkflowHandler<Input, Output>): LibrettoWorkflow<Input, Output>;
32
+
33
+ export { LIBRETTO_WORKFLOW_BRAND, type LibrettoAuthProfile, LibrettoWorkflow, type LibrettoWorkflowContext, type LibrettoWorkflowHandler, type LibrettoWorkflowMetadata, workflow };
@@ -0,0 +1,21 @@
1
+ const LIBRETTO_WORKFLOW_BRAND = /* @__PURE__ */ Symbol.for("libretto.workflow");
2
+ class LibrettoWorkflow {
3
+ [LIBRETTO_WORKFLOW_BRAND] = true;
4
+ metadata;
5
+ handler;
6
+ constructor(metadata, handler) {
7
+ this.metadata = metadata;
8
+ this.handler = handler;
9
+ }
10
+ async run(ctx, input) {
11
+ return this.handler(ctx, input);
12
+ }
13
+ }
14
+ function workflow(metadata, handler) {
15
+ return new LibrettoWorkflow(metadata, handler);
16
+ }
17
+ export {
18
+ LIBRETTO_WORKFLOW_BRAND,
19
+ LibrettoWorkflow,
20
+ workflow
21
+ };
package/package.json CHANGED
@@ -1,35 +1,134 @@
1
1
  {
2
2
  "name": "libretto",
3
- "version": "0.1.5",
4
- "description": "libretto ========",
5
- "main": "./lib/index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
3
+ "version": "0.2.1",
4
+ "description": "AI-powered browser automation library and CLI built on Playwright",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/saffron-health/libretto"
8
9
  },
10
+ "type": "module",
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "bin"
17
+ ],
9
18
  "bin": {
10
- "libretto": "./bin/libretto"
19
+ "libretto": "./bin/libretto.mjs",
20
+ "libretto-cli": "./bin/libretto.mjs"
11
21
  },
12
- "repository": {
13
- "type": "git",
14
- "url": "git://github.com/crcn/libretto.git"
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/index.d.ts",
25
+ "import": "./dist/index.js",
26
+ "require": "./dist/index.cjs"
27
+ },
28
+ "./logger": {
29
+ "types": "./dist/shared/logger/index.d.ts",
30
+ "import": "./dist/shared/logger/index.js",
31
+ "require": "./dist/shared/logger/index.cjs"
32
+ },
33
+ "./recovery": {
34
+ "types": "./dist/runtime/recovery/index.d.ts",
35
+ "import": "./dist/runtime/recovery/index.js",
36
+ "require": "./dist/runtime/recovery/index.cjs"
37
+ },
38
+ "./extract": {
39
+ "types": "./dist/runtime/extract/index.d.ts",
40
+ "import": "./dist/runtime/extract/index.js",
41
+ "require": "./dist/runtime/extract/index.cjs"
42
+ },
43
+ "./network": {
44
+ "types": "./dist/runtime/network/index.d.ts",
45
+ "import": "./dist/runtime/network/index.js",
46
+ "require": "./dist/runtime/network/index.cjs"
47
+ },
48
+ "./download": {
49
+ "types": "./dist/runtime/download/index.d.ts",
50
+ "import": "./dist/runtime/download/index.js",
51
+ "require": "./dist/runtime/download/index.cjs"
52
+ },
53
+ "./debug": {
54
+ "types": "./dist/shared/debug/index.d.ts",
55
+ "import": "./dist/shared/debug/index.js",
56
+ "require": "./dist/shared/debug/index.cjs"
57
+ },
58
+ "./config": {
59
+ "types": "./dist/shared/config/index.d.ts",
60
+ "import": "./dist/shared/config/index.js",
61
+ "require": "./dist/shared/config/index.cjs"
62
+ },
63
+ "./instrumentation": {
64
+ "types": "./dist/shared/instrumentation/index.d.ts",
65
+ "import": "./dist/shared/instrumentation/index.js",
66
+ "require": "./dist/shared/instrumentation/index.cjs"
67
+ },
68
+ "./visualization": {
69
+ "types": "./dist/shared/visualization/index.d.ts",
70
+ "import": "./dist/shared/visualization/index.js",
71
+ "require": "./dist/shared/visualization/index.cjs"
72
+ },
73
+ "./llm": {
74
+ "types": "./dist/shared/llm/index.d.ts",
75
+ "import": "./dist/shared/llm/index.js",
76
+ "require": "./dist/shared/llm/index.cjs"
77
+ },
78
+ "./state": {
79
+ "types": "./dist/shared/state/index.d.ts",
80
+ "import": "./dist/shared/state/index.js",
81
+ "require": "./dist/shared/state/index.cjs"
82
+ },
83
+ "./run": {
84
+ "types": "./dist/shared/run/api.d.ts",
85
+ "import": "./dist/shared/run/api.js",
86
+ "require": "./dist/shared/run/api.cjs"
87
+ }
88
+ },
89
+ "scripts": {
90
+ "postinstall": "node ./scripts/postinstall.mjs; npx playwright install chromium",
91
+ "build": "pnpm run build:runtime && pnpm run build:cli",
92
+ "build:runtime": "tsup --config tsup.config.ts",
93
+ "build:cli": "tsup --config tsup.cli.config.ts",
94
+ "type-check": "tsc --noEmit",
95
+ "dev": "tsx src/cli/index.ts",
96
+ "test": "pnpm run build && vitest run",
97
+ "test:watch": "vitest"
98
+ },
99
+ "peerDependencies": {
100
+ "@ai-sdk/anthropic": "^3.0.0",
101
+ "@ai-sdk/google-vertex": "^4.0.0",
102
+ "@ai-sdk/openai": "^3.0.0",
103
+ "zod": ">=3.0.0"
104
+ },
105
+ "peerDependenciesMeta": {
106
+ "@ai-sdk/anthropic": {
107
+ "optional": true
108
+ },
109
+ "@ai-sdk/google-vertex": {
110
+ "optional": true
111
+ },
112
+ "@ai-sdk/openai": {
113
+ "optional": true
114
+ }
115
+ },
116
+ "devDependencies": {
117
+ "@ai-sdk/anthropic": "^3.0.53",
118
+ "@ai-sdk/google-vertex": "^4.0.72",
119
+ "@ai-sdk/openai": "^3.0.39",
120
+ "@types/node": "^25.3.3",
121
+ "@types/yargs": "^17.0.33",
122
+ "openai": "^6.27.0",
123
+ "tsup": "^8.0.0",
124
+ "tsx": "^4.19.2",
125
+ "typescript": "^5.7.0",
126
+ "vitest": "^4.0.18",
127
+ "zod": "^3.25.0"
15
128
  },
16
- "author": "",
17
- "license": "BSD",
18
- "readmeFilename": "README.md",
19
- "gitHead": "e4c500dd1e07a33eb4ca80731c085967c2d4add3",
20
129
  "dependencies": {
21
- "commander": "~2.0.0",
22
- "mongodb": "~1.3.19",
23
- "comerr": "0.0.6",
24
- "verify": "0.0.7",
25
- "mkdirp": "~0.3.5",
26
- "outcome": "0.0.18",
27
- "stepc": "0.0.3",
28
- "async": "~0.2.9",
29
- "traverse": "~0.6.3",
30
- "step": "0.0.x",
31
- "type-component": "0.0.1",
32
- "memoizee": "~0.2.6",
33
- "glob": "~3.2.8"
130
+ "ai": "^6.0.110",
131
+ "playwright": "^1.52.0",
132
+ "yargs": "^17.7.2"
34
133
  }
35
134
  }
package/.npmignore DELETED
@@ -1,2 +0,0 @@
1
- node_modules
2
-
package/bin/libretto DELETED
@@ -1,31 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- var commander = require("commander"),
4
- libretto = require("..");
5
-
6
- commander.
7
- option("-y, --yes", "yes to any prompt that shows up").
8
- option("-v, --verbose", "verbose mode").
9
- option("-d, --database <host>", "database to use");
10
-
11
-
12
- function complete(err) {
13
- if(err) console.error("Error: %s", err.stack);
14
- process.exit();
15
- }
16
-
17
- commander.
18
- command("import [path]").
19
- description("import fixtures").
20
- action(function(path) {
21
- libretto.import({ path: path, db: commander.database, verbose: true }, complete);
22
- });
23
-
24
- commander.
25
- command("export [path]").
26
- description("export fixtures").
27
- action(function(path) {
28
- libretto.export({ path: path, db: commander.database, verbose: true }, complete);
29
- });
30
-
31
- commander.parse(process.argv);
package/lib/connect.js DELETED
@@ -1,34 +0,0 @@
1
- // Generated by CoffeeScript 1.7.0
2
- (function() {
3
- var client, connect, memoize, mongodb, step, _log;
4
-
5
- mongodb = require("mongodb");
6
-
7
- client = mongodb.MongoClient;
8
-
9
- step = require("step");
10
-
11
- memoize = require("memoizee");
12
-
13
- _log = require("./log");
14
-
15
-
16
- /*
17
- connects to the database
18
- */
19
-
20
- connect = memoize((function(db, next) {
21
- if (!~db.indexOf("mongodb://")) {
22
- db = "mongodb://127.0.0.1:27017/" + db;
23
- }
24
- _log("connecting to %s", db);
25
- return client.connect(db, next);
26
- }), {
27
- async: true
28
- });
29
-
30
- module.exports = function(options, next) {
31
- return connect(options.db, next);
32
- };
33
-
34
- }).call(this);
package/lib/export.js DELETED
@@ -1,224 +0,0 @@
1
- // Generated by CoffeeScript 1.7.0
2
- (function() {
3
- var async, attachRefs, attachRefs2, connect, exportCollection, exportCollections, fs, loadCollections, mapItemRelationships, mkdirp, mongodb, outcome, stepc, traverse, type, validate, _log;
4
-
5
- stepc = require("stepc");
6
-
7
- outcome = require("outcome");
8
-
9
- async = require("async");
10
-
11
- mkdirp = require("mkdirp");
12
-
13
- fs = require("fs");
14
-
15
- type = require("type-component");
16
-
17
- traverse = require("traverse");
18
-
19
- validate = require("./validate");
20
-
21
- connect = require("./connect");
22
-
23
- mongodb = require("mongodb");
24
-
25
- _log = require("./log");
26
-
27
-
28
- /*
29
- */
30
-
31
- module.exports = function(options, next) {
32
- var o;
33
- o = outcome.e(next);
34
- return stepc.async(o.s(function() {
35
- var e;
36
- try {
37
- mkdirp.sync(options.path);
38
- } catch (_error) {
39
- e = _error;
40
- }
41
- return this();
42
- }), o.s(function() {
43
- return connect({
44
- db: options.db
45
- }, this);
46
- }), o.s(function(db) {
47
- this.db = db;
48
- return db.collectionNames(this);
49
- }), o.s(function(names) {
50
- var collections;
51
- collections = names.map((function(_this) {
52
- return function(data) {
53
- return _this.db.collection(data.name.split(".").slice(1).join("."));
54
- };
55
- })(this));
56
- return exportCollections(options, collections, this);
57
- }), next);
58
- };
59
-
60
-
61
- /*
62
- */
63
-
64
- exportCollections = function(options, collections, next) {
65
- return loadCollections(collections, function(err, collections) {
66
- mapItemRelationships(collections);
67
- return async.eachSeries(collections, exportCollection(options), next);
68
- });
69
- };
70
-
71
-
72
- /*
73
- */
74
-
75
- mapItemRelationships = function(collections) {
76
- var all, collection, item, key, _i, _j, _len, _len1, _ref, _results;
77
- _log("mapping item relationships");
78
- all = {};
79
- for (_i = 0, _len = collections.length; _i < _len; _i++) {
80
- collection = collections[_i];
81
- _ref = collection.items;
82
- for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
83
- item = _ref[_j];
84
- all[item.data._id] = item;
85
- }
86
- }
87
- _results = [];
88
- for (key in all) {
89
- item = all[key];
90
- _results.push(attachRefs(item, all, collections));
91
- }
92
- return _results;
93
- };
94
-
95
- attachRefs = function(item, all) {
96
- var keys;
97
- keys = [];
98
- return traverse(item.data).forEach(function(x) {
99
- var key, p, r, ref, refs;
100
- keys = [];
101
- p = this;
102
- while (p) {
103
- if (isNaN(p.key) && p.key) {
104
- keys.unshift(p.key);
105
- }
106
- p = p.parent;
107
- }
108
- key = keys.join(".");
109
- if (ref = all[x]) {
110
- refs = ref.refs;
111
- if (!(r = refs[item.collection])) {
112
- r = refs[item.collection] = [];
113
- }
114
- if (!~r.indexOf(key)) {
115
- r.push(key);
116
- }
117
- }
118
- if (x && typeof x === "object" && !/^(Array|Object)$/.test(x.constructor.name)) {
119
- this.update({
120
- __type: x.constructor.name,
121
- value: x
122
- });
123
- return this.block();
124
- }
125
- });
126
- };
127
-
128
-
129
- /*
130
- */
131
-
132
- attachRefs2 = function(item, all, current, keys) {
133
- var key, kp, r, ref, refs, sub, t, value, _i, _len;
134
- if (keys == null) {
135
- keys = [];
136
- }
137
- if (!current) {
138
- current = item;
139
- }
140
- for (key in current) {
141
- value = current[key];
142
- if ((ref = all[value])) {
143
- kp = keys.concat(key).join(".");
144
- refs = ref.__refs;
145
- if (!(r = refs[item.__collection])) {
146
- r = refs[item.__collection] = [];
147
- }
148
- if (!~r.indexOf(kp)) {
149
- r.push(kp);
150
- }
151
- } else if ((t = type(value)) === "array") {
152
- for (_i = 0, _len = value.length; _i < _len; _i++) {
153
- sub = value[_i];
154
- if (sub) {
155
- attachRefs(item, all, sub, keys.concat(key));
156
- }
157
- }
158
- } else if (t === "object" && value) {
159
- attachRefs(item, all, value, keys.concat());
160
- }
161
- if (value && (typeof value === "object") && !/^Array|Object$/.test(value.constructor.name)) {
162
- current[key] = {
163
- __type: value.constructor.name,
164
- value: value
165
- };
166
- }
167
- }
168
- return refs;
169
- };
170
-
171
-
172
- /*
173
- */
174
-
175
- loadCollections = function(collections, next) {
176
- var data;
177
- data = [];
178
- return async.eachSeries(collections, (function(collection, next) {
179
- return collection.find().toArray(function(err, result) {
180
- if (err != null) {
181
- return next(err);
182
- }
183
- _log("loaded %s (%d)", collection.collectionName, result.length);
184
- data.push({
185
- name: collection.collectionName,
186
- items: result.map(function(item) {
187
- return {
188
- data: item,
189
- collection: collection.collectionName,
190
- refs: {},
191
- method: "insert"
192
- };
193
- })
194
- });
195
- return next();
196
- });
197
- }), function(err) {
198
- if (err != null) {
199
- return next(err);
200
- }
201
- return next(null, data);
202
- });
203
- };
204
-
205
-
206
- /*
207
- */
208
-
209
- exportCollection = function(options) {
210
- return function(collection, next) {
211
- var o, path;
212
- path = options.path + "/" + collection.name + ".json";
213
- _log("exporting %s", collection.name);
214
- o = outcome.e(next);
215
- if (collection.items.length === 0) {
216
- return next();
217
- }
218
- return stepc.async(o.s(function(results) {
219
- return fs.writeFile(path, JSON.stringify(collection.items, null, 2), this);
220
- }), next);
221
- };
222
- };
223
-
224
- }).call(this);