autokap 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/chrome/ios-statusbar-comparison-reference.jpg +0 -0
- package/assets/chrome/ios-statusbar-dark-reference.jpg +0 -0
- package/assets/chrome/ios-statusbar-light-reference.jpg +0 -0
- package/assets/cursors/macos.svg +4 -0
- package/assets/cursors/windows.svg +15 -0
- package/assets/devices/ipad-pro-11-m4.json +52 -0
- package/assets/devices/iphone-16-pro.json +53 -0
- package/assets/devices/macbook-air-13.json +45 -0
- package/assets/frames/MacBook Air 13.svg +242 -0
- package/assets/frames/Status bar - iPhone.png +0 -0
- Menu bar- iPad.png +0 -0
- package/assets/frames/iPad Pro M4 11_.png +0 -0
- package/assets/frames/iPhone 16 Pro.png +0 -0
- package/assets/icons/Cellular Connection.svg +3 -0
- package/assets/icons/Union.svg +6 -0
- package/assets/icons/Wifi.svg +3 -0
- package/assets/icons/battery.svg +5 -0
- package/assets/icons/battery_charging.svg +8 -0
- package/assets/skill/OPCODE-REFERENCE.md +607 -0
- package/assets/skill/README.md +39 -0
- package/assets/skill/SKILL.md +453 -468
- package/assets/skill/STUDIO-SKILL.md +476 -0
- package/assets/skill/references/examples.md +104 -0
- package/assets/skill/references/interactive-demo.md +225 -0
- package/assets/skill/references/mock-data.md +178 -0
- package/dist/abort.d.ts +5 -0
- package/dist/abort.js +44 -0
- package/dist/action-verifier.d.ts +29 -0
- package/dist/action-verifier.js +133 -0
- package/dist/agent-action-recovery.d.ts +45 -0
- package/dist/agent-action-recovery.js +370 -0
- package/dist/agent-message-utils.d.ts +21 -0
- package/dist/agent-message-utils.js +77 -0
- package/dist/agent-url-utils.d.ts +30 -0
- package/dist/agent-url-utils.js +138 -0
- package/dist/agent.d.ts +226 -0
- package/dist/agent.js +6666 -0
- package/dist/ak-tree.d.ts +39 -0
- package/dist/ak-tree.js +368 -0
- package/dist/alt-text.d.ts +26 -0
- package/dist/alt-text.js +55 -0
- package/dist/auth-capture.d.ts +17 -0
- package/dist/auth-capture.js +164 -0
- package/dist/benchmark.d.ts +59 -0
- package/dist/benchmark.js +135 -0
- package/dist/billing-operation-logging.d.ts +38 -0
- package/dist/billing-operation-logging.js +248 -0
- package/dist/browser-bar.d.ts +48 -0
- package/dist/browser-bar.js +284 -0
- package/dist/browser-pool.d.ts +7 -0
- package/dist/browser-pool.js +15 -5
- package/dist/browser-utils.d.ts +31 -0
- package/dist/browser-utils.js +97 -0
- package/dist/browser.d.ts +76 -1
- package/dist/browser.js +1657 -39
- package/dist/capture-alt-text.d.ts +12 -0
- package/dist/capture-alt-text.js +52 -0
- package/dist/capture-encryption.d.ts +10 -0
- package/dist/capture-encryption.js +41 -0
- package/dist/capture-language-preflight.d.ts +41 -0
- package/dist/capture-language-preflight.js +300 -0
- package/dist/capture-llm-page-identity.d.ts +15 -0
- package/dist/capture-llm-page-identity.js +128 -0
- package/dist/capture-model-resolution.d.ts +9 -0
- package/dist/capture-model-resolution.js +21 -0
- package/dist/capture-page-identity.d.ts +7 -0
- package/dist/capture-page-identity.js +352 -0
- package/dist/capture-preset-credentials.d.ts +62 -0
- package/dist/capture-preset-credentials.js +184 -0
- package/dist/capture-request-plan.d.ts +58 -0
- package/dist/capture-request-plan.js +264 -0
- package/dist/capture-run-optimizer.d.ts +139 -0
- package/dist/capture-run-optimizer.js +863 -0
- package/dist/capture-selector-memory.d.ts +31 -0
- package/dist/capture-selector-memory.js +345 -0
- package/dist/capture-session-profile-encryption.d.ts +2 -0
- package/dist/capture-session-profile-encryption.js +22 -0
- package/dist/capture-step-timeout.d.ts +10 -0
- package/dist/capture-step-timeout.js +30 -0
- package/dist/capture-strategy.d.ts +36 -0
- package/dist/capture-strategy.js +95 -0
- package/dist/capture-studio-sync.d.ts +23 -0
- package/dist/capture-studio-sync.js +172 -0
- package/dist/capture-surface-contract.d.ts +36 -0
- package/dist/capture-surface-contract.js +299 -0
- package/dist/capture-transition-engine.d.ts +28 -0
- package/dist/capture-transition-engine.js +292 -0
- package/dist/capture-variant-state.d.ts +56 -0
- package/dist/capture-variant-state.js +182 -0
- package/dist/capture-verification.d.ts +35 -0
- package/dist/capture-verification.js +95 -0
- package/dist/capture-viewport-lock.d.ts +48 -0
- package/dist/capture-viewport-lock.js +74 -0
- package/dist/circuit-breaker.d.ts +42 -0
- package/dist/circuit-breaker.js +119 -0
- package/dist/cli-config.d.ts +8 -1
- package/dist/cli-config.js +62 -6
- package/dist/cli-contract.d.ts +15 -0
- package/dist/cli-contract.js +167 -0
- package/dist/cli-runner-local.d.ts +12 -0
- package/dist/cli-runner-local.js +102 -0
- package/dist/cli-runner.d.ts +34 -0
- package/dist/cli-runner.js +433 -0
- package/dist/cli-utils.d.ts +0 -1
- package/dist/cli-utils.js +2 -5
- package/dist/cli.js +1005 -252
- package/dist/clip-orchestrator.d.ts +148 -0
- package/dist/clip-orchestrator.js +957 -0
- package/dist/clip-postprocess.d.ts +42 -0
- package/dist/clip-postprocess.js +201 -0
- package/dist/cookie-dismiss.d.ts +2 -0
- package/dist/cookie-dismiss.js +48 -13
- package/dist/cost-logging.d.ts +35 -0
- package/dist/cost-logging.js +242 -0
- package/dist/cost-resolution-monitor.d.ts +16 -0
- package/dist/cost-resolution-monitor.js +34 -0
- package/dist/credential-templates.d.ts +5 -0
- package/dist/credential-templates.js +60 -0
- package/dist/cursor-overlay-script.d.ts +6 -0
- package/dist/cursor-overlay-script.js +169 -0
- package/dist/dom-css-purger.d.ts +65 -0
- package/dist/dom-css-purger.js +333 -0
- package/dist/dom-font-inliner.d.ts +45 -0
- package/dist/dom-font-inliner.js +148 -0
- package/dist/dom-patch-resolver.d.ts +52 -0
- package/dist/dom-patch-resolver.js +242 -0
- package/dist/dom-serializer.d.ts +82 -0
- package/dist/dom-serializer.js +378 -0
- package/dist/element-capture.d.ts +13 -0
- package/dist/element-capture.js +522 -0
- package/dist/env-validation.d.ts +5 -0
- package/dist/env-validation.js +29 -0
- package/dist/execution-schema.d.ts +4423 -0
- package/dist/execution-schema.js +507 -0
- package/dist/execution-types.d.ts +886 -0
- package/dist/execution-types.js +65 -0
- package/dist/fonts-loader.d.ts +14 -0
- package/dist/fonts-loader.js +55 -0
- package/dist/hybrid-navigator.d.ts +138 -0
- package/dist/hybrid-navigator.js +468 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +17 -0
- package/dist/legacy/agent-action-recovery.d.ts +45 -0
- package/dist/legacy/agent-action-recovery.js +370 -0
- package/dist/legacy/agent-message-utils.d.ts +21 -0
- package/dist/legacy/agent-message-utils.js +77 -0
- package/dist/legacy/agent-url-utils.d.ts +30 -0
- package/dist/legacy/agent-url-utils.js +138 -0
- package/dist/legacy/agent.d.ts +226 -0
- package/dist/legacy/agent.js +6666 -0
- package/dist/legacy/clip-orchestrator.d.ts +148 -0
- package/dist/legacy/clip-orchestrator.js +957 -0
- package/dist/legacy/credential-templates.d.ts +5 -0
- package/dist/legacy/credential-templates.js +60 -0
- package/dist/legacy/hybrid-navigator.d.ts +138 -0
- package/dist/legacy/hybrid-navigator.js +468 -0
- package/dist/legacy/llm-usage.d.ts +17 -0
- package/dist/legacy/llm-usage.js +45 -0
- package/dist/legacy/prompt-cache.d.ts +10 -0
- package/dist/legacy/prompt-cache.js +24 -0
- package/dist/legacy/prompts.d.ts +175 -0
- package/dist/legacy/prompts.js +1038 -0
- package/dist/legacy/tools.d.ts +4 -0
- package/dist/legacy/tools.js +216 -0
- package/dist/legacy/video-agent.d.ts +143 -0
- package/dist/legacy/video-agent.js +4788 -0
- package/dist/legacy/video-observation.d.ts +36 -0
- package/dist/legacy/video-observation.js +192 -0
- package/dist/legacy/video-planner.d.ts +12 -0
- package/dist/legacy/video-planner.js +501 -0
- package/dist/legacy/video-prompts.d.ts +37 -0
- package/dist/legacy/video-prompts.js +569 -0
- package/dist/legacy/video-tools.d.ts +3 -0
- package/dist/legacy/video-tools.js +59 -0
- package/dist/legacy/video-variant-state.d.ts +29 -0
- package/dist/legacy/video-variant-state.js +80 -0
- package/dist/legacy/vision-model.d.ts +17 -0
- package/dist/legacy/vision-model.js +74 -0
- package/dist/llm-healer.d.ts +63 -0
- package/dist/llm-healer.js +166 -0
- package/dist/llm-provider.d.ts +29 -0
- package/dist/llm-provider.js +80 -0
- package/dist/llm-usage.d.ts +17 -0
- package/dist/llm-usage.js +45 -0
- package/dist/logger.d.ts +6 -2
- package/dist/logger.js +15 -1
- package/dist/mockup-html.d.ts +119 -0
- package/dist/mockup-html.js +263 -0
- package/dist/mockup.d.ts +187 -0
- package/dist/mockup.js +869 -0
- package/dist/mouse-animation.d.ts +46 -0
- package/dist/mouse-animation.js +114 -0
- package/dist/opcode-actions.d.ts +42 -0
- package/dist/opcode-actions.js +511 -0
- package/dist/opcode-runner.d.ts +51 -0
- package/dist/opcode-runner.js +770 -0
- package/dist/openrouter-client.d.ts +40 -0
- package/dist/openrouter-client.js +16 -0
- package/dist/overlay-engine.d.ts +24 -0
- package/dist/overlay-engine.js +176 -0
- package/dist/overlay-utils.d.ts +14 -0
- package/dist/overlay-utils.js +13 -0
- package/dist/postcondition.d.ts +16 -0
- package/dist/postcondition.js +269 -0
- package/dist/posthog.d.ts +4 -0
- package/dist/posthog.js +26 -0
- package/dist/program-patcher.d.ts +25 -0
- package/dist/program-patcher.js +44 -0
- package/dist/prompt-cache.d.ts +10 -0
- package/dist/prompt-cache.js +24 -0
- package/dist/prompts.d.ts +175 -0
- package/dist/prompts.js +1038 -0
- package/dist/provider-config.d.ts +12 -0
- package/dist/provider-config.js +15 -0
- package/dist/recovery-chain.d.ts +37 -0
- package/dist/recovery-chain.js +350 -0
- package/dist/remote-browser.d.ts +215 -0
- package/dist/remote-browser.js +360 -0
- package/dist/safari-browser-bar.d.ts +15 -0
- package/dist/safari-browser-bar.js +95 -0
- package/dist/safari-toolbar-asset.d.ts +15 -0
- package/dist/safari-toolbar-asset.js +12 -0
- package/dist/security.d.ts +21 -0
- package/dist/security.js +608 -0
- package/dist/selector-resolver.d.ts +34 -0
- package/dist/selector-resolver.js +181 -0
- package/dist/semantic-resolver.d.ts +35 -0
- package/dist/semantic-resolver.js +161 -0
- package/dist/server-capture-runtime.d.ts +125 -0
- package/dist/server-capture-runtime.js +585 -0
- package/dist/server-credit-usage.d.ts +12 -0
- package/dist/server-credit-usage.js +41 -0
- package/dist/server-posthog.d.ts +2 -0
- package/dist/server-posthog.js +16 -0
- package/dist/server-project-webhooks.d.ts +59 -0
- package/dist/server-project-webhooks.js +123 -0
- package/dist/server-screenshot-watermark.d.ts +7 -0
- package/dist/server-screenshot-watermark.js +60 -0
- package/dist/session-profile.d.ts +86 -0
- package/dist/session-profile.js +1536 -0
- package/dist/sf-pro-fonts.d.ts +4 -0
- package/dist/sf-pro-fonts.js +7 -0
- package/dist/sf-pro-symbols.d.ts +1 -0
- package/dist/sf-pro-symbols.js +55 -0
- package/dist/skill-packaging.d.ts +28 -0
- package/dist/skill-packaging.js +169 -0
- package/dist/smart-wait.d.ts +27 -0
- package/dist/smart-wait.js +81 -0
- package/dist/status-bar-l10n.d.ts +14 -0
- package/dist/status-bar-l10n.js +177 -0
- package/dist/status-bar-render.d.ts +20 -0
- package/dist/status-bar-render.js +410 -0
- package/dist/status-bar.d.ts +53 -0
- package/dist/status-bar.js +620 -0
- package/dist/svg-browser-bar.d.ts +33 -0
- package/dist/svg-browser-bar.js +206 -0
- package/dist/svg-status-bar.d.ts +36 -0
- package/dist/svg-status-bar.js +597 -0
- package/dist/svg-text.d.ts +61 -0
- package/dist/svg-text.js +118 -0
- package/dist/tools.d.ts +4 -0
- package/dist/tools.js +216 -0
- package/dist/types.d.ts +240 -5
- package/dist/types.js +23 -1
- package/dist/v2/action-verifier.d.ts +29 -0
- package/dist/v2/action-verifier.js +133 -0
- package/dist/v2/alt-text.d.ts +26 -0
- package/dist/v2/alt-text.js +55 -0
- package/dist/v2/benchmark.d.ts +59 -0
- package/dist/v2/benchmark.js +135 -0
- package/dist/v2/capture-strategy.d.ts +30 -0
- package/dist/v2/capture-strategy.js +67 -0
- package/dist/v2/capture-verification.d.ts +35 -0
- package/dist/v2/capture-verification.js +95 -0
- package/dist/v2/circuit-breaker.d.ts +42 -0
- package/dist/v2/circuit-breaker.js +119 -0
- package/dist/v2/cli-runner-local.d.ts +11 -0
- package/dist/v2/cli-runner-local.js +91 -0
- package/dist/v2/cli-runner.d.ts +34 -0
- package/dist/v2/cli-runner.js +300 -0
- package/dist/v2/compiler-prompts.d.ts +27 -0
- package/dist/v2/compiler-prompts.js +123 -0
- package/dist/v2/compiler.d.ts +37 -0
- package/dist/v2/compiler.js +147 -0
- package/dist/v2/explorer.d.ts +41 -0
- package/dist/v2/explorer.js +56 -0
- package/dist/v2/index.d.ts +37 -0
- package/dist/v2/index.js +31 -0
- package/dist/v2/llm-healer.d.ts +62 -0
- package/dist/v2/llm-healer.js +166 -0
- package/dist/v2/llm-provider.d.ts +29 -0
- package/dist/v2/llm-provider.js +80 -0
- package/dist/v2/opcode-runner.d.ts +47 -0
- package/dist/v2/opcode-runner.js +634 -0
- package/dist/v2/overlay-engine.d.ts +24 -0
- package/dist/v2/overlay-engine.js +150 -0
- package/dist/v2/postcondition.d.ts +16 -0
- package/dist/v2/postcondition.js +249 -0
- package/dist/v2/program-patcher.d.ts +25 -0
- package/dist/v2/program-patcher.js +44 -0
- package/dist/v2/recovery-chain.d.ts +30 -0
- package/dist/v2/recovery-chain.js +368 -0
- package/dist/v2/schema.d.ts +2580 -0
- package/dist/v2/schema.js +295 -0
- package/dist/v2/selector-resolver.d.ts +34 -0
- package/dist/v2/selector-resolver.js +181 -0
- package/dist/v2/semantic-resolver.d.ts +35 -0
- package/dist/v2/semantic-resolver.js +161 -0
- package/dist/v2/smart-wait.d.ts +27 -0
- package/dist/v2/smart-wait.js +81 -0
- package/dist/v2/types.d.ts +444 -0
- package/dist/v2/types.js +19 -0
- package/dist/v2/web-playwright-local.d.ts +69 -0
- package/dist/v2/web-playwright-local.js +392 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/video-agent.d.ts +143 -0
- package/dist/video-agent.js +4788 -0
- package/dist/video-observation.d.ts +36 -0
- package/dist/video-observation.js +192 -0
- package/dist/video-planner.d.ts +12 -0
- package/dist/video-planner.js +501 -0
- package/dist/video-prompts.d.ts +37 -0
- package/dist/video-prompts.js +554 -0
- package/dist/video-tools.d.ts +3 -0
- package/dist/video-tools.js +59 -0
- package/dist/video-variant-state.d.ts +29 -0
- package/dist/video-variant-state.js +80 -0
- package/dist/vision-model.d.ts +17 -0
- package/dist/vision-model.js +74 -0
- package/dist/web-playwright-local.d.ts +126 -0
- package/dist/web-playwright-local.js +819 -0
- package/dist/ws-auth.d.ts +20 -0
- package/dist/ws-auth.js +70 -0
- package/dist/ws-broadcast.d.ts +34 -0
- package/dist/ws-broadcast.js +85 -0
- package/dist/ws-connection-limits.d.ts +12 -0
- package/dist/ws-connection-limits.js +44 -0
- package/dist/ws-handler-utils.d.ts +32 -0
- package/dist/ws-handler-utils.js +139 -0
- package/dist/ws-handler.d.ts +10 -0
- package/dist/ws-handler.js +1793 -0
- package/dist/ws-metrics-server.d.ts +9 -0
- package/dist/ws-metrics-server.js +31 -0
- package/dist/ws-server.d.ts +9 -0
- package/dist/ws-server.js +92 -0
- package/package.json +142 -71
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
const TOKEN_STOP_WORDS = new Set([
|
|
2
|
+
"the",
|
|
3
|
+
"and",
|
|
4
|
+
"for",
|
|
5
|
+
"with",
|
|
6
|
+
"from",
|
|
7
|
+
"that",
|
|
8
|
+
"this",
|
|
9
|
+
"your",
|
|
10
|
+
"into",
|
|
11
|
+
"onto",
|
|
12
|
+
"page",
|
|
13
|
+
"pages",
|
|
14
|
+
"state",
|
|
15
|
+
"screen",
|
|
16
|
+
"capture",
|
|
17
|
+
"captures",
|
|
18
|
+
"screenshot",
|
|
19
|
+
"screenshots",
|
|
20
|
+
"open",
|
|
21
|
+
"opened",
|
|
22
|
+
"currently",
|
|
23
|
+
"current",
|
|
24
|
+
"already",
|
|
25
|
+
"visible",
|
|
26
|
+
"show",
|
|
27
|
+
"showing",
|
|
28
|
+
"display",
|
|
29
|
+
"displayed",
|
|
30
|
+
"view",
|
|
31
|
+
"interface",
|
|
32
|
+
"workflow",
|
|
33
|
+
"project",
|
|
34
|
+
"projects",
|
|
35
|
+
"user",
|
|
36
|
+
"step",
|
|
37
|
+
"steps",
|
|
38
|
+
"then",
|
|
39
|
+
"after",
|
|
40
|
+
"before",
|
|
41
|
+
"dans",
|
|
42
|
+
"pour",
|
|
43
|
+
"avec",
|
|
44
|
+
"page",
|
|
45
|
+
"pages",
|
|
46
|
+
"etat",
|
|
47
|
+
"état",
|
|
48
|
+
"capture",
|
|
49
|
+
"captures",
|
|
50
|
+
"ecran",
|
|
51
|
+
"écran",
|
|
52
|
+
"ouverte",
|
|
53
|
+
"ouvert",
|
|
54
|
+
"affiche",
|
|
55
|
+
"affiché",
|
|
56
|
+
"affichee",
|
|
57
|
+
"affichée",
|
|
58
|
+
"courante",
|
|
59
|
+
"actuelle",
|
|
60
|
+
"deja",
|
|
61
|
+
"déjà",
|
|
62
|
+
"interface",
|
|
63
|
+
"etape",
|
|
64
|
+
"étape",
|
|
65
|
+
"click",
|
|
66
|
+
"clicked",
|
|
67
|
+
"clicking",
|
|
68
|
+
"tap",
|
|
69
|
+
"tapped",
|
|
70
|
+
"press",
|
|
71
|
+
"pressed",
|
|
72
|
+
"navigate",
|
|
73
|
+
"navigation",
|
|
74
|
+
"go",
|
|
75
|
+
"goto",
|
|
76
|
+
"open",
|
|
77
|
+
"opening",
|
|
78
|
+
"wait",
|
|
79
|
+
"waiting",
|
|
80
|
+
"load",
|
|
81
|
+
"loaded",
|
|
82
|
+
"loading",
|
|
83
|
+
"select",
|
|
84
|
+
"selected",
|
|
85
|
+
"choose",
|
|
86
|
+
"chosen",
|
|
87
|
+
"pick",
|
|
88
|
+
"picked",
|
|
89
|
+
"launch",
|
|
90
|
+
"launched",
|
|
91
|
+
"continue",
|
|
92
|
+
"continuing",
|
|
93
|
+
"stop",
|
|
94
|
+
"stopping",
|
|
95
|
+
"first",
|
|
96
|
+
"second",
|
|
97
|
+
"third",
|
|
98
|
+
"next",
|
|
99
|
+
"previous",
|
|
100
|
+
"left",
|
|
101
|
+
"right",
|
|
102
|
+
"top",
|
|
103
|
+
"bottom",
|
|
104
|
+
"header",
|
|
105
|
+
"footer",
|
|
106
|
+
"sidebar",
|
|
107
|
+
"toolbar",
|
|
108
|
+
"menu",
|
|
109
|
+
"menus",
|
|
110
|
+
"button",
|
|
111
|
+
"buttons",
|
|
112
|
+
"link",
|
|
113
|
+
"links",
|
|
114
|
+
"new",
|
|
115
|
+
"exact",
|
|
116
|
+
"exactly",
|
|
117
|
+
"fully",
|
|
118
|
+
"ensure",
|
|
119
|
+
"make",
|
|
120
|
+
"sure",
|
|
121
|
+
"should",
|
|
122
|
+
"must",
|
|
123
|
+
"still",
|
|
124
|
+
"just",
|
|
125
|
+
"true",
|
|
126
|
+
"real",
|
|
127
|
+
"launching",
|
|
128
|
+
"lance",
|
|
129
|
+
"lancer",
|
|
130
|
+
"ouvrir",
|
|
131
|
+
"ouvrez",
|
|
132
|
+
"navigue",
|
|
133
|
+
"naviguer",
|
|
134
|
+
"clique",
|
|
135
|
+
"cliquez",
|
|
136
|
+
"attend",
|
|
137
|
+
"attendre",
|
|
138
|
+
"charge",
|
|
139
|
+
"charger",
|
|
140
|
+
"selectionne",
|
|
141
|
+
"sélectionne",
|
|
142
|
+
"selectionner",
|
|
143
|
+
"sélectionner",
|
|
144
|
+
"choisir",
|
|
145
|
+
"choisis",
|
|
146
|
+
"premier",
|
|
147
|
+
"premiere",
|
|
148
|
+
"première",
|
|
149
|
+
"gauche",
|
|
150
|
+
"droite",
|
|
151
|
+
"haut",
|
|
152
|
+
"bas",
|
|
153
|
+
"menu",
|
|
154
|
+
"sidebar",
|
|
155
|
+
"header",
|
|
156
|
+
"bouton",
|
|
157
|
+
"boutons",
|
|
158
|
+
"nouveau",
|
|
159
|
+
"nouvelle",
|
|
160
|
+
"exacte",
|
|
161
|
+
"exactement",
|
|
162
|
+
"entierement",
|
|
163
|
+
"entièrement",
|
|
164
|
+
"assure",
|
|
165
|
+
"assurez",
|
|
166
|
+
"doit",
|
|
167
|
+
"encore",
|
|
168
|
+
"arrete",
|
|
169
|
+
"arrête",
|
|
170
|
+
"arreter",
|
|
171
|
+
"arrêter",
|
|
172
|
+
]);
|
|
173
|
+
const PAGE_ID_STOP_WORDS = new Set([
|
|
174
|
+
...TOKEN_STOP_WORDS,
|
|
175
|
+
"form",
|
|
176
|
+
"editor",
|
|
177
|
+
"edit",
|
|
178
|
+
"modal",
|
|
179
|
+
"dialog",
|
|
180
|
+
"route",
|
|
181
|
+
"screen",
|
|
182
|
+
"detail",
|
|
183
|
+
"details",
|
|
184
|
+
"config",
|
|
185
|
+
"configuration",
|
|
186
|
+
"preview",
|
|
187
|
+
]);
|
|
188
|
+
const COLLECTION_RE = /\b(gallery|grid|list|overview|results?|catalog|library|feed|table|items?|cards?)\b/i;
|
|
189
|
+
const MODAL_RE = /\b(modal|dialog|popup|drawer|overlay)\b/i;
|
|
190
|
+
const SELECTION_RE = /\b(select|selection|choose|pick|picker|library|options?|templates?)\b/i;
|
|
191
|
+
const CONFIGURATION_RE = /\b(edit|editor|editing|config|configuration|configure|settings|details|detail|instructions|textarea|form|modifier|modification|edition|customi[sz]e|compose)\b/i;
|
|
192
|
+
const FOCUSED_DETAIL_RE = /\b(first|selected|opened|individual|single|preview|inspect|expanded|zoom(?:ed)?|detail view|item details?)\b/i;
|
|
193
|
+
const STRONG_ROUTE_PROMPT_RE = /\b(route|dedicated page|full page|editor page|edit page|detail page|screen|view|section)\b/i;
|
|
194
|
+
const PASSIVE_STATE_RE = /\b(currently open|already open|currently displayed|already displayed|without launching|ne la lance pas|sans la lancer|deja ouverte|ouverte actuellement)\b/i;
|
|
195
|
+
function uniqueInOrder(values) {
|
|
196
|
+
const seen = new Set();
|
|
197
|
+
const out = [];
|
|
198
|
+
for (const value of values) {
|
|
199
|
+
if (seen.has(value))
|
|
200
|
+
continue;
|
|
201
|
+
seen.add(value);
|
|
202
|
+
out.push(value);
|
|
203
|
+
}
|
|
204
|
+
return out;
|
|
205
|
+
}
|
|
206
|
+
function tokenize(value) {
|
|
207
|
+
return value
|
|
208
|
+
.toLowerCase()
|
|
209
|
+
.normalize("NFD")
|
|
210
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
211
|
+
.split(/[^a-z0-9]+/g)
|
|
212
|
+
.map((part) => part.trim())
|
|
213
|
+
.filter((part) => part.length >= 3 && !TOKEN_STOP_WORDS.has(part));
|
|
214
|
+
}
|
|
215
|
+
export function normalizeCaptureIdentityTokens(values, options = {}) {
|
|
216
|
+
const stopWords = options.stopWords ?? TOKEN_STOP_WORDS;
|
|
217
|
+
const tokens = [];
|
|
218
|
+
for (const value of values) {
|
|
219
|
+
if (!value)
|
|
220
|
+
continue;
|
|
221
|
+
const parts = value
|
|
222
|
+
.toLowerCase()
|
|
223
|
+
.normalize("NFD")
|
|
224
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
225
|
+
.split(/[^a-z0-9]+/g)
|
|
226
|
+
.map((part) => part.trim())
|
|
227
|
+
.filter((part) => part.length >= 3 && !stopWords.has(part));
|
|
228
|
+
tokens.push(...parts);
|
|
229
|
+
}
|
|
230
|
+
return uniqueInOrder(tokens);
|
|
231
|
+
}
|
|
232
|
+
function normalizeUrlPath(rawUrl) {
|
|
233
|
+
try {
|
|
234
|
+
return new URL(rawUrl).pathname.toLowerCase();
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
return rawUrl.toLowerCase();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
export function buildCapturePageIdentitySummary(kind, tokens, urlPath) {
|
|
241
|
+
const tokenSummary = tokens.slice(0, 4).join(",");
|
|
242
|
+
const pathSummary = urlPath.replace(/\/+/g, "/").slice(0, 80) || "/";
|
|
243
|
+
return `${kind}:${tokenSummary || "none"}@${pathSummary}`;
|
|
244
|
+
}
|
|
245
|
+
function normalizeForMatching(value) {
|
|
246
|
+
return value
|
|
247
|
+
.normalize("NFD")
|
|
248
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
249
|
+
.toLowerCase();
|
|
250
|
+
}
|
|
251
|
+
function extractPromptSurfaceHints(rawPrompt) {
|
|
252
|
+
const patterns = [
|
|
253
|
+
/select ([^.]+?),?\s+and capture/i,
|
|
254
|
+
/select ([^.]+?) and stop/i,
|
|
255
|
+
/capture the currently open ([^.]+)/i,
|
|
256
|
+
/capture the ([^.]+?) with [^.]+ visible/i,
|
|
257
|
+
/the page should show ([^.]+)/i,
|
|
258
|
+
/the detail view should show ([^.]+)/i,
|
|
259
|
+
/the page must show ([^.]+)/i,
|
|
260
|
+
/stop (?:only )?when ([^.]+)/i,
|
|
261
|
+
/with ([^.]+?) visible/i,
|
|
262
|
+
/show the full ([^.]+)/i,
|
|
263
|
+
];
|
|
264
|
+
const hints = [];
|
|
265
|
+
for (const pattern of patterns) {
|
|
266
|
+
const match = rawPrompt.match(pattern);
|
|
267
|
+
if (match?.[1]) {
|
|
268
|
+
hints.push(match[1]);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
const quoted = Array.from(rawPrompt.matchAll(/["“]([^"”]+)["”]/g), (match) => match[1]);
|
|
272
|
+
hints.push(...quoted);
|
|
273
|
+
return uniqueInOrder(hints.filter(Boolean));
|
|
274
|
+
}
|
|
275
|
+
function extractPathMeaningfulTokens(urlPath) {
|
|
276
|
+
const segments = urlPath
|
|
277
|
+
.split("/")
|
|
278
|
+
.map((segment) => segment.trim())
|
|
279
|
+
.filter(Boolean)
|
|
280
|
+
.filter((segment) => !/^\d+$/.test(segment) && !/^[a-f0-9]{8,}$/i.test(segment));
|
|
281
|
+
return normalizeCaptureIdentityTokens(segments, { stopWords: TOKEN_STOP_WORDS });
|
|
282
|
+
}
|
|
283
|
+
export function inferCapturePageIdentity(pageRun) {
|
|
284
|
+
const rawPrompt = pageRun.prompt.trim();
|
|
285
|
+
const prompt = normalizeForMatching(rawPrompt);
|
|
286
|
+
const pageId = pageRun.pageId ?? "main";
|
|
287
|
+
const urlPath = normalizeUrlPath(pageRun.url);
|
|
288
|
+
const context = normalizeForMatching(`${pageId} ${rawPrompt} ${urlPath}`);
|
|
289
|
+
// For dialog/modal detection, only use the prompt and URL — page IDs are user-defined
|
|
290
|
+
// identifiers that often contain "modal" or "dialog" as naming convention, not as DOM intent.
|
|
291
|
+
const promptAndUrl = normalizeForMatching(`${rawPrompt} ${urlPath}`);
|
|
292
|
+
const pathSegments = urlPath.split("/").filter(Boolean);
|
|
293
|
+
const hasSpecificPath = pathSegments.length >= 2
|
|
294
|
+
|| pathSegments.some((segment) => /[0-9]/.test(segment) || segment.length >= 12);
|
|
295
|
+
const mentionsCollection = COLLECTION_RE.test(context);
|
|
296
|
+
const mentionsModal = MODAL_RE.test(promptAndUrl);
|
|
297
|
+
const mentionsSelection = SELECTION_RE.test(promptAndUrl);
|
|
298
|
+
const mentionsConfiguration = CONFIGURATION_RE.test(context);
|
|
299
|
+
const mentionsFocusedDetail = FOCUSED_DETAIL_RE.test(prompt);
|
|
300
|
+
const passiveState = PASSIVE_STATE_RE.test(prompt);
|
|
301
|
+
const mentionsDedicatedRoute = !mentionsModal
|
|
302
|
+
&& !passiveState
|
|
303
|
+
&& (STRONG_ROUTE_PROMPT_RE.test(prompt)
|
|
304
|
+
|| (hasSpecificPath && mentionsConfiguration));
|
|
305
|
+
let kind = "unknown";
|
|
306
|
+
if (mentionsModal && mentionsSelection && !mentionsConfiguration) {
|
|
307
|
+
kind = "modal_selection";
|
|
308
|
+
}
|
|
309
|
+
else if (mentionsModal && (mentionsConfiguration || passiveState)) {
|
|
310
|
+
kind = "modal_configuration";
|
|
311
|
+
}
|
|
312
|
+
else if (mentionsCollection && mentionsFocusedDetail && !mentionsModal) {
|
|
313
|
+
kind = "detail_route";
|
|
314
|
+
}
|
|
315
|
+
else if (mentionsCollection && !mentionsConfiguration && !mentionsModal && !mentionsSelection) {
|
|
316
|
+
kind = "gallery";
|
|
317
|
+
}
|
|
318
|
+
else if (mentionsConfiguration && mentionsDedicatedRoute && !mentionsModal) {
|
|
319
|
+
kind = "editor_route";
|
|
320
|
+
}
|
|
321
|
+
else if (mentionsConfiguration && (mentionsModal || mentionsSelection || passiveState)) {
|
|
322
|
+
kind = "modal_configuration";
|
|
323
|
+
}
|
|
324
|
+
else if (mentionsModal || mentionsSelection) {
|
|
325
|
+
kind = "modal_selection";
|
|
326
|
+
}
|
|
327
|
+
else if (mentionsConfiguration) {
|
|
328
|
+
kind = "detail_route";
|
|
329
|
+
}
|
|
330
|
+
else if (mentionsCollection) {
|
|
331
|
+
kind = "gallery";
|
|
332
|
+
}
|
|
333
|
+
const promptSurfaceHints = extractPromptSurfaceHints(rawPrompt);
|
|
334
|
+
const promptSubjectTokens = normalizeCaptureIdentityTokens(promptSurfaceHints.length > 0 ? promptSurfaceHints : [rawPrompt]);
|
|
335
|
+
const pathSubjectTokens = extractPathMeaningfulTokens(urlPath);
|
|
336
|
+
const pageIdSubjectTokens = normalizeCaptureIdentityTokens([pageId], {
|
|
337
|
+
stopWords: PAGE_ID_STOP_WORDS,
|
|
338
|
+
});
|
|
339
|
+
const subjectTokens = uniqueInOrder([
|
|
340
|
+
...promptSubjectTokens,
|
|
341
|
+
...pathSubjectTokens,
|
|
342
|
+
...pageIdSubjectTokens,
|
|
343
|
+
]).slice(0, 10);
|
|
344
|
+
return {
|
|
345
|
+
kind,
|
|
346
|
+
summary: buildCapturePageIdentitySummary(kind, subjectTokens, urlPath),
|
|
347
|
+
subjectTokens,
|
|
348
|
+
dialogTarget: kind === "modal_selection" || kind === "modal_configuration",
|
|
349
|
+
dedicatedRoute: kind === "editor_route" || (kind === "detail_route" && hasSpecificPath),
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
//# sourceMappingURL=capture-page-identity.js.map
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type EncryptedEnvelope } from './capture-encryption.js';
|
|
2
|
+
export interface StoredPresetCredentials {
|
|
3
|
+
loginUrl?: string;
|
|
4
|
+
email?: string;
|
|
5
|
+
password?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface StoredPresetAuthCookie {
|
|
8
|
+
name: string;
|
|
9
|
+
value: string;
|
|
10
|
+
domain: string;
|
|
11
|
+
path?: string;
|
|
12
|
+
}
|
|
13
|
+
export type StoredPresetAuthCookies = StoredPresetAuthCookie[];
|
|
14
|
+
export interface StoredPresetAuthCookiesMeta {
|
|
15
|
+
count: number;
|
|
16
|
+
domains: string[];
|
|
17
|
+
}
|
|
18
|
+
export declare function normalizePresetCredentials(credentials?: Partial<StoredPresetCredentials> | null): StoredPresetCredentials | undefined;
|
|
19
|
+
export declare function hasStoredCredentials(raw: unknown): boolean;
|
|
20
|
+
export declare function encryptPresetCredentials(credentials: StoredPresetCredentials): EncryptedEnvelope;
|
|
21
|
+
export declare function decryptPresetCredentials(value: unknown): StoredPresetCredentials | undefined;
|
|
22
|
+
export declare function normalizePresetAuthCookies(value: unknown): StoredPresetAuthCookies | undefined;
|
|
23
|
+
export declare function encryptPresetAuthCookies(cookies: StoredPresetAuthCookies): EncryptedEnvelope;
|
|
24
|
+
export declare function decryptPresetAuthCookies(value: unknown): StoredPresetAuthCookies | undefined;
|
|
25
|
+
export declare function hasStoredAuthCookies(raw: unknown): boolean;
|
|
26
|
+
export declare function buildAuthCookiesMeta(cookies: StoredPresetAuthCookies): StoredPresetAuthCookiesMeta;
|
|
27
|
+
export interface StorageStateCookie {
|
|
28
|
+
name: string;
|
|
29
|
+
value: string;
|
|
30
|
+
domain: string;
|
|
31
|
+
path: string;
|
|
32
|
+
expires: number;
|
|
33
|
+
httpOnly: boolean;
|
|
34
|
+
secure: boolean;
|
|
35
|
+
sameSite: 'Strict' | 'Lax' | 'None';
|
|
36
|
+
}
|
|
37
|
+
export interface StorageStateOrigin {
|
|
38
|
+
origin: string;
|
|
39
|
+
localStorage: Array<{
|
|
40
|
+
name: string;
|
|
41
|
+
value: string;
|
|
42
|
+
}>;
|
|
43
|
+
}
|
|
44
|
+
export interface PlaywrightStorageState {
|
|
45
|
+
cookies: StorageStateCookie[];
|
|
46
|
+
origins: StorageStateOrigin[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Normalize a Playwright storageState payload, dropping anything that doesn't
|
|
50
|
+
* match the expected shape. Returns undefined if the payload is empty (no
|
|
51
|
+
* cookies and no origin data).
|
|
52
|
+
*/
|
|
53
|
+
export declare function normalizeStorageState(value: unknown): PlaywrightStorageState | undefined;
|
|
54
|
+
export declare function encryptStorageState(state: PlaywrightStorageState): EncryptedEnvelope;
|
|
55
|
+
export declare function decryptStorageState(value: unknown): PlaywrightStorageState | undefined;
|
|
56
|
+
export declare function summarizeStorageState(state: PlaywrightStorageState): {
|
|
57
|
+
cookieCount: number;
|
|
58
|
+
originCount: number;
|
|
59
|
+
domains: string[];
|
|
60
|
+
};
|
|
61
|
+
export declare function preparePresetConfigForStorage<T extends Record<string, unknown>>(config: T): T;
|
|
62
|
+
export declare function hydratePresetConfigFromStorage<T extends Record<string, unknown>>(raw: unknown): T;
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { decrypt, encrypt, isEncryptedEnvelope } from './capture-encryption.js';
|
|
2
|
+
function getSecret() {
|
|
3
|
+
const secret = process.env.PRESET_CREDENTIALS_ENCRYPTION_SECRET;
|
|
4
|
+
if (!secret) {
|
|
5
|
+
throw new Error('Missing PRESET_CREDENTIALS_ENCRYPTION_SECRET for preset credential encryption');
|
|
6
|
+
}
|
|
7
|
+
return secret;
|
|
8
|
+
}
|
|
9
|
+
export function normalizePresetCredentials(credentials) {
|
|
10
|
+
if (!credentials)
|
|
11
|
+
return undefined;
|
|
12
|
+
const loginUrl = credentials.loginUrl?.trim() || undefined;
|
|
13
|
+
const email = credentials.email?.trim() || undefined;
|
|
14
|
+
const password = credentials.password || undefined;
|
|
15
|
+
if (!loginUrl && !email && !password)
|
|
16
|
+
return undefined;
|
|
17
|
+
return {
|
|
18
|
+
...(loginUrl ? { loginUrl } : {}),
|
|
19
|
+
...(email ? { email } : {}),
|
|
20
|
+
...(password ? { password } : {}),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function hasStoredCredentials(raw) {
|
|
24
|
+
if (!raw || typeof raw !== 'object')
|
|
25
|
+
return false;
|
|
26
|
+
return raw.credentials != null;
|
|
27
|
+
}
|
|
28
|
+
export function encryptPresetCredentials(credentials) {
|
|
29
|
+
return encrypt(JSON.stringify(credentials), getSecret());
|
|
30
|
+
}
|
|
31
|
+
export function decryptPresetCredentials(value) {
|
|
32
|
+
if (!value)
|
|
33
|
+
return undefined;
|
|
34
|
+
if (isEncryptedEnvelope(value)) {
|
|
35
|
+
const decrypted = decrypt(value, getSecret());
|
|
36
|
+
return normalizePresetCredentials(JSON.parse(decrypted));
|
|
37
|
+
}
|
|
38
|
+
return normalizePresetCredentials(value);
|
|
39
|
+
}
|
|
40
|
+
export function normalizePresetAuthCookies(value) {
|
|
41
|
+
if (!Array.isArray(value))
|
|
42
|
+
return undefined;
|
|
43
|
+
const cleaned = [];
|
|
44
|
+
for (const entry of value) {
|
|
45
|
+
if (!entry || typeof entry !== 'object')
|
|
46
|
+
continue;
|
|
47
|
+
const candidate = entry;
|
|
48
|
+
const name = typeof candidate.name === 'string' ? candidate.name.trim() : '';
|
|
49
|
+
const cookieValue = typeof candidate.value === 'string' ? candidate.value : '';
|
|
50
|
+
const domain = typeof candidate.domain === 'string' ? candidate.domain.trim().toLowerCase() : '';
|
|
51
|
+
if (!name || !cookieValue || !domain)
|
|
52
|
+
continue;
|
|
53
|
+
const path = typeof candidate.path === 'string' && candidate.path.trim()
|
|
54
|
+
? candidate.path.trim()
|
|
55
|
+
: undefined;
|
|
56
|
+
cleaned.push({
|
|
57
|
+
name,
|
|
58
|
+
value: cookieValue,
|
|
59
|
+
domain,
|
|
60
|
+
...(path ? { path } : {}),
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
return cleaned.length > 0 ? cleaned : undefined;
|
|
64
|
+
}
|
|
65
|
+
export function encryptPresetAuthCookies(cookies) {
|
|
66
|
+
return encrypt(JSON.stringify(cookies), getSecret());
|
|
67
|
+
}
|
|
68
|
+
export function decryptPresetAuthCookies(value) {
|
|
69
|
+
if (!value)
|
|
70
|
+
return undefined;
|
|
71
|
+
if (isEncryptedEnvelope(value)) {
|
|
72
|
+
const decrypted = decrypt(value, getSecret());
|
|
73
|
+
return normalizePresetAuthCookies(JSON.parse(decrypted));
|
|
74
|
+
}
|
|
75
|
+
return normalizePresetAuthCookies(value);
|
|
76
|
+
}
|
|
77
|
+
export function hasStoredAuthCookies(raw) {
|
|
78
|
+
if (!raw || typeof raw !== 'object')
|
|
79
|
+
return false;
|
|
80
|
+
return raw.authCookies != null;
|
|
81
|
+
}
|
|
82
|
+
export function buildAuthCookiesMeta(cookies) {
|
|
83
|
+
const domainSet = new Set();
|
|
84
|
+
for (const cookie of cookies) {
|
|
85
|
+
if (cookie.domain)
|
|
86
|
+
domainSet.add(cookie.domain);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
count: cookies.length,
|
|
90
|
+
domains: Array.from(domainSet),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Normalize a Playwright storageState payload, dropping anything that doesn't
|
|
95
|
+
* match the expected shape. Returns undefined if the payload is empty (no
|
|
96
|
+
* cookies and no origin data).
|
|
97
|
+
*/
|
|
98
|
+
export function normalizeStorageState(value) {
|
|
99
|
+
if (!value || typeof value !== 'object')
|
|
100
|
+
return undefined;
|
|
101
|
+
const candidate = value;
|
|
102
|
+
const cookies = Array.isArray(candidate.cookies)
|
|
103
|
+
? candidate.cookies
|
|
104
|
+
.filter((c) => !!c && typeof c === 'object' && typeof c.name === 'string' && typeof c.value === 'string' && typeof c.domain === 'string')
|
|
105
|
+
.map((c) => ({
|
|
106
|
+
name: c.name,
|
|
107
|
+
value: c.value,
|
|
108
|
+
domain: c.domain,
|
|
109
|
+
path: typeof c.path === 'string' ? c.path : '/',
|
|
110
|
+
expires: typeof c.expires === 'number' ? c.expires : -1,
|
|
111
|
+
httpOnly: !!c.httpOnly,
|
|
112
|
+
secure: !!c.secure,
|
|
113
|
+
sameSite: c.sameSite === 'Strict' || c.sameSite === 'Lax' || c.sameSite === 'None'
|
|
114
|
+
? c.sameSite
|
|
115
|
+
: 'Lax',
|
|
116
|
+
}))
|
|
117
|
+
: [];
|
|
118
|
+
const origins = Array.isArray(candidate.origins)
|
|
119
|
+
? candidate.origins
|
|
120
|
+
.filter((o) => !!o && typeof o === 'object' && typeof o.origin === 'string')
|
|
121
|
+
.map((o) => ({
|
|
122
|
+
origin: o.origin,
|
|
123
|
+
localStorage: Array.isArray(o.localStorage)
|
|
124
|
+
? o.localStorage
|
|
125
|
+
.filter((entry) => entry && typeof entry === 'object' && typeof entry.name === 'string')
|
|
126
|
+
.map((entry) => ({ name: entry.name, value: typeof entry.value === 'string' ? entry.value : '' }))
|
|
127
|
+
: [],
|
|
128
|
+
}))
|
|
129
|
+
: [];
|
|
130
|
+
if (cookies.length === 0 && origins.length === 0)
|
|
131
|
+
return undefined;
|
|
132
|
+
return { cookies, origins };
|
|
133
|
+
}
|
|
134
|
+
export function encryptStorageState(state) {
|
|
135
|
+
return encrypt(JSON.stringify(state), getSecret());
|
|
136
|
+
}
|
|
137
|
+
export function decryptStorageState(value) {
|
|
138
|
+
if (!value)
|
|
139
|
+
return undefined;
|
|
140
|
+
if (isEncryptedEnvelope(value)) {
|
|
141
|
+
const decrypted = decrypt(value, getSecret());
|
|
142
|
+
return normalizeStorageState(JSON.parse(decrypted));
|
|
143
|
+
}
|
|
144
|
+
return normalizeStorageState(value);
|
|
145
|
+
}
|
|
146
|
+
export function summarizeStorageState(state) {
|
|
147
|
+
const domainSet = new Set();
|
|
148
|
+
for (const cookie of state.cookies) {
|
|
149
|
+
if (cookie.domain)
|
|
150
|
+
domainSet.add(cookie.domain);
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
cookieCount: state.cookies.length,
|
|
154
|
+
originCount: state.origins.length,
|
|
155
|
+
domains: Array.from(domainSet),
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export function preparePresetConfigForStorage(config) {
|
|
159
|
+
const credentials = normalizePresetCredentials(config.credentials);
|
|
160
|
+
const authCookies = normalizePresetAuthCookies(config.authCookies);
|
|
161
|
+
return {
|
|
162
|
+
...config,
|
|
163
|
+
...(credentials
|
|
164
|
+
? { credentials: encryptPresetCredentials(credentials) }
|
|
165
|
+
: { credentials: undefined }),
|
|
166
|
+
...(authCookies
|
|
167
|
+
? {
|
|
168
|
+
authCookies: encryptPresetAuthCookies(authCookies),
|
|
169
|
+
authCookiesMeta: buildAuthCookiesMeta(authCookies),
|
|
170
|
+
}
|
|
171
|
+
: { authCookies: undefined, authCookiesMeta: undefined }),
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export function hydratePresetConfigFromStorage(raw) {
|
|
175
|
+
const config = (raw && typeof raw === 'object' ? raw : {});
|
|
176
|
+
const credentials = decryptPresetCredentials(config.credentials);
|
|
177
|
+
const authCookies = decryptPresetAuthCookies(config.authCookies);
|
|
178
|
+
return {
|
|
179
|
+
...config,
|
|
180
|
+
...(credentials ? { credentials } : { credentials: undefined }),
|
|
181
|
+
...(authCookies ? { authCookies } : { authCookies: undefined }),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
//# sourceMappingURL=capture-preset-credentials.js.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type ScreenshotPageRunInput, type ScreenshotVariantExecution } from "./capture-run-optimizer.js";
|
|
2
|
+
export type CaptureTheme = "light" | "dark";
|
|
3
|
+
export interface CaptureViewport {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
export interface CaptureTargetLike {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
viewport: CaptureViewport;
|
|
11
|
+
deviceFrame?: string;
|
|
12
|
+
mockupOptions?: {
|
|
13
|
+
orientation?: "portrait" | "landscape" | string;
|
|
14
|
+
} | null;
|
|
15
|
+
}
|
|
16
|
+
export interface CapturePageDefinitionLike {
|
|
17
|
+
id?: string | null;
|
|
18
|
+
prompt?: string | null;
|
|
19
|
+
url?: string | null;
|
|
20
|
+
}
|
|
21
|
+
export interface CaptureRequestPlanInput<TTarget extends CaptureTargetLike = CaptureTargetLike, TElement = unknown> {
|
|
22
|
+
url: string;
|
|
23
|
+
prompt?: string | null;
|
|
24
|
+
targets?: TTarget[] | null;
|
|
25
|
+
viewports?: CaptureViewport[] | null;
|
|
26
|
+
deviceFrame?: string | null;
|
|
27
|
+
mockupOptions?: TTarget["mockupOptions"];
|
|
28
|
+
outputScale?: number | null;
|
|
29
|
+
langs?: string[] | null;
|
|
30
|
+
themes?: Array<CaptureTheme> | null;
|
|
31
|
+
elements?: TElement[] | null;
|
|
32
|
+
pages?: CapturePageDefinitionLike[] | null;
|
|
33
|
+
}
|
|
34
|
+
export interface CaptureRequestPlan<TTarget extends CaptureTargetLike = CaptureTargetLike, TElement = unknown> {
|
|
35
|
+
targets: TTarget[];
|
|
36
|
+
outputScale: number;
|
|
37
|
+
langs: string[];
|
|
38
|
+
themes: Array<CaptureTheme>;
|
|
39
|
+
elements: TElement[];
|
|
40
|
+
pageRuns: ScreenshotPageRunInput[];
|
|
41
|
+
variantPlan: ScreenshotVariantExecution[];
|
|
42
|
+
requestedCaptureCount: number;
|
|
43
|
+
totalCaptures: number;
|
|
44
|
+
/** Warnings about non-fatal issues (e.g. unknown device frames). */
|
|
45
|
+
warnings: string[];
|
|
46
|
+
}
|
|
47
|
+
export declare function hasNonEmptyCapturePrompt(prompt: string | null | undefined): boolean;
|
|
48
|
+
export declare function getCapturePromptValidationError(input: Pick<CaptureRequestPlanInput, "url" | "prompt" | "pages">): string | null;
|
|
49
|
+
export declare function normalizeOutputScale(scale?: number | null): number;
|
|
50
|
+
export declare function resolveCaptureLangs(raw: unknown): string[];
|
|
51
|
+
export declare function resolveCaptureThemes(raw: unknown): Array<CaptureTheme>;
|
|
52
|
+
export declare function buildCapturePageRuns(input: Pick<CaptureRequestPlanInput, "url" | "prompt" | "pages">): ScreenshotPageRunInput[];
|
|
53
|
+
export declare function normalizeCaptureTargets<TTarget extends CaptureTargetLike = CaptureTargetLike>(input: Pick<CaptureRequestPlanInput<TTarget>, "targets" | "viewports" | "deviceFrame" | "mockupOptions">): Promise<TTarget[]>;
|
|
54
|
+
export declare function sanitizeStorageSegment(value: string | null | undefined): string;
|
|
55
|
+
export declare function getCaptureUrlHostname(value: string | null | undefined): string;
|
|
56
|
+
export declare function normalizeComparableUrl(value: string | null | undefined): string;
|
|
57
|
+
export declare function urlsPointToSameCaptureState(left: string | null | undefined, right: string | null | undefined): boolean;
|
|
58
|
+
export declare function resolveCaptureRequestPlan<TTarget extends CaptureTargetLike = CaptureTargetLike, TElement = unknown>(input: CaptureRequestPlanInput<TTarget, TElement>): Promise<CaptureRequestPlan<TTarget, TElement>>;
|