browserpaw 0.0.0-stage → 5.0.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 (69) hide show
  1. package/LICENSE +681 -0
  2. package/README.md +4 -2
  3. package/dist/v5/cli-files.cjs +147 -0
  4. package/dist/v5/cli.cjs +4900 -0
  5. package/dist/v5/extension/assets/popup-Djl4pI1R.css +359 -0
  6. package/dist/v5/extension/background.js +39389 -0
  7. package/dist/v5/extension/browserpaw-build.json +191 -0
  8. package/dist/v5/extension/chunks/popup-BSqTH70w.js +6575 -0
  9. package/dist/v5/extension/content-scripts/agent-cursor.js +1475 -0
  10. package/dist/v5/extension/icon/128.png +0 -0
  11. package/dist/v5/extension/icon/16.png +0 -0
  12. package/dist/v5/extension/icon/32.png +0 -0
  13. package/dist/v5/extension/icon/48.png +0 -0
  14. package/dist/v5/extension/icon/96.png +0 -0
  15. package/dist/v5/extension/images/cursor-chat.png +0 -0
  16. package/dist/v5/extension/inject-scripts/accessibility-tree-helper.js +2031 -0
  17. package/dist/v5/extension/inject-scripts/keyboard-helper.js +412 -0
  18. package/dist/v5/extension/inject-scripts/network-helper.js +378 -0
  19. package/dist/v5/extension/inject-scripts/screenshot-helper.js +449 -0
  20. package/dist/v5/extension/inpage-engine.js +9437 -0
  21. package/dist/v5/extension/manifest.json +1 -0
  22. package/dist/v5/extension/popup.html +14 -0
  23. package/dist/v5/host.cjs +19813 -0
  24. package/dist/v5/recipes/bilibili-popular-videos.json +364 -0
  25. package/dist/v5/recipes/bilibili-video-detail.json +395 -0
  26. package/dist/v5/recipes/developer.mozilla.org.md +15 -0
  27. package/dist/v5/recipes/github-issue-thread.json +313 -0
  28. package/dist/v5/recipes/github-releases.json +218 -0
  29. package/dist/v5/recipes/github-repo-readme.json +306 -0
  30. package/dist/v5/recipes/github-repo-search.json +313 -0
  31. package/dist/v5/recipes/mdn-search.json +219 -0
  32. package/dist/v5/recipes/npm-compare.json +458 -0
  33. package/dist/v5/recipes/reddit-post-read.json +289 -0
  34. package/dist/v5/recipes/reddit-subreddit-posts.json +331 -0
  35. package/dist/v5/recipes/v2ex-node-topics.json +334 -0
  36. package/dist/v5/recipes/v2ex-topic-read.json +325 -0
  37. package/dist/v5/recipes/x-profile-posts.json +332 -0
  38. package/dist/v5/recipes/x-search-thread.json +293 -0
  39. package/dist/v5/recipes/x-visible-thread.json +260 -0
  40. package/dist/v5/recipes/youtube-search-videos.json +279 -0
  41. package/dist/v5/recipes/youtube-video-read.json +349 -0
  42. package/dist/v5/run_host.bat +7 -0
  43. package/dist/v5/run_host.sh +6 -0
  44. package/dist/v5/skill/browserpaw/SKILL.md +48 -0
  45. package/dist/v5/skill/browserpaw/assets/recipes/bilibili-popular-videos.json +364 -0
  46. package/dist/v5/skill/browserpaw/assets/recipes/bilibili-video-detail.json +395 -0
  47. package/dist/v5/skill/browserpaw/assets/recipes/developer.mozilla.org.md +15 -0
  48. package/dist/v5/skill/browserpaw/assets/recipes/github-issue-thread.json +313 -0
  49. package/dist/v5/skill/browserpaw/assets/recipes/github-releases.json +218 -0
  50. package/dist/v5/skill/browserpaw/assets/recipes/github-repo-readme.json +306 -0
  51. package/dist/v5/skill/browserpaw/assets/recipes/github-repo-search.json +313 -0
  52. package/dist/v5/skill/browserpaw/assets/recipes/mdn-search.json +219 -0
  53. package/dist/v5/skill/browserpaw/assets/recipes/npm-compare.json +458 -0
  54. package/dist/v5/skill/browserpaw/assets/recipes/reddit-post-read.json +289 -0
  55. package/dist/v5/skill/browserpaw/assets/recipes/reddit-subreddit-posts.json +331 -0
  56. package/dist/v5/skill/browserpaw/assets/recipes/v2ex-node-topics.json +334 -0
  57. package/dist/v5/skill/browserpaw/assets/recipes/v2ex-topic-read.json +325 -0
  58. package/dist/v5/skill/browserpaw/assets/recipes/x-profile-posts.json +332 -0
  59. package/dist/v5/skill/browserpaw/assets/recipes/x-search-thread.json +293 -0
  60. package/dist/v5/skill/browserpaw/assets/recipes/x-visible-thread.json +260 -0
  61. package/dist/v5/skill/browserpaw/assets/recipes/youtube-search-videos.json +279 -0
  62. package/dist/v5/skill/browserpaw/assets/recipes/youtube-video-read.json +349 -0
  63. package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.md +7 -0
  64. package/dist/v5/skill/browserpaw/references/TROUBLESHOOTING.zh-CN.md +5 -0
  65. package/dist/v5/skill/browserpaw/references/browser-data.md +33 -0
  66. package/dist/v5/skill/browserpaw/references/commands.md +103 -0
  67. package/dist/v5/skill/browserpaw/references/debugging.md +32 -0
  68. package/dist/v5/skill/browserpaw/references/recipe-contract.md +47 -0
  69. package/package.json +67 -4
@@ -0,0 +1,1475 @@
1
+ var agentCursor = (function() {
2
+ //#region ../../node_modules/.pnpm/wxt@0.20.27_@types+node@22._f9a73202785fde064a3453eb6ac50c6c/node_modules/wxt/dist/utils/define-content-script.mjs
3
+ function defineContentScript(definition) {
4
+ return definition;
5
+ }
6
+ //#endregion
7
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/typeof.js
8
+ function _typeof(o) {
9
+ "@babel/helpers - typeof";
10
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
11
+ return typeof o;
12
+ } : function(o) {
13
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
14
+ }, _typeof(o);
15
+ }
16
+ //#endregion
17
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/toPrimitive.js
18
+ function toPrimitive(t, r) {
19
+ if ("object" != _typeof(t) || !t) return t;
20
+ var e = t[Symbol.toPrimitive];
21
+ if (void 0 !== e) {
22
+ var i = e.call(t, r || "default");
23
+ if ("object" != _typeof(i)) return i;
24
+ throw new TypeError("@@toPrimitive must return a primitive value.");
25
+ }
26
+ return ("string" === r ? String : Number)(t);
27
+ }
28
+ //#endregion
29
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/toPropertyKey.js
30
+ function toPropertyKey(t) {
31
+ var i = toPrimitive(t, "string");
32
+ return "symbol" == _typeof(i) ? i : i + "";
33
+ }
34
+ //#endregion
35
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/defineProperty.js
36
+ function _defineProperty(e, r, t) {
37
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
38
+ value: t,
39
+ enumerable: !0,
40
+ configurable: !0,
41
+ writable: !0
42
+ }) : e[r] = t, e;
43
+ }
44
+ //#endregion
45
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/objectSpread2.js
46
+ function ownKeys(e, r) {
47
+ var t = Object.keys(e);
48
+ if (Object.getOwnPropertySymbols) {
49
+ var o = Object.getOwnPropertySymbols(e);
50
+ r && (o = o.filter(function(r) {
51
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
52
+ })), t.push.apply(t, o);
53
+ }
54
+ return t;
55
+ }
56
+ function _objectSpread2(e) {
57
+ for (var r = 1; r < arguments.length; r++) {
58
+ var t = null != arguments[r] ? arguments[r] : {};
59
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
60
+ _defineProperty(e, r, t[r]);
61
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
62
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
63
+ });
64
+ }
65
+ return e;
66
+ }
67
+ //#endregion
68
+ //#region entrypoints/agent-cursor.content.ts
69
+ var agent_cursor_content_default = defineContentScript({
70
+ matches: ["<all_urls>"],
71
+ allFrames: false,
72
+ runAt: "document_start",
73
+ main() {
74
+ initAgentCursor();
75
+ }
76
+ });
77
+ var CURSOR_BASE_SCALE = .9;
78
+ var CURSOR_SIZE = 24;
79
+ var HALF_SIZE = CURSOR_SIZE / 2;
80
+ var ASSET_WIDTH = 23;
81
+ var ASSET_HEIGHT = 24;
82
+ var ASSET_OFFSET_X = 12;
83
+ var ASSET_OFFSET_Y = -2.5;
84
+ var ASSET_ROTATION_DEG = 44;
85
+ var GLOW_CSS_VAR = "--browser-agent-cursor-glow-color";
86
+ var GLOW_COLOR = "#339cff";
87
+ var GLOW_FILTER = `drop-shadow(0 2px 6px rgba(0, 0, 0, 0.32)) drop-shadow(0 0 3px color-mix(in srgb, var(${GLOW_CSS_VAR}) 40%, transparent))`;
88
+ var DT_STEP = 1 / 240;
89
+ var FRAME_DURATION = 1 / 60;
90
+ var SPRING_POS = {
91
+ dampingFraction: .92,
92
+ response: .11
93
+ };
94
+ var SPRING_ROT = {
95
+ dampingFraction: .9,
96
+ response: .08
97
+ };
98
+ var SPRING_STRETCH = {
99
+ dampingFraction: .85,
100
+ response: .2
101
+ };
102
+ var SPRING_VISIBILITY = {
103
+ dampingFraction: .86,
104
+ response: .42
105
+ };
106
+ var SPRING_SCOOT_AXIS = {
107
+ dampingFraction: .9,
108
+ response: .09
109
+ };
110
+ var SPRING_SCOOT_ROT = {
111
+ dampingFraction: .82,
112
+ response: .045
113
+ };
114
+ var SPRING_SCOOT_STRETCH = {
115
+ dampingFraction: .86,
116
+ response: .09
117
+ };
118
+ function createSpring(val, target, cfg) {
119
+ return {
120
+ value: val,
121
+ target,
122
+ velocity: 0,
123
+ force: 0,
124
+ dampingFraction: cfg.dampingFraction,
125
+ response: cfg.response,
126
+ scriptTime: 0,
127
+ simulationTime: 0
128
+ };
129
+ }
130
+ function resetSpring(s, val) {
131
+ s.value = val;
132
+ s.target = val;
133
+ s.velocity = 0;
134
+ s.force = 0;
135
+ s.scriptTime = 0;
136
+ s.simulationTime = 0;
137
+ }
138
+ function stepSpringSub(s, stiffness, damping) {
139
+ const halfDt = DT_STEP / 2;
140
+ const velMid = s.velocity + s.force * halfDt;
141
+ s.value += velMid * DT_STEP;
142
+ s.force = velMid * -damping + (s.target - s.value) * stiffness;
143
+ s.velocity = velMid + s.force * halfDt;
144
+ }
145
+ function isSpringSettled(s) {
146
+ const velSqr = s.velocity * s.velocity;
147
+ const forceSqr = s.force * s.force;
148
+ if (Math.max(velSqr, forceSqr) > .0036) return false;
149
+ const diff = s.target - s.value;
150
+ return Math.abs(diff) <= .005;
151
+ }
152
+ function stepSpring(s, dt) {
153
+ const resp = Math.max(.001, s.response);
154
+ const maxStiffness = 1 / (2 * DT_STEP * DT_STEP);
155
+ const stiffness = Math.min(Math.pow(Math.PI * 2, 2) / (resp * resp), maxStiffness);
156
+ const damping = Math.sqrt(stiffness) * 2 * s.dampingFraction;
157
+ s.scriptTime += Math.max(0, dt);
158
+ if (s.scriptTime - s.simulationTime > 1) s.simulationTime = s.scriptTime - FRAME_DURATION;
159
+ while (s.simulationTime < s.scriptTime) {
160
+ stepSpringSub(s, stiffness, damping);
161
+ s.simulationTime += DT_STEP;
162
+ }
163
+ if (isSpringSettled(s)) s.value = s.target;
164
+ }
165
+ function dist(a, b) {
166
+ const dx = b.x - a.x;
167
+ const dy = b.y - a.y;
168
+ return Math.sqrt(dx * dx + dy * dy);
169
+ }
170
+ function distToSegment(p1, p2, p) {
171
+ const dx = p2.x - p1.x;
172
+ const dy = p2.y - p1.y;
173
+ const l2 = dx * dx + dy * dy;
174
+ if (l2 === 0) return dist(p1, p);
175
+ const t = Math.max(0, Math.min(1, ((p.x - p1.x) * dx + (p.y - p1.y) * dy) / l2));
176
+ return dist(p, {
177
+ x: p1.x + t * dx,
178
+ y: p1.y + t * dy
179
+ });
180
+ }
181
+ function clamp(v, min, max) {
182
+ return Math.max(min, Math.min(max, v));
183
+ }
184
+ function normAngle(deg) {
185
+ const m = deg % 360;
186
+ return m < 0 ? m + 360 : m;
187
+ }
188
+ function angleDiff(from, to) {
189
+ let d = to - from;
190
+ while (d > 180) d -= 360;
191
+ while (d < -180) d += 360;
192
+ return d;
193
+ }
194
+ function setAngleTarget(s, targetDeg) {
195
+ s.target = s.value + angleDiff(s.value, targetDeg);
196
+ }
197
+ function cubicBezier(p0, p1, p2, p3, t) {
198
+ const it = 1 - t;
199
+ const c0 = it * it * it;
200
+ const c1 = 3 * it * it * t;
201
+ const c2 = 3 * it * t * t;
202
+ const c3 = t * t * t;
203
+ return {
204
+ x: p0.x * c0 + p1.x * c1 + p2.x * c2 + p3.x * c3,
205
+ y: p0.y * c0 + p1.y * c1 + p2.y * c2 + p3.y * c3
206
+ };
207
+ }
208
+ function cubicBezierTangent(p0, p1, p2, p3, t) {
209
+ const it = 1 - t;
210
+ return {
211
+ x: 3 * it * it * (p1.x - p0.x) + 6 * it * t * (p2.x - p1.x) + 3 * t * t * (p3.x - p2.x),
212
+ y: 3 * it * it * (p1.y - p0.y) + 6 * it * t * (p2.y - p1.y) + 3 * t * t * (p3.y - p2.y)
213
+ };
214
+ }
215
+ function evaluateBezierPath(path, t) {
216
+ const cl = clamp(t, 0, 1);
217
+ const segIndex = cl === 1 ? path.segments.length - 1 : Math.floor(cl * path.segments.length);
218
+ const seg = path.segments[segIndex] || path.segments[0];
219
+ const startPt = segIndex === 0 ? path.start : path.segments[segIndex - 1].end;
220
+ const localT = cl === 1 ? 1 : cl * path.segments.length - segIndex;
221
+ return {
222
+ point: cubicBezier(startPt, seg.control1, seg.control2, seg.end, localT),
223
+ tangent: cubicBezierTangent(startPt, seg.control1, seg.control2, seg.end, localT)
224
+ };
225
+ }
226
+ function tangentToDegrees(tangent) {
227
+ const len = Math.sqrt(tangent.x * tangent.x + tangent.y * tangent.y);
228
+ if (len < .001) return normAngle(-44);
229
+ return normAngle(Math.atan2(tangent.y / len, tangent.x / len) * (180 / Math.PI) + 90);
230
+ }
231
+ function buildArcCandidates(start, end, bounds) {
232
+ const d = dist(start, end);
233
+ const mid = {
234
+ x: (start.x + end.x) / 2,
235
+ y: (start.y + end.y) / 2
236
+ };
237
+ const normal = d > 0 ? {
238
+ x: -(end.y - start.y) / d,
239
+ y: (end.x - start.x) / d
240
+ } : {
241
+ x: 0,
242
+ y: -1
243
+ };
244
+ const naturalArcRatio = .18;
245
+ const maxArcForDist = Math.max(6, d * .28);
246
+ const minArc = Math.min(8, d * .2);
247
+ const arcHeight = clamp(d * naturalArcRatio, minArc, Math.min(160, maxArcForDist));
248
+ let arcPt = {
249
+ x: mid.x + normal.x * arcHeight,
250
+ y: mid.y + normal.y * arcHeight
251
+ };
252
+ const margin = 36;
253
+ if (arcPt.x < margin || arcPt.x > bounds.width - margin || arcPt.y < margin || arcPt.y > bounds.height - margin) {
254
+ const invertedPt = {
255
+ x: mid.x - normal.x * arcHeight,
256
+ y: mid.y - normal.y * arcHeight
257
+ };
258
+ if (invertedPt.x >= margin && invertedPt.x <= bounds.width - margin && invertedPt.y >= margin && invertedPt.y <= bounds.height - margin) arcPt = invertedPt;
259
+ else arcPt = {
260
+ x: clamp(arcPt.x, margin, bounds.width - margin),
261
+ y: clamp(arcPt.y, margin, bounds.height - margin)
262
+ };
263
+ }
264
+ return {
265
+ start,
266
+ startControl: {
267
+ x: start.x + (arcPt.x - start.x) * .5,
268
+ y: start.y + (arcPt.y - start.y) * .5
269
+ },
270
+ end,
271
+ endControl: {
272
+ x: end.x + (arcPt.x - end.x) * .5,
273
+ y: end.y + (arcPt.y - end.y) * .5
274
+ },
275
+ arc: arcPt,
276
+ arcIn: null,
277
+ arcOut: null,
278
+ segments: [{
279
+ control1: {
280
+ x: start.x + (arcPt.x - start.x) * .45,
281
+ y: start.y + (arcPt.y - start.y) * .45
282
+ },
283
+ control2: {
284
+ x: arcPt.x - (end.x - start.x) * .15,
285
+ y: arcPt.y - (end.y - start.y) * .15
286
+ },
287
+ end: arcPt
288
+ }, {
289
+ control1: {
290
+ x: arcPt.x + (end.x - start.x) * .15,
291
+ y: arcPt.y + (end.y - start.y) * .15
292
+ },
293
+ control2: {
294
+ x: end.x - (end.x - arcPt.x) * .45,
295
+ y: end.y - (end.y - arcPt.y) * .45
296
+ },
297
+ end
298
+ }]
299
+ };
300
+ }
301
+ function initCursorState(pt) {
302
+ return {
303
+ point: pt,
304
+ rotation: normAngle(-44),
305
+ scootAxisRotation: 0,
306
+ thinkStartedAt: null,
307
+ positionXSpring: createSpring(pt.x, pt.x, SPRING_POS),
308
+ positionYSpring: createSpring(pt.y, pt.y, SPRING_POS),
309
+ rotationSpring: createSpring(normAngle(-44), normAngle(-44), SPRING_ROT),
310
+ stretchSpring: createSpring(1, 1, SPRING_STRETCH),
311
+ visibilitySpring: createSpring(0, 0, SPRING_VISIBILITY),
312
+ scootAxisSpring: createSpring(0, 0, SPRING_SCOOT_AXIS),
313
+ scootRotationSpring: createSpring(0, 0, SPRING_SCOOT_ROT),
314
+ scootStretchSpring: createSpring(1, 1, SPRING_SCOOT_STRETCH),
315
+ motion: null
316
+ };
317
+ }
318
+ function initAgentCursor() {
319
+ if (window.top !== window.self) return;
320
+ const OVERLAY_ROOT_ID = "codex-agent-overlay-root";
321
+ if (document.getElementById(OVERLAY_ROOT_ID)) return;
322
+ const host = document.createElement("div");
323
+ host.id = OVERLAY_ROOT_ID;
324
+ host.dataset.browserpawAgentOverlayRoot = "true";
325
+ document.documentElement.appendChild(host);
326
+ const shadow = host.attachShadow({ mode: "closed" });
327
+ const style = document.createElement("style");
328
+ style.textContent = `
329
+ .codex-agent-overlay {
330
+ all: initial;
331
+ z-index: 2147483646;
332
+ pointer-events: none;
333
+ position: fixed;
334
+ inset: 0;
335
+ }
336
+ @media print {
337
+ .codex-agent-overlay {
338
+ display: none;
339
+ }
340
+ }
341
+ `;
342
+ shadow.appendChild(style);
343
+ const overlay = document.createElement("div");
344
+ overlay.className = "codex-agent-overlay";
345
+ overlay.setAttribute("aria-hidden", "true");
346
+ globalThis[Symbol.for("__browserpaw_agent_overlay__")] = overlay;
347
+ const cursorContainer = document.createElement("div");
348
+ cursorContainer.style.position = "absolute";
349
+ cursorContainer.style.width = `${CURSOR_SIZE}px`;
350
+ cursorContainer.style.height = `${CURSOR_SIZE}px`;
351
+ cursorContainer.style.left = "0";
352
+ cursorContainer.style.top = "0";
353
+ cursorContainer.style.transformOrigin = `${HALF_SIZE}px ${HALF_SIZE}px`;
354
+ cursorContainer.style.willChange = "transform, opacity, filter";
355
+ cursorContainer.style.opacity = "0";
356
+ cursorContainer.style.visibility = "hidden";
357
+ const offsetWrapper = document.createElement("div");
358
+ offsetWrapper.style.transform = `translate3d(${ASSET_OFFSET_X}px, ${ASSET_OFFSET_Y}px, 0)`;
359
+ const assetImg = document.createElement("img");
360
+ assetImg.alt = "";
361
+ assetImg.draggable = false;
362
+ assetImg.width = ASSET_WIDTH;
363
+ assetImg.height = ASSET_HEIGHT;
364
+ assetImg.src = chrome.runtime.getURL("images/cursor-chat.png");
365
+ assetImg.style.display = "block";
366
+ assetImg.style.setProperty(GLOW_CSS_VAR, GLOW_COLOR);
367
+ assetImg.style.filter = GLOW_FILTER;
368
+ assetImg.style.transform = `rotate(${ASSET_ROTATION_DEG}deg) scale(1)`;
369
+ assetImg.style.transformOrigin = "0 0";
370
+ offsetWrapper.appendChild(assetImg);
371
+ cursorContainer.appendChild(offsetWrapper);
372
+ overlay.appendChild(cursorContainer);
373
+ const clickRipple = document.createElement("div");
374
+ clickRipple.style.position = "absolute";
375
+ clickRipple.style.left = "0";
376
+ clickRipple.style.top = "0";
377
+ clickRipple.style.width = "32px";
378
+ clickRipple.style.height = "32px";
379
+ clickRipple.style.marginLeft = "-16px";
380
+ clickRipple.style.marginTop = "-16px";
381
+ clickRipple.style.borderRadius = "50%";
382
+ clickRipple.style.pointerEvents = "none";
383
+ clickRipple.style.border = "2.5px solid #339cff";
384
+ clickRipple.style.boxShadow = "0 0 10px #339cff, inset 0 0 6px #339cff";
385
+ clickRipple.style.transform = "scale(0)";
386
+ clickRipple.style.opacity = "0";
387
+ overlay.appendChild(clickRipple);
388
+ const actionTooltip = document.createElement("div");
389
+ actionTooltip.className = "codex-agent-tooltip";
390
+ actionTooltip.style.position = "absolute";
391
+ actionTooltip.style.left = "0";
392
+ actionTooltip.style.top = "0";
393
+ actionTooltip.style.pointerEvents = "none";
394
+ actionTooltip.style.userSelect = "none";
395
+ actionTooltip.style.zIndex = "2147483647";
396
+ actionTooltip.style.display = "flex";
397
+ actionTooltip.style.alignItems = "center";
398
+ actionTooltip.style.gap = "6px";
399
+ actionTooltip.style.padding = "5px 12px";
400
+ actionTooltip.style.background = "rgba(24, 24, 27, 0.94)";
401
+ actionTooltip.style.backdropFilter = "blur(12px)";
402
+ actionTooltip.style.setProperty("-webkit-backdrop-filter", "blur(12px)");
403
+ actionTooltip.style.border = "1px solid rgba(255, 255, 255, 0.14)";
404
+ actionTooltip.style.borderRadius = "8px";
405
+ actionTooltip.style.boxShadow = "0 4px 16px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.2)";
406
+ actionTooltip.style.color = "#ffffff";
407
+ actionTooltip.style.fontFamily = "-apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif";
408
+ actionTooltip.style.fontSize = "12px";
409
+ actionTooltip.style.fontWeight = "500";
410
+ actionTooltip.style.lineHeight = "16px";
411
+ actionTooltip.style.whiteSpace = "nowrap";
412
+ actionTooltip.style.opacity = "0";
413
+ actionTooltip.style.transform = "translate3d(0, 0, 0) scale(0.92)";
414
+ actionTooltip.style.transformOrigin = "center center";
415
+ actionTooltip.style.transition = "opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1)";
416
+ actionTooltip.style.willChange = "transform, opacity";
417
+ const tooltipText = document.createElement("span");
418
+ tooltipText.style.overflow = "hidden";
419
+ tooltipText.style.textOverflow = "ellipsis";
420
+ tooltipText.style.maxWidth = "340px";
421
+ actionTooltip.appendChild(tooltipText);
422
+ overlay.appendChild(actionTooltip);
423
+ let tooltipHideTimer = null;
424
+ let typewriterTimer = null;
425
+ let caretRemoveTimer = null;
426
+ let currentNoteText = "";
427
+ let tooltipVisible = false;
428
+ const updateTooltipPosition = (scale = 1) => {
429
+ if (!tooltipVisible) return;
430
+ const tooltipWidth = actionTooltip.offsetWidth || 140;
431
+ const tooltipHeight = actionTooltip.offsetHeight || 28;
432
+ let tx = Math.round(cursorState.point.x - tooltipWidth / 2 + 10);
433
+ tx = clamp(tx, 12, window.innerWidth - tooltipWidth - 12);
434
+ let ty = Math.round(cursorState.point.y + 24);
435
+ if (ty + tooltipHeight > window.innerHeight - 10) ty = Math.round(cursorState.point.y - tooltipHeight - 12);
436
+ ty = clamp(ty, 8, window.innerHeight - tooltipHeight - 8);
437
+ actionTooltip.style.transform = `translate3d(${tx}px, ${ty}px, 0) scale(${scale})`;
438
+ };
439
+ const showActionNote = (noteText, autoHideMs = 2800) => {
440
+ if (cursorMode === "off") {
441
+ hideActionNote();
442
+ return;
443
+ }
444
+ const text = (noteText || "").trim();
445
+ if (!text) {
446
+ hideActionNote();
447
+ return;
448
+ }
449
+ if (tooltipHideTimer) {
450
+ clearTimeout(tooltipHideTimer);
451
+ tooltipHideTimer = null;
452
+ }
453
+ tooltipVisible = true;
454
+ agentActiveUntil = Math.max(agentActiveUntil, Date.now() + Math.max(3e3, autoHideMs));
455
+ actionTooltip.style.opacity = "1";
456
+ if (text !== currentNoteText) {
457
+ currentNoteText = text;
458
+ if (typewriterTimer) {
459
+ clearInterval(typewriterTimer);
460
+ typewriterTimer = null;
461
+ }
462
+ if (caretRemoveTimer) {
463
+ clearTimeout(caretRemoveTimer);
464
+ caretRemoveTimer = null;
465
+ }
466
+ if (text.length <= 40) {
467
+ let charIndex = 0;
468
+ tooltipText.textContent = "";
469
+ const caret = document.createElement("span");
470
+ caret.className = "codex-agent-caret";
471
+ caret.textContent = "|";
472
+ caret.style.display = "inline-block";
473
+ caret.style.marginLeft = "1px";
474
+ caret.style.opacity = "0.9";
475
+ caret.style.fontWeight = "300";
476
+ caret.style.color = "#93c5fd";
477
+ typewriterTimer = window.setInterval(() => {
478
+ charIndex++;
479
+ if (charIndex <= text.length) {
480
+ tooltipText.textContent = text.slice(0, charIndex);
481
+ tooltipText.appendChild(caret);
482
+ updateTooltipPosition(1);
483
+ } else {
484
+ if (typewriterTimer) {
485
+ clearInterval(typewriterTimer);
486
+ typewriterTimer = null;
487
+ }
488
+ if (caretRemoveTimer) clearTimeout(caretRemoveTimer);
489
+ caretRemoveTimer = window.setTimeout(() => {
490
+ caretRemoveTimer = null;
491
+ if (caret.parentNode) caret.remove();
492
+ updateTooltipPosition(1);
493
+ }, 500);
494
+ }
495
+ }, 20);
496
+ } else tooltipText.textContent = text;
497
+ }
498
+ updateTooltipPosition(1);
499
+ if (autoHideMs > 0) tooltipHideTimer = window.setTimeout(() => {
500
+ hideActionNote();
501
+ }, autoHideMs);
502
+ };
503
+ const hideActionNote = () => {
504
+ if (tooltipHideTimer) {
505
+ clearTimeout(tooltipHideTimer);
506
+ tooltipHideTimer = null;
507
+ }
508
+ if (typewriterTimer) {
509
+ clearInterval(typewriterTimer);
510
+ typewriterTimer = null;
511
+ }
512
+ if (caretRemoveTimer) {
513
+ clearTimeout(caretRemoveTimer);
514
+ caretRemoveTimer = null;
515
+ }
516
+ currentNoteText = "";
517
+ actionTooltip.style.opacity = "0";
518
+ updateTooltipPosition(.92);
519
+ tooltipVisible = false;
520
+ };
521
+ const resetAutoIdleTimer = () => {
522
+ if (cursorMode !== "auto") return;
523
+ if (autoIdleTimer) clearTimeout(autoIdleTimer);
524
+ autoIdleTimer = window.setTimeout(() => {
525
+ if (!cursorState.motion) {
526
+ hideCursor();
527
+ hideActionNote();
528
+ }
529
+ }, 3500);
530
+ };
531
+ const triggerClickAnimation = (clickX, clickY, note) => {
532
+ if (cursorMode === "off") return;
533
+ const cx = typeof clickX === "number" ? clickX : cursorState.point.x;
534
+ const cy = typeof clickY === "number" ? clickY : cursorState.point.y;
535
+ const currentDist = dist(cursorState.point, {
536
+ x: cx,
537
+ y: cy
538
+ });
539
+ agentActiveUntil = Math.max(agentActiveUntil, Date.now() + 2500);
540
+ cursorState.visibilitySpring.value = 1;
541
+ cursorState.visibilitySpring.target = 1;
542
+ if (currentDist > 2) {
543
+ cursorState.positionXSpring.target = cx;
544
+ cursorState.positionYSpring.target = cy;
545
+ } else {
546
+ cursorState.point = {
547
+ x: cx,
548
+ y: cy
549
+ };
550
+ cursorState.positionXSpring.target = cx;
551
+ cursorState.positionYSpring.target = cy;
552
+ }
553
+ renderCursor();
554
+ startAnimationLoop();
555
+ if (note) showActionNote(note);
556
+ const ripple = clickRipple.cloneNode(true);
557
+ ripple.style.left = `${cx}px`;
558
+ ripple.style.top = `${cy}px`;
559
+ ripple.style.transform = "scale(0.2)";
560
+ ripple.style.opacity = "0.95";
561
+ ripple.style.transition = "none";
562
+ overlay.appendChild(ripple);
563
+ ripple.offsetWidth;
564
+ ripple.style.transition = "transform 0.35s cubic-bezier(0, 0, 0.2, 1), opacity 0.35s ease-out";
565
+ ripple.style.transform = "scale(1.8)";
566
+ ripple.style.opacity = "0";
567
+ setTimeout(() => {
568
+ ripple.remove();
569
+ }, 380);
570
+ assetImg.style.transition = "transform 0.08s ease-out";
571
+ assetImg.style.transform = `rotate(${ASSET_ROTATION_DEG}deg) scale(0.84)`;
572
+ setTimeout(() => {
573
+ assetImg.style.transition = "transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1)";
574
+ assetImg.style.transform = `rotate(${ASSET_ROTATION_DEG}deg) scale(1)`;
575
+ }, 85);
576
+ if (cursorMode === "auto") resetAutoIdleTimer();
577
+ };
578
+ shadow.appendChild(overlay);
579
+ let hasInteracted = false;
580
+ const cursorState = initCursorState({
581
+ x: Math.round(window.innerWidth * .5),
582
+ y: Math.round(window.innerHeight * .5)
583
+ });
584
+ let isRunningAnimation = false;
585
+ let lastFrameTime = performance.now();
586
+ let pendingMoveSequence = null;
587
+ let userTakeoverDetected = false;
588
+ let agentActiveUntil = 0;
589
+ let autoIdleTimer = null;
590
+ let cursorMode = "always";
591
+ const hideCursorImmediate = () => {
592
+ cursorState.visibilitySpring.value = 0;
593
+ cursorState.visibilitySpring.target = 0;
594
+ cursorState.thinkStartedAt = null;
595
+ cursorContainer.style.opacity = "0";
596
+ cursorContainer.style.visibility = "hidden";
597
+ hideActionNote();
598
+ };
599
+ try {
600
+ chrome.storage.local.get("agentCursorMode", (data) => {
601
+ if (data === null || data === void 0 ? void 0 : data.agentCursorMode) {
602
+ cursorMode = data.agentCursorMode;
603
+ if (cursorMode === "off") hideCursorImmediate();
604
+ }
605
+ });
606
+ chrome.storage.onChanged.addListener((changes, area) => {
607
+ if (area === "local" && changes.agentCursorMode) {
608
+ cursorMode = changes.agentCursorMode.newValue || "always";
609
+ if (cursorMode === "off") hideCursorImmediate();
610
+ else if (cursorMode === "always" && hasInteracted) {
611
+ cursorState.visibilitySpring.target = 1;
612
+ startAnimationLoop();
613
+ }
614
+ }
615
+ });
616
+ } catch (_unused) {}
617
+ const triggerArrivalCallback = (seq) => {
618
+ if (seq !== null) chrome.runtime.sendMessage({
619
+ type: "AGENT_CURSOR_ARRIVED",
620
+ moveSequence: seq
621
+ }).catch(() => {});
622
+ };
623
+ const renderCursor = () => {
624
+ const now = performance.now();
625
+ let rotation = cursorState.rotation;
626
+ if (cursorState.thinkStartedAt !== null) {
627
+ const elapsedSec = (now - cursorState.thinkStartedAt) / 1e3;
628
+ if (elapsedSec < 1.41) {
629
+ const envelope = Math.sin(Math.min(1, elapsedSec / 1.41) * Math.PI);
630
+ const wave = Math.sin(elapsedSec / .66 * Math.PI * 2) * envelope;
631
+ rotation += wave * 12.5;
632
+ } else cursorState.thinkStartedAt = null;
633
+ }
634
+ const vis = clamp(cursorState.visibilitySpring.value, 0, 1);
635
+ const scaleVis = .4 + .6 * vis;
636
+ const blurPx = 5 * (1 - vis);
637
+ const stretch = cursorState.stretchSpring.value;
638
+ const scootStretch = clamp(cursorState.scootStretchSpring.value, 0, 1);
639
+ const scootRot = cursorState.scootRotationSpring.value;
640
+ const axisRot = cursorState.scootAxisRotation;
641
+ const transforms = [`translate3d(${Math.round((cursorState.point.x - HALF_SIZE) * 10) / 10}px, ${Math.round((cursorState.point.y - HALF_SIZE) * 10) / 10}px, 0)`];
642
+ if (Math.abs(axisRot) > .001 || Math.abs(scootStretch - 1) > .001) transforms.push(`rotate(${axisRot}deg)`, `scale(1, ${scootStretch})`, `rotate(${-axisRot}deg)`);
643
+ transforms.push(`rotate(${normAngle(rotation + scootRot)}deg)`, `scale(${stretch * scaleVis * CURSOR_BASE_SCALE}, ${scaleVis * CURSOR_BASE_SCALE})`);
644
+ cursorContainer.style.transform = transforms.join(" ");
645
+ if (vis <= .001) {
646
+ cursorContainer.style.opacity = "0";
647
+ cursorContainer.style.visibility = "hidden";
648
+ return;
649
+ }
650
+ cursorContainer.style.visibility = "visible";
651
+ cursorContainer.style.opacity = `${vis}`;
652
+ cursorContainer.style.filter = `blur(${Math.round(blurPx * 10) / 10}px)`;
653
+ if (tooltipVisible) updateTooltipPosition(1);
654
+ };
655
+ const tick = (time) => {
656
+ isRunningAnimation = false;
657
+ const dt = Math.min(.1, Math.max(FRAME_DURATION, (time - lastFrameTime) / 1e3));
658
+ lastFrameTime = time;
659
+ stepSpring(cursorState.visibilitySpring, dt);
660
+ stepSpring(cursorState.stretchSpring, dt);
661
+ stepSpring(cursorState.scootStretchSpring, dt);
662
+ stepSpring(cursorState.scootRotationSpring, dt);
663
+ const motion = cursorState.motion;
664
+ let arrivedThisFrame = false;
665
+ if ((motion === null || motion === void 0 ? void 0 : motion.mode) === "scoot") {
666
+ stepSpring(motion.progressSpring, dt);
667
+ cursorState.positionXSpring.target = motion.end.x;
668
+ cursorState.positionYSpring.target = motion.end.y;
669
+ setAngleTarget(cursorState.scootAxisSpring, motion.axisRotation);
670
+ setAngleTarget(cursorState.rotationSpring, normAngle(-44));
671
+ const prg = motion.progressSpring.value;
672
+ const sinArc = Math.sin(clamp(prg, 0, 1) * Math.PI);
673
+ cursorState.stretchSpring.target = 1;
674
+ cursorState.scootStretchSpring.target = 1 - sinArc * .15;
675
+ cursorState.scootRotationSpring.target = motion.rotationTarget * sinArc;
676
+ stepSpring(cursorState.positionXSpring, dt);
677
+ stepSpring(cursorState.positionYSpring, dt);
678
+ stepSpring(cursorState.rotationSpring, dt);
679
+ stepSpring(cursorState.scootAxisSpring, dt);
680
+ cursorState.point = {
681
+ x: cursorState.positionXSpring.value,
682
+ y: cursorState.positionYSpring.value
683
+ };
684
+ cursorState.rotation = cursorState.rotationSpring.value;
685
+ cursorState.scootAxisRotation = cursorState.scootAxisSpring.value;
686
+ if (prg >= .99 && dist(cursorState.point, motion.end) <= 1.5) {
687
+ cursorState.point = motion.end;
688
+ resetSpring(cursorState.positionXSpring, motion.end.x);
689
+ resetSpring(cursorState.positionYSpring, motion.end.y);
690
+ cursorState.motion = null;
691
+ cursorState.thinkStartedAt = time;
692
+ arrivedThisFrame = true;
693
+ } else if (prg >= .98) {
694
+ cursorState.positionXSpring.target = motion.end.x;
695
+ cursorState.positionYSpring.target = motion.end.y;
696
+ }
697
+ } else if ((motion === null || motion === void 0 ? void 0 : motion.mode) === "bezier") {
698
+ cursorState.scootStretchSpring.target = 1;
699
+ cursorState.scootRotationSpring.target = 0;
700
+ stepSpring(motion.progressSpring, dt);
701
+ const prg = clamp(motion.progressSpring.value, 0, 1);
702
+ const evalPt = evaluateBezierPath(motion.path, prg);
703
+ const tangentDeg = tangentToDegrees(evalPt.tangent);
704
+ cursorState.positionXSpring.target = evalPt.point.x;
705
+ cursorState.positionYSpring.target = evalPt.point.y;
706
+ setAngleTarget(cursorState.rotationSpring, tangentDeg);
707
+ setAngleTarget(cursorState.scootAxisSpring, 0);
708
+ const prevPt = _objectSpread2({}, cursorState.point);
709
+ stepSpring(cursorState.positionXSpring, dt);
710
+ stepSpring(cursorState.positionYSpring, dt);
711
+ stepSpring(cursorState.rotationSpring, dt);
712
+ stepSpring(cursorState.scootAxisSpring, dt);
713
+ cursorState.point = {
714
+ x: cursorState.positionXSpring.value,
715
+ y: cursorState.positionYSpring.value
716
+ };
717
+ cursorState.rotation = cursorState.rotationSpring.value;
718
+ cursorState.scootAxisRotation = cursorState.scootAxisSpring.value;
719
+ const speed = dist(prevPt, cursorState.point) / dt;
720
+ cursorState.stretchSpring.target = clamp(1 - speed / 5500, .65, 1);
721
+ if (prg >= .985 && dist(cursorState.point, motion.path.end) <= 2.5) {
722
+ cursorState.point = motion.path.end;
723
+ resetSpring(cursorState.positionXSpring, motion.path.end.x);
724
+ resetSpring(cursorState.positionYSpring, motion.path.end.y);
725
+ resetSpring(cursorState.stretchSpring, 1);
726
+ cursorState.motion = null;
727
+ cursorState.thinkStartedAt = time;
728
+ arrivedThisFrame = true;
729
+ } else if (prg >= .98) {
730
+ cursorState.positionXSpring.target = motion.path.end.x;
731
+ cursorState.positionYSpring.target = motion.path.end.y;
732
+ }
733
+ } else {
734
+ stepSpring(cursorState.positionXSpring, dt);
735
+ stepSpring(cursorState.positionYSpring, dt);
736
+ stepSpring(cursorState.rotationSpring, dt);
737
+ cursorState.point = {
738
+ x: cursorState.positionXSpring.value,
739
+ y: cursorState.positionYSpring.value
740
+ };
741
+ cursorState.rotation = cursorState.rotationSpring.value;
742
+ }
743
+ renderCursor();
744
+ if (arrivedThisFrame) {
745
+ const seq = pendingMoveSequence;
746
+ pendingMoveSequence = null;
747
+ triggerArrivalCallback(seq);
748
+ resetAutoIdleTimer();
749
+ }
750
+ const isMoving = cursorState.motion !== null;
751
+ const isBreathing = cursorState.thinkStartedAt !== null;
752
+ const isSpringing = !isSpringSettled(cursorState.positionXSpring) || !isSpringSettled(cursorState.positionYSpring) || !isSpringSettled(cursorState.rotationSpring) || !isSpringSettled(cursorState.stretchSpring) || !isSpringSettled(cursorState.visibilitySpring);
753
+ if (isMoving || isBreathing || isSpringing) startAnimationLoop();
754
+ };
755
+ const startAnimationLoop = () => {
756
+ if (!isRunningAnimation) {
757
+ isRunningAnimation = true;
758
+ requestAnimationFrame(tick);
759
+ }
760
+ };
761
+ const moveTo = (targetX, targetY, moveSequence, immediate = false, actionNote, fromX, fromY) => {
762
+ if (cursorMode === "off") {
763
+ triggerArrivalCallback(moveSequence);
764
+ return;
765
+ }
766
+ const now = Date.now();
767
+ if (userTakeoverDetected && now < userInteractingUntil) {
768
+ if (pendingMoveSequence !== null && pendingMoveSequence !== moveSequence) {
769
+ triggerArrivalCallback(pendingMoveSequence);
770
+ pendingMoveSequence = null;
771
+ }
772
+ setTimeout(() => triggerArrivalCallback(moveSequence), 80);
773
+ return;
774
+ }
775
+ userTakeoverDetected = false;
776
+ if (pendingMoveSequence !== null && pendingMoveSequence !== moveSequence) triggerArrivalCallback(pendingMoveSequence);
777
+ pendingMoveSequence = moveSequence;
778
+ agentActiveUntil = Math.max(agentActiveUntil, now + 3500);
779
+ cursorState.visibilitySpring.target = 1;
780
+ cursorState.thinkStartedAt = null;
781
+ if (autoIdleTimer) {
782
+ clearTimeout(autoIdleTimer);
783
+ autoIdleTimer = null;
784
+ }
785
+ if (actionNote) showActionNote(actionNote);
786
+ const target = {
787
+ x: clamp(targetX, 0, window.innerWidth),
788
+ y: clamp(targetY, 0, window.innerHeight)
789
+ };
790
+ if (!hasInteracted) {
791
+ hasInteracted = true;
792
+ if (typeof fromX === "number" && typeof fromY === "number") {
793
+ cursorState.point = {
794
+ x: clamp(fromX, 0, window.innerWidth),
795
+ y: clamp(fromY, 0, window.innerHeight)
796
+ };
797
+ resetSpring(cursorState.positionXSpring, cursorState.point.x);
798
+ resetSpring(cursorState.positionYSpring, cursorState.point.y);
799
+ cursorState.visibilitySpring.value = 1;
800
+ cursorState.visibilitySpring.target = 1;
801
+ } else {
802
+ const entryX = target.x > window.innerWidth / 2 ? target.x - 70 : target.x + 70;
803
+ const entryY = Math.min(window.innerHeight - 24, target.y + 55);
804
+ cursorState.point = {
805
+ x: clamp(entryX, 0, window.innerWidth),
806
+ y: clamp(entryY, 0, window.innerHeight)
807
+ };
808
+ resetSpring(cursorState.positionXSpring, cursorState.point.x);
809
+ resetSpring(cursorState.positionYSpring, cursorState.point.y);
810
+ cursorState.visibilitySpring.value = 0;
811
+ cursorState.visibilitySpring.target = 1;
812
+ }
813
+ }
814
+ if (dist(cursorState.point, target) < 1.5) {
815
+ cursorState.point = target;
816
+ resetSpring(cursorState.positionXSpring, target.x);
817
+ resetSpring(cursorState.positionYSpring, target.y);
818
+ resetSpring(cursorState.stretchSpring, 1);
819
+ cursorState.motion = null;
820
+ renderCursor();
821
+ pendingMoveSequence = null;
822
+ triggerArrivalCallback(moveSequence);
823
+ return;
824
+ }
825
+ const path = buildArcCandidates(cursorState.point, target, {
826
+ width: window.innerWidth,
827
+ height: window.innerHeight
828
+ });
829
+ cursorState.motion = {
830
+ mode: "bezier",
831
+ path,
832
+ progressSpring: createSpring(0, 1, immediate ? {
833
+ dampingFraction: .95,
834
+ response: .055
835
+ } : {
836
+ dampingFraction: .88,
837
+ response: .13
838
+ })
839
+ };
840
+ startAnimationLoop();
841
+ };
842
+ const hideCursor = () => {
843
+ if (cursorMode === "always") return;
844
+ cursorState.visibilitySpring.target = 0;
845
+ cursorState.thinkStartedAt = null;
846
+ startAnimationLoop();
847
+ };
848
+ let lastUserMousePos = null;
849
+ let userMoveAccumulatedDist = 0;
850
+ let userTakeoverTimer = null;
851
+ let userInteractingUntil = 0;
852
+ const onUserMouseMove = (e) => {
853
+ if (cursorMode === "always" || !e.isTrusted) return;
854
+ if (Date.now() < agentActiveUntil || cursorState.motion !== null) {
855
+ const dToCursor = dist(cursorState.point, {
856
+ x: e.clientX,
857
+ y: e.clientY
858
+ });
859
+ const targetPt = cursorState.motion ? cursorState.motion.mode === "scoot" ? cursorState.motion.end : cursorState.motion.path.end : cursorState.point;
860
+ const dToTarget = dist(targetPt, {
861
+ x: e.clientX,
862
+ y: e.clientY
863
+ });
864
+ if (dToCursor < 60 || dToTarget < 60) {
865
+ lastUserMousePos = {
866
+ x: e.clientX,
867
+ y: e.clientY
868
+ };
869
+ return;
870
+ }
871
+ if (cursorState.motion) {
872
+ if (distToSegment(cursorState.point, targetPt, {
873
+ x: e.clientX,
874
+ y: e.clientY
875
+ }) < 60) {
876
+ lastUserMousePos = {
877
+ x: e.clientX,
878
+ y: e.clientY
879
+ };
880
+ return;
881
+ }
882
+ }
883
+ }
884
+ if (!lastUserMousePos) {
885
+ lastUserMousePos = {
886
+ x: e.clientX,
887
+ y: e.clientY
888
+ };
889
+ return;
890
+ }
891
+ const d = dist(lastUserMousePos, {
892
+ x: e.clientX,
893
+ y: e.clientY
894
+ });
895
+ lastUserMousePos = {
896
+ x: e.clientX,
897
+ y: e.clientY
898
+ };
899
+ userMoveAccumulatedDist += d;
900
+ if (userMoveAccumulatedDist > 18) {
901
+ userTakeoverDetected = true;
902
+ userInteractingUntil = Date.now() + 1500;
903
+ hideCursor();
904
+ hideActionNote();
905
+ }
906
+ if (userTakeoverTimer) clearTimeout(userTakeoverTimer);
907
+ userTakeoverTimer = window.setTimeout(() => {
908
+ userMoveAccumulatedDist = 0;
909
+ lastUserMousePos = null;
910
+ if (Date.now() >= userInteractingUntil) userTakeoverDetected = false;
911
+ }, 1500);
912
+ };
913
+ const onUserInteractionDirect = (e) => {
914
+ if (cursorMode === "always" || !e.isTrusted) return;
915
+ if (Date.now() < agentActiveUntil) {
916
+ if (e.type === "mousedown") {
917
+ const me = e;
918
+ const d = dist(cursorState.point, {
919
+ x: me.clientX,
920
+ y: me.clientY
921
+ });
922
+ if (dist(cursorState.motion ? cursorState.motion.mode === "scoot" ? cursorState.motion.end : cursorState.motion.path.end : cursorState.point, {
923
+ x: me.clientX,
924
+ y: me.clientY
925
+ }) < 50) return;
926
+ if (d < 50) return;
927
+ } else if (e.type === "wheel") {
928
+ const we = e;
929
+ if (dist(cursorState.point, {
930
+ x: we.clientX,
931
+ y: we.clientY
932
+ }) < 120) return;
933
+ } else if (e.type === "keydown") return;
934
+ }
935
+ userTakeoverDetected = true;
936
+ userInteractingUntil = Date.now() + 1500;
937
+ hideCursor();
938
+ hideActionNote();
939
+ if (userTakeoverTimer) clearTimeout(userTakeoverTimer);
940
+ userTakeoverTimer = window.setTimeout(() => {
941
+ if (Date.now() >= userInteractingUntil) userTakeoverDetected = false;
942
+ }, 1500);
943
+ };
944
+ window.addEventListener("mousemove", onUserMouseMove, { passive: true });
945
+ window.addEventListener("mousedown", onUserInteractionDirect, { passive: true });
946
+ window.addEventListener("keydown", onUserInteractionDirect, { passive: true });
947
+ window.addEventListener("wheel", onUserInteractionDirect, { passive: true });
948
+ window.addEventListener("scroll", () => {
949
+ if (tooltipVisible) updateTooltipPosition(1);
950
+ }, { passive: true });
951
+ window.addEventListener("resize", () => {
952
+ if (tooltipVisible) updateTooltipPosition(1);
953
+ }, { passive: true });
954
+ let activeInterventionCleanup = null;
955
+ chrome.runtime.onMessage.addListener((message, _sender, sendResponse) => {
956
+ if (!message || typeof message !== "object") return false;
957
+ if (message.type === "HUMAN_INTERVENTION_REQUEST") {
958
+ if (activeInterventionCleanup) {
959
+ try {
960
+ activeInterventionCleanup("preempted");
961
+ } catch (_unused2) {}
962
+ activeInterventionCleanup = null;
963
+ }
964
+ const { reason } = message;
965
+ moveTo(window.innerWidth - 60, 40, null, false);
966
+ const existingBanner = shadow.getElementById("codex-human-intervention-banner");
967
+ if (existingBanner) existingBanner.remove();
968
+ const banner = document.createElement("div");
969
+ banner.id = "codex-human-intervention-banner";
970
+ banner.style.cssText = [
971
+ "position: fixed",
972
+ "top: 24px",
973
+ "left: 50%",
974
+ "transform: translateX(-50%)",
975
+ "z-index: 2147483647",
976
+ "background: rgba(15, 23, 42, 0.92)",
977
+ "backdrop-filter: blur(16px)",
978
+ "-webkit-backdrop-filter: blur(16px)",
979
+ "border: 1px solid rgba(51, 156, 255, 0.5)",
980
+ "border-radius: 9999px",
981
+ "box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 24px rgba(51, 156, 255, 0.35)",
982
+ "color: #ffffff",
983
+ "padding: 10px 22px",
984
+ "font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif",
985
+ "font-size: 14px",
986
+ "line-height: 20px",
987
+ "display: flex",
988
+ "align-items: center",
989
+ "gap: 16px",
990
+ "pointer-events: auto",
991
+ "user-select: none",
992
+ "animation: codexSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1)"
993
+ ].join("; ");
994
+ const style = document.createElement("style");
995
+ style.textContent = `
996
+ @keyframes codexSlideIn {
997
+ from { opacity: 0; transform: translate(-50%, -20px) scale(0.96); }
998
+ to { opacity: 1; transform: translate(-50%, 0) scale(1); }
999
+ }
1000
+ @keyframes codexPulse {
1001
+ 0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(51, 156, 255, 0.7); }
1002
+ 70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(51, 156, 255, 0); }
1003
+ 100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(51, 156, 255, 0); }
1004
+ }
1005
+ `;
1006
+ banner.appendChild(style);
1007
+ const pulseDot = document.createElement("div");
1008
+ pulseDot.style.cssText = "width: 10px; height: 10px; border-radius: 50%; background: #339cff; animation: codexPulse 1.8s infinite; flex-shrink: 0;";
1009
+ banner.appendChild(pulseDot);
1010
+ const textContainer = document.createElement("div");
1011
+ textContainer.style.cssText = "font-weight: 500; max-width: 480px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;";
1012
+ const labelSpan = document.createElement("span");
1013
+ labelSpan.style.cssText = "color: #93c5fd; font-weight: 600;";
1014
+ labelSpan.textContent = "Human Assistance Required: ";
1015
+ textContainer.appendChild(labelSpan);
1016
+ textContainer.appendChild(document.createTextNode(reason));
1017
+ banner.appendChild(textContainer);
1018
+ const continueBtn = document.createElement("button");
1019
+ continueBtn.id = "codex-btn-continue";
1020
+ continueBtn.style.cssText = [
1021
+ "background: #339cff",
1022
+ "color: #ffffff",
1023
+ "border: none",
1024
+ "padding: 6px 14px",
1025
+ "border-radius: 9999px",
1026
+ "font-size: 12px",
1027
+ "font-weight: 600",
1028
+ "cursor: pointer",
1029
+ "transition: all 0.2s",
1030
+ "outline: none"
1031
+ ].join("; ");
1032
+ continueBtn.textContent = "Complete & Resume (Enter)";
1033
+ banner.appendChild(continueBtn);
1034
+ shadow.appendChild(banner);
1035
+ let responded = false;
1036
+ const respondOnce = (payload) => {
1037
+ if (responded) return;
1038
+ responded = true;
1039
+ try {
1040
+ sendResponse(payload);
1041
+ } catch (_unused3) {}
1042
+ };
1043
+ const cleanup = (cancelReason) => {
1044
+ continueBtn.removeEventListener("click", onDone);
1045
+ window.removeEventListener("keydown", onKey);
1046
+ if (activeInterventionCleanup === cleanup) activeInterventionCleanup = null;
1047
+ if (banner && banner.parentNode) {
1048
+ if (cancelReason === "preempted") banner.remove();
1049
+ else {
1050
+ banner.style.transition = "opacity 0.25s, transform 0.25s";
1051
+ banner.style.opacity = "0";
1052
+ banner.style.transform = "translate(-50%, -15px) scale(0.95)";
1053
+ setTimeout(() => banner === null || banner === void 0 ? void 0 : banner.remove(), 260);
1054
+ }
1055
+ }
1056
+ if (cancelReason) respondOnce({
1057
+ ok: false,
1058
+ cancelled: true,
1059
+ reason: cancelReason
1060
+ });
1061
+ };
1062
+ activeInterventionCleanup = cleanup;
1063
+ const onDone = () => {
1064
+ cleanup();
1065
+ respondOnce({
1066
+ ok: true,
1067
+ action: "completed_by_user"
1068
+ });
1069
+ };
1070
+ const onKey = (e) => {
1071
+ if (e.key === "Enter") {
1072
+ var _e$composedPath, _target$tagName;
1073
+ const target = ((_e$composedPath = e.composedPath) === null || _e$composedPath === void 0 ? void 0 : _e$composedPath.call(e)[0]) || e.target;
1074
+ const tagName = target === null || target === void 0 || (_target$tagName = target.tagName) === null || _target$tagName === void 0 ? void 0 : _target$tagName.toLowerCase();
1075
+ if (tagName === "input" || tagName === "textarea" || tagName === "select" || Boolean(target === null || target === void 0 ? void 0 : target.isContentEditable)) return;
1076
+ e.preventDefault();
1077
+ onDone();
1078
+ }
1079
+ };
1080
+ continueBtn.addEventListener("click", onDone);
1081
+ window.addEventListener("keydown", onKey);
1082
+ return true;
1083
+ }
1084
+ if (message.type === "HUMAN_INTERVENTION_CANCEL") {
1085
+ if (activeInterventionCleanup) {
1086
+ try {
1087
+ activeInterventionCleanup("cancelled");
1088
+ } catch (_unused4) {}
1089
+ activeInterventionCleanup = null;
1090
+ } else {
1091
+ const banner = shadow.getElementById("codex-human-intervention-banner");
1092
+ if (banner) banner.remove();
1093
+ }
1094
+ sendResponse({ ok: true });
1095
+ return false;
1096
+ }
1097
+ if (message.type === "AGENT_CURSOR_MOVE") {
1098
+ const { x, y, moveSequence, immediate, actionNote, fromX, fromY } = message;
1099
+ moveTo(x, y, typeof moveSequence === "number" ? moveSequence : null, immediate === true, actionNote, fromX, fromY);
1100
+ sendResponse({ ok: true });
1101
+ return false;
1102
+ }
1103
+ if (message.type === "AGENT_CURSOR_CLICK") {
1104
+ triggerClickAnimation(message.x, message.y, message.actionNote);
1105
+ sendResponse({ ok: true });
1106
+ return false;
1107
+ }
1108
+ if (message.type === "AGENT_CURSOR_SET_NOTE") {
1109
+ if (message.note) {
1110
+ var _message$durationMs;
1111
+ showActionNote(message.note, (_message$durationMs = message.durationMs) !== null && _message$durationMs !== void 0 ? _message$durationMs : 2600);
1112
+ } else hideActionNote();
1113
+ sendResponse({ ok: true });
1114
+ return false;
1115
+ }
1116
+ if (message.type === "AGENT_CURSOR_HIDE") {
1117
+ if (message.force || cursorMode !== "always") {
1118
+ hideCursor();
1119
+ hideActionNote();
1120
+ }
1121
+ sendResponse({ ok: true });
1122
+ return false;
1123
+ }
1124
+ if (message.type === "AGENT_CURSOR_STATE") {
1125
+ var _message$state, _message$state2;
1126
+ const cursor = (_message$state = message.state) === null || _message$state === void 0 ? void 0 : _message$state.cursor;
1127
+ if (cursor && typeof cursor.x === "number" && typeof cursor.y === "number") {
1128
+ var _cursor$moveSequence;
1129
+ moveTo(cursor.x, cursor.y, (_cursor$moveSequence = cursor.moveSequence) !== null && _cursor$moveSequence !== void 0 ? _cursor$moveSequence : null, cursor.animateMovement === false);
1130
+ } else if (((_message$state2 = message.state) === null || _message$state2 === void 0 ? void 0 : _message$state2.isVisible) === false) hideCursor();
1131
+ sendResponse({ ok: true });
1132
+ return false;
1133
+ }
1134
+ return false;
1135
+ });
1136
+ renderCursor();
1137
+ }
1138
+ //#endregion
1139
+ //#region ../../node_modules/.pnpm/wxt@0.20.27_@types+node@22._f9a73202785fde064a3453eb6ac50c6c/node_modules/wxt/dist/utils/internal/logger.mjs
1140
+ /** Wrapper around `console` with a "[wxt]" prefix */
1141
+ var logger$1 = {
1142
+ debug: (...args) => ([...args], void 0),
1143
+ log: (...args) => ([...args], void 0),
1144
+ warn: (...args) => ([...args], void 0),
1145
+ error: (...args) => ([...args], void 0)
1146
+ };
1147
+ //#endregion
1148
+ //#region ../../node_modules/.pnpm/@wxt-dev+browser@0.2.8/node_modules/@wxt-dev/browser/src/index.mjs
1149
+ var _globalThis$browser;
1150
+ //#endregion
1151
+ //#region ../../node_modules/.pnpm/wxt@0.20.27_@types+node@22._f9a73202785fde064a3453eb6ac50c6c/node_modules/wxt/dist/browser.mjs
1152
+ /**
1153
+ * Contains the `browser` export which you should use to access the extension
1154
+ * APIs in your project:
1155
+ *
1156
+ * ```ts
1157
+ * import { browser } from 'wxt/browser';
1158
+ *
1159
+ * browser.runtime.onInstalled.addListener(() => {
1160
+ * // ...
1161
+ * });
1162
+ * ```
1163
+ *
1164
+ * @module wxt/browser
1165
+ */
1166
+ var browser = ((_globalThis$browser = globalThis.browser) === null || _globalThis$browser === void 0 || (_globalThis$browser = _globalThis$browser.runtime) === null || _globalThis$browser === void 0 ? void 0 : _globalThis$browser.id) ? globalThis.browser : globalThis.chrome;
1167
+ //#endregion
1168
+ //#region ../../node_modules/.pnpm/wxt@0.20.27_@types+node@22._f9a73202785fde064a3453eb6ac50c6c/node_modules/wxt/dist/utils/internal/custom-events.mjs
1169
+ var _WxtLocationChangeEvent = class WxtLocationChangeEvent extends Event {
1170
+ constructor(newUrl, oldUrl) {
1171
+ super(WxtLocationChangeEvent.EVENT_NAME, {});
1172
+ this.newUrl = newUrl;
1173
+ this.oldUrl = oldUrl;
1174
+ }
1175
+ };
1176
+ var WxtLocationChangeEvent = (_defineProperty(_WxtLocationChangeEvent, "EVENT_NAME", getUniqueEventName("wxt:locationchange")), _WxtLocationChangeEvent);
1177
+ /**
1178
+ * Returns an event name unique to the extension and content script that's
1179
+ * running.
1180
+ */
1181
+ function getUniqueEventName(eventName) {
1182
+ var _browser$runtime;
1183
+ return `${browser === null || browser === void 0 || (_browser$runtime = browser.runtime) === null || _browser$runtime === void 0 ? void 0 : _browser$runtime.id}:agent-cursor:${eventName}`;
1184
+ }
1185
+ //#endregion
1186
+ //#region ../../node_modules/.pnpm/wxt@0.20.27_@types+node@22._f9a73202785fde064a3453eb6ac50c6c/node_modules/wxt/dist/utils/internal/location-watcher.mjs
1187
+ var _globalThis$navigatio;
1188
+ var supportsNavigationApi = typeof ((_globalThis$navigatio = globalThis.navigation) === null || _globalThis$navigatio === void 0 ? void 0 : _globalThis$navigatio.addEventListener) === "function";
1189
+ /**
1190
+ * Create a util that watches for URL changes, dispatching the custom event when
1191
+ * detected. Stops watching when content script is invalidated. Uses Navigation
1192
+ * API when available, otherwise falls back to polling.
1193
+ */
1194
+ function createLocationWatcher(ctx) {
1195
+ let lastUrl;
1196
+ let watching = false;
1197
+ return { run() {
1198
+ if (watching) return;
1199
+ watching = true;
1200
+ lastUrl = new URL(location.href);
1201
+ if (supportsNavigationApi) globalThis.navigation.addEventListener("navigate", (event) => {
1202
+ const newUrl = new URL(event.destination.url);
1203
+ if (newUrl.href === lastUrl.href) return;
1204
+ window.dispatchEvent(new WxtLocationChangeEvent(newUrl, lastUrl));
1205
+ lastUrl = newUrl;
1206
+ }, { signal: ctx.signal });
1207
+ else ctx.setInterval(() => {
1208
+ const newUrl = new URL(location.href);
1209
+ if (newUrl.href !== lastUrl.href) {
1210
+ window.dispatchEvent(new WxtLocationChangeEvent(newUrl, lastUrl));
1211
+ lastUrl = newUrl;
1212
+ }
1213
+ }, 1e3);
1214
+ } };
1215
+ }
1216
+ //#endregion
1217
+ //#region ../../node_modules/.pnpm/wxt@0.20.27_@types+node@22._f9a73202785fde064a3453eb6ac50c6c/node_modules/wxt/dist/utils/content-script-context.mjs
1218
+ var _ContentScriptContext = class ContentScriptContext {
1219
+ constructor(contentScriptName, options) {
1220
+ _defineProperty(this, "id", void 0);
1221
+ _defineProperty(this, "abortController", void 0);
1222
+ _defineProperty(this, "locationWatcher", createLocationWatcher(this));
1223
+ this.contentScriptName = contentScriptName;
1224
+ this.options = options;
1225
+ this.id = Math.random().toString(36).slice(2);
1226
+ this.abortController = new AbortController();
1227
+ this.stopOldScripts();
1228
+ this.listenForNewerScripts();
1229
+ }
1230
+ get signal() {
1231
+ return this.abortController.signal;
1232
+ }
1233
+ abort(reason) {
1234
+ return this.abortController.abort(reason);
1235
+ }
1236
+ get isInvalid() {
1237
+ var _browser$runtime;
1238
+ if (((_browser$runtime = browser.runtime) === null || _browser$runtime === void 0 ? void 0 : _browser$runtime.id) == null) this.notifyInvalidated();
1239
+ return this.signal.aborted;
1240
+ }
1241
+ get isValid() {
1242
+ return !this.isInvalid;
1243
+ }
1244
+ /**
1245
+ * Add a listener that is called when the content script's context is
1246
+ * invalidated.
1247
+ *
1248
+ * @example
1249
+ * browser.runtime.onMessage.addListener(cb);
1250
+ * const removeInvalidatedListener = ctx.onInvalidated(() => {
1251
+ * browser.runtime.onMessage.removeListener(cb);
1252
+ * });
1253
+ * // ...
1254
+ * removeInvalidatedListener();
1255
+ *
1256
+ * @returns A function to remove the listener.
1257
+ */
1258
+ onInvalidated(cb) {
1259
+ this.signal.addEventListener("abort", cb);
1260
+ return () => this.signal.removeEventListener("abort", cb);
1261
+ }
1262
+ /**
1263
+ * Return a promise that never resolves. Useful if you have an async function
1264
+ * that shouldn't run after the context is expired.
1265
+ *
1266
+ * @example
1267
+ * const getValueFromStorage = async () => {
1268
+ * if (ctx.isInvalid) return ctx.block();
1269
+ *
1270
+ * // ...
1271
+ * };
1272
+ */
1273
+ block() {
1274
+ return new Promise(() => {});
1275
+ }
1276
+ /**
1277
+ * Wrapper around `window.setInterval` that automatically clears the interval
1278
+ * when invalidated.
1279
+ *
1280
+ * Intervals can be cleared by calling the normal `clearInterval` function.
1281
+ */
1282
+ setInterval(handler, timeout) {
1283
+ const id = setInterval(() => {
1284
+ if (this.isValid) handler();
1285
+ }, timeout);
1286
+ this.onInvalidated(() => clearInterval(id));
1287
+ return id;
1288
+ }
1289
+ /**
1290
+ * Wrapper around `window.setTimeout` that automatically clears the interval
1291
+ * when invalidated.
1292
+ *
1293
+ * Timeouts can be cleared by calling the normal `setTimeout` function.
1294
+ */
1295
+ setTimeout(handler, timeout) {
1296
+ const id = setTimeout(() => {
1297
+ if (this.isValid) handler();
1298
+ }, timeout);
1299
+ this.onInvalidated(() => clearTimeout(id));
1300
+ return id;
1301
+ }
1302
+ /**
1303
+ * Wrapper around `window.requestAnimationFrame` that automatically cancels
1304
+ * the request when invalidated.
1305
+ *
1306
+ * Callbacks can be canceled by calling the normal `cancelAnimationFrame`
1307
+ * function.
1308
+ */
1309
+ requestAnimationFrame(callback) {
1310
+ const id = requestAnimationFrame((...args) => {
1311
+ if (this.isValid) callback(...args);
1312
+ });
1313
+ this.onInvalidated(() => cancelAnimationFrame(id));
1314
+ return id;
1315
+ }
1316
+ /**
1317
+ * Wrapper around `window.requestIdleCallback` that automatically cancels the
1318
+ * request when invalidated.
1319
+ *
1320
+ * Callbacks can be canceled by calling the normal `cancelIdleCallback`
1321
+ * function.
1322
+ */
1323
+ requestIdleCallback(callback, options) {
1324
+ const id = requestIdleCallback((...args) => {
1325
+ if (!this.signal.aborted) callback(...args);
1326
+ }, options);
1327
+ this.onInvalidated(() => cancelIdleCallback(id));
1328
+ return id;
1329
+ }
1330
+ addEventListener(target, type, handler, options) {
1331
+ var _target$addEventListe;
1332
+ if (type === "wxt:locationchange") {
1333
+ if (this.isValid) this.locationWatcher.run();
1334
+ }
1335
+ (_target$addEventListe = target.addEventListener) === null || _target$addEventListe === void 0 || _target$addEventListe.call(target, type.startsWith("wxt:") ? getUniqueEventName(type) : type, handler, _objectSpread2(_objectSpread2({}, options), {}, { signal: this.signal }));
1336
+ }
1337
+ /**
1338
+ * @internal
1339
+ * Abort the abort controller and execute all `onInvalidated` listeners.
1340
+ */
1341
+ notifyInvalidated() {
1342
+ this.abort("Content script context invalidated");
1343
+ logger$1.debug(`Content script "${this.contentScriptName}" context invalidated`);
1344
+ }
1345
+ stopOldScripts() {
1346
+ var _this$options;
1347
+ document.dispatchEvent(new CustomEvent(ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE, { detail: {
1348
+ contentScriptName: this.contentScriptName,
1349
+ messageId: this.id
1350
+ } }));
1351
+ if (!((_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.noScriptStartedPostMessage)) window.postMessage({
1352
+ type: ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE,
1353
+ contentScriptName: this.contentScriptName,
1354
+ messageId: this.id
1355
+ }, "*");
1356
+ }
1357
+ verifyScriptStartedEvent(event) {
1358
+ var _event$detail, _event$detail2;
1359
+ const isSameContentScript = ((_event$detail = event.detail) === null || _event$detail === void 0 ? void 0 : _event$detail.contentScriptName) === this.contentScriptName;
1360
+ const isFromSelf = ((_event$detail2 = event.detail) === null || _event$detail2 === void 0 ? void 0 : _event$detail2.messageId) === this.id;
1361
+ return isSameContentScript && !isFromSelf;
1362
+ }
1363
+ listenForNewerScripts() {
1364
+ const cb = (event) => {
1365
+ if (!(event instanceof CustomEvent) || !this.verifyScriptStartedEvent(event)) return;
1366
+ this.notifyInvalidated();
1367
+ };
1368
+ document.addEventListener(ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE, cb);
1369
+ this.onInvalidated(() => document.removeEventListener(ContentScriptContext.SCRIPT_STARTED_MESSAGE_TYPE, cb));
1370
+ }
1371
+ };
1372
+ /**
1373
+ * Implements
1374
+ * [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
1375
+ * Used to detect and stop content script code when the script is invalidated.
1376
+ *
1377
+ * It also provides several utilities like `ctx.setTimeout` and
1378
+ * `ctx.setInterval` that should be used in content scripts instead of
1379
+ * `window.setTimeout` or `window.setInterval`.
1380
+ *
1381
+ * To create context for testing, you can use the class's constructor:
1382
+ *
1383
+ * ```ts
1384
+ * import { ContentScriptContext } from 'wxt/utils/content-scripts-context';
1385
+ *
1386
+ * test('storage listener should be removed when context is invalidated', () => {
1387
+ * const ctx = new ContentScriptContext('test');
1388
+ * const item = storage.defineItem('local:count', { defaultValue: 0 });
1389
+ * const watcher = vi.fn();
1390
+ *
1391
+ * const unwatch = item.watch(watcher);
1392
+ * ctx.onInvalidated(unwatch); // Listen for invalidate here
1393
+ *
1394
+ * await item.setValue(1);
1395
+ * expect(watcher).toBeCalledTimes(1);
1396
+ * expect(watcher).toBeCalledWith(1, 0);
1397
+ *
1398
+ * ctx.notifyInvalidated(); // Use this function to invalidate the context
1399
+ * await item.setValue(2);
1400
+ * expect(watcher).toBeCalledTimes(1);
1401
+ * });
1402
+ * ```
1403
+ */
1404
+ var ContentScriptContext = (_defineProperty(_ContentScriptContext, "SCRIPT_STARTED_MESSAGE_TYPE", getUniqueEventName("wxt:content-script-started")), _ContentScriptContext);
1405
+ //#endregion
1406
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/objectWithoutPropertiesLoose.js
1407
+ function _objectWithoutPropertiesLoose(r, e) {
1408
+ if (null == r) return {};
1409
+ var t = {};
1410
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
1411
+ if (e.includes(n)) continue;
1412
+ t[n] = r[n];
1413
+ }
1414
+ return t;
1415
+ }
1416
+ //#endregion
1417
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/objectWithoutProperties.js
1418
+ function _objectWithoutProperties(e, t) {
1419
+ if (null == e) return {};
1420
+ var o, r, i = _objectWithoutPropertiesLoose(e, t);
1421
+ if (Object.getOwnPropertySymbols) {
1422
+ var s = Object.getOwnPropertySymbols(e);
1423
+ for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
1424
+ }
1425
+ return i;
1426
+ }
1427
+ //#endregion
1428
+ //#region \0@oxc-project+runtime@0.148.0/helpers/esm/asyncToGenerator.js
1429
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
1430
+ try {
1431
+ var i = n[a](c), u = i.value;
1432
+ } catch (n) {
1433
+ e(n);
1434
+ return;
1435
+ }
1436
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
1437
+ }
1438
+ function _asyncToGenerator(n) {
1439
+ return function() {
1440
+ var t = this, e = arguments;
1441
+ return new Promise(function(r, o) {
1442
+ var a = n.apply(t, e);
1443
+ function _next(n) {
1444
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
1445
+ }
1446
+ function _throw(n) {
1447
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
1448
+ }
1449
+ _next(void 0);
1450
+ });
1451
+ };
1452
+ }
1453
+ //#endregion
1454
+ //#region \0virtual:wxt-content-script-isolated-world-entrypoint?D:/workspace/mcp-chrome-master/mcp-chrome-master/app/chrome-extension/entrypoints/agent-cursor.content.ts
1455
+ var _excluded = ["main"];
1456
+ /** Wrapper around `console` with a "[wxt]" prefix */
1457
+ var logger = {
1458
+ debug: (...args) => ([...args], void 0),
1459
+ log: (...args) => ([...args], void 0),
1460
+ warn: (...args) => ([...args], void 0),
1461
+ error: (...args) => ([...args], void 0)
1462
+ };
1463
+ //#endregion
1464
+ return _asyncToGenerator(function* () {
1465
+ try {
1466
+ const { main } = agent_cursor_content_default;
1467
+ return yield main(new ContentScriptContext("agent-cursor", _objectWithoutProperties(agent_cursor_content_default, _excluded)));
1468
+ } catch (err) {
1469
+ logger.error(`The content script "agent-cursor" crashed on startup!`, err);
1470
+ throw err;
1471
+ }
1472
+ })();
1473
+ })();
1474
+
1475
+ agentCursor;