@namzu/sdk 65.1.0 → 65.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/dist/public-tools.d.ts +1 -1
- package/dist/public-tools.d.ts.map +1 -1
- package/dist/public-tools.js +1 -1
- package/dist/public-tools.js.map +1 -1
- package/dist/tools/builtins/browser-stall.d.ts +59 -0
- package/dist/tools/builtins/browser-stall.d.ts.map +1 -0
- package/dist/tools/builtins/browser-stall.js +141 -0
- package/dist/tools/builtins/browser-stall.js.map +1 -0
- package/dist/tools/builtins/browser.d.ts +33 -4
- package/dist/tools/builtins/browser.d.ts.map +1 -1
- package/dist/tools/builtins/browser.js +304 -24
- package/dist/tools/builtins/browser.js.map +1 -1
- package/dist/types/browser/index.d.ts +142 -8
- package/dist/types/browser/index.d.ts.map +1 -1
- package/dist/types/browser/index.js +2 -0
- package/dist/types/browser/index.js.map +1 -1
- package/package.json +1 -1
- package/src/public-tools.ts +1 -0
- package/src/tools/builtins/browser-stall.ts +172 -0
- package/src/tools/builtins/browser.ts +382 -33
- package/src/types/browser/index.ts +145 -3
|
@@ -15,6 +15,7 @@ export type BrowserObserveActionName =
|
|
|
15
15
|
| 'scroll'
|
|
16
16
|
| 'wait_for'
|
|
17
17
|
| 'tabs'
|
|
18
|
+
| 'value'
|
|
18
19
|
|
|
19
20
|
/** Every action the `browser_act` tool (change the page) can ask for. */
|
|
20
21
|
export type BrowserActActionName =
|
|
@@ -33,6 +34,9 @@ export type BrowserScrollDirection = 'up' | 'down' | 'left' | 'right'
|
|
|
33
34
|
|
|
34
35
|
export type BrowserTabsOp = 'list' | 'select' | 'close' | 'new'
|
|
35
36
|
|
|
37
|
+
/** The shapes a `snapshot` can take; see {@link BrowserObserveAction}. */
|
|
38
|
+
export type BrowserSnapshotView = 'full' | 'interactive' | 'reading' | 'delta'
|
|
39
|
+
|
|
36
40
|
// ---------------------------------------------------------------------------
|
|
37
41
|
// Capabilities — frozen at host construction; the model reads them through
|
|
38
42
|
// the tools' descriptions and schemas.
|
|
@@ -73,6 +77,9 @@ export const BROWSER_SNAPSHOT_MAX_CHARS = 20_000
|
|
|
73
77
|
/** Longest `wait_for` the tool accepts, in milliseconds. */
|
|
74
78
|
export const BROWSER_WAIT_MAX_MS = 30_000
|
|
75
79
|
|
|
80
|
+
/** Most elements one find (`snapshot` with `query` or `role`) returns. */
|
|
81
|
+
export const BROWSER_FIND_MAX_MATCHES = 20
|
|
82
|
+
|
|
76
83
|
/** Most fields one `fill_form` call may set. */
|
|
77
84
|
export const BROWSER_FILL_FORM_MAX_FIELDS = 20
|
|
78
85
|
|
|
@@ -90,7 +97,22 @@ export type BrowserObserveAction =
|
|
|
90
97
|
| { readonly action: 'back' }
|
|
91
98
|
| { readonly action: 'forward' }
|
|
92
99
|
| { readonly action: 'reload' }
|
|
93
|
-
| {
|
|
100
|
+
| {
|
|
101
|
+
readonly action: 'snapshot'
|
|
102
|
+
readonly ref?: string
|
|
103
|
+
readonly cursor?: string
|
|
104
|
+
/**
|
|
105
|
+
* What to return. `full` (default): the page as a tree. `interactive`: only
|
|
106
|
+
* the elements a call can act on, one per line. `reading`: the page's text
|
|
107
|
+
* without markup. `delta`: only the lines added and removed since the last
|
|
108
|
+
* snapshot this tab returned.
|
|
109
|
+
*/
|
|
110
|
+
readonly view?: BrowserSnapshotView
|
|
111
|
+
/** Find: elements whose name or text contains this (case-insensitive). Up to {@link BROWSER_FIND_MAX_MATCHES}. */
|
|
112
|
+
readonly query?: string
|
|
113
|
+
/** Find: only elements of this ARIA role; with `query`, the role and the name both must match. */
|
|
114
|
+
readonly role?: string
|
|
115
|
+
}
|
|
94
116
|
| { readonly action: 'screenshot'; readonly ref?: string; readonly fullPage?: boolean }
|
|
95
117
|
| {
|
|
96
118
|
readonly action: 'scroll'
|
|
@@ -104,6 +126,13 @@ export type BrowserObserveAction =
|
|
|
104
126
|
readonly text?: string
|
|
105
127
|
readonly textGone?: string
|
|
106
128
|
readonly timeMs?: number
|
|
129
|
+
/** Wait until the page is quiet: no DOM change and no request in flight for a short window. */
|
|
130
|
+
readonly stable?: boolean
|
|
131
|
+
}
|
|
132
|
+
| {
|
|
133
|
+
/** Read one element's current value and state, without a snapshot. */
|
|
134
|
+
readonly action: 'value'
|
|
135
|
+
readonly ref: string
|
|
107
136
|
}
|
|
108
137
|
| {
|
|
109
138
|
readonly action: 'tabs'
|
|
@@ -120,20 +149,43 @@ export interface BrowserFormField {
|
|
|
120
149
|
readonly value: string
|
|
121
150
|
}
|
|
122
151
|
|
|
152
|
+
/**
|
|
153
|
+
* What a `click` or `hover` aims at: a ref from the latest snapshot, or, when
|
|
154
|
+
* the snapshot has no ref for it, the element's role and accessible name, or
|
|
155
|
+
* its visible text. Exactly one of the three forms is set. A host refuses a
|
|
156
|
+
* role/name or text that matches no element or several, and lists the
|
|
157
|
+
* candidates ({@link BrowserTargetUnclear}).
|
|
158
|
+
*/
|
|
159
|
+
export interface BrowserTarget {
|
|
160
|
+
readonly ref?: string
|
|
161
|
+
/** With `name`: an ARIA role such as `button` or `menuitem`. */
|
|
162
|
+
readonly role?: string
|
|
163
|
+
/** With `role`: the accessible name, matched as text. */
|
|
164
|
+
readonly name?: string
|
|
165
|
+
/** The element's visible text, matched as text. */
|
|
166
|
+
readonly text?: string
|
|
167
|
+
}
|
|
168
|
+
|
|
123
169
|
/** The change a `browser_act` call makes. */
|
|
124
170
|
export type BrowserActOperation =
|
|
125
|
-
| { readonly action: 'click'; readonly
|
|
171
|
+
| ({ readonly action: 'click'; readonly doubleClick?: boolean } & BrowserTarget)
|
|
126
172
|
| {
|
|
127
173
|
readonly action: 'type'
|
|
128
174
|
readonly ref: string
|
|
129
175
|
readonly text: string
|
|
130
176
|
/** Press Enter after typing. */
|
|
131
177
|
readonly submit?: boolean
|
|
178
|
+
/** Send real key events, one key at a time, instead of setting the value. */
|
|
179
|
+
readonly keys?: boolean
|
|
180
|
+
/** Empty the field first. This is also what happens when neither `clear` nor `append` is set. */
|
|
181
|
+
readonly clear?: boolean
|
|
182
|
+
/** Keep what the field holds and add the text after it. */
|
|
183
|
+
readonly append?: boolean
|
|
132
184
|
}
|
|
133
185
|
| { readonly action: 'fill_form'; readonly fields: readonly BrowserFormField[] }
|
|
134
186
|
| { readonly action: 'select'; readonly ref: string; readonly values: readonly string[] }
|
|
135
187
|
| { readonly action: 'press'; readonly key: string; readonly ref?: string }
|
|
136
|
-
| { readonly action: 'hover'
|
|
188
|
+
| ({ readonly action: 'hover' } & BrowserTarget)
|
|
137
189
|
| { readonly action: 'upload'; readonly ref: string; readonly path: string }
|
|
138
190
|
| { readonly action: 'dialog'; readonly accept: boolean; readonly promptText?: string }
|
|
139
191
|
|
|
@@ -147,6 +199,11 @@ export type BrowserActOperation =
|
|
|
147
199
|
* when they differ.** That comparison is what binds an approval of "click
|
|
148
200
|
* Place order on shop.example.com" to shop.example.com: a redirect between
|
|
149
201
|
* the snapshot and the click must not carry the click to another site.
|
|
202
|
+
*
|
|
203
|
+
* A host MAY go ahead when the live origin differs but the site rules treat
|
|
204
|
+
* the live origin exactly as they treat the named one (both at the level
|
|
205
|
+
* that needs no review), as long as it says so in the result's `message`.
|
|
206
|
+
* Where the rules would differ it MUST refuse.
|
|
150
207
|
*/
|
|
151
208
|
export type BrowserActAction = BrowserActOperation & {
|
|
152
209
|
readonly origin: string
|
|
@@ -193,6 +250,53 @@ export interface BrowserScreenshot {
|
|
|
193
250
|
readonly height: number
|
|
194
251
|
}
|
|
195
252
|
|
|
253
|
+
/**
|
|
254
|
+
* What an action did to the page, worked out by the host from the page before
|
|
255
|
+
* and after it: the one thing a model needs to tell a click that worked from
|
|
256
|
+
* one that did nothing. The counts and `settle` are the host's words; the
|
|
257
|
+
* lines and addresses are page text, so the tool shows them inside the
|
|
258
|
+
* untrusted envelope.
|
|
259
|
+
*/
|
|
260
|
+
export interface BrowserEffect {
|
|
261
|
+
/** The page's address before and after, when it changed. Page-controlled. */
|
|
262
|
+
readonly urlChanged?: { readonly from: string; readonly to: string }
|
|
263
|
+
/** How many lines of the page's tree appeared and disappeared. */
|
|
264
|
+
readonly added: number
|
|
265
|
+
readonly removed: number
|
|
266
|
+
/** The first few lines that appeared, and the first few that went. Page text. */
|
|
267
|
+
readonly addedLines: readonly string[]
|
|
268
|
+
readonly removedLines: readonly string[]
|
|
269
|
+
/** A new tab opened and the page the action ran on did not change. */
|
|
270
|
+
readonly newTab?: boolean
|
|
271
|
+
/**
|
|
272
|
+
* Present only when nothing visible changed but the page sent requests
|
|
273
|
+
* (fetch, XHR or a document, never images, scripts or beacons): the first
|
|
274
|
+
* few by method and path, with no query string. The paths are chosen by the
|
|
275
|
+
* site, so the tool shows them inside the untrusted envelope.
|
|
276
|
+
*/
|
|
277
|
+
readonly requests?: readonly { readonly method: string; readonly path: string }[]
|
|
278
|
+
/** How many requests the page sent; may exceed `requests`. Present with it. */
|
|
279
|
+
readonly requestCount?: number
|
|
280
|
+
/** Whether the page went quiet before the host looked, and how long it waited. */
|
|
281
|
+
readonly settle?: { readonly quiet: boolean; readonly waitedMs: number; readonly capMs: number }
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** One element's current value and state, from `value`. Page-controlled. */
|
|
285
|
+
export interface BrowserValue {
|
|
286
|
+
readonly page: BrowserPageInfo
|
|
287
|
+
readonly ref: string
|
|
288
|
+
readonly role?: string
|
|
289
|
+
readonly name?: string
|
|
290
|
+
/** What the control holds: the text of a field, the chosen option(s) of a select, the position of a slider. Absent when it holds none. */
|
|
291
|
+
readonly value?: string
|
|
292
|
+
/** `checked`, `selected`, `disabled`, `expanded`, `pressed`, `readonly`, `required`, `invalid`, as set. */
|
|
293
|
+
readonly state: readonly string[]
|
|
294
|
+
/** For a select: every option's label, the chosen ones listed in `value`. */
|
|
295
|
+
readonly options?: readonly string[]
|
|
296
|
+
/** The field is a password or one-time code; its value is not shown. */
|
|
297
|
+
readonly hidden?: boolean
|
|
298
|
+
}
|
|
299
|
+
|
|
196
300
|
/**
|
|
197
301
|
* What an action produced. Every field is optional because actions differ;
|
|
198
302
|
* the tool renders whichever are present.
|
|
@@ -209,6 +313,10 @@ export interface BrowserResult {
|
|
|
209
313
|
readonly snapshot?: BrowserSnapshot
|
|
210
314
|
readonly screenshot?: BrowserScreenshot
|
|
211
315
|
readonly tabs?: readonly BrowserTabInfo[]
|
|
316
|
+
/** `browser_act`: what the action did to the page. */
|
|
317
|
+
readonly effect?: BrowserEffect
|
|
318
|
+
/** `value`: the element's value and state. */
|
|
319
|
+
readonly value?: BrowserValue
|
|
212
320
|
}
|
|
213
321
|
|
|
214
322
|
/** What a snapshot said about one ref, for labelling a call before it runs. */
|
|
@@ -284,6 +392,38 @@ export interface BrowserOutcomeUnknown {
|
|
|
284
392
|
readonly message: string
|
|
285
393
|
}
|
|
286
394
|
|
|
395
|
+
/**
|
|
396
|
+
* An action failed before it did anything: the element was not reachable
|
|
397
|
+
* (covered, hidden, disabled, not stable) and the page was not touched. The
|
|
398
|
+
* model may take a fresh snapshot and try once more.
|
|
399
|
+
*/
|
|
400
|
+
export interface BrowserNoEffect {
|
|
401
|
+
readonly code: 'browser_no_effect'
|
|
402
|
+
readonly action: BrowserActionName
|
|
403
|
+
readonly outcome: 'unchanged'
|
|
404
|
+
readonly retrySafety: 'once-after-snapshot'
|
|
405
|
+
readonly message: string
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
/** One element a role/name or text target could have meant. */
|
|
409
|
+
export interface BrowserTargetCandidate {
|
|
410
|
+
readonly role: string
|
|
411
|
+
readonly name: string
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* A role/name or text target matched no element, or more than one. Nothing
|
|
416
|
+
* was done; `candidates` lists what matched (at most a handful).
|
|
417
|
+
*/
|
|
418
|
+
export interface BrowserTargetUnclear {
|
|
419
|
+
readonly code: 'browser_target_unclear'
|
|
420
|
+
readonly matches: number
|
|
421
|
+
readonly candidates: readonly BrowserTargetCandidate[]
|
|
422
|
+
/** What the model asked for, in the host's words, e.g. `button "Save"`. */
|
|
423
|
+
readonly wanted: string
|
|
424
|
+
readonly message: string
|
|
425
|
+
}
|
|
426
|
+
|
|
287
427
|
/** The site policy does not allow this origin at the level the call needs. */
|
|
288
428
|
export interface BrowserSiteDenied {
|
|
289
429
|
readonly code: 'browser_site_denied'
|
|
@@ -296,6 +436,8 @@ export type BrowserHostError =
|
|
|
296
436
|
| BrowserStaleRef
|
|
297
437
|
| BrowserHumanRequired
|
|
298
438
|
| BrowserOutcomeUnknown
|
|
439
|
+
| BrowserNoEffect
|
|
440
|
+
| BrowserTargetUnclear
|
|
299
441
|
| BrowserSiteDenied
|
|
300
442
|
|
|
301
443
|
// ---------------------------------------------------------------------------
|