@elyracode/browser-tools 0.9.56 → 0.9.58
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/CHANGELOG.md +8 -0
- package/extensions/index.ts +33 -24
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9.58] - 2026-11-18
|
|
4
|
+
|
|
5
|
+
## [0.9.57] - 2026-11-10
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Tool failures were returned as normal results (`isError` on the return value is ignored) and the model saw them as successes; they now throw so the result is marked as an error
|
|
10
|
+
|
|
3
11
|
## [0.9.56] - 2026-11-01
|
|
4
12
|
|
|
5
13
|
## [0.9.55] - 2026-10-21
|
package/extensions/index.ts
CHANGED
|
@@ -173,10 +173,6 @@ function ok(text: string) {
|
|
|
173
173
|
return { content: [{ type: "text" as const, text }], details: {} };
|
|
174
174
|
}
|
|
175
175
|
|
|
176
|
-
function err(text: string) {
|
|
177
|
-
return { content: [{ type: "text" as const, text }], details: {}, isError: true as const };
|
|
178
|
-
}
|
|
179
|
-
|
|
180
176
|
interface Target {
|
|
181
177
|
role?: string;
|
|
182
178
|
name?: string;
|
|
@@ -223,11 +219,11 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
223
219
|
}),
|
|
224
220
|
execute: async (_id, params) => {
|
|
225
221
|
const result = await ensurePage();
|
|
226
|
-
if ("error" in result)
|
|
222
|
+
if ("error" in result) throw new Error(result.error);
|
|
227
223
|
try {
|
|
228
224
|
await result.page.goto(params.url, { waitUntil: params.wait_until ?? "load", timeout: 30_000 });
|
|
229
225
|
} catch (error) {
|
|
230
|
-
|
|
226
|
+
throw new Error(`Navigation failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
231
227
|
}
|
|
232
228
|
const title = await result.page.title();
|
|
233
229
|
const snapshot = await snapshotOf(result.page);
|
|
@@ -243,21 +239,25 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
243
239
|
"Re-read the current page as an accessibility snapshot without navigating - use after the page " +
|
|
244
240
|
"changed on its own (SPA updates, timers) or to scope into part of a large page with a css selector.",
|
|
245
241
|
parameters: Type.Object({
|
|
246
|
-
css: Type.Optional(
|
|
242
|
+
css: Type.Optional(
|
|
243
|
+
Type.String({ description: "Scope the snapshot to this selector (e.g. 'main', '#results')" }),
|
|
244
|
+
),
|
|
247
245
|
}),
|
|
248
246
|
execute: async (_id, params) => {
|
|
249
|
-
if (!page)
|
|
247
|
+
if (!page) throw new Error("No page is open. Use browser_navigate first.");
|
|
250
248
|
try {
|
|
251
249
|
if (params.css) {
|
|
252
250
|
const scoped = await page.locator(params.css).first().ariaSnapshot();
|
|
253
251
|
const clipped =
|
|
254
|
-
scoped.length > SNAPSHOT_MAX_CHARS
|
|
252
|
+
scoped.length > SNAPSHOT_MAX_CHARS
|
|
253
|
+
? `${scoped.slice(0, SNAPSHOT_MAX_CHARS)}\n... (truncated)`
|
|
254
|
+
: scoped;
|
|
255
255
|
return ok(`${clipped || "(empty)"}\n\n${drainConsole()}`);
|
|
256
256
|
}
|
|
257
257
|
const snapshot = await snapshotOf(page);
|
|
258
258
|
return ok(`URL: ${page.url()}\n\n${snapshot}\n\n${drainConsole()}`);
|
|
259
259
|
} catch (error) {
|
|
260
|
-
|
|
260
|
+
throw new Error(`Snapshot failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
261
261
|
}
|
|
262
262
|
},
|
|
263
263
|
});
|
|
@@ -286,12 +286,22 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
286
286
|
label: Type.Optional(Type.String({ description: "Form field label" })),
|
|
287
287
|
text: Type.Optional(Type.String({ description: "Visible text (links, buttons)" })),
|
|
288
288
|
css: Type.Optional(Type.String({ description: "CSS selector (escape hatch)" })),
|
|
289
|
-
value: Type.Optional(
|
|
289
|
+
value: Type.Optional(
|
|
290
|
+
Type.String({ description: "For fill/select: the value. For press: the key (e.g. 'Enter')" }),
|
|
291
|
+
),
|
|
290
292
|
}),
|
|
291
293
|
execute: async (_id, params) => {
|
|
292
|
-
if (!page)
|
|
294
|
+
if (!page) throw new Error("No page is open. Use browser_navigate first.");
|
|
293
295
|
const locator = resolveTarget(page, params);
|
|
294
|
-
if (!locator)
|
|
296
|
+
if (!locator) throw new Error("No target given. Provide role(+name), label, text, or css.");
|
|
297
|
+
if ((params.action === "fill" || params.action === "select") && params.value == null) {
|
|
298
|
+
throw new Error(`'${params.action}' needs a value.`);
|
|
299
|
+
}
|
|
300
|
+
if (params.action === "press" && !params.value) {
|
|
301
|
+
throw new Error("'press' needs a key in value (e.g. 'Enter').");
|
|
302
|
+
}
|
|
303
|
+
// Validated above for the actions that use it.
|
|
304
|
+
const value = params.value ?? "";
|
|
295
305
|
const timeout = DEFAULT_ACTION_TIMEOUT;
|
|
296
306
|
try {
|
|
297
307
|
switch (params.action) {
|
|
@@ -299,16 +309,13 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
299
309
|
await locator.click({ timeout });
|
|
300
310
|
break;
|
|
301
311
|
case "fill":
|
|
302
|
-
|
|
303
|
-
await locator.fill(params.value, { timeout });
|
|
312
|
+
await locator.fill(value, { timeout });
|
|
304
313
|
break;
|
|
305
314
|
case "press":
|
|
306
|
-
|
|
307
|
-
await locator.press(params.value, { timeout });
|
|
315
|
+
await locator.press(value, { timeout });
|
|
308
316
|
break;
|
|
309
317
|
case "select":
|
|
310
|
-
|
|
311
|
-
await locator.selectOption(params.value, { timeout });
|
|
318
|
+
await locator.selectOption(value, { timeout });
|
|
312
319
|
break;
|
|
313
320
|
case "check":
|
|
314
321
|
await locator.check({ timeout });
|
|
@@ -322,7 +329,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
322
329
|
}
|
|
323
330
|
} catch (error) {
|
|
324
331
|
const message = error instanceof Error ? error.message.split("\n")[0] : String(error);
|
|
325
|
-
|
|
332
|
+
throw new Error(
|
|
326
333
|
`${params.action} on ${describeTarget(params)} failed: ${message} ` +
|
|
327
334
|
"(take a browser_snapshot to see what the page actually offers)",
|
|
328
335
|
);
|
|
@@ -354,7 +361,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
354
361
|
height: Type.Optional(Type.Number({ description: "Viewport height to set first" })),
|
|
355
362
|
}),
|
|
356
363
|
execute: async (_id, params) => {
|
|
357
|
-
if (!page)
|
|
364
|
+
if (!page) throw new Error("No page is open. Use browser_navigate first.");
|
|
358
365
|
try {
|
|
359
366
|
if (params.width && params.height) {
|
|
360
367
|
await page.setViewportSize({ width: params.width, height: params.height });
|
|
@@ -380,7 +387,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
380
387
|
details: {},
|
|
381
388
|
};
|
|
382
389
|
} catch (error) {
|
|
383
|
-
|
|
390
|
+
throw new Error(`Screenshot failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
384
391
|
}
|
|
385
392
|
},
|
|
386
393
|
});
|
|
@@ -408,7 +415,7 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
408
415
|
if (result.code === 0) {
|
|
409
416
|
return ok(`Playwright tests passed.\n\n${tail}`);
|
|
410
417
|
}
|
|
411
|
-
|
|
418
|
+
throw new Error(`Playwright tests failed (exit ${result.code}).\n\n${tail}`);
|
|
412
419
|
},
|
|
413
420
|
});
|
|
414
421
|
|
|
@@ -434,7 +441,9 @@ export default function (elyra: ExtensionAPI): void {
|
|
|
434
441
|
ctx.ui.notify("Usage: /browser <url> \u2014 e.g. /browser https://freddy.test", "error");
|
|
435
442
|
return;
|
|
436
443
|
}
|
|
437
|
-
elyra.sendUserMessage(
|
|
444
|
+
elyra.sendUserMessage(
|
|
445
|
+
`Open ${url} with browser_navigate and describe what the page shows and whether the console is clean.`,
|
|
446
|
+
);
|
|
438
447
|
},
|
|
439
448
|
});
|
|
440
449
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elyracode/browser-tools",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.58",
|
|
4
4
|
"description": "Browser automation for Elyra via Playwright - the agent navigates, clicks, fills, and verifies behavior, with token-cheap accessibility snapshots and screenshots",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|