@developerz.ai/ui-debugger-mcp 1.0.4 → 1.2.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 (161) hide show
  1. package/README.md +22 -10
  2. package/dist/adapters/android/adb.d.ts +34 -5
  3. package/dist/adapters/android/adb.js +74 -20
  4. package/dist/adapters/android/adb.js.map +1 -1
  5. package/dist/adapters/android/android-adapter.d.ts +23 -7
  6. package/dist/adapters/android/android-adapter.js +106 -36
  7. package/dist/adapters/android/android-adapter.js.map +1 -1
  8. package/dist/adapters/android/android-adapter.test-helpers.d.ts +52 -0
  9. package/dist/adapters/android/android-adapter.test-helpers.js +115 -0
  10. package/dist/adapters/android/android-adapter.test-helpers.js.map +1 -0
  11. package/dist/adapters/android/commands.d.ts +27 -4
  12. package/dist/adapters/android/commands.js +66 -4
  13. package/dist/adapters/android/commands.js.map +1 -1
  14. package/dist/adapters/android/ports.d.ts +32 -0
  15. package/dist/adapters/android/ports.js +47 -0
  16. package/dist/adapters/android/ports.js.map +1 -0
  17. package/dist/adapters/android/uiautomator.d.ts +10 -2
  18. package/dist/adapters/android/uiautomator.js +36 -4
  19. package/dist/adapters/android/uiautomator.js.map +1 -1
  20. package/dist/adapters/browser/browser-adapter.d.ts +14 -13
  21. package/dist/adapters/browser/browser-adapter.js +81 -200
  22. package/dist/adapters/browser/browser-adapter.js.map +1 -1
  23. package/dist/adapters/browser/cdp.js +18 -11
  24. package/dist/adapters/browser/cdp.js.map +1 -1
  25. package/dist/adapters/browser/extractor.d.ts +49 -0
  26. package/dist/adapters/browser/extractor.js +208 -0
  27. package/dist/adapters/browser/extractor.js.map +1 -0
  28. package/dist/adapters/browser/filters.d.ts +15 -0
  29. package/dist/adapters/browser/filters.js +93 -0
  30. package/dist/adapters/browser/filters.js.map +1 -0
  31. package/dist/adapters/browser/launch.d.ts +41 -0
  32. package/dist/adapters/browser/launch.js +61 -0
  33. package/dist/adapters/browser/launch.js.map +1 -0
  34. package/dist/adapters/browser/query.d.ts +3 -2
  35. package/dist/adapters/browser/query.js +68 -2
  36. package/dist/adapters/browser/query.js.map +1 -1
  37. package/dist/adapters/budget.d.ts +16 -0
  38. package/dist/adapters/budget.js +25 -0
  39. package/dist/adapters/budget.js.map +1 -0
  40. package/dist/adapters/contract.d.ts +29 -6
  41. package/dist/adapters/desktop/atspi.d.ts +15 -0
  42. package/dist/adapters/desktop/atspi.js +37 -17
  43. package/dist/adapters/desktop/atspi.js.map +1 -1
  44. package/dist/adapters/desktop/capture.js +8 -1
  45. package/dist/adapters/desktop/capture.js.map +1 -1
  46. package/dist/adapters/desktop/desktop-adapter.d.ts +9 -2
  47. package/dist/adapters/desktop/desktop-adapter.js +84 -32
  48. package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
  49. package/dist/adapters/desktop/input.d.ts +16 -1
  50. package/dist/adapters/desktop/input.js +30 -0
  51. package/dist/adapters/desktop/input.js.map +1 -1
  52. package/dist/adapters/desktop/proc.d.ts +18 -3
  53. package/dist/adapters/desktop/proc.js +48 -5
  54. package/dist/adapters/desktop/proc.js.map +1 -1
  55. package/dist/adapters/factory.d.ts +3 -1
  56. package/dist/adapters/factory.js +6 -2
  57. package/dist/adapters/factory.js.map +1 -1
  58. package/dist/adapters/limit.d.ts +10 -0
  59. package/dist/adapters/limit.js +19 -0
  60. package/dist/adapters/limit.js.map +1 -0
  61. package/dist/agent/belt/act.d.ts +27 -5
  62. package/dist/agent/belt/act.js +75 -17
  63. package/dist/agent/belt/act.js.map +1 -1
  64. package/dist/agent/belt/look.d.ts +37 -0
  65. package/dist/agent/belt/look.js +96 -4
  66. package/dist/agent/belt/look.js.map +1 -1
  67. package/dist/agent/belt/observe.d.ts +35 -9
  68. package/dist/agent/belt/observe.js +127 -18
  69. package/dist/agent/belt/observe.js.map +1 -1
  70. package/dist/agent/belt/report.d.ts +29 -9
  71. package/dist/agent/belt/report.js +77 -10
  72. package/dist/agent/belt/report.js.map +1 -1
  73. package/dist/agent/belt/trail.d.ts +34 -0
  74. package/dist/agent/belt/trail.js +64 -0
  75. package/dist/agent/belt/trail.js.map +1 -0
  76. package/dist/agent/capabilities.d.ts +30 -0
  77. package/dist/agent/capabilities.js +75 -0
  78. package/dist/agent/capabilities.js.map +1 -0
  79. package/dist/agent/loop.d.ts +68 -19
  80. package/dist/agent/loop.js +195 -51
  81. package/dist/agent/loop.js.map +1 -1
  82. package/dist/agent/prompts/compose.d.ts +9 -1
  83. package/dist/agent/prompts/compose.js +5 -4
  84. package/dist/agent/prompts/compose.js.map +1 -1
  85. package/dist/agent/prompts/debug-agent.d.ts +13 -1
  86. package/dist/agent/prompts/debug-agent.js +47 -7
  87. package/dist/agent/prompts/debug-agent.js.map +1 -1
  88. package/dist/agent/prompts/desktop-addendum.d.ts +1 -1
  89. package/dist/agent/prompts/desktop-addendum.js +1 -1
  90. package/dist/agent/prompts/web-addendum.d.ts +1 -1
  91. package/dist/agent/prompts/web-addendum.js +45 -17
  92. package/dist/agent/prompts/web-addendum.js.map +1 -1
  93. package/dist/agent/provider.d.ts +12 -3
  94. package/dist/agent/provider.js +13 -8
  95. package/dist/agent/provider.js.map +1 -1
  96. package/dist/cli/control.d.ts +3 -1
  97. package/dist/cli/control.js +26 -40
  98. package/dist/cli/control.js.map +1 -1
  99. package/dist/cli/help.d.ts +3 -1
  100. package/dist/cli/help.js +6 -2
  101. package/dist/cli/help.js.map +1 -1
  102. package/dist/cli/init.d.ts +3 -6
  103. package/dist/cli/init.js +64 -16
  104. package/dist/cli/init.js.map +1 -1
  105. package/dist/config/load.js +8 -1
  106. package/dist/config/load.js.map +1 -1
  107. package/dist/config/schema.d.ts +12 -5
  108. package/dist/config/schema.js +17 -7
  109. package/dist/config/schema.js.map +1 -1
  110. package/dist/errors.d.ts +22 -2
  111. package/dist/errors.js +36 -4
  112. package/dist/errors.js.map +1 -1
  113. package/dist/index.d.ts +1 -1
  114. package/dist/index.js +1 -1
  115. package/dist/main.js +38 -11
  116. package/dist/main.js.map +1 -1
  117. package/dist/mcp/server.d.ts +16 -1
  118. package/dist/mcp/server.js +23 -2
  119. package/dist/mcp/server.js.map +1 -1
  120. package/dist/mcp/server.test-helpers.d.ts +23 -0
  121. package/dist/mcp/server.test-helpers.js +49 -0
  122. package/dist/mcp/server.test-helpers.js.map +1 -0
  123. package/dist/mcp/tools/describe.js +5 -0
  124. package/dist/mcp/tools/describe.js.map +1 -1
  125. package/dist/mcp/tools/end-session.js +5 -0
  126. package/dist/mcp/tools/end-session.js.map +1 -1
  127. package/dist/mcp/tools/get-findings.js +23 -3
  128. package/dist/mcp/tools/get-findings.js.map +1 -1
  129. package/dist/mcp/tools/output.d.ts +50 -0
  130. package/dist/mcp/tools/output.js +55 -0
  131. package/dist/mcp/tools/output.js.map +1 -0
  132. package/dist/mcp/tools/result.d.ts +24 -1
  133. package/dist/mcp/tools/result.js +106 -5
  134. package/dist/mcp/tools/result.js.map +1 -1
  135. package/dist/mcp/tools/send-message.js +5 -0
  136. package/dist/mcp/tools/send-message.js.map +1 -1
  137. package/dist/mcp/tools/start-debug.js +7 -1
  138. package/dist/mcp/tools/start-debug.js.map +1 -1
  139. package/dist/services/debug-service.d.ts +38 -6
  140. package/dist/services/debug-service.js +122 -13
  141. package/dist/services/debug-service.js.map +1 -1
  142. package/dist/services/session-builder.d.ts +26 -3
  143. package/dist/services/session-builder.js +46 -14
  144. package/dist/services/session-builder.js.map +1 -1
  145. package/dist/session/atomic-write.d.ts +24 -0
  146. package/dist/session/atomic-write.js +39 -0
  147. package/dist/session/atomic-write.js.map +1 -0
  148. package/dist/session/findings-store.js +3 -4
  149. package/dist/session/findings-store.js.map +1 -1
  150. package/dist/session/process-identity.d.ts +16 -0
  151. package/dist/session/process-identity.js +29 -0
  152. package/dist/session/process-identity.js.map +1 -1
  153. package/dist/session/session.js +10 -2
  154. package/dist/session/session.js.map +1 -1
  155. package/dist/session/state-file.d.ts +51 -5
  156. package/dist/session/state-file.js +60 -8
  157. package/dist/session/state-file.js.map +1 -1
  158. package/dist/session/workspace.d.ts +11 -0
  159. package/dist/session/workspace.js +14 -1
  160. package/dist/session/workspace.js.map +1 -1
  161. package/package.json +4 -1
@@ -9,9 +9,11 @@
9
9
  * any mid-run messages (the smart agent's `send_message`) into a standing
10
10
  * instruction block re-appended to EVERY turn (the SDK rebuilds each step's
11
11
  * prompt from scratch), so the driver adapts without restarting or forgetting.
12
- * - **incremental findings** — `onStepFinish` lifts each step's `act` results
13
- * into a running step trail and flushes it as `status: 'running'` findings,
14
- * so `get_findings` shows live progress before the verdict lands.
12
+ * - **incremental findings** — `onStepFinish` snapshots the shared act trail
13
+ * (`act` records each step as it happens) plus `look`'s visual issues and
14
+ * error-level console rows, and flushes them as `status: 'running'` findings,
15
+ * so `get_findings` streams findings before the verdict lands, and a run that
16
+ * crashes, aborts or hits the step cap keeps everything surfaced so far.
15
17
  *
16
18
  * Adapter-blind and model-blind like the belt: the loop never touches a protocol
17
19
  * or a provider. It is pure over two seams — {@link LoopInbox} (drain) and
@@ -26,8 +28,29 @@ import { z } from 'zod';
26
28
  export const DEFAULT_MAX_STEPS = 30;
27
29
  /** Kickoff turn — the story lives in `instructions`; this nudges the driver to start the loop. */
28
30
  export const KICKOFF_PROMPT = 'Begin. Work toward the goal with observe/act/look, then call report exactly once with your verdict.';
29
- /** The `act` result fields lifted into the step trail: its label and the post-action frame. */
30
- const ActStepSchema = z.object({ label: z.string(), screenshot: z.string() });
31
+ /**
32
+ * The `look` result fields lifted into streamed visual findings: the vision guy's
33
+ * `issues[]` and the frame it judged (see `belt/look.ts`). A SELF-look result (a
34
+ * multimodal driver judging the frame with its own eyes) carries no `issues`, so
35
+ * it contributes nothing here — those issues reach findings via `report`.
36
+ */
37
+ const LookVisualSchema = z.object({
38
+ screenshot: z.string().optional(),
39
+ issues: z
40
+ .array(z.object({
41
+ what: z.string(),
42
+ where: z.string(),
43
+ severity: z.enum(['low', 'medium', 'high']),
44
+ }))
45
+ .default([]),
46
+ });
47
+ /** The `observe` console rows lifted into streamed bugs (see `belt/observe.ts`). */
48
+ const ConsoleObserveSchema = z.object({
49
+ kind: z.literal('console'),
50
+ entries: z
51
+ .array(z.object({ level: z.string(), text: z.string(), location: z.string().optional() }))
52
+ .default([]),
53
+ });
31
54
  /**
32
55
  * `prepareStep`: fold mid-run messages into the next model turn. Drains the inbox
33
56
  * into `standing` — the run-long list of caller instructions — then, while any
@@ -52,6 +75,58 @@ export function foldInstructionsIntoStep(inbox, standing, messages) {
52
75
  };
53
76
  return { messages: [...messages, injected] };
54
77
  }
78
+ /** What a pruned frame collapses to — tells the driver how to get a fresh one. */
79
+ export const STALE_FRAME_NOTE = '[stale frame removed — call look again for a fresh screenshot]';
80
+ /** Whether a tool-result part carries a self-look frame (`content` output with `file-data`). */
81
+ function isLookFrame(part) {
82
+ if (typeof part !== 'object' || part === null)
83
+ return false;
84
+ const p = part;
85
+ return (p.type === 'tool-result' &&
86
+ p.toolName === 'look' &&
87
+ p.output?.type === 'content' &&
88
+ Array.isArray(p.output.value) &&
89
+ p.output.value.some((v) => v?.type === 'file-data'));
90
+ }
91
+ /** Collapse every `file-data` part of a look tool-result to the stale-frame note. */
92
+ function stripFrame(message) {
93
+ if (!Array.isArray(message.content))
94
+ return message;
95
+ const content = message.content.map((part) => {
96
+ if (!isLookFrame(part))
97
+ return part;
98
+ const p = part;
99
+ return {
100
+ ...part,
101
+ output: {
102
+ ...p.output,
103
+ value: p.output.value.map((v) => v?.type === 'file-data' ? { type: 'text', text: STALE_FRAME_NOTE } : v),
104
+ },
105
+ };
106
+ });
107
+ return { ...message, content };
108
+ }
109
+ /**
110
+ * Keep only the NEWEST self-look frame in the transcript. The SDK re-sends every
111
+ * tool result on every step, so each `look` image would otherwise ride along for
112
+ * the rest of the run — N looks × M steps of image tokens. Rebuilt per step in
113
+ * `prepareStep` (overrides never persist), like the instruction fold. Returns the
114
+ * SAME array when there is at most one frame, preserving the no-change fast path.
115
+ */
116
+ export function pruneStaleFrames(messages) {
117
+ const frameIndexes = [];
118
+ messages.forEach((message, index) => {
119
+ if (message.role === 'tool' &&
120
+ Array.isArray(message.content) &&
121
+ message.content.some(isLookFrame)) {
122
+ frameIndexes.push(index);
123
+ }
124
+ });
125
+ if (frameIndexes.length <= 1)
126
+ return messages;
127
+ const stale = new Set(frameIndexes.slice(0, -1));
128
+ return messages.map((message, index) => (stale.has(index) ? stripFrame(message) : message));
129
+ }
55
130
  /** Steps left at or below which the driver is nudged to wrap up and `report`. */
56
131
  export const BUDGET_WARN = 6;
57
132
  /**
@@ -69,42 +144,113 @@ export function budgetNudge(stepNumber, maxSteps) {
69
144
  }
70
145
  return `Step budget almost spent: ~${remaining} of ${maxSteps} steps left. Finish exploring and call \`report\` soon with all findings; an unreported run is wasted.`;
71
146
  }
72
- /** Lift a finished step's `act` results into ordered step-trail entries (each with its frame). */
73
- export function stepTrailFrom(toolResults) {
74
- const steps = [];
147
+ /**
148
+ * Lift a finished step's `look` results into visual findings — each issue the
149
+ * vision guy flagged, carrying the frame it was judged on as evidence.
150
+ */
151
+ export function visualFrom(toolResults) {
152
+ const issues = [];
153
+ for (const result of toolResults) {
154
+ if (result.toolName !== 'look')
155
+ continue;
156
+ const parsed = LookVisualSchema.safeParse(result.output);
157
+ if (!parsed.success)
158
+ continue;
159
+ const { screenshot } = parsed.data;
160
+ for (const issue of parsed.data.issues) {
161
+ issues.push({
162
+ issue: issue.what,
163
+ where: issue.where,
164
+ severity: issue.severity,
165
+ ...(screenshot !== undefined && { screenshot }),
166
+ });
167
+ }
168
+ }
169
+ return issues;
170
+ }
171
+ /**
172
+ * Lift a finished step's `observe` console reads into bugs — ERROR rows only
173
+ * (warn/log/info are working noise, not findings). The console channel is a ring
174
+ * buffer read non-destructively, so a re-read returns rows already lifted;
175
+ * {@link progressForStep} dedupes by message before they land.
176
+ */
177
+ export function consoleBugsFrom(toolResults) {
178
+ const bugs = [];
75
179
  for (const result of toolResults) {
76
- if (result.toolName !== 'act')
180
+ if (result.toolName !== 'observe')
181
+ continue;
182
+ const parsed = ConsoleObserveSchema.safeParse(result.output);
183
+ if (!parsed.success)
77
184
  continue;
78
- const parsed = ActStepSchema.safeParse(result.output);
79
- if (parsed.success) {
80
- steps.push({ step: parsed.data.label, ok: true, screenshot: parsed.data.screenshot });
185
+ for (const entry of parsed.data.entries) {
186
+ if (entry.level !== 'error')
187
+ continue;
188
+ bugs.push({
189
+ kind: 'console',
190
+ detail: entry.text,
191
+ ...(entry.location !== undefined && { evidence: entry.location }),
192
+ });
81
193
  }
82
194
  }
83
- return steps;
195
+ return bugs;
196
+ }
197
+ /** Dedupe key for a streamed finding — its message, case- and whitespace-insensitive. */
198
+ function messageKey(...parts) {
199
+ return parts.join(' @ ').trim().toLowerCase().replace(/\s+/g, ' ');
200
+ }
201
+ /** Append the `fresh` entries whose key is not already present; returns how many landed. */
202
+ function appendNew(into, fresh, key) {
203
+ const seen = new Set(into.map(key));
204
+ let added = 0;
205
+ for (const item of fresh) {
206
+ const k = key(item);
207
+ if (seen.has(k))
208
+ continue;
209
+ seen.add(k);
210
+ into.push(item);
211
+ added += 1;
212
+ }
213
+ return added;
84
214
  }
85
215
  /**
86
216
  * Decide the running-findings write for a finished step. Steps aside for the
87
- * terminal `report` step (it owns the verdict) and for steps that produced no
88
- * `act` results; otherwise appends the fresh trail to `trail` (mutated in place)
89
- * and returns the `running` findings to persist.
217
+ * terminal `report` step (it owns the verdict, and already merged the trail — see
218
+ * `belt/report.ts`); otherwise appends this step's NEW `look` issues and console
219
+ * errors to `running` (mutated in place) and returns the `running` findings to
220
+ * persist — act steps are already on `running.steps`, recorded by `act` itself.
221
+ * `null` when the step surfaced nothing new — no act, and every issue/error
222
+ * already streamed.
90
223
  */
91
- export function progressForStep(step, trail) {
224
+ export function progressForStep(step, running) {
92
225
  if (step.toolCalls.some((call) => call.toolName === 'report'))
93
226
  return null;
94
- const fresh = stepTrailFrom(step.toolResults);
95
- if (fresh.length === 0)
227
+ // Checked against `toolCalls`, NOT `toolResults`: a FAILED act still lands on
228
+ // `running.steps` (`act` records `ok: false` at act time, then rethrows — see
229
+ // `belt/act.ts`), but AI SDK 6 routes a rejected tool call to a `tool-error`
230
+ // content part, never `toolResults` (see `describeStep` above). Gating on
231
+ // `toolResults` would miss every failed act — exactly the step a crashed run
232
+ // most needs preserved — unless the same step happened to also add a bug or
233
+ // visual issue.
234
+ const acted = step.toolCalls.some((call) => call.toolName === 'act');
235
+ const bugs = appendNew(running.bugs, consoleBugsFrom(step.toolResults), (bug) => messageKey(bug.detail));
236
+ const visual = appendNew(running.visual, visualFrom(step.toolResults), (issue) => messageKey(issue.issue, issue.where));
237
+ if (!acted && bugs === 0 && visual === 0)
96
238
  return null;
97
- trail.push(...fresh);
98
- return { status: 'running', steps: [...trail], bugs: [], visual: [] };
239
+ return {
240
+ status: 'running',
241
+ steps: [...running.steps],
242
+ bugs: [...running.bugs],
243
+ visual: [...running.visual],
244
+ };
99
245
  }
100
246
  /** Summarize a finished step for `logs/agent.log`: the tools it called (+ input) + any error text. */
101
247
  export function describeStep(step, index) {
102
248
  const calls = step.toolCalls
103
249
  .map((c) => (c.input !== undefined ? `${c.toolName}(${compactArg(c.input)})` : c.toolName))
104
250
  .join(', ') || '(no tool call)';
105
- const errors = step.toolResults
106
- .filter((r) => isErrorOutput(r.output))
107
- .map((r) => `${r.toolName}: ${errorText(r.output)}`);
251
+ const errors = (step.content ?? [])
252
+ .filter((part) => part.type === 'tool-error')
253
+ .map((part) => `${part.toolName ?? 'tool'}: ${errorText(part.error)}`);
108
254
  const tail = errors.length > 0 ? ` — ERROR ${errors.join('; ')}` : '';
109
255
  return `step ${index}: ${calls}${tail}`;
110
256
  }
@@ -118,21 +264,9 @@ function compactArg(input) {
118
264
  return String(input);
119
265
  }
120
266
  }
121
- /** Whether a tool result output looks like an error envelope (`{ error: ... }` / Error). */
122
- function isErrorOutput(output) {
123
- if (output instanceof Error)
124
- return true;
125
- return typeof output === 'object' && output !== null && 'error' in output;
126
- }
127
- /** Pull a short error string out of a tool result output. */
128
- function errorText(output) {
129
- if (output instanceof Error)
130
- return output.message;
131
- if (typeof output === 'object' && output !== null && 'error' in output) {
132
- const e = output.error;
133
- return e instanceof Error ? e.message : String(e);
134
- }
135
- return String(output);
267
+ /** Pull a short error string out of a `tool-error` part's `error` field. */
268
+ function errorText(error) {
269
+ return error instanceof Error ? error.message : String(error);
136
270
  }
137
271
  /**
138
272
  * Build the debug agent loop. The driver runs `observe`→`act`→`look` until it
@@ -146,29 +280,39 @@ export function createDebugAgent(options) {
146
280
  // Run-long list of mid-run caller instructions: drained from the inbox once,
147
281
  // re-folded into EVERY step's prompt (the SDK never persists a prepareStep override).
148
282
  const standing = [];
283
+ // The running flush's accumulators. `steps` IS the shared act trail (same array
284
+ // the `act` and `report` tools hold — `act` writes it at act time); bugs/visual
285
+ // accumulate here only — they are streamed evidence, and the driver owns the
286
+ // terminal verdict's own arrays.
287
+ const running = { steps: trail, bugs: [], visual: [] };
149
288
  return new ToolLoopAgent({
150
289
  model,
151
290
  tools,
152
291
  instructions,
153
292
  stopWhen: [stepCountIs(maxSteps), hasToolCall('report')],
154
293
  prepareStep: ({ messages, stepNumber }) => {
155
- const withInbox = foldInstructionsIntoStep(inbox, standing, messages);
294
+ // Self-look frame hygiene first: only the newest screenshot stays live.
295
+ const pruned = pruneStaleFrames(messages);
296
+ const withInbox = foldInstructionsIntoStep(inbox, standing, pruned);
297
+ const base = 'messages' in withInbox ? withInbox.messages : pruned;
156
298
  const nudge = budgetNudge(stepNumber, maxSteps);
157
- if (!nudge)
158
- return withInbox;
159
- const base = 'messages' in withInbox ? withInbox.messages : messages;
160
- return { messages: [...base, { role: 'user', content: nudge }] };
299
+ if (nudge)
300
+ return { messages: [...base, { role: 'user', content: nudge }] };
301
+ if (base === messages)
302
+ return {};
303
+ return { messages: base };
161
304
  },
162
305
  onStepFinish: async (step) => {
163
306
  stepIndex += 1;
164
307
  log?.(describeStep(step, stepIndex));
165
- // Append this step's `act` results to the shared trail and flush a running
166
- // snapshot. The terminal `report` step writes its own verdict — with this
167
- // same trail overlaid as `steps` (see `createReportTool`) — so the running
168
- // flush steps aside for it (`progressForStep` returns null on the report step).
169
- const running = progressForStep(step, trail);
170
- if (running)
171
- await progress.writeFindings(running);
308
+ // Stream this step's new `look` issues + console errors and flush a running
309
+ // snapshot of the shared trail (`act` already recorded its own steps there).
310
+ // The terminal `report` step writes its own verdict — with that same trail
311
+ // merged into `steps` (see `createReportTool`) — so the running flush steps
312
+ // aside for it (`progressForStep` returns null on the report step).
313
+ const snapshot = progressForStep(step, running);
314
+ if (snapshot)
315
+ await progress.writeFindings(snapshot);
172
316
  },
173
317
  });
174
318
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,WAAW,EAGX,WAAW,EAEX,aAAa,GACd,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,oGAAoG;AACpG,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,kGAAkG;AAClG,MAAM,CAAC,MAAM,cAAc,GACzB,qGAAqG,CAAC;AA8BxG,+FAA+F;AAC/F,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AAE9E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,wBAAwB,CACtC,KAAgB,EAChB,QAAkB,EAClB,QAAwB;IAExB,QAAQ,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;IAChC,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAiB;QAC7B,IAAI,EAAE,MAAM;QACZ,OAAO,E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ACH,MAAM,UAAU,YAAY,CAAC,OAA4B;IACvD,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,GAAG,cAAc,EAAE,GAAG,OAAO,CAAC;IAChE,OAAO,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC"}
@@ -6,7 +6,8 @@
6
6
  * independently, diffed in review, and swapped without touching the others.
7
7
  *
8
8
  * Composition order:
9
- * 1. Base debug-agent prompt (loop rules, tools, finding shape, verdict)
9
+ * 1. Base debug-agent prompt (loop rules, tools, finding shape, verdict),
10
+ * in the eye mode (`selfLook`) the belt's `look` tool actually runs in
10
11
  * 2. Target addendum (web/desktop/android specifics)
11
12
  * 3. Session story (what the smart agent wants done)
12
13
  * 4. Criteria (optional) (pass/fail rules for this run)
@@ -20,6 +21,13 @@ export interface ComposeOptions {
20
21
  story: string;
21
22
  /** Optional pass/fail criteria. When omitted, agent uses built-in judgment. */
22
23
  criteria?: string[];
24
+ /**
25
+ * Which `look` the belt is wired to — self-look (the driver is multimodal and
26
+ * judges the frame itself) or the separate vision guy. Required, not defaulted:
27
+ * a wrong prompt here tells the driver it cannot see what it can, or to ask a
28
+ * vision model that this run never calls.
29
+ */
30
+ selfLook: boolean;
23
31
  }
24
32
  /**
25
33
  * Compose the full system prompt for a debug-agent session.
@@ -6,13 +6,14 @@
6
6
  * independently, diffed in review, and swapped without touching the others.
7
7
  *
8
8
  * Composition order:
9
- * 1. Base debug-agent prompt (loop rules, tools, finding shape, verdict)
9
+ * 1. Base debug-agent prompt (loop rules, tools, finding shape, verdict),
10
+ * in the eye mode (`selfLook`) the belt's `look` tool actually runs in
10
11
  * 2. Target addendum (web/desktop/android specifics)
11
12
  * 3. Session story (what the smart agent wants done)
12
13
  * 4. Criteria (optional) (pass/fail rules for this run)
13
14
  */
14
15
  import { ANDROID_ADDENDUM_PROMPT } from './android-addendum.js';
15
- import { DEBUG_AGENT_BASE_PROMPT } from './debug-agent.js';
16
+ import { debugAgentPrompt } from './debug-agent.js';
16
17
  import { DESKTOP_ADDENDUM_PROMPT } from './desktop-addendum.js';
17
18
  import { WEB_ADDENDUM_PROMPT } from './web-addendum.js';
18
19
  /** Resolved per-target addendum string. */
@@ -28,7 +29,7 @@ const TARGET_ADDENDA = {
28
29
  * model can orient itself without relying on positional context.
29
30
  */
30
31
  export function composeSystemPrompt(options) {
31
- const { target, story, criteria } = options;
32
+ const { target, story, criteria, selfLook } = options;
32
33
  const addendum = TARGET_ADDENDA[target];
33
34
  const storySection = `\
34
35
  ## Your goal for this session
@@ -45,7 +46,7 @@ Evaluate each one explicitly in your \`report\`:
45
46
  ${criteria.map((c, i) => `${i + 1}. ${c}`).join('\n')}
46
47
  `
47
48
  : '';
48
- return [DEBUG_AGENT_BASE_PROMPT, addendum, storySection, criteriaSection]
49
+ return [debugAgentPrompt(selfLook), addendum, storySection, criteriaSection]
49
50
  .filter((section) => section.length > 0)
50
51
  .join('\n---\n\n');
51
52
  }
@@ -1 +1 @@
1
- {"version":3,"file":"compose.js","sourceRoot":"","sources":["../../../src/agent/prompts/compose.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,mBAAmB,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;AAWF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuB;IACzD,MAAM,EAAE,M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E,GAAG,OAAO,CAAC;IAEtD,MAAM,QAAQ,GAAG,cAAc,CAAC,MAAM,CAAC,CAAC;IAExC,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,YAAY,EAAE,eAAe,CAAC;SACzE,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;SACvC,IAAI,CAAC,WAAW,CAAC,CAAC;AACvB,CAAC"}
@@ -5,5 +5,17 @@
5
5
  * format, and terminal verdict — without assuming any model-specific defaults.
6
6
  * Extended per-target via addenda (see `web-addendum.ts`) and composed with
7
7
  * the session story + criteria via `compose.ts`.
8
+ *
9
+ * ONE body, two eye modes (see `belt/look.ts`):
10
+ * - vision mode — the driver is blind; `look` asks a separate vision model.
11
+ * - self-look mode — control + vision are the SAME multimodal model; `look`
12
+ * attaches the frame to the tool result and the driver judges it itself.
13
+ * Only the paragraphs that would contradict the live tool differ; everything
14
+ * else is shared so the two variants can never drift.
15
+ */
16
+ /**
17
+ * Build the base prompt for one eye mode. `selfLook` must match the `look` tool
18
+ * actually bound to the belt (`session-builder.ts`) — a mismatch tells the driver
19
+ * to ask a vision model that is not there, or that it cannot see what it can.
8
20
  */
9
- export declare const DEBUG_AGENT_BASE_PROMPT = "You are the debug agent \u2014 a fast, blind driver that tests UIs and reports findings.\nYou control the target (browser, desktop, or mobile) through structured tools.\nYou NEVER see pixels directly. When visual judgment is needed, call `look`.\n\n## Your tool belt\n\n- `observe` \u2014 read state: DOM tree, screenshot path, console logs, network requests.\n- `act` \u2014 take action: click, type, key, scroll, navigate, wait.\n- `look` \u2014 ask the vision model to describe/judge a screenshot. Use when you need eyes.\n- `report` \u2014 emit the final structured findings and STOP. Call once; it ends your run.\n\n## Structure-first rule\n\nAlways prefer structured reads over vision:\n1. Use `observe({kind:\"tree\"})` to read DOM / accessibility tree.\n2. Use `observe({kind:\"console\"})` and `observe({kind:\"network\"})` to watch errors.\n3. Call `look` ONLY when visual judgment is needed \u2014 layout, colour, alignment,\n \"does this look right?\", \"is this element centred?\". Vision tokens are expensive.\n\nNever screenshot for information you can read from the tree or logs.\n\n## When to act vs observe\n\n- Start with `observe` to understand the current state.\n- `act` to advance: navigate, click interactive elements, fill inputs.\n- After each `act`, re-`observe` to confirm the effect before acting again.\n- If a step requires visual confirmation (looks good? aligned?), call `look`.\n- Record a visual finding any time `look` surfaces an issue; attach the screenshot path.\n\n## Mid-run instructions\n\nBetween steps, the smart agent may inject new messages. Read them, fold them into\nyour plan, and adapt. They may add work, redirect you, or answer a question.\n\n## What to record at each step\n\nFor every meaningful action or check, record a step entry:\n```\n{ step: \"Clicked Checkout button\", ok: true | false, note: \"...\", screenshot?: \"path\" }\n```\n\n- `ok: false` if the step failed or produced an unexpected result.\n- Attach a screenshot path when evidence matters (errors, visual issues, flows).\n\n## Functional findings (bugs)\n\nCollect bugs as you go. Three kinds:\n\n| kind | when to record |\n|-----------|----------------|\n| `console` | JS errors, unhandled promise rejections, error-level logs |\n| `network` | failed/hung requests (4xx/5xx, timeouts, CORS) |\n| `flow` | dead buttons, wrong navigation, broken flows, data not saved |\n\nEach bug: `{ kind, detail: \"concise description\", evidence?: \"screenshot or log path\" }`\n\n## Visual findings\n\nCollect visual issues discovered via `look`. Each:\n`{ issue: \"what\", where: \"which component/area\", severity: \"low|medium|high\", screenshot?: \"path\" }`\n\nSeverities:\n- `high` \u2014 broken layout, text overlap, invisible interactive elements.\n- `medium` \u2014 misalignment, bad spacing, contrast issue.\n- `low` \u2014 minor polish (rounding, colour shade, icon size).\n\n## Pass / fail verdict\n\nIf `criteria` were given, evaluate each one and set `status:\"passed\"` only when ALL\ncriteria pass. If any criterion fails, set `status:\"failed\"`.\n\nWithout explicit criteria, use your judgment:\n- `passed`: the goal was achieved, no blocking bugs, UI looks acceptable.\n- `failed`: any blocking functional bug OR a high-severity visual issue prevents the goal.\n\n## Terminal `report` call\n\nWhen the goal is complete (or you hit the step limit), call `report` exactly once:\n\n```json\n{\n \"status\": \"passed\" | \"failed\",\n \"steps\": [ { \"step\": \"...\", \"ok\": true, \"note\": \"...\", \"screenshot\": \"...\" } ],\n \"bugs\": [ { \"kind\": \"console\"|\"network\"|\"flow\", \"detail\": \"...\", \"evidence\": \"...\" } ],\n \"visual\": [ { \"issue\": \"...\", \"where\": \"...\", \"severity\": \"low\"|\"medium\"|\"high\", \"screenshot\": \"...\" } ],\n \"summary\": \"One-paragraph verdict the smart agent can act on.\"\n}\n```\n\nDo NOT stop before calling `report`. Do NOT call `report` more than once.\nThe summary is for the smart agent \u2014 make it actionable: what broke, where, what to fix.\n";
21
+ export declare function debugAgentPrompt(selfLook: boolean): string;
@@ -5,26 +5,62 @@
5
5
  * format, and terminal verdict — without assuming any model-specific defaults.
6
6
  * Extended per-target via addenda (see `web-addendum.ts`) and composed with
7
7
  * the session story + criteria via `compose.ts`.
8
+ *
9
+ * ONE body, two eye modes (see `belt/look.ts`):
10
+ * - vision mode — the driver is blind; `look` asks a separate vision model.
11
+ * - self-look mode — control + vision are the SAME multimodal model; `look`
12
+ * attaches the frame to the tool result and the driver judges it itself.
13
+ * Only the paragraphs that would contradict the live tool differ; everything
14
+ * else is shared so the two variants can never drift.
15
+ */
16
+ /** Blind driver + separate vision guy: `look` is a second model call, and it can latch off. */
17
+ const VISION_MODE = {
18
+ eyes: 'You are FAST and BLIND: you NEVER see pixels. When visual judgment is needed, call `look`.',
19
+ belt: '- `look` — ask the vision model to describe/judge a screenshot. Use when you need eyes.',
20
+ cost: 'Vision tokens are expensive.',
21
+ // `createLookExecute` latches on VisionUnavailableError: once a text-only vision
22
+ // model rejects the frame, every later `look` fails fast with the same guidance.
23
+ extraRule: `
24
+ - If \`look\` reports it is unavailable for this run, do not call it again — finish
25
+ the structural checks and state in your report summary that visual checks could
26
+ not be performed (unverified, not passed).`,
27
+ };
28
+ /** Multimodal driver: `look` hands the frame back to it — no vision guy, no latch. */
29
+ const SELF_LOOK_MODE = {
30
+ eyes: 'You are FAST and MULTIMODAL: `look` attaches the current frame to the tool result, and YOU judge it with your own eyes.',
31
+ belt: '- `look` — capture the current screen and judge it yourself; the frame comes back attached.',
32
+ // `pruneStaleFrames` (agent/loop.ts) drops older frames from the re-sent history.
33
+ cost: 'Only the newest frame stays in your context, so judge each one as it arrives.',
34
+ extraRule: '',
35
+ };
36
+ /**
37
+ * Build the base prompt for one eye mode. `selfLook` must match the `look` tool
38
+ * actually bound to the belt (`session-builder.ts`) — a mismatch tells the driver
39
+ * to ask a vision model that is not there, or that it cannot see what it can.
8
40
  */
9
- export const DEBUG_AGENT_BASE_PROMPT = `\
10
- You are the debug agent — a fast, blind driver that tests UIs and reports findings.
41
+ export function debugAgentPrompt(selfLook) {
42
+ const mode = selfLook ? SELF_LOOK_MODE : VISION_MODE;
43
+ return `\
44
+ You are the debug agent — the driver that tests UIs and reports findings.
11
45
  You control the target (browser, desktop, or mobile) through structured tools.
12
- You NEVER see pixels directly. When visual judgment is needed, call \`look\`.
46
+ ${mode.eyes}
13
47
 
14
48
  ## Your tool belt
15
49
 
16
50
  - \`observe\` — read state: DOM tree, screenshot path, console logs, network requests.
17
51
  - \`act\` — take action: click, type, key, scroll, navigate, wait.
18
- - \`look\` — ask the vision model to describe/judge a screenshot. Use when you need eyes.
52
+ ${mode.belt}
19
53
  - \`report\` — emit the final structured findings and STOP. Call once; it ends your run.
20
54
 
21
55
  ## Structure-first rule
22
56
 
23
57
  Always prefer structured reads over vision:
24
58
  1. Use \`observe({kind:"tree"})\` to read DOM / accessibility tree.
25
- 2. Use \`observe({kind:"console"})\` and \`observe({kind:"network"})\` to watch errors.
59
+ 2. Where the target supports them, use \`observe({kind:"console"})\` and
60
+ \`observe({kind:"network"})\` to watch errors.
26
61
  3. Call \`look\` ONLY when visual judgment is needed — layout, colour, alignment,
27
- "does this look right?", "is this element centred?". Vision tokens are expensive.
62
+ "does this look right?", "is this element centred?".
63
+ ${mode.cost}
28
64
 
29
65
  Never screenshot for information you can read from the tree or logs.
30
66
 
@@ -34,7 +70,10 @@ Never screenshot for information you can read from the tree or logs.
34
70
  - \`act\` to advance: navigate, click interactive elements, fill inputs.
35
71
  - After each \`act\`, re-\`observe\` to confirm the effect before acting again.
36
72
  - If a step requires visual confirmation (looks good? aligned?), call \`look\`.
37
- - Record a visual finding any time \`look\` surfaces an issue; attach the screenshot path.
73
+ - Record a visual finding any time a \`look\` turns up an issue; attach the screenshot path.
74
+ - Repeated elements (e.g. several "Add to cart" buttons): test EACH instance and
75
+ report exactly which work and which fail. Never generalize one instance's
76
+ behavior to all of them.${mode.extraRule}
38
77
 
39
78
  ## Mid-run instructions
40
79
 
@@ -99,4 +138,5 @@ When the goal is complete (or you hit the step limit), call \`report\` exactly o
99
138
  Do NOT stop before calling \`report\`. Do NOT call \`report\` more than once.
100
139
  The summary is for the smart agent — make it actionable: what broke, where, what to fix.
101
140
  `;
141
+ }
102
142
  //# sourceMappingURL=debug-agent.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"debug-agent.js","sourceRoot":"","sources":["../../../src/agent/prompts/debug-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4FtC,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;;;;;;;;;;;;;4BAac,IAAI,CAAC,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgEzC,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 the vision guy's read 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 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";
@@ -61,6 +61,6 @@ with \`within\`/\`filters\` and act on what comes back.
61
61
  Record functional bugs (a click that does nothing, a disabled control that should be
62
62
  live, a wrong value) AND visual/UX feedback (misaligned, clipped, low-contrast,
63
63
  cramped). Attach the screenshot path as \`evidence\`. With no console/network to mine,
64
- the a11y tree and the vision guy's read are your only signals — lean on both.
64
+ the a11y tree and what \`look\` reports back are your only signals — lean on both.
65
65
  `;
66
66
  //# sourceMappingURL=desktop-addendum.js.map
@@ -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).\nOne connection reaches everything: the current page, every iframe (including\nout-of-process), all tabs and windows, workers \u2014 plus DOM, console, network,\ninput, and screenshots. Use it deliberately.\n\n### CDP domains and when to reach for each\n\n| Domain | What it gives you | Use via |\n|-------------|-------------------|---------|\n| `Target` | enumerate/switch tabs and frames | `observe({kind:\"tree\"})` with `within` to scope to a frame |\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| `Runtime` | evaluate JS in a context (e.g. read a value not in the DOM) | `observe({kind:\"tree\", query:\"Runtime.evaluate:...\"})` |\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\"})` proactively after\n each meaningful action \u2014 errors land there before they surface visually.\n4. Only after the tree gives you no answer: call `look` for pixels.\n\n### Multi-frame / tab navigation\n\nIf the goal involves an iframe or a new tab:\n- Enumerate frames via the Target domain (use `observe` with appropriate scope).\n- Switch context to the target frame/tab before acting inside it.\n- After navigation, wait for the page to settle before reading state.\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. `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 watch always\n\nAfter every `act`, immediately:\n1. Check `observe({kind:\"console\"})` for JS errors or warnings.\n2. Check `observe({kind:\"network\"})` for failed requests (4xx/5xx).\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";
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### 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";