@burdenoff/ui-engine 0.0.0-stage → 2026.1127.2
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/LICENSE +25 -0
- package/README.md +97 -2
- package/dist/capture.d.ts +118 -0
- package/dist/capture.js +14 -0
- package/dist/index-3v887c75.js +52 -0
- package/dist/index-c6pmt2rg.js +213 -0
- package/dist/index-n5amgh31.js +210 -0
- package/dist/index-phd8yhyg.js +224 -0
- package/dist/index-tqffkt91.js +1986 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +234 -0
- package/dist/recording.d.ts +214 -0
- package/dist/recording.js +28 -0
- package/dist/redact-credentials.d.ts +39 -0
- package/dist/replay.d.ts +144 -0
- package/dist/replay.js +20 -0
- package/dist/resolve.d.ts +43 -0
- package/dist/resolve.js +10 -0
- package/dist/script/adapters/browser-action-contract.d.ts +22 -0
- package/dist/script/adapters/from-browser-action.d.ts +7 -0
- package/dist/script/adapters/from-remote-browser.d.ts +7 -0
- package/dist/script/adapters/recording.d.ts +25 -0
- package/dist/script/adapters/to-browser-action.d.ts +8 -0
- package/dist/script/canonical.d.ts +6 -0
- package/dist/script/capabilities.d.ts +29 -0
- package/dist/script/describe.d.ts +83 -0
- package/dist/script/fingerprint.d.ts +9 -0
- package/dist/script/hash.d.ts +3 -0
- package/dist/script/index.d.ts +22 -0
- package/dist/script/json-schema.d.ts +4 -0
- package/dist/script/limits.d.ts +61 -0
- package/dist/script/parse.d.ts +31 -0
- package/dist/script/schema.d.ts +87 -0
- package/dist/script/types.d.ts +489 -0
- package/dist/script/walk.d.ts +29 -0
- package/dist/script.d.ts +2 -0
- package/dist/script.js +175 -0
- package/package.json +101 -4
- package/schema/ui-script-v1.schema.json +8199 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RecordingError2,
|
|
3
|
+
parseRecording2
|
|
4
|
+
} from "./index-c6pmt2rg.js";
|
|
5
|
+
import {
|
|
6
|
+
readSnapshotNodes2,
|
|
7
|
+
resolveTarget2
|
|
8
|
+
} from "./index-3v887c75.js";
|
|
9
|
+
|
|
10
|
+
// src/replay.ts
|
|
11
|
+
var CALL_PREFIX = "replay-";
|
|
12
|
+
var SNAPSHOT_SUFFIX = "-snapshot";
|
|
13
|
+
var ACT_SUFFIX = "-act";
|
|
14
|
+
function defaultToolName(kind) {
|
|
15
|
+
return `desk_${kind}`;
|
|
16
|
+
}
|
|
17
|
+
function callPrefixOf(options) {
|
|
18
|
+
return options?.callPrefix ?? CALL_PREFIX;
|
|
19
|
+
}
|
|
20
|
+
function toolNameOf(options) {
|
|
21
|
+
return options?.toolName ?? defaultToolName;
|
|
22
|
+
}
|
|
23
|
+
function stepAt(state) {
|
|
24
|
+
return state.recording.steps[state.cursor];
|
|
25
|
+
}
|
|
26
|
+
function needsTarget(step) {
|
|
27
|
+
return "target" in step && step.target !== undefined;
|
|
28
|
+
}
|
|
29
|
+
function call(id, name, args) {
|
|
30
|
+
return { id, type: "function", function: { name, arguments: JSON.stringify(args) } };
|
|
31
|
+
}
|
|
32
|
+
function actionArguments(step, ref) {
|
|
33
|
+
const at = ref ? { ref } : {};
|
|
34
|
+
switch (step.action) {
|
|
35
|
+
case "click":
|
|
36
|
+
return { ...at, button: step.button, count: step.count };
|
|
37
|
+
case "type":
|
|
38
|
+
return { ...at, text: step.text ?? "" };
|
|
39
|
+
case "secret_fill":
|
|
40
|
+
return { ...at, secretRef: step.secretRef, expectedOrigin: step.expectedOrigin };
|
|
41
|
+
case "key":
|
|
42
|
+
return { keys: step.keys };
|
|
43
|
+
case "scroll":
|
|
44
|
+
return { ...at, dx: step.dx, dy: step.dy };
|
|
45
|
+
case "navigate":
|
|
46
|
+
return { url: step.url };
|
|
47
|
+
case "focus_window":
|
|
48
|
+
return { app: step.app, ...step.title ? { title: step.title } : {} };
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function replayStateFrom2(context) {
|
|
52
|
+
if (!context || typeof context !== "object" || Array.isArray(context))
|
|
53
|
+
return null;
|
|
54
|
+
const replay = context.replay;
|
|
55
|
+
if (replay === undefined || replay === null)
|
|
56
|
+
return null;
|
|
57
|
+
if (typeof replay !== "object" || Array.isArray(replay)) {
|
|
58
|
+
throw new RecordingError2("INVALID_RECORDING", "The run replay settings are not an object.");
|
|
59
|
+
}
|
|
60
|
+
const record = replay;
|
|
61
|
+
const recording = parseRecording2(record.recording);
|
|
62
|
+
return {
|
|
63
|
+
recording,
|
|
64
|
+
source: {
|
|
65
|
+
playbookId: typeof record.playbookId === "string" ? record.playbookId : null,
|
|
66
|
+
version: typeof record.version === "number" ? record.version : null
|
|
67
|
+
},
|
|
68
|
+
cursor: 0,
|
|
69
|
+
snapshot: null,
|
|
70
|
+
snapshotFor: null,
|
|
71
|
+
fallback: null,
|
|
72
|
+
replayed: 0,
|
|
73
|
+
fallbacks: 0,
|
|
74
|
+
awaiting: null
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
function readReplayState2(value) {
|
|
78
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
79
|
+
return null;
|
|
80
|
+
const record = value;
|
|
81
|
+
let recording;
|
|
82
|
+
try {
|
|
83
|
+
recording = parseRecording2(record.recording);
|
|
84
|
+
} catch {
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
const cursor = typeof record.cursor === "number" && Number.isInteger(record.cursor) ? record.cursor : 0;
|
|
88
|
+
const fallback = record.fallback;
|
|
89
|
+
const source = record.source ?? {};
|
|
90
|
+
return {
|
|
91
|
+
recording,
|
|
92
|
+
source: {
|
|
93
|
+
playbookId: typeof source.playbookId === "string" ? source.playbookId : null,
|
|
94
|
+
version: typeof source.version === "number" ? source.version : null
|
|
95
|
+
},
|
|
96
|
+
cursor: Math.max(0, Math.min(cursor, recording.steps.length)),
|
|
97
|
+
snapshot: record.snapshot === null || record.snapshot === undefined ? null : readSnapshotNodes2(record.snapshot),
|
|
98
|
+
snapshotFor: typeof record.snapshotFor === "number" ? record.snapshotFor : null,
|
|
99
|
+
fallback: fallback && typeof fallback.index === "number" && typeof fallback.reason === "string" ? { index: fallback.index, reason: fallback.reason, asked: fallback.asked === true } : null,
|
|
100
|
+
replayed: typeof record.replayed === "number" ? record.replayed : 0,
|
|
101
|
+
fallbacks: typeof record.fallbacks === "number" ? record.fallbacks : 0,
|
|
102
|
+
awaiting: typeof record.awaiting === "string" ? record.awaiting : null
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function fallbackPlan(state, step, reason) {
|
|
106
|
+
const next = {
|
|
107
|
+
...state,
|
|
108
|
+
fallback: { index: state.cursor, reason, asked: false },
|
|
109
|
+
snapshot: null,
|
|
110
|
+
snapshotFor: null,
|
|
111
|
+
awaiting: null
|
|
112
|
+
};
|
|
113
|
+
const position = `${state.cursor + 1} of ${state.recording.steps.length}`;
|
|
114
|
+
return {
|
|
115
|
+
kind: "fallback",
|
|
116
|
+
state: next,
|
|
117
|
+
reasons: [`replay:fallback:${step.id}:${reason}`],
|
|
118
|
+
message: {
|
|
119
|
+
role: "user",
|
|
120
|
+
content: `Saved step ${position} could not be replayed (${reason}). Do this one step yourself with the desk tools, ` + `then stop; the remaining saved steps continue after it. The step: ${step.intent}`
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function planReplay2(state, options) {
|
|
125
|
+
const prefix = callPrefixOf(options);
|
|
126
|
+
const toolName = toolNameOf(options);
|
|
127
|
+
const step = stepAt(state);
|
|
128
|
+
if (!step) {
|
|
129
|
+
return {
|
|
130
|
+
kind: "done",
|
|
131
|
+
state,
|
|
132
|
+
output: state.fallbacks === 0 ? `Replayed ${state.replayed} saved step(s) with no model call.` : `Replayed ${state.replayed} saved step(s); ${state.fallbacks} step(s) needed the model.`
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
if (step.action === "type" && step.masked)
|
|
136
|
+
return fallbackPlan(state, step, "masked-input");
|
|
137
|
+
let ref = null;
|
|
138
|
+
if (needsTarget(step) && "target" in step && step.target) {
|
|
139
|
+
if (state.snapshotFor !== state.cursor) {
|
|
140
|
+
const snapshot = call(`${prefix}${step.id}${SNAPSHOT_SUFFIX}`, toolName("snapshot"), {});
|
|
141
|
+
return {
|
|
142
|
+
kind: "call",
|
|
143
|
+
state: { ...state, awaiting: snapshot.id },
|
|
144
|
+
call: snapshot,
|
|
145
|
+
reasons: [`replay:snapshot:${step.id}`]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const found = resolveTarget2(step.target, state.snapshot);
|
|
149
|
+
if (!found.resolved)
|
|
150
|
+
return fallbackPlan(state, step, found.reason);
|
|
151
|
+
ref = found.ref;
|
|
152
|
+
}
|
|
153
|
+
const act = call(`${prefix}${step.id}${ACT_SUFFIX}`, toolName(step.action), actionArguments(step, ref));
|
|
154
|
+
return { kind: "call", state: { ...state, awaiting: act.id }, call: act, reasons: [`replay:step:${step.id}`] };
|
|
155
|
+
}
|
|
156
|
+
var RAN = new Set(["ALLOWED", "APPROVED"]);
|
|
157
|
+
function afterReplayCall2(state, callId, outcome, options) {
|
|
158
|
+
const step = stepAt(state);
|
|
159
|
+
if (!step || callId !== state.awaiting)
|
|
160
|
+
return { state };
|
|
161
|
+
if (callId === `${callPrefixOf(options)}${step.id}${SNAPSHOT_SUFFIX}`) {
|
|
162
|
+
if (!RAN.has(outcome.verdict))
|
|
163
|
+
return fallbackPlan(state, step, "snapshot-failed");
|
|
164
|
+
return {
|
|
165
|
+
state: { ...state, snapshot: readSnapshotNodes2(outcome.data), snapshotFor: state.cursor, awaiting: null }
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
if (!RAN.has(outcome.verdict) && outcome.verdict !== "SKIPPED" && outcome.verdict !== "BLOCKED_DRY_RUN") {
|
|
169
|
+
return fallbackPlan(state, step, outcome.verdict === "FAILED" ? "action-failed" : "action-refused");
|
|
170
|
+
}
|
|
171
|
+
return {
|
|
172
|
+
state: {
|
|
173
|
+
...state,
|
|
174
|
+
cursor: state.cursor + 1,
|
|
175
|
+
replayed: state.replayed + 1,
|
|
176
|
+
snapshot: null,
|
|
177
|
+
snapshotFor: null,
|
|
178
|
+
awaiting: null
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function finishFallback2(state) {
|
|
183
|
+
if (!state.fallback)
|
|
184
|
+
return state;
|
|
185
|
+
return {
|
|
186
|
+
...state,
|
|
187
|
+
cursor: state.fallback.index + 1,
|
|
188
|
+
fallback: null,
|
|
189
|
+
fallbacks: state.fallbacks + 1,
|
|
190
|
+
snapshot: null,
|
|
191
|
+
snapshotFor: null
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function markFallbackAsked2(state) {
|
|
195
|
+
return state.fallback ? { ...state, fallback: { ...state.fallback, asked: true } } : state;
|
|
196
|
+
}
|
|
197
|
+
function replayReasons2(state, callId) {
|
|
198
|
+
if (!state)
|
|
199
|
+
return [];
|
|
200
|
+
const step = stepAt(state);
|
|
201
|
+
if (step && callId !== null && callId === state.awaiting) {
|
|
202
|
+
return [callId.endsWith(SNAPSHOT_SUFFIX) ? `replay:snapshot:${step.id}` : `replay:step:${step.id}`];
|
|
203
|
+
}
|
|
204
|
+
if (!state.fallback)
|
|
205
|
+
return [];
|
|
206
|
+
const replaced = state.recording.steps[state.fallback.index];
|
|
207
|
+
return replaced ? [`replay:fallback:${replaced.id}:${state.fallback.reason}`] : [];
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export { replayStateFrom2, readReplayState2, planReplay2, afterReplayCall2, finishFallback2, markFallbackAsked2, replayReasons2 };
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {
|
|
2
|
+
REDACTED2,
|
|
3
|
+
redactCredentials2,
|
|
4
|
+
containsCredential,
|
|
5
|
+
decodeUriText,
|
|
6
|
+
containsCredentialInUrl,
|
|
7
|
+
RECORDING_VERSION2,
|
|
8
|
+
targetFingerprint2,
|
|
9
|
+
parseRecording2
|
|
10
|
+
} from "./index-c6pmt2rg.js";
|
|
11
|
+
|
|
12
|
+
// src/capture.ts
|
|
13
|
+
var SECRET_FIELD = /password|passcode|passwd|\bpin\b|otp|one[\s-]?time|verification|security code|auth(?:entication)? code|\bcvv\b|\bcvc\b|card number|secret|token|recovery/i;
|
|
14
|
+
var SECRET_AUTOCOMPLETE = /password|one-time-code|^cc-/i;
|
|
15
|
+
var SECRET_PARAM = /token|code|key|secret|sig|signature|auth|password|passwd|otp|session|state|reset|nonce|ticket|hash/i;
|
|
16
|
+
var RESET_PATH = /reset|recover|verify|verification|magic|confirm|activate|invite|unsubscribe/i;
|
|
17
|
+
var SECRET_LABEL = /code|pin|otp|password|passcode|token|verification|one[\s-]?time/i;
|
|
18
|
+
var CODE_LIKE = /^[\d ]{4,10}$/;
|
|
19
|
+
function isSecretField(element) {
|
|
20
|
+
if (!element)
|
|
21
|
+
return false;
|
|
22
|
+
if (element.inputType?.toLowerCase() === "password")
|
|
23
|
+
return true;
|
|
24
|
+
if (element.autocomplete && SECRET_AUTOCOMPLETE.test(element.autocomplete))
|
|
25
|
+
return true;
|
|
26
|
+
return SECRET_FIELD.test(element.name);
|
|
27
|
+
}
|
|
28
|
+
function cleanLabel(text) {
|
|
29
|
+
const cleaned = redactCredentials2(text);
|
|
30
|
+
return (SECRET_LABEL.test(cleaned) ? cleaned.replace(/\d{4,}/g, REDACTED2) : cleaned).trim();
|
|
31
|
+
}
|
|
32
|
+
var MIN_SCRUBBED_SECRET = 4;
|
|
33
|
+
function scrubberFor(secrets) {
|
|
34
|
+
const known = [...new Set(secrets.filter((secret) => secret.length >= MIN_SCRUBBED_SECRET))].sort((a, b) => b.length - a.length);
|
|
35
|
+
const holds = (part) => {
|
|
36
|
+
const decoded = decodeUriText(part);
|
|
37
|
+
return known.some((secret) => part.includes(secret) || decoded.includes(secret));
|
|
38
|
+
};
|
|
39
|
+
const scrub = Object.assign((text) => known.reduce((out, secret) => out.replaceAll(secret, REDACTED2), text), {
|
|
40
|
+
url: (raw) => {
|
|
41
|
+
const url = new URL(raw);
|
|
42
|
+
if (holds(url.search) || holds(url.hash)) {
|
|
43
|
+
url.search = "";
|
|
44
|
+
url.hash = "";
|
|
45
|
+
}
|
|
46
|
+
if (holds(url.pathname))
|
|
47
|
+
url.pathname = "/";
|
|
48
|
+
return url.toString();
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return scrub;
|
|
52
|
+
}
|
|
53
|
+
function scrubTarget(target, scrub) {
|
|
54
|
+
return {
|
|
55
|
+
...target,
|
|
56
|
+
...target.app ? { app: scrub(target.app) } : {},
|
|
57
|
+
...target.window ? { window: scrub(target.window) } : {},
|
|
58
|
+
role: scrub(target.role),
|
|
59
|
+
name: scrub(target.name)
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function scrubDraft(draft, scrub) {
|
|
63
|
+
const intent = scrub(draft.intent);
|
|
64
|
+
switch (draft.action) {
|
|
65
|
+
case "click":
|
|
66
|
+
case "secret_fill":
|
|
67
|
+
return { ...draft, intent, target: scrubTarget(draft.target, scrub) };
|
|
68
|
+
case "scroll":
|
|
69
|
+
return { ...draft, intent, ...draft.target ? { target: scrubTarget(draft.target, scrub) } : {} };
|
|
70
|
+
case "focus_window":
|
|
71
|
+
return { ...draft, intent, app: scrub(draft.app), ...draft.title ? { title: scrub(draft.title) } : {} };
|
|
72
|
+
case "type": {
|
|
73
|
+
const target = draft.target ? { target: scrubTarget(draft.target, scrub) } : {};
|
|
74
|
+
if (draft.text === undefined || scrub(draft.text) === draft.text) {
|
|
75
|
+
return { ...draft, intent, ...target };
|
|
76
|
+
}
|
|
77
|
+
const screenshotRef = draft.screenshotRef ? { screenshotRef: draft.screenshotRef } : {};
|
|
78
|
+
return { id: draft.id, intent, ...screenshotRef, ...target, action: "type", masked: true };
|
|
79
|
+
}
|
|
80
|
+
case "navigate":
|
|
81
|
+
return { ...draft, intent, url: scrub.url(draft.url) };
|
|
82
|
+
case "key":
|
|
83
|
+
return { ...draft, intent };
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function targetOf(element) {
|
|
87
|
+
return {
|
|
88
|
+
...element.app ? { app: cleanLabel(element.app) } : {},
|
|
89
|
+
...element.window ? { window: cleanLabel(element.window) } : {},
|
|
90
|
+
role: cleanLabel(element.role),
|
|
91
|
+
name: cleanLabel(element.name),
|
|
92
|
+
nth: element.nth ?? 0
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function resetLinkKeep(segments) {
|
|
96
|
+
const index = segments.findIndex((segment) => RESET_PATH.test(decodeUriText(segment)));
|
|
97
|
+
if (index === -1)
|
|
98
|
+
return;
|
|
99
|
+
const segment = decodeUriText(segments[index] ?? "");
|
|
100
|
+
return /\d/.test(segment) || segment.length > 64 ? index : index + 1;
|
|
101
|
+
}
|
|
102
|
+
function sensitiveValues(params, everyValue) {
|
|
103
|
+
return [...params.entries()].filter(([name, value]) => everyValue || SECRET_PARAM.test(name) || containsCredential(value)).map(([, value]) => value);
|
|
104
|
+
}
|
|
105
|
+
function maskUrlParts(raw) {
|
|
106
|
+
const url = new URL(raw);
|
|
107
|
+
const removed = [url.username, url.password].map(decodeUriText);
|
|
108
|
+
url.username = "";
|
|
109
|
+
url.password = "";
|
|
110
|
+
const params = [...url.searchParams.keys()];
|
|
111
|
+
const resetLink = RESET_PATH.test(decodeUriText(url.pathname));
|
|
112
|
+
const credentialInPath = containsCredentialInUrl(url.pathname);
|
|
113
|
+
const carriesSecret = params.some((name) => SECRET_PARAM.test(name)) || resetLink || credentialInPath || SECRET_PARAM.test(url.hash) || containsCredentialInUrl(url.search) || containsCredentialInUrl(url.hash);
|
|
114
|
+
if (!carriesSecret) {
|
|
115
|
+
return { url: url.toString(), masked: raw !== url.toString(), removed: removed.filter(Boolean) };
|
|
116
|
+
}
|
|
117
|
+
removed.push(...sensitiveValues(url.searchParams, resetLink));
|
|
118
|
+
const fragment = url.hash.slice(1);
|
|
119
|
+
if (fragment.includes("="))
|
|
120
|
+
removed.push(...sensitiveValues(new URLSearchParams(fragment), resetLink));
|
|
121
|
+
else if (fragment && (resetLink || SECRET_PARAM.test(fragment)))
|
|
122
|
+
removed.push(decodeUriText(fragment));
|
|
123
|
+
url.search = "";
|
|
124
|
+
url.hash = "";
|
|
125
|
+
const segments = url.pathname.split("/");
|
|
126
|
+
const keep = credentialInPath ? 1 : resetLink ? resetLinkKeep(segments) : undefined;
|
|
127
|
+
if (keep !== undefined) {
|
|
128
|
+
if (!credentialInPath)
|
|
129
|
+
removed.push(...segments.slice(keep).map(decodeUriText));
|
|
130
|
+
url.pathname = segments.slice(0, keep).join("/") || "/";
|
|
131
|
+
}
|
|
132
|
+
return { url: url.toString(), masked: true, removed: removed.filter(Boolean) };
|
|
133
|
+
}
|
|
134
|
+
function maskUrl2(raw) {
|
|
135
|
+
const { url, masked } = maskUrlParts(raw);
|
|
136
|
+
return { url, masked };
|
|
137
|
+
}
|
|
138
|
+
function captureRecording2(events) {
|
|
139
|
+
const drafts = [];
|
|
140
|
+
const capturedSecrets = [];
|
|
141
|
+
events.forEach((event, index) => {
|
|
142
|
+
const id = `s${index + 1}`;
|
|
143
|
+
const intent = redactCredentials2(event.intent?.trim() || `Step ${index + 1}: ${event.type}`).slice(0, 500);
|
|
144
|
+
const screenshotRef = event.screenshot?.masked ? { screenshotRef: event.screenshot.ref } : {};
|
|
145
|
+
const common = { id, intent, ...screenshotRef };
|
|
146
|
+
let draft;
|
|
147
|
+
switch (event.type) {
|
|
148
|
+
case "click":
|
|
149
|
+
draft = {
|
|
150
|
+
...common,
|
|
151
|
+
action: "click",
|
|
152
|
+
target: targetOf(event.element),
|
|
153
|
+
button: event.button ?? "left",
|
|
154
|
+
count: event.count ?? 1
|
|
155
|
+
};
|
|
156
|
+
break;
|
|
157
|
+
case "type": {
|
|
158
|
+
const target = event.element ? { target: targetOf(event.element) } : {};
|
|
159
|
+
const secret = isSecretField(event.element) || CODE_LIKE.test(event.text) || redactCredentials2(event.text) !== event.text;
|
|
160
|
+
if (secret) {
|
|
161
|
+
if (event.text)
|
|
162
|
+
capturedSecrets.push(event.text);
|
|
163
|
+
if (event.secretRef && event.origin && event.element) {
|
|
164
|
+
draft = {
|
|
165
|
+
...common,
|
|
166
|
+
action: "secret_fill",
|
|
167
|
+
target: targetOf(event.element),
|
|
168
|
+
secretRef: event.secretRef,
|
|
169
|
+
expectedOrigin: new URL(event.origin).origin
|
|
170
|
+
};
|
|
171
|
+
} else {
|
|
172
|
+
draft = { ...common, ...target, action: "type", masked: true };
|
|
173
|
+
}
|
|
174
|
+
} else {
|
|
175
|
+
draft = { ...common, ...target, action: "type", text: event.text, masked: false };
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case "key":
|
|
180
|
+
draft = { ...common, action: "key", keys: [...event.keys] };
|
|
181
|
+
break;
|
|
182
|
+
case "scroll":
|
|
183
|
+
draft = {
|
|
184
|
+
...common,
|
|
185
|
+
...event.element ? { target: targetOf(event.element) } : {},
|
|
186
|
+
action: "scroll",
|
|
187
|
+
dx: Math.trunc(event.dx),
|
|
188
|
+
dy: Math.trunc(event.dy)
|
|
189
|
+
};
|
|
190
|
+
break;
|
|
191
|
+
case "navigate": {
|
|
192
|
+
const masked = maskUrlParts(event.url);
|
|
193
|
+
if (masked.masked)
|
|
194
|
+
capturedSecrets.push(event.url, ...masked.removed);
|
|
195
|
+
draft = { ...common, action: "navigate", url: masked.url };
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case "focus_window":
|
|
199
|
+
draft = {
|
|
200
|
+
...common,
|
|
201
|
+
action: "focus_window",
|
|
202
|
+
app: cleanLabel(event.app),
|
|
203
|
+
...event.title ? { title: cleanLabel(event.title) } : {}
|
|
204
|
+
};
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
drafts.push(draft);
|
|
208
|
+
});
|
|
209
|
+
const scrub = scrubberFor(capturedSecrets);
|
|
210
|
+
const steps = drafts.map((original) => {
|
|
211
|
+
const draft = scrubDraft(original, scrub);
|
|
212
|
+
return { ...draft, fingerprint: targetFingerprint2(draft) };
|
|
213
|
+
});
|
|
214
|
+
for (const step of steps) {
|
|
215
|
+
if (step.screenshotRef && capturedSecrets.some((secret) => secret && step.screenshotRef?.includes(secret))) {
|
|
216
|
+
delete step.screenshotRef;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
const recording = parseRecording2({ version: RECORDING_VERSION2, steps });
|
|
220
|
+
const maskedStepIds = recording.steps.filter((step) => step.action === "type" && step.masked).map((step) => step.id);
|
|
221
|
+
return { recording, maskedStepIds, capturedSecrets };
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export { maskUrl2, captureRecording2 };
|