@developerz.ai/ui-debugger-mcp 1.3.0 → 1.4.0

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 (107) hide show
  1. package/README.md +28 -0
  2. package/dist/adapters/android/adb.js +3 -1
  3. package/dist/adapters/android/adb.js.map +1 -1
  4. package/dist/adapters/android/android-adapter.js +24 -14
  5. package/dist/adapters/android/android-adapter.js.map +1 -1
  6. package/dist/adapters/android/commands.d.ts +7 -4
  7. package/dist/adapters/android/commands.js +11 -6
  8. package/dist/adapters/android/commands.js.map +1 -1
  9. package/dist/adapters/browser/browser-adapter.d.ts +4 -50
  10. package/dist/adapters/browser/browser-adapter.js +55 -223
  11. package/dist/adapters/browser/browser-adapter.js.map +1 -1
  12. package/dist/adapters/browser/cdp.d.ts +12 -42
  13. package/dist/adapters/browser/cdp.js +122 -261
  14. package/dist/adapters/browser/cdp.js.map +1 -1
  15. package/dist/adapters/browser/geometry.d.ts +97 -0
  16. package/dist/adapters/browser/geometry.js +158 -0
  17. package/dist/adapters/browser/geometry.js.map +1 -0
  18. package/dist/adapters/browser/launch.d.ts +42 -2
  19. package/dist/adapters/browser/launch.js +77 -2
  20. package/dist/adapters/browser/launch.js.map +1 -1
  21. package/dist/adapters/browser/locate.d.ts +44 -0
  22. package/dist/adapters/browser/locate.js +93 -0
  23. package/dist/adapters/browser/locate.js.map +1 -0
  24. package/dist/adapters/browser/log-filters.d.ts +25 -0
  25. package/dist/adapters/browser/log-filters.js +149 -0
  26. package/dist/adapters/browser/log-filters.js.map +1 -0
  27. package/dist/adapters/browser/log-format.d.ts +52 -0
  28. package/dist/adapters/browser/log-format.js +131 -0
  29. package/dist/adapters/browser/log-format.js.map +1 -0
  30. package/dist/adapters/contract.d.ts +22 -2
  31. package/dist/adapters/desktop/atspi.d.ts +7 -0
  32. package/dist/adapters/desktop/atspi.js +3 -0
  33. package/dist/adapters/desktop/atspi.js.map +1 -1
  34. package/dist/adapters/desktop/desktop-adapter.d.ts +8 -1
  35. package/dist/adapters/desktop/desktop-adapter.js +38 -20
  36. package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
  37. package/dist/adapters/desktop/input.d.ts +8 -1
  38. package/dist/adapters/desktop/input.js +12 -3
  39. package/dist/adapters/desktop/input.js.map +1 -1
  40. package/dist/adapters/desktop/proc.d.ts +13 -2
  41. package/dist/adapters/desktop/proc.js +42 -2
  42. package/dist/adapters/desktop/proc.js.map +1 -1
  43. package/dist/adapters/factory.js +5 -1
  44. package/dist/adapters/factory.js.map +1 -1
  45. package/dist/agent/belt/act.d.ts +3 -2
  46. package/dist/agent/belt/act.js +51 -7
  47. package/dist/agent/belt/act.js.map +1 -1
  48. package/dist/agent/belt/look.d.ts +5 -8
  49. package/dist/agent/belt/look.js +47 -8
  50. package/dist/agent/belt/look.js.map +1 -1
  51. package/dist/agent/belt/observe.d.ts +28 -2
  52. package/dist/agent/belt/observe.js +102 -27
  53. package/dist/agent/belt/observe.js.map +1 -1
  54. package/dist/agent/capabilities.d.ts +9 -0
  55. package/dist/agent/capabilities.js +10 -1
  56. package/dist/agent/capabilities.js.map +1 -1
  57. package/dist/agent/loop.d.ts +11 -2
  58. package/dist/agent/loop.js +55 -6
  59. package/dist/agent/loop.js.map +1 -1
  60. package/dist/agent/prompts/android-addendum.d.ts +1 -1
  61. package/dist/agent/prompts/android-addendum.js +20 -5
  62. package/dist/agent/prompts/android-addendum.js.map +1 -1
  63. package/dist/agent/prompts/compose.d.ts +8 -0
  64. package/dist/agent/prompts/compose.js +15 -2
  65. package/dist/agent/prompts/compose.js.map +1 -1
  66. package/dist/agent/prompts/debug-agent.js +12 -0
  67. package/dist/agent/prompts/debug-agent.js.map +1 -1
  68. package/dist/agent/prompts/desktop-addendum.d.ts +1 -1
  69. package/dist/agent/prompts/desktop-addendum.js +18 -5
  70. package/dist/agent/prompts/desktop-addendum.js.map +1 -1
  71. package/dist/agent/prompts/web-addendum.d.ts +1 -1
  72. package/dist/agent/prompts/web-addendum.js +0 -10
  73. package/dist/agent/prompts/web-addendum.js.map +1 -1
  74. package/dist/config/fingerprint.d.ts +6 -0
  75. package/dist/config/fingerprint.js +16 -4
  76. package/dist/config/fingerprint.js.map +1 -1
  77. package/dist/config/schema.d.ts +10 -4
  78. package/dist/config/schema.js +21 -5
  79. package/dist/config/schema.js.map +1 -1
  80. package/dist/index.d.ts +1 -1
  81. package/dist/index.js +1 -1
  82. package/dist/main.js +11 -13
  83. package/dist/main.js.map +1 -1
  84. package/dist/services/debug-service.d.ts +2 -1
  85. package/dist/services/debug-service.js +82 -29
  86. package/dist/services/debug-service.js.map +1 -1
  87. package/dist/services/replay.d.ts +14 -3
  88. package/dist/services/replay.js +57 -10
  89. package/dist/services/replay.js.map +1 -1
  90. package/dist/services/session-builder.js +30 -5
  91. package/dist/services/session-builder.js.map +1 -1
  92. package/dist/services/shutdown.d.ts +37 -0
  93. package/dist/services/shutdown.js +51 -0
  94. package/dist/services/shutdown.js.map +1 -0
  95. package/dist/session/findings-store.d.ts +6 -2
  96. package/dist/session/findings-store.js +39 -6
  97. package/dist/session/findings-store.js.map +1 -1
  98. package/dist/session/session.d.ts +4 -2
  99. package/dist/session/session.js +7 -2
  100. package/dist/session/session.js.map +1 -1
  101. package/dist/session/state-file.d.ts +8 -2
  102. package/dist/session/state-file.js +8 -2
  103. package/dist/session/state-file.js.map +1 -1
  104. package/dist/session/workspace.d.ts +2 -1
  105. package/dist/session/workspace.js +28 -3
  106. package/dist/session/workspace.js.map +1 -1
  107. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../src/agent/prompts/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE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BAAmB,EAAE,MAAM,mBAAmB,CAAC;AAKxD,2CAA2C;AAC3C,MAAM,cAAc,GAA+B;IACjD,GAAG,EAAE,mBAAmB;IACxB,OAAO,EAAE,uBAAuB;IAChC,OAAO,EAAE,uBAAuB;CACjC,CAAC;AA0BF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuB;IACzD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC;IAE/D,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAExC,MAAM,cAAc,GAAG,OAAO;QAC5B,CAAC,CAAC;;;EAGJ,OAAO;;;;;;;CAOR;QACG,CAAC,CAAC,EAAE,CAAC;IAEP,MAAM,YAAY,GAAG;;;EAGrB,KAAK,CAAC,IAAI,EAAE;CACb,CAAC;IAEA,MAAM,eAAe,GACnB,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC;QAC7B,CAAC,CAAC;;;;;;EAMN,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;CACpD;QACK,CAAC,CAAC,EAAE,CAAC;IAET,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,CAAC;SACzF,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;SACvC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvB,CAAC"}
@@ -81,6 +81,18 @@ Never screenshot for information you can read from the tree or logs.
81
81
  behavior to all of them. If there are more than ~5, test the first, the last and
82
82
  one in the middle, and say in your report that you sampled rather than swept.${mode.extraRule}
83
83
 
84
+ ## Typing APPENDS — say so when you mean to replace
85
+
86
+ \`act({action:"type"})\` types into the field on top of whatever it already holds —
87
+ on every target (web, desktop, android). Re-typing a field you have used before
88
+ yields \`old textnew text\`, and that doubled value is YOUR bug, not the app's.
89
+
90
+ Pass \`clear: true\` to replace the contents instead:
91
+ \`act({action:"type", target:"...", text:"...", clear:true})\`
92
+
93
+ Use \`clear\` whenever the field may be non-empty: a retry, a second item through
94
+ the same form, or any field you have not just read as empty.
95
+
84
96
  ## Budget discipline — an unreported run produces NOTHING
85
97
 
86
98
  You have a limited number of steps. If you spend them all without calling
@@ -1 +1 @@
1
- {"version":3,"file":"debug-agent.js","sourceRoot":"","sources":["../../../src/agent/prompts/debug-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH,+FAA+F;AAC/F,MAAM,WAAW,GAAa;IAC5B,IAAI,EAAE,4FAA4F;IAClG,IAAI,EAAE,yFAAyF;IAC/F,IAAI,EAAE,8BAA8B;IACpC,iFAAiF;IACjF,iFAAiF;IACjF,SAAS,EAAE;;;6CAGgC;CAC5C,CAAC;AAEF,sFAAsF;AACtF,MAAM,cAAc,GAAa;IAC/B,IAAI,EAAE,yHAAyH;IAC/H,IAAI,EAAE,6FAA6F;IACnG,kFAAkF;IAClF,IAAI,EAAE,+EAA+E;IACrF,SAAS,EAAE,EAAE;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAiB;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC;IAErD,OAAO;;;EAGP,IAAI,CAAC,IAAI;;;;;;EAMT,IAAI,CAAC,IAAI;;;;;;;;;;;KAWN,IAAI,CAAC,IAAI;;;;;;;;;;;;;;;;;;;iFAmBmE,IAAI,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4G9F,CAAC;AACF,CAAC"}
1
+ {"version":3,"file":"debug-agent.js","sourceRoot":"","sources":["../../../src/agent/prompts/debug-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAcH,+FAA+F;AAC/F,MAAM,WAAW,GAAa;IAC5B,IAAI,EAAE,4FAA4F;IAClG,IAAI,EAAE,yFAAyF;IAC/F,IAAI,EAAE,8BAA8B;IACpC,iFAAiF;IACjF,iFAAiF;IACjF,SAAS,EAAE;;;6CAGgC;CAC5C,CAAC;AAEF,sFAAsF;AACtF,MAAM,cAAc,GAAa;IAC/B,IAAI,EAAE,yHAAyH;IAC/H,IAAI,EAAE,6FAA6F;IACnG,kFAAkF;IAClF,IAAI,EAAE,+EAA+E;IACrF,SAAS,EAAE,EAAE;CACd,CAAC;AAEF;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,QAAiB;IAChD,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC;IAErD,OAAO;;;EAGP,IAAI,CAAC,IAAI;;;;;;EAMT,IAAI,CAAC,IAAI;;;;;;;;;;;KAWN,IAAI,CAAC,IAAI;;;;;;;;;;;;;;;;;;;iFAmBmE,IAAI,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAwH9F,CAAC;AACF,CAAC"}
@@ -7,4 +7,4 @@
7
7
  *
8
8
  * Provider-agnostic — no vendor tricks; any competent model drives the same loop.
9
9
  */
10
- export declare const DESKTOP_ADDENDUM_PROMPT = "## Desktop target \u2014 AT-SPI + X11 reach\n\nYou are driving a native Linux application, already launched for you (managed).\nYou read it through the **AT-SPI2 accessibility tree** (over D-Bus), drive it with\n**xdotool** (X11/XWayland synthetic input), and capture frames with **scrot/grim**.\nThere is no DOM, no JavaScript context, and **no console or network channel**.\n\n### Channels and when to reach for each\n\n| Channel | What it gives you | Use via |\n|---------------|-------------------|---------|\n| a11y tree | element roles, names, on-screen bounds, enabled state | `observe({kind:\"tree\"})` |\n| screenshot | the current frame as PNG (evidence + vision) | `observe({kind:\"screenshot\"})`, `look` |\n\n`observe({kind:\"console\"})` and `observe({kind:\"network\"})` are **unsupported** on\ndesktop and error out \u2014 native apps expose no such streams. Never call them; judge\nbehaviour from the a11y tree and the pixels instead.\n\n### The app is already up \u2014 don't navigate to a URL\n\nThe window is launched and focused before your first step. There is no address bar.\nOnly use `act({action:\"navigate\", target:\"<window title>\"})` to re-focus a specific\nwindow by title when several are open; normally you skip it and act directly.\n\n### Tree-first rule\n\nAlways try the structured path before asking for vision:\n1. `observe({kind:\"tree\"})` \u2014 read element roles, names, bounds, enabled state.\n2. If an element is missing, try scrolling (`act({action:\"scroll\"})`) or waiting\n (`act({action:\"wait\", target:\"<role/name>\"})`), then re-observe.\n3. The a11y tree is often thinner than a DOM \u2014 many custom widgets expose little.\n When the tree gives you no answer, call `look` for pixels sooner than you would\n on web, and use the screenshot to judge layout, spacing, and visual polish.\n\n### Waiting \u2014 node queries only\n\n`act({action:\"wait\"})` polls the a11y tree for a `target` to appear. There is no\n`networkIdle` on desktop (no network channel) \u2014 waiting on it errors. Wait on a\nvisible element instead, e.g. a button or a heading you expect to render.\n\n### Selectors \u2014 use the node's `target`, don't invent one\n\nActionable nodes from `observe({kind:\"tree\"})` carry a ready-to-use `target` string\nbuilt from their a11y role + name (e.g. `role=button[name=\"Save\" i]`). When a node\nhas a `target`, COPY it verbatim into `act({action, target})`. Do NOT hand-craft a\nselector. If a node is unnamed, pass its visible text as `target`, or scope the read\nwith `within`/`filters` and act on what comes back.\n\n### Findings \u2014 functional + visual\n\nRecord functional bugs (a click that does nothing, a disabled control that should be\nlive, a wrong value) AND visual/UX feedback (misaligned, clipped, low-contrast,\ncramped). Attach the screenshot path as `evidence`. With no console/network to mine,\nthe a11y tree and what `look` reports back are your only signals \u2014 lean on both.\n";
10
+ export declare const DESKTOP_ADDENDUM_PROMPT = "## Desktop target \u2014 AT-SPI + X11 reach\n\nYou are driving a native Linux application, already launched for you (managed).\nYou read it through the **AT-SPI2 accessibility tree** (over D-Bus), drive it with\n**xdotool** (X11/XWayland synthetic input), and capture frames with **scrot/grim**.\nThere is no DOM, no JavaScript context, and **no console or network channel**.\n\n### Channels and when to reach for each\n\n| Channel | What it gives you | Use via |\n|---------------|-------------------|---------|\n| a11y tree | element roles, names, on-screen bounds, enabled state | `observe({kind:\"tree\"})` |\n| screenshot | the frame SAVED as evidence \u2014 you get a file path back, not pixels | `observe({kind:\"screenshot\"})` |\n| eyes | an actual visual judgment of the current frame | `look` |\n\n`observe({kind:\"console\"})` and `observe({kind:\"network\"})` are **unsupported** on\ndesktop and error out \u2014 native apps expose no such streams. Never call them; judge\nbehaviour from the a11y tree and the pixels instead.\n\n`observe({kind:\"tabs\"})` and `act({action:\"switch_tab\"})` are **unsupported** on\ndesktop and error out too \u2014 a native window has no tabs. Never call them; switch\nwindows with `act({action:\"navigate\", target:\"<window title>\"})` instead.\n\n### The app is already up \u2014 don't navigate to a URL\n\nThe window is launched and focused before your first step. There is no address bar.\nOnly use `act({action:\"navigate\", target:\"<window title>\"})` to re-focus a specific\nwindow by title when several are open; normally you skip it and act directly.\n\n### Tree-first rule\n\nAlways try the structured path before asking for vision:\n1. `observe({kind:\"tree\"})` \u2014 read element roles, names, bounds, enabled state.\n2. If an element is missing, try scrolling (`act({action:\"scroll\"})`) or waiting\n (`act({action:\"wait\", target:\"<role/name>\"})`), then re-observe.\n3. The a11y tree is often thinner than a DOM \u2014 many custom widgets expose little.\n When the tree gives you no answer, call `look` for pixels sooner than you would\n on web, and use the screenshot to judge layout, spacing, and visual polish.\n\n### Waiting \u2014 node queries only\n\n`act({action:\"wait\"})` polls the a11y tree for a `target` to appear. There is no\n`networkIdle` on desktop (no network channel) \u2014 waiting on it errors. Wait on a\nvisible element instead, e.g. a button or a heading you expect to render.\n\n### Selectors \u2014 use the node's `target`, don't invent one\n\nActionable nodes from `observe({kind:\"tree\"})` carry a ready-to-use `target` string\nbuilt from their a11y role + name \u2014 `button \"Save\"`. When a node has a `target`,\nCOPY it verbatim into `act({action, target})`.\n\nDesktop targets take exactly two forms, and NOTHING else:\n- `role \"name\"` \u2014 e.g. `button \"Save\"`, `text \"Email\"` (role must match exactly,\n name is a case-insensitive substring).\n- a plain name substring \u2014 e.g. `Save`.\n\nWeb selector syntax does NOT work here: `role=button[name=\"Save\" i]`, `text=Save`,\nCSS and `>> nth=` are all read as literal text, match nothing, and cost you the step.\nIf a node is unnamed, or repeats and so carries no `target`, scope the read with\n`within`/`filters` and act on what comes back.\n\n### Findings \u2014 functional + visual\n\nRecord functional bugs (a click that does nothing, a disabled control that should be\nlive, a wrong value) AND visual/UX feedback (misaligned, clipped, low-contrast,\ncramped). Attach the screenshot path as `evidence`. With no console/network to mine,\nthe a11y tree and what `look` reports back are your only signals \u2014 lean on both.\n";
@@ -20,12 +20,17 @@ There is no DOM, no JavaScript context, and **no console or network channel**.
20
20
  | Channel | What it gives you | Use via |
21
21
  |---------------|-------------------|---------|
22
22
  | a11y tree | element roles, names, on-screen bounds, enabled state | \`observe({kind:"tree"})\` |
23
- | screenshot | the current frame as PNG (evidence + vision) | \`observe({kind:"screenshot"})\`, \`look\` |
23
+ | screenshot | the frame SAVED as evidence — you get a file path back, not pixels | \`observe({kind:"screenshot"})\` |
24
+ | eyes | an actual visual judgment of the current frame | \`look\` |
24
25
 
25
26
  \`observe({kind:"console"})\` and \`observe({kind:"network"})\` are **unsupported** on
26
27
  desktop and error out — native apps expose no such streams. Never call them; judge
27
28
  behaviour from the a11y tree and the pixels instead.
28
29
 
30
+ \`observe({kind:"tabs"})\` and \`act({action:"switch_tab"})\` are **unsupported** on
31
+ desktop and error out too — a native window has no tabs. Never call them; switch
32
+ windows with \`act({action:"navigate", target:"<window title>"})\` instead.
33
+
29
34
  ### The app is already up — don't navigate to a URL
30
35
 
31
36
  The window is launched and focused before your first step. There is no address bar.
@@ -51,10 +56,18 @@ visible element instead, e.g. a button or a heading you expect to render.
51
56
  ### Selectors — use the node's \`target\`, don't invent one
52
57
 
53
58
  Actionable nodes from \`observe({kind:"tree"})\` carry a ready-to-use \`target\` string
54
- built from their a11y role + name (e.g. \`role=button[name="Save" i]\`). When a node
55
- has a \`target\`, COPY it verbatim into \`act({action, target})\`. Do NOT hand-craft a
56
- selector. If a node is unnamed, pass its visible text as \`target\`, or scope the read
57
- with \`within\`/\`filters\` and act on what comes back.
59
+ built from their a11y role + name — \`button "Save"\`. When a node has a \`target\`,
60
+ COPY it verbatim into \`act({action, target})\`.
61
+
62
+ Desktop targets take exactly two forms, and NOTHING else:
63
+ - \`role "name"\` — e.g. \`button "Save"\`, \`text "Email"\` (role must match exactly,
64
+ name is a case-insensitive substring).
65
+ - a plain name substring — e.g. \`Save\`.
66
+
67
+ Web selector syntax does NOT work here: \`role=button[name="Save" i]\`, \`text=Save\`,
68
+ CSS and \`>> nth=\` are all read as literal text, match nothing, and cost you the step.
69
+ If a node is unnamed, or repeats and so carries no \`target\`, scope the read with
70
+ \`within\`/\`filters\` and act on what comes back.
58
71
 
59
72
  ### Findings — functional + visual
60
73
 
@@ -1 +1 @@
1
- {"version":3,"file":"desktop-addendum.js","sourceRoot":"","sources":["../../../src/agent/prompts/desktop-addendum.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuDtC,CAAC"}
1
+ {"version":3,"file":"desktop-addendum.js","sourceRoot":"","sources":["../../../src/agent/prompts/desktop-addendum.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoEtC,CAAC"}
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * Provider-agnostic — no vendor tricks; any competent model drives the same loop.
8
8
  */
9
- export declare const WEB_ADDENDUM_PROMPT = "## Web target \u2014 CDP reach\n\nYour browser connection uses the Chrome DevTools Protocol (CDP).\nIt reaches the current page: DOM, console, network, input, and screenshots.\nUse it deliberately.\n\n### CDP domains and when to reach for each\n\n| Domain | What it gives you | Use via |\n|-------------|-------------------|---------|\n| `Page` | navigate, wait for load, capture screenshot | `act({action:\"navigate\"})`, `observe({kind:\"screenshot\"})` |\n| `DOM` | read/query the element tree, attributes, text | `observe({kind:\"tree\"})` |\n| `Network` | request/response status, failed requests, timing | `observe({kind:\"network\"})` |\n| `Log` | browser console messages, JS errors | `observe({kind:\"console\"})` |\n\n### DOM-first rule\n\nAlways try the structured path before asking for vision:\n1. `observe({kind:\"tree\"})` \u2014 read element roles, names, bounds, enabled state.\n2. If an element is not visible in the tree, try scrolling or waiting, then re-observe.\n3. Use `observe({kind:\"console\"})` and `observe({kind:\"network\"})` (filtered \u2014 see\n below) after actions that plausibly trigger errors \u2014 errors land there before\n they surface visually.\n4. Only after the tree gives you no answer: call `look` for pixels.\n\n### Composing tree queries\n\n- `query` accepts: a bare HTML tag (`span`, `img`), CSS (`.cart span`),\n `role \"name\"` (`button \"Add to cart\"`), an explicit engine\n (`data-testid=cart-count`, `text=Subscribe`), or plain visible text.\n- Elements with a `data-testid` always appear in the default (no-query) tree with\n their `testid` \u2014 to read a counter/value, find its node and read `name` (the\n text content). Re-observe the same node after acting to verify a change.\n- `within` scopes the read: pass a selector string or a node OBJECT exactly as a\n previous observe returned it \u2014 never a JSON-stringified node.\n\n### Invisible text & contrast \u2014 no vision needed\n\nText-bearing nodes carry a `style` column = `{ color, backgroundColor, contrast }`\n(WCAG ratio 1\u201321). It is omitted by default \u2014 request it via `fields:[\"role\",\"name\",\"style\"]`\nor sweep all text in ONE call:\n`observe({kind:\"tree\", query:\"p, span, div, a, li\", filters:{contrast_lt: 4.5}})`\n(returns only hard-to-read text; empty = contrast is fine). Flag `contrast < 4.5`\nas a `medium` visual finding and `contrast < 1.5` as `high` (the text is\neffectively invisible). Always run one contrast sweep when the goal mentions\nreadability, contrast, or visual polish.\n\n### Follow links by CLICKING them \u2014 never invent URLs\n\nThe tree does not expose `href`s. To follow a link, `act({action:\"click\"})` its\nnode. Do NOT fabricate a URL from a link's label (e.g. label \"Help Center\" \u2192\nnavigating to `/help-center`): a guessed URL that 404s is YOUR error, not a site\nbug. Only `navigate` to URLs given in the goal or seen in network entries. If a\nlink's click target is hidden (e.g. inside a closed menu), click the parent menu\nitem first, then re-observe.\n\n### Verify input from the TREE, never from vision\n\nForm controls carry their LIVE state in the tree: `value` (what an\ninput/textarea/select currently holds) and `checked` (checkbox/radio). `name`\nstays the label, so you can still target the field by it.\n\nAfter typing or toggling, confirm with one `observe`:\n`observe({kind:\"tree\", query:\"input\", fields:[\"name\",\"value\",\"checked\"]})`\n\nNEVER spend a `look` asking \"did my text land?\" or \"is the box checked now?\" \u2014\nthe tree answers exactly, instantly, and for free. Vision is for how things LOOK,\nnot for reading back your own input.\n\n### Typing replaces nothing unless you say so\n\n`act({action:\"type\"})` APPENDS to whatever the field already holds. Re-typing a\nfield you have used before yields `old textnew text` \u2014 and that doubled value is\nYOUR bug, not the app's. Pass `clear: true` to replace the contents instead:\n`act({action:\"type\", target:\"...\", text:\"...\", clear:true})`.\n\nUse `clear` whenever the field may be non-empty: a retry, a second item through\nthe same form, or any field you have not just seen empty in the tree.\n\n### Login bypass\n\nIf the target has `?debug-ai=true` support (the app's captcha bypass gate),\nappend it to the login URL before navigating. This skips captcha only \u2014 not auth.\nThe app must have `ALLOW_AI_DEBUG_LOGIN=true` set in its environment.\n\n### Selectors \u2014 use the node's `target`, don't invent one\n\nMost actionable nodes from `observe({kind:\"tree\"})` carry a ready-to-use `target`\nstring (e.g. `data-testid=\"cart-count\"` when the element has a test id, else\n`role=button[name=\"Add to cart\" i]`, with `>> nth=N` when names repeat).\nWhen a node has a `target`, COPY it verbatim into `act({action, target})`.\nDo NOT hand-craft a selector \u2014 guessed CSS like `button[name=\"...\"]` will not resolve.\n\nIf a node has no `target` (unnamed/non-semantic, or a scoped `within`/`filters`\nread), you may pass its visible text as `target` (plain text resolves), or\n`role \"name\"`. Avoid XPath and positional CSS.\n\n### Console + network \u2014 filter, don't dump\n\nBoth channels support `filters` and `limit` \u2014 use them instead of reading\neverything every time:\n- `observe({kind:\"console\", filters:{level_eq:\"error\"}})` \u2014 just JS errors.\n- `observe({kind:\"network\", filters:{status_gte:400}})` \u2014 just failed requests.\n- `limit` caps rows returned when you only need the latest few.\n\nCheck both after actions that plausibly trigger errors (submits, navigations,\nAPI calls) \u2014 not mechanically after every single `act`.\n\nRecord any errors as `console` or `network` bugs with the request URL / error\nmessage as `detail` and the screenshot path as `evidence` when relevant.\n\n### Network entries carry the WHY, not just the status\n\nEach row is a full exchange: `method`, `url`, `status`, `ok`, `durationMs`,\nand for API calls (`fetch`/`xhr`) the `requestBody`, `responseBody`, and\nredacted `requestHeaders`/`responseHeaders`.\n\n**A failing request is only half-reported without its `responseBody`.** When a\nsubmit fails, do NOT stop at \"POST /api/x returned 400\" \u2014 read the row and quote\nwhat the server actually said (`{\"error\":\"password too short\"}`); that string is\nwhat turns a finding into a fix. Same for the `requestBody`: it shows whether the\nUI even sent what you typed.\n\nCredential header values arrive as `<redacted, N chars>`. That is deliberate \u2014\npresence is what you need (a missing `cookie` explains a 401), never the secret.\n\nOther reads that pay off:\n- `filters:{duration_gte:1000}` \u2014 requests slow enough to be a UX bug.\n- `filters:{body_contains:\"error\"}` \u2014 failures that still returned HTTP 200.\n\nA default `network` read hides successful static assets (scripts, styles,\nimages) and tells you how many via `hidden` \u2014 on a dev server they outnumber real\nAPI calls ~15:1 and would crowd out everything worth seeing. Failed assets are\nalways shown (a 404 image is a real bug). To inspect assets deliberately, ask:\n`observe({kind:\"network\", filters:{resource_in:[\"script\",\"stylesheet\",\"image\"]}})`.\n\n### iframes \u2014 already in the tree\n\n`observe({kind:\"tree\"})` reads embedded documents too (payment fields, editors,\nconsent screens). A node inside one carries `frame` = the iframe's URL; its\n`bounds` are page coordinates, so clicking it needs nothing special. If a\nselector mysteriously fails to resolve on a node you can see, check whether it\nhas a `frame` \u2014 and prefer clicking the node object over a hand-written selector.\n\n### Tabs \u2014 a click can open one\n\nWhen more than one tab is open, every `act` result carries a `tabs` array\n(`index`, `url`, `title`, `active`). A click on an external link, an OAuth\nbutton, or `target=\"_blank\"` opens a new tab and **you are still on the old one**\n\u2014 if a click seems to have done nothing, check `tabs` before concluding the\nbutton is broken.\n\n- `observe({kind:\"tabs\"})` \u2014 list them any time.\n- `act({action:\"switch_tab\", target:\"1\"})` \u2014 drive tab 1 from now on. Console and\n network capture follow you; what the previous tab recorded is kept.\n\nSwitch back the same way when the popup flow is done.\n";
9
+ export declare const WEB_ADDENDUM_PROMPT = "## Web target \u2014 CDP reach\n\nYour browser connection uses the Chrome DevTools Protocol (CDP).\nIt reaches the current page: DOM, console, network, input, and screenshots.\nUse it deliberately.\n\n### CDP domains and when to reach for each\n\n| Domain | What it gives you | Use via |\n|-------------|-------------------|---------|\n| `Page` | navigate, wait for load, capture screenshot | `act({action:\"navigate\"})`, `observe({kind:\"screenshot\"})` |\n| `DOM` | read/query the element tree, attributes, text | `observe({kind:\"tree\"})` |\n| `Network` | request/response status, failed requests, timing | `observe({kind:\"network\"})` |\n| `Log` | browser console messages, JS errors | `observe({kind:\"console\"})` |\n\n### DOM-first rule\n\nAlways try the structured path before asking for vision:\n1. `observe({kind:\"tree\"})` \u2014 read element roles, names, bounds, enabled state.\n2. If an element is not visible in the tree, try scrolling or waiting, then re-observe.\n3. Use `observe({kind:\"console\"})` and `observe({kind:\"network\"})` (filtered \u2014 see\n below) after actions that plausibly trigger errors \u2014 errors land there before\n they surface visually.\n4. Only after the tree gives you no answer: call `look` for pixels.\n\n### Composing tree queries\n\n- `query` accepts: a bare HTML tag (`span`, `img`), CSS (`.cart span`),\n `role \"name\"` (`button \"Add to cart\"`), an explicit engine\n (`data-testid=cart-count`, `text=Subscribe`), or plain visible text.\n- Elements with a `data-testid` always appear in the default (no-query) tree with\n their `testid` \u2014 to read a counter/value, find its node and read `name` (the\n text content). Re-observe the same node after acting to verify a change.\n- `within` scopes the read: pass a selector string or a node OBJECT exactly as a\n previous observe returned it \u2014 never a JSON-stringified node.\n\n### Invisible text & contrast \u2014 no vision needed\n\nText-bearing nodes carry a `style` column = `{ color, backgroundColor, contrast }`\n(WCAG ratio 1\u201321). It is omitted by default \u2014 request it via `fields:[\"role\",\"name\",\"style\"]`\nor sweep all text in ONE call:\n`observe({kind:\"tree\", query:\"p, span, div, a, li\", filters:{contrast_lt: 4.5}})`\n(returns only hard-to-read text; empty = contrast is fine). Flag `contrast < 4.5`\nas a `medium` visual finding and `contrast < 1.5` as `high` (the text is\neffectively invisible). Always run one contrast sweep when the goal mentions\nreadability, contrast, or visual polish.\n\n### Follow links by CLICKING them \u2014 never invent URLs\n\nThe tree does not expose `href`s. To follow a link, `act({action:\"click\"})` its\nnode. Do NOT fabricate a URL from a link's label (e.g. label \"Help Center\" \u2192\nnavigating to `/help-center`): a guessed URL that 404s is YOUR error, not a site\nbug. Only `navigate` to URLs given in the goal or seen in network entries. If a\nlink's click target is hidden (e.g. inside a closed menu), click the parent menu\nitem first, then re-observe.\n\n### Verify input from the TREE, never from vision\n\nForm controls carry their LIVE state in the tree: `value` (what an\ninput/textarea/select currently holds) and `checked` (checkbox/radio). `name`\nstays the label, so you can still target the field by it.\n\nAfter typing or toggling, confirm with one `observe`:\n`observe({kind:\"tree\", query:\"input\", fields:[\"name\",\"value\",\"checked\"]})`\n\nNEVER spend a `look` asking \"did my text land?\" or \"is the box checked now?\" \u2014\nthe tree answers exactly, instantly, and for free. Vision is for how things LOOK,\nnot for reading back your own input.\n\n### Login bypass\n\nIf the target has `?debug-ai=true` support (the app's captcha bypass gate),\nappend it to the login URL before navigating. This skips captcha only \u2014 not auth.\nThe app must have `ALLOW_AI_DEBUG_LOGIN=true` set in its environment.\n\n### Selectors \u2014 use the node's `target`, don't invent one\n\nMost actionable nodes from `observe({kind:\"tree\"})` carry a ready-to-use `target`\nstring (e.g. `data-testid=\"cart-count\"` when the element has a test id, else\n`role=button[name=\"Add to cart\" i]`, with `>> nth=N` when names repeat).\nWhen a node has a `target`, COPY it verbatim into `act({action, target})`.\nDo NOT hand-craft a selector \u2014 guessed CSS like `button[name=\"...\"]` will not resolve.\n\nIf a node has no `target` (unnamed/non-semantic, or a scoped `within`/`filters`\nread), you may pass its visible text as `target` (plain text resolves), or\n`role \"name\"`. Avoid XPath and positional CSS.\n\n### Console + network \u2014 filter, don't dump\n\nBoth channels support `filters` and `limit` \u2014 use them instead of reading\neverything every time:\n- `observe({kind:\"console\", filters:{level_eq:\"error\"}})` \u2014 just JS errors.\n- `observe({kind:\"network\", filters:{status_gte:400}})` \u2014 just failed requests.\n- `limit` caps rows returned when you only need the latest few.\n\nCheck both after actions that plausibly trigger errors (submits, navigations,\nAPI calls) \u2014 not mechanically after every single `act`.\n\nRecord any errors as `console` or `network` bugs with the request URL / error\nmessage as `detail` and the screenshot path as `evidence` when relevant.\n\n### Network entries carry the WHY, not just the status\n\nEach row is a full exchange: `method`, `url`, `status`, `ok`, `durationMs`,\nand for API calls (`fetch`/`xhr`) the `requestBody`, `responseBody`, and\nredacted `requestHeaders`/`responseHeaders`.\n\n**A failing request is only half-reported without its `responseBody`.** When a\nsubmit fails, do NOT stop at \"POST /api/x returned 400\" \u2014 read the row and quote\nwhat the server actually said (`{\"error\":\"password too short\"}`); that string is\nwhat turns a finding into a fix. Same for the `requestBody`: it shows whether the\nUI even sent what you typed.\n\nCredential header values arrive as `<redacted, N chars>`. That is deliberate \u2014\npresence is what you need (a missing `cookie` explains a 401), never the secret.\n\nOther reads that pay off:\n- `filters:{duration_gte:1000}` \u2014 requests slow enough to be a UX bug.\n- `filters:{body_contains:\"error\"}` \u2014 failures that still returned HTTP 200.\n\nA default `network` read hides successful static assets (scripts, styles,\nimages) and tells you how many via `hidden` \u2014 on a dev server they outnumber real\nAPI calls ~15:1 and would crowd out everything worth seeing. Failed assets are\nalways shown (a 404 image is a real bug). To inspect assets deliberately, ask:\n`observe({kind:\"network\", filters:{resource_in:[\"script\",\"stylesheet\",\"image\"]}})`.\n\n### iframes \u2014 already in the tree\n\n`observe({kind:\"tree\"})` reads embedded documents too (payment fields, editors,\nconsent screens). A node inside one carries `frame` = the iframe's URL; its\n`bounds` are page coordinates, so clicking it needs nothing special. If a\nselector mysteriously fails to resolve on a node you can see, check whether it\nhas a `frame` \u2014 and prefer clicking the node object over a hand-written selector.\n\n### Tabs \u2014 a click can open one\n\nWhen more than one tab is open, every `act` result carries a `tabs` array\n(`index`, `url`, `title`, `active`). A click on an external link, an OAuth\nbutton, or `target=\"_blank\"` opens a new tab and **you are still on the old one**\n\u2014 if a click seems to have done nothing, check `tabs` before concluding the\nbutton is broken.\n\n- `observe({kind:\"tabs\"})` \u2014 list them any time.\n- `act({action:\"switch_tab\", target:\"1\"})` \u2014 drive tab 1 from now on. Console and\n network capture follow you; what the previous tab recorded is kept.\n\nSwitch back the same way when the popup flow is done.\n";
@@ -76,16 +76,6 @@ NEVER spend a \`look\` asking "did my text land?" or "is the box checked now?"
76
76
  the tree answers exactly, instantly, and for free. Vision is for how things LOOK,
77
77
  not for reading back your own input.
78
78
 
79
- ### Typing replaces nothing unless you say so
80
-
81
- \`act({action:"type"})\` APPENDS to whatever the field already holds. Re-typing a
82
- field you have used before yields \`old textnew text\` — and that doubled value is
83
- YOUR bug, not the app's. Pass \`clear: true\` to replace the contents instead:
84
- \`act({action:"type", target:"...", text:"...", clear:true})\`.
85
-
86
- Use \`clear\` whenever the field may be non-empty: a retry, a second item through
87
- the same form, or any field you have not just seen empty in the tree.
88
-
89
79
  ### Login bypass
90
80
 
91
81
  If the target has \`?debug-ai=true\` support (the app's captcha bypass gate),
@@ -1 +1 @@
1
- {"version":3,"file":"web-addendum.js","sourceRoot":"","sources":["../../../src/agent/prompts/web-addendum.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8JlC,CAAC"}
1
+ {"version":3,"file":"web-addendum.js","sourceRoot":"","sources":["../../../src/agent/prompts/web-addendum.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoJlC,CAAC"}
@@ -22,6 +22,12 @@
22
22
  *
23
23
  * Contents, not mtime: editors and formatters rewrite files without changing
24
24
  * anything that matters, and a spurious "restart me" is its own kind of noise.
25
+ *
26
+ * `node:crypto`, not `Bun.hash`: the package ships as `bin: dist/main.js` behind
27
+ * `#!/usr/bin/env node`, so the published server runs on Node, where `Bun` is
28
+ * undefined. Hashing with a Bun global threw a `ReferenceError` straight into the
29
+ * catch below — the fingerprint was permanently `null` and drift detection was
30
+ * dead in every installed copy, while working fine under `bun run dev`.
25
31
  */
26
32
  export declare function configFingerprint(cwd: string): string | null;
27
33
  /**
@@ -16,6 +16,7 @@
16
16
  * fail loud with the one instruction that actually resolves it. A stale config is
17
17
  * a bad assumption, and the house rule is to crash on those rather than run on.
18
18
  */
19
+ import { createHash } from 'node:crypto';
19
20
  import { readFileSync } from 'node:fs';
20
21
  import { join } from 'node:path';
21
22
  import { CONFIG_FILENAME } from './load.js';
@@ -25,15 +26,26 @@ import { CONFIG_FILENAME } from './load.js';
25
26
  *
26
27
  * Contents, not mtime: editors and formatters rewrite files without changing
27
28
  * anything that matters, and a spurious "restart me" is its own kind of noise.
29
+ *
30
+ * `node:crypto`, not `Bun.hash`: the package ships as `bin: dist/main.js` behind
31
+ * `#!/usr/bin/env node`, so the published server runs on Node, where `Bun` is
32
+ * undefined. Hashing with a Bun global threw a `ReferenceError` straight into the
33
+ * catch below — the fingerprint was permanently `null` and drift detection was
34
+ * dead in every installed copy, while working fine under `bun run dev`.
28
35
  */
29
36
  export function configFingerprint(cwd) {
37
+ let raw;
30
38
  try {
31
- const raw = readFileSync(join(cwd, CONFIG_FILENAME), 'utf8');
32
- return Bun.hash(raw).toString(16);
39
+ raw = readFileSync(join(cwd, CONFIG_FILENAME), 'utf8');
33
40
  }
34
- catch {
35
- return null;
41
+ catch (err) {
42
+ // Absent config = nothing to drift from. Anything else (permissions, I/O) is a
43
+ // bad assumption, and the house rule is to crash on those rather than run on.
44
+ if (err?.code === 'ENOENT')
45
+ return null;
46
+ throw err;
36
47
  }
48
+ return createHash('sha256').update(raw).digest('hex');
37
49
  }
38
50
  /**
39
51
  * A comparison against the fingerprint taken at boot. Returns whether the file
@@ -1 +1 @@
1
- {"version":3,"file":"fingerprint.js","sourceRoot":"","sources":["../../src/config/fingerprint.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,eAAe,CAAC,EAAE,MAAM,CAAC,CAAC;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AAG,CAAC,CAAC;IACtC,OAAO,GAAG,EAAE,CAAC,iBAAiB,CAAC,GAAG,CAAC,KAAK,MAAM,CAAC;AACjD,CAAC"}
@@ -39,10 +39,16 @@ export declare const DesktopTargetSchema: z.ZodObject<{
39
39
  }, z.core.$strict>>;
40
40
  display: z.ZodOptional<z.ZodNullable<z.ZodString>>;
41
41
  }, z.core.$strict>;
42
- /** Android target — ADB adapter. Managed (boot `emulator @avd`) unless `adbSerial` attaches. */
42
+ /**
43
+ * Android target — ADB adapter. Managed (boot `emulator @avd`) unless `adbSerial` attaches.
44
+ *
45
+ * `avd`/`emulatorPath` are **managed-only** — attach binds straight to the serial and
46
+ * never reads them, so a physical device is just `{ adapter, adbSerial }` instead of a
47
+ * made-up AVD name. The constraint is stated where it is real: managed requires `avd`.
48
+ */
43
49
  export declare const AndroidTargetSchema: z.ZodObject<{
44
50
  adapter: z.ZodLiteral<"android">;
45
- avd: z.ZodString;
51
+ avd: z.ZodOptional<z.ZodString>;
46
52
  emulatorPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
47
53
  adbSerial: z.ZodOptional<z.ZodNullable<z.ZodString>>;
48
54
  }, z.core.$strict>;
@@ -67,7 +73,7 @@ export declare const TargetSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
67
73
  display: z.ZodOptional<z.ZodNullable<z.ZodString>>;
68
74
  }, z.core.$strict>, z.ZodObject<{
69
75
  adapter: z.ZodLiteral<"android">;
70
- avd: z.ZodString;
76
+ avd: z.ZodOptional<z.ZodString>;
71
77
  emulatorPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
78
  adbSerial: z.ZodOptional<z.ZodNullable<z.ZodString>>;
73
79
  }, z.core.$strict>], "adapter">;
@@ -99,7 +105,7 @@ export declare const ConfigSchema: z.ZodObject<{
99
105
  display: z.ZodOptional<z.ZodNullable<z.ZodString>>;
100
106
  }, z.core.$strict>, z.ZodObject<{
101
107
  adapter: z.ZodLiteral<"android">;
102
- avd: z.ZodString;
108
+ avd: z.ZodOptional<z.ZodString>;
103
109
  emulatorPath: z.ZodOptional<z.ZodNullable<z.ZodString>>;
104
110
  adbSerial: z.ZodOptional<z.ZodNullable<z.ZodString>>;
105
111
  }, z.core.$strict>], "adapter">>;
@@ -33,8 +33,8 @@ export const WebTargetSchema = z.strictObject({
33
33
  * window title itself — with neither, `open` fails loud instead of driving nothing.
34
34
  */
35
35
  const WindowMatchSchema = z.strictObject({
36
- title: z.string().optional(), // WM_NAME / title substring
37
- class: z.string().optional(), // WM_CLASS
36
+ title: z.string().optional(), // WM_NAME / title substring, literal (regex chars escaped)
37
+ class: z.string().optional(), // WM_CLASS, literal (regex chars escaped)
38
38
  });
39
39
  /**
40
40
  * Desktop target — X11/Xvfb + Wayland adapter. Managed launch.
@@ -50,12 +50,28 @@ export const DesktopTargetSchema = z.strictObject({
50
50
  window: WindowMatchSchema.optional(), // which window to drive; omit → `open` must supply a title
51
51
  display: z.string().nullish(), // X11 DISPLAY, e.g. ":99" for Xvfb; null = inherit env
52
52
  });
53
- /** Android target — ADB adapter. Managed (boot `emulator @avd`) unless `adbSerial` attaches. */
54
- export const AndroidTargetSchema = z.strictObject({
53
+ /**
54
+ * Android target — ADB adapter. Managed (boot `emulator @avd`) unless `adbSerial` attaches.
55
+ *
56
+ * `avd`/`emulatorPath` are **managed-only** — attach binds straight to the serial and
57
+ * never reads them, so a physical device is just `{ adapter, adbSerial }` instead of a
58
+ * made-up AVD name. The constraint is stated where it is real: managed requires `avd`.
59
+ */
60
+ export const AndroidTargetSchema = z
61
+ .strictObject({
55
62
  adapter: z.literal('android'),
56
- avd: z.string(),
63
+ avd: z.string().optional(), // required in managed mode (see the refinement below)
57
64
  emulatorPath: z.string().nullish(), // null = auto-detect from SDK (managed)
58
65
  adbSerial: z.string().nullish(), // set → attach to a running device, no start/stop
66
+ })
67
+ .superRefine((target, ctx) => {
68
+ if (target.adbSerial == null && target.avd === undefined) {
69
+ ctx.addIssue({
70
+ code: 'custom',
71
+ path: ['avd'],
72
+ message: '`avd` is required in managed mode (set `adbSerial` to attach instead)',
73
+ });
74
+ }
59
75
  });
60
76
  /** A single target, discriminated on `adapter`. All three adapters (browser, desktop, android) are operational. */
61
77
  export const TargetSchema = z.discriminatedUnion('adapter', [
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/config/schema.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,6FAA6F;AAC7F,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC;IACzC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,+CAA+C;IACnE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,mDAAmD;IACvE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,mDAAmD;CACpF,CAAC,CAAC;AAEH,gEAAgE;AAChE,MAAM,gBAAgB,GAAG,CAAC,CAAC,YAAY,CAAC;IACtC,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,uDAAuD;CAC3E,CAAC,CAAC;AAEH,mFAAmF;AACnF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,YAAY,CAAC;IAC5C,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC7B,GAAG,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,EAAE,sEAAsE;IAC/F,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,mDAAmD;IACxF,UAAU,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACvC,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,EAAE,+CAA+C;IACrF,kFAAkF;IAClF,iFAAiF;IACjF,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC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,IAAI,MAAM,CAAC,SAAS,IAAI,IAAI,IAAI,MAAM,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QACzD,GAAG,CAAC,QAAQ,CAAC;YACX,IAAI,EAAE,QAAQ;YACd,IAAI,EAAE,CAAC,KAAK,CAAC;YACb,OAAO,EAAE,uEAAuE;SACjF,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC;AAEL,mHAAmH;AACnH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,kBAAkB,CAAC,SAAS,EAAE;IAC1D,eAAe;IACf,mBAAmB;IACnB,mBAAmB;CACpB,CAAC,CAAC;AAEH,gGAAgG;AAChG,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,YAAY,CAAC;IACzC,MAAM,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACzC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAChC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,YAAY,CAAC;CAC5C,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare const NAME = "ui-debugger-mcp";
2
- export declare const VERSION = "1.3.0";
2
+ export declare const VERSION = "1.4.0";
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // Public package surface. Implementation lands incrementally — see idea/ for design.
2
2
  export const NAME = 'ui-debugger-mcp';
3
- export const VERSION = '1.3.0';
3
+ export const VERSION = '1.4.0';
4
4
  //# sourceMappingURL=index.js.map
package/dist/main.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- import { isAbsolute, join } from 'node:path';
3
2
  import { supportsImageInput } from './agent/capabilities.js';
4
3
  import { resolveModels } from './agent/models.js';
5
4
  import { createOpenRouterProvider, resolveProviderConfig } from './agent/provider.js';
@@ -13,6 +12,7 @@ import { startStdioServer } from './mcp/server.js';
13
12
  import { outerTools } from './mcp/tools/index.js';
14
13
  import { DebugService } from './services/debug-service.js';
15
14
  import { makeSessionBuilder } from './services/session-builder.js';
15
+ import { createShutdown } from './services/shutdown.js';
16
16
  import { SessionManager } from './session/manager.js';
17
17
  import { FileStatePort } from './session/state-file.js';
18
18
  import { ensureWorkspace, workspacePaths } from './session/workspace.js';
@@ -54,12 +54,10 @@ async function main() {
54
54
  // Load project config (cwd-keyed)
55
55
  const config = loadConfig();
56
56
  const cwd = process.cwd();
57
- // Bootstrap workspace directories (chrome-user-data/, sessions/)
58
- // Anchor relative workspace paths to the project root.
59
- const workspaceBase = isAbsolute(config.workspace)
60
- ? config.workspace
61
- : join(cwd, config.workspace);
62
- const workspace = workspacePaths(cwd, workspaceBase);
57
+ // Bootstrap workspace directories (chrome-user-data/, sessions/).
58
+ // A relative workspace anchors at the project root; an absolute (shared) one
59
+ // gets a cwd-derived project dir — see `workspacePaths`.
60
+ const workspace = workspacePaths(cwd, config.workspace);
63
61
  await ensureWorkspace(workspace);
64
62
  // Resolve provider + per-role models (driver, vision, summary)
65
63
  const providerOptions = {
@@ -102,12 +100,12 @@ async function main() {
102
100
  });
103
101
  // Graceful stop: a CLI `stop` (or any SIGTERM/SIGINT) tears the run down —
104
102
  // abort the loop, close the browser, free the profile — then exits cleanly.
105
- const shutdown = (exitCode) => {
106
- service
107
- .endActive()
108
- .catch(() => undefined)
109
- .finally(() => process.exit(exitCode));
110
- };
103
+ // Bounded: a teardown that wedges (a tool call that never observes its abort)
104
+ // must not leave the process alive forever, because `stop` only signals once.
105
+ const shutdown = createShutdown({
106
+ endActive: () => service.endActive(),
107
+ exit: (exitCode) => process.exit(exitCode),
108
+ });
111
109
  process.once('SIGTERM', () => shutdown(0));
112
110
  process.once('SIGINT', () => shutdown(130));
113
111
  // Boot stdio MCP server with outer tools. A dead client is a shutdown too:
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"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E;YACpC,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC;SAC3C,CAAC,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QAE5C,2EAA2E;QAC3E,2EAA2E;QAC3E,6EAA6E;QAC7E,sCAAsC;QACtC,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;QAClC,MAAM,gBAAgB,CAAC,KAAK,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAChE,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,KAAK,OAAO,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC1F,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,KAAK,IAAI,EAAE,CAAC"}
@@ -93,6 +93,7 @@ export interface DescribeResult {
93
93
  vision: string;
94
94
  summary: string;
95
95
  };
96
+ /** Resolved per-project workspace root (`<base>/<project>`) — where evidence lands. */
96
97
  workspace: string;
97
98
  }
98
99
  /** The surface the outer MCP tools call. Implemented by {@link DebugService}. */
@@ -146,7 +147,7 @@ export declare class DebugService implements DebugApi {
146
147
  * remaining budget is threaded into the build and the first navigation, so a slow
147
148
  * Chrome launch spends the caller's cap instead of sitting outside it.
148
149
  */
149
- start({ target, goal, criteria, url, timeoutMs }: StartInput): Promise<StartResult>;
150
+ start(input: StartInput): Promise<StartResult>;
150
151
  /**
151
152
  * Queue a mid-run instruction for the active run's driver. Fails loud
152
153
  * ({@link SessionSettledError}) once the run has settled — the loop no longer
@@ -29,7 +29,7 @@ import { CONFIG_FILENAME } from '../config/load.js';
29
29
  import { ConfigError, SessionBusyError, SessionNotFoundError, SessionSettledError, TargetNotFoundError, } from '../errors.js';
30
30
  import { FindingsSchema } from '../findings/schema.js';
31
31
  import { noopStatePort } from '../session/state-file.js';
32
- import { generateSessionId } from '../session/workspace.js';
32
+ import { generateSessionId, workspacePaths } from '../session/workspace.js';
33
33
  /** Default wall-clock cap on a debug run before it auto-ends (overridable per run). */
34
34
  export const DEFAULT_SESSION_TIMEOUT_MS = 300_000;
35
35
  /**
@@ -64,12 +64,17 @@ export class DebugService {
64
64
  */
65
65
  #retained;
66
66
  /**
67
- * A `start()` is in flight (building/launching, slot not yet in the manager).
68
- * Set synchronously before the first await so a concurrent `start_debug` fails
69
- * loud with {@link SessionBusyError} instead of racing a second browser onto
70
- * the same profile.
67
+ * The `start()` currently in flight (building/launching, slot not yet in the
68
+ * manager), or `undefined`. Set synchronously before the first await so a
69
+ * concurrent `start_debug` fails loud with {@link SessionBusyError} instead of
70
+ * racing a second browser onto the same profile.
71
+ *
72
+ * `controller` cancels it at the next checkpoint and `settled` resolves once it
73
+ * has finished tearing down (it never rejects) — so {@link endActive} can abort a
74
+ * launch *and wait for it*, instead of finding an empty manager and letting the
75
+ * process exit with a half-launched Chrome still holding the profile lock.
71
76
  */
72
- #starting = false;
77
+ #starting;
73
78
  constructor(deps) {
74
79
  this.#manager = deps.manager;
75
80
  this.#config = deps.config;
@@ -92,7 +97,7 @@ export class DebugService {
92
97
  * remaining budget is threaded into the build and the first navigation, so a slow
93
98
  * Chrome launch spends the caller's cap instead of sitting outside it.
94
99
  */
95
- async start({ target, goal, criteria, url, timeoutMs }) {
100
+ async start(input) {
96
101
  const cwd = this.#cwd;
97
102
  if (this.#manager.has(cwd)) {
98
103
  throw new SessionBusyError(`A debug session ('${this.#manager.get(cwd).id}') is already active for '${cwd}'. ` +
@@ -100,22 +105,54 @@ export class DebugService {
100
105
  }
101
106
  // Taken synchronously (no await since the has() check) — a concurrent start
102
107
  // must fail here, not launch a second browser on the same profile.
103
- if (this.#starting) {
108
+ if (this.#starting !== undefined) {
104
109
  throw new SessionBusyError(`A debug session is already starting for '${cwd}'. ` +
105
110
  'Wait for it to open (or end it) before starting another — one run per project at a time.');
106
111
  }
107
112
  // Before anything is launched: a run built from config the caller has already
108
113
  // replaced is worse than no run — it reproduces the very failure they just fixed.
109
114
  this.#assertConfigFresh();
110
- this.#starting = true;
111
- const deadline = this.#now() + (timeoutMs ?? this.#defaultTimeoutMs);
115
+ const deadline = this.#now() + (input.timeoutMs ?? this.#defaultTimeoutMs);
116
+ const controller = new AbortController();
117
+ const attempt = this.#launch(input, deadline, controller.signal);
118
+ // Registered before anyone awaits `attempt`, and swallowing its outcome: this
119
+ // handle is a teardown *barrier* for `endActive`, never a second failure path.
120
+ this.#starting = {
121
+ controller,
122
+ settled: attempt.then(() => undefined, () => undefined),
123
+ };
124
+ try {
125
+ return await attempt;
126
+ }
127
+ finally {
128
+ this.#starting = undefined;
129
+ }
130
+ }
131
+ /**
132
+ * The launch itself: breadcrumb, build, lock, open, arm. Every await is a
133
+ * cancellation checkpoint — `signal` is the shutdown path asking this start to
134
+ * stop — and every failure (including a cancellation) tears down whatever
135
+ * already came up and drops the breadcrumb, so nothing is left holding the
136
+ * project's profile lock.
137
+ */
138
+ async #launch({ target, goal, criteria, url }, deadline, signal) {
139
+ const cwd = this.#cwd;
112
140
  /** Budget left on the caller's cap; never negative — a blown budget is simply spent. */
113
141
  const remaining = () => Math.max(0, deadline - this.#now());
142
+ await this.#assertNoForeignRun(cwd);
143
+ const id = generateSessionId(this.#now());
144
+ // The breadcrumb goes down BEFORE the launch, not after it: a cold Chrome start
145
+ // takes 5-20s, and until `state.json` exists the run is invisible out-of-band —
146
+ // `status` prints "no debug run recorded" and `stop` never signals, while a real
147
+ // browser already holds the profile lock. It fails loud (a run the CLI cannot
148
+ // see is a run nobody can stop) — and here that costs nothing, since not one
149
+ // process has been launched yet.
150
+ await this.#state.record({ sessionId: id, target, goal });
114
151
  try {
115
- await this.#assertNoForeignRun(cwd);
116
- const id = generateSessionId(this.#now());
152
+ this.#assertStartNotAborted(signal, id);
117
153
  const built = await this.#build({ id, target, goal, criteria, url, timeoutMs: remaining() });
118
154
  try {
155
+ this.#assertStartNotAborted(signal, id);
119
156
  this.#manager.start(cwd, built.session);
120
157
  }
121
158
  catch (err) {
@@ -127,33 +164,37 @@ export class DebugService {
127
164
  this.#retained = undefined;
128
165
  try {
129
166
  await built.open(remaining());
167
+ this.#assertStartNotAborted(signal, id);
130
168
  built.session.start(built.run);
131
169
  }
132
170
  catch (err) {
133
171
  await this.#manager.end(cwd).catch(() => undefined);
134
172
  throw err;
135
173
  }
136
- // Armed BEFORE the breadcrumb write, on what is LEFT of the cap: a throwing
137
- // StatePort must never leave a live run with no timer on it, and the launch
138
- // already spent part of the budget.
174
+ // Armed last, on what is LEFT of the cap: the launch already spent part of
175
+ // the budget, and nothing past this point can fail and strand the timer.
139
176
  this.#armTimeout(remaining());
140
- try {
141
- await this.#state.record({ sessionId: id, target, goal });
142
- }
143
- catch (err) {
144
- // The caller gets no session_id back, so nothing could ever end this run —
145
- // tear it down here (and drop any half-written breadcrumb) and fail loud.
146
- this.#clearTimeout();
147
- await this.#manager.end(cwd).catch(() => undefined);
148
- await this.#state.clear().catch(() => undefined);
149
- throw err;
150
- }
151
177
  return { session_id: id };
152
178
  }
153
- finally {
154
- this.#starting = false;
179
+ catch (err) {
180
+ // Nobody holds this id, so nothing could ever end the run — leave no
181
+ // `running` breadcrumb pointing the CLI at a run that is already gone.
182
+ await this.#state.clear().catch(() => undefined);
183
+ throw err;
155
184
  }
156
185
  }
186
+ /**
187
+ * Stop a start that the shutdown path has cancelled (SIGTERM, a CLI `stop`, the
188
+ * MCP client dying). The caller tears down whatever it had already built —
189
+ * teardown is exactly what the abort is for.
190
+ */
191
+ #assertStartNotAborted(signal, id) {
192
+ if (!signal.aborted)
193
+ return;
194
+ throw new SessionSettledError(`Debug run '${id}' was torn down while it was still starting — this ui-debugger-mcp server ` +
195
+ 'is shutting down (SIGTERM, `ui-debugger-mcp stop`, or the MCP client disconnected). ' +
196
+ 'Nothing was left running; start again once the server is back.');
197
+ }
157
198
  /**
158
199
  * Refuse to start on config this server can no longer honour.
159
200
  *
@@ -265,7 +306,10 @@ export class DebugService {
265
306
  return {
266
307
  targets: selected.map(([name, config]) => describeTarget(name, config)),
267
308
  models: this.#config.models,
268
- workspace: this.#config.workspace,
309
+ // The RESOLVED per-project root, not the raw config string: the caller joins
310
+ // this to the relative evidence paths it gets back, and `./tmp/ui-debugger-mcp`
311
+ // would send it looking one directory short of where anything lands.
312
+ workspace: workspacePaths(this.#cwd, this.#config.workspace).root,
269
313
  };
270
314
  }
271
315
  /**
@@ -297,6 +341,15 @@ export class DebugService {
297
341
  */
298
342
  async endActive() {
299
343
  this.#clearTimeout();
344
+ // A start still in flight owns no manager slot yet, so the check below would
345
+ // sail straight past a Chrome that is mid-launch: cancel it and WAIT for its
346
+ // teardown, or the process exits with a browser still holding the profile lock
347
+ // and every later run fails with "Chrome profile ... is locked".
348
+ const starting = this.#starting;
349
+ if (starting !== undefined) {
350
+ starting.controller.abort();
351
+ await starting.settled;
352
+ }
300
353
  if (!this.#manager.has(this.#cwd))
301
354
  return;
302
355
  // Nobody asked for this end, so nobody has read the results yet: retain the