@simular-ai/simulang-js 7.0.1 → 8.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.
- package/CHANGELOG.md +32 -0
- package/examples/element_at_point.mjs +75 -0
- package/index.d.ts +279 -45
- package/index.js +66 -56
- package/package.json +15 -15
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [8.1.0] - 2026-06-23
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- `AccessibilityNode.parent()`, `ancestors()`, direct/strict ancestry checks, and `lowestCommonAncestor(other)` for navigating accessibility-tree relationships. `parent()` returns `null` when a node has no parent, `ancestors()` stops only when the parent chain is fully resolved, and both throw on lookup failure; `lowestCommonAncestor` returns a `[node, level]` tuple where `level` is from the reached parentless node, returns `null` only for resolved unrelated trees, and throws if either parent chain cannot be resolved.
|
|
15
|
+
- `Window.screenshot(hideCursor)` — captures just this window's pixels from its own backing store (macOS `ScreenCaptureKit` window filter / Windows `Windows.Graphics.Capture`), so occluding windows don't bleed through and hardware-accelerated content (Chrome, Electron, D3D apps) is captured correctly; off-display or minimized windows throw.
|
|
16
|
+
- `Window.ground(model, concept)` — locate a concept within this window and return its global desktop coordinates (sugar for `screenshot(true).ground(model, concept)`); restricting the search to the window's bounds is faster and more accurate than grounding a full-screen screenshot.
|
|
17
|
+
- `AccessibilityNode.url` — the node's raw hyperlink target as a `string`, or `null` when the node isn't a link, has no target, or the platform doesn't expose it.
|
|
18
|
+
- `Image.drawDot(x, y, radius, red, green, blue)` and `Screenshot.drawDot(...)` — paint a filled opaque RGB disc at an image-pixel coordinate (companion to `drawGrid`; `radius` 0 paints a single pixel, out-of-bounds points are no-ops). Handy for annotating grounding results.
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Frame-relative input on a `Window` (`moveMouse`, `click`) now throws when the target point maps off every connected display, instead of letting the OS silently clamp the cursor to a screen edge and click the wrong location.
|
|
23
|
+
|
|
24
|
+
## [8.0.0] - 2026-06-05
|
|
25
|
+
|
|
26
|
+
### Added
|
|
27
|
+
|
|
28
|
+
- `AccessibilityNode.fromPoint(x, y)` — element under a screen coordinate via the platform hit-test (UIA `ElementFromPoint` on Windows, `AXUIElementCopyElementAtPosition` on macOS, recursive AT-SPI `GetAccessibleAtPoint` on Linux). Coordinates are global desktop coordinates in OS-native units (physical pixels on Windows/Linux, logical points on macOS), the same space as `boundingBox()` and `MouseController`; returns an uncached, one-shot handle for reading properties such as `.boundingBox()` / `.overallDescription`, or `null` when the point has no accessible element (empty desktop, gaps, or — on Linux — outside the focused app). Throws only on a genuine backend failure.
|
|
29
|
+
- `AccessibilityTree.findByDescription(description)` — every node whose `overallDescription` exactly equals `description` (pre-order depth-first)
|
|
30
|
+
- `GroundingModel.checkAuth()`, `AskModel.checkAuth()`, and `SttModel.checkAuth()` — probe the provider's auth-check endpoint to validate credentials before launching any UI automation. Throws (and logs a warning) on rejection or transport failure; no-op for providers without an auth-check endpoint. Idiom: `try { model.checkAuth() } catch { process.exit(1) }`.
|
|
31
|
+
|
|
32
|
+
### Changed
|
|
33
|
+
|
|
34
|
+
- `GroundingModel.default()` / `AskModel.default()` / `SttModel.default()` now produce a per-candidate diagnostic when no provider has working credentials, naming each provider and explaining exactly why its credentials were unavailable (env var unset, env var empty, credentials file missing, …). The previous error misleadingly said "no provider advertises a VLM service" even when the provider was correctly configured but its API-key env var was unset.
|
|
35
|
+
- Corrected the documented coordinate space across the API (`MouseController`, `Window.boundingBox()`, `AccessibilityNode.boundingBox()` / `fromPoint()`, `Screen.boundingBox()`, screenshots, and grounding output). Coordinates are in **OS-native units** — physical pixels on Windows/Linux and **logical points on macOS** (where one point spans two hardware pixels on a 2× display) — not uniformly "physical pixels" as previously stated. Behavior is unchanged; coordinates still round-trip between these APIs without conversion on a given OS.
|
|
36
|
+
|
|
37
|
+
### Breaking
|
|
38
|
+
|
|
39
|
+
- `Image.addGrid()` and `Screenshot.addGrid()` are renamed to `drawGrid()` to match the underlying `simulang-rs` API. Same signature and behavior; update call sites from `.addGrid(w, h)` to `.drawGrid(w, h)`.
|
|
40
|
+
- `Screenshot.toGlobalPhysicalPixels()` is renamed to `Screenshot.toGlobalDesktopCoordinates()`. The old name implied physical pixels, but the result is in the canonical global-desktop space (OS-native units — logical points on macOS, physical pixels on Windows/Linux). Same signature and behavior; update call sites from `.toGlobalPhysicalPixels(...)` to `.toGlobalDesktopCoordinates(...)`.
|
|
41
|
+
|
|
10
42
|
## [7.0.1] - 2026-05-22
|
|
11
43
|
|
|
12
44
|
## [7.0.0] - 2026-05-22
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Run: node examples/element_at_point.mjs
|
|
2
|
+
// Optionally pass coordinates: node examples/element_at_point.mjs 400 300
|
|
3
|
+
//
|
|
4
|
+
// Demonstrates the element-picker primitives:
|
|
5
|
+
// 1. AccessibilityNode.fromPoint(x, y) — hit-test the element under a
|
|
6
|
+
// screen coordinate (used per-poll to draw a hover highlight). The
|
|
7
|
+
// returned node is already actionable (activate / setValue / …).
|
|
8
|
+
// 2. AccessibilityTree.findByDescription(desc) — the picker's grounding
|
|
9
|
+
// check: is this element's overallDescription unique in the window?
|
|
10
|
+
// `isUnique` is just `matches.length === 1`.
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
AccessibilityNode,
|
|
14
|
+
AccessibilityTree,
|
|
15
|
+
MouseController,
|
|
16
|
+
Window,
|
|
17
|
+
ariaRoleToString,
|
|
18
|
+
} from '@simular-ai/simulang-js'
|
|
19
|
+
|
|
20
|
+
// Coordinates: explicit args, or the live cursor location.
|
|
21
|
+
const args = process.argv.slice(2)
|
|
22
|
+
const [x, y] = args.length >= 2 ? [Number(args[0]), Number(args[1])] : new MouseController().location()
|
|
23
|
+
|
|
24
|
+
// 1. Hit-test — cheap, resolves a single element. Returns null when the
|
|
25
|
+
// point has no accessible element (empty desktop, gaps, etc.).
|
|
26
|
+
const t0 = Date.now()
|
|
27
|
+
const node = AccessibilityNode.fromPoint(x, y)
|
|
28
|
+
if (!node) {
|
|
29
|
+
console.log(`=== No accessible element at (${x}, ${y}) (${Date.now() - t0}ms) ===`)
|
|
30
|
+
process.exit(0)
|
|
31
|
+
}
|
|
32
|
+
const description = node.overallDescription
|
|
33
|
+
console.log(`=== Element at (${x}, ${y}) — fromPoint in ${Date.now() - t0}ms ===`)
|
|
34
|
+
console.log(`role: ${ariaRoleToString(node.role)}`)
|
|
35
|
+
console.log(`name: ${JSON.stringify(node.name)}`)
|
|
36
|
+
console.log(`value: ${JSON.stringify(node.value)}`)
|
|
37
|
+
console.log(`description: ${JSON.stringify(description)}`)
|
|
38
|
+
console.log('bounds: ', node.boundingBox())
|
|
39
|
+
// The fromPoint node is already actionable — no tree round-trip to click it.
|
|
40
|
+
console.log('actions: ', node.supportedActions())
|
|
41
|
+
|
|
42
|
+
// 2. Uniqueness of the description across the whole window (the picker's
|
|
43
|
+
// grounding check). This walks the *entire* tree computing
|
|
44
|
+
// summary_with_context per node, so it is far heavier than fromPoint —
|
|
45
|
+
// especially on macOS, where every attribute read is a live AX IPC.
|
|
46
|
+
console.log('\n=== findByDescription on foreground window (app-scoped) ===')
|
|
47
|
+
const t1 = Date.now()
|
|
48
|
+
const tree = AccessibilityTree.fromForeground()
|
|
49
|
+
const matches = tree.findByDescription(description)
|
|
50
|
+
console.log(`matches: ${matches.length} (in ${Date.now() - t1}ms)`)
|
|
51
|
+
console.log(`isUnique: ${matches.length === 1}`)
|
|
52
|
+
if (matches.length > 1) {
|
|
53
|
+
console.log(
|
|
54
|
+
'Not a stable grounding key — the cursor is over a generic/nameless ' +
|
|
55
|
+
'container whose description many siblings share.',
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// 3. Window-scoped uniqueness: resolve the window under the cursor and check
|
|
60
|
+
// uniqueness WITHIN that window only (cross-platform: AXWindow subtree on
|
|
61
|
+
// macOS, the HWND subtree on Windows). This is what the element picker
|
|
62
|
+
// should use so a description shared across other windows of the same app
|
|
63
|
+
// doesn't count against it.
|
|
64
|
+
console.log('\n=== findByDescription on hovered window (window-scoped) ===')
|
|
65
|
+
const window = Window.fromPoint(x, y)
|
|
66
|
+
if (!window) {
|
|
67
|
+
console.log(`No window under (${x}, ${y}).`)
|
|
68
|
+
} else {
|
|
69
|
+
console.log(`window: ${JSON.stringify(window.title)} (pid ${window.pid})`)
|
|
70
|
+
const t2 = Date.now()
|
|
71
|
+
const windowTree = AccessibilityTree.fromWindow(window)
|
|
72
|
+
const windowMatches = windowTree.findByDescription(description)
|
|
73
|
+
console.log(`matches: ${windowMatches.length} (in ${Date.now() - t2}ms)`)
|
|
74
|
+
console.log(`isUnique: ${windowMatches.length === 1}`)
|
|
75
|
+
}
|
package/index.d.ts
CHANGED
|
@@ -16,6 +16,26 @@ export declare class AccessibilityNode {
|
|
|
16
16
|
static fromFocusedApplication(): AccessibilityNode
|
|
17
17
|
/** Root node of the application identified by `pid`. */
|
|
18
18
|
static fromPid(pid: number): AccessibilityNode
|
|
19
|
+
/**
|
|
20
|
+
* Element at screen coordinates (`x`, `y`) via the platform hit-test
|
|
21
|
+
* (Windows UIA `ElementFromPoint`, macOS
|
|
22
|
+
* `AXUIElementCopyElementAtPosition`, Linux recursive AT-SPI
|
|
23
|
+
* `GetAccessibleAtPoint`).
|
|
24
|
+
*
|
|
25
|
+
* `(x, y)` are global desktop coordinates in the canonical coordinate space
|
|
26
|
+
* (OS-native units; see [`MouseController`])
|
|
27
|
+
* — the same space `.boundingBox()` and `MouseController` use, so a
|
|
28
|
+
* `boundingBox()` corner or cursor `location()` can be passed straight in.
|
|
29
|
+
* Returns an **uncached** handle suitable for one-shot reads of properties
|
|
30
|
+
* such as `.boundingBox()` or `.overallDescription`; it is not registered
|
|
31
|
+
* for ref-based action methods (`activate`, `setValue`, …).
|
|
32
|
+
*
|
|
33
|
+
* Returns `null` when the point has no accessible element (empty
|
|
34
|
+
* desktop, gaps between controls, or — on Linux — a point outside the
|
|
35
|
+
* focused application). Throws only on a genuine accessibility-backend
|
|
36
|
+
* failure.
|
|
37
|
+
*/
|
|
38
|
+
static fromPoint(x: number, y: number): AccessibilityNode | null
|
|
19
39
|
/** Cross-platform ARIA role. */
|
|
20
40
|
get role(): AriaRole
|
|
21
41
|
/** Accessible name (title / label). */
|
|
@@ -42,7 +62,16 @@ export declare class AccessibilityNode {
|
|
|
42
62
|
/** Whether the node accepts user input. */
|
|
43
63
|
get isEnabled(): boolean
|
|
44
64
|
/**
|
|
45
|
-
*
|
|
65
|
+
* Hyperlink target of this node, or `null` when the node is not a link,
|
|
66
|
+
* the link has no target, or the platform backend does not expose the
|
|
67
|
+
* target through the accessibility API. The string is the raw URL as
|
|
68
|
+
* reported by the platform (no parsing or normalisation).
|
|
69
|
+
*/
|
|
70
|
+
get url(): string | null
|
|
71
|
+
/**
|
|
72
|
+
* Live bounding box of the element on the global desktop, in the canonical
|
|
73
|
+
* coordinate space (OS-native units; see
|
|
74
|
+
* [`MouseController`]).
|
|
46
75
|
* `right` and `bottom` are exclusive (Playwright / DOM convention).
|
|
47
76
|
*/
|
|
48
77
|
boundingBox(): BoundingBox
|
|
@@ -52,6 +81,31 @@ export declare class AccessibilityNode {
|
|
|
52
81
|
* simulang-rs's convention of treating walk failures as "no children").
|
|
53
82
|
*/
|
|
54
83
|
children(): Array<AccessibilityNode>
|
|
84
|
+
/**
|
|
85
|
+
* Direct parent node, or `null` if this node has no parent. Parent lookup
|
|
86
|
+
* failures throw.
|
|
87
|
+
*/
|
|
88
|
+
parent(): AccessibilityNode | null
|
|
89
|
+
/**
|
|
90
|
+
* Parent chain for this node, nearest parent first, excluding this node.
|
|
91
|
+
* Stops when a node has no parent; parent lookup failures throw.
|
|
92
|
+
*/
|
|
93
|
+
ancestors(): Array<AccessibilityNode>
|
|
94
|
+
/** Whether this node is the direct parent of `other`. */
|
|
95
|
+
isParentOf(other: AccessibilityNode): boolean
|
|
96
|
+
/** Whether this node is a direct child of `other`. */
|
|
97
|
+
isChildOf(other: AccessibilityNode): boolean
|
|
98
|
+
/** Whether this node is a strict ancestor of `other`. */
|
|
99
|
+
isAncestorOf(other: AccessibilityNode): boolean
|
|
100
|
+
/** Whether this node is a strict descendant of `other`. */
|
|
101
|
+
isDescendantOf(other: AccessibilityNode): boolean
|
|
102
|
+
/**
|
|
103
|
+
* Lowest shared ancestor for this node and `other`, plus that ancestor's
|
|
104
|
+
* level from the reached parentless node (`parentless = 0`, its children
|
|
105
|
+
* `= 1`). Returns `null` when both chains resolve and no shared ancestor
|
|
106
|
+
* exists; lookup failures throw.
|
|
107
|
+
*/
|
|
108
|
+
lowestCommonAncestor(other: AccessibilityNode): [AccessibilityNode, number] | null
|
|
55
109
|
/**
|
|
56
110
|
* Render this node's accessibility subtree as an indented
|
|
57
111
|
* Playwright-style aria snapshot string.
|
|
@@ -138,6 +192,22 @@ export declare class AccessibilityTree {
|
|
|
138
192
|
* On Windows this is an HWND; on macOS it is a PID.
|
|
139
193
|
*/
|
|
140
194
|
static fromHwnd(hwnd: number): AccessibilityTree
|
|
195
|
+
/**
|
|
196
|
+
* Create an accessibility tree scoped to a single window.
|
|
197
|
+
*
|
|
198
|
+
* Unlike [`AccessibilityTree.fromForeground`] / [`fromPid`] — which on
|
|
199
|
+
* macOS scope to the whole application (every window plus the app menu
|
|
200
|
+
* bar) — this scopes to exactly the given window's subtree on **both**
|
|
201
|
+
* Windows and macOS. Use it to measure "is this element unique within
|
|
202
|
+
* this window", or to snapshot / act on one window of a multi-window
|
|
203
|
+
* app.
|
|
204
|
+
*
|
|
205
|
+
* The window is resolved once at construction; subsequent snapshots
|
|
206
|
+
* target that same window. On macOS the underlying `AXWindow` handle can
|
|
207
|
+
* go stale if the window is destroyed and recreated (as an `HWND` can on
|
|
208
|
+
* Windows).
|
|
209
|
+
*/
|
|
210
|
+
static fromWindow(window: Window): AccessibilityTree
|
|
141
211
|
/** Get the window title. */
|
|
142
212
|
get windowTitle(): string
|
|
143
213
|
/**
|
|
@@ -217,6 +287,15 @@ export declare class AccessibilityTree {
|
|
|
217
287
|
maxResults?: number | undefined | null,
|
|
218
288
|
collapseStructural?: boolean | undefined | null,
|
|
219
289
|
): Array<AccessibilityNodeJs>
|
|
290
|
+
/**
|
|
291
|
+
* Find every node whose `overallDescription`
|
|
292
|
+
* (`AXNodeSynthetic::summary_with_context`) is **exactly** equal to
|
|
293
|
+
* `description`, walked in pre-order depth-first.
|
|
294
|
+
*
|
|
295
|
+
* Clears existing refs; returned nodes carry `refId` values usable
|
|
296
|
+
* with the action methods (`activate`, `setValue`, …).
|
|
297
|
+
*/
|
|
298
|
+
findByDescription(description: string): Array<AccessibilityNodeJs>
|
|
220
299
|
}
|
|
221
300
|
|
|
222
301
|
/** Represents an application that can be opened. */
|
|
@@ -286,6 +365,17 @@ export declare class AskModel {
|
|
|
286
365
|
static availableAliases(): Array<string>
|
|
287
366
|
/** The wire-level model identifier sent in the request body. */
|
|
288
367
|
get name(): string
|
|
368
|
+
/**
|
|
369
|
+
* Check that the API key works. Throws if it doesn't.
|
|
370
|
+
*
|
|
371
|
+
* Call right after creating the model so a bad key fails fast,
|
|
372
|
+
* before any UI automation has had a chance to steal focus:
|
|
373
|
+
*
|
|
374
|
+
* ```ts
|
|
375
|
+
* try { model.checkAuth() } catch { process.exit(1) }
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
checkAuth(): void
|
|
289
379
|
/**
|
|
290
380
|
* Ask the model a question, optionally grounded in accessibility text
|
|
291
381
|
* and/or images.
|
|
@@ -502,16 +592,25 @@ export declare class GroundingModel {
|
|
|
502
592
|
static availableAliases(): Array<string>
|
|
503
593
|
/** The wire-level model identifier sent in the request body. */
|
|
504
594
|
get name(): string
|
|
595
|
+
/**
|
|
596
|
+
* Check that the API key works. Throws if it doesn't.
|
|
597
|
+
*
|
|
598
|
+
* Call right after creating the model so a bad key fails fast,
|
|
599
|
+
* before any UI automation has had a chance to steal focus:
|
|
600
|
+
*
|
|
601
|
+
* ```ts
|
|
602
|
+
* try { model.checkAuth() } catch { process.exit(1) }
|
|
603
|
+
* ```
|
|
604
|
+
*/
|
|
605
|
+
checkAuth(): void
|
|
505
606
|
/**
|
|
506
607
|
* Locate `concept` on `target` and return zero-based pixel coordinates
|
|
507
608
|
* `[x, y]`:
|
|
508
609
|
*
|
|
509
610
|
* * If `target` is an `Image`, coordinates are in **image-space**.
|
|
510
|
-
*
|
|
511
|
-
*
|
|
512
|
-
*
|
|
513
|
-
* screen space** — suitable to feed directly into primitives that
|
|
514
|
-
* expect global screen coordinates (e.g. `moveTo`, `clickAt`).
|
|
611
|
+
* * If `target` is a `Screenshot`, coordinates are in the **global desktop
|
|
612
|
+
* space** in OS-native units (may be negative on multi-monitor setups;
|
|
613
|
+
* see [`MouseController`]).
|
|
515
614
|
*
|
|
516
615
|
* Equivalent to `target.ground(model, concept)`.
|
|
517
616
|
*/
|
|
@@ -527,7 +626,22 @@ export declare class Image {
|
|
|
527
626
|
*
|
|
528
627
|
* Grid squares have the specified `width` and `height`.
|
|
529
628
|
*/
|
|
530
|
-
|
|
629
|
+
drawGrid(width: number, height: number): void
|
|
630
|
+
/**
|
|
631
|
+
* Paints a filled disc on the image. Useful for visualizing point
|
|
632
|
+
* coordinates returned from grounding, layout queries, etc.
|
|
633
|
+
*
|
|
634
|
+
* `x` / `y` are image-pixel coordinates of the disc's centre. `radius`
|
|
635
|
+
* is the disc radius in pixels (`0` paints a single pixel at the
|
|
636
|
+
* centre). `(red, green, blue)` is the fill color; alpha is always 255
|
|
637
|
+
* (opaque replacement of the underlying pixel).
|
|
638
|
+
*
|
|
639
|
+
* Coordinates that fall outside the image bounds (negative, or past the
|
|
640
|
+
* width / height) silently produce no pixel, so the helper is safe to
|
|
641
|
+
* call with the raw output of a grounding model even at the edge of the
|
|
642
|
+
* captured rect.
|
|
643
|
+
*/
|
|
644
|
+
drawDot(x: number, y: number, radius: number, red: number, green: number, blue: number): void
|
|
531
645
|
/**
|
|
532
646
|
* Compress the image by converting it to JPEG with the specified quality.
|
|
533
647
|
*
|
|
@@ -746,20 +860,35 @@ export declare class LoopbackSource {
|
|
|
746
860
|
}
|
|
747
861
|
|
|
748
862
|
/**
|
|
749
|
-
*
|
|
863
|
+
* Contains functions to control the mouse and to get the cursor position.
|
|
864
|
+
*
|
|
865
|
+
* # Canonical coordinate space
|
|
750
866
|
*
|
|
751
|
-
*
|
|
752
|
-
*
|
|
753
|
-
*
|
|
754
|
-
*
|
|
867
|
+
* This is the reference description of the coordinate space used throughout
|
|
868
|
+
* the library. `Window.boundingBox()`, `AccessibilityNode.boundingBox()`,
|
|
869
|
+
* `AccessibilityNode.fromPoint()`, screenshots, and grounding-model output
|
|
870
|
+
* all live in this same space, so coordinates round-trip between them
|
|
871
|
+
* **without conversion**.
|
|
755
872
|
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
* [`Window.moveMouse`] for window-frame-relative input) to discover
|
|
760
|
-
* where the addressable region actually is.
|
|
873
|
+
* Absolute coordinates live on the **global desktop**: top-left origin at
|
|
874
|
+
* `(0, 0)` on the primary monitor, with the OS's native units. The unit is
|
|
875
|
+
* **not** the same on every OS:
|
|
761
876
|
*
|
|
762
|
-
*
|
|
877
|
+
* - **Windows** and **Linux** use **physical pixels** (raw hardware pixels).
|
|
878
|
+
* - **macOS** uses **logical points** — on a 2× Retina display one point spans
|
|
879
|
+
* two hardware pixels, so coordinates are half the physical-pixel count.
|
|
880
|
+
*
|
|
881
|
+
* Within a single OS every function speaks that OS's unit, so the
|
|
882
|
+
* round-trip guarantee holds; only code that crosses into a *different*
|
|
883
|
+
* coordinate system (e.g. an Electron overlay measured in CSS pixels) needs to
|
|
884
|
+
* account for the per-OS unit. These are also the native units the OS
|
|
885
|
+
* input/accessibility APIs expect, so they are *not* the browser logical/CSS
|
|
886
|
+
* pixel.
|
|
887
|
+
*
|
|
888
|
+
* Monitors arranged to the left of or above the primary display contribute
|
|
889
|
+
* **negative** coordinates, so callers should not assume `x, y >= 0`. Use
|
|
890
|
+
* [`Screen.all`] / [`Screen.fromWindow`] to discover where the
|
|
891
|
+
* addressable region actually is.
|
|
763
892
|
*/
|
|
764
893
|
export declare class MouseController {
|
|
765
894
|
constructor()
|
|
@@ -775,11 +904,11 @@ export declare class MouseController {
|
|
|
775
904
|
* You can specify absolute coordinates or relative from the current
|
|
776
905
|
* position.
|
|
777
906
|
*
|
|
778
|
-
* With absolute coordinates, `(x, y)` is in the global
|
|
779
|
-
*
|
|
780
|
-
*
|
|
781
|
-
* monitors arranged above / to the left
|
|
782
|
-
*
|
|
907
|
+
* With absolute coordinates, `(x, y)` is in the global desktop space
|
|
908
|
+
* described on [`MouseController`]: top-left of the primary monitor is
|
|
909
|
+
* `(0, 0)`, OS-native units (physical pixels on Windows/Linux, logical
|
|
910
|
+
* points on macOS), and secondary monitors arranged above / to the left
|
|
911
|
+
* of the primary may have negative coordinates.
|
|
783
912
|
*
|
|
784
913
|
* With relative coordinates, a positive `x` moves the cursor `x`
|
|
785
914
|
* pixels to the right; a positive `y` moves it down.
|
|
@@ -792,7 +921,10 @@ export declare class MouseController {
|
|
|
792
921
|
* ones up/left.
|
|
793
922
|
*/
|
|
794
923
|
scroll(deltaX: number, deltaY: number): void
|
|
795
|
-
/**
|
|
924
|
+
/**
|
|
925
|
+
* Get the location of the mouse in the canonical global-desktop space
|
|
926
|
+
* (OS-native units; see [`MouseController`]).
|
|
927
|
+
*/
|
|
796
928
|
location(): [number, number]
|
|
797
929
|
}
|
|
798
930
|
|
|
@@ -926,7 +1058,7 @@ export declare class SamplesBuffer {
|
|
|
926
1058
|
transcribe(model: SttModel): string
|
|
927
1059
|
}
|
|
928
1060
|
|
|
929
|
-
/** Represents a
|
|
1061
|
+
/** Represents a connected display/screen on the global desktop. */
|
|
930
1062
|
export declare class Screen {
|
|
931
1063
|
/** Returns the main / primary screen. */
|
|
932
1064
|
static mainScreen(): Screen
|
|
@@ -962,9 +1094,10 @@ export declare class Screen {
|
|
|
962
1094
|
*/
|
|
963
1095
|
static all(): Array<Screen>
|
|
964
1096
|
/**
|
|
965
|
-
* Live bounding box of the screen
|
|
1097
|
+
* Live bounding box of the screen on the global desktop.
|
|
966
1098
|
*
|
|
967
|
-
* Top-left of the primary monitor is `(0, 0)`,
|
|
1099
|
+
* Top-left of the primary monitor is `(0, 0)`, in the canonical coordinate
|
|
1100
|
+
* space (OS-native units; see [`MouseController`]).
|
|
968
1101
|
* Monitors arranged to the left of or above the primary display
|
|
969
1102
|
* contribute **negative** `left` / `top`. `right` and `bottom` are
|
|
970
1103
|
* exclusive (Playwright / DOM convention), matching
|
|
@@ -985,7 +1118,22 @@ export declare class Screenshot {
|
|
|
985
1118
|
*
|
|
986
1119
|
* Grid squares have the specified `width` and `height`.
|
|
987
1120
|
*/
|
|
988
|
-
|
|
1121
|
+
drawGrid(width: number, height: number): void
|
|
1122
|
+
/**
|
|
1123
|
+
* Paints a filled disc on the image. Useful for visualizing point
|
|
1124
|
+
* coordinates returned from grounding, layout queries, etc.
|
|
1125
|
+
*
|
|
1126
|
+
* `x` / `y` are image-pixel coordinates of the disc's centre. `radius`
|
|
1127
|
+
* is the disc radius in pixels (`0` paints a single pixel at the
|
|
1128
|
+
* centre). `(red, green, blue)` is the fill color; alpha is always 255
|
|
1129
|
+
* (opaque replacement of the underlying pixel).
|
|
1130
|
+
*
|
|
1131
|
+
* Coordinates that fall outside the image bounds (negative, or past the
|
|
1132
|
+
* width / height) silently produce no pixel, so the helper is safe to
|
|
1133
|
+
* call with the raw output of a grounding model even at the edge of the
|
|
1134
|
+
* captured rect.
|
|
1135
|
+
*/
|
|
1136
|
+
drawDot(x: number, y: number, radius: number, red: number, green: number, blue: number): void
|
|
989
1137
|
/**
|
|
990
1138
|
* Compress the image by converting it to JPEG with the specified quality.
|
|
991
1139
|
*
|
|
@@ -1015,23 +1163,27 @@ export declare class Screenshot {
|
|
|
1015
1163
|
*/
|
|
1016
1164
|
base64(): string
|
|
1017
1165
|
/**
|
|
1018
|
-
* Converts a point in this screenshot to global
|
|
1019
|
-
*
|
|
1166
|
+
* Converts a point in this screenshot to global desktop coordinates.
|
|
1167
|
+
*
|
|
1168
|
+
* The result is in the library's canonical coordinate space (OS-native
|
|
1169
|
+
* units; see [`MouseController`]), so it can be fed straight to
|
|
1170
|
+
* `MouseController.moveMouse` without conversion.
|
|
1020
1171
|
*
|
|
1021
|
-
* Screenshots may represent only part of a display, and
|
|
1022
|
-
*
|
|
1023
|
-
*
|
|
1024
|
-
* moving the mouse to the same on-screen point).
|
|
1172
|
+
* Screenshots may represent only part of a display, and the captured
|
|
1173
|
+
* region may have been resampled to a different image size, so this
|
|
1174
|
+
* rescales `(x, y)` from image space back to the captured region (for
|
|
1175
|
+
* example, when moving the mouse to the same on-screen point).
|
|
1025
1176
|
*
|
|
1026
1177
|
* See `ScreenshotCoordinateType` for how `coord_type` affects
|
|
1027
1178
|
* interpretation of `(x, y)`.
|
|
1028
1179
|
*/
|
|
1029
|
-
|
|
1180
|
+
toGlobalDesktopCoordinates(x: number, y: number, coordType: ScreenshotCoordinateType): [number, number]
|
|
1030
1181
|
/**
|
|
1031
1182
|
* Locate `concept` on this screenshot using the given grounding model and
|
|
1032
|
-
* return the corresponding **global
|
|
1033
|
-
*
|
|
1034
|
-
*
|
|
1183
|
+
* return the corresponding **global desktop coordinates** `[x, y]` in
|
|
1184
|
+
* OS-native units (may be negative on multi-monitor setups; see
|
|
1185
|
+
* [`MouseController`]). The output can be fed
|
|
1186
|
+
* directly to primitives that expect global screen coordinates.
|
|
1035
1187
|
*
|
|
1036
1188
|
* Equivalent to `model.ground(screenshot, concept)`.
|
|
1037
1189
|
*/
|
|
@@ -1039,8 +1191,9 @@ export declare class Screenshot {
|
|
|
1039
1191
|
}
|
|
1040
1192
|
|
|
1041
1193
|
/**
|
|
1042
|
-
*
|
|
1043
|
-
*
|
|
1194
|
+
* How a screenshot-relative `(x, y)` coordinate is expressed: as absolute
|
|
1195
|
+
* screenshot-image pixels or normalized to a fixed range. Construct one with
|
|
1196
|
+
* [`ScreenshotCoordinateType.absolute`] or [`ScreenshotCoordinateType.normalized`].
|
|
1044
1197
|
*/
|
|
1045
1198
|
export declare class ScreenshotCoordinateType {
|
|
1046
1199
|
/**
|
|
@@ -1089,6 +1242,17 @@ export declare class SttModel {
|
|
|
1089
1242
|
static availableAliases(): Array<string>
|
|
1090
1243
|
/** The wire-level model identifier sent in the request body. */
|
|
1091
1244
|
get name(): string
|
|
1245
|
+
/**
|
|
1246
|
+
* Check that the API key works. Throws if it doesn't.
|
|
1247
|
+
*
|
|
1248
|
+
* Call right after creating the model so a bad key fails fast,
|
|
1249
|
+
* before any UI automation has had a chance to steal focus:
|
|
1250
|
+
*
|
|
1251
|
+
* ```ts
|
|
1252
|
+
* try { model.checkAuth() } catch { process.exit(1) }
|
|
1253
|
+
* ```
|
|
1254
|
+
*/
|
|
1255
|
+
checkAuth(): void
|
|
1092
1256
|
/** Transcribe a single audio chunk and return the recognised text. */
|
|
1093
1257
|
transcribe(audio: SamplesBuffer): string
|
|
1094
1258
|
}
|
|
@@ -1114,12 +1278,32 @@ export declare class Window {
|
|
|
1114
1278
|
static allForPid(pid: number): Array<Window>
|
|
1115
1279
|
/** All visible top-level windows across every process. */
|
|
1116
1280
|
static all(): Array<Window>
|
|
1281
|
+
/**
|
|
1282
|
+
* The top-level window at screen coordinates `(x, y)`, or `null` when no
|
|
1283
|
+
* window sits under the point.
|
|
1284
|
+
*
|
|
1285
|
+
* `(x, y)` are global desktop coordinates in the canonical coordinate
|
|
1286
|
+
* space (OS-native units; see [`MouseController`]) — the same space
|
|
1287
|
+
* `Window.boundingBox`, `AccessibilityNode.fromPoint`, and
|
|
1288
|
+
* `MouseController.location` use, so a cursor `location()` can be passed
|
|
1289
|
+
* straight in.
|
|
1290
|
+
*
|
|
1291
|
+
* Platform notes:
|
|
1292
|
+
* - **macOS**: returns the containing `AXWindow` of the element under the
|
|
1293
|
+
* cursor — the window itself, not the whole application.
|
|
1294
|
+
* - **Windows**: returns the top-level window (`GA_ROOT`) of whatever
|
|
1295
|
+
* control sits under the cursor.
|
|
1296
|
+
* - **Linux**: always `null` (no per-point window hit-test).
|
|
1297
|
+
*/
|
|
1298
|
+
static fromPoint(x: number, y: number): Window | null
|
|
1117
1299
|
/** Window title (may be empty). */
|
|
1118
1300
|
get title(): string
|
|
1119
1301
|
/** Process ID that owns this window. */
|
|
1120
1302
|
get pid(): number
|
|
1121
1303
|
/**
|
|
1122
|
-
* Live bounding box of the window
|
|
1304
|
+
* Live bounding box of the window on the global desktop, in the canonical
|
|
1305
|
+
* coordinate space (OS-native units; see
|
|
1306
|
+
* [`MouseController`]).
|
|
1123
1307
|
* `right` and `bottom` are exclusive (Playwright / DOM convention).
|
|
1124
1308
|
* Coordinates can be negative when the window sits on a monitor that
|
|
1125
1309
|
* is arranged to the left of / above the primary display.
|
|
@@ -1165,9 +1349,20 @@ export declare class Window {
|
|
|
1165
1349
|
/**
|
|
1166
1350
|
* Move the cursor to a point inside this window.
|
|
1167
1351
|
*
|
|
1168
|
-
* `(x, y)` are **window-frame-relative
|
|
1169
|
-
*
|
|
1170
|
-
* title bar and
|
|
1352
|
+
* `(x, y)` are **window-frame-relative**, in OS-native units (physical
|
|
1353
|
+
* pixels on Windows/Linux, logical points on macOS) — `(0, 0)` is the
|
|
1354
|
+
* top-left of [`Window.boundingBox`], which includes the title bar and
|
|
1355
|
+
* other OS chrome.
|
|
1356
|
+
*
|
|
1357
|
+
* Two validation passes run before any input is synthesized, and either
|
|
1358
|
+
* failing throws:
|
|
1359
|
+
* 1. `(x, y)` must lie inside the window frame (`[0, width) × [0,
|
|
1360
|
+
* height)`).
|
|
1361
|
+
* 2. The resulting global point must fall on at least one connected
|
|
1362
|
+
* display. Windows dragged partly off-screen can map an in-frame
|
|
1363
|
+
* point to a coordinate the OS would silently clamp to a display
|
|
1364
|
+
* edge — erroring out is strictly more useful than moving the cursor
|
|
1365
|
+
* somewhere unintended and clicking the wrong thing.
|
|
1171
1366
|
*
|
|
1172
1367
|
* Does **not** focus the window. Call [`Window.focus`] (or
|
|
1173
1368
|
* [`Instance.focus`]) first if the click target requires the window
|
|
@@ -1187,7 +1382,9 @@ export declare class Window {
|
|
|
1187
1382
|
* Move the cursor to `(x, y)` inside this window and synthesise a
|
|
1188
1383
|
* mouse button event. Sugar for `moveMouse(x, y); button(...)`.
|
|
1189
1384
|
*
|
|
1190
|
-
* Coordinates are window-frame-relative (see [`Window.moveMouse`])
|
|
1385
|
+
* Coordinates are window-frame-relative (see [`Window.moveMouse`]), and
|
|
1386
|
+
* are subject to the same bounds / on-screen validation: an off-frame or
|
|
1387
|
+
* off-screen target throws instead of clicking the wrong location.
|
|
1191
1388
|
* Does not focus the window.
|
|
1192
1389
|
*/
|
|
1193
1390
|
click(x: number, y: number, button: Button, direction: Direction): void
|
|
@@ -1210,6 +1407,43 @@ export declare class Window {
|
|
|
1210
1407
|
* [`AccessibilityTree.snapshot`] instead.
|
|
1211
1408
|
*/
|
|
1212
1409
|
snapshot(): string
|
|
1410
|
+
/**
|
|
1411
|
+
* Capture just this window's pixels.
|
|
1412
|
+
*
|
|
1413
|
+
* Reads from the window's own backing store, so overlapping windows do
|
|
1414
|
+
* **not** bleed through and the whole window is captured even where it is
|
|
1415
|
+
* occluded or extends past a display edge — partially off-screen and
|
|
1416
|
+
* multi-display-spanning windows are captured in full. The window must be
|
|
1417
|
+
* on-screen at capture time: a minimized or fully off-display window
|
|
1418
|
+
* throws, because there is nothing to capture.
|
|
1419
|
+
*/
|
|
1420
|
+
screenshot(hideCursor: boolean): Screenshot
|
|
1421
|
+
/**
|
|
1422
|
+
* Locate `concept` inside this window's pixels and return its **global
|
|
1423
|
+
* desktop coordinates** `[x, y]` in OS-native units (may be negative on
|
|
1424
|
+
* multi-monitor setups; see [`MouseController`]), ready to feed straight
|
|
1425
|
+
* into [`MouseController.moveMouse`] / click helpers.
|
|
1426
|
+
*
|
|
1427
|
+
* Sugar for `screenshot(true).ground(model, concept)` — the cursor is
|
|
1428
|
+
* hidden because it can occlude or distract the model. Restricts the
|
|
1429
|
+
* model's search to this window's bounds, which is both faster (fewer
|
|
1430
|
+
* pixels to upload) and more accurate (no risk of grounding onto a
|
|
1431
|
+
* concept that happens to be elsewhere on the screen) than grounding a
|
|
1432
|
+
* full-screen screenshot.
|
|
1433
|
+
*
|
|
1434
|
+
* Drop down to [`Window.screenshot`] + [`Screenshot.ground`] directly
|
|
1435
|
+
* when you want to keep the cursor visible, reuse the screenshot across
|
|
1436
|
+
* multiple `ground` calls, or shrink / compress the image before
|
|
1437
|
+
* sending it.
|
|
1438
|
+
*
|
|
1439
|
+
* The screenshot includes any portion of the window that's past the
|
|
1440
|
+
* desktop edge (the capture reads the window's own backing store, not a
|
|
1441
|
+
* display rectangle). A `concept` the model locates in that off-screen
|
|
1442
|
+
* region returns coordinates the OS won't route a click to;
|
|
1443
|
+
* [`Window.moveMouse`] catches this and errors out instead of clicking
|
|
1444
|
+
* the nearest on-screen point.
|
|
1445
|
+
*/
|
|
1446
|
+
ground(model: GroundingModel, concept: string): [number, number]
|
|
1213
1447
|
/**
|
|
1214
1448
|
* Search this window's accessibility subtree by *concept text*, using
|
|
1215
1449
|
* bag-of-words paired-Jaccard scoring against each node's
|
package/index.js
CHANGED
|
@@ -77,8 +77,8 @@ function requireNative() {
|
|
|
77
77
|
try {
|
|
78
78
|
const binding = require('@simular-ai/simulang-js-android-arm64')
|
|
79
79
|
const bindingPackageVersion = require('@simular-ai/simulang-js-android-arm64/package.json').version
|
|
80
|
-
if (bindingPackageVersion !== '
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
80
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
81
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
82
82
|
}
|
|
83
83
|
return binding
|
|
84
84
|
} catch (e) {
|
|
@@ -93,8 +93,8 @@ function requireNative() {
|
|
|
93
93
|
try {
|
|
94
94
|
const binding = require('@simular-ai/simulang-js-android-arm-eabi')
|
|
95
95
|
const bindingPackageVersion = require('@simular-ai/simulang-js-android-arm-eabi/package.json').version
|
|
96
|
-
if (bindingPackageVersion !== '
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
96
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
97
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
98
98
|
}
|
|
99
99
|
return binding
|
|
100
100
|
} catch (e) {
|
|
@@ -114,8 +114,8 @@ function requireNative() {
|
|
|
114
114
|
try {
|
|
115
115
|
const binding = require('@simular-ai/simulang-js-win32-x64-gnu')
|
|
116
116
|
const bindingPackageVersion = require('@simular-ai/simulang-js-win32-x64-gnu/package.json').version
|
|
117
|
-
if (bindingPackageVersion !== '
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
117
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
118
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
119
119
|
}
|
|
120
120
|
return binding
|
|
121
121
|
} catch (e) {
|
|
@@ -130,8 +130,8 @@ function requireNative() {
|
|
|
130
130
|
try {
|
|
131
131
|
const binding = require('@simular-ai/simulang-js-win32-x64-msvc')
|
|
132
132
|
const bindingPackageVersion = require('@simular-ai/simulang-js-win32-x64-msvc/package.json').version
|
|
133
|
-
if (bindingPackageVersion !== '
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
133
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
134
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
135
135
|
}
|
|
136
136
|
return binding
|
|
137
137
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('@simular-ai/simulang-js-win32-ia32-msvc')
|
|
149
149
|
const bindingPackageVersion = require('@simular-ai/simulang-js-win32-ia32-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
150
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -163,8 +163,8 @@ function requireNative() {
|
|
|
163
163
|
try {
|
|
164
164
|
const binding = require('@simular-ai/simulang-js-win32-arm64-msvc')
|
|
165
165
|
const bindingPackageVersion = require('@simular-ai/simulang-js-win32-arm64-msvc/package.json').version
|
|
166
|
-
if (bindingPackageVersion !== '
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
166
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
167
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
168
168
|
}
|
|
169
169
|
return binding
|
|
170
170
|
} catch (e) {
|
|
@@ -182,8 +182,8 @@ function requireNative() {
|
|
|
182
182
|
try {
|
|
183
183
|
const binding = require('@simular-ai/simulang-js-darwin-universal')
|
|
184
184
|
const bindingPackageVersion = require('@simular-ai/simulang-js-darwin-universal/package.json').version
|
|
185
|
-
if (bindingPackageVersion !== '
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
185
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
186
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
187
187
|
}
|
|
188
188
|
return binding
|
|
189
189
|
} catch (e) {
|
|
@@ -198,8 +198,8 @@ function requireNative() {
|
|
|
198
198
|
try {
|
|
199
199
|
const binding = require('@simular-ai/simulang-js-darwin-x64')
|
|
200
200
|
const bindingPackageVersion = require('@simular-ai/simulang-js-darwin-x64/package.json').version
|
|
201
|
-
if (bindingPackageVersion !== '
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
201
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
202
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
203
203
|
}
|
|
204
204
|
return binding
|
|
205
205
|
} catch (e) {
|
|
@@ -214,8 +214,8 @@ function requireNative() {
|
|
|
214
214
|
try {
|
|
215
215
|
const binding = require('@simular-ai/simulang-js-darwin-arm64')
|
|
216
216
|
const bindingPackageVersion = require('@simular-ai/simulang-js-darwin-arm64/package.json').version
|
|
217
|
-
if (bindingPackageVersion !== '
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
217
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
218
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
219
219
|
}
|
|
220
220
|
return binding
|
|
221
221
|
} catch (e) {
|
|
@@ -234,8 +234,8 @@ function requireNative() {
|
|
|
234
234
|
try {
|
|
235
235
|
const binding = require('@simular-ai/simulang-js-freebsd-x64')
|
|
236
236
|
const bindingPackageVersion = require('@simular-ai/simulang-js-freebsd-x64/package.json').version
|
|
237
|
-
if (bindingPackageVersion !== '
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
237
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
238
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
239
239
|
}
|
|
240
240
|
return binding
|
|
241
241
|
} catch (e) {
|
|
@@ -250,8 +250,8 @@ function requireNative() {
|
|
|
250
250
|
try {
|
|
251
251
|
const binding = require('@simular-ai/simulang-js-freebsd-arm64')
|
|
252
252
|
const bindingPackageVersion = require('@simular-ai/simulang-js-freebsd-arm64/package.json').version
|
|
253
|
-
if (bindingPackageVersion !== '
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
253
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
254
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
255
255
|
}
|
|
256
256
|
return binding
|
|
257
257
|
} catch (e) {
|
|
@@ -271,8 +271,8 @@ function requireNative() {
|
|
|
271
271
|
try {
|
|
272
272
|
const binding = require('@simular-ai/simulang-js-linux-x64-musl')
|
|
273
273
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-x64-musl/package.json').version
|
|
274
|
-
if (bindingPackageVersion !== '
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
274
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
275
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
276
276
|
}
|
|
277
277
|
return binding
|
|
278
278
|
} catch (e) {
|
|
@@ -287,8 +287,8 @@ function requireNative() {
|
|
|
287
287
|
try {
|
|
288
288
|
const binding = require('@simular-ai/simulang-js-linux-x64-gnu')
|
|
289
289
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-x64-gnu/package.json').version
|
|
290
|
-
if (bindingPackageVersion !== '
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
290
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
291
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
292
292
|
}
|
|
293
293
|
return binding
|
|
294
294
|
} catch (e) {
|
|
@@ -305,8 +305,8 @@ function requireNative() {
|
|
|
305
305
|
try {
|
|
306
306
|
const binding = require('@simular-ai/simulang-js-linux-arm64-musl')
|
|
307
307
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-arm64-musl/package.json').version
|
|
308
|
-
if (bindingPackageVersion !== '
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
308
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
309
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
310
310
|
}
|
|
311
311
|
return binding
|
|
312
312
|
} catch (e) {
|
|
@@ -321,8 +321,8 @@ function requireNative() {
|
|
|
321
321
|
try {
|
|
322
322
|
const binding = require('@simular-ai/simulang-js-linux-arm64-gnu')
|
|
323
323
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-arm64-gnu/package.json').version
|
|
324
|
-
if (bindingPackageVersion !== '
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
324
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
325
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
326
326
|
}
|
|
327
327
|
return binding
|
|
328
328
|
} catch (e) {
|
|
@@ -339,8 +339,8 @@ function requireNative() {
|
|
|
339
339
|
try {
|
|
340
340
|
const binding = require('@simular-ai/simulang-js-linux-arm-musleabihf')
|
|
341
341
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-arm-musleabihf/package.json').version
|
|
342
|
-
if (bindingPackageVersion !== '
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
342
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
343
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
344
344
|
}
|
|
345
345
|
return binding
|
|
346
346
|
} catch (e) {
|
|
@@ -355,8 +355,8 @@ function requireNative() {
|
|
|
355
355
|
try {
|
|
356
356
|
const binding = require('@simular-ai/simulang-js-linux-arm-gnueabihf')
|
|
357
357
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-arm-gnueabihf/package.json').version
|
|
358
|
-
if (bindingPackageVersion !== '
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
358
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
359
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
360
360
|
}
|
|
361
361
|
return binding
|
|
362
362
|
} catch (e) {
|
|
@@ -373,8 +373,8 @@ function requireNative() {
|
|
|
373
373
|
try {
|
|
374
374
|
const binding = require('@simular-ai/simulang-js-linux-loong64-musl')
|
|
375
375
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-loong64-musl/package.json').version
|
|
376
|
-
if (bindingPackageVersion !== '
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
376
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
377
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
378
378
|
}
|
|
379
379
|
return binding
|
|
380
380
|
} catch (e) {
|
|
@@ -389,8 +389,8 @@ function requireNative() {
|
|
|
389
389
|
try {
|
|
390
390
|
const binding = require('@simular-ai/simulang-js-linux-loong64-gnu')
|
|
391
391
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-loong64-gnu/package.json').version
|
|
392
|
-
if (bindingPackageVersion !== '
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
392
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
393
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
394
394
|
}
|
|
395
395
|
return binding
|
|
396
396
|
} catch (e) {
|
|
@@ -407,8 +407,8 @@ function requireNative() {
|
|
|
407
407
|
try {
|
|
408
408
|
const binding = require('@simular-ai/simulang-js-linux-riscv64-musl')
|
|
409
409
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-riscv64-musl/package.json').version
|
|
410
|
-
if (bindingPackageVersion !== '
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
410
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
411
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
412
412
|
}
|
|
413
413
|
return binding
|
|
414
414
|
} catch (e) {
|
|
@@ -423,8 +423,8 @@ function requireNative() {
|
|
|
423
423
|
try {
|
|
424
424
|
const binding = require('@simular-ai/simulang-js-linux-riscv64-gnu')
|
|
425
425
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-riscv64-gnu/package.json').version
|
|
426
|
-
if (bindingPackageVersion !== '
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
426
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
427
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
428
428
|
}
|
|
429
429
|
return binding
|
|
430
430
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('@simular-ai/simulang-js-linux-ppc64-gnu')
|
|
442
442
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-ppc64-gnu/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
443
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('@simular-ai/simulang-js-linux-s390x-gnu')
|
|
458
458
|
const bindingPackageVersion = require('@simular-ai/simulang-js-linux-s390x-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
459
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -476,8 +476,8 @@ function requireNative() {
|
|
|
476
476
|
try {
|
|
477
477
|
const binding = require('@simular-ai/simulang-js-openharmony-arm64')
|
|
478
478
|
const bindingPackageVersion = require('@simular-ai/simulang-js-openharmony-arm64/package.json').version
|
|
479
|
-
if (bindingPackageVersion !== '
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
479
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
480
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
481
481
|
}
|
|
482
482
|
return binding
|
|
483
483
|
} catch (e) {
|
|
@@ -492,8 +492,8 @@ function requireNative() {
|
|
|
492
492
|
try {
|
|
493
493
|
const binding = require('@simular-ai/simulang-js-openharmony-x64')
|
|
494
494
|
const bindingPackageVersion = require('@simular-ai/simulang-js-openharmony-x64/package.json').version
|
|
495
|
-
if (bindingPackageVersion !== '
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
495
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
496
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
497
497
|
}
|
|
498
498
|
return binding
|
|
499
499
|
} catch (e) {
|
|
@@ -508,8 +508,8 @@ function requireNative() {
|
|
|
508
508
|
try {
|
|
509
509
|
const binding = require('@simular-ai/simulang-js-openharmony-arm')
|
|
510
510
|
const bindingPackageVersion = require('@simular-ai/simulang-js-openharmony-arm/package.json').version
|
|
511
|
-
if (bindingPackageVersion !== '
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected
|
|
511
|
+
if (bindingPackageVersion !== '8.1.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
512
|
+
throw new Error(`Native binding package version mismatch, expected 8.1.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -525,23 +525,33 @@ function requireNative() {
|
|
|
525
525
|
|
|
526
526
|
nativeBinding = requireNative()
|
|
527
527
|
|
|
528
|
-
|
|
528
|
+
// NAPI_RS_FORCE_WASI is a tri-state flag:
|
|
529
|
+
// unset / any other value → native binding preferred, WASI is only a fallback
|
|
530
|
+
// 'true' → force WASI fallback even if native loaded
|
|
531
|
+
// 'error' → force WASI and throw if no WASI binding is found
|
|
532
|
+
// Treating any non-empty string as truthy (the historical behavior) meant
|
|
533
|
+
// NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
|
|
534
|
+
// the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
|
|
535
|
+
const forceWasi =
|
|
536
|
+
process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error'
|
|
537
|
+
|
|
538
|
+
if (!nativeBinding || forceWasi) {
|
|
529
539
|
let wasiBinding = null
|
|
530
540
|
let wasiBindingError = null
|
|
531
541
|
try {
|
|
532
542
|
wasiBinding = require('./simulang-js.wasi.cjs')
|
|
533
543
|
nativeBinding = wasiBinding
|
|
534
544
|
} catch (err) {
|
|
535
|
-
if (
|
|
545
|
+
if (forceWasi) {
|
|
536
546
|
wasiBindingError = err
|
|
537
547
|
}
|
|
538
548
|
}
|
|
539
|
-
if (!nativeBinding ||
|
|
549
|
+
if (!nativeBinding || forceWasi) {
|
|
540
550
|
try {
|
|
541
551
|
wasiBinding = require('@simular-ai/simulang-js-wasm32-wasi')
|
|
542
552
|
nativeBinding = wasiBinding
|
|
543
553
|
} catch (err) {
|
|
544
|
-
if (
|
|
554
|
+
if (forceWasi) {
|
|
545
555
|
if (!wasiBindingError) {
|
|
546
556
|
wasiBindingError = err
|
|
547
557
|
} else {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@simular-ai/simulang-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "Node.js bindings for simulang-rs",
|
|
5
5
|
"main": "wrapped.js",
|
|
6
6
|
"types": "./wrapped.d.ts",
|
|
@@ -82,21 +82,21 @@
|
|
|
82
82
|
"prepare": "husky"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
|
-
"@napi-rs/cli": "^3.
|
|
85
|
+
"@napi-rs/cli": "^3.7.2",
|
|
86
86
|
"@oxc-node/core": "^0.1.0",
|
|
87
87
|
"@taplo/cli": "^0.7.0",
|
|
88
|
-
"@types/node": "^25.
|
|
88
|
+
"@types/node": "^25.9.3",
|
|
89
89
|
"husky": "^9.1.7",
|
|
90
|
-
"lint-staged": "^17.0.
|
|
91
|
-
"npm-run-all2": "^
|
|
92
|
-
"oxlint": "^1.
|
|
93
|
-
"prettier": "^3.8.
|
|
90
|
+
"lint-staged": "^17.0.7",
|
|
91
|
+
"npm-run-all2": "^9.0.2",
|
|
92
|
+
"oxlint": "^1.70.0",
|
|
93
|
+
"prettier": "^3.8.4",
|
|
94
94
|
"tinybench": "^6.0.0",
|
|
95
95
|
"typedoc": "^0.28.19",
|
|
96
96
|
"typedoc-plugin-frontmatter": "^1.3.1",
|
|
97
|
-
"typedoc-plugin-markdown": "^4.
|
|
97
|
+
"typedoc-plugin-markdown": "^4.12.0",
|
|
98
98
|
"typescript": "^6.0.2",
|
|
99
|
-
"vitest": "^4.1.
|
|
99
|
+
"vitest": "^4.1.9"
|
|
100
100
|
},
|
|
101
101
|
"lint-staged": {
|
|
102
102
|
"*.@(js|ts|tsx)": [
|
|
@@ -117,11 +117,11 @@
|
|
|
117
117
|
"arrowParens": "always"
|
|
118
118
|
},
|
|
119
119
|
"optionalDependencies": {
|
|
120
|
-
"@simular-ai/simulang-js-win32-x64-msvc": "
|
|
121
|
-
"@simular-ai/simulang-js-win32-arm64-msvc": "
|
|
122
|
-
"@simular-ai/simulang-js-darwin-x64": "
|
|
123
|
-
"@simular-ai/simulang-js-darwin-arm64": "
|
|
124
|
-
"@simular-ai/simulang-js-linux-x64-gnu": "
|
|
125
|
-
"@simular-ai/simulang-js-linux-arm64-gnu": "
|
|
120
|
+
"@simular-ai/simulang-js-win32-x64-msvc": "8.1.0",
|
|
121
|
+
"@simular-ai/simulang-js-win32-arm64-msvc": "8.1.0",
|
|
122
|
+
"@simular-ai/simulang-js-darwin-x64": "8.1.0",
|
|
123
|
+
"@simular-ai/simulang-js-darwin-arm64": "8.1.0",
|
|
124
|
+
"@simular-ai/simulang-js-linux-x64-gnu": "8.1.0",
|
|
125
|
+
"@simular-ai/simulang-js-linux-arm64-gnu": "8.1.0"
|
|
126
126
|
}
|
|
127
127
|
}
|