@developerz.ai/ui-debugger-mcp 1.1.0 → 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.
- package/README.md +22 -10
- package/dist/adapters/android/adb.d.ts +34 -5
- package/dist/adapters/android/adb.js +74 -20
- package/dist/adapters/android/adb.js.map +1 -1
- package/dist/adapters/android/android-adapter.d.ts +23 -7
- package/dist/adapters/android/android-adapter.js +106 -36
- package/dist/adapters/android/android-adapter.js.map +1 -1
- package/dist/adapters/android/android-adapter.test-helpers.d.ts +52 -0
- package/dist/adapters/android/android-adapter.test-helpers.js +115 -0
- package/dist/adapters/android/android-adapter.test-helpers.js.map +1 -0
- package/dist/adapters/android/commands.d.ts +27 -4
- package/dist/adapters/android/commands.js +66 -4
- package/dist/adapters/android/commands.js.map +1 -1
- package/dist/adapters/android/ports.d.ts +32 -0
- package/dist/adapters/android/ports.js +47 -0
- package/dist/adapters/android/ports.js.map +1 -0
- package/dist/adapters/android/uiautomator.d.ts +10 -2
- package/dist/adapters/android/uiautomator.js +36 -4
- package/dist/adapters/android/uiautomator.js.map +1 -1
- package/dist/adapters/browser/browser-adapter.d.ts +14 -13
- package/dist/adapters/browser/browser-adapter.js +69 -306
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.js +18 -11
- package/dist/adapters/browser/cdp.js.map +1 -1
- package/dist/adapters/browser/extractor.d.ts +49 -0
- package/dist/adapters/browser/extractor.js +208 -0
- package/dist/adapters/browser/extractor.js.map +1 -0
- package/dist/adapters/browser/filters.d.ts +15 -0
- package/dist/adapters/browser/filters.js +93 -0
- package/dist/adapters/browser/filters.js.map +1 -0
- package/dist/adapters/browser/launch.d.ts +41 -0
- package/dist/adapters/browser/launch.js +61 -0
- package/dist/adapters/browser/launch.js.map +1 -0
- package/dist/adapters/budget.d.ts +16 -0
- package/dist/adapters/budget.js +25 -0
- package/dist/adapters/budget.js.map +1 -0
- package/dist/adapters/contract.d.ts +13 -6
- package/dist/adapters/desktop/atspi.d.ts +15 -0
- package/dist/adapters/desktop/atspi.js +37 -17
- package/dist/adapters/desktop/atspi.js.map +1 -1
- package/dist/adapters/desktop/capture.js +8 -1
- package/dist/adapters/desktop/capture.js.map +1 -1
- package/dist/adapters/desktop/desktop-adapter.d.ts +9 -2
- package/dist/adapters/desktop/desktop-adapter.js +84 -32
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
- package/dist/adapters/desktop/input.d.ts +16 -1
- package/dist/adapters/desktop/input.js +30 -0
- package/dist/adapters/desktop/input.js.map +1 -1
- package/dist/adapters/desktop/proc.d.ts +18 -3
- package/dist/adapters/desktop/proc.js +48 -5
- package/dist/adapters/desktop/proc.js.map +1 -1
- package/dist/adapters/factory.d.ts +3 -1
- package/dist/adapters/factory.js +6 -2
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/limit.d.ts +10 -0
- package/dist/adapters/limit.js +19 -0
- package/dist/adapters/limit.js.map +1 -0
- package/dist/agent/belt/act.d.ts +27 -5
- package/dist/agent/belt/act.js +75 -17
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +29 -15
- package/dist/agent/belt/observe.js +74 -19
- package/dist/agent/belt/observe.js.map +1 -1
- package/dist/agent/belt/report.d.ts +29 -9
- package/dist/agent/belt/report.js +77 -10
- package/dist/agent/belt/report.js.map +1 -1
- package/dist/agent/belt/trail.d.ts +34 -0
- package/dist/agent/belt/trail.js +64 -0
- package/dist/agent/belt/trail.js.map +1 -0
- package/dist/agent/capabilities.d.ts +4 -4
- package/dist/agent/capabilities.js +38 -13
- package/dist/agent/capabilities.js.map +1 -1
- package/dist/agent/loop.d.ts +58 -19
- package/dist/agent/loop.js +134 -46
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/prompts/compose.d.ts +9 -1
- package/dist/agent/prompts/compose.js +5 -4
- package/dist/agent/prompts/compose.js.map +1 -1
- package/dist/agent/prompts/debug-agent.d.ts +13 -1
- package/dist/agent/prompts/debug-agent.js +45 -11
- package/dist/agent/prompts/debug-agent.js.map +1 -1
- package/dist/agent/prompts/desktop-addendum.d.ts +1 -1
- package/dist/agent/prompts/desktop-addendum.js +1 -1
- package/dist/agent/prompts/web-addendum.d.ts +1 -1
- package/dist/agent/prompts/web-addendum.js +16 -18
- package/dist/agent/prompts/web-addendum.js.map +1 -1
- package/dist/cli/control.d.ts +3 -1
- package/dist/cli/control.js +26 -40
- package/dist/cli/control.js.map +1 -1
- package/dist/cli/help.d.ts +3 -1
- package/dist/cli/help.js +6 -2
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/init.d.ts +3 -6
- package/dist/cli/init.js +64 -16
- package/dist/cli/init.js.map +1 -1
- package/dist/config/load.js +8 -1
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +12 -5
- package/dist/config/schema.js +17 -7
- package/dist/config/schema.js.map +1 -1
- package/dist/errors.d.ts +14 -2
- package/dist/errors.js +24 -4
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/main.js +22 -8
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.d.ts +16 -1
- package/dist/mcp/server.js +23 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/server.test-helpers.d.ts +23 -0
- package/dist/mcp/server.test-helpers.js +49 -0
- package/dist/mcp/server.test-helpers.js.map +1 -0
- package/dist/mcp/tools/describe.js +5 -0
- package/dist/mcp/tools/describe.js.map +1 -1
- package/dist/mcp/tools/end-session.js +5 -0
- package/dist/mcp/tools/end-session.js.map +1 -1
- package/dist/mcp/tools/get-findings.js +23 -3
- package/dist/mcp/tools/get-findings.js.map +1 -1
- package/dist/mcp/tools/output.d.ts +50 -0
- package/dist/mcp/tools/output.js +55 -0
- package/dist/mcp/tools/output.js.map +1 -0
- package/dist/mcp/tools/result.d.ts +24 -1
- package/dist/mcp/tools/result.js +106 -5
- package/dist/mcp/tools/result.js.map +1 -1
- package/dist/mcp/tools/send-message.js +5 -0
- package/dist/mcp/tools/send-message.js.map +1 -1
- package/dist/mcp/tools/start-debug.js +7 -1
- package/dist/mcp/tools/start-debug.js.map +1 -1
- package/dist/services/debug-service.d.ts +38 -6
- package/dist/services/debug-service.js +122 -13
- package/dist/services/debug-service.js.map +1 -1
- package/dist/services/session-builder.d.ts +20 -3
- package/dist/services/session-builder.js +43 -13
- package/dist/services/session-builder.js.map +1 -1
- package/dist/session/atomic-write.d.ts +24 -0
- package/dist/session/atomic-write.js +39 -0
- package/dist/session/atomic-write.js.map +1 -0
- package/dist/session/findings-store.js +3 -4
- package/dist/session/findings-store.js.map +1 -1
- package/dist/session/process-identity.d.ts +16 -0
- package/dist/session/process-identity.js +29 -0
- package/dist/session/process-identity.js.map +1 -1
- package/dist/session/session.js +10 -2
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +51 -5
- package/dist/session/state-file.js +60 -8
- package/dist/session/state-file.js.map +1 -1
- package/dist/session/workspace.d.ts +11 -0
- package/dist/session/workspace.js +14 -1
- package/dist/session/workspace.js.map +1 -1
- package/package.json +4 -1
package/dist/agent/loop.d.ts
CHANGED
|
@@ -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`
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
|
@@ -21,7 +23,7 @@
|
|
|
21
23
|
* aborted run rejects loud (wired to `end_session`), never a silent half-finish.
|
|
22
24
|
*/
|
|
23
25
|
import { type LanguageModel, type ModelMessage, type Tool, ToolLoopAgent } from 'ai';
|
|
24
|
-
import type { Findings, Step } from '../findings/schema.js';
|
|
26
|
+
import type { Bug, Findings, Step, VisualIssue } from '../findings/schema.js';
|
|
25
27
|
/** Safety cap on driver steps before the loop force-stops (paired with `hasToolCall('report')`). */
|
|
26
28
|
export declare const DEFAULT_MAX_STEPS = 30;
|
|
27
29
|
/** Kickoff turn — the story lives in `instructions`; this nudges the driver to start the loop. */
|
|
@@ -43,18 +45,30 @@ export interface ProgressWriter {
|
|
|
43
45
|
/** Validate + write the current (running) findings; returns the path written. */
|
|
44
46
|
writeFindings(findings: Findings): Promise<string>;
|
|
45
47
|
}
|
|
46
|
-
/** The slice of a finished step the running flush reads — `
|
|
48
|
+
/** The slice of a finished step the running flush reads — `look`/`observe` outputs + what ran. */
|
|
47
49
|
export interface FinishedStep {
|
|
48
50
|
/** Tools called this step; a `report` call marks the terminal step (verdict owned elsewhere). */
|
|
49
51
|
toolCalls: ReadonlyArray<{
|
|
50
52
|
toolName: string;
|
|
51
53
|
input?: unknown;
|
|
52
54
|
}>;
|
|
53
|
-
/** Tool results this step; `
|
|
55
|
+
/** Tool results this step; `look`/`observe` outputs become streamed findings. */
|
|
54
56
|
toolResults: ReadonlyArray<{
|
|
55
57
|
toolName: string;
|
|
56
58
|
output: unknown;
|
|
57
59
|
}>;
|
|
60
|
+
/**
|
|
61
|
+
* Raw step content, AI SDK 6 shape — a *rejected* tool call lands here as a
|
|
62
|
+
* `tool-error` part, never in {@link toolResults} (that array only ever holds
|
|
63
|
+
* successful `tool-result` parts). Optional so hand-built test fixtures that
|
|
64
|
+
* never fail a tool call can omit it; `describeStep` treats an absent array as
|
|
65
|
+
* "no errors" rather than throwing.
|
|
66
|
+
*/
|
|
67
|
+
content?: ReadonlyArray<{
|
|
68
|
+
type: string;
|
|
69
|
+
toolName?: string;
|
|
70
|
+
error?: unknown;
|
|
71
|
+
}>;
|
|
58
72
|
}
|
|
59
73
|
/**
|
|
60
74
|
* `prepareStep`: fold mid-run messages into the next model turn. Drains the inbox
|
|
@@ -90,18 +104,43 @@ export declare const BUDGET_WARN = 6;
|
|
|
90
104
|
* budget. `stepNumber` is the 0-based index of the step about to run.
|
|
91
105
|
*/
|
|
92
106
|
export declare function budgetNudge(stepNumber: number, maxSteps: number): string | null;
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
107
|
+
/**
|
|
108
|
+
* Lift a finished step's `look` results into visual findings — each issue the
|
|
109
|
+
* vision guy flagged, carrying the frame it was judged on as evidence.
|
|
110
|
+
*/
|
|
111
|
+
export declare function visualFrom(toolResults: FinishedStep['toolResults']): VisualIssue[];
|
|
112
|
+
/**
|
|
113
|
+
* Lift a finished step's `observe` console reads into bugs — ERROR rows only
|
|
114
|
+
* (warn/log/info are working noise, not findings). The console channel is a ring
|
|
115
|
+
* buffer read non-destructively, so a re-read returns rows already lifted;
|
|
116
|
+
* {@link progressForStep} dedupes by message before they land.
|
|
117
|
+
*/
|
|
118
|
+
export declare function consoleBugsFrom(toolResults: FinishedStep['toolResults']): Bug[];
|
|
119
|
+
/**
|
|
120
|
+
* The run-long accumulators the running flush reads: the shared act-`steps` trail
|
|
121
|
+
* (the SAME array the `act` and `report` tools hold) plus the findings streamed off
|
|
122
|
+
* the belt — `look`'s visual issues and error-level console rows. Streaming those
|
|
123
|
+
* is what keeps a crashed, aborted or step-capped run's findings file complete;
|
|
124
|
+
* before, they lived only in model context until `report`.
|
|
125
|
+
*/
|
|
126
|
+
export interface RunTrail {
|
|
127
|
+
/** Ordered act trail, written by `act` as each act finishes (shared with `report`). */
|
|
128
|
+
steps: Step[];
|
|
129
|
+
/** Console bugs seen so far, deduped by message. */
|
|
130
|
+
bugs: Bug[];
|
|
131
|
+
/** Visual issues seen so far, deduped by issue + location. */
|
|
132
|
+
visual: VisualIssue[];
|
|
133
|
+
}
|
|
98
134
|
/**
|
|
99
135
|
* Decide the running-findings write for a finished step. Steps aside for the
|
|
100
|
-
* terminal `report` step (it owns the verdict
|
|
101
|
-
* `
|
|
102
|
-
* and returns the `running` findings to
|
|
136
|
+
* terminal `report` step (it owns the verdict, and already merged the trail — see
|
|
137
|
+
* `belt/report.ts`); otherwise appends this step's NEW `look` issues and console
|
|
138
|
+
* errors to `running` (mutated in place) and returns the `running` findings to
|
|
139
|
+
* persist — act steps are already on `running.steps`, recorded by `act` itself.
|
|
140
|
+
* `null` when the step surfaced nothing new — no act, and every issue/error
|
|
141
|
+
* already streamed.
|
|
103
142
|
*/
|
|
104
|
-
export declare function progressForStep(step: FinishedStep,
|
|
143
|
+
export declare function progressForStep(step: FinishedStep, running: RunTrail): Findings | null;
|
|
105
144
|
/** Everything the loop needs to run one debug session. */
|
|
106
145
|
export interface DebugAgentOptions {
|
|
107
146
|
/** fast guy — the blind text driver running the high-frequency click loop. */
|
|
@@ -117,10 +156,10 @@ export interface DebugAgentOptions {
|
|
|
117
156
|
/** Optional sink for a human-readable step trail (`logs/agent.log`). */
|
|
118
157
|
log?: AgentLog;
|
|
119
158
|
/**
|
|
120
|
-
* Shared act-trail the running flush
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
159
|
+
* Shared act-trail the `act` tool writes, the running flush snapshots and the
|
|
160
|
+
* `report` tool merges into the verdict's `steps` — pass the SAME array the
|
|
161
|
+
* belt's act trail holds so the write and its counts agree. Defaults to a fresh
|
|
162
|
+
* array (an unwired loop then flushes no steps).
|
|
124
163
|
*/
|
|
125
164
|
trail?: Step[];
|
|
126
165
|
/** Step safety cap; defaults to {@link DEFAULT_MAX_STEPS}. */
|
package/dist/agent/loop.js
CHANGED
|
@@ -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`
|
|
13
|
-
*
|
|
14
|
-
*
|
|
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
|
-
/**
|
|
30
|
-
|
|
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
|
|
@@ -121,42 +144,113 @@ export function budgetNudge(stepNumber, maxSteps) {
|
|
|
121
144
|
}
|
|
122
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.`;
|
|
123
146
|
}
|
|
124
|
-
/**
|
|
125
|
-
|
|
126
|
-
|
|
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 = [];
|
|
127
179
|
for (const result of toolResults) {
|
|
128
|
-
if (result.toolName !== '
|
|
180
|
+
if (result.toolName !== 'observe')
|
|
181
|
+
continue;
|
|
182
|
+
const parsed = ConsoleObserveSchema.safeParse(result.output);
|
|
183
|
+
if (!parsed.success)
|
|
129
184
|
continue;
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
|
|
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
|
+
});
|
|
133
193
|
}
|
|
134
194
|
}
|
|
135
|
-
return
|
|
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;
|
|
136
214
|
}
|
|
137
215
|
/**
|
|
138
216
|
* Decide the running-findings write for a finished step. Steps aside for the
|
|
139
|
-
* terminal `report` step (it owns the verdict
|
|
140
|
-
* `
|
|
141
|
-
* and returns the `running` findings to
|
|
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.
|
|
142
223
|
*/
|
|
143
|
-
export function progressForStep(step,
|
|
224
|
+
export function progressForStep(step, running) {
|
|
144
225
|
if (step.toolCalls.some((call) => call.toolName === 'report'))
|
|
145
226
|
return null;
|
|
146
|
-
|
|
147
|
-
|
|
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)
|
|
148
238
|
return null;
|
|
149
|
-
|
|
150
|
-
|
|
239
|
+
return {
|
|
240
|
+
status: 'running',
|
|
241
|
+
steps: [...running.steps],
|
|
242
|
+
bugs: [...running.bugs],
|
|
243
|
+
visual: [...running.visual],
|
|
244
|
+
};
|
|
151
245
|
}
|
|
152
246
|
/** Summarize a finished step for `logs/agent.log`: the tools it called (+ input) + any error text. */
|
|
153
247
|
export function describeStep(step, index) {
|
|
154
248
|
const calls = step.toolCalls
|
|
155
249
|
.map((c) => (c.input !== undefined ? `${c.toolName}(${compactArg(c.input)})` : c.toolName))
|
|
156
250
|
.join(', ') || '(no tool call)';
|
|
157
|
-
const errors = step.
|
|
158
|
-
.filter((
|
|
159
|
-
.map((
|
|
251
|
+
const errors = (step.content ?? [])
|
|
252
|
+
.filter((part) => part.type === 'tool-error')
|
|
253
|
+
.map((part) => `${part.toolName ?? 'tool'}: ${errorText(part.error)}`);
|
|
160
254
|
const tail = errors.length > 0 ? ` — ERROR ${errors.join('; ')}` : '';
|
|
161
255
|
return `step ${index}: ${calls}${tail}`;
|
|
162
256
|
}
|
|
@@ -170,21 +264,9 @@ function compactArg(input) {
|
|
|
170
264
|
return String(input);
|
|
171
265
|
}
|
|
172
266
|
}
|
|
173
|
-
/**
|
|
174
|
-
function
|
|
175
|
-
|
|
176
|
-
return true;
|
|
177
|
-
return typeof output === 'object' && output !== null && 'error' in output;
|
|
178
|
-
}
|
|
179
|
-
/** Pull a short error string out of a tool result output. */
|
|
180
|
-
function errorText(output) {
|
|
181
|
-
if (output instanceof Error)
|
|
182
|
-
return output.message;
|
|
183
|
-
if (typeof output === 'object' && output !== null && 'error' in output) {
|
|
184
|
-
const e = output.error;
|
|
185
|
-
return e instanceof Error ? e.message : String(e);
|
|
186
|
-
}
|
|
187
|
-
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);
|
|
188
270
|
}
|
|
189
271
|
/**
|
|
190
272
|
* Build the debug agent loop. The driver runs `observe`→`act`→`look` until it
|
|
@@ -198,6 +280,11 @@ export function createDebugAgent(options) {
|
|
|
198
280
|
// Run-long list of mid-run caller instructions: drained from the inbox once,
|
|
199
281
|
// re-folded into EVERY step's prompt (the SDK never persists a prepareStep override).
|
|
200
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: [] };
|
|
201
288
|
return new ToolLoopAgent({
|
|
202
289
|
model,
|
|
203
290
|
tools,
|
|
@@ -218,13 +305,14 @@ export function createDebugAgent(options) {
|
|
|
218
305
|
onStepFinish: async (step) => {
|
|
219
306
|
stepIndex += 1;
|
|
220
307
|
log?.(describeStep(step, stepIndex));
|
|
221
|
-
//
|
|
222
|
-
// snapshot
|
|
223
|
-
//
|
|
224
|
-
//
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
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);
|
|
228
316
|
},
|
|
229
317
|
});
|
|
230
318
|
}
|
package/dist/agent/loop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;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;AAsCxG;;;;;GAKG;A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AO,EAAE,CAAC;YACjC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QAC5B,CAAC;QACD,YAAY,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE;YAC3B,SAAS,IAAI,CAAC,CAAC;YACf,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;YACrC,4EAA4E;YAC5E,6EAA6E;YAC7E,2EAA2E;YAC3E,4EAA4E;YAC5E,oEAAoE;YACpE,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAChD,IAAI,QAAQ;gBAAE,MAAM,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACvD,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAYD;;;;GAIG;AACH,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 {
|
|
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 [
|
|
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
|
|
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,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;AAkBF;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAuB;IACzD,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,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
|
|
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
|
|
10
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
|
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?".
|
|
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,13 +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\`
|
|
73
|
+
- Record a visual finding any time a \`look\` turns up an issue; attach the screenshot path.
|
|
38
74
|
- Repeated elements (e.g. several "Add to cart" buttons): test EACH instance and
|
|
39
75
|
report exactly which work and which fail. Never generalize one instance's
|
|
40
|
-
behavior to all of them.
|
|
41
|
-
- If \`look\` reports it is unavailable for this run, do not call it again — finish
|
|
42
|
-
the structural checks and state in your report summary that visual checks could
|
|
43
|
-
not be performed (unverified, not passed).
|
|
76
|
+
behavior to all of them.${mode.extraRule}
|
|
44
77
|
|
|
45
78
|
## Mid-run instructions
|
|
46
79
|
|
|
@@ -105,4 +138,5 @@ When the goal is complete (or you hit the step limit), call \`report\` exactly o
|
|
|
105
138
|
Do NOT stop before calling \`report\`. Do NOT call \`report\` more than once.
|
|
106
139
|
The summary is for the smart agent — make it actionable: what broke, where, what to fix.
|
|
107
140
|
`;
|
|
141
|
+
}
|
|
108
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
|
|
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
|
|
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";
|