@developerz.ai/ui-debugger-mcp 1.1.0 → 1.3.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 +45 -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 +16 -13
- package/dist/adapters/browser/browser-adapter.js +196 -313
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.d.ts +40 -2
- package/dist/adapters/browser/cdp.js +223 -19
- package/dist/adapters/browser/cdp.js.map +1 -1
- package/dist/adapters/browser/extractor.d.ts +53 -0
- package/dist/adapters/browser/extractor.js +224 -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 +82 -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 +44 -9
- package/dist/agent/belt/act.js +176 -21
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +1 -1
- package/dist/agent/belt/look.js +31 -2
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +42 -16
- package/dist/agent/belt/observe.js +134 -22
- 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 +41 -13
- package/dist/agent/capabilities.js.map +1 -1
- package/dist/agent/loop.d.ts +70 -21
- package/dist/agent/loop.js +146 -48
- 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 +98 -14
- 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 +84 -16
- 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/fingerprint.d.ts +32 -0
- package/dist/config/fingerprint.js +47 -0
- package/dist/config/fingerprint.js.map +1 -0
- package/dist/config/load.d.ts +7 -1
- package/dist/config/load.js +17 -4
- 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 +26 -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 +47 -8
- package/dist/services/debug-service.js +185 -14
- 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/services/summarize.d.ts +1 -1
- package/dist/services/summarize.js +8 -1
- package/dist/services/summarize.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 +36 -4
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +64 -5
- package/dist/session/state-file.js +76 -9
- 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
|
@@ -53,8 +53,8 @@ export const ReportInputSchema = z.object({
|
|
|
53
53
|
});
|
|
54
54
|
/**
|
|
55
55
|
* Build the canonical findings record from a validated report input. The base
|
|
56
|
-
* verdict shape; {@link terminalFindings}
|
|
57
|
-
*
|
|
56
|
+
* verdict shape; {@link terminalFindings} merges the loop's recorded act-trail
|
|
57
|
+
* into its `steps`, so both the persisted write and the returned counts agree.
|
|
58
58
|
*/
|
|
59
59
|
export function reportFindings(input) {
|
|
60
60
|
return {
|
|
@@ -65,22 +65,83 @@ export function reportFindings(input) {
|
|
|
65
65
|
...(input.summary !== undefined && { summary: input.summary }),
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
+
/** Pairing key for a reported step and a recorded one — case- and whitespace-insensitive. */
|
|
69
|
+
function stepKey(step) {
|
|
70
|
+
return step.step.trim().toLowerCase().replace(/\s+/g, ' ');
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Fuse one reported step with the trail entry it restates: the driver's version
|
|
74
|
+
* wins field by field (its `ok`, its `note`), the recorded one fills what the
|
|
75
|
+
* driver left out — above all the evidence frame it never sees a path for.
|
|
76
|
+
*/
|
|
77
|
+
function fuseStep(recorded, reported) {
|
|
78
|
+
const skipped = reported.skipped ?? recorded.skipped;
|
|
79
|
+
const note = reported.note ?? recorded.note;
|
|
80
|
+
const screenshot = reported.screenshot ?? recorded.screenshot;
|
|
81
|
+
return {
|
|
82
|
+
step: reported.step,
|
|
83
|
+
ok: reported.ok,
|
|
84
|
+
...(skipped !== undefined && { skipped }),
|
|
85
|
+
...(note !== undefined && { note }),
|
|
86
|
+
...(screenshot !== undefined && { screenshot }),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Merge the driver's reported steps with the loop's recorded act-`trail`. Nothing
|
|
91
|
+
* is discarded: the driver's `ok: false` steps and notes (the prompt mandates
|
|
92
|
+
* them) survive alongside the mechanical trail and its evidence frames.
|
|
93
|
+
*
|
|
94
|
+
* The trail is the spine — it is the true chronology, recorded at act time — and
|
|
95
|
+
* each entry the driver restated verbatim (models commonly echo the `act` result
|
|
96
|
+
* label) is fused in place, driver fields winning, trail filling the gaps. Steps
|
|
97
|
+
* the driver reported that no trail entry matches — assertions, observations, acts
|
|
98
|
+
* from a step that also called `report` — follow in reported order, since nothing
|
|
99
|
+
* places them in the chronology. Both inputs keep their relative order, and equal
|
|
100
|
+
* labels pair up first-come-first-served, so repeating an action pairs each
|
|
101
|
+
* occurrence with a distinct trail entry.
|
|
102
|
+
*/
|
|
103
|
+
export function mergeSteps(reported, trail) {
|
|
104
|
+
if (trail.length === 0)
|
|
105
|
+
return [...reported];
|
|
106
|
+
if (reported.length === 0)
|
|
107
|
+
return [...trail];
|
|
108
|
+
const pending = new Map();
|
|
109
|
+
reported.forEach((step, index) => {
|
|
110
|
+
const queue = pending.get(stepKey(step));
|
|
111
|
+
if (queue)
|
|
112
|
+
queue.push({ index, step });
|
|
113
|
+
else
|
|
114
|
+
pending.set(stepKey(step), [{ index, step }]);
|
|
115
|
+
});
|
|
116
|
+
const fused = new Set();
|
|
117
|
+
const merged = trail.map((recorded) => {
|
|
118
|
+
const hit = pending.get(stepKey(recorded))?.shift();
|
|
119
|
+
if (!hit)
|
|
120
|
+
return recorded;
|
|
121
|
+
fused.add(hit.index);
|
|
122
|
+
return fuseStep(recorded, hit.step);
|
|
123
|
+
});
|
|
124
|
+
for (const [index, step] of reported.entries()) {
|
|
125
|
+
if (!fused.has(index))
|
|
126
|
+
merged.push(step);
|
|
127
|
+
}
|
|
128
|
+
return merged;
|
|
129
|
+
}
|
|
68
130
|
/**
|
|
69
131
|
* The authoritative terminal {@link Findings}: the report input with the loop's
|
|
70
|
-
* recorded act-`trail`
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* so they never drift (a `0`-step result returned over a trail-filled file).
|
|
132
|
+
* recorded act-`trail` merged into its `steps` (see {@link mergeSteps}) — never a
|
|
133
|
+
* wholesale replacement, which silently dropped every step the driver reported.
|
|
134
|
+
* The single source of truth for the terminal write AND the counts, so they never
|
|
135
|
+
* drift (a `0`-step result returned over a trail-filled file).
|
|
75
136
|
*/
|
|
76
137
|
export function terminalFindings(input, trail = []) {
|
|
77
138
|
const findings = reportFindings(input);
|
|
78
|
-
return
|
|
139
|
+
return { ...findings, steps: mergeSteps(input.steps, trail) };
|
|
79
140
|
}
|
|
80
141
|
/**
|
|
81
142
|
* Write the terminal verdict and report the stop. Both the persisted findings and
|
|
82
143
|
* the returned counts derive from one {@link terminalFindings} object — the loop's
|
|
83
|
-
* `trail`
|
|
144
|
+
* `trail` merged with the driver's reported steps. Pure over the
|
|
84
145
|
* {@link FindingsWriter} seam, so it unit-tests against a fake with no disk.
|
|
85
146
|
*/
|
|
86
147
|
export async function runReport(writer, input, trail = []) {
|
|
@@ -101,12 +162,18 @@ export async function runReport(writer, input, trail = []) {
|
|
|
101
162
|
* Build the `report` tool bound to one findings store, for the debug agent's belt.
|
|
102
163
|
* `getTrail` (when wired by the loop) supplies the recorded act-trail so the
|
|
103
164
|
* written verdict and its counts both reflect the steps actually taken.
|
|
165
|
+
*
|
|
166
|
+
* It may be async — and the wired one is. `report` executes CONCURRENTLY with the
|
|
167
|
+
* other tool calls of its own step, so when the driver emits `act` + `report`
|
|
168
|
+
* together the act is still running here; the wired read is the act trail's
|
|
169
|
+
* `settled()`, which waits for it (see `belt/trail.ts`). Waiting is safe: the
|
|
170
|
+
* step's own `Promise.all` already awaits that act.
|
|
104
171
|
*/
|
|
105
172
|
export function createReportTool(writer, getTrail) {
|
|
106
173
|
return tool({
|
|
107
174
|
description: 'Emit the final structured findings and END the run. Call exactly once, when the goal is met or you hit the step limit. Validates and writes findings.json: status (passed|failed) plus steps/bugs/visual/summary. This is terminal — the loop stops after report, so do not act again. Make summary actionable for the smart agent: what broke, where, what to fix.',
|
|
108
175
|
inputSchema: ReportInputSchema,
|
|
109
|
-
execute: (input) => runReport(writer, input, getTrail?.() ?? []),
|
|
176
|
+
execute: async (input) => runReport(writer, input, (await getTrail?.()) ?? []),
|
|
110
177
|
});
|
|
111
178
|
}
|
|
112
179
|
//# sourceMappingURL=report.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/agent/belt/report.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GA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;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAsB,EACtB,KAAkB,EAClB,QAAyB,EAAE;IAE3B,MAAM,QAAQ,GAAG,gBAAgB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAClD,OAAO;QACL,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,IAAI;QACd,MAAM,EAAE;YACN,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,MAAM;YAC5B,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM;YAC1B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM;SAC/B;QACD,IAAI,EAAE,IAAI;KACX,CAAC;AACJ,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gBAAgB,CAC9B,MAAsB,EACtB,QAA2D;IAE3D,OAAO,IAAI,CAAC;QACV,WAAW,EACT,qWAAqW;QACvW,WAAW,EAAE,iBAAiB;QAC9B,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,SAAS,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,MAAM,QAAQ,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC;KAC/E,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run's shared act trail — the evidence spine `act` writes and `report` reads.
|
|
3
|
+
*
|
|
4
|
+
* `act` records every step it finishes, ok or not, AT ACT TIME. The timing is the
|
|
5
|
+
* whole point. The SDK runs a step's tool calls CONCURRENTLY (`Promise.all` over
|
|
6
|
+
* the call list) and `onStepFinish` only fires once they have all settled, so when
|
|
7
|
+
* the driver emits `act` and `report` in ONE step — which models do, despite the
|
|
8
|
+
* prompt calling `report` terminal — `report` executes while that act is still in
|
|
9
|
+
* flight. A trail lifted at step end reaches the terminal read too late: the
|
|
10
|
+
* verdict ships without the last thing the run did.
|
|
11
|
+
*
|
|
12
|
+
* So the trail also counts the acts in flight and the terminal read waits for them
|
|
13
|
+
* ({@link ActTrail.settled}). That can never deadlock: the step's own `Promise.all`
|
|
14
|
+
* already awaits every act, so `report` only ever waits on work that must finish
|
|
15
|
+
* for its own step to finish at all.
|
|
16
|
+
*/
|
|
17
|
+
import type { Step } from '../../findings/schema.js';
|
|
18
|
+
/**
|
|
19
|
+
* The shared trail: an ordered {@link Step} log plus the in-flight bookkeeping the
|
|
20
|
+
* terminal read needs. One per run — `act` writes it, the loop's running flush
|
|
21
|
+
* snapshots it, `report` merges it into the verdict.
|
|
22
|
+
*/
|
|
23
|
+
export interface ActTrail {
|
|
24
|
+
/** Recorded steps in act order — the array the loop's running flush snapshots. */
|
|
25
|
+
readonly steps: Step[];
|
|
26
|
+
/** Announce an act in flight; call the returned function once it settles. */
|
|
27
|
+
begin(): () => void;
|
|
28
|
+
/** Record one finished act — `ok: true` with its frame, or `ok: false` with the error. */
|
|
29
|
+
record(step: Step): void;
|
|
30
|
+
/** The trail once no act is in flight — the read `report` takes before it writes. */
|
|
31
|
+
settled(): Promise<readonly Step[]>;
|
|
32
|
+
}
|
|
33
|
+
/** Build a fresh {@link ActTrail} for one run. */
|
|
34
|
+
export declare function createActTrail(): ActTrail;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The run's shared act trail — the evidence spine `act` writes and `report` reads.
|
|
3
|
+
*
|
|
4
|
+
* `act` records every step it finishes, ok or not, AT ACT TIME. The timing is the
|
|
5
|
+
* whole point. The SDK runs a step's tool calls CONCURRENTLY (`Promise.all` over
|
|
6
|
+
* the call list) and `onStepFinish` only fires once they have all settled, so when
|
|
7
|
+
* the driver emits `act` and `report` in ONE step — which models do, despite the
|
|
8
|
+
* prompt calling `report` terminal — `report` executes while that act is still in
|
|
9
|
+
* flight. A trail lifted at step end reaches the terminal read too late: the
|
|
10
|
+
* verdict ships without the last thing the run did.
|
|
11
|
+
*
|
|
12
|
+
* So the trail also counts the acts in flight and the terminal read waits for them
|
|
13
|
+
* ({@link ActTrail.settled}). That can never deadlock: the step's own `Promise.all`
|
|
14
|
+
* already awaits every act, so `report` only ever waits on work that must finish
|
|
15
|
+
* for its own step to finish at all.
|
|
16
|
+
*/
|
|
17
|
+
/** Let already-queued microtasks run — one full turn of the event loop. */
|
|
18
|
+
function nextTurn() {
|
|
19
|
+
return new Promise((resolve) => setTimeout(resolve, 0));
|
|
20
|
+
}
|
|
21
|
+
/** Build a fresh {@link ActTrail} for one run. */
|
|
22
|
+
export function createActTrail() {
|
|
23
|
+
const steps = [];
|
|
24
|
+
let inFlight = 0;
|
|
25
|
+
let idle = null;
|
|
26
|
+
let markIdle = null;
|
|
27
|
+
return {
|
|
28
|
+
steps,
|
|
29
|
+
begin() {
|
|
30
|
+
inFlight += 1;
|
|
31
|
+
idle ??= new Promise((resolve) => {
|
|
32
|
+
markIdle = resolve;
|
|
33
|
+
});
|
|
34
|
+
let settled = false;
|
|
35
|
+
return () => {
|
|
36
|
+
// Idempotent: a double-settle must not drop a sibling act's count.
|
|
37
|
+
if (settled)
|
|
38
|
+
return;
|
|
39
|
+
settled = true;
|
|
40
|
+
inFlight -= 1;
|
|
41
|
+
if (inFlight > 0)
|
|
42
|
+
return;
|
|
43
|
+
markIdle?.();
|
|
44
|
+
idle = null;
|
|
45
|
+
markIdle = null;
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
record(step) {
|
|
49
|
+
steps.push(step);
|
|
50
|
+
},
|
|
51
|
+
async settled() {
|
|
52
|
+
// Yield a full turn before checking: the sibling tool calls of this step are
|
|
53
|
+
// launched in microtasks, so an act listed AFTER `report` in the call list has
|
|
54
|
+
// not entered `begin()` yet when the terminal read starts. One turn guarantees
|
|
55
|
+
// every sibling has begun — otherwise the barrier would read an empty gate and
|
|
56
|
+
// miss exactly the act it exists to wait for.
|
|
57
|
+
await nextTurn();
|
|
58
|
+
while (idle !== null)
|
|
59
|
+
await idle;
|
|
60
|
+
return steps;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=trail.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trail.js","sourceRoot":"","sources":["../../../src/agent/belt/trail.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAoBH,2EAA2E;AAC3E,SAAS,QAAQ;IACf,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,cAAc;IAC5B,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,IAAI,QAAQ,GAAG,CAAC,CAAC;IACjB,IAAI,IAAI,GAAyB,IAAI,CAAC;IACtC,IAAI,QAAQ,GAAwB,IAAI,CAAC;IACzC,OAAO;QACL,KAAK;QACL,KAAK;YACH,QAAQ,IAAI,CAAC,CAAC;YACd,IAAI,KAAK,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBACrC,QAAQ,GAAG,OAAO,CAAC;YACrB,CAAC,CAAC,CAAC;YACH,IAAI,OAAO,GAAG,KAAK,CAAC;YACpB,OAAO,GAAG,EAAE;gBACV,mEAAmE;gBACnE,IAAI,OAAO;oBAAE,OAAO;gBACpB,OAAO,GAAG,IAAI,CAAC;gBACf,QAAQ,IAAI,CAAC,CAAC;gBACd,IAAI,QAAQ,GAAG,CAAC;oBAAE,OAAO;gBACzB,QAAQ,EAAE,EAAE,CAAC;gBACb,IAAI,GAAG,IAAI,CAAC;gBACZ,QAAQ,GAAG,IAAI,CAAC;YAClB,CAAC,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,IAAI;YACT,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QACD,KAAK,CAAC,OAAO;YACX,6EAA6E;YAC7E,+EAA+E;YAC/E,+EAA+E;YAC/E,+EAA+E;YAC/E,8CAA8C;YAC9C,MAAM,QAAQ,EAAE,CAAC;YACjB,OAAO,IAAI,KAAK,IAAI;gBAAE,MAAM,IAAI,CAAC;YACjC,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Three-valued on purpose: `true` / `false` when the catalog answers, `null`
|
|
10
10
|
* when it can't (endpoint missing, no `architecture` field — e.g. z.ai's
|
|
11
|
-
* OpenAI-style `/models` — network error). Callers treat
|
|
12
|
-
* self-look": the separate-call path already fails soft
|
|
13
|
-
* an image pushed at a text-only DRIVER would poison
|
|
14
|
-
* run (the SDK re-sends tool results each turn).
|
|
11
|
+
* OpenAI-style `/models` — network error, malformed payload). Callers treat
|
|
12
|
+
* `null` as "don't self-look": the separate-call path already fails soft
|
|
13
|
+
* (vision latch), while an image pushed at a text-only DRIVER would poison
|
|
14
|
+
* every later step of the run (the SDK re-sends tool results each turn).
|
|
15
15
|
*/
|
|
16
16
|
/**
|
|
17
17
|
* The slice of `fetch` the probe needs — typed locally (the DOM lib is off
|
|
@@ -8,11 +8,38 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Three-valued on purpose: `true` / `false` when the catalog answers, `null`
|
|
10
10
|
* when it can't (endpoint missing, no `architecture` field — e.g. z.ai's
|
|
11
|
-
* OpenAI-style `/models` — network error). Callers treat
|
|
12
|
-
* self-look": the separate-call path already fails soft
|
|
13
|
-
* an image pushed at a text-only DRIVER would poison
|
|
14
|
-
* run (the SDK re-sends tool results each turn).
|
|
11
|
+
* OpenAI-style `/models` — network error, malformed payload). Callers treat
|
|
12
|
+
* `null` as "don't self-look": the separate-call path already fails soft
|
|
13
|
+
* (vision latch), while an image pushed at a text-only DRIVER would poison
|
|
14
|
+
* every later step of the run (the SDK re-sends tool results each turn).
|
|
15
15
|
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
/** One models-catalog row, OpenRouter shape (other providers may omit `architecture`). */
|
|
18
|
+
const CatalogModelSchema = z.object({
|
|
19
|
+
id: z.string(),
|
|
20
|
+
architecture: z.object({ input_modalities: z.array(z.string()).optional() }).nullish(),
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* `/models` payload. A row that doesn't parse degrades to `null` and is skipped
|
|
24
|
+
* — one odd entry in a 300-model catalog must not blind the probe for every model.
|
|
25
|
+
*/
|
|
26
|
+
const CatalogSchema = z.object({
|
|
27
|
+
data: z.array(CatalogModelSchema.nullable().catch(null)),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Catalog id for a routing-suffixed model id. The router accepts suffixes the
|
|
31
|
+
* `/models` catalog does not list as ids of their own — `:nitro`, `:floor`. Some
|
|
32
|
+
* suffixed ids ARE listed verbatim (`…:free`), so the probe tries the id as given
|
|
33
|
+
* first and only then falls back to this base form.
|
|
34
|
+
*
|
|
35
|
+
* `#` is stripped too, but only so a user-supplied `#…` id still resolves a
|
|
36
|
+
* capability — the router itself rejects `#` suffixes outright, so no default
|
|
37
|
+
* ships one (see {@link DEFAULT_MODELS}).
|
|
38
|
+
*/
|
|
39
|
+
function baseModelId(modelId) {
|
|
40
|
+
const base = modelId.replace(/[#:].*$/, '');
|
|
41
|
+
return base || modelId; // nothing but suffix — no base to fall back to
|
|
42
|
+
}
|
|
16
43
|
/**
|
|
17
44
|
* Look the model up in the provider's `/models` catalog and report whether its
|
|
18
45
|
* input modalities include `image`. `null` = the catalog can't say.
|
|
@@ -36,15 +63,16 @@ export async function supportsImageInput(baseUrl, apiKey, modelId, fetchImpl = f
|
|
|
36
63
|
catch {
|
|
37
64
|
return null;
|
|
38
65
|
}
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
41
|
-
return null;
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
66
|
+
const catalog = CatalogSchema.safeParse(body);
|
|
67
|
+
if (!catalog.success)
|
|
68
|
+
return null; // not a models catalog at all
|
|
69
|
+
const rows = catalog.data.data;
|
|
70
|
+
const base = baseModelId(modelId);
|
|
71
|
+
const model = rows.find((row) => row?.id === modelId) ??
|
|
72
|
+
(base === modelId ? undefined : rows.find((row) => row?.id === base));
|
|
73
|
+
const modalities = model?.architecture?.input_modalities;
|
|
74
|
+
if (!modalities)
|
|
75
|
+
return null; // model unlisted, or catalog says nothing (e.g. z.ai)
|
|
48
76
|
return modalities.includes('image');
|
|
49
77
|
}
|
|
50
78
|
//# sourceMappingURL=capabilities.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/agent/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;
|
|
1
|
+
{"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/agent/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,0FAA0F;AAC1F,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE;CACvF,CAAC,CAAC;AAEH;;;GAGG;AACH,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;IAC7B,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;CACzD,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,SAAS,WAAW,CAAC,OAAe;IAClC,MAAM,IAAI,GAAG,O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E,CAAC,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,CAAC,CAAC;IAExE,MAAM,UAAU,GAAG,KAAK,EAAE,YAAY,EAAE,gBAAgB,CAAC;IACzD,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC,CAAC,sDAAsD;IACpF,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC"}
|
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,9 +23,19 @@
|
|
|
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';
|
|
25
|
-
/**
|
|
26
|
-
|
|
26
|
+
import type { Bug, Findings, Step, VisualIssue } from '../findings/schema.js';
|
|
27
|
+
/**
|
|
28
|
+
* Safety cap on driver steps before the loop force-stops (paired with
|
|
29
|
+
* `hasToolCall('report')`).
|
|
30
|
+
*
|
|
31
|
+
* Raised from 30 on measurement, not taste: the tool's own headline scenario —
|
|
32
|
+
* register an account, log in, add two todos, toggle one, then exercise three
|
|
33
|
+
* filters — spent all 30 steps and died one action short of reporting, which
|
|
34
|
+
* costs the entire run (no verdict, no findings, full token spend). The observed
|
|
35
|
+
* pace is ~3s/step, so 60 still finishes well inside the default 300s wall-clock
|
|
36
|
+
* cap, which remains the real bound on what a run costs.
|
|
37
|
+
*/
|
|
38
|
+
export declare const DEFAULT_MAX_STEPS = 60;
|
|
27
39
|
/** Kickoff turn — the story lives in `instructions`; this nudges the driver to start the loop. */
|
|
28
40
|
export declare const KICKOFF_PROMPT = "Begin. Work toward the goal with observe/act/look, then call report exactly once with your verdict.";
|
|
29
41
|
/** The driver's inner belt — the four fat tools the loop drives (see `idea/mcp-tools.md`). */
|
|
@@ -43,18 +55,30 @@ export interface ProgressWriter {
|
|
|
43
55
|
/** Validate + write the current (running) findings; returns the path written. */
|
|
44
56
|
writeFindings(findings: Findings): Promise<string>;
|
|
45
57
|
}
|
|
46
|
-
/** The slice of a finished step the running flush reads — `
|
|
58
|
+
/** The slice of a finished step the running flush reads — `look`/`observe` outputs + what ran. */
|
|
47
59
|
export interface FinishedStep {
|
|
48
60
|
/** Tools called this step; a `report` call marks the terminal step (verdict owned elsewhere). */
|
|
49
61
|
toolCalls: ReadonlyArray<{
|
|
50
62
|
toolName: string;
|
|
51
63
|
input?: unknown;
|
|
52
64
|
}>;
|
|
53
|
-
/** Tool results this step; `
|
|
65
|
+
/** Tool results this step; `look`/`observe` outputs become streamed findings. */
|
|
54
66
|
toolResults: ReadonlyArray<{
|
|
55
67
|
toolName: string;
|
|
56
68
|
output: unknown;
|
|
57
69
|
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Raw step content, AI SDK 6 shape — a *rejected* tool call lands here as a
|
|
72
|
+
* `tool-error` part, never in {@link toolResults} (that array only ever holds
|
|
73
|
+
* successful `tool-result` parts). Optional so hand-built test fixtures that
|
|
74
|
+
* never fail a tool call can omit it; `describeStep` treats an absent array as
|
|
75
|
+
* "no errors" rather than throwing.
|
|
76
|
+
*/
|
|
77
|
+
content?: ReadonlyArray<{
|
|
78
|
+
type: string;
|
|
79
|
+
toolName?: string;
|
|
80
|
+
error?: unknown;
|
|
81
|
+
}>;
|
|
58
82
|
}
|
|
59
83
|
/**
|
|
60
84
|
* `prepareStep`: fold mid-run messages into the next model turn. Drains the inbox
|
|
@@ -90,18 +114,43 @@ export declare const BUDGET_WARN = 6;
|
|
|
90
114
|
* budget. `stepNumber` is the 0-based index of the step about to run.
|
|
91
115
|
*/
|
|
92
116
|
export declare function budgetNudge(stepNumber: number, maxSteps: number): string | null;
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
/**
|
|
118
|
+
* Lift a finished step's `look` results into visual findings — each issue the
|
|
119
|
+
* vision guy flagged, carrying the frame it was judged on as evidence.
|
|
120
|
+
*/
|
|
121
|
+
export declare function visualFrom(toolResults: FinishedStep['toolResults']): VisualIssue[];
|
|
122
|
+
/**
|
|
123
|
+
* Lift a finished step's `observe` console reads into bugs — ERROR rows only
|
|
124
|
+
* (warn/log/info are working noise, not findings). The console channel is a ring
|
|
125
|
+
* buffer read non-destructively, so a re-read returns rows already lifted;
|
|
126
|
+
* {@link progressForStep} dedupes by message before they land.
|
|
127
|
+
*/
|
|
128
|
+
export declare function consoleBugsFrom(toolResults: FinishedStep['toolResults']): Bug[];
|
|
129
|
+
/**
|
|
130
|
+
* The run-long accumulators the running flush reads: the shared act-`steps` trail
|
|
131
|
+
* (the SAME array the `act` and `report` tools hold) plus the findings streamed off
|
|
132
|
+
* the belt — `look`'s visual issues and error-level console rows. Streaming those
|
|
133
|
+
* is what keeps a crashed, aborted or step-capped run's findings file complete;
|
|
134
|
+
* before, they lived only in model context until `report`.
|
|
135
|
+
*/
|
|
136
|
+
export interface RunTrail {
|
|
137
|
+
/** Ordered act trail, written by `act` as each act finishes (shared with `report`). */
|
|
138
|
+
steps: Step[];
|
|
139
|
+
/** Console bugs seen so far, deduped by message. */
|
|
140
|
+
bugs: Bug[];
|
|
141
|
+
/** Visual issues seen so far, deduped by issue + location. */
|
|
142
|
+
visual: VisualIssue[];
|
|
143
|
+
}
|
|
98
144
|
/**
|
|
99
145
|
* 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
|
|
146
|
+
* terminal `report` step (it owns the verdict, and already merged the trail — see
|
|
147
|
+
* `belt/report.ts`); otherwise appends this step's NEW `look` issues and console
|
|
148
|
+
* errors to `running` (mutated in place) and returns the `running` findings to
|
|
149
|
+
* persist — act steps are already on `running.steps`, recorded by `act` itself.
|
|
150
|
+
* `null` when the step surfaced nothing new — no act, and every issue/error
|
|
151
|
+
* already streamed.
|
|
103
152
|
*/
|
|
104
|
-
export declare function progressForStep(step: FinishedStep,
|
|
153
|
+
export declare function progressForStep(step: FinishedStep, running: RunTrail): Findings | null;
|
|
105
154
|
/** Everything the loop needs to run one debug session. */
|
|
106
155
|
export interface DebugAgentOptions {
|
|
107
156
|
/** fast guy — the blind text driver running the high-frequency click loop. */
|
|
@@ -117,10 +166,10 @@ export interface DebugAgentOptions {
|
|
|
117
166
|
/** Optional sink for a human-readable step trail (`logs/agent.log`). */
|
|
118
167
|
log?: AgentLog;
|
|
119
168
|
/**
|
|
120
|
-
* Shared act-trail the running flush
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
169
|
+
* Shared act-trail the `act` tool writes, the running flush snapshots and the
|
|
170
|
+
* `report` tool merges into the verdict's `steps` — pass the SAME array the
|
|
171
|
+
* belt's act trail holds so the write and its counts agree. Defaults to a fresh
|
|
172
|
+
* array (an unwired loop then flushes no steps).
|
|
124
173
|
*/
|
|
125
174
|
trail?: Step[];
|
|
126
175
|
/** Step safety cap; defaults to {@link DEFAULT_MAX_STEPS}. */
|