@developerz.ai/ui-debugger-mcp 1.9.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 +63 -47
- 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/adb.d.ts +19 -7
- package/dist/adapters/android/adb.js +50 -13
- package/dist/adapters/android/adb.js.map +1 -1
- package/dist/adapters/android/android-adapter.d.ts +20 -12
- package/dist/adapters/android/android-adapter.js +113 -165
- 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/android/ports.js.map +1 -1
- package/dist/adapters/android/sdk.d.ts +65 -0
- package/dist/adapters/android/sdk.js +107 -0
- package/dist/adapters/android/sdk.js.map +1 -0
- package/dist/adapters/android/uiautomator.d.ts +23 -7
- package/dist/adapters/android/uiautomator.js +31 -7
- package/dist/adapters/android/uiautomator.js.map +1 -1
- package/dist/adapters/availability.d.ts +39 -0
- package/dist/adapters/availability.js +62 -0
- package/dist/adapters/availability.js.map +1 -0
- package/dist/adapters/browser/browser-adapter.d.ts +11 -22
- package/dist/adapters/browser/browser-adapter.js +90 -71
- package/dist/adapters/browser/browser-adapter.js.map +1 -1
- package/dist/adapters/browser/cdp.d.ts +22 -17
- package/dist/adapters/browser/cdp.js +118 -72
- 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/filters.d.ts +1 -1
- package/dist/adapters/browser/filters.js.map +1 -1
- package/dist/adapters/browser/geometry.js.map +1 -1
- package/dist/adapters/browser/launch.d.ts +14 -5
- package/dist/adapters/browser/launch.js +14 -5
- package/dist/adapters/browser/launch.js.map +1 -1
- package/dist/adapters/browser/lifecycle.d.ts +91 -0
- package/dist/adapters/browser/lifecycle.js +141 -0
- package/dist/adapters/browser/lifecycle.js.map +1 -0
- 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 +2 -2
- 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 +23 -20
- package/dist/adapters/browser/log-format.js +133 -56
- package/dist/adapters/browser/log-format.js.map +1 -1
- package/dist/adapters/browser/tab-context.d.ts +30 -0
- package/dist/adapters/browser/tab-context.js +41 -0
- package/dist/adapters/browser/tab-context.js.map +1 -0
- package/dist/adapters/contract.d.ts +113 -10
- package/dist/adapters/contract.js +7 -2
- package/dist/adapters/contract.js.map +1 -1
- package/dist/adapters/desktop/atspi-busctl.d.ts +26 -0
- package/dist/adapters/desktop/atspi-busctl.js +332 -0
- package/dist/adapters/desktop/atspi-busctl.js.map +1 -0
- package/dist/adapters/desktop/atspi-parse.d.ts +39 -0
- package/dist/adapters/desktop/atspi-parse.js +155 -0
- package/dist/adapters/desktop/atspi-parse.js.map +1 -0
- package/dist/adapters/desktop/atspi.d.ts +81 -50
- package/dist/adapters/desktop/atspi.js +64 -285
- package/dist/adapters/desktop/atspi.js.map +1 -1
- package/dist/adapters/desktop/capture.d.ts +11 -20
- package/dist/adapters/desktop/capture.js +68 -37
- package/dist/adapters/desktop/capture.js.map +1 -1
- package/dist/adapters/desktop/desktop-adapter.d.ts +22 -2
- package/dist/adapters/desktop/desktop-adapter.js +202 -86
- package/dist/adapters/desktop/desktop-adapter.js.map +1 -1
- package/dist/adapters/desktop/input.d.ts +19 -5
- package/dist/adapters/desktop/input.js +29 -13
- 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 +34 -4
- package/dist/adapters/desktop/proc.js +37 -6
- 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 +13 -6
- package/dist/adapters/factory.js +30 -4
- package/dist/adapters/factory.js.map +1 -1
- package/dist/adapters/log-format.d.ts +38 -0
- package/dist/adapters/log-format.js +47 -0
- package/dist/adapters/log-format.js.map +1 -0
- package/dist/agent/belt/act.d.ts +426 -23
- package/dist/agent/belt/act.js +44 -64
- package/dist/agent/belt/act.js.map +1 -1
- package/dist/agent/belt/look.d.ts +479 -16
- package/dist/agent/belt/look.js +94 -16
- package/dist/agent/belt/look.js.map +1 -1
- package/dist/agent/belt/observe.d.ts +652 -65
- package/dist/agent/belt/observe.js +119 -231
- 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/report.d.ts +754 -48
- package/dist/agent/belt/report.js +121 -38
- package/dist/agent/belt/report.js.map +1 -1
- 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/trail.d.ts +44 -16
- package/dist/agent/belt/trail.js +46 -11
- package/dist/agent/belt/trail.js.map +1 -1
- 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/capabilities.js.map +1 -1
- package/dist/agent/fallback.d.ts +33 -0
- package/dist/agent/fallback.js +84 -0
- package/dist/agent/fallback.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 +56 -65
- package/dist/agent/loop.js +122 -189
- package/dist/agent/loop.js.map +1 -1
- package/dist/agent/models.d.ts +10 -6
- package/dist/agent/models.js +15 -9
- package/dist/agent/models.js.map +1 -1
- package/dist/agent/prompts/compose.d.ts +1 -1
- package/dist/agent/prompts/debug-agent.js +48 -10
- 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 +26 -25
- package/dist/agent/prompts/web-addendum.js.map +1 -1
- package/dist/agent/provider.d.ts +41 -1
- package/dist/agent/provider.js +59 -5
- package/dist/agent/provider.js.map +1 -1
- package/dist/boot.d.ts +64 -0
- package/dist/boot.js +147 -0
- package/dist/boot.js.map +1 -0
- package/dist/cli/chromium-libs.d.ts +267 -0
- package/dist/cli/chromium-libs.js +546 -0
- package/dist/cli/chromium-libs.js.map +1 -0
- package/dist/cli/control.js +79 -12
- package/dist/cli/control.js.map +1 -1
- package/dist/cli/init.d.ts +52 -3
- package/dist/cli/init.js +62 -10
- package/dist/cli/init.js.map +1 -1
- package/dist/config/load.d.ts +25 -8
- package/dist/config/load.js +50 -13
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +18 -6
- package/dist/config/schema.js +34 -17
- package/dist/config/schema.js.map +1 -1
- package/dist/errors.d.ts +30 -15
- package/dist/errors.js +49 -30
- package/dist/errors.js.map +1 -1
- package/dist/findings/schema.d.ts +44 -6
- package/dist/findings/schema.js +39 -3
- package/dist/findings/schema.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/main.js +4 -82
- package/dist/main.js.map +1 -1
- package/dist/mcp/server.js +10 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/describe.d.ts +5 -4
- package/dist/mcp/tools/describe.js +14 -10
- package/dist/mcp/tools/describe.js.map +1 -1
- package/dist/mcp/tools/end-session.d.ts +3 -1
- package/dist/mcp/tools/end-session.js +8 -3
- package/dist/mcp/tools/end-session.js.map +1 -1
- package/dist/mcp/tools/output.d.ts +12 -4
- package/dist/mcp/tools/output.js +15 -2
- package/dist/mcp/tools/output.js.map +1 -1
- package/dist/mcp/tools/result.d.ts +10 -1
- package/dist/mcp/tools/result.js +12 -7
- package/dist/mcp/tools/result.js.map +1 -1
- package/dist/mcp/tools/start-debug.js +7 -5
- package/dist/mcp/tools/start-debug.js.map +1 -1
- package/dist/redact.d.ts +44 -0
- package/dist/redact.js +166 -0
- package/dist/redact.js.map +1 -0
- 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/catalog.d.ts +28 -0
- package/dist/services/catalog.js +65 -0
- package/dist/services/catalog.js.map +1 -0
- package/dist/services/debug-api.d.ts +179 -0
- package/dist/services/debug-api.js +9 -0
- package/dist/services/debug-api.js.map +1 -0
- package/dist/services/debug-service.d.ts +26 -174
- package/dist/services/debug-service.js +159 -227
- 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 +16 -29
- package/dist/services/login.js +269 -97
- 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/retained-snapshot.d.ts +36 -0
- package/dist/services/retained-snapshot.js +63 -0
- package/dist/services/retained-snapshot.js.map +1 -0
- package/dist/services/session-builder.d.ts +26 -0
- package/dist/services/session-builder.js +63 -21
- 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 +37 -0
- package/dist/services/start-guards.js +61 -0
- package/dist/services/start-guards.js.map +1 -0
- package/dist/services/summarize.d.ts +12 -3
- package/dist/services/summarize.js +13 -5
- package/dist/services/summarize.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/findings-store.d.ts +2 -1
- package/dist/session/findings-store.js +30 -2
- package/dist/session/findings-store.js.map +1 -1
- 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/live-pointer.d.ts +19 -0
- package/dist/session/live-pointer.js +41 -0
- package/dist/session/live-pointer.js.map +1 -0
- package/dist/session/manager.d.ts +11 -1
- package/dist/session/manager.js +46 -2
- package/dist/session/manager.js.map +1 -1
- package/dist/session/owner-lock.d.ts +117 -0
- package/dist/session/owner-lock.js +218 -0
- package/dist/session/owner-lock.js.map +1 -0
- package/dist/session/process-identity.js.map +1 -1
- package/dist/session/session.js +40 -109
- package/dist/session/session.js.map +1 -1
- package/dist/session/state-file.d.ts +74 -14
- package/dist/session/state-file.js +211 -21
- 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 +11 -11
- package/dist/adapters/android/android-adapter.test-helpers.d.ts +0 -52
- package/dist/adapters/android/android-adapter.test-helpers.js +0 -115
- package/dist/adapters/android/android-adapter.test-helpers.js.map +0 -1
- package/dist/mcp/server.test-helpers.d.ts +0 -23
- package/dist/mcp/server.test-helpers.js +0 -49
- package/dist/mcp/server.test-helpers.js.map +0 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-node selectors for the belt — the `target` string `observe` attaches to
|
|
3
|
+
* every node it returns, and the `within` scope it accepts back.
|
|
4
|
+
*
|
|
5
|
+
* Split from `observe.ts` (one responsibility per file): `observe` routes reads,
|
|
6
|
+
* this module knows the two selector dialects ({@link SelectorDialect}) and how a
|
|
7
|
+
* node round-trips between a read and the next `act`/`observe`.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import type { Adapter, Node, NodeField, NodeRef, SelectorDialect } from '../../adapters/contract.js';
|
|
11
|
+
/**
|
|
12
|
+
* A {@link Node} echoed back as a `within` scope (the alternative to a selector string).
|
|
13
|
+
*
|
|
14
|
+
* `bounds`/`enabled` are OPTIONAL: a `fields:["role","name"]` read — what the web
|
|
15
|
+
* addendum recommends for slim reads — returns neither, and rejecting the very node
|
|
16
|
+
* observe just handed back is the kind of contradiction that burns steps. Role + name
|
|
17
|
+
* are enough; {@link coerceWithin} turns a region-less node into a selector.
|
|
18
|
+
*/
|
|
19
|
+
export declare const NodeSchema: z.ZodObject<{
|
|
20
|
+
role: z.ZodString;
|
|
21
|
+
name: z.ZodString;
|
|
22
|
+
bounds: z.ZodOptional<z.ZodObject<{
|
|
23
|
+
x: z.ZodNumber;
|
|
24
|
+
y: z.ZodNumber;
|
|
25
|
+
width: z.ZodNumber;
|
|
26
|
+
height: z.ZodNumber;
|
|
27
|
+
}, z.core.$strip>>;
|
|
28
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
testid: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
/** A `within` node as the driver may pass it — possibly projected down to role + name. */
|
|
32
|
+
type WithinNode = z.infer<typeof NodeSchema>;
|
|
33
|
+
/** A tree node projected for the agent, plus a ready-to-use `target` selector for `act`. */
|
|
34
|
+
export type TreeNode = Partial<Node> & {
|
|
35
|
+
target?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* The dialect an adapter speaks — READ from the adapter's own declaration
|
|
39
|
+
* ({@link Adapter.selectorDialect}).
|
|
40
|
+
*
|
|
41
|
+
* It used to be inferred from `tabs`, which the contract marks optional and
|
|
42
|
+
* web-only: a native target that grew a tab listing would silently flip to the
|
|
43
|
+
* web dialect and hand the driver selectors its own parser cannot resolve. The
|
|
44
|
+
* dialect is explicit now, and a missing or unknown declaration fails loud
|
|
45
|
+
* instead of falling back to `web`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function dialectOf(adapter: Adapter): SelectorDialect;
|
|
48
|
+
/**
|
|
49
|
+
* Attach a copy-paste `target` to each tree node, disambiguating duplicates with
|
|
50
|
+
* `>> nth=` in document order — so the agent never has to invent a selector (the
|
|
51
|
+
* #1 cause of wasted steps: a blind model guessing CSS that does not resolve).
|
|
52
|
+
*
|
|
53
|
+
* A `scoped` read (`query`/`within`/`filters`) returns a *subset*, so the `nth=`
|
|
54
|
+
* index — and even a bare role/text selector — can resolve a different element when
|
|
55
|
+
* `act` replays it with an unscoped, document-wide `find` (e.g. header "Settings"
|
|
56
|
+
* instead of the sidebar "Settings" the narrowed read returned). In that case we
|
|
57
|
+
* emit no `target` — EXCEPT a testid one, which is document-unique and survives
|
|
58
|
+
* any scoping. Otherwise, better the agent falls back (visible text /
|
|
59
|
+
* `role "name"`) than act on the wrong node.
|
|
60
|
+
*
|
|
61
|
+
* `>> nth=` is Playwright chaining and exists on WEB only; the native parsers read
|
|
62
|
+
* it as part of a name substring and match nothing. So on a native target a
|
|
63
|
+
* repeated selector yields a `target` for the FIRST node only — the others are
|
|
64
|
+
* genuinely unaddressable there, and saying so beats handing out a string that
|
|
65
|
+
* silently acts on the first one.
|
|
66
|
+
*/
|
|
67
|
+
export declare function withTargets(nodes: Node[], dialect: SelectorDialect, fields?: readonly NodeField[], scoped?: boolean): TreeNode[];
|
|
68
|
+
/**
|
|
69
|
+
* Resolve `within` to something the {@link Adapter} contract takes — a selector string
|
|
70
|
+
* or a {@link Node}. Two coercions, each fixing a shape drivers actually produce:
|
|
71
|
+
*
|
|
72
|
+
* - a JSON-*stringified* node (`within: "{\"role\": …}"`). Before this it fell through
|
|
73
|
+
* as a selector, normalized to `text={"role"…}`, matched nothing, and returned an
|
|
74
|
+
* empty tree with no clue why — the single biggest step-waster observed.
|
|
75
|
+
* Garbage-that-looks-like-JSON fails loud instead of reading the whole page.
|
|
76
|
+
* - a node projected without `bounds` (`fields:["role","name"]`) → {@link scopeOf}.
|
|
77
|
+
*/
|
|
78
|
+
export declare function coerceWithin(within: string | WithinNode | undefined, dialect: SelectorDialect): NodeRef | undefined;
|
|
79
|
+
export {};
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tree-node selectors for the belt — the `target` string `observe` attaches to
|
|
3
|
+
* every node it returns, and the `within` scope it accepts back.
|
|
4
|
+
*
|
|
5
|
+
* Split from `observe.ts` (one responsibility per file): `observe` routes reads,
|
|
6
|
+
* this module knows the two selector dialects ({@link SelectorDialect}) and how a
|
|
7
|
+
* node round-trips between a read and the next `act`/`observe`.
|
|
8
|
+
*/
|
|
9
|
+
import { z } from 'zod';
|
|
10
|
+
import { AgentError } from '../../errors.js';
|
|
11
|
+
/**
|
|
12
|
+
* Columns a no-`fields` read returns. `style` (colour + contrast per text node)
|
|
13
|
+
* is opt-in only — on a 200-node default read it would triple the payload the
|
|
14
|
+
* text driver re-reads every step for data it rarely needs.
|
|
15
|
+
*/
|
|
16
|
+
const DEFAULT_PROJECTION = [
|
|
17
|
+
'role',
|
|
18
|
+
'name',
|
|
19
|
+
'bounds',
|
|
20
|
+
'enabled',
|
|
21
|
+
'testid',
|
|
22
|
+
'frame',
|
|
23
|
+
'value',
|
|
24
|
+
'checked',
|
|
25
|
+
];
|
|
26
|
+
/** On-screen rectangle backing a {@link Node} `within` reference. */
|
|
27
|
+
const BoundsSchema = z.object({
|
|
28
|
+
x: z.number(),
|
|
29
|
+
y: z.number(),
|
|
30
|
+
width: z.number(),
|
|
31
|
+
height: z.number(),
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* A {@link Node} echoed back as a `within` scope (the alternative to a selector string).
|
|
35
|
+
*
|
|
36
|
+
* `bounds`/`enabled` are OPTIONAL: a `fields:["role","name"]` read — what the web
|
|
37
|
+
* addendum recommends for slim reads — returns neither, and rejecting the very node
|
|
38
|
+
* observe just handed back is the kind of contradiction that burns steps. Role + name
|
|
39
|
+
* are enough; {@link coerceWithin} turns a region-less node into a selector.
|
|
40
|
+
*/
|
|
41
|
+
export const NodeSchema = z.object({
|
|
42
|
+
role: z.string(),
|
|
43
|
+
name: z.string(),
|
|
44
|
+
bounds: BoundsSchema.optional(),
|
|
45
|
+
enabled: z.boolean().optional(),
|
|
46
|
+
testid: z.string().optional(),
|
|
47
|
+
});
|
|
48
|
+
/**
|
|
49
|
+
* The dialect an adapter speaks — READ from the adapter's own declaration
|
|
50
|
+
* ({@link Adapter.selectorDialect}).
|
|
51
|
+
*
|
|
52
|
+
* It used to be inferred from `tabs`, which the contract marks optional and
|
|
53
|
+
* web-only: a native target that grew a tab listing would silently flip to the
|
|
54
|
+
* web dialect and hand the driver selectors its own parser cannot resolve. The
|
|
55
|
+
* dialect is explicit now, and a missing or unknown declaration fails loud
|
|
56
|
+
* instead of falling back to `web`.
|
|
57
|
+
*/
|
|
58
|
+
export function dialectOf(adapter) {
|
|
59
|
+
// Read as `unknown`: the declaration is data, and a missing or misspelled one
|
|
60
|
+
// must fail loud rather than slip through as the web default.
|
|
61
|
+
const declared = adapter.selectorDialect;
|
|
62
|
+
if (declared === 'web')
|
|
63
|
+
return 'web';
|
|
64
|
+
if (declared === 'native')
|
|
65
|
+
return 'native';
|
|
66
|
+
throw new AgentError(`adapter declares no usable selector dialect (got ${String(declared)}) — ` +
|
|
67
|
+
'every adapter must declare `selectorDialect: "web" | "native"`');
|
|
68
|
+
}
|
|
69
|
+
/** A role token both native parsers accept as the leading word of `role "name"`. */
|
|
70
|
+
const NATIVE_ROLE_TOKEN = /^[a-zA-Z][\w-]*$/;
|
|
71
|
+
/**
|
|
72
|
+
* The base selector for a node on a NATIVE target (desktop AT-SPI · android
|
|
73
|
+
* uiautomator). Their query parsers accept exactly two shapes — `role "name"`
|
|
74
|
+
* (`/^([a-zA-Z][\w-]*)\s+["'](.+)["']$/`, role matched exactly, name as a
|
|
75
|
+
* case-insensitive substring) and a bare name substring — so that is all we emit.
|
|
76
|
+
*
|
|
77
|
+
* A `testid` here is android's `resource-id` (`com.app:id/submit`), which its
|
|
78
|
+
* matcher tests against `name + resourceId`: the bare id is both accepted and
|
|
79
|
+
* near-unique, so it wins, exactly like `data-testid` does on web.
|
|
80
|
+
*/
|
|
81
|
+
function nativeSelector(node) {
|
|
82
|
+
if (node.testid)
|
|
83
|
+
return node.testid;
|
|
84
|
+
const name = node.name.trim();
|
|
85
|
+
if (!name)
|
|
86
|
+
return null;
|
|
87
|
+
// A quote inside the name would close the parser's quoted group early; fall back
|
|
88
|
+
// to the bare-name form rather than emit a selector that resolves the wrong node.
|
|
89
|
+
if (NATIVE_ROLE_TOKEN.test(node.role) && !name.includes('"'))
|
|
90
|
+
return `${node.role} "${name}"`;
|
|
91
|
+
return name;
|
|
92
|
+
}
|
|
93
|
+
/** ARIA roles Playwright's `role=` engine accepts (others fall back to a text selector). */
|
|
94
|
+
const ARIA_ROLES = new Set([
|
|
95
|
+
'button',
|
|
96
|
+
'link',
|
|
97
|
+
'checkbox',
|
|
98
|
+
'radio',
|
|
99
|
+
'textbox',
|
|
100
|
+
'combobox',
|
|
101
|
+
'slider',
|
|
102
|
+
'heading',
|
|
103
|
+
'img',
|
|
104
|
+
'navigation',
|
|
105
|
+
'main',
|
|
106
|
+
'form',
|
|
107
|
+
'list',
|
|
108
|
+
'listitem',
|
|
109
|
+
'tab',
|
|
110
|
+
'menuitem',
|
|
111
|
+
'switch',
|
|
112
|
+
'dialog',
|
|
113
|
+
'banner',
|
|
114
|
+
'contentinfo',
|
|
115
|
+
'region',
|
|
116
|
+
'article',
|
|
117
|
+
'search',
|
|
118
|
+
'table',
|
|
119
|
+
]);
|
|
120
|
+
/**
|
|
121
|
+
* The base selector for a node the agent can paste straight into `act`'s `target`,
|
|
122
|
+
* in the target's own {@link SelectorDialect} (a `native` node goes to
|
|
123
|
+
* {@link nativeSelector}). Web: role + accessible name when the role is
|
|
124
|
+
* ARIA-addressable, else the visible text. `null` for an unnamed, non-semantic
|
|
125
|
+
* node (the agent targets those by other means).
|
|
126
|
+
*/
|
|
127
|
+
function baseSelector(node, dialect) {
|
|
128
|
+
if (dialect === 'native')
|
|
129
|
+
return nativeSelector(node);
|
|
130
|
+
// A test hook beats everything: document-unique, stable across renames/moves.
|
|
131
|
+
if (node.testid)
|
|
132
|
+
return `data-testid=${JSON.stringify(node.testid)}`;
|
|
133
|
+
const name = node.name.trim();
|
|
134
|
+
if (node.role && ARIA_ROLES.has(node.role) && name) {
|
|
135
|
+
return `role=${node.role}[name=${JSON.stringify(name)} i]`;
|
|
136
|
+
}
|
|
137
|
+
if (name)
|
|
138
|
+
return `text=${name}`;
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Attach a copy-paste `target` to each tree node, disambiguating duplicates with
|
|
143
|
+
* `>> nth=` in document order — so the agent never has to invent a selector (the
|
|
144
|
+
* #1 cause of wasted steps: a blind model guessing CSS that does not resolve).
|
|
145
|
+
*
|
|
146
|
+
* A `scoped` read (`query`/`within`/`filters`) returns a *subset*, so the `nth=`
|
|
147
|
+
* index — and even a bare role/text selector — can resolve a different element when
|
|
148
|
+
* `act` replays it with an unscoped, document-wide `find` (e.g. header "Settings"
|
|
149
|
+
* instead of the sidebar "Settings" the narrowed read returned). In that case we
|
|
150
|
+
* emit no `target` — EXCEPT a testid one, which is document-unique and survives
|
|
151
|
+
* any scoping. Otherwise, better the agent falls back (visible text /
|
|
152
|
+
* `role "name"`) than act on the wrong node.
|
|
153
|
+
*
|
|
154
|
+
* `>> nth=` is Playwright chaining and exists on WEB only; the native parsers read
|
|
155
|
+
* it as part of a name substring and match nothing. So on a native target a
|
|
156
|
+
* repeated selector yields a `target` for the FIRST node only — the others are
|
|
157
|
+
* genuinely unaddressable there, and saying so beats handing out a string that
|
|
158
|
+
* silently acts on the first one.
|
|
159
|
+
*/
|
|
160
|
+
export function withTargets(nodes, dialect, fields, scoped = false) {
|
|
161
|
+
const seen = new Map();
|
|
162
|
+
const projection = fields && fields.length > 0 ? fields : DEFAULT_PROJECTION;
|
|
163
|
+
return nodes.map((node) => {
|
|
164
|
+
const projected = pick(node, projection);
|
|
165
|
+
if (scoped) {
|
|
166
|
+
if (node.testid) {
|
|
167
|
+
projected.target =
|
|
168
|
+
dialect === 'native' ? node.testid : `data-testid=${JSON.stringify(node.testid)}`;
|
|
169
|
+
}
|
|
170
|
+
return projected;
|
|
171
|
+
}
|
|
172
|
+
const base = baseSelector(node, dialect);
|
|
173
|
+
if (!base)
|
|
174
|
+
return projected;
|
|
175
|
+
const k = seen.get(base) ?? 0;
|
|
176
|
+
seen.set(base, k + 1);
|
|
177
|
+
if (k === 0)
|
|
178
|
+
projected.target = base;
|
|
179
|
+
else if (dialect === 'web')
|
|
180
|
+
projected.target = `${base} >> nth=${k}`;
|
|
181
|
+
return projected;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/** Pick a subset of keys off an object (a typed `SELECT cols`) for the `fields` projection. */
|
|
185
|
+
function pick(obj, keys) {
|
|
186
|
+
const out = {};
|
|
187
|
+
// Skip absent optionals (testid/style) so they never serialize as explicit nulls.
|
|
188
|
+
for (const key of keys)
|
|
189
|
+
if (obj[key] !== undefined)
|
|
190
|
+
out[key] = obj[key];
|
|
191
|
+
return out;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* A `within` node as a contract {@link NodeRef}: its on-screen region when it has one,
|
|
195
|
+
* else the selector its testid/role/name resolve to — the same string `observe` would
|
|
196
|
+
* have attached to that node as `target`.
|
|
197
|
+
*
|
|
198
|
+
* Adapters scope a {@link Node} `within` by `bounds` ALONE, so a region-less node has
|
|
199
|
+
* to become a selector or it would silently read nothing. `enabled` is never read when
|
|
200
|
+
* scoping; the contract just requires the field, so a projection that dropped it
|
|
201
|
+
* defaults to `true` rather than throwing away an exact region.
|
|
202
|
+
*/
|
|
203
|
+
function scopeOf(node, dialect) {
|
|
204
|
+
const { bounds } = node;
|
|
205
|
+
if (bounds !== undefined)
|
|
206
|
+
return { ...node, bounds, enabled: node.enabled ?? true };
|
|
207
|
+
const selector = baseSelector(node, dialect);
|
|
208
|
+
if (selector)
|
|
209
|
+
return selector;
|
|
210
|
+
throw new AgentError('observe `within` node has no `bounds` and no name/testid to resolve it — re-read with `fields` including "bounds", or pass a selector string');
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Resolve `within` to something the {@link Adapter} contract takes — a selector string
|
|
214
|
+
* or a {@link Node}. Two coercions, each fixing a shape drivers actually produce:
|
|
215
|
+
*
|
|
216
|
+
* - a JSON-*stringified* node (`within: "{\"role\": …}"`). Before this it fell through
|
|
217
|
+
* as a selector, normalized to `text={"role"…}`, matched nothing, and returned an
|
|
218
|
+
* empty tree with no clue why — the single biggest step-waster observed.
|
|
219
|
+
* Garbage-that-looks-like-JSON fails loud instead of reading the whole page.
|
|
220
|
+
* - a node projected without `bounds` (`fields:["role","name"]`) → {@link scopeOf}.
|
|
221
|
+
*/
|
|
222
|
+
export function coerceWithin(within, dialect) {
|
|
223
|
+
if (within === undefined)
|
|
224
|
+
return undefined;
|
|
225
|
+
if (typeof within !== 'string')
|
|
226
|
+
return scopeOf(within, dialect);
|
|
227
|
+
if (!within.trimStart().startsWith('{'))
|
|
228
|
+
return within;
|
|
229
|
+
let data;
|
|
230
|
+
try {
|
|
231
|
+
data = JSON.parse(within);
|
|
232
|
+
}
|
|
233
|
+
catch {
|
|
234
|
+
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');
|
|
235
|
+
}
|
|
236
|
+
const parsed = NodeSchema.safeParse(data);
|
|
237
|
+
if (!parsed.success) {
|
|
238
|
+
throw new AgentError('observe `within` was a JSON string but not a valid node (needs role + name) — pass a node from a previous observe, or a selector string');
|
|
239
|
+
}
|
|
240
|
+
return scopeOf(parsed.data, dialect);
|
|
241
|
+
}
|
|
242
|
+
//# sourceMappingURL=tree-targets.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-targets.js","sourceRoot":"","sources":["../../../src/agent/belt/tree-targets.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAQxB,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C;;;;GAIG;AACH,MAAM,kBAAkB,GAAG;IACzB,MAAM;IACN,MAAM;IACN,QAAQ;IACR,SAAS;IACT,QAAQ;IACR,OAAO;IACP,OAAO;IACP,SAAS;CAC8B,CAAC;AAE1C,qEAAqE;AACrE,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;IACb,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;IACb,KAAK,EAAE,CAA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AAI,EAAE,OAAO,CAAC,CAAC;AACvC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
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,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IAC5C,OAAO,IAAI,IAAI,OAAO,CAAC,CAAC,+CAA+C;AACzE,CAAC;AAWD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAErC;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,OAAe,EACf,MAAc,EACd,OAAe,EACf,
|
|
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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,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,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,IAAI,CAAC,CAAC,8BAA8B;IAEjE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;IAC/B,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,KAAK,GACT,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,KAAK,OAAO,CAAC;QACvC,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,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"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paid fallback behind a (free) primary model.
|
|
3
|
+
*
|
|
4
|
+
* The default roles run on OpenRouter `:free` models. Those are rate-limited
|
|
5
|
+
* per model (~20 req/min), capped per day, and upstream-throttled at random —
|
|
6
|
+
* measured 2026-11-14: `google/gemma-4-31b-it:free` answered a run's very first
|
|
7
|
+
* step with `429 … temporarily rate-limited upstream`, and the run failed after
|
|
8
|
+
* the SDK's three retries. So every role carries ONE paid fallback: when the
|
|
9
|
+
* primary fails with a transient/availability status, or answers with nothing
|
|
10
|
+
* at all, the SAME call is re-issued on the fallback model.
|
|
11
|
+
*
|
|
12
|
+
* Gateway-agnostic on purpose (no OpenRouter `models: []` body field): it works
|
|
13
|
+
* on any OpenAI-compatible router, and the fallback is observable — every
|
|
14
|
+
* switch is reported through `onFallback` (boot wires it to stderr).
|
|
15
|
+
*/
|
|
16
|
+
import { type LanguageModel, wrapLanguageModel } from 'ai';
|
|
17
|
+
/** The wrapped model type `wrapLanguageModel` takes and returns. */
|
|
18
|
+
type WrappableModel = Parameters<typeof wrapLanguageModel>[0]['model'];
|
|
19
|
+
/** Why a call left the primary: an HTTP status, a transport error, or an empty answer. */
|
|
20
|
+
export interface FallbackEvent {
|
|
21
|
+
primary: string;
|
|
22
|
+
fallback: string;
|
|
23
|
+
reason: string;
|
|
24
|
+
}
|
|
25
|
+
export type OnFallback = (event: FallbackEvent) => void;
|
|
26
|
+
/** The fallback-worthy reason for an error, or `null` when it must propagate. */
|
|
27
|
+
export declare function fallbackReason(error: unknown): string | null;
|
|
28
|
+
/**
|
|
29
|
+
* `primary` with `fallback` behind it. Same `modelId` as the primary, so
|
|
30
|
+
* capability messages and logs keep naming the configured model.
|
|
31
|
+
*/
|
|
32
|
+
export declare function withFallback(primary: WrappableModel, fallback: WrappableModel, onFallback: OnFallback): LanguageModel;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paid fallback behind a (free) primary model.
|
|
3
|
+
*
|
|
4
|
+
* The default roles run on OpenRouter `:free` models. Those are rate-limited
|
|
5
|
+
* per model (~20 req/min), capped per day, and upstream-throttled at random —
|
|
6
|
+
* measured 2026-11-14: `google/gemma-4-31b-it:free` answered a run's very first
|
|
7
|
+
* step with `429 … temporarily rate-limited upstream`, and the run failed after
|
|
8
|
+
* the SDK's three retries. So every role carries ONE paid fallback: when the
|
|
9
|
+
* primary fails with a transient/availability status, or answers with nothing
|
|
10
|
+
* at all, the SAME call is re-issued on the fallback model.
|
|
11
|
+
*
|
|
12
|
+
* Gateway-agnostic on purpose (no OpenRouter `models: []` body field): it works
|
|
13
|
+
* on any OpenAI-compatible router, and the fallback is observable — every
|
|
14
|
+
* switch is reported through `onFallback` (boot wires it to stderr).
|
|
15
|
+
*/
|
|
16
|
+
import { APICallError, wrapLanguageModel } from 'ai';
|
|
17
|
+
/**
|
|
18
|
+
* Statuses that say "this model, right now, cannot serve you" — not "your
|
|
19
|
+
* request is wrong": 404 (a `:free` variant retired / no endpoints), 408, 429
|
|
20
|
+
* (per-model or daily free cap), every 5xx. A 400 is deliberately NOT here: it
|
|
21
|
+
* is a bad request (e.g. an image at a text-only model, which `look` turns
|
|
22
|
+
* into its vision latch), and re-sending it elsewhere would hide the defect.
|
|
23
|
+
*/
|
|
24
|
+
function isUnavailable(status) {
|
|
25
|
+
return (status === undefined || status === 404 || status === 408 || status === 429 || status >= 500);
|
|
26
|
+
}
|
|
27
|
+
/** The fallback-worthy reason for an error, or `null` when it must propagate. */
|
|
28
|
+
export function fallbackReason(error) {
|
|
29
|
+
if (!APICallError.isInstance(error))
|
|
30
|
+
return null; // abort, validation, our own bugs
|
|
31
|
+
if (!isUnavailable(error.statusCode))
|
|
32
|
+
return null;
|
|
33
|
+
return error.statusCode === undefined
|
|
34
|
+
? `transport error: ${error.message}`
|
|
35
|
+
: `HTTP ${error.statusCode}`;
|
|
36
|
+
}
|
|
37
|
+
/** A generate result with no text and no tool call — the model said nothing usable. */
|
|
38
|
+
function isEmpty(content) {
|
|
39
|
+
return !content.some((part) => part.type === 'tool-call' || (part.type === 'text' && (part.text ?? '').trim() !== ''));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* `primary` with `fallback` behind it. Same `modelId` as the primary, so
|
|
43
|
+
* capability messages and logs keep naming the configured model.
|
|
44
|
+
*/
|
|
45
|
+
export function withFallback(primary, fallback, onFallback) {
|
|
46
|
+
const ids = { primary: primary.modelId, fallback: fallback.modelId };
|
|
47
|
+
const fellBack = (reason) => onFallback({ ...ids, reason });
|
|
48
|
+
// `wrapLanguageModel` normalises both to the same spec version; call the
|
|
49
|
+
// fallback through a passthrough wrap so its `doGenerate` matches the primary's.
|
|
50
|
+
const backup = wrapLanguageModel({ model: fallback, middleware: {} });
|
|
51
|
+
return wrapLanguageModel({
|
|
52
|
+
model: primary,
|
|
53
|
+
middleware: {
|
|
54
|
+
wrapGenerate: async ({ doGenerate, params }) => {
|
|
55
|
+
try {
|
|
56
|
+
const result = await doGenerate();
|
|
57
|
+
if (!isEmpty(result.content))
|
|
58
|
+
return result;
|
|
59
|
+
fellBack('empty response');
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
const reason = fallbackReason(error);
|
|
63
|
+
if (reason === null)
|
|
64
|
+
throw error;
|
|
65
|
+
fellBack(reason);
|
|
66
|
+
}
|
|
67
|
+
return backup.doGenerate(params);
|
|
68
|
+
},
|
|
69
|
+
wrapStream: async ({ doStream, params }) => {
|
|
70
|
+
try {
|
|
71
|
+
return await doStream();
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
const reason = fallbackReason(error);
|
|
75
|
+
if (reason === null)
|
|
76
|
+
throw error;
|
|
77
|
+
fellBack(reason);
|
|
78
|
+
return backup.doStream(params);
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.js","sourceRoot":"","sources":["../../src/agent/fallback.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,YAAY,EAAsB,iBAAiB,EAAE,MAAM,IAAI,CAAC;AAczE;;;;;;GAMG;AACH,SAAS,aAAa,CAAC,MAA0B;IAC/C,OAAO,CACL,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,GAAG,IAAI,MA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C;QACvB,KAAK,EAAE,OAAO;QACd,UAAU,EAAE;YACV,YAAY,EAAE,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,EAAE;gBAC7C,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,MAAM,UAAU,EAAE,CAAC;oBAClC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;wBAAE,OAAO,MAAM,CAAC;oBAC5C,QAAQ,CAAC,gBAAgB,CAAC,CAAC;gBAC7B,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;oBACrC,IAAI,MAAM,KAAK,IAAI;wBAAE,MAAM,KAAK,CAAC;oBACjC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACnB,CAAC;gBACD,OAAO,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACnC,CAAC;YACD,UAAU,EAAE,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE;gBACzC,IAAI,CAAC;oBACH,OAAO,MAAM,QAAQ,EAAE,CAAC;gBAC1B,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACf,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;oBACrC,IAAI,MAAM,KAAK,IAAI;wBAAE,MAAM,KAAK,CAAC;oBACjC,QAAQ,CAAC,MAAM,CAAC,CAAC;oBACjB,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBACjC,CAAC;YACH,CAAC;SACF;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
import type { ModelMessage } from 'ai';
|
|
10
|
+
/** What a pruned frame collapses to — tells the driver how to get a fresh one. */
|
|
11
|
+
export declare const STALE_FRAME_NOTE = "[stale frame removed \u2014 call look again for a fresh screenshot]";
|
|
12
|
+
/**
|
|
13
|
+
* Keep only the NEWEST self-look frame in the transcript. The SDK re-sends every
|
|
14
|
+
* tool result on every step, so each `look` image would otherwise ride along for
|
|
15
|
+
* the rest of the run — N looks × M steps of image tokens. Rebuilt per step in
|
|
16
|
+
* `prepareStep`, over the stripped chain (`stripInjectedStepMessages`, `loop.ts`).
|
|
17
|
+
*
|
|
18
|
+
* Counts FRAMES, not messages: AI SDK 6 collects ALL of a step's tool results
|
|
19
|
+
* into ONE `tool`-role message, so a step that looked twice holds two frames in
|
|
20
|
+
* a single message. The newest frame (last in transcript order) stays live and
|
|
21
|
+
* every older one collapses to {@link STALE_FRAME_NOTE}; the rest of each
|
|
22
|
+
* tool-result (its own text, a sibling `act` result) is left exactly as it was.
|
|
23
|
+
* Returns the SAME array when the transcript holds at most ONE frame, keeping
|
|
24
|
+
* the no-change fast path.
|
|
25
|
+
*/
|
|
26
|
+
export declare function pruneStaleFrames(messages: ModelMessage[]): ModelMessage[];
|
|
@@ -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,CAAC,CAAC,EAAE,CAAC;AAC9E,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,UAAU,CAAC,QAAwB;IAC1C,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE;QACzC,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE;YAC3C,sEAAsE;YACtE,mEAAmE;YACnE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI;gBAAE,OAAO;YACtD,MAAM,CAAC,GAAG,IAAiB,CAAC;YAC5B,IAAI,CAAC,CAAC,IAAI,KAAK,aAAa,IAAI,CAAC,CAAC,QAAQ,KAAK,MAAM;gBAAE,OAAO;YAC9D,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;YACxB,IAAI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