@developerz.ai/ui-debugger-mcp 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/adapters/browser/browser-adapter.d.ts +1 -1
  2. package/dist/adapters/browser/browser-adapter.js +122 -4
  3. package/dist/adapters/browser/browser-adapter.js.map +1 -1
  4. package/dist/adapters/browser/query.d.ts +3 -2
  5. package/dist/adapters/browser/query.js +68 -2
  6. package/dist/adapters/browser/query.js.map +1 -1
  7. package/dist/adapters/contract.d.ts +16 -0
  8. package/dist/agent/belt/look.d.ts +37 -0
  9. package/dist/agent/belt/look.js +96 -4
  10. package/dist/agent/belt/look.js.map +1 -1
  11. package/dist/agent/belt/observe.d.ts +13 -1
  12. package/dist/agent/belt/observe.js +63 -9
  13. package/dist/agent/belt/observe.js.map +1 -1
  14. package/dist/agent/capabilities.d.ts +30 -0
  15. package/dist/agent/capabilities.js +50 -0
  16. package/dist/agent/capabilities.js.map +1 -0
  17. package/dist/agent/loop.d.ts +10 -0
  18. package/dist/agent/loop.js +61 -5
  19. package/dist/agent/loop.js.map +1 -1
  20. package/dist/agent/prompts/debug-agent.d.ts +1 -1
  21. package/dist/agent/prompts/debug-agent.js +6 -0
  22. package/dist/agent/prompts/debug-agent.js.map +1 -1
  23. package/dist/agent/prompts/web-addendum.d.ts +1 -1
  24. package/dist/agent/prompts/web-addendum.js +33 -3
  25. package/dist/agent/prompts/web-addendum.js.map +1 -1
  26. package/dist/agent/provider.d.ts +12 -3
  27. package/dist/agent/provider.js +13 -8
  28. package/dist/agent/provider.js.map +1 -1
  29. package/dist/errors.d.ts +8 -0
  30. package/dist/errors.js +12 -0
  31. package/dist/errors.js.map +1 -1
  32. package/dist/main.js +16 -3
  33. package/dist/main.js.map +1 -1
  34. package/dist/services/session-builder.d.ts +6 -0
  35. package/dist/services/session-builder.js +4 -2
  36. package/dist/services/session-builder.js.map +1 -1
  37. package/package.json +1 -1
@@ -40,6 +40,8 @@ export declare const ObserveInputSchema: z.ZodObject<{
40
40
  role: "role";
41
41
  bounds: "bounds";
42
42
  enabled: "enabled";
43
+ testid: "testid";
44
+ style: "style";
43
45
  }>>>;
44
46
  filters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodArray<z.ZodString>]>>>;
45
47
  limit: z.ZodOptional<z.ZodNumber>;
@@ -53,6 +55,7 @@ export declare const ObserveInputSchema: z.ZodObject<{
53
55
  height: z.ZodNumber;
54
56
  }, z.core.$strip>;
55
57
  enabled: z.ZodBoolean;
58
+ testid: z.ZodOptional<z.ZodString>;
56
59
  }, z.core.$strip>]>>;
57
60
  }, z.core.$strip>;
58
61
  export type ObserveInput = z.infer<typeof ObserveInputSchema>;
@@ -78,6 +81,14 @@ export type ObserveResult = {
78
81
  count: number;
79
82
  entries: NetworkEntry[];
80
83
  };
84
+ /**
85
+ * Accept a JSON-*stringified* node for `within`. Drivers routinely paste the node
86
+ * back as a string (`within: "{\"role\": …}"`); before this coercion that string
87
+ * fell through as a selector, normalized to `text={"role"…}`, matched nothing, and
88
+ * returned an empty tree with no clue why — the single biggest step-waster observed.
89
+ * Garbage-that-looks-like-JSON fails loud instead of silently reading the whole page.
90
+ */
91
+ export declare function coerceWithin(within: ObserveInput['within']): ObserveInput['within'];
81
92
  /**
82
93
  * Route one `observe` call to the adapter and shape the result. Pure over the
83
94
  * {@link Adapter} + {@link EvidenceRecorder} seams (no `tool()` wrapper), so it
@@ -88,7 +99,7 @@ export declare function runObserve(adapter: Adapter, recorder: EvidenceRecorder,
88
99
  export declare function createObserveTool(adapter: Adapter, recorder: EvidenceRecorder): import("ai").Tool<{
89
100
  kind: "screenshot" | "console" | "network" | "tree";
90
101
  query?: string | undefined;
91
- fields?: ("name" | "role" | "bounds" | "enabled")[] | undefined;
102
+ fields?: ("name" | "role" | "bounds" | "enabled" | "testid" | "style")[] | undefined;
92
103
  filters?: Record<string, string | number | boolean | string[]> | undefined;
93
104
  limit?: number | undefined;
94
105
  within?: string | {
@@ -101,5 +112,6 @@ export declare function createObserveTool(adapter: Adapter, recorder: EvidenceRe
101
112
  height: number;
102
113
  };
103
114
  enabled: boolean;
115
+ testid?: string | undefined;
104
116
  } | undefined;
105
117
  }, ObserveResult>;
@@ -29,7 +29,26 @@ import { AgentError } from '../../errors.js';
29
29
  /** The four observable channels `kind` selects (each routes to one contract method). */
30
30
  const OBSERVE_KINDS = ['tree', 'screenshot', 'console', 'network'];
31
31
  /** Selectable {@link Node} columns — the `fields` projection whitelist (contract-level). */
32
- const NODE_FIELDS = ['role', 'name', 'bounds', 'enabled'];
32
+ const NODE_FIELDS = [
33
+ 'role',
34
+ 'name',
35
+ 'bounds',
36
+ 'enabled',
37
+ 'testid',
38
+ 'style',
39
+ ];
40
+ /**
41
+ * Columns a no-`fields` read returns. `style` (colour + contrast per text node)
42
+ * is opt-in only — on a 200-node default read it would triple the payload the
43
+ * text driver re-reads every step for data it rarely needs.
44
+ */
45
+ const DEFAULT_PROJECTION = [
46
+ 'role',
47
+ 'name',
48
+ 'bounds',
49
+ 'enabled',
50
+ 'testid',
51
+ ];
33
52
  /** One `filters` predicate value; arrays back `_in`-style set membership (matches `FilterValue`). */
34
53
  const FilterValueSchema = z.union([z.string(), z.number(), z.boolean(), z.array(z.string())]);
35
54
  /** On-screen rectangle backing a {@link Node} `within` reference. */
@@ -45,6 +64,7 @@ const NodeSchema = z.object({
45
64
  name: z.string(),
46
65
  bounds: BoundsSchema,
47
66
  enabled: z.boolean(),
67
+ testid: z.string().optional(),
48
68
  });
49
69
  /** `observe` input — flat + SQL-like; `kind` picks the table, the rest compose the read. */
50
70
  export const ObserveInputSchema = z.object({
@@ -65,7 +85,7 @@ export const ObserveInputSchema = z.object({
65
85
  within: z
66
86
  .union([z.string(), NodeSchema])
67
87
  .optional()
68
- .describe('tree scope: restrict to a subtree/region (a selector or a node)'),
88
+ .describe('tree scope: restrict to a subtree/region (a selector string, or a node OBJECT exactly as observe returned it — not a JSON string)'),
69
89
  });
70
90
  /** ARIA roles Playwright's `role=` engine accepts (others fall back to a text selector). */
71
91
  const ARIA_ROLES = new Set([
@@ -100,6 +120,9 @@ const ARIA_ROLES = new Set([
100
120
  * `null` for an unnamed, non-semantic node (the agent targets those by other means).
101
121
  */
102
122
  function baseSelector(node) {
123
+ // A test hook beats everything: document-unique, stable across renames/moves.
124
+ if (node.testid)
125
+ return `data-testid=${JSON.stringify(node.testid)}`;
103
126
  const name = node.name.trim();
104
127
  if (node.role && ARIA_ROLES.has(node.role) && name) {
105
128
  return `role=${node.role}[name=${JSON.stringify(name)} i]`;
@@ -117,15 +140,20 @@ function baseSelector(node) {
117
140
  * index — and even a bare role/text selector — can resolve a different element when
118
141
  * `act` replays it with an unscoped, document-wide `find` (e.g. header "Settings"
119
142
  * instead of the sidebar "Settings" the narrowed read returned). In that case we
120
- * emit no `target`: better the agent falls back (visible text / `role "name"`) than
121
- * act on the wrong node.
143
+ * emit no `target` — EXCEPT a `data-testid` one, which is document-unique and
144
+ * survives any scoping. Otherwise, better the agent falls back (visible text /
145
+ * `role "name"`) than act on the wrong node.
122
146
  */
123
147
  function withTargets(nodes, fields, scoped = false) {
124
148
  const seen = new Map();
149
+ const projection = fields && fields.length > 0 ? fields : DEFAULT_PROJECTION;
125
150
  return nodes.map((node) => {
126
- const projected = fields && fields.length > 0 ? pick(node, fields) : { ...node };
127
- if (scoped)
151
+ const projected = pick(node, projection);
152
+ if (scoped) {
153
+ if (node.testid)
154
+ projected.target = `data-testid=${JSON.stringify(node.testid)}`;
128
155
  return projected;
156
+ }
129
157
  const base = baseSelector(node);
130
158
  if (!base)
131
159
  return projected;
@@ -138,10 +166,35 @@ function withTargets(nodes, fields, scoped = false) {
138
166
  /** Pick a subset of keys off an object (a typed `SELECT cols`) for the `fields` projection. */
139
167
  function pick(obj, keys) {
140
168
  const out = {};
169
+ // Skip absent optionals (testid/style) so they never serialize as explicit nulls.
141
170
  for (const key of keys)
142
- out[key] = obj[key];
171
+ if (obj[key] !== undefined)
172
+ out[key] = obj[key];
143
173
  return out;
144
174
  }
175
+ /**
176
+ * Accept a JSON-*stringified* node for `within`. Drivers routinely paste the node
177
+ * back as a string (`within: "{\"role\": …}"`); before this coercion that string
178
+ * fell through as a selector, normalized to `text={"role"…}`, matched nothing, and
179
+ * returned an empty tree with no clue why — the single biggest step-waster observed.
180
+ * Garbage-that-looks-like-JSON fails loud instead of silently reading the whole page.
181
+ */
182
+ export function coerceWithin(within) {
183
+ if (typeof within !== 'string' || !within.trimStart().startsWith('{'))
184
+ return within;
185
+ let data;
186
+ try {
187
+ data = JSON.parse(within);
188
+ }
189
+ catch {
190
+ throw new AgentError('observe `within` looks like a JSON node but does not parse — pass the node OBJECT exactly as observe returned it, or a selector string');
191
+ }
192
+ const parsed = NodeSchema.safeParse(data);
193
+ if (!parsed.success) {
194
+ throw new AgentError('observe `within` was a JSON string but not a valid node (needs role/name/bounds/enabled) — pass a node from a previous observe, or a selector string');
195
+ }
196
+ return parsed.data;
197
+ }
145
198
  /**
146
199
  * Route one `observe` call to the adapter and shape the result. Pure over the
147
200
  * {@link Adapter} + {@link EvidenceRecorder} seams (no `tool()` wrapper), so it
@@ -151,8 +204,9 @@ export async function runObserve(adapter, recorder, input) {
151
204
  const { kind, query, fields, filters, limit, within } = input;
152
205
  switch (kind) {
153
206
  case 'tree': {
154
- const nodes = await adapter.readState({ query, filters, limit, within });
155
- const scoped = query !== undefined || within !== undefined || filters !== undefined;
207
+ const scope = coerceWithin(within);
208
+ const nodes = await adapter.readState({ query, filters, limit, within: scope });
209
+ const scoped = query !== undefined || scope !== undefined || filters !== undefined;
156
210
  const projected = withTargets(nodes, fields, scoped);
157
211
  return { kind, count: projected.length, nodes: projected };
158
212
  }
@@ -1 +1 @@
1
- {"version":3,"file":"observe.js","sourceRoot":"","sources":["../../../src/agent/belt/observe.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;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AAC,EAAE,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;AACH,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,iBAAiB,CAAC,OAAgB,EAAE,QAA0B;IAC5E,OAAO,IAAI,CAAC;QACV,WAAW,EACT,mRAAmR;QACrR,WAAW,EAAE,kBAAkB;QAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC;KACzD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Model capability probe — can a model take image input?
3
+ *
4
+ * Decides whether `look` can hand the frame straight to the DRIVER (self-look:
5
+ * same model for control + vision) instead of a second blind vision call. The
6
+ * answer comes from the provider's `/models` catalog the way OpenRouter exposes
7
+ * it: `data[].architecture.input_modalities` (e.g. `["text","image"]`).
8
+ *
9
+ * Three-valued on purpose: `true` / `false` when the catalog answers, `null`
10
+ * when it can't (endpoint missing, no `architecture` field — e.g. z.ai's
11
+ * OpenAI-style `/models` — network error). Callers treat `null` as "don't
12
+ * self-look": the separate-call path already fails soft (vision latch), while
13
+ * an image pushed at a text-only DRIVER would poison every later step of the
14
+ * run (the SDK re-sends tool results each turn).
15
+ */
16
+ /**
17
+ * The slice of `fetch` the probe needs — typed locally (the DOM lib is off
18
+ * project-wide), satisfied by the global `fetch` and by test fakes alike.
19
+ */
20
+ export type FetchLike = (url: string, init?: {
21
+ headers?: Record<string, string>;
22
+ }) => Promise<{
23
+ ok: boolean;
24
+ json(): Promise<unknown>;
25
+ }>;
26
+ /**
27
+ * Look the model up in the provider's `/models` catalog and report whether its
28
+ * input modalities include `image`. `null` = the catalog can't say.
29
+ */
30
+ export declare function supportsImageInput(baseUrl: string, apiKey: string, modelId: string, fetchImpl?: FetchLike): Promise<boolean | null>;
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Model capability probe — can a model take image input?
3
+ *
4
+ * Decides whether `look` can hand the frame straight to the DRIVER (self-look:
5
+ * same model for control + vision) instead of a second blind vision call. The
6
+ * answer comes from the provider's `/models` catalog the way OpenRouter exposes
7
+ * it: `data[].architecture.input_modalities` (e.g. `["text","image"]`).
8
+ *
9
+ * Three-valued on purpose: `true` / `false` when the catalog answers, `null`
10
+ * when it can't (endpoint missing, no `architecture` field — e.g. z.ai's
11
+ * OpenAI-style `/models` — network error). Callers treat `null` as "don't
12
+ * self-look": the separate-call path already fails soft (vision latch), while
13
+ * an image pushed at a text-only DRIVER would poison every later step of the
14
+ * run (the SDK re-sends tool results each turn).
15
+ */
16
+ /**
17
+ * Look the model up in the provider's `/models` catalog and report whether its
18
+ * input modalities include `image`. `null` = the catalog can't say.
19
+ */
20
+ export async function supportsImageInput(baseUrl, apiKey, modelId, fetchImpl = fetch) {
21
+ let res;
22
+ try {
23
+ res = await fetchImpl(`${baseUrl.replace(/\/$/, '')}/models`, {
24
+ headers: { Authorization: `Bearer ${apiKey}` },
25
+ });
26
+ }
27
+ catch {
28
+ return null; // catalog unreachable — not a run-blocking condition
29
+ }
30
+ if (!res.ok)
31
+ return null;
32
+ let body;
33
+ try {
34
+ body = await res.json();
35
+ }
36
+ catch {
37
+ return null;
38
+ }
39
+ const data = body.data;
40
+ if (!Array.isArray(data))
41
+ return null;
42
+ const model = data.find((m) => m?.id === modelId);
43
+ if (!model)
44
+ return null;
45
+ const modalities = model.architecture?.input_modalities;
46
+ if (!Array.isArray(modalities))
47
+ return null; // catalog exists but says nothing (e.g. z.ai)
48
+ return modalities.includes('image');
49
+ }
50
+ //# sourceMappingURL=capabilities.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capabilities.js","sourceRoot":"","sources":["../../src/agent/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiBH;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAe,EACf,MAAc,EACd,OAAe,EACf,YAAuB,KAAK;IAE5B,IAAI,GAAmC,CAAC;IACxC,IAAI,CAAC;QACH,GAAG,GAAG,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,SAAS,EAAE;YAC5D,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,MAAM,EAAE,EAAE;SAC/C,CAAC,CAAC;IACL,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC,CAAC,qDAAqD;IACpE,CAAC;IACD,IAAI,CAAC,GAAG,CAAC,EAAE;QAAE,OAAO,IAAI,CAAC;IACzB,IAAI,IAAa,CAAC;IAClB,IAAI,CAAC;QACH,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,GAAI,IAA2B,CAAC,IAAI,CAAC;IAC/C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACtC,MAAM,KAAK,GAAI,IAAuB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,KAAK,OAAO,CAAC,CAAC;IACtE,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,UAAU,GAAG,KAAK,CAAC,YAAY,EAAE,gBAAgB,CAAC;IACxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC;QAAE,OAAO,IAAI,CAAC,CAAC,8CAA8C;IAC3F,OAAO,UAAU,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC"}
@@ -71,6 +71,16 @@ export interface FinishedStep {
71
71
  export declare function foldInstructionsIntoStep(inbox: LoopInbox, standing: string[], messages: ModelMessage[]): {
72
72
  messages: ModelMessage[];
73
73
  } | Record<string, never>;
74
+ /** What a pruned frame collapses to — tells the driver how to get a fresh one. */
75
+ export declare const STALE_FRAME_NOTE = "[stale frame removed \u2014 call look again for a fresh screenshot]";
76
+ /**
77
+ * Keep only the NEWEST self-look frame in the transcript. The SDK re-sends every
78
+ * tool result on every step, so each `look` image would otherwise ride along for
79
+ * the rest of the run — N looks × M steps of image tokens. Rebuilt per step in
80
+ * `prepareStep` (overrides never persist), like the instruction fold. Returns the
81
+ * SAME array when there is at most one frame, preserving the no-change fast path.
82
+ */
83
+ export declare function pruneStaleFrames(messages: ModelMessage[]): ModelMessage[];
74
84
  /** Steps left at or below which the driver is nudged to wrap up and `report`. */
75
85
  export declare const BUDGET_WARN = 6;
76
86
  /**
@@ -52,6 +52,58 @@ export function foldInstructionsIntoStep(inbox, standing, messages) {
52
52
  };
53
53
  return { messages: [...messages, injected] };
54
54
  }
55
+ /** What a pruned frame collapses to — tells the driver how to get a fresh one. */
56
+ export const STALE_FRAME_NOTE = '[stale frame removed — call look again for a fresh screenshot]';
57
+ /** Whether a tool-result part carries a self-look frame (`content` output with `file-data`). */
58
+ function isLookFrame(part) {
59
+ if (typeof part !== 'object' || part === null)
60
+ return false;
61
+ const p = part;
62
+ return (p.type === 'tool-result' &&
63
+ p.toolName === 'look' &&
64
+ p.output?.type === 'content' &&
65
+ Array.isArray(p.output.value) &&
66
+ p.output.value.some((v) => v?.type === 'file-data'));
67
+ }
68
+ /** Collapse every `file-data` part of a look tool-result to the stale-frame note. */
69
+ function stripFrame(message) {
70
+ if (!Array.isArray(message.content))
71
+ return message;
72
+ const content = message.content.map((part) => {
73
+ if (!isLookFrame(part))
74
+ return part;
75
+ const p = part;
76
+ return {
77
+ ...part,
78
+ output: {
79
+ ...p.output,
80
+ value: p.output.value.map((v) => v?.type === 'file-data' ? { type: 'text', text: STALE_FRAME_NOTE } : v),
81
+ },
82
+ };
83
+ });
84
+ return { ...message, content };
85
+ }
86
+ /**
87
+ * Keep only the NEWEST self-look frame in the transcript. The SDK re-sends every
88
+ * tool result on every step, so each `look` image would otherwise ride along for
89
+ * the rest of the run — N looks × M steps of image tokens. Rebuilt per step in
90
+ * `prepareStep` (overrides never persist), like the instruction fold. Returns the
91
+ * SAME array when there is at most one frame, preserving the no-change fast path.
92
+ */
93
+ export function pruneStaleFrames(messages) {
94
+ const frameIndexes = [];
95
+ messages.forEach((message, index) => {
96
+ if (message.role === 'tool' &&
97
+ Array.isArray(message.content) &&
98
+ message.content.some(isLookFrame)) {
99
+ frameIndexes.push(index);
100
+ }
101
+ });
102
+ if (frameIndexes.length <= 1)
103
+ return messages;
104
+ const stale = new Set(frameIndexes.slice(0, -1));
105
+ return messages.map((message, index) => (stale.has(index) ? stripFrame(message) : message));
106
+ }
55
107
  /** Steps left at or below which the driver is nudged to wrap up and `report`. */
56
108
  export const BUDGET_WARN = 6;
57
109
  /**
@@ -152,12 +204,16 @@ export function createDebugAgent(options) {
152
204
  instructions,
153
205
  stopWhen: [stepCountIs(maxSteps), hasToolCall('report')],
154
206
  prepareStep: ({ messages, stepNumber }) => {
155
- const withInbox = foldInstructionsIntoStep(inbox, standing, messages);
207
+ // Self-look frame hygiene first: only the newest screenshot stays live.
208
+ const pruned = pruneStaleFrames(messages);
209
+ const withInbox = foldInstructionsIntoStep(inbox, standing, pruned);
210
+ const base = 'messages' in withInbox ? withInbox.messages : pruned;
156
211
  const nudge = budgetNudge(stepNumber, maxSteps);
157
- if (!nudge)
158
- return withInbox;
159
- const base = 'messages' in withInbox ? withInbox.messages : messages;
160
- return { messages: [...base, { role: 'user', content: nudge }] };
212
+ if (nudge)
213
+ return { messages: [...base, { role: 'user', content: nudge }] };
214
+ if (base === messages)
215
+ return {};
216
+ return { messages: base };
161
217
  },
162
218
  onStepFinish: async (step) => {
163
219
  stepIndex += 1;
@@ -1 +1 @@
1
- {"version":3,"file":"loop.js","sourceRoot":"","sources":["../../src/agent/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EACL,WAAW,EAGX,WAAW,EAEX,aAAa,GACd,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,CAAC,EAAE,MAA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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,2EAA2E;YAC3E,0EAA0E;YAC1E,2EAA2E;YAC3E,gFAAgF;YAChF,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC7C,IAAI,OAAO;gBAAE,MAAM,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACrD,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,4 +6,4 @@
6
6
  * Extended per-target via addenda (see `web-addendum.ts`) and composed with
7
7
  * the session story + criteria via `compose.ts`.
8
8
  */
9
- export declare const DEBUG_AGENT_BASE_PROMPT = "You are the debug agent \u2014 a fast, blind driver that tests UIs and reports findings.\nYou control the target (browser, desktop, or mobile) through structured tools.\nYou NEVER see pixels directly. When visual judgment is needed, call `look`.\n\n## Your tool belt\n\n- `observe` \u2014 read state: DOM tree, screenshot path, console logs, network requests.\n- `act` \u2014 take action: click, type, key, scroll, navigate, wait.\n- `look` \u2014 ask the vision model to describe/judge a screenshot. Use when you need eyes.\n- `report` \u2014 emit the final structured findings and STOP. Call once; it ends your run.\n\n## Structure-first rule\n\nAlways prefer structured reads over vision:\n1. Use `observe({kind:\"tree\"})` to read DOM / accessibility tree.\n2. Use `observe({kind:\"console\"})` and `observe({kind:\"network\"})` to watch errors.\n3. Call `look` ONLY when visual judgment is needed \u2014 layout, colour, alignment,\n \"does this look right?\", \"is this element centred?\". Vision tokens are expensive.\n\nNever screenshot for information you can read from the tree or logs.\n\n## When to act vs observe\n\n- Start with `observe` to understand the current state.\n- `act` to advance: navigate, click interactive elements, fill inputs.\n- After each `act`, re-`observe` to confirm the effect before acting again.\n- If a step requires visual confirmation (looks good? aligned?), call `look`.\n- Record a visual finding any time `look` surfaces an issue; attach the screenshot path.\n\n## Mid-run instructions\n\nBetween steps, the smart agent may inject new messages. Read them, fold them into\nyour plan, and adapt. They may add work, redirect you, or answer a question.\n\n## What to record at each step\n\nFor every meaningful action or check, record a step entry:\n```\n{ step: \"Clicked Checkout button\", ok: true | false, note: \"...\", screenshot?: \"path\" }\n```\n\n- `ok: false` if the step failed or produced an unexpected result.\n- Attach a screenshot path when evidence matters (errors, visual issues, flows).\n\n## Functional findings (bugs)\n\nCollect bugs as you go. Three kinds:\n\n| kind | when to record |\n|-----------|----------------|\n| `console` | JS errors, unhandled promise rejections, error-level logs |\n| `network` | failed/hung requests (4xx/5xx, timeouts, CORS) |\n| `flow` | dead buttons, wrong navigation, broken flows, data not saved |\n\nEach bug: `{ kind, detail: \"concise description\", evidence?: \"screenshot or log path\" }`\n\n## Visual findings\n\nCollect visual issues discovered via `look`. Each:\n`{ issue: \"what\", where: \"which component/area\", severity: \"low|medium|high\", screenshot?: \"path\" }`\n\nSeverities:\n- `high` \u2014 broken layout, text overlap, invisible interactive elements.\n- `medium` \u2014 misalignment, bad spacing, contrast issue.\n- `low` \u2014 minor polish (rounding, colour shade, icon size).\n\n## Pass / fail verdict\n\nIf `criteria` were given, evaluate each one and set `status:\"passed\"` only when ALL\ncriteria pass. If any criterion fails, set `status:\"failed\"`.\n\nWithout explicit criteria, use your judgment:\n- `passed`: the goal was achieved, no blocking bugs, UI looks acceptable.\n- `failed`: any blocking functional bug OR a high-severity visual issue prevents the goal.\n\n## Terminal `report` call\n\nWhen the goal is complete (or you hit the step limit), call `report` exactly once:\n\n```json\n{\n \"status\": \"passed\" | \"failed\",\n \"steps\": [ { \"step\": \"...\", \"ok\": true, \"note\": \"...\", \"screenshot\": \"...\" } ],\n \"bugs\": [ { \"kind\": \"console\"|\"network\"|\"flow\", \"detail\": \"...\", \"evidence\": \"...\" } ],\n \"visual\": [ { \"issue\": \"...\", \"where\": \"...\", \"severity\": \"low\"|\"medium\"|\"high\", \"screenshot\": \"...\" } ],\n \"summary\": \"One-paragraph verdict the smart agent can act on.\"\n}\n```\n\nDo NOT stop before calling `report`. Do NOT call `report` more than once.\nThe summary is for the smart agent \u2014 make it actionable: what broke, where, what to fix.\n";
9
+ export declare const DEBUG_AGENT_BASE_PROMPT = "You are the debug agent \u2014 a fast, blind driver that tests UIs and reports findings.\nYou control the target (browser, desktop, or mobile) through structured tools.\nYou NEVER see pixels directly. When visual judgment is needed, call `look`.\n\n## Your tool belt\n\n- `observe` \u2014 read state: DOM tree, screenshot path, console logs, network requests.\n- `act` \u2014 take action: click, type, key, scroll, navigate, wait.\n- `look` \u2014 ask the vision model to describe/judge a screenshot. Use when you need eyes.\n- `report` \u2014 emit the final structured findings and STOP. Call once; it ends your run.\n\n## Structure-first rule\n\nAlways prefer structured reads over vision:\n1. Use `observe({kind:\"tree\"})` to read DOM / accessibility tree.\n2. Use `observe({kind:\"console\"})` and `observe({kind:\"network\"})` to watch errors.\n3. Call `look` ONLY when visual judgment is needed \u2014 layout, colour, alignment,\n \"does this look right?\", \"is this element centred?\". Vision tokens are expensive.\n\nNever screenshot for information you can read from the tree or logs.\n\n## When to act vs observe\n\n- Start with `observe` to understand the current state.\n- `act` to advance: navigate, click interactive elements, fill inputs.\n- After each `act`, re-`observe` to confirm the effect before acting again.\n- If a step requires visual confirmation (looks good? aligned?), call `look`.\n- Record a visual finding any time `look` surfaces an issue; attach the screenshot path.\n- Repeated elements (e.g. several \"Add to cart\" buttons): test EACH instance and\n report exactly which work and which fail. Never generalize one instance's\n behavior to all of them.\n- If `look` reports it is unavailable for this run, do not call it again \u2014 finish\n the structural checks and state in your report summary that visual checks could\n not be performed (unverified, not passed).\n\n## Mid-run instructions\n\nBetween steps, the smart agent may inject new messages. Read them, fold them into\nyour plan, and adapt. They may add work, redirect you, or answer a question.\n\n## What to record at each step\n\nFor every meaningful action or check, record a step entry:\n```\n{ step: \"Clicked Checkout button\", ok: true | false, note: \"...\", screenshot?: \"path\" }\n```\n\n- `ok: false` if the step failed or produced an unexpected result.\n- Attach a screenshot path when evidence matters (errors, visual issues, flows).\n\n## Functional findings (bugs)\n\nCollect bugs as you go. Three kinds:\n\n| kind | when to record |\n|-----------|----------------|\n| `console` | JS errors, unhandled promise rejections, error-level logs |\n| `network` | failed/hung requests (4xx/5xx, timeouts, CORS) |\n| `flow` | dead buttons, wrong navigation, broken flows, data not saved |\n\nEach bug: `{ kind, detail: \"concise description\", evidence?: \"screenshot or log path\" }`\n\n## Visual findings\n\nCollect visual issues discovered via `look`. Each:\n`{ issue: \"what\", where: \"which component/area\", severity: \"low|medium|high\", screenshot?: \"path\" }`\n\nSeverities:\n- `high` \u2014 broken layout, text overlap, invisible interactive elements.\n- `medium` \u2014 misalignment, bad spacing, contrast issue.\n- `low` \u2014 minor polish (rounding, colour shade, icon size).\n\n## Pass / fail verdict\n\nIf `criteria` were given, evaluate each one and set `status:\"passed\"` only when ALL\ncriteria pass. If any criterion fails, set `status:\"failed\"`.\n\nWithout explicit criteria, use your judgment:\n- `passed`: the goal was achieved, no blocking bugs, UI looks acceptable.\n- `failed`: any blocking functional bug OR a high-severity visual issue prevents the goal.\n\n## Terminal `report` call\n\nWhen the goal is complete (or you hit the step limit), call `report` exactly once:\n\n```json\n{\n \"status\": \"passed\" | \"failed\",\n \"steps\": [ { \"step\": \"...\", \"ok\": true, \"note\": \"...\", \"screenshot\": \"...\" } ],\n \"bugs\": [ { \"kind\": \"console\"|\"network\"|\"flow\", \"detail\": \"...\", \"evidence\": \"...\" } ],\n \"visual\": [ { \"issue\": \"...\", \"where\": \"...\", \"severity\": \"low\"|\"medium\"|\"high\", \"screenshot\": \"...\" } ],\n \"summary\": \"One-paragraph verdict the smart agent can act on.\"\n}\n```\n\nDo NOT stop before calling `report`. Do NOT call `report` more than once.\nThe summary is for the smart agent \u2014 make it actionable: what broke, where, what to fix.\n";
@@ -35,6 +35,12 @@ Never screenshot for information you can read from the tree or logs.
35
35
  - After each \`act\`, re-\`observe\` to confirm the effect before acting again.
36
36
  - If a step requires visual confirmation (looks good? aligned?), call \`look\`.
37
37
  - Record a visual finding any time \`look\` surfaces an issue; attach the screenshot path.
38
+ - Repeated elements (e.g. several "Add to cart" buttons): test EACH instance and
39
+ 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).
38
44
 
39
45
  ## Mid-run instructions
40
46
 
@@ -1 +1 @@
1
- {"version":3,"file":"debug-agent.js","sourceRoot":"","sources":["../../../src/agent/prompts/debug-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4FtC,CAAC"}
1
+ {"version":3,"file":"debug-agent.js","sourceRoot":"","sources":["../../../src/agent/prompts/debug-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGtC,CAAC"}
@@ -6,4 +6,4 @@
6
6
  *
7
7
  * Provider-agnostic — no vendor tricks; any competent model drives the same loop.
8
8
  */
9
- export declare const WEB_ADDENDUM_PROMPT = "## Web target \u2014 CDP reach\n\nYour browser connection uses the Chrome DevTools Protocol (CDP).\nOne connection reaches everything: the current page, every iframe (including\nout-of-process), all tabs and windows, workers \u2014 plus DOM, console, network,\ninput, and screenshots. Use it deliberately.\n\n### CDP domains and when to reach for each\n\n| Domain | What it gives you | Use via |\n|-------------|-------------------|---------|\n| `Target` | enumerate/switch tabs and frames | `observe({kind:\"tree\"})` with `within` to scope to a frame |\n| `Page` | navigate, wait for load, capture screenshot | `act({action:\"navigate\"})`, `observe({kind:\"screenshot\"})` |\n| `DOM` | read/query the element tree, attributes, text | `observe({kind:\"tree\"})` |\n| `Runtime` | evaluate JS in a context (e.g. read a value not in the DOM) | `observe({kind:\"tree\", query:\"Runtime.evaluate:...\"})` |\n| `Network` | request/response status, failed requests, timing | `observe({kind:\"network\"})` |\n| `Log` | browser console messages, JS errors | `observe({kind:\"console\"})` |\n\n### DOM-first rule\n\nAlways try the structured path before asking for vision:\n1. `observe({kind:\"tree\"})` \u2014 read element roles, names, bounds, enabled state.\n2. If an element is not visible in the tree, try scrolling or waiting, then re-observe.\n3. Use `observe({kind:\"console\"})` and `observe({kind:\"network\"})` proactively after\n each meaningful action \u2014 errors land there before they surface visually.\n4. Only after the tree gives you no answer: call `look` for pixels.\n\n### Multi-frame / tab navigation\n\nIf the goal involves an iframe or a new tab:\n- Enumerate frames via the Target domain (use `observe` with appropriate scope).\n- Switch context to the target frame/tab before acting inside it.\n- After navigation, wait for the page to settle before reading state.\n\n### Login bypass\n\nIf the target has `?debug-ai=true` support (the app's captcha bypass gate),\nappend it to the login URL before navigating. This skips captcha only \u2014 not auth.\nThe app must have `ALLOW_AI_DEBUG_LOGIN=true` set in its environment.\n\n### Selectors \u2014 use the node's `target`, don't invent one\n\nMost actionable nodes from `observe({kind:\"tree\"})` carry a ready-to-use `target`\nstring (e.g. `role=button[name=\"Add to cart\" i]`, with `>> nth=N` when names repeat).\nWhen a node has a `target`, COPY it verbatim into `act({action, target})`.\nDo NOT hand-craft a selector \u2014 guessed CSS like `button[name=\"...\"]` will not resolve.\n\nIf a node has no `target` (unnamed/non-semantic, or a scoped `within`/`filters`\nread), you may pass its visible text as `target` (plain text resolves), or\n`role \"name\"`. Avoid XPath and positional CSS.\n\n### Console + network \u2014 watch always\n\nAfter every `act`, immediately:\n1. Check `observe({kind:\"console\"})` for JS errors or warnings.\n2. Check `observe({kind:\"network\"})` for failed requests (4xx/5xx).\n\nRecord any errors as `console` or `network` bugs with the request URL / error\nmessage as `detail` and the screenshot path as `evidence` when relevant.\n";
9
+ export declare const WEB_ADDENDUM_PROMPT = "## Web target \u2014 CDP reach\n\nYour browser connection uses the Chrome DevTools Protocol (CDP).\nOne connection reaches everything: the current page, every iframe (including\nout-of-process), all tabs and windows, workers \u2014 plus DOM, console, network,\ninput, and screenshots. Use it deliberately.\n\n### CDP domains and when to reach for each\n\n| Domain | What it gives you | Use via |\n|-------------|-------------------|---------|\n| `Page` | navigate, wait for load, capture screenshot | `act({action:\"navigate\"})`, `observe({kind:\"screenshot\"})` |\n| `DOM` | read/query the element tree, attributes, text | `observe({kind:\"tree\"})` |\n| `Network` | request/response status, failed requests, timing | `observe({kind:\"network\"})` |\n| `Log` | browser console messages, JS errors | `observe({kind:\"console\"})` |\n\n### DOM-first rule\n\nAlways try the structured path before asking for vision:\n1. `observe({kind:\"tree\"})` \u2014 read element roles, names, bounds, enabled state.\n2. If an element is not visible in the tree, try scrolling or waiting, then re-observe.\n3. Use `observe({kind:\"console\"})` and `observe({kind:\"network\"})` proactively after\n each meaningful action \u2014 errors land there before they surface visually.\n4. Only after the tree gives you no answer: call `look` for pixels.\n\n### Composing tree queries\n\n- `query` accepts: a bare HTML tag (`span`, `img`), CSS (`.cart span`),\n `role \"name\"` (`button \"Add to cart\"`), an explicit engine\n (`data-testid=cart-count`, `text=Subscribe`), or plain visible text.\n- Elements with a `data-testid` always appear in the default (no-query) tree with\n their `testid` \u2014 to read a counter/value, find its node and read `name` (the\n text content). Re-observe the same node after acting to verify a change.\n- `within` scopes the read: pass a selector string or a node OBJECT exactly as a\n previous observe returned it \u2014 never a JSON-stringified node.\n\n### Invisible text & contrast \u2014 no vision needed\n\nText-bearing nodes carry a `style` column = `{ color, backgroundColor, contrast }`\n(WCAG ratio 1\u201321). It is omitted by default \u2014 request it via `fields:[\"role\",\"name\",\"style\"]`\nor sweep all text in ONE call:\n`observe({kind:\"tree\", query:\"p, span, div, a, li\", filters:{contrast_lt: 4.5}})`\n(returns only hard-to-read text; empty = contrast is fine). Flag `contrast < 4.5`\nas a `medium` visual finding and `contrast < 1.5` as `high` (the text is\neffectively invisible). Always run one contrast sweep when the goal mentions\nreadability, contrast, or visual polish.\n\n### Follow links by CLICKING them \u2014 never invent URLs\n\nThe tree does not expose `href`s. To follow a link, `act({action:\"click\"})` its\nnode. Do NOT fabricate a URL from a link's label (e.g. label \"Help Center\" \u2192\nnavigating to `/help-center`): a guessed URL that 404s is YOUR error, not a site\nbug. Only `navigate` to URLs given in the goal or seen in network entries. If a\nlink's click target is hidden (e.g. inside a closed menu), hover/click the parent\nmenu item first, then re-observe.\n\n### Multi-frame / tab navigation\n\nIf the goal involves an iframe or a new tab:\n- Enumerate frames via the Target domain (use `observe` with appropriate scope).\n- Switch context to the target frame/tab before acting inside it.\n- After navigation, wait for the page to settle before reading state.\n\n### Login bypass\n\nIf the target has `?debug-ai=true` support (the app's captcha bypass gate),\nappend it to the login URL before navigating. This skips captcha only \u2014 not auth.\nThe app must have `ALLOW_AI_DEBUG_LOGIN=true` set in its environment.\n\n### Selectors \u2014 use the node's `target`, don't invent one\n\nMost actionable nodes from `observe({kind:\"tree\"})` carry a ready-to-use `target`\nstring (e.g. `data-testid=\"cart-count\"` when the element has a test id, else\n`role=button[name=\"Add to cart\" i]`, with `>> nth=N` when names repeat).\nWhen a node has a `target`, COPY it verbatim into `act({action, target})`.\nDo NOT hand-craft a selector \u2014 guessed CSS like `button[name=\"...\"]` will not resolve.\n\nIf a node has no `target` (unnamed/non-semantic, or a scoped `within`/`filters`\nread), you may pass its visible text as `target` (plain text resolves), or\n`role \"name\"`. Avoid XPath and positional CSS.\n\n### Console + network \u2014 watch always\n\nAfter every `act`, immediately:\n1. Check `observe({kind:\"console\"})` for JS errors or warnings.\n2. Check `observe({kind:\"network\"})` for failed requests (4xx/5xx).\n\nRecord any errors as `console` or `network` bugs with the request URL / error\nmessage as `detail` and the screenshot path as `evidence` when relevant.\n";
@@ -18,10 +18,8 @@ input, and screenshots. Use it deliberately.
18
18
 
19
19
  | Domain | What it gives you | Use via |
20
20
  |-------------|-------------------|---------|
21
- | \`Target\` | enumerate/switch tabs and frames | \`observe({kind:"tree"})\` with \`within\` to scope to a frame |
22
21
  | \`Page\` | navigate, wait for load, capture screenshot | \`act({action:"navigate"})\`, \`observe({kind:"screenshot"})\` |
23
22
  | \`DOM\` | read/query the element tree, attributes, text | \`observe({kind:"tree"})\` |
24
- | \`Runtime\` | evaluate JS in a context (e.g. read a value not in the DOM) | \`observe({kind:"tree", query:"Runtime.evaluate:..."})\` |
25
23
  | \`Network\` | request/response status, failed requests, timing | \`observe({kind:"network"})\` |
26
24
  | \`Log\` | browser console messages, JS errors | \`observe({kind:"console"})\` |
27
25
 
@@ -34,6 +32,37 @@ Always try the structured path before asking for vision:
34
32
  each meaningful action — errors land there before they surface visually.
35
33
  4. Only after the tree gives you no answer: call \`look\` for pixels.
36
34
 
35
+ ### Composing tree queries
36
+
37
+ - \`query\` accepts: a bare HTML tag (\`span\`, \`img\`), CSS (\`.cart span\`),
38
+ \`role "name"\` (\`button "Add to cart"\`), an explicit engine
39
+ (\`data-testid=cart-count\`, \`text=Subscribe\`), or plain visible text.
40
+ - Elements with a \`data-testid\` always appear in the default (no-query) tree with
41
+ their \`testid\` — to read a counter/value, find its node and read \`name\` (the
42
+ text content). Re-observe the same node after acting to verify a change.
43
+ - \`within\` scopes the read: pass a selector string or a node OBJECT exactly as a
44
+ previous observe returned it — never a JSON-stringified node.
45
+
46
+ ### Invisible text & contrast — no vision needed
47
+
48
+ Text-bearing nodes carry a \`style\` column = \`{ color, backgroundColor, contrast }\`
49
+ (WCAG ratio 1–21). It is omitted by default — request it via \`fields:["role","name","style"]\`
50
+ or sweep all text in ONE call:
51
+ \`observe({kind:"tree", query:"p, span, div, a, li", filters:{contrast_lt: 4.5}})\`
52
+ (returns only hard-to-read text; empty = contrast is fine). Flag \`contrast < 4.5\`
53
+ as a \`medium\` visual finding and \`contrast < 1.5\` as \`high\` (the text is
54
+ effectively invisible). Always run one contrast sweep when the goal mentions
55
+ readability, contrast, or visual polish.
56
+
57
+ ### Follow links by CLICKING them — never invent URLs
58
+
59
+ The tree does not expose \`href\`s. To follow a link, \`act({action:"click"})\` its
60
+ node. Do NOT fabricate a URL from a link's label (e.g. label "Help Center" →
61
+ navigating to \`/help-center\`): a guessed URL that 404s is YOUR error, not a site
62
+ bug. Only \`navigate\` to URLs given in the goal or seen in network entries. If a
63
+ link's click target is hidden (e.g. inside a closed menu), hover/click the parent
64
+ menu item first, then re-observe.
65
+
37
66
  ### Multi-frame / tab navigation
38
67
 
39
68
  If the goal involves an iframe or a new tab:
@@ -50,7 +79,8 @@ The app must have \`ALLOW_AI_DEBUG_LOGIN=true\` set in its environment.
50
79
  ### Selectors — use the node's \`target\`, don't invent one
51
80
 
52
81
  Most actionable nodes from \`observe({kind:"tree"})\` carry a ready-to-use \`target\`
53
- string (e.g. \`role=button[name="Add to cart" i]\`, with \`>> nth=N\` when names repeat).
82
+ string (e.g. \`data-testid="cart-count"\` when the element has a test id, else
83
+ \`role=button[name="Add to cart" i]\`, with \`>> nth=N\` when names repeat).
54
84
  When a node has a \`target\`, COPY it verbatim into \`act({action, target})\`.
55
85
  Do NOT hand-craft a selector — guessed CSS like \`button[name="..."]\` will not resolve.
56
86
 
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DlC,CAAC"}
1
+ {"version":3,"file":"web-addendum.js","sourceRoot":"","sources":["../../../src/agent/prompts/web-addendum.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0FlC,CAAC"}
@@ -8,10 +8,19 @@ export interface ProviderOptions {
8
8
  baseURL?: string;
9
9
  }
10
10
  /**
11
- * Create an OpenRouter provider with fallback resolution.
12
- * Resolves apiKey from: provided value → OPENAI_API_KEY → OPENROUTER_API_KEY
13
- * Resolves baseURL from: provided value → OPENAI_BASE_URL → DEFAULT_BASE_URL
11
+ * Resolve the provider endpoint the same way `createOpenRouterProvider` does —
12
+ * apiKey: provided value → OPENAI_API_KEY → OPENROUTER_API_KEY;
13
+ * baseURL: provided value → OPENAI_BASE_URL → DEFAULT_BASE_URL.
14
+ * Exported so capability probes hit the exact endpoint the models run against.
14
15
  * Throws ProviderError if no API key is found or if it's empty.
15
16
  */
17
+ export declare function resolveProviderConfig(options?: ProviderOptions): {
18
+ apiKey: string;
19
+ baseURL: string;
20
+ };
21
+ /**
22
+ * Create an OpenRouter provider with fallback resolution (see
23
+ * {@link resolveProviderConfig} for the chains).
24
+ */
16
25
  export declare function createOpenRouterProvider(options?: ProviderOptions): OpenRouterProvider;
17
26
  export type { OpenRouterProvider };
@@ -6,21 +6,26 @@ import { createOpenRouter } from '@openrouter/ai-sdk-provider';
6
6
  import { ProviderError } from '../errors.js';
7
7
  const DEFAULT_BASE_URL = 'https://openrouter.ai/api/v1';
8
8
  /**
9
- * Create an OpenRouter provider with fallback resolution.
10
- * Resolves apiKey from: provided value → OPENAI_API_KEY → OPENROUTER_API_KEY
11
- * Resolves baseURL from: provided value → OPENAI_BASE_URL → DEFAULT_BASE_URL
9
+ * Resolve the provider endpoint the same way `createOpenRouterProvider` does —
10
+ * apiKey: provided value → OPENAI_API_KEY → OPENROUTER_API_KEY;
11
+ * baseURL: provided value → OPENAI_BASE_URL → DEFAULT_BASE_URL.
12
+ * Exported so capability probes hit the exact endpoint the models run against.
12
13
  * Throws ProviderError if no API key is found or if it's empty.
13
14
  */
14
- export function createOpenRouterProvider(options = {}) {
15
- // Resolve API key with fallback chain
15
+ export function resolveProviderConfig(options = {}) {
16
16
  const apiKey = options.apiKey || process.env.OPENAI_API_KEY || process.env.OPENROUTER_API_KEY || '';
17
- // Validate API key
18
17
  if (!apiKey || apiKey.trim() === '') {
19
18
  throw new ProviderError('No API key found. Set OPENAI_API_KEY or OPENROUTER_API_KEY in the environment, or provide apiKey in options.');
20
19
  }
21
- // Resolve base URL with fallback
22
20
  const baseURL = options.baseURL || process.env.OPENAI_BASE_URL || DEFAULT_BASE_URL;
23
- // Create and return the provider
21
+ return { apiKey, baseURL };
22
+ }
23
+ /**
24
+ * Create an OpenRouter provider with fallback resolution (see
25
+ * {@link resolveProviderConfig} for the chains).
26
+ */
27
+ export function createOpenRouterProvider(options = {}) {
28
+ const { apiKey, baseURL } = resolveProviderConfig(options);
24
29
  return createOpenRouter({
25
30
  apiKey,
26
31
  ...(baseURL ? { baseURL } : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/agent/provider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,gBAAgB,EAA2B,MAAM,6BAA6B,CAAC;AACxF,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,gBAAgB,GAAG,8BAA8B,CAAC;AAOxD;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,UAA2B,EAAE;IACpE,sCAAsC;IACtC,MAAM,MAAM,GACV,OAAO,CAAC,MAAM,IAAI,OAAO,CAAC,GAAG,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