@developerz.ai/ui-debugger-mcp 1.10.0 → 1.11.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 +9 -5
- package/dist/adapters/android/abortable.d.ts +6 -0
- package/dist/adapters/android/abortable.js +22 -0
- package/dist/adapters/android/abortable.js.map +1 -0
- package/dist/adapters/android/android-adapter.d.ts +7 -39
- package/dist/adapters/android/android-adapter.js +54 -436
- package/dist/adapters/android/android-adapter.js.map +1 -1
- package/dist/adapters/android/commands.d.ts +10 -0
- package/dist/adapters/android/commands.js +22 -0
- package/dist/adapters/android/commands.js.map +1 -1
- package/dist/adapters/android/emulator.d.ts +41 -0
- package/dist/adapters/android/emulator.js +115 -0
- package/dist/adapters/android/emulator.js.map +1 -0
- package/dist/adapters/android/logcat.d.ts +87 -0
- package/dist/adapters/android/logcat.js +352 -0
- package/dist/adapters/android/logcat.js.map +1 -0
- package/dist/adapters/browser/browser-adapter.js +30 -42
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.d.ts +7 -10
- package/dist/adapters/browser/cdp.js +93 -69
- package/dist/adapters/browser/cdp.js.map +1 -1
- package/dist/adapters/browser/exchange-read.d.ts +39 -0
- package/dist/adapters/browser/exchange-read.js +102 -0
- package/dist/adapters/browser/exchange-read.js.map +1 -0
- package/dist/adapters/browser/extractor.js +9 -2
- package/dist/adapters/browser/extractor.js.map +1 -1
- package/dist/adapters/browser/lifecycle.d.ts +33 -0
- package/dist/adapters/browser/lifecycle.js +47 -4
- package/dist/adapters/browser/lifecycle.js.map +1 -1
- package/dist/adapters/browser/locate.d.ts +18 -2
- package/dist/adapters/browser/locate.js +48 -3
- package/dist/adapters/browser/locate.js.map +1 -1
- package/dist/adapters/browser/log-filters.d.ts +1 -1
- package/dist/adapters/browser/log-filters.js +15 -4
- package/dist/adapters/browser/log-filters.js.map +1 -1
- package/dist/adapters/browser/log-format.d.ts +12 -0
- package/dist/adapters/browser/log-format.js +123 -7
- package/dist/adapters/browser/log-format.js.map +1 -1
- package/dist/adapters/contract.d.ts +22 -5
- package/dist/adapters/desktop/atspi-busctl.js +3 -1
- package/dist/adapters/desktop/atspi-busctl.js.map +1 -1
- package/dist/adapters/desktop/atspi.d.ts +6 -0
- package/dist/adapters/desktop/atspi.js.map +1 -1
- package/dist/adapters/desktop/desktop-adapter.d.ts +2 -0
- package/dist/adapters/desktop/desktop-adapter.js +132 -98
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
- package/dist/adapters/desktop/input.d.ts +1 -1
- package/dist/adapters/desktop/input.js +14 -3
- package/dist/adapters/desktop/input.js.map +1 -1
- package/dist/adapters/desktop/managed-app.d.ts +43 -0
- package/dist/adapters/desktop/managed-app.js +114 -0
- package/dist/adapters/desktop/managed-app.js.map +1 -0
- package/dist/adapters/desktop/proc.d.ts +2 -0
- package/dist/adapters/desktop/proc.js +4 -0
- package/dist/adapters/desktop/proc.js.map +1 -1
- package/dist/adapters/desktop/wait-poll.d.ts +17 -0
- package/dist/adapters/desktop/wait-poll.js +38 -0
- package/dist/adapters/desktop/wait-poll.js.map +1 -0
- package/dist/adapters/factory.d.ts +1 -1
- package/dist/adapters/factory.js +1 -1
- package/dist/adapters/log-format.d.ts +6 -0
- package/dist/adapters/log-format.js +10 -2
- package/dist/adapters/log-format.js.map +1 -1
- package/dist/agent/belt/act.d.ts +6 -3
- package/dist/agent/belt/act.js +40 -60
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +9 -3
- package/dist/agent/belt/look.js +21 -5
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +9 -43
- package/dist/agent/belt/observe.js +66 -242
- package/dist/agent/belt/observe.js.map +1 -1
- package/dist/agent/belt/redact-output.d.ts +20 -0
- package/dist/agent/belt/redact-output.js +70 -0
- package/dist/agent/belt/redact-output.js.map +1 -0
- package/dist/agent/belt/same-origin.d.ts +21 -0
- package/dist/agent/belt/same-origin.js +38 -0
- package/dist/agent/belt/same-origin.js.map +1 -0
- package/dist/agent/belt/target-refs.d.ts +39 -0
- package/dist/agent/belt/target-refs.js +60 -0
- package/dist/agent/belt/target-refs.js.map +1 -0
- package/dist/agent/belt/tree-targets.d.ts +79 -0
- package/dist/agent/belt/tree-targets.js +242 -0
- package/dist/agent/belt/tree-targets.js.map +1 -0
- package/dist/agent/loop-frames.d.ts +26 -0
- package/dist/agent/loop-frames.js +106 -0
- package/dist/agent/loop-frames.js.map +1 -0
- package/dist/agent/loop.d.ts +13 -24
- package/dist/agent/loop.js +40 -104
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/prompts/debug-agent.js +3 -2
- package/dist/agent/prompts/debug-agent.js.map +1 -1
- package/dist/agent/prompts/web-addendum.d.ts +2 -2
- package/dist/agent/prompts/web-addendum.js +21 -32
- package/dist/agent/prompts/web-addendum.js.map +1 -1
- package/dist/agent/provider.d.ts +3 -1
- package/dist/agent/provider.js +4 -2
- package/dist/agent/provider.js.map +1 -1
- package/dist/boot.js +3 -1
- package/dist/boot.js.map +1 -1
- package/dist/cli/chromium-libs.d.ts +6 -1
- package/dist/cli/chromium-libs.js +27 -3
- package/dist/cli/chromium-libs.js.map +1 -1
- package/dist/cli/control.js +30 -5
- package/dist/cli/control.js.map +1 -1
- package/dist/config/load.js +10 -0
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.js +12 -10
- package/dist/config/schema.js.map +1 -1
- package/dist/errors.d.ts +17 -16
- package/dist/errors.js +33 -32
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mcp/server.js +10 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/end-session.js +2 -1
- package/dist/mcp/tools/end-session.js.map +1 -1
- package/dist/mcp/tools/output.d.ts +7 -0
- package/dist/mcp/tools/output.js +5 -0
- package/dist/mcp/tools/output.js.map +1 -1
- package/dist/mcp/tools/result.js +4 -1
- package/dist/mcp/tools/result.js.map +1 -1
- package/dist/redact.d.ts +20 -4
- package/dist/redact.js +134 -19
- package/dist/redact.js.map +1 -1
- package/dist/services/auth-persona.d.ts +19 -0
- package/dist/services/auth-persona.js +32 -0
- package/dist/services/auth-persona.js.map +1 -0
- package/dist/services/debug-api.d.ts +7 -0
- package/dist/services/debug-service.d.ts +1 -1
- package/dist/services/debug-service.js +64 -65
- package/dist/services/debug-service.js.map +1 -1
- package/dist/services/foreign-findings.d.ts +22 -0
- package/dist/services/foreign-findings.js +38 -0
- package/dist/services/foreign-findings.js.map +1 -0
- package/dist/services/login-failure.d.ts +10 -0
- package/dist/services/login-failure.js +24 -0
- package/dist/services/login-failure.js.map +1 -0
- package/dist/services/login-selectors.d.ts +18 -0
- package/dist/services/login-selectors.js +44 -0
- package/dist/services/login-selectors.js.map +1 -0
- package/dist/services/login-session.d.ts +25 -0
- package/dist/services/login-session.js +59 -0
- package/dist/services/login-session.js.map +1 -0
- package/dist/services/login.d.ts +9 -27
- package/dist/services/login.js +78 -80
- package/dist/services/login.js.map +1 -1
- package/dist/services/replay.js +15 -3
- package/dist/services/replay.js.map +1 -1
- package/dist/services/session-builder.js +19 -4
- package/dist/services/session-builder.js.map +1 -1
- package/dist/services/shutdown.d.ts +8 -4
- package/dist/services/shutdown.js +21 -8
- package/dist/services/shutdown.js.map +1 -1
- package/dist/services/start-guards.d.ts +6 -1
- package/dist/services/start-guards.js +13 -2
- package/dist/services/start-guards.js.map +1 -1
- package/dist/session/cleanup.d.ts +3 -2
- package/dist/session/cleanup.js +6 -2
- package/dist/session/cleanup.js.map +1 -1
- package/dist/session/finalize.d.ts +45 -0
- package/dist/session/finalize.js +150 -0
- package/dist/session/finalize.js.map +1 -0
- package/dist/session/flock-backend.d.ts +117 -0
- package/dist/session/flock-backend.js +293 -0
- package/dist/session/flock-backend.js.map +1 -0
- package/dist/session/owner-lock.d.ts +4 -95
- package/dist/session/owner-lock.js +7 -288
- package/dist/session/owner-lock.js.map +1 -1
- package/dist/session/session.js +11 -134
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.js +9 -1
- package/dist/session/state-file.js.map +1 -1
- package/dist/session/workspace.d.ts +32 -2
- package/dist/session/workspace.js +65 -4
- package/dist/session/workspace.js.map +1 -1
- package/package.json +8 -8
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-look frame hygiene for the debug loop's transcript.
|
|
3
|
+
*
|
|
4
|
+
* A multimodal driver's `look` returns the screenshot itself, and the SDK
|
|
5
|
+
* re-sends every tool result on every step — so each frame would ride along for
|
|
6
|
+
* the rest of the run. {@link pruneStaleFrames} keeps only the newest one live;
|
|
7
|
+
* the loop applies it per step in `prepareStep` (`loop.ts`).
|
|
8
|
+
*/
|
|
9
|
+
/** What a pruned frame collapses to — tells the driver how to get a fresh one. */
|
|
10
|
+
export const STALE_FRAME_NOTE = '[stale frame removed — call look again for a fresh screenshot]';
|
|
11
|
+
/** The content parts of a message as a plain array (empty for string content). */
|
|
12
|
+
function partsOf(message) {
|
|
13
|
+
return Array.isArray(message.content) ? message.content : [];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Every self-look frame in the transcript, in transcript order (message →
|
|
17
|
+
* content part → output value).
|
|
18
|
+
*
|
|
19
|
+
* A frame is ONE `file` value part of a look tool-result. AI SDK 6 puts ALL
|
|
20
|
+
* of a step's tool results into ONE `tool`-role message, so a step that called
|
|
21
|
+
* `look` twice carries TWO frames inside a SINGLE message — counting messages
|
|
22
|
+
* instead of frames let both survive and stacked the driver's images.
|
|
23
|
+
*/
|
|
24
|
+
function findFrames(messages) {
|
|
25
|
+
const frames = [];
|
|
26
|
+
messages.forEach((message, messageIndex) => {
|
|
27
|
+
partsOf(message).forEach((part, partIndex) => {
|
|
28
|
+
// A content array may hold a null/undefined part — skip it instead of
|
|
29
|
+
// dereferencing it and killing the whole run inside `prepareStep`.
|
|
30
|
+
if (typeof part !== 'object' || part === null)
|
|
31
|
+
return;
|
|
32
|
+
const p = part;
|
|
33
|
+
if (p.type !== 'tool-result' || p.toolName !== 'look')
|
|
34
|
+
return;
|
|
35
|
+
const output = p.output;
|
|
36
|
+
if (output?.type !== 'content')
|
|
37
|
+
return;
|
|
38
|
+
const values = output.value;
|
|
39
|
+
if (!Array.isArray(values))
|
|
40
|
+
return;
|
|
41
|
+
values.forEach((value, valueIndex) => {
|
|
42
|
+
if (value?.type === 'file') {
|
|
43
|
+
frames.push({ messageIndex, partIndex, valueIndex });
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return frames;
|
|
49
|
+
}
|
|
50
|
+
/** Collapse the stale frames of ONE tool-result part to the stale-frame note. */
|
|
51
|
+
function collapseStaleFrames(part, staleValues) {
|
|
52
|
+
const p = part;
|
|
53
|
+
const values = (p.output?.value ?? []);
|
|
54
|
+
return {
|
|
55
|
+
...p,
|
|
56
|
+
output: {
|
|
57
|
+
...p.output,
|
|
58
|
+
value: values.map((value, valueIndex) => staleValues.has(valueIndex) ? { type: 'text', text: STALE_FRAME_NOTE } : value),
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Keep only the NEWEST self-look frame in the transcript. The SDK re-sends every
|
|
64
|
+
* tool result on every step, so each `look` image would otherwise ride along for
|
|
65
|
+
* the rest of the run — N looks × M steps of image tokens. Rebuilt per step in
|
|
66
|
+
* `prepareStep`, over the stripped chain (`stripInjectedStepMessages`, `loop.ts`).
|
|
67
|
+
*
|
|
68
|
+
* Counts FRAMES, not messages: AI SDK 6 collects ALL of a step's tool results
|
|
69
|
+
* into ONE `tool`-role message, so a step that looked twice holds two frames in
|
|
70
|
+
* a single message. The newest frame (last in transcript order) stays live and
|
|
71
|
+
* every older one collapses to {@link STALE_FRAME_NOTE}; the rest of each
|
|
72
|
+
* tool-result (its own text, a sibling `act` result) is left exactly as it was.
|
|
73
|
+
* Returns the SAME array when the transcript holds at most ONE frame, keeping
|
|
74
|
+
* the no-change fast path.
|
|
75
|
+
*/
|
|
76
|
+
export function pruneStaleFrames(messages) {
|
|
77
|
+
const frames = findFrames(messages);
|
|
78
|
+
if (frames.length <= 1)
|
|
79
|
+
return messages;
|
|
80
|
+
// Every frame but the LAST is stale — group them by the part they live in.
|
|
81
|
+
const staleByMessage = new Map();
|
|
82
|
+
for (const frame of frames.slice(0, -1)) {
|
|
83
|
+
let parts = staleByMessage.get(frame.messageIndex);
|
|
84
|
+
if (!parts) {
|
|
85
|
+
parts = new Map();
|
|
86
|
+
staleByMessage.set(frame.messageIndex, parts);
|
|
87
|
+
}
|
|
88
|
+
let values = parts.get(frame.partIndex);
|
|
89
|
+
if (!values) {
|
|
90
|
+
values = new Set();
|
|
91
|
+
parts.set(frame.partIndex, values);
|
|
92
|
+
}
|
|
93
|
+
values.add(frame.valueIndex);
|
|
94
|
+
}
|
|
95
|
+
return messages.map((message, messageIndex) => {
|
|
96
|
+
const staleParts = staleByMessage.get(messageIndex);
|
|
97
|
+
if (!staleParts)
|
|
98
|
+
return message;
|
|
99
|
+
const content = partsOf(message).map((part, partIndex) => {
|
|
100
|
+
const staleValues = staleParts.get(partIndex);
|
|
101
|
+
return staleValues ? collapseStaleFrames(part, staleValues) : part;
|
|
102
|
+
});
|
|
103
|
+
return { ...message, content };
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=loop-frames.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loop-frames.js","sourceRoot":"","sources":["../../src/agent/loop-frames.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,kFAAkF;AAClF,MAAM,CAAC,MAAM,gBAAgB,GAAG,gEAAgE,CAAC;AAsBjG,kFAAkF;AAClF,SAAS,OAAO,CAAC,OAAqB;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAE,OAAO,CAAC,OAAqB,CAAC,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B,CAAC;IACD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE;QAC5C,MAAM,UAAU,GAAG,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;QACpD,IAAI,CAAC,UAAU;YAAE,OAAO,OAAO,CAAC;QAChC,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;YACvD,MAAM,WAAW,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAC9C,OAAO,WAAW,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;QACrE,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,GAAG,OAAO,EAAE,OAAO,EAA6B,CAAC;IAC5D,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/agent/loop.d.ts
CHANGED
|
@@ -39,6 +39,12 @@ import type { ActTrail, TrailEvidence } from './belt/trail.js';
|
|
|
39
39
|
export declare const DEFAULT_MAX_STEPS = 60;
|
|
40
40
|
/** Kickoff turn — the story lives in `instructions`; this nudges the driver to start the loop. */
|
|
41
41
|
export declare const KICKOFF_PROMPT = "Begin. Work toward the goal with observe/act/look, then call report exactly once with your verdict.";
|
|
42
|
+
/**
|
|
43
|
+
* Re-entry turn after a step with NO tool call. The SDK ends a tool loop on any
|
|
44
|
+
* such step, so one line of prose ("I will now click Save.") used to end the
|
|
45
|
+
* whole run with no verdict — {@link runDebugLoop} re-enters with this instead.
|
|
46
|
+
*/
|
|
47
|
+
export declare const NO_TOOL_CALL_NUDGE = "You replied without calling a tool, which does nothing. Continue with observe/act/look, or call report now if you are done.";
|
|
42
48
|
/** The driver's inner belt — the four fat tools the loop drives (see `idea/mcp-tools.md`). */
|
|
43
49
|
export type BeltTools = {
|
|
44
50
|
observe: Tool;
|
|
@@ -110,28 +116,11 @@ export declare function foldInstructionsIntoStep(inbox: LoopInbox, standing: str
|
|
|
110
116
|
* correct whether the SDK persists it or not.
|
|
111
117
|
*/
|
|
112
118
|
export declare function stripInjectedStepMessages(messages: ModelMessage[]): ModelMessage[];
|
|
113
|
-
/** What a pruned frame collapses to — tells the driver how to get a fresh one. */
|
|
114
|
-
export declare const STALE_FRAME_NOTE = "[stale frame removed \u2014 call look again for a fresh screenshot]";
|
|
115
|
-
/**
|
|
116
|
-
* Keep only the NEWEST self-look frame in the transcript. The SDK re-sends every
|
|
117
|
-
* tool result on every step, so each `look` image would otherwise ride along for
|
|
118
|
-
* the rest of the run — N looks × M steps of image tokens. Rebuilt per step in
|
|
119
|
-
* `prepareStep`, over the stripped chain (see {@link stripInjectedStepMessages}).
|
|
120
|
-
*
|
|
121
|
-
* Counts FRAMES, not messages: AI SDK 6 collects ALL of a step's tool results
|
|
122
|
-
* into ONE `tool`-role message, so a step that looked twice holds two frames in
|
|
123
|
-
* a single message. The newest frame (last in transcript order) stays live and
|
|
124
|
-
* every older one collapses to {@link STALE_FRAME_NOTE}; the rest of each
|
|
125
|
-
* tool-result (its own text, a sibling `act` result) is left exactly as it was.
|
|
126
|
-
* Returns the SAME array when the transcript holds at most ONE frame, keeping
|
|
127
|
-
* the no-change fast path.
|
|
128
|
-
*/
|
|
129
|
-
export declare function pruneStaleFrames(messages: ModelMessage[]): ModelMessage[];
|
|
130
119
|
/** Steps left at or below which the driver is nudged to wrap up and `report`. */
|
|
131
120
|
export declare const BUDGET_WARN = 6;
|
|
132
121
|
/**
|
|
133
122
|
* A step-budget reminder folded into the turn as the run nears its cap — so the
|
|
134
|
-
* driver converges on `report` instead of churning to the hard
|
|
123
|
+
* driver converges on `report` instead of churning to the hard step-cap stop
|
|
135
124
|
* (which leaves an empty, verdict-less `failed` run). `null` while there is ample
|
|
136
125
|
* budget. `stepNumber` is the 0-based index of the step about to run.
|
|
137
126
|
*/
|
|
@@ -190,12 +179,6 @@ export declare const UNDELIVERED_NOTE = "Undelivered mid-run instruction(s) \u20
|
|
|
190
179
|
* untouched — the schema, not this, decides what a valid verdict is.
|
|
191
180
|
*/
|
|
192
181
|
export declare function appendUndelivered(input: unknown, pending: readonly string[]): unknown;
|
|
193
|
-
/**
|
|
194
|
-
* Build the debug agent loop. The driver runs `observe`→`act`→`look` until it
|
|
195
|
-
* calls `report` (terminal) or hits the step cap. Between steps `prepareStep`
|
|
196
|
-
* folds in mid-run messages; after each step `onStepFinish` flushes the running
|
|
197
|
-
* trail (skipping the `report` step, which writes the final verdict itself).
|
|
198
|
-
*/
|
|
199
182
|
export declare function createDebugAgent(options: DebugAgentOptions): ToolLoopAgent<never, BeltTools>;
|
|
200
183
|
/** How to run a built loop to its verdict. */
|
|
201
184
|
export interface RunDebugLoopOptions {
|
|
@@ -210,5 +193,11 @@ export interface RunDebugLoopOptions {
|
|
|
210
193
|
* Run the loop to its verdict. Resolves with the agent's generate result once the
|
|
211
194
|
* driver reports (or the step cap trips); rejects if aborted (fail loud — the
|
|
212
195
|
* session decides what an aborted run means).
|
|
196
|
+
*
|
|
197
|
+
* A step with no tool call ends the SDK's loop, so while step budget remains the
|
|
198
|
+
* run re-enters with the transcript so far plus {@link NO_TOOL_CALL_NUDGE}. Each
|
|
199
|
+
* re-entry spends a step of the SAME run-long budget, so it can never spin.
|
|
200
|
+
* Only a NORMAL prose completion (`stop`) re-enters: a content-filtered, errored
|
|
201
|
+
* or truncated turn would just be re-asked the same way until the budget is gone.
|
|
213
202
|
*/
|
|
214
203
|
export declare function runDebugLoop(options: RunDebugLoopOptions): Promise<import("ai").GenerateTextResult<BeltTools, import("@ai-sdk/provider-utils").Context, never>>;
|
package/dist/agent/loop.js
CHANGED
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
* (never clobbers the verdict with a `running` snapshot). Abort propagates: an
|
|
23
23
|
* aborted run rejects loud (wired to `end_session`), never a silent half-finish.
|
|
24
24
|
*/
|
|
25
|
-
import {
|
|
25
|
+
import { ToolLoopAgent } from 'ai';
|
|
26
26
|
import { EMPTY_EVIDENCE } from './belt/report.js';
|
|
27
|
+
import { pruneStaleFrames } from './loop-frames.js';
|
|
27
28
|
/**
|
|
28
29
|
* Safety cap on driver steps before the loop force-stops (paired with the
|
|
29
30
|
* report-RESULT stop condition in {@link createDebugAgent}).
|
|
@@ -38,6 +39,12 @@ import { EMPTY_EVIDENCE } from './belt/report.js';
|
|
|
38
39
|
export const DEFAULT_MAX_STEPS = 60;
|
|
39
40
|
/** Kickoff turn — the story lives in `instructions`; this nudges the driver to start the loop. */
|
|
40
41
|
export const KICKOFF_PROMPT = 'Begin. Work toward the goal with observe/act/look, then call report exactly once with your verdict.';
|
|
42
|
+
/**
|
|
43
|
+
* Re-entry turn after a step with NO tool call. The SDK ends a tool loop on any
|
|
44
|
+
* such step, so one line of prose ("I will now click Save.") used to end the
|
|
45
|
+
* whole run with no verdict — {@link runDebugLoop} re-enters with this instead.
|
|
46
|
+
*/
|
|
47
|
+
export const NO_TOOL_CALL_NUDGE = 'You replied without calling a tool, which does nothing. Continue with observe/act/look, or call report now if you are done.';
|
|
41
48
|
/**
|
|
42
49
|
* `prepareStep`: fold mid-run messages into the next model turn. Drains the inbox
|
|
43
50
|
* into `standing` — the run-long list of caller instructions — then, while any
|
|
@@ -97,108 +104,11 @@ export function stripInjectedStepMessages(messages) {
|
|
|
97
104
|
return messages;
|
|
98
105
|
return messages.filter((message) => !isInjectedStepMessage(message));
|
|
99
106
|
}
|
|
100
|
-
/** What a pruned frame collapses to — tells the driver how to get a fresh one. */
|
|
101
|
-
export const STALE_FRAME_NOTE = '[stale frame removed — call look again for a fresh screenshot]';
|
|
102
|
-
/** The content parts of a message as a plain array (empty for string content). */
|
|
103
|
-
function partsOf(message) {
|
|
104
|
-
return Array.isArray(message.content) ? message.content : [];
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Every self-look frame in the transcript, in transcript order (message →
|
|
108
|
-
* content part → output value).
|
|
109
|
-
*
|
|
110
|
-
* A frame is ONE `file-data` value part of a look tool-result. AI SDK 6 puts ALL
|
|
111
|
-
* of a step's tool results into ONE `tool`-role message, so a step that called
|
|
112
|
-
* `look` twice carries TWO frames inside a SINGLE message — counting messages
|
|
113
|
-
* instead of frames let both survive and stacked the driver's images.
|
|
114
|
-
*/
|
|
115
|
-
function findFrames(messages) {
|
|
116
|
-
const frames = [];
|
|
117
|
-
messages.forEach((message, messageIndex) => {
|
|
118
|
-
partsOf(message).forEach((part, partIndex) => {
|
|
119
|
-
// A content array may hold a null/undefined part — skip it instead of
|
|
120
|
-
// dereferencing it and killing the whole run inside `prepareStep`.
|
|
121
|
-
if (typeof part !== 'object' || part === null)
|
|
122
|
-
return;
|
|
123
|
-
const p = part;
|
|
124
|
-
if (p.type !== 'tool-result' || p.toolName !== 'look')
|
|
125
|
-
return;
|
|
126
|
-
const output = p.output;
|
|
127
|
-
if (output?.type !== 'content')
|
|
128
|
-
return;
|
|
129
|
-
const values = output.value;
|
|
130
|
-
if (!Array.isArray(values))
|
|
131
|
-
return;
|
|
132
|
-
values.forEach((value, valueIndex) => {
|
|
133
|
-
if (value?.type === 'file-data') {
|
|
134
|
-
frames.push({ messageIndex, partIndex, valueIndex });
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
return frames;
|
|
140
|
-
}
|
|
141
|
-
/** Collapse the stale frames of ONE tool-result part to the stale-frame note. */
|
|
142
|
-
function collapseStaleFrames(part, staleValues) {
|
|
143
|
-
const p = part;
|
|
144
|
-
const values = (p.output?.value ?? []);
|
|
145
|
-
return {
|
|
146
|
-
...p,
|
|
147
|
-
output: {
|
|
148
|
-
...p.output,
|
|
149
|
-
value: values.map((value, valueIndex) => staleValues.has(valueIndex) ? { type: 'text', text: STALE_FRAME_NOTE } : value),
|
|
150
|
-
},
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Keep only the NEWEST self-look frame in the transcript. The SDK re-sends every
|
|
155
|
-
* tool result on every step, so each `look` image would otherwise ride along for
|
|
156
|
-
* the rest of the run — N looks × M steps of image tokens. Rebuilt per step in
|
|
157
|
-
* `prepareStep`, over the stripped chain (see {@link stripInjectedStepMessages}).
|
|
158
|
-
*
|
|
159
|
-
* Counts FRAMES, not messages: AI SDK 6 collects ALL of a step's tool results
|
|
160
|
-
* into ONE `tool`-role message, so a step that looked twice holds two frames in
|
|
161
|
-
* a single message. The newest frame (last in transcript order) stays live and
|
|
162
|
-
* every older one collapses to {@link STALE_FRAME_NOTE}; the rest of each
|
|
163
|
-
* tool-result (its own text, a sibling `act` result) is left exactly as it was.
|
|
164
|
-
* Returns the SAME array when the transcript holds at most ONE frame, keeping
|
|
165
|
-
* the no-change fast path.
|
|
166
|
-
*/
|
|
167
|
-
export function pruneStaleFrames(messages) {
|
|
168
|
-
const frames = findFrames(messages);
|
|
169
|
-
if (frames.length <= 1)
|
|
170
|
-
return messages;
|
|
171
|
-
// Every frame but the LAST is stale — group them by the part they live in.
|
|
172
|
-
const staleByMessage = new Map();
|
|
173
|
-
for (const frame of frames.slice(0, -1)) {
|
|
174
|
-
let parts = staleByMessage.get(frame.messageIndex);
|
|
175
|
-
if (!parts) {
|
|
176
|
-
parts = new Map();
|
|
177
|
-
staleByMessage.set(frame.messageIndex, parts);
|
|
178
|
-
}
|
|
179
|
-
let values = parts.get(frame.partIndex);
|
|
180
|
-
if (!values) {
|
|
181
|
-
values = new Set();
|
|
182
|
-
parts.set(frame.partIndex, values);
|
|
183
|
-
}
|
|
184
|
-
values.add(frame.valueIndex);
|
|
185
|
-
}
|
|
186
|
-
return messages.map((message, messageIndex) => {
|
|
187
|
-
const staleParts = staleByMessage.get(messageIndex);
|
|
188
|
-
if (!staleParts)
|
|
189
|
-
return message;
|
|
190
|
-
const content = partsOf(message).map((part, partIndex) => {
|
|
191
|
-
const staleValues = staleParts.get(partIndex);
|
|
192
|
-
return staleValues ? collapseStaleFrames(part, staleValues) : part;
|
|
193
|
-
});
|
|
194
|
-
return { ...message, content };
|
|
195
|
-
});
|
|
196
|
-
}
|
|
197
107
|
/** Steps left at or below which the driver is nudged to wrap up and `report`. */
|
|
198
108
|
export const BUDGET_WARN = 6;
|
|
199
109
|
/**
|
|
200
110
|
* A step-budget reminder folded into the turn as the run nears its cap — so the
|
|
201
|
-
* driver converges on `report` instead of churning to the hard
|
|
111
|
+
* driver converges on `report` instead of churning to the hard step-cap stop
|
|
202
112
|
* (which leaves an empty, verdict-less `failed` run). `null` while there is ample
|
|
203
113
|
* budget. `stepNumber` is the 0-based index of the step about to run.
|
|
204
114
|
*/
|
|
@@ -312,9 +222,16 @@ function withUndeliveredInbox(report, inbox) {
|
|
|
312
222
|
* folds in mid-run messages; after each step `onStepFinish` flushes the running
|
|
313
223
|
* trail (skipping the `report` step, which writes the final verdict itself).
|
|
314
224
|
*/
|
|
225
|
+
/** Run-long step budget of a built agent — shared by every `generate` re-entry. */
|
|
226
|
+
const stepsLeft = new WeakMap();
|
|
315
227
|
export function createDebugAgent(options) {
|
|
316
228
|
const { model, tools, instructions, inbox, progress, log, maxSteps = DEFAULT_MAX_STEPS, trail, } = options;
|
|
317
229
|
let stepIndex = 0;
|
|
230
|
+
// Steps STARTED, run-long. The SDK's own `stepNumber` restarts at 0 on every
|
|
231
|
+
// `generate`, and `runDebugLoop` re-enters after a no-tool-call step — the cap
|
|
232
|
+
// and the budget nudge must count across re-entries, or a stalling driver
|
|
233
|
+
// would get a fresh budget each time.
|
|
234
|
+
let started = 0;
|
|
318
235
|
// Run-long list of mid-run caller instructions: drained from the inbox once,
|
|
319
236
|
// re-folded into EVERY step's prompt (AI SDK 7 persists the previous override;
|
|
320
237
|
// `stripInjectedStepMessages` drops it before the re-fold).
|
|
@@ -322,7 +239,7 @@ export function createDebugAgent(options) {
|
|
|
322
239
|
// What the running flush has already persisted. The trail's arrays only grow,
|
|
323
240
|
// so growth past these lengths is exactly "this step surfaced something new".
|
|
324
241
|
let flushed = EMPTY_EVIDENCE;
|
|
325
|
-
|
|
242
|
+
const agent = new ToolLoopAgent({
|
|
326
243
|
model,
|
|
327
244
|
tools: { ...tools, report: withUndeliveredInbox(tools.report, inbox) },
|
|
328
245
|
instructions,
|
|
@@ -334,10 +251,12 @@ export function createDebugAgent(options) {
|
|
|
334
251
|
// `report` actually ran and wrote the verdict; anything else keeps the loop
|
|
335
252
|
// going, and the driver gets the tool-error and retries.
|
|
336
253
|
stopWhen: [
|
|
337
|
-
|
|
254
|
+
() => started >= maxSteps,
|
|
338
255
|
({ steps }) => steps.at(-1)?.toolResults.some((r) => r.toolName === 'report') ?? false,
|
|
339
256
|
],
|
|
340
|
-
prepareStep: ({ messages
|
|
257
|
+
prepareStep: ({ messages }) => {
|
|
258
|
+
const stepNumber = started;
|
|
259
|
+
started += 1;
|
|
341
260
|
// AI SDK 7 persists the previous step's override into `messages` — strip
|
|
342
261
|
// its fold/nudge so both rebuild fresh: the fold never duplicates, the
|
|
343
262
|
// nudge reflects THIS step's remaining budget.
|
|
@@ -371,14 +290,31 @@ export function createDebugAgent(options) {
|
|
|
371
290
|
}
|
|
372
291
|
},
|
|
373
292
|
});
|
|
293
|
+
stepsLeft.set(agent, () => maxSteps - started);
|
|
294
|
+
return agent;
|
|
374
295
|
}
|
|
375
296
|
/**
|
|
376
297
|
* Run the loop to its verdict. Resolves with the agent's generate result once the
|
|
377
298
|
* driver reports (or the step cap trips); rejects if aborted (fail loud — the
|
|
378
299
|
* session decides what an aborted run means).
|
|
300
|
+
*
|
|
301
|
+
* A step with no tool call ends the SDK's loop, so while step budget remains the
|
|
302
|
+
* run re-enters with the transcript so far plus {@link NO_TOOL_CALL_NUDGE}. Each
|
|
303
|
+
* re-entry spends a step of the SAME run-long budget, so it can never spin.
|
|
304
|
+
* Only a NORMAL prose completion (`stop`) re-enters: a content-filtered, errored
|
|
305
|
+
* or truncated turn would just be re-asked the same way until the budget is gone.
|
|
379
306
|
*/
|
|
380
|
-
export function runDebugLoop(options) {
|
|
307
|
+
export async function runDebugLoop(options) {
|
|
381
308
|
const { agent, abortSignal, prompt = KICKOFF_PROMPT } = options;
|
|
382
|
-
|
|
309
|
+
const signal = abortSignal ? { abortSignal } : {};
|
|
310
|
+
const remaining = stepsLeft.get(agent) ?? (() => 0);
|
|
311
|
+
const messages = [{ role: 'user', content: prompt }];
|
|
312
|
+
let result = await agent.generate({ messages, ...signal });
|
|
313
|
+
const talkedInsteadOfActing = () => result.finishReason === 'stop' && result.steps.at(-1)?.toolCalls.length === 0;
|
|
314
|
+
while (talkedInsteadOfActing() && remaining() > 0) {
|
|
315
|
+
messages.push(...result.responseMessages, { role: 'user', content: NO_TOOL_CALL_NUDGE });
|
|
316
|
+
result = await agent.generate({ messages, ...signal });
|
|
317
|
+
}
|
|
318
|
+
return result;
|
|
383
319
|
}
|
|
384
320
|
//# sourceMappingURL=loop.js.map
|
package/dist/agent/loop.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAoD,aAAa,EAAE,MAAM,IAAI,CAAC;AAErF,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAEpC,kGAAkG;AAClG,MAAM,CAAC,MAAM,cAAc,GACzB,qGAAqG,CAAC;AAExG;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAC7B,6HAA6H,CAAC;AAsChI;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,wBAAwB,CACtC,K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,MAAM,KAAK,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -40,7 +40,7 @@ unconfirmed findings.`,
|
|
|
40
40
|
const SELF_LOOK_MODE = {
|
|
41
41
|
eyes: 'You are FAST and MULTIMODAL: `look` attaches the current frame to the tool result, and YOU judge it with your own eyes.',
|
|
42
42
|
belt: '- `look` — capture the current screen and judge it yourself; the frame comes back attached.',
|
|
43
|
-
// `pruneStaleFrames` (agent/loop.ts) drops older frames from the re-sent history.
|
|
43
|
+
// `pruneStaleFrames` (agent/loop-frames.ts) drops older frames from the re-sent history.
|
|
44
44
|
cost: 'Only the newest frame stays in your context, so judge each one as it arrives.',
|
|
45
45
|
extraRule: '',
|
|
46
46
|
// `createSelfLookTool` (look.ts) records NOTHING on the trail — it hands the
|
|
@@ -106,7 +106,8 @@ target. Re-typing a used field yields \`old textnew text\` — YOUR bug, not the
|
|
|
106
106
|
Replace instead — pass \`clear: true\`:
|
|
107
107
|
\`act({action:"type", target:"...", text:"...", clear:true})\`
|
|
108
108
|
Use \`clear\` whenever the field may be non-empty — a retry, a second item through
|
|
109
|
-
the same form, any field you have not just read as empty.
|
|
109
|
+
the same form, any field you have not just read as empty. To EMPTY a field:
|
|
110
|
+
\`text:"", clear:true\`.
|
|
110
111
|
|
|
111
112
|
## Budget — spending it all still costs the verdict
|
|
112
113
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug-agent.js","sourceRoot":"","sources":["../../../src/agent/prompts/debug-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAkB3F,+FAA+F;AAC/F,MAAM,WAAW,GAAa;IAC5B,IAAI,EAAE,4FAA4F;IAClG,IAAI,EAAE,yFAAyF;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c,CAAC,CAAC,CAAC,WAAW,CAAC;IAErD,OAAO;;;EAGP,IAAI,CAAC,IAAI;;;;;;EAMT,IAAI,CAAC,IAAI;;;;;;;;KAQN,IAAI,CAAC,IAAI;;;;;;;;;;;;;;;yDAe2C,IAAI,CAAC,SAAS;;;;;;;;;;;;;;;;;gBAiBvD,IAAI,CAAC,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DA8DkC,iBAAiB,CAAC,IAAI,CAAC,GAAG,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2B5E,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;;0BAEtC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;8DACJ,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;;;;;;EAM5G,IAAI,CAAC,OAAO;;;;CAIb,CAAC;AACF,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Web-target addendum for the debug agent system prompt.
|
|
3
3
|
*
|
|
4
|
-
* Teaches
|
|
4
|
+
* Teaches web reach: tree queries, selectors, console/network, iframes, tabs.
|
|
5
5
|
* Appended to the base prompt by `compose.ts` when target is "web".
|
|
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
|
|
9
|
+
export declare const WEB_ADDENDUM_PROMPT = "## Web target\n\nYou drive ONE browser page: DOM tree, console, network, input, screenshots.\n\n- Element not in the tree \u2192 scroll or wait, then re-observe.\n- Errors land in console/network before they show visually (see below).\n- Only when the tree has no answer: `look`.\n\n### Tree queries\n\n- `query` accepts: a bare tag (`span`, `img`), CSS (`.cart span`), `role \"name\"`\n (`button \"Add to cart\"`), an engine (`data-testid=cart-count`, `text=Subscribe`),\n or plain visible text.\n- `data-testid` elements always appear in the default tree with their `testid`.\n Read a counter/value from that node's `name` (its text). Re-observe the same\n node after acting to confirm the change.\n- `within` scopes a read: a selector string, or a node OBJECT exactly as a previous\n observe returned it \u2014 NEVER a JSON-stringified node.\n\n### Contrast \u2014 no vision needed\n\nText nodes carry `style` = `{ color, backgroundColor, contrast }` (WCAG 1\u201321),\nomitted by default. Request `fields:[\"role\",\"name\",\"style\"]`, or sweep 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 = fine). `contrast < 4.5` \u2192 `medium` visual\nfinding; `< 1.5` \u2192 `high` (effectively invisible). ALWAYS sweep once when the goal\nmentions readability, contrast, or visual polish.\n\n### Follow links by CLICKING \u2014 never invent URLs\n\nThe tree does not expose `href`s. `act({action:\"click\"})` the node. NEVER fabricate\na URL from a label (\"Help Center\" \u2192 `/help-center`) \u2014 a guessed URL that 404s is\nYOUR error, not a site bug. Only `navigate` to URLs from the goal or from network\nentries. Click target hidden inside a closed menu \u2192 click the parent menu item\nfirst, then re-observe.\n\n### Verify input from the TREE, never vision\n\nForm controls carry live state: `value` (input/textarea/select) and `checked`\n(checkbox/radio). `name` stays the label, so you can still target by it.\n\nAfter typing or toggling:\n`observe({kind:\"tree\", query:\"input\", fields:[\"name\",\"value\",\"checked\"]})`\n\nNEVER spend a `look` on \"did my text land?\" or \"is the box checked?\" \u2014 the tree\nanswers exactly, instantly, free. Vision is for how things LOOK.\n\n### Login bypass\n\nTarget supports `?debug-ai=true` (the app's captcha gate) \u2192 append it to the login\nURL before navigating. Skips captcha only, not auth. Needs `ALLOW_AI_DEBUG_LOGIN=true`\nin the app's environment.\n\n### Selectors \u2014 copy the node's `target`\n\nMost actionable nodes carry a ready `target` (`data-testid=\"cart-count\"`, else\n`role=button[name=\"Add to cart\" i]`, with `>> nth=N` when names repeat). COPY it\nverbatim into `act({action, target})`. NEVER hand-craft a selector \u2014 guessed CSS\nlike `button[name=\"...\"]` will not resolve.\n\nNo `target` (unnamed node, or a scoped `within`/`filters` read) \u2192 pass its visible\ntext (plain text resolves) or `role \"name\"`. Avoid XPath and positional CSS.\n\n### Console + network \u2014 filter, don't dump\n\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 when you need only the latest few.\n- Every row carries `tab` \u2014 the id of the tab it came from (see Tabs).\n\nCheck both after actions that plausibly error (submits, navigations, API calls) \u2014\nnot mechanically after every `act`. Record what you find as `console`/`network`\nbugs: request URL or error message as `detail`, screenshot path as `evidence`.\n\n### Network rows carry the WHY\n\nEach row is a full exchange: `method`, `url`, `status`, `ok`, `durationMs`, plus\n`requestBody`, `responseBody` and redacted `requestHeaders`/`responseHeaders` for\n`fetch`/`xhr`.\n\n**A failing request is half-reported without its `responseBody`.** NEVER stop at\n\"POST /api/x returned 400\" \u2014 quote what the server said\n(`{\"error\":\"password too short\"}`); that string turns a finding into a fix. The\n`requestBody` shows whether the UI even sent what you typed.\n\nCredentials arrive as `<redacted, N chars>` \u2014 header values, and the signed-in\npersona's values wherever they appear (bodies, urls, node names and `value`s).\nDeliberate, never a bug. Presence is what you need (a missing `cookie` explains a\n401). Such a node's `target` is an opaque `@@ref:N` \u2014 copy it like any other.\n\n- `filters:{duration_gte:1000}` \u2014 slow enough to be a UX bug.\n- `filters:{body_contains:\"error\"}` \u2014 failures that still returned 200.\n- `filters:{pending_eq:true}` \u2014 still in flight (no response yet): the hung call\n behind a spinner.\n\nA default `network` read hides SUCCESSFUL static assets and reports the count as\n`hidden` \u2014 on a dev server they outnumber API calls ~15:1. Failed assets are always\nshown (a 404 image is a real bug). Inspect assets deliberately:\n`observe({kind:\"network\", filters:{resource_in:[\"script\",\"stylesheet\",\"image\"]}})`.\n\n### iframes \u2014 already in the tree\n\n`observe({kind:\"tree\"})` reads embedded documents (payment fields, editors, consent\nscreens). A node inside one carries `frame` = the iframe URL; its `bounds` are page\ncoordinates, so clicking needs nothing special. A selector that mysteriously fails\non a node you can see \u2192 check for `frame`, and prefer clicking the node object.\n\n### Tabs \u2014 a click can open one\n\nWith more than one tab open, every `act` result carries `tabs`\n(`index`, `id`, `url`, `title`, `active`, `visible`). `active` = the page you\ncontrol; `visible` = document visibility, NOT window focus (an active page can be\nhidden). A click on an external link, an OAuth button or `target=\"_blank\"` opens a\nnew tab and **you stay on the old one** \u2014 a click that seems to have done nothing\nmeans check `tabs` before calling the button broken.\n\n- `observe({kind:\"tabs\"})` \u2014 list them.\n- `act({action:\"switch_tab\", target:\"1\"})` \u2014 drive the tab at index 1 from now on\n and explicitly bring it forward. Console and network capture follow you; the\n previous tab's records are kept.\n\n`index` is a POSITION \u2014 it shifts when an earlier tab closes. `id` (`tab-1`,\n`tab-2`, \u2026) follows the PAGE for the whole run; console/network rows carry it as\n`tab`. To drive that tab, find its `id` in the CURRENT `tabs` listing and switch\nto that entry's `index` \u2014 the label is NOT an index, and `switch_tab` rejects it.\n\nSwitch back the same way when the popup flow is done.\n";
|
|
@@ -1,31 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Web-target addendum for the debug agent system prompt.
|
|
3
3
|
*
|
|
4
|
-
* Teaches
|
|
4
|
+
* Teaches web reach: tree queries, selectors, console/network, iframes, tabs.
|
|
5
5
|
* Appended to the base prompt by `compose.ts` when target is "web".
|
|
6
6
|
*
|
|
7
7
|
* Provider-agnostic — no vendor tricks; any competent model drives the same loop.
|
|
8
8
|
*/
|
|
9
9
|
export const WEB_ADDENDUM_PROMPT = `\
|
|
10
|
-
## Web target
|
|
10
|
+
## Web target
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
input, screenshots on the current page.
|
|
12
|
+
You drive ONE browser page: DOM tree, console, network, input, screenshots.
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
| \`DOM\` | element tree, attributes, text | \`observe({kind:"tree"})\` |
|
|
19
|
-
| \`Network\` | status, failed requests, timing | \`observe({kind:"network"})\` |
|
|
20
|
-
| \`Log\` | console messages, JS errors | \`observe({kind:"console"})\` |
|
|
21
|
-
|
|
22
|
-
### DOM-first
|
|
23
|
-
|
|
24
|
-
1. \`observe({kind:"tree"})\` — roles, names, bounds, enabled state.
|
|
25
|
-
2. Element not in the tree → scroll or wait, then re-observe.
|
|
26
|
-
3. \`observe({kind:"console"})\` + \`observe({kind:"network"})\` (filtered) after
|
|
27
|
-
actions that plausibly error — errors land there before they show visually.
|
|
28
|
-
4. Only when the tree has no answer: \`look\`.
|
|
14
|
+
- Element not in the tree → scroll or wait, then re-observe.
|
|
15
|
+
- Errors land in console/network before they show visually (see below).
|
|
16
|
+
- Only when the tree has no answer: \`look\`.
|
|
29
17
|
|
|
30
18
|
### Tree queries
|
|
31
19
|
|
|
@@ -104,11 +92,15 @@ Each row is a full exchange: \`method\`, \`url\`, \`status\`, \`ok\`, \`duration
|
|
|
104
92
|
(\`{"error":"password too short"}\`); that string turns a finding into a fix. The
|
|
105
93
|
\`requestBody\` shows whether the UI even sent what you typed.
|
|
106
94
|
|
|
107
|
-
|
|
108
|
-
|
|
95
|
+
Credentials arrive as \`<redacted, N chars>\` — header values, and the signed-in
|
|
96
|
+
persona's values wherever they appear (bodies, urls, node names and \`value\`s).
|
|
97
|
+
Deliberate, never a bug. Presence is what you need (a missing \`cookie\` explains a
|
|
98
|
+
401). Such a node's \`target\` is an opaque \`@@ref:N\` — copy it like any other.
|
|
109
99
|
|
|
110
100
|
- \`filters:{duration_gte:1000}\` — slow enough to be a UX bug.
|
|
111
101
|
- \`filters:{body_contains:"error"}\` — failures that still returned 200.
|
|
102
|
+
- \`filters:{pending_eq:true}\` — still in flight (no response yet): the hung call
|
|
103
|
+
behind a spinner.
|
|
112
104
|
|
|
113
105
|
A default \`network\` read hides SUCCESSFUL static assets and reports the count as
|
|
114
106
|
\`hidden\` — on a dev server they outnumber API calls ~15:1. Failed assets are always
|
|
@@ -125,24 +117,21 @@ on a node you can see → check for \`frame\`, and prefer clicking the node obje
|
|
|
125
117
|
### Tabs — a click can open one
|
|
126
118
|
|
|
127
119
|
With more than one tab open, every \`act\` result carries \`tabs\`
|
|
128
|
-
(\`index\`, \`id\`, \`url\`, \`title\`, \`active\`, \`visible\`). \`active\`
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
seems to have done nothing means check \`tabs\` before calling the button broken.
|
|
120
|
+
(\`index\`, \`id\`, \`url\`, \`title\`, \`active\`, \`visible\`). \`active\` = the page you
|
|
121
|
+
control; \`visible\` = document visibility, NOT window focus (an active page can be
|
|
122
|
+
hidden). A click on an external link, an OAuth button or \`target="_blank"\` opens a
|
|
123
|
+
new tab and **you stay on the old one** — a click that seems to have done nothing
|
|
124
|
+
means check \`tabs\` before calling the button broken.
|
|
134
125
|
|
|
135
126
|
- \`observe({kind:"tabs"})\` — list them.
|
|
136
127
|
- \`act({action:"switch_tab", target:"1"})\` — drive the tab at index 1 from now on
|
|
137
128
|
and explicitly bring it forward. Console and network capture follow you; the
|
|
138
129
|
previous tab's records are kept.
|
|
139
130
|
|
|
140
|
-
\`index\` is a POSITION — it shifts when an earlier tab closes. \`id\`
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
\`
|
|
144
|
-
its \`id\` in the CURRENT \`tabs\` listing and switch to that entry's \`index\` — the
|
|
145
|
-
label is NOT an index, and \`switch_tab\` rejects it.
|
|
131
|
+
\`index\` is a POSITION — it shifts when an earlier tab closes. \`id\` (\`tab-1\`,
|
|
132
|
+
\`tab-2\`, …) follows the PAGE for the whole run; console/network rows carry it as
|
|
133
|
+
\`tab\`. To drive that tab, find its \`id\` in the CURRENT \`tabs\` listing and switch
|
|
134
|
+
to that entry's \`index\` — the label is NOT an index, and \`switch_tab\` rejects it.
|
|
146
135
|
|
|
147
136
|
Switch back the same way when the popup flow is done.
|
|
148
137
|
`;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-addendum.js","sourceRoot":"","sources":["../../../src/agent/prompts/web-addendum.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG
|
|
1
|
+
{"version":3,"file":"web-addendum.js","sourceRoot":"","sources":["../../../src/agent/prompts/web-addendum.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgIlC,CAAC"}
|
package/dist/agent/provider.d.ts
CHANGED
|
@@ -48,7 +48,9 @@ export declare function providerApiKeyGuidance(): string;
|
|
|
48
48
|
/**
|
|
49
49
|
* Resolve the provider endpoint the same way `createOpenRouterProvider` does —
|
|
50
50
|
* apiKey: provided value → OPENAI_API_KEY → OPENROUTER_API_KEY;
|
|
51
|
-
* baseURL: provided value → OPENAI_BASE_URL
|
|
51
|
+
* baseURL: provided value → DEFAULT_BASE_URL. `OPENAI_BASE_URL` is NOT read
|
|
52
|
+
* here: the config loader (`src/config/load.ts`) is its one, validated source
|
|
53
|
+
* and boot passes the result in.
|
|
52
54
|
* Exported so capability probes hit the exact endpoint the models run against.
|
|
53
55
|
* Throws ProviderError if no API key is found or if it's empty.
|
|
54
56
|
*/
|