@anweat/dsh-browser 0.1.17 → 0.2.0-rc.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 (162) hide show
  1. package/README.md +238 -71
  2. package/assets/skills/dsh-browser/SKILL.md +120 -0
  3. package/assets/skills/dsh-browser/references/develop.md +48 -0
  4. package/assets/skills/dsh-browser/references/observe.md +91 -0
  5. package/assets/skills/dsh-browser/references/opencli.md +25 -0
  6. package/assets/skills/dsh-browser/references/recipes.md +149 -0
  7. package/assets/skills/dsh-browser/references/userscripts.md +44 -0
  8. package/cordis.patch.yml +4 -0
  9. package/lib/actions/act.d.ts +3 -0
  10. package/lib/actions/act.js +147 -0
  11. package/lib/actions/act.js.map +1 -0
  12. package/lib/actions/automation.d.ts +3 -0
  13. package/lib/actions/automation.js +356 -0
  14. package/lib/actions/automation.js.map +1 -0
  15. package/lib/actions/crawl.d.ts +3 -0
  16. package/lib/actions/crawl.js +28 -0
  17. package/lib/actions/crawl.js.map +1 -0
  18. package/lib/actions/errors.d.ts +53 -0
  19. package/lib/actions/errors.js +178 -0
  20. package/lib/actions/errors.js.map +1 -0
  21. package/lib/actions/index-view.d.ts +42 -0
  22. package/lib/actions/index-view.js +268 -0
  23. package/lib/actions/index-view.js.map +1 -0
  24. package/lib/actions/inspect.d.ts +3 -0
  25. package/lib/actions/inspect.js +35 -0
  26. package/lib/actions/inspect.js.map +1 -0
  27. package/lib/actions/observe.d.ts +3 -0
  28. package/lib/actions/observe.js +121 -0
  29. package/lib/actions/observe.js.map +1 -0
  30. package/lib/actions/opencli.d.ts +3 -0
  31. package/lib/actions/opencli.js +51 -0
  32. package/lib/actions/opencli.js.map +1 -0
  33. package/lib/actions/registry.d.ts +35 -0
  34. package/lib/actions/registry.js +89 -0
  35. package/lib/actions/registry.js.map +1 -0
  36. package/lib/actions/run.d.ts +34 -0
  37. package/lib/actions/run.js +226 -0
  38. package/lib/actions/run.js.map +1 -0
  39. package/lib/actions/runtime.d.ts +3 -0
  40. package/lib/actions/runtime.js +33 -0
  41. package/lib/actions/runtime.js.map +1 -0
  42. package/lib/actions/schema.d.ts +31 -0
  43. package/lib/actions/schema.js +309 -0
  44. package/lib/actions/schema.js.map +1 -0
  45. package/lib/actions/script.d.ts +3 -0
  46. package/lib/actions/script.js +97 -0
  47. package/lib/actions/script.js.map +1 -0
  48. package/lib/actions/shared.d.ts +31 -0
  49. package/lib/actions/shared.js +45 -0
  50. package/lib/actions/shared.js.map +1 -0
  51. package/lib/actions/surface.d.ts +22 -0
  52. package/lib/actions/surface.js +18 -0
  53. package/lib/actions/surface.js.map +1 -0
  54. package/lib/actions/target.d.ts +3 -0
  55. package/lib/actions/target.js +66 -0
  56. package/lib/actions/target.js.map +1 -0
  57. package/lib/actions/types.d.ts +181 -0
  58. package/lib/actions/types.js +48 -0
  59. package/lib/actions/types.js.map +1 -0
  60. package/lib/activation-rules.d.ts +29 -0
  61. package/lib/activation-rules.js +33 -0
  62. package/lib/activation-rules.js.map +1 -0
  63. package/lib/approval-policy.d.ts +40 -2
  64. package/lib/approval-policy.js +184 -97
  65. package/lib/approval-policy.js.map +1 -1
  66. package/lib/automation-assets-rpc.d.ts +8 -2
  67. package/lib/automation-assets-rpc.js +67 -6
  68. package/lib/automation-assets-rpc.js.map +1 -1
  69. package/lib/automation-assets.d.ts +152 -4
  70. package/lib/automation-assets.js +255 -15
  71. package/lib/automation-assets.js.map +1 -1
  72. package/lib/automation-convert.d.ts +23 -0
  73. package/lib/automation-convert.js +110 -0
  74. package/lib/automation-convert.js.map +1 -0
  75. package/lib/automation-development.d.ts +26 -0
  76. package/lib/automation-development.js +47 -0
  77. package/lib/automation-development.js.map +1 -1
  78. package/lib/automation-execution.d.ts +57 -1
  79. package/lib/automation-execution.js +167 -11
  80. package/lib/automation-execution.js.map +1 -1
  81. package/lib/automation-journal.d.ts +92 -0
  82. package/lib/automation-journal.js +449 -0
  83. package/lib/automation-journal.js.map +1 -0
  84. package/lib/automation-v2.d.ts +138 -0
  85. package/lib/automation-v2.js +631 -0
  86. package/lib/automation-v2.js.map +1 -0
  87. package/lib/automation.d.ts +82 -5
  88. package/lib/automation.js +239 -82
  89. package/lib/automation.js.map +1 -1
  90. package/lib/browser-service.d.ts +304 -32
  91. package/lib/browser-service.js +631 -182
  92. package/lib/browser-service.js.map +1 -1
  93. package/lib/client/SettingsCard.js +95 -57
  94. package/lib/client/SettingsCard.js.map +1 -1
  95. package/lib/client/asset-editor.d.ts +55 -0
  96. package/lib/client/asset-editor.js +101 -0
  97. package/lib/client/asset-editor.js.map +1 -0
  98. package/lib/client/automation-assets-client.d.ts +99 -2
  99. package/lib/client/automation-assets-client.js +243 -10
  100. package/lib/client/automation-assets-client.js.map +1 -1
  101. package/lib/client/form.d.ts +48 -4
  102. package/lib/client/form.js +142 -29
  103. package/lib/client/form.js.map +1 -1
  104. package/lib/client/index.d.ts +25 -2
  105. package/lib/client/index.js +5 -1
  106. package/lib/client/index.js.map +1 -1
  107. package/lib/client/locales.d.ts +85 -6
  108. package/lib/client/locales.js +64 -12
  109. package/lib/client/locales.js.map +1 -1
  110. package/lib/client/prompts-form.d.ts +67 -0
  111. package/lib/client/prompts-form.js +140 -0
  112. package/lib/client/prompts-form.js.map +1 -0
  113. package/lib/client/prompts-status-client.d.ts +34 -0
  114. package/lib/client/prompts-status-client.js +53 -0
  115. package/lib/client/prompts-status-client.js.map +1 -0
  116. package/lib/client.js +1914 -329
  117. package/lib/client.js.map +1 -1
  118. package/lib/config.d.ts +50 -1
  119. package/lib/config.js +31 -1
  120. package/lib/config.js.map +1 -1
  121. package/lib/dialogs.d.ts +37 -0
  122. package/lib/dialogs.js +73 -0
  123. package/lib/dialogs.js.map +1 -0
  124. package/lib/freedom.d.ts +23 -7
  125. package/lib/freedom.js +48 -59
  126. package/lib/freedom.js.map +1 -1
  127. package/lib/index.d.ts +4 -4
  128. package/lib/index.js +36 -10
  129. package/lib/index.js.map +1 -1
  130. package/lib/journal.d.ts +109 -0
  131. package/lib/journal.js +238 -0
  132. package/lib/journal.js.map +1 -0
  133. package/lib/locator.d.ts +82 -0
  134. package/lib/locator.js +190 -0
  135. package/lib/locator.js.map +1 -0
  136. package/lib/observe-script.d.ts +27 -0
  137. package/lib/observe-script.js +565 -0
  138. package/lib/observe-script.js.map +1 -0
  139. package/lib/observe.d.ts +179 -0
  140. package/lib/observe.js +368 -0
  141. package/lib/observe.js.map +1 -0
  142. package/lib/policy-keys.d.ts +30 -0
  143. package/lib/policy-keys.js +34 -0
  144. package/lib/policy-keys.js.map +1 -0
  145. package/lib/prompt-limits.d.ts +30 -0
  146. package/lib/prompt-limits.js +31 -0
  147. package/lib/prompt-limits.js.map +1 -0
  148. package/lib/prompts.d.ts +131 -0
  149. package/lib/prompts.js +295 -0
  150. package/lib/prompts.js.map +1 -0
  151. package/lib/skill.d.ts +100 -0
  152. package/lib/skill.js +181 -0
  153. package/lib/skill.js.map +1 -0
  154. package/lib/tool-defs.d.ts +72 -0
  155. package/lib/tool-defs.js +67 -0
  156. package/lib/tool-defs.js.map +1 -0
  157. package/lib/tools.d.ts +19 -4
  158. package/lib/tools.js +124 -922
  159. package/lib/tools.js.map +1 -1
  160. package/package.json +5 -1
  161. package/scripts/dump-prompts.mjs +29 -0
  162. package/scripts/measure-tool-surface.mjs +190 -0
@@ -0,0 +1,449 @@
1
+ /**
2
+ * Turn a slice of the exploration journal into a v2 recipe draft.
3
+ *
4
+ * The journal is evidence of one exploration, not a trusted recording (the same rule the recording notes in
5
+ * docs/browser-recipe-migration-and-cancellation.md apply): failed and purely observing calls are left out,
6
+ * an action the recipe cannot express is reported as `unmapped` and keeps the draft from being activated,
7
+ * typed values are never guessed (a value that was not retained becomes a required input), and every
8
+ * judgement the builder made is visible in the report. It does not decide that the draft is equivalent to
9
+ * the exploration; the independent replay (`test` with `inputSets`) is what shows that.
10
+ * @module dsh-browser/automation-journal
11
+ */
12
+ import { ActionArgError } from "./actions/types.js";
13
+ import { redactUrl } from "./journal.js";
14
+ const NAME = /^[a-zA-Z][\w-]{0,39}$/;
15
+ const MAX_STEPS = 25;
16
+ const PARAM_FIELDS = { 'act.fill': 'text', 'act.type': 'text', 'act.select': 'values', 'target.open': 'url' };
17
+ function slug(value) {
18
+ const text = (value ?? '').toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '').slice(0, 24);
19
+ return /^[a-z]/.test(text) ? text : '';
20
+ }
21
+ function suggestedName(entry) {
22
+ const locator = entry.locator;
23
+ return slug(locator?.label ?? locator?.name ?? locator?.testId ?? (locator?.css?.match(/#([\w-]+)/)?.[1])) || 'input';
24
+ }
25
+ function hostOf(url) {
26
+ if (!url)
27
+ return undefined;
28
+ try {
29
+ const parsed = new URL(url);
30
+ return ['http:', 'https:'].includes(parsed.protocol) ? parsed.hostname.toLowerCase() : undefined;
31
+ }
32
+ catch {
33
+ return undefined;
34
+ }
35
+ }
36
+ function isRef(value) {
37
+ return !!value && typeof value === 'object' && typeof value.ref === 'string';
38
+ }
39
+ /** An atomic-action locator as a v2 recipe locator, or the reason it cannot be one. */
40
+ function recipeLocator(locator) {
41
+ if (!locator)
42
+ return { ok: true };
43
+ const { frame, selector, explicitFirst: _first, ...rest } = locator;
44
+ const out = { ...rest };
45
+ if (selector !== undefined && out.css === undefined)
46
+ out.css = selector;
47
+ if (frame) {
48
+ if (!frame.selector)
49
+ return { ok: false, reason: 'the locator picks its iframe by name or url, which v2 steps cannot express (they take framePath, iframe CSS selectors)' };
50
+ out.framePath = [frame.selector];
51
+ }
52
+ return { ok: true, value: out };
53
+ }
54
+ export function buildDraftFromJournal(journal, args) {
55
+ const all = journal.entries();
56
+ if (all.length === 0)
57
+ throw new ActionArgError('the journal of this session is empty: nothing was explored through browser_call yet', 'Explore first (target.open, observe.read, act.*), then call draft_from_journal.');
58
+ const fromSeq = args.fromSeq ?? all[0].seq;
59
+ const toSeq = args.toSeq ?? all[all.length - 1].seq;
60
+ if (fromSeq > toSeq)
61
+ throw new ActionArgError(`fromSeq ${fromSeq} is after toSeq ${toSeq}`);
62
+ const range = all.filter(entry => entry.seq >= fromSeq && entry.seq <= toSeq);
63
+ if (range.length === 0)
64
+ throw new ActionArgError(`no journal entry between seq ${fromSeq} and ${toSeq}`, `The journal holds seq ${all[0].seq}-${all[all.length - 1].seq}.`);
65
+ const bySeq = new Map(range.map(entry => [entry.seq, entry]));
66
+ const warnings = [];
67
+ if (journal.dropped > 0 && args.fromSeq !== undefined && args.fromSeq < all[0].seq)
68
+ warnings.push({ code: 'JOURNAL_TRUNCATED', message: `the journal keeps the last ${journal.limit} calls; seq before ${all[0].seq} were dropped, so the draft may start mid-exploration` });
69
+ // Arguments that name a seq must name one that is in the range.
70
+ const known = (seq, what) => {
71
+ const entry = bySeq.get(seq);
72
+ if (!entry)
73
+ throw new ActionArgError(`${what} names seq ${seq}, which is not in the selected range ${fromSeq}-${toSeq}`, `Journal entries in range: ${range.map(item => item.seq).join(', ')}.`);
74
+ return entry;
75
+ };
76
+ const excludeSet = new Set();
77
+ for (const seq of args.exclude ?? []) {
78
+ known(seq, 'exclude');
79
+ excludeSet.add(seq);
80
+ }
81
+ const lifted = new Map();
82
+ const names = new Map();
83
+ for (const parameter of args.parameters ?? []) {
84
+ const entry = known(parameter.seq, 'parameters');
85
+ const field = PARAM_FIELDS[entry.action];
86
+ if (!field)
87
+ throw new ActionArgError(`parameters: seq ${parameter.seq} is ${entry.action}, which has no value to turn into an input`, 'Parameters apply to act.fill, act.type (field "text"), act.select (field "values") and a later target.open (field "url").');
88
+ if (parameter.field !== field)
89
+ throw new ActionArgError(`parameters: ${entry.action} (seq ${parameter.seq}) has the field "${field}", not "${parameter.field}"`);
90
+ if (!NAME.test(parameter.name))
91
+ throw new ActionArgError(`parameters: name "${parameter.name}" must start with a letter and use letters, digits, _ or - (max 40)`);
92
+ if (lifted.has(parameter.seq))
93
+ throw new ActionArgError(`parameters: seq ${parameter.seq} is listed twice`);
94
+ const type = parameter.type ?? 'string';
95
+ if (names.has(parameter.name) && names.get(parameter.name) !== type)
96
+ throw new ActionArgError(`parameters: ${parameter.name} is declared with two types`);
97
+ names.set(parameter.name, type);
98
+ lifted.set(parameter.seq, { name: parameter.name, type });
99
+ }
100
+ const extracts = new Map();
101
+ for (const extract of args.extract ?? []) {
102
+ const entry = known(extract.seq, 'extract');
103
+ if (entry.action !== 'observe.read')
104
+ throw new ActionArgError(`extract: seq ${extract.seq} is ${entry.action}; only an observe.read can become an extract step`, 'Read the part of the page you want (observe.read with a locator), then name that seq here.');
105
+ const sections = entry.params.sections;
106
+ if (Array.isArray(sections) && !sections.includes('content'))
107
+ throw new ActionArgError(`extract: seq ${extract.seq} did not read the page text (sections ${JSON.stringify(sections)}); extract needs the content section`);
108
+ if (!NAME.test(extract.as))
109
+ throw new ActionArgError(`extract: as "${extract.as}" must start with a letter and use letters, digits, _ or - (max 40)`);
110
+ if ([...extracts.values()].some(other => other.as === extract.as))
111
+ throw new ActionArgError(`extract: output name "${extract.as}" is used twice`);
112
+ extracts.set(extract.seq, extract);
113
+ }
114
+ const steps = [];
115
+ const sourceMap = {};
116
+ const excluded = [];
117
+ const observationPoints = [];
118
+ const unmapped = [];
119
+ const inputs = new Map();
120
+ const candidates = [];
121
+ const pending = [];
122
+ const included = [];
123
+ let startUrl;
124
+ let primaryTarget;
125
+ const usedNames = new Set(names.keys());
126
+ const autoName = (entry, sensitive) => {
127
+ const base = sensitive ? 'secret' : suggestedName(entry);
128
+ let name = base;
129
+ for (let n = 2; usedNames.has(name) || inputs.has(name); n += 1)
130
+ name = `${base}${n}`;
131
+ usedNames.add(name);
132
+ return name;
133
+ };
134
+ const addInput = (spec) => { if (!inputs.has(spec.name))
135
+ inputs.set(spec.name, spec); };
136
+ const includedSeqs0 = () => new Set(included.map(entry => entry.seq));
137
+ const push = (entry, step) => {
138
+ steps.push(step);
139
+ sourceMap[String(entry.seq)] = steps.length;
140
+ included.push(entry);
141
+ if (step.locator?.index !== undefined)
142
+ pending.push({ step: steps.length, seq: entry.seq, kind: 'positional-index', locator: structuredClone(step.locator) });
143
+ };
144
+ const skip = (entry, reason) => { unmapped.push({ seq: entry.seq, action: entry.action, reason }); };
145
+ for (const entry of range) {
146
+ if (excludeSet.has(entry.seq)) {
147
+ excluded.push({ seq: entry.seq, reason: 'excluded by the caller' });
148
+ continue;
149
+ }
150
+ if (!entry.outcome.ok) {
151
+ excluded.push({ seq: entry.seq, reason: `failed: ${entry.outcome.errorCode ?? entry.outcome.executionStatus}` });
152
+ warnings.push({
153
+ code: entry.effects === 'unknown' ? 'FAILED_STEP_EFFECTS_UNKNOWN' : 'FAILED_STEP_EXCLUDED', seq: entry.seq,
154
+ message: `seq ${entry.seq} (${entry.action}) failed with ${entry.outcome.errorCode ?? entry.outcome.executionStatus} and was left out; the draft assumes the later steps did not depend on it${entry.effects === 'unknown' ? ' (it may have changed the page before failing)' : ''}`,
155
+ });
156
+ continue;
157
+ }
158
+ if (entry.action === 'target.close') {
159
+ excluded.push({ seq: entry.seq, reason: 'session control, not a page step' });
160
+ continue;
161
+ }
162
+ if (entry.observation) {
163
+ const extract = extracts.get(entry.seq);
164
+ if (!extract) {
165
+ observationPoints.push(entry.seq);
166
+ continue;
167
+ }
168
+ const located = recipeLocator(entry.locator);
169
+ if (!located.ok) {
170
+ skip(entry, located.reason);
171
+ continue;
172
+ }
173
+ push(entry, { type: 'extract', ...located.value ? { locator: located.value } : {}, mode: extract.mode ?? 'text', ...extract.limit !== undefined ? { limit: extract.limit } : {}, as: extract.as });
174
+ continue;
175
+ }
176
+ if (entry.action === 'target.select') {
177
+ skip(entry, 'switching between pages (target.select): a v2 recipe runs on one page');
178
+ continue;
179
+ }
180
+ if (['script.evaluate', 'script.run_builtin', 'script.run_userscript'].includes(entry.action)) {
181
+ skip(entry, 'page script cannot be a recipe step; reuse it as a userscript asset instead');
182
+ continue;
183
+ }
184
+ if (entry.action.startsWith('script.')) {
185
+ skip(entry, 'script actions are not recipe steps');
186
+ continue;
187
+ }
188
+ if (entry.action === 'act.upload') {
189
+ skip(entry, 'file upload is not a v2 recipe step');
190
+ continue;
191
+ }
192
+ if (entry.action === 'automation.run_recipe' || entry.action === 'automation.run') {
193
+ skip(entry, 'a whole recipe or asset was run here; save that recipe directly instead of recording it');
194
+ continue;
195
+ }
196
+ if (entry.targetId !== undefined) {
197
+ primaryTarget ??= entry.targetId;
198
+ if (entry.targetId !== primaryTarget) {
199
+ skip(entry, `ran on page ${entry.targetId}, not ${primaryTarget}: a v2 recipe runs on one page`);
200
+ continue;
201
+ }
202
+ }
203
+ const located = recipeLocator(entry.locator);
204
+ if (!located.ok) {
205
+ skip(entry, located.reason);
206
+ continue;
207
+ }
208
+ const locator = located.value;
209
+ const timeout = typeof entry.params.timeoutMs === 'number' && entry.params.timeoutMs >= 1 && entry.params.timeoutMs <= 30_000 ? { timeoutMs: entry.params.timeoutMs } : {};
210
+ switch (entry.action) {
211
+ case 'target.open': {
212
+ const raw = typeof entry.params.url === 'string' ? entry.params.url : undefined;
213
+ if (!raw || redactUrl(raw).url !== raw || raw.includes('%5Bredacted%5D')) {
214
+ skip(entry, 'the URL carried a secret (userinfo or a token in the query), which is not kept; pass the page url when testing');
215
+ break;
216
+ }
217
+ const first = startUrl === undefined && steps.length === 0;
218
+ if (first) {
219
+ if (lifted.has(entry.seq))
220
+ throw new ActionArgError(`parameters: seq ${entry.seq} is the opening page; the start url is already an argument of test and run`);
221
+ startUrl = raw;
222
+ included.push(entry);
223
+ sourceMap[String(entry.seq)] = 0;
224
+ break;
225
+ }
226
+ const lift = lifted.get(entry.seq);
227
+ if (lift) {
228
+ addInput({ name: lift.name, type: lift.type, required: true, example: raw });
229
+ push(entry, { type: 'goto', url: `{{${lift.name}}}` });
230
+ }
231
+ else {
232
+ push(entry, { type: 'goto', url: raw });
233
+ candidates.push({ seq: entry.seq, field: 'url', example: raw, suggestedName: 'url' });
234
+ }
235
+ break;
236
+ }
237
+ case 'act.click':
238
+ push(entry, { type: 'click', locator, ...timeout });
239
+ break;
240
+ case 'act.hover':
241
+ push(entry, { type: 'hover', locator, ...timeout });
242
+ break;
243
+ case 'act.clear':
244
+ push(entry, { type: 'clear', locator, ...timeout });
245
+ break;
246
+ case 'act.check':
247
+ push(entry, { type: 'check', locator, ...entry.params.checked === false ? { checked: false } : {}, ...timeout });
248
+ break;
249
+ case 'act.press':
250
+ push(entry, { type: 'press', key: String(entry.params.key), ...locator ? { locator } : {}, ...timeout });
251
+ break;
252
+ case 'act.scroll':
253
+ push(entry, { type: 'scroll', deltaY: typeof entry.params.deltaY === 'number' ? entry.params.deltaY : 2000 });
254
+ break;
255
+ case 'act.fill':
256
+ case 'act.type': {
257
+ const type = entry.action === 'act.fill' ? 'fill' : 'type';
258
+ const ref = entry.params.text;
259
+ const raw = isRef(ref) ? journal.rawText(entry.seq) : undefined;
260
+ const lift = lifted.get(entry.seq);
261
+ if (lift) {
262
+ if (lift.type === 'number' && raw !== undefined && !Number.isFinite(Number(raw)))
263
+ throw new ActionArgError(`parameters: seq ${entry.seq} typed a value that is not a number, so it cannot be a number input`);
264
+ addInput({ name: lift.name, type: lift.type, required: true, ...raw !== undefined && raw !== '' ? { example: lift.type === 'number' ? Number(raw) : raw } : {}, ...isRef(ref) && ref.sensitive ? { description: 'sensitive: pass at run time' } : {} });
265
+ push(entry, { type, locator, value: `{{${lift.name}}}`, ...timeout });
266
+ }
267
+ else if (raw !== undefined) {
268
+ if (raw === '')
269
+ push(entry, { type: 'fill', locator, value: '', allowEmpty: true, ...timeout });
270
+ else {
271
+ push(entry, { type, locator, value: raw, ...timeout });
272
+ candidates.push({ seq: entry.seq, field: 'text', example: raw, suggestedName: suggestedName(entry) });
273
+ }
274
+ }
275
+ else {
276
+ // The value was not retained (secret-looking, or too long): it cannot be a literal, so it becomes a required input.
277
+ const sensitive = isRef(ref) && ref.sensitive === true;
278
+ const name = autoName(entry, sensitive);
279
+ addInput({ name, type: 'string', required: true, description: sensitive ? 'sensitive: pass at run time' : 'value too long to keep; pass at run time' });
280
+ push(entry, { type, locator, value: `{{${name}}}`, ...timeout });
281
+ warnings.push({ code: sensitive ? 'SENSITIVE_VALUE_BECAME_INPUT' : 'VALUE_BECAME_INPUT', seq: entry.seq, message: `seq ${entry.seq}: the typed value was ${sensitive ? 'sensitive' : 'too long'} and is not stored; the draft takes it as the required input "${name}"` });
282
+ }
283
+ break;
284
+ }
285
+ case 'act.select': {
286
+ const values = Array.isArray(entry.params.values) ? entry.params.values : [];
287
+ if (values.length !== 1) {
288
+ skip(entry, 'selecting several options at once: v2 select takes one value');
289
+ break;
290
+ }
291
+ const value = values[0];
292
+ const lift = lifted.get(entry.seq);
293
+ if (lift) {
294
+ addInput({ name: lift.name, type: lift.type, required: true, ...typeof value === 'string' ? { example: lift.type === 'number' ? Number(value) : value } : {} });
295
+ push(entry, { type: 'select', locator, value: `{{${lift.name}}}`, ...timeout });
296
+ }
297
+ else if (typeof value === 'string') {
298
+ push(entry, { type: 'select', locator, value, ...timeout });
299
+ candidates.push({ seq: entry.seq, field: 'values', example: value, suggestedName: suggestedName(entry) });
300
+ }
301
+ else {
302
+ const name = autoName(entry, false);
303
+ addInput({ name, type: 'string', required: true, description: 'value not kept; pass at run time' });
304
+ push(entry, { type: 'select', locator, value: `{{${name}}}`, ...timeout });
305
+ }
306
+ break;
307
+ }
308
+ case 'act.wait': {
309
+ const p = entry.params;
310
+ if (locator) {
311
+ if (p.state !== undefined && p.state !== 'visible') {
312
+ skip(entry, `waiting for state "${String(p.state)}": v2 wait only waits for a visible element`);
313
+ break;
314
+ }
315
+ push(entry, { type: 'wait', condition: 'locator', locator, ...timeout });
316
+ }
317
+ else if (typeof p.urlPattern === 'string') {
318
+ if (/[*?{}[\]]/.test(p.urlPattern)) {
319
+ skip(entry, 'a glob URL pattern: v2 wait url matches by substring; wait for the page text or add an assert urlIncludes');
320
+ break;
321
+ }
322
+ push(entry, { type: 'wait', condition: 'url', value: p.urlPattern, ...timeout });
323
+ }
324
+ else if (p.networkIdle === true)
325
+ push(entry, { type: 'wait', condition: 'load', ...timeout });
326
+ else if (typeof p.timeMs === 'number') {
327
+ push(entry, { type: 'wait', condition: 'time', waitMs: p.timeMs });
328
+ warnings.push({ code: 'FIXED_DELAY', seq: entry.seq, message: `seq ${entry.seq}: a fixed ${p.timeMs} ms delay was copied; replace it with a wait for an element or text` });
329
+ }
330
+ else
331
+ skip(entry, 'a wait condition v2 cannot express');
332
+ break;
333
+ }
334
+ default:
335
+ skip(entry, `${entry.action} has no recipe step`);
336
+ }
337
+ }
338
+ for (const seq of lifted.keys())
339
+ if (!includedSeqs0().has(seq))
340
+ warnings.push({ code: 'PARAMETER_NOT_APPLIED', seq, message: `parameters names seq ${seq}, which is not a step in the draft (failed, excluded or unmapped), so that input was not declared` });
341
+ for (const seq of extracts.keys())
342
+ if (!includedSeqs0().has(seq))
343
+ warnings.push({ code: 'EXTRACT_NOT_APPLIED', seq, message: `extract names seq ${seq}, which is not a step in the draft` });
344
+ // Which steps did the exploration really run in sequence? A page that moved between two calls on its own is worth knowing about.
345
+ const lastOnTarget = new Map();
346
+ for (const entry of range) {
347
+ if (entry.targetId === undefined)
348
+ continue;
349
+ const before = lastOnTarget.get(entry.targetId);
350
+ if (before && before.generationAfter !== undefined && entry.generationBefore !== undefined && before.generationAfter !== entry.generationBefore) {
351
+ warnings.push({ code: 'GENERATION_JUMP', seq: entry.seq, message: `the page moved from generation ${before.generationAfter} (after seq ${before.seq}) to ${entry.generationBefore} (before seq ${entry.seq}) without a recorded action: it navigated or re-rendered on its own; the draft may need a wait or a goto there` });
352
+ }
353
+ lastOnTarget.set(entry.targetId, entry);
354
+ }
355
+ const includedSeqs = new Set(included.map(entry => entry.seq));
356
+ for (const entry of range) {
357
+ if (includedSeqs.has(entry.seq) || entry.observation)
358
+ continue;
359
+ const navigated = entry.generationAfter !== undefined && (entry.generationBefore === undefined || entry.generationAfter > entry.generationBefore);
360
+ if (navigated && entry.outcome.ok === false && entry.effects === 'none')
361
+ continue;
362
+ if (navigated && ['target.open', 'act.click', 'act.press'].includes(entry.action)) {
363
+ warnings.push({ code: 'EXCLUDED_NAVIGATION', seq: entry.seq, message: `seq ${entry.seq} (${entry.action}) navigated the page but is not a step in the draft, and no goto replaces it` });
364
+ }
365
+ }
366
+ if (steps.length === 0) {
367
+ throw new ActionArgError(`no step could be drafted from seq ${fromSeq}-${toSeq}${unmapped.length ? `; ${unmapped.length} action(s) are unmapped (${unmapped.slice(0, 3).map(item => `seq ${item.seq}: ${item.reason}`).join('; ')})` : ''}`, 'Widen the range, or write the recipe yourself with automation.develop save.');
368
+ }
369
+ if (steps.length > MAX_STEPS)
370
+ throw new ActionArgError(`the selection makes ${steps.length} steps; a recipe holds at most ${MAX_STEPS}`, 'Narrow it with fromSeq/toSeq or exclude repeated steps.');
371
+ // Domains: what the exploration touched, unless the caller says.
372
+ const hosts = new Set();
373
+ for (const entry of included) {
374
+ const host = hostOf(entry.url);
375
+ if (host)
376
+ hosts.add(host);
377
+ }
378
+ for (const step of steps)
379
+ if (step.type === 'goto' && !step.url.includes('{{')) {
380
+ const host = hostOf(step.url);
381
+ if (host)
382
+ hosts.add(host);
383
+ }
384
+ const startHost = hostOf(startUrl);
385
+ if (startHost)
386
+ hosts.add(startHost);
387
+ const domains = args.domains?.length ? args.domains.map(domain => domain.toLowerCase()) : [...hosts];
388
+ if (domains.length === 0)
389
+ throw new ActionArgError('no domain could be derived from the journal: pass domains', 'The draft needs the hostnames it may run on, for example ["example.com"].');
390
+ // Where a test has to start.
391
+ let suggestedTestUrl = startUrl;
392
+ if (suggestedTestUrl === undefined) {
393
+ const firstIncluded = included[0];
394
+ const before = [...all].reverse().find(entry => entry.seq < firstIncluded.seq && entry.url);
395
+ suggestedTestUrl = before?.url;
396
+ warnings.push({ code: 'NO_OPENING_STEP', message: `the selection has no opening target.open, so the draft starts on whatever page the test url loads${suggestedTestUrl ? `; the page before seq ${firstIncluded.seq} was ${suggestedTestUrl}` : ''}` });
397
+ }
398
+ // Outputs and what could verify them.
399
+ const extractSteps = steps.filter(step => step.type === 'extract');
400
+ const outputSchema = extractSteps.map(step => {
401
+ const source = [...extracts.values()].find(extract => extract.as === step.as);
402
+ return { name: step.as, type: step.mode === 'links' ? 'json' : 'string', ...source.dedupe ? { dedupe: true } : {} };
403
+ });
404
+ const extractCandidates = range
405
+ .filter(entry => entry.observation && entry.action === 'observe.read' && entry.outcome.ok && entry.locator && !extracts.has(entry.seq))
406
+ .map(entry => ({ seq: entry.seq, locator: entry.locator, ...entry.size !== undefined ? { chars: entry.size } : {} }));
407
+ if (extractSteps.length === 0)
408
+ warnings.push({ code: 'NO_OUTPUT', message: extractCandidates.length ? 'the draft has no extract step, so it returns nothing; pass extract:[{seq, as}] for one of extractCandidates' : 'the draft has no extract step, so it returns nothing; read the result with observe.read (locator) and name it in extract' });
409
+ const suggestedPostconditions = [];
410
+ const lastExtract = [...included].reverse().find(entry => entry.observation);
411
+ if (lastExtract) {
412
+ const name = steps[sourceMap[String(lastExtract.seq)] - 1].as;
413
+ suggestedPostconditions.push(lastExtract.size === 0 ? { output: name, allowEmpty: true } : { output: name, nonEmpty: true });
414
+ }
415
+ const lastUrl = included.length ? included[included.length - 1].url : undefined;
416
+ if (lastUrl && startUrl) {
417
+ try {
418
+ const now = new URL(lastUrl);
419
+ const start = new URL(startUrl);
420
+ if (now.pathname !== start.pathname)
421
+ suggestedPostconditions.push({ urlIncludes: now.pathname });
422
+ }
423
+ catch { /* not comparable */ }
424
+ }
425
+ const postconditions = args.postconditions;
426
+ if (!postconditions?.length && !steps.some(step => step.type === 'assert')) {
427
+ warnings.push({ code: 'NO_VERIFIER', message: 'the draft has no postcondition or assert, so its test cannot pass (VALIDATION_MISSING); pass postconditions (see suggestedPostconditions) when you call draft_from_journal again with id' });
428
+ }
429
+ const inputSchema = [...inputs.values()];
430
+ const report = {
431
+ fromSeq, toSeq, steps: steps.length, complete: unmapped.length === 0, sourceMap, observationPoints, excluded, unmapped, inputSchema,
432
+ pendingDisambiguation: pending, parameterCandidates: candidates, extractCandidates, suggestedPostconditions,
433
+ ...suggestedTestUrl ? { suggestedTestUrl } : {}, domains, warnings,
434
+ };
435
+ if (!report.complete)
436
+ warnings.push({ code: 'INCOMPLETE_DRAFT', message: `${unmapped.length} journaled action(s) could not become steps (see unmapped); the draft cannot be activated until you finish the recipe and save it yourself` });
437
+ return {
438
+ draft: {
439
+ kind: 'recipe', schemaVersion: 2, name: args.name,
440
+ description: args.description ?? `Drafted from exploration journal seq ${fromSeq}-${toSeq}.`,
441
+ domains, recipe: steps,
442
+ ...inputSchema.length ? { inputSchema } : {}, ...outputSchema.length ? { outputSchema } : {},
443
+ ...postconditions?.length ? { postconditions: postconditions } : {},
444
+ origin: { kind: 'journal', fromSeq, toSeq, unmapped: unmapped.length },
445
+ },
446
+ report,
447
+ };
448
+ }
449
+ //# sourceMappingURL=automation-journal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"automation-journal.js","sourceRoot":"","sources":["../src/automation-journal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAInD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AA+CxC,MAAM,IAAI,GAAG,uBAAuB,CAAA;AACpC,MAAM,SAAS,GAAG,EAAE,CAAA;AACpB,MAAM,YAAY,GAA2B,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,KAAK,EAAE,CAAA;AAErI,SAAS,IAAI,CAAC,KAAyB;IACrC,MAAM,IAAI,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IACzG,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,I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,IAAI,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,GAAG,QAAQ,CAAC,MAAM,4IAA4I,EAAE,CAAC,CAAA;IAC1O,OAAO;QACL,KAAK,EAAE;YACL,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI;YACjD,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,wCAAwC,OAAO,IAAI,KAAK,GAAG;YAC5F,OAAO,EAAE,MAAM,EAAE,KAAK;YACtB,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE;YAC5F,GAAG,cAAc,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,cAAiC,EAAE,CAAC,CAAC,CAAC,EAAE;YACtF,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,CAAC,MAAM,EAAE;SACvE;QACD,MAAM;KACP,CAAA;AACH,CAAC"}
@@ -0,0 +1,138 @@
1
+ /**
2
+ * Recipe schema v2: strict locators, goto/clear steps, typed inputs and outputs,
3
+ * and asset-level postconditions.
4
+ *
5
+ * v1 recipes (`schemaVersion` absent or 1) never pass through this module: they
6
+ * keep `.first()` and the old fill rule. A v2 step locates with a LocatorSpec,
7
+ * which must match exactly one element unless it carries `index` + `indexReason`
8
+ * (or the converter's `explicitFirst` marker).
9
+ * @module dsh-browser/automation-v2
10
+ */
11
+ import { type BrowserLocatorSpec } from './locator.ts';
12
+ export declare const WAIT_CONDITIONS_V2: readonly ["locator", "text", "url", "load", "time"];
13
+ export declare const STEP_TYPES_V2: readonly ["wait", "click", "fill", "clear", "type", "press", "select", "check", "hover", "scroll", "goto", "extract", "assert", "screenshot"];
14
+ export declare const EXTRACT_MODES_V2: readonly ["text", "html", "links", "attribute"];
15
+ export declare const INPUT_TYPES: readonly ["string", "number", "enum"];
16
+ export declare const OUTPUT_TYPES: readonly ["string", "number", "json"];
17
+ /** `{role,name?,exact?} | {label} | {text} | {testId} | {css}`, plus `framePath`, `index`+`indexReason`, `explicitFirst`. */
18
+ export type RecipeLocator = Omit<BrowserLocatorSpec, 'selector' | 'frame'>;
19
+ export interface BrowserRecipeStepV2 {
20
+ type: typeof STEP_TYPES_V2[number];
21
+ locator?: RecipeLocator;
22
+ condition?: typeof WAIT_CONDITIONS_V2[number];
23
+ value?: string;
24
+ allowEmpty?: boolean;
25
+ key?: string;
26
+ url?: string;
27
+ text?: string;
28
+ urlIncludes?: string;
29
+ mode?: typeof EXTRACT_MODES_V2[number];
30
+ attribute?: string;
31
+ limit?: number;
32
+ as?: string;
33
+ checked?: boolean;
34
+ deltaY?: number;
35
+ waitMs?: number;
36
+ timeoutMs?: number;
37
+ }
38
+ export interface InputSpec {
39
+ name: string;
40
+ type: typeof INPUT_TYPES[number];
41
+ required?: boolean;
42
+ example?: string | number;
43
+ enumValues?: string[];
44
+ description?: string;
45
+ }
46
+ export interface OutputSpec {
47
+ name: string;
48
+ type: typeof OUTPUT_TYPES[number];
49
+ description?: string;
50
+ /**
51
+ * Post-process the value: drop repeats, keep first occurrences in order. A `json` array is deduplicated by
52
+ * element, a `string` by line (blank lines dropped). It does not fail on duplicates; it removes them.
53
+ */
54
+ dedupe?: true;
55
+ }
56
+ export type Postcondition = {
57
+ selector: string;
58
+ timeoutMs?: number;
59
+ } | {
60
+ text: string;
61
+ timeoutMs?: number;
62
+ } | {
63
+ urlIncludes: string;
64
+ timeoutMs?: number;
65
+ } | {
66
+ output: string;
67
+ nonEmpty?: true;
68
+ allowEmpty?: true;
69
+ };
70
+ /** A step the v1 converter could not make strict: it still takes the first match, and should be made unique. */
71
+ export interface PendingDisambiguation {
72
+ step: number;
73
+ action: string;
74
+ kind: 'explicit-first';
75
+ locator: RecipeLocator;
76
+ }
77
+ /** What the runner needs besides the steps. */
78
+ export interface RecipeV2Options {
79
+ postconditions?: readonly Postcondition[];
80
+ outputSchema?: readonly OutputSpec[];
81
+ /** goto may land on these domains (a host equal to one of them, or a subdomain). */
82
+ allowedDomains?: readonly string[];
83
+ /** An inline recipe may also stay on the origin of the page it started on. */
84
+ sameOrigin?: string;
85
+ /** Navigate like `target.open` does (usage governor, settle, rule steps); supplied by the service. */
86
+ goto?: (url: string) => Promise<void>;
87
+ }
88
+ /** True when `host` is one of `domains` or a subdomain of one. */
89
+ export declare function hostInDomains(host: string, domains: readonly string[]): boolean;
90
+ /**
91
+ * Refuse a recipe whose literal goto URLs leave the allowed domains, before any step runs.
92
+ * Throws a message with "is not allowed on", which the shared mapping reports as POLICY_DENIED.
93
+ */
94
+ export declare function assertGotoAllowed(steps: readonly BrowserRecipeStepV2[], options: Pick<RecipeV2Options, 'allowedDomains' | 'sameOrigin'>): void;
95
+ /** Structural validation of v2 steps. Throws a message the model can act on; nothing is run. */
96
+ export declare function validateRecipeV2(steps: readonly BrowserRecipeStepV2[]): void;
97
+ /** Every `{{name}}` used by the steps and postconditions. */
98
+ export declare function placeholderNames(...values: unknown[]): string[];
99
+ export declare function normalizeInputSchema(raw: unknown): InputSpec[];
100
+ export declare function normalizeOutputSchema(raw: unknown, steps: readonly BrowserRecipeStepV2[]): OutputSpec[];
101
+ export declare function normalizePostconditions(raw: unknown, steps: readonly BrowserRecipeStepV2[]): Postcondition[];
102
+ export declare function normalizeRequiredCapabilities(raw: unknown): string[];
103
+ /** Steps whose locator still takes the first match without a reason: left by the v1 converter. */
104
+ export declare function pendingDisambiguation(steps: readonly BrowserRecipeStepV2[]): PendingDisambiguation[];
105
+ /**
106
+ * Validate caller inputs against the declared schema and convert them to the
107
+ * strings placeholders are replaced with: numbers are parsed and canonicalized,
108
+ * enums must be a listed value, an optional input left out becomes "".
109
+ */
110
+ export declare function coerceInputs(schema: readonly InputSpec[], raw: unknown): Record<string, string>;
111
+ /** Replace `{{name}}` in every string of a step or postcondition. `type` and `indexReason` are never touched. */
112
+ export declare function materializeDeep<T>(value: T, inputs: Record<string, string>): T;
113
+ export interface StepContext extends RecipeV2Options {
114
+ captureScreenshot: () => Promise<string>;
115
+ }
116
+ /** Run one v2 step. Returns the value an extract or screenshot step produced. */
117
+ export declare function runStepV2(page: any, step: BrowserRecipeStepV2, ctx: StepContext): Promise<string | undefined>;
118
+ /** Turn an extracted string into the declared output type. Returns the typed value, or a problem description. */
119
+ export declare function coerceOutput(spec: OutputSpec, value: unknown): {
120
+ ok: true;
121
+ value: unknown;
122
+ } | {
123
+ ok: false;
124
+ problem: string;
125
+ };
126
+ /** Drop repeats, keeping the first of each in order: array elements by value, text by line. Other values are returned unchanged. */
127
+ export declare function dedupeValue(value: unknown): unknown;
128
+ export interface PostconditionOutcome {
129
+ /** One line per condition that did not hold. */
130
+ failures: string[];
131
+ /** A failure that is not "did not hold" (page closed, ...): reported as the step failure itself. */
132
+ error?: unknown;
133
+ }
134
+ /** Check every postcondition; a condition that does not hold is described, never thrown. */
135
+ export declare function evaluatePostconditions(page: any, conditions: readonly Postcondition[], outputs: readonly {
136
+ name?: string;
137
+ value: unknown;
138
+ }[], signal?: AbortSignal): Promise<PostconditionOutcome>;