libretto 0.4.4 → 0.5.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 (194) hide show
  1. package/README.md +106 -36
  2. package/dist/cli/cli.js +39 -113
  3. package/dist/cli/commands/ai.js +1 -1
  4. package/dist/cli/commands/browser.js +87 -60
  5. package/dist/cli/commands/execution.js +201 -88
  6. package/dist/cli/commands/init.js +30 -8
  7. package/dist/cli/commands/logs.js +5 -6
  8. package/dist/cli/commands/shared.js +30 -29
  9. package/dist/cli/commands/snapshot.js +26 -39
  10. package/dist/cli/core/ai-config.js +9 -2
  11. package/dist/cli/core/api-snapshot-analyzer.js +15 -5
  12. package/dist/cli/core/browser.js +141 -33
  13. package/dist/cli/core/context.js +7 -18
  14. package/dist/cli/core/session-telemetry.js +5 -2
  15. package/dist/cli/core/session.js +23 -10
  16. package/dist/cli/core/snapshot-analyzer.js +16 -33
  17. package/dist/cli/core/snapshot-api-config.js +2 -6
  18. package/dist/cli/core/telemetry.js +10 -2
  19. package/dist/cli/framework/simple-cli.js +45 -25
  20. package/dist/cli/router.js +14 -21
  21. package/dist/cli/workers/run-integration-runtime.js +26 -7
  22. package/dist/cli/workers/run-integration-worker-protocol.js +3 -1
  23. package/dist/cli/workers/run-integration-worker.js +1 -4
  24. package/dist/index.d.ts +1 -2
  25. package/dist/index.js +7 -10
  26. package/dist/runtime/download/download.js +5 -1
  27. package/dist/runtime/extract/extract.js +11 -2
  28. package/dist/runtime/network/network.js +8 -1
  29. package/dist/runtime/recovery/agent.js +6 -2
  30. package/dist/runtime/recovery/errors.js +3 -1
  31. package/dist/runtime/recovery/recovery.js +3 -1
  32. package/dist/shared/condense-dom/condense-dom.js +6 -13
  33. package/dist/shared/config/config.d.ts +1 -9
  34. package/dist/shared/config/config.js +0 -18
  35. package/dist/shared/config/index.d.ts +2 -1
  36. package/dist/shared/config/index.js +0 -10
  37. package/dist/shared/debug/pause.js +9 -3
  38. package/dist/shared/instrumentation/instrument.js +101 -5
  39. package/dist/shared/llm/ai-sdk-adapter.js +3 -1
  40. package/dist/shared/llm/client.js +3 -1
  41. package/dist/shared/logger/index.js +4 -1
  42. package/dist/shared/paths/paths.js +2 -1
  43. package/dist/shared/paths/repo-root.d.ts +3 -0
  44. package/dist/shared/paths/repo-root.js +24 -0
  45. package/dist/shared/run/api.js +3 -1
  46. package/dist/shared/run/browser.js +7 -2
  47. package/dist/shared/state/session-state.d.ts +2 -1
  48. package/dist/shared/state/session-state.js +5 -2
  49. package/dist/shared/visualization/ghost-cursor.js +19 -10
  50. package/dist/shared/visualization/highlight.js +9 -6
  51. package/dist/shared/workflow/workflow.d.ts +4 -5
  52. package/dist/shared/workflow/workflow.js +3 -5
  53. package/package.json +11 -8
  54. package/scripts/check-skills-sync.mjs +25 -0
  55. package/scripts/compare-eval-summary.mjs +47 -0
  56. package/scripts/postinstall.mjs +26 -17
  57. package/scripts/prepare-release.sh +97 -0
  58. package/scripts/skills-libretto.mjs +103 -0
  59. package/scripts/summarize-evals.mjs +135 -0
  60. package/scripts/sync-skills.mjs +12 -0
  61. package/skills/libretto/SKILL.md +130 -377
  62. package/skills/libretto/references/auth-profiles.md +30 -0
  63. package/skills/libretto/{code-generation-rules.md → references/code-generation-rules.md} +27 -42
  64. package/skills/libretto/references/configuration-file-reference.md +53 -0
  65. package/skills/libretto/references/pages-and-page-targeting.md +29 -0
  66. package/skills/libretto/references/site-security-review.md +143 -0
  67. package/src/cli/cli.ts +86 -0
  68. package/src/cli/commands/ai.ts +35 -0
  69. package/src/cli/commands/browser.ts +189 -0
  70. package/src/cli/commands/execution.ts +822 -0
  71. package/src/cli/commands/init.ts +350 -0
  72. package/src/cli/commands/logs.ts +128 -0
  73. package/src/cli/commands/shared.ts +69 -0
  74. package/src/cli/commands/snapshot.ts +312 -0
  75. package/src/cli/core/ai-config.ts +264 -0
  76. package/src/cli/core/api-snapshot-analyzer.ts +108 -0
  77. package/src/cli/core/browser.ts +976 -0
  78. package/src/cli/core/context.ts +127 -0
  79. package/src/cli/core/pause-signals.ts +35 -0
  80. package/src/cli/core/session-telemetry.ts +564 -0
  81. package/src/cli/core/session.ts +223 -0
  82. package/src/cli/core/snapshot-analyzer.ts +855 -0
  83. package/src/cli/core/snapshot-api-config.ts +231 -0
  84. package/src/cli/core/telemetry.ts +459 -0
  85. package/src/cli/framework/simple-cli.ts +1340 -0
  86. package/src/cli/index.ts +13 -0
  87. package/src/cli/router.ts +20 -0
  88. package/src/cli/workers/run-integration-runtime.ts +338 -0
  89. package/src/cli/workers/run-integration-worker-protocol.ts +16 -0
  90. package/src/cli/workers/run-integration-worker.ts +72 -0
  91. package/src/index.ts +127 -0
  92. package/src/runtime/download/download.ts +104 -0
  93. package/src/runtime/download/index.ts +7 -0
  94. package/src/runtime/extract/extract.ts +102 -0
  95. package/src/runtime/extract/index.ts +1 -0
  96. package/src/runtime/network/index.ts +5 -0
  97. package/src/runtime/network/network.ts +119 -0
  98. package/{dist/runtime/recovery/agent.cjs → src/runtime/recovery/agent.ts} +114 -76
  99. package/src/runtime/recovery/errors.ts +155 -0
  100. package/src/runtime/recovery/index.ts +7 -0
  101. package/src/runtime/recovery/recovery.ts +53 -0
  102. package/{dist/shared/condense-dom/condense-dom.cjs → src/shared/condense-dom/condense-dom.ts} +249 -124
  103. package/src/shared/config/config.ts +3 -0
  104. package/src/shared/config/index.ts +0 -0
  105. package/src/shared/debug/index.ts +1 -0
  106. package/src/shared/debug/pause.ts +91 -0
  107. package/src/shared/instrumentation/errors.ts +84 -0
  108. package/src/shared/instrumentation/index.ts +9 -0
  109. package/src/shared/instrumentation/instrument.ts +406 -0
  110. package/src/shared/llm/ai-sdk-adapter.ts +81 -0
  111. package/{dist/shared/llm/client.cjs → src/shared/llm/client.ts} +86 -80
  112. package/src/shared/llm/index.ts +3 -0
  113. package/src/shared/llm/types.ts +63 -0
  114. package/src/shared/logger/index.ts +13 -0
  115. package/src/shared/logger/logger.ts +358 -0
  116. package/src/shared/logger/sinks.ts +148 -0
  117. package/src/shared/paths/paths.ts +110 -0
  118. package/src/shared/paths/repo-root.ts +27 -0
  119. package/src/shared/run/api.ts +6 -0
  120. package/src/shared/run/browser.ts +107 -0
  121. package/src/shared/state/index.ts +11 -0
  122. package/src/shared/state/session-state.ts +77 -0
  123. package/src/shared/visualization/ghost-cursor.ts +213 -0
  124. package/src/shared/visualization/highlight.ts +149 -0
  125. package/src/shared/visualization/index.ts +18 -0
  126. package/src/shared/workflow/workflow.ts +36 -0
  127. package/dist/index.cjs +0 -144
  128. package/dist/index.d.cts +0 -21
  129. package/dist/runtime/download/download.cjs +0 -70
  130. package/dist/runtime/download/download.d.cts +0 -35
  131. package/dist/runtime/download/index.cjs +0 -30
  132. package/dist/runtime/download/index.d.cts +0 -3
  133. package/dist/runtime/extract/extract.cjs +0 -88
  134. package/dist/runtime/extract/extract.d.cts +0 -23
  135. package/dist/runtime/extract/index.cjs +0 -28
  136. package/dist/runtime/extract/index.d.cts +0 -5
  137. package/dist/runtime/network/index.cjs +0 -28
  138. package/dist/runtime/network/index.d.cts +0 -4
  139. package/dist/runtime/network/network.cjs +0 -91
  140. package/dist/runtime/network/network.d.cts +0 -28
  141. package/dist/runtime/recovery/agent.d.cts +0 -13
  142. package/dist/runtime/recovery/errors.cjs +0 -124
  143. package/dist/runtime/recovery/errors.d.cts +0 -31
  144. package/dist/runtime/recovery/index.cjs +0 -34
  145. package/dist/runtime/recovery/index.d.cts +0 -7
  146. package/dist/runtime/recovery/recovery.cjs +0 -55
  147. package/dist/runtime/recovery/recovery.d.cts +0 -12
  148. package/dist/shared/condense-dom/condense-dom.d.cts +0 -34
  149. package/dist/shared/config/config.cjs +0 -44
  150. package/dist/shared/config/config.d.cts +0 -10
  151. package/dist/shared/config/index.cjs +0 -32
  152. package/dist/shared/config/index.d.cts +0 -1
  153. package/dist/shared/debug/index.cjs +0 -28
  154. package/dist/shared/debug/index.d.cts +0 -1
  155. package/dist/shared/debug/pause.cjs +0 -86
  156. package/dist/shared/debug/pause.d.cts +0 -12
  157. package/dist/shared/instrumentation/errors.cjs +0 -81
  158. package/dist/shared/instrumentation/errors.d.cts +0 -12
  159. package/dist/shared/instrumentation/index.cjs +0 -35
  160. package/dist/shared/instrumentation/index.d.cts +0 -6
  161. package/dist/shared/instrumentation/instrument.cjs +0 -206
  162. package/dist/shared/instrumentation/instrument.d.cts +0 -32
  163. package/dist/shared/llm/ai-sdk-adapter.cjs +0 -71
  164. package/dist/shared/llm/ai-sdk-adapter.d.cts +0 -22
  165. package/dist/shared/llm/client.d.cts +0 -13
  166. package/dist/shared/llm/index.cjs +0 -31
  167. package/dist/shared/llm/index.d.cts +0 -5
  168. package/dist/shared/llm/types.cjs +0 -16
  169. package/dist/shared/llm/types.d.cts +0 -67
  170. package/dist/shared/logger/index.cjs +0 -37
  171. package/dist/shared/logger/index.d.cts +0 -2
  172. package/dist/shared/logger/logger.cjs +0 -232
  173. package/dist/shared/logger/logger.d.cts +0 -86
  174. package/dist/shared/logger/sinks.cjs +0 -160
  175. package/dist/shared/logger/sinks.d.cts +0 -9
  176. package/dist/shared/paths/paths.cjs +0 -104
  177. package/dist/shared/paths/paths.d.cts +0 -10
  178. package/dist/shared/run/api.cjs +0 -28
  179. package/dist/shared/run/api.d.cts +0 -2
  180. package/dist/shared/run/browser.cjs +0 -98
  181. package/dist/shared/run/browser.d.cts +0 -22
  182. package/dist/shared/state/index.cjs +0 -38
  183. package/dist/shared/state/index.d.cts +0 -2
  184. package/dist/shared/state/session-state.cjs +0 -92
  185. package/dist/shared/state/session-state.d.cts +0 -40
  186. package/dist/shared/visualization/ghost-cursor.cjs +0 -174
  187. package/dist/shared/visualization/ghost-cursor.d.cts +0 -37
  188. package/dist/shared/visualization/highlight.cjs +0 -134
  189. package/dist/shared/visualization/highlight.d.cts +0 -22
  190. package/dist/shared/visualization/index.cjs +0 -45
  191. package/dist/shared/visualization/index.d.cts +0 -3
  192. package/dist/shared/workflow/workflow.cjs +0 -47
  193. package/dist/shared/workflow/workflow.d.cts +0 -21
  194. package/skills/libretto/integration-approach-selection.md +0 -174
@@ -1,134 +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 highlight_exports = {};
20
- __export(highlight_exports, {
21
- clearHighlights: () => clearHighlights,
22
- ensureHighlightLayer: () => ensureHighlightLayer,
23
- showHighlight: () => showHighlight
24
- });
25
- module.exports = __toCommonJS(highlight_exports);
26
- const HIGHLIGHT_DEFAULTS = {
27
- color: "rgba(59, 130, 246, 0.25)",
28
- zIndex: 2147483645
29
- };
30
- const LAYER_ID = "__libretto_highlight_layer__";
31
- function buildHighlightInitScript(opts) {
32
- return `
33
- (function() {
34
- if (document.getElementById("${LAYER_ID}")) return;
35
- var el = document.createElement("div");
36
- el.id = "${LAYER_ID}";
37
- el.style.cssText = "position:fixed;top:0;left:0;width:100%;height:100%;z-index:${opts.zIndex};pointer-events:none;overflow:hidden;";
38
- document.documentElement.appendChild(el);
39
- })();
40
- `;
41
- }
42
- const installedPages = /* @__PURE__ */ new WeakSet();
43
- async function ensureHighlightLayer(page, options) {
44
- const existingOpts = page.__librettoHighlightOpts;
45
- const zIndex = options?.zIndex ?? existingOpts?.zIndex ?? HIGHLIGHT_DEFAULTS.zIndex;
46
- const initScript = buildHighlightInitScript({ zIndex });
47
- if (!installedPages.has(page)) {
48
- installedPages.add(page);
49
- await page.addInitScript({ content: initScript });
50
- }
51
- page.__librettoHighlightOpts = {
52
- color: options?.color ?? existingOpts?.color ?? HIGHLIGHT_DEFAULTS.color,
53
- zIndex
54
- };
55
- try {
56
- await page.evaluate(new Function(initScript));
57
- } catch {
58
- }
59
- }
60
- async function showHighlight(page, params) {
61
- const opts = page.__librettoHighlightOpts ?? HIGHLIGHT_DEFAULTS;
62
- const color = params.color ?? opts.color;
63
- const durationMs = params.durationMs ?? 350;
64
- try {
65
- await page.evaluate(
66
- ({ layerId, box, color: color2, label, durationMs: durationMs2 }) => {
67
- const layer = document.getElementById(layerId);
68
- if (!layer) return;
69
- const rect = document.createElement("div");
70
- rect.className = "__libretto_highlight_rect__";
71
- rect.style.cssText = `
72
- position:absolute;
73
- left:${box.x}px;
74
- top:${box.y}px;
75
- width:${box.width}px;
76
- height:${box.height}px;
77
- background:${color2};
78
- border:2px solid ${color2.replace(/[\d.]+\)$/, "0.6)")};
79
- border-radius:3px;
80
- pointer-events:none;
81
- transition:opacity 200ms ease-out;
82
- opacity:1;
83
- `;
84
- if (label) {
85
- const labelEl = document.createElement("div");
86
- labelEl.textContent = label;
87
- labelEl.style.cssText = `
88
- position:absolute;
89
- top:-22px;
90
- left:0;
91
- font:11px/1.2 -apple-system,BlinkMacSystemFont,sans-serif;
92
- color:#fff;
93
- background:rgba(0,0,0,0.7);
94
- padding:2px 6px;
95
- border-radius:3px;
96
- white-space:nowrap;
97
- pointer-events:none;
98
- `;
99
- rect.appendChild(labelEl);
100
- }
101
- layer.appendChild(rect);
102
- setTimeout(() => {
103
- rect.style.opacity = "0";
104
- setTimeout(() => rect.remove(), 250);
105
- }, durationMs2);
106
- },
107
- {
108
- layerId: LAYER_ID,
109
- box: params.box,
110
- color,
111
- label: params.label,
112
- durationMs
113
- }
114
- );
115
- } catch {
116
- }
117
- }
118
- async function clearHighlights(page) {
119
- try {
120
- await page.evaluate(({ layerId }) => {
121
- const layer = document.getElementById(layerId);
122
- if (!layer) return;
123
- const rects = layer.querySelectorAll(".__libretto_highlight_rect__");
124
- rects.forEach((r) => r.remove());
125
- }, { layerId: LAYER_ID });
126
- } catch {
127
- }
128
- }
129
- // Annotate the CommonJS export names for ESM import in node:
130
- 0 && (module.exports = {
131
- clearHighlights,
132
- ensureHighlightLayer,
133
- showHighlight
134
- });
@@ -1,22 +0,0 @@
1
- import { Page } from 'playwright';
2
-
3
- type HighlightOptions = {
4
- color?: string;
5
- zIndex?: number;
6
- };
7
- declare function ensureHighlightLayer(page: Page, options?: HighlightOptions): Promise<void>;
8
- type ShowHighlightParams = {
9
- box: {
10
- x: number;
11
- y: number;
12
- width: number;
13
- height: number;
14
- };
15
- label?: string;
16
- color?: string;
17
- durationMs?: number;
18
- };
19
- declare function showHighlight(page: Page, params: ShowHighlightParams): Promise<void>;
20
- declare function clearHighlights(page: Page): Promise<void>;
21
-
22
- export { type HighlightOptions, type ShowHighlightParams, clearHighlights, ensureHighlightLayer, showHighlight };
@@ -1,45 +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 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
- });
@@ -1,3 +0,0 @@
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';
@@ -1,47 +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 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
- });
@@ -1,21 +0,0 @@
1
- import { Page } from 'playwright';
2
- import { MinimalLogger } from '../logger/logger.cjs';
3
-
4
- declare const LIBRETTO_WORKFLOW_BRAND: unique symbol;
5
- type LibrettoWorkflowMetadata = {};
6
- type LibrettoWorkflowContext<S = {}> = {
7
- page: Page;
8
- logger: MinimalLogger;
9
- services: S;
10
- };
11
- type LibrettoWorkflowHandler<Input = unknown, Output = unknown, S = {}> = (ctx: LibrettoWorkflowContext<S>, input: Input) => Promise<Output>;
12
- declare class LibrettoWorkflow<Input = unknown, Output = unknown, S = {}> {
13
- readonly [LIBRETTO_WORKFLOW_BRAND] = true;
14
- readonly metadata: LibrettoWorkflowMetadata;
15
- private readonly handler;
16
- constructor(metadata: LibrettoWorkflowMetadata, handler: LibrettoWorkflowHandler<Input, Output, S>);
17
- run(ctx: LibrettoWorkflowContext<S>, input: Input): Promise<Output>;
18
- }
19
- declare function workflow<Input = unknown, Output = unknown, S = {}>(metadata: LibrettoWorkflowMetadata, handler: LibrettoWorkflowHandler<Input, Output, S>): LibrettoWorkflow<Input, Output, S>;
20
-
21
- export { LIBRETTO_WORKFLOW_BRAND, LibrettoWorkflow, type LibrettoWorkflowContext, type LibrettoWorkflowHandler, type LibrettoWorkflowMetadata, workflow };
@@ -1,174 +0,0 @@
1
- # Integration Approach Selection Guide
2
-
3
- **Purpose:** You are connected to a live Chrome session on a target website. Your job is to probe the site for bot detection measures, assess its security posture, and determine the best integration strategy for data extraction. All strategies use Playwright for browser control — the question is what to **prioritize** for data capture: in-browser fetch calls, passive network interception, or DOM extraction.
4
-
5
- After completing the probes below, produce a **Site Assessment Summary** (see the output format at the end of this document).
6
-
7
- ---
8
-
9
- ## Probing the Site
10
-
11
- Run these probes to build a picture of the site's detection posture. The examples below are starting points — use your judgment to investigate further based on what you find. Sites may use detection methods not listed here.
12
-
13
- ### Probe 1: Bot Protection Services & Security Signals
14
-
15
- Look for signs that the site uses bot protection — either a third-party service or custom detection. There is no complete list of indicators; these are common examples.
16
-
17
- **Cookies to look for (examples, not exhaustive):**
18
-
19
- | Cookie Pattern | Associated Service |
20
- |---|---|
21
- | `_abck` | Akamai Bot Manager |
22
- | `_px*` | PerimeterX (HUMAN) |
23
- | `datadome` | DataDome |
24
- | `cf_clearance` | Cloudflare |
25
- | `_imp_apg_r_*` | Shape Security (F5) |
26
- | `x-kpsdk-*` | Kasada |
27
-
28
- But don't just check this list. Examine **all** cookies on the page — look for any cookies with obfuscated names, telemetry-related prefixes, or values that look like fingerprint hashes or encrypted tokens. Unknown security cookies are still security cookies.
29
-
30
- **Global variables to check (examples):**
31
-
32
- ```js
33
- // Known telemetry globals — but probe broadly, not just these
34
- window._pxAppId // PerimeterX
35
- window.bmak // Akamai
36
- window.ddjskey // DataDome
37
- ```
38
-
39
- Also examine the page's scripts: look at the first `<script>` tags in the document source, check what external domains scripts load from (e.g., `*.akamaized.net`, `*.perimeterx.net`, `*.datadome.co`, `*.kasada.io`). Bot protection scripts are typically injected before any application code.
40
-
41
- **Challenge pages:**
42
-
43
- Check if the page is showing a challenge or interstitial instead of real content — "Checking your browser...", CAPTCHA iframes, blank pages with only a spinner. These indicate active bot protection that has already been triggered.
44
-
45
- **General guidance:** The goal is to determine whether the site has bot protection and roughly how aggressive it is. Don't limit yourself to known signatures — look at the overall page behavior, unusual scripts, and anything that seems like security telemetry.
46
-
47
- ### Probe 2: Fetch / XHR Interception
48
-
49
- Check whether the site has monkey-patched `window.fetch` or `XMLHttpRequest`. If it has, making your own fetch calls from `page.evaluate()` is risky because the site can inspect call stacks and detect calls that don't originate from its own code.
50
-
51
- ```js
52
- // Check if fetch has been wrapped
53
- window.fetch.toString()
54
- // Native: "function fetch() { [native code] }"
55
- // Patched: shows actual JavaScript source
56
-
57
- // Check XMLHttpRequest
58
- XMLHttpRequest.prototype.open.toString()
59
-
60
- // Check property descriptors for tampering
61
- Object.getOwnPropertyDescriptor(window, 'fetch')
62
- // Normal: { value: ƒ, writable: true, enumerable: true, configurable: true }
63
-
64
- // Proxy-based wrapping is harder to detect — native fetch has no prototype
65
- window.fetch.hasOwnProperty('prototype') // true may indicate a Proxy wrapper
66
- ```
67
-
68
- **Important:** Some sites use `Proxy` to wrap fetch, which makes `toString()` still return `"[native code]"`. The prototype check is a heuristic, not definitive. If you see any sign of fetch interception, treat it as patched.
69
-
70
- ### Probe 3: Behavioral Monitoring
71
-
72
- Look for signs that the site collects behavioral telemetry (mouse movements, keystrokes, scroll patterns). Heavy monitoring means you should use natural, human-like interaction patterns when driving the UI.
73
-
74
- Things to check:
75
- - Unusually large numbers of event listeners on `document` or `body` for `mousemove`, `keydown`, `scroll`, `touchstart`, `click`
76
- - Known telemetry collection scripts
77
- - `MutationObserver` instances watching the DOM for injected elements
78
- - `requestAnimationFrame` loops that aren't tied to visible animations
79
-
80
- If you're in a DevTools context, `getEventListeners(document)` is the quickest way to assess this. Otherwise, use heuristics — heavy behavioral monitoring usually correlates with enterprise bot protection from Probe 1.
81
-
82
- ---
83
-
84
- ## Choosing a Data Capture Strategy
85
-
86
- Every integration uses Playwright to control the browser. The question is what to **prioritize** for getting data out. In practice, most integrations use a mix — you'll always need some Playwright interaction for navigation, login flows, cookie consent, etc. The strategies below describe what to lean on for the core data extraction.
87
-
88
- ### Strategy A: Prioritize `page.evaluate(fetch(...))`
89
-
90
- Make fetch calls directly from within the browser's JavaScript context. The requests share the browser's TLS fingerprint, cookies, and origin — they look identical to requests the site's own JS would make.
91
-
92
- **When to prioritize this:**
93
- - No enterprise bot protection detected
94
- - `fetch` is NOT monkey-patched
95
- - You've identified API endpoints that return the data you need
96
- - You need data that requires many API calls (deep pagination, bulk queries) where driving the UI would be slow
97
-
98
- **Why:** Maximum control and efficiency. You call exactly the endpoints you want with the parameters you want, skip UI rendering, and get structured JSON back. On sites without aggressive detection, this is the fastest and cleanest approach.
99
-
100
- **Risk:** If the site monitors fetch call stacks (Layer 4 detection), your calls will be flagged because they don't originate from the site's bundled code. This is uncommon but exists on high-security sites.
101
-
102
- **You'll still use Playwright for:** Initial navigation, login/auth flows, cookie consent, and any UI interactions needed to establish session state before making fetch calls.
103
-
104
- ### Strategy B: Prioritize `page.on('response', ...)` (Passive Interception)
105
-
106
- Listen to network responses that the browser naturally makes as you navigate. You don't make any extra requests — you capture data flowing through the site's own API calls.
107
-
108
- **When to prioritize this:**
109
- - Enterprise bot protection is detected
110
- - `fetch` IS monkey-patched
111
- - The site's normal UI flow triggers API calls that return the data you need
112
- - You want to minimize detection risk as much as possible
113
-
114
- **Why:** Zero additional network risk. The requests that happen are the ones the site's own code triggers. You're just listening. No anomalous call stacks, no unexpected request patterns, no extra fetch calls for monitoring to flag.
115
-
116
- **Trade-off:** You only get data the page naturally loads. If you need page 50 of results, you have to click "next" 49 times via Playwright. You must set up listeners before the navigation that triggers the requests.
117
-
118
- **You'll still use Playwright for:** All navigation and interaction to trigger the data-bearing API calls, plus any data that isn't available via intercepted responses (DOM-only content).
119
-
120
- ### Strategy C: Prioritize Playwright DOM Extraction
121
-
122
- Extract data directly from the rendered page using selectors and `page.evaluate()` to read DOM content.
123
-
124
- **When to prioritize this:**
125
- - Data is server-rendered (no JSON API calls observed)
126
- - The site doesn't expose the data you need via any API
127
- - You need visual/layout information that only exists in the DOM
128
- - As a fallback when Strategies A and B can't get specific pieces of data
129
-
130
- **Why:** Works regardless of the site's API architecture. If the data is visible on the page, you can extract it.
131
-
132
- **Trade-off:** Slower, fragile against DOM changes, and you only get data the UI renders (which may be less than what API responses contain).
133
-
134
- ---
135
-
136
- ## Decision Summary
137
-
138
- | Site Profile | Primary Strategy | Supplement With |
139
- |---|---|---|
140
- | No bot protection, fetch not patched | **A** (`page.evaluate(fetch)`) | Playwright for navigation/auth |
141
- | No bot protection, fetch IS patched | **B** (`page.on('response', ...)`) | Playwright for navigation; DOM extraction as fallback |
142
- | Bot protection detected, fetch not patched | **B** (`page.on('response', ...)`) | Playwright for all navigation; cautious use of `page.evaluate(fetch)` only if needed |
143
- | Bot protection detected, fetch IS patched | **B** (`page.on('response', ...)`) | Playwright for all navigation; DOM extraction as fallback |
144
- | Server-rendered content (no API calls) | **C** (DOM extraction) | Playwright for all interaction |
145
-
146
- ---
147
-
148
- ## Output: Site Assessment Summary
149
-
150
- After running the probes, produce a summary in this format. **Do NOT include a final strategy recommendation.** The security assessment determines what's *safe to use*, not what will *work*. Present this to the user for input, then use the safe approaches as you build the integration — adapting if specific endpoints don't work as expected (see "Handling Approach Mismatches" in SKILL.md).
151
-
152
- ```
153
- ## Site Assessment: [site URL]
154
-
155
- ### Bot Detection Profile
156
- - **Enterprise bot protection:** [None detected / Detected — describe what you found (service name if identifiable, cookies, scripts, telemetry globals)]
157
- - **Fetch/XHR interception:** [Native (not patched) / Patched — describe what you found]
158
- - **Behavioral monitoring:** [None detected / Light / Heavy — describe indicators]
159
- - **Challenge pages:** [None / Present — describe type (CAPTCHA, interstitial, etc.)]
160
- - **Overall security posture:** [None / Low / Moderate / High / Very High]
161
-
162
- ### API Surface
163
- - **API calls observed:** [List key endpoints discovered, or "None — content appears server-rendered"]
164
- - **Data format:** [JSON / GraphQL / HTML fragments / Other — note if any responses use proprietary/binary formats]
165
- - **Pagination:** [Describe how pagination works if applicable]
166
-
167
- ### Safe Approaches
168
- - **`page.evaluate(fetch(...))`:** [Safe / Unsafe — brief rationale based on fetch patching, bot detection, etc.]
169
- - **`page.on('response', ...)`:** [Viable / Not viable — note if response formats are parseable or proprietary]
170
- - **DOM extraction:** [Always available as fallback]
171
- - **Interaction notes:** [any behavioral precautions — natural mouse movements, typing delays, etc.]
172
- ```
173
-
174
- **Important:** This assessment tells you which tools are in your toolbox. Present it to the user, get their input, then start building the integration using the safe approaches.