@simular-ai/simulang-js 9.0.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/index.d.ts +166 -10
  3. package/index.js +55 -52
  4. package/package.json +10 -10
  5. package/sai.js +2 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [10.0.0] - 2026-07-03
11
+
12
+ ### Added
13
+
14
+ - `Window.focused()` — the window that currently has keyboard focus, or `null` when nothing is focused (no windows open, focus on the desktop, or the frontmost app has no focused window). The read-side counterpart to the instance method `Window.focus()`. Backed by `GetForegroundWindow` (Windows), the frontmost app's `AXFocusedWindow` (macOS), and `_NET_ACTIVE_WINDOW` (Linux); throws only on genuine backend failures.
15
+ - `ImageGenModel` for generating images from a text prompt through a provider's `image_gen` service. `generate(prompt, quality?, aspectRatio?, images?)` returns a `[image, description]` tuple — the generated `Image` and the model's text description. `quality` (`ImageQuality.Fast` / `.Pro`) and `aspectRatio` (`ImageAspectRatio.Square`, `.Landscape16x9`, …) are type-safe enums defaulting to `Fast` / `Square`. Optional reference images are downscaled / transcoded and size-checked against the model's configured limits before sending. Discover aliases with `ImageGenModel.availableAliases()`; the bundled `simular_cloud` provider advertises `simular_image_gen`.
16
+ - `Image.drawBox(bounds, thickness, red, green, blue)` and `Screenshot.drawBox(...)` — paint the outline of an axis-aligned `BoundingBox` (e.g. the result of `Window.boundingBox()` or `AccessibilityNode.boundingBox()`) with an inset border `thickness` pixels wide in an opaque RGB color. On `Image` the box is in image pixels; on `Screenshot` it is in **global desktop** coordinates (converted to image pixels internally), so a grounding or element box can be passed straight in. Out-of-bounds pixels are clipped; throws on zero thickness or a degenerate box (`right <= left` / `bottom <= top`). Companion to `drawDot` for annotating bounding boxes.
17
+
18
+ ### Breaking
19
+
20
+ - `Screenshot.drawDot(x, y, ...)` now interprets `(x, y)` as **global desktop** coordinates (the same space `Screenshot.ground` returns and `MouseController` consumes) rather than screenshot image pixels; the point is converted to image pixels internally, inverting the capture offset and any resampling. This lets a `Screenshot.ground` result or an element's `boundingBox()` corner be drawn without manual conversion. Update call sites that passed raw image-pixel coordinates to `Screenshot.drawDot` to pass global desktop coordinates instead. `Image.drawDot` is unchanged (still image pixels).
21
+
10
22
  ## [9.0.0] - 2026-06-29
11
23
 
12
24
  ### Added
package/index.d.ts CHANGED
@@ -644,6 +644,21 @@ export declare class Image {
644
644
  * captured rect.
645
645
  */
646
646
  drawDot(x: number, y: number, radius: number, red: number, green: number, blue: number): void
647
+ /**
648
+ * Draws the outline of the axis-aligned rectangle `bounds` on the image.
649
+ * Useful for visualizing bounding boxes returned from grounding, element /
650
+ * layout queries, ground-truth annotations, etc.
651
+ *
652
+ * `bounds` is in image-pixel coordinates and covers `[left, right) ×
653
+ * [top, bottom)` (`right` / `bottom` exclusive, matching a `BoundingBox`).
654
+ * The border is `thickness` pixels wide, drawn inset within that range so
655
+ * nothing is painted outside it, in the opaque RGB `(red, green, blue)`
656
+ * color. Pixels that fall outside the image bounds are silently clipped, so
657
+ * it is safe to call with a box that extends past the image. Throws when
658
+ * `thickness` is `0` or `bounds` is degenerate (`right <= left` or
659
+ * `bottom <= top`).
660
+ */
661
+ drawBox(bounds: BoundingBox, thickness: number, red: number, green: number, blue: number): void
647
662
  /**
648
663
  * Compress the image by converting it to JPEG with the specified quality.
649
664
  *
@@ -691,6 +706,79 @@ export declare class Image {
691
706
  ground(model: GroundingModel, concept: string): [number, number]
692
707
  }
693
708
 
709
+ /**
710
+ * A model for generating images from a text prompt (with optional reference
711
+ * images), speaking Simular's `v1/image-gen` wire contract.
712
+ *
713
+ * This targets a dedicated Simular endpoint rather than an `OpenAI`-compatible
714
+ * one; the endpoint picks the concrete backend model from the [`ImageQuality`]
715
+ * argument, so the resolved model `name` is nominal (used only for `name`).
716
+ * Reference images are downscaled / transcoded and size-checked against the
717
+ * model's configured image limits before sending, exactly as the VLM/LLM image
718
+ * paths do.
719
+ */
720
+ export declare class ImageGenModel {
721
+ /**
722
+ * First image-gen model advertised by the first capable provider in the
723
+ * loaded configuration whose credentials are currently available.
724
+ * Providers that advertise the service but lack working credentials are
725
+ * skipped. Throws only if no provider is left after that filter.
726
+ */
727
+ static default(): ImageGenModel
728
+ /**
729
+ * Resolve a model alias against the loaded configuration.
730
+ *
731
+ * The alias is looked up across every loaded provider in alphabetical
732
+ * order; the first provider that advertises this alias wins. Throws if the
733
+ * alias is unknown.
734
+ */
735
+ static byAlias(alias: string): ImageGenModel
736
+ /** Convenience shim for the bundled Simular image-gen alias. */
737
+ static simularImageGen(): ImageGenModel
738
+ /**
739
+ * Every image-gen model alias advertised by the loaded configuration,
740
+ * deduplicated and sorted alphabetically. Use to discover what `byAlias`
741
+ * will accept on the current machine.
742
+ */
743
+ static availableAliases(): Array<string>
744
+ /**
745
+ * The model identifier from provider configuration. Nominal — the
746
+ * endpoint selects the concrete model from the [`ImageQuality`] argument.
747
+ */
748
+ get name(): string
749
+ /**
750
+ * Check that provider credentials work. Throws (and logs a warning) if they
751
+ * do not.
752
+ *
753
+ * Call right after creating the model so a bad key fails fast:
754
+ *
755
+ * ```ts
756
+ * try { model.checkAuth() } catch { process.exit(1) }
757
+ * ```
758
+ */
759
+ checkAuth(): void
760
+ /**
761
+ * Generate an image from `prompt`.
762
+ *
763
+ * - `prompt`: a description of the image to generate.
764
+ * - `quality`: selects the model tier; defaults to `ImageQuality.Fast`.
765
+ * - `aspectRatio`: the output shape; defaults to `ImageAspectRatio.Square`.
766
+ * - `images`: reference images (count capped by the model's configured
767
+ * `max_images_per_request` image limit) that condition the result; each is
768
+ * downscaled / transcoded to a supported format and size-checked before
769
+ * sending. Pass `null` / omit for none.
770
+ *
771
+ * Returns a `[image, description]` tuple: the first generated [`Image`] and
772
+ * the model's text description (an empty string when the model returns none).
773
+ */
774
+ generate(
775
+ prompt: string,
776
+ quality?: ImageQuality | undefined | null,
777
+ aspectRatio?: ImageAspectRatio | undefined | null,
778
+ images?: Array<Image> | undefined | null,
779
+ ): [Image, string]
780
+ }
781
+
694
782
  /** Represents an opened application instance. */
695
783
  export declare class Instance {
696
784
  /** Get the process ID of the opened application (returns 0 when unknown). */
@@ -1124,20 +1212,39 @@ export declare class Screenshot {
1124
1212
  */
1125
1213
  drawGrid(width: number, height: number): void
1126
1214
  /**
1127
- * Paints a filled disc on the image. Useful for visualizing point
1128
- * coordinates returned from grounding, layout queries, etc.
1215
+ * Paints a filled disc on the screenshot. Useful for visualizing point
1216
+ * coordinates returned from grounding, element / layout queries, etc.
1129
1217
  *
1130
- * `x` / `y` are image-pixel coordinates of the disc's centre. `radius`
1131
- * is the disc radius in pixels (`0` paints a single pixel at the
1132
- * centre). `(red, green, blue)` is the fill color; alpha is always 255
1133
- * (opaque replacement of the underlying pixel).
1218
+ * `x` / `y` are **global desktop** coordinates (the same space
1219
+ * `Screenshot.ground` returns and `MouseController` consumes), which are
1220
+ * converted to image pixels inverting the capture offset and any
1221
+ * resampling before drawing. So a `ground(...)` result or an element's
1222
+ * `boundingBox()` corner can be passed straight in. `radius` is the disc
1223
+ * radius in pixels (`0` paints a single pixel at the centre).
1224
+ * `(red, green, blue)` is the fill color; alpha is always 255 (opaque
1225
+ * replacement of the underlying pixel).
1134
1226
  *
1135
- * Coordinates that fall outside the image bounds (negative, or past the
1136
- * width / height) silently produce no pixel, so the helper is safe to
1137
- * call with the raw output of a grounding model even at the edge of the
1138
- * captured rect.
1227
+ * Coordinates that map outside the image bounds silently produce no pixel,
1228
+ * so the helper is safe to call even for points that fall outside the
1229
+ * captured region.
1139
1230
  */
1140
1231
  drawDot(x: number, y: number, radius: number, red: number, green: number, blue: number): void
1232
+ /**
1233
+ * Draws the outline of the axis-aligned rectangle `bounds` on the
1234
+ * screenshot. Useful for visualizing bounding boxes returned from grounding,
1235
+ * element / window `boundingBox()` queries, ground-truth annotations, etc.
1236
+ *
1237
+ * `bounds` is in **global desktop** coordinates (the same space element /
1238
+ * window `boundingBox()` and grounding results use); its corners are
1239
+ * converted to image pixels — inverting the capture offset and any
1240
+ * resampling — before drawing, so an element's `boundingBox()` can be passed
1241
+ * straight in. It covers `[left, right) × [top, bottom)` (`right` / `bottom`
1242
+ * exclusive). The border is `thickness` pixels wide, drawn inset, in the
1243
+ * opaque RGB `(red, green, blue)` color. Pixels that map outside the image
1244
+ * bounds are silently clipped. Throws when `thickness` is `0` or `bounds` is
1245
+ * degenerate (`right <= left` or `bottom <= top`).
1246
+ */
1247
+ drawBox(bounds: BoundingBox, thickness: number, red: number, green: number, blue: number): void
1141
1248
  /**
1142
1249
  * Compress the image by converting it to JPEG with the specified quality.
1143
1250
  *
@@ -1341,6 +1448,24 @@ export declare class Window {
1341
1448
  * - **Linux**: always `null` (no per-point window hit-test).
1342
1449
  */
1343
1450
  static fromPoint(x: number, y: number): Window | null
1451
+ /**
1452
+ * The window that currently has keyboard focus, if any.
1453
+ *
1454
+ * Returns `null` when nothing is focused (e.g. no windows open, focus is on
1455
+ * the desktop, or the frontmost app has no focused window) rather than
1456
+ * treating that as an error. Throwing is reserved for genuine backend
1457
+ * failures.
1458
+ *
1459
+ * Platform notes:
1460
+ * - **Windows**: `GetForegroundWindow` — the top-level window of the
1461
+ * foreground thread. Never throws; `null` only when there is no
1462
+ * foreground window at all.
1463
+ * - **macOS**: the frontmost running application's `AXFocusedWindow`
1464
+ * attribute. `null` when there is no frontmost app, or the frontmost app
1465
+ * has no focused window (e.g. all its windows are minimized).
1466
+ * - **Linux**: EWMH `_NET_ACTIVE_WINDOW` root-window property.
1467
+ */
1468
+ static focused(): Window | null
1344
1469
  /** Window title (may be empty). */
1345
1470
  get title(): string
1346
1471
  /** Process ID that owns this window. */
@@ -1700,6 +1825,37 @@ export declare enum FocusPolicy {
1700
1825
 
1701
1826
  export declare function hasScreenCapturePermission(): boolean
1702
1827
 
1828
+ /** Aspect ratio of the generated image. */
1829
+ export declare enum ImageAspectRatio {
1830
+ /** `1:1` square. Default. */
1831
+ Square = 0,
1832
+ /** `16:9` widescreen landscape. */
1833
+ Landscape16x9 = 1,
1834
+ /** `9:16` tall portrait. */
1835
+ Portrait9x16 = 2,
1836
+ /** `4:3` landscape. */
1837
+ Landscape4x3 = 3,
1838
+ /** `3:4` portrait. */
1839
+ Portrait3x4 = 4,
1840
+ /** `3:2` landscape. */
1841
+ Landscape3x2 = 5,
1842
+ /** `2:3` portrait. */
1843
+ Portrait2x3 = 6,
1844
+ }
1845
+
1846
+ /**
1847
+ * Output image quality / model tier for [`ImageGenModel.generate`].
1848
+ *
1849
+ * The image-gen endpoint selects the underlying model from this value, so it
1850
+ * is a per-request parameter rather than a config-resolved model name.
1851
+ */
1852
+ export declare enum ImageQuality {
1853
+ /** Faster, cheaper tier. Default. */
1854
+ Fast = 0,
1855
+ /** Higher-fidelity tier. */
1856
+ Pro = 1,
1857
+ }
1858
+
1703
1859
  /**
1704
1860
  * Initialize the logger.
1705
1861
  *
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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '10.0.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 10.0.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 !== '9.0.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 9.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '10.0.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 10.0.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -596,6 +596,7 @@ module.exports.Directory = nativeBinding.Directory
596
596
  module.exports.File = nativeBinding.File
597
597
  module.exports.GroundingModel = nativeBinding.GroundingModel
598
598
  module.exports.Image = nativeBinding.Image
599
+ module.exports.ImageGenModel = nativeBinding.ImageGenModel
599
600
  module.exports.Instance = nativeBinding.Instance
600
601
  module.exports.KeyboardController = nativeBinding.KeyboardController
601
602
  module.exports.LoopbackSource = nativeBinding.LoopbackSource
@@ -617,6 +618,8 @@ module.exports.Direction = nativeBinding.Direction
617
618
  module.exports.enableAccessibilityForFrontmostApp = nativeBinding.enableAccessibilityForFrontmostApp
618
619
  module.exports.FocusPolicy = nativeBinding.FocusPolicy
619
620
  module.exports.hasScreenCapturePermission = nativeBinding.hasScreenCapturePermission
621
+ module.exports.ImageAspectRatio = nativeBinding.ImageAspectRatio
622
+ module.exports.ImageQuality = nativeBinding.ImageQuality
620
623
  module.exports.initLogger = nativeBinding.initLogger
621
624
  module.exports.Key = nativeBinding.Key
622
625
  module.exports.keyFromString = nativeBinding.keyFromString
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simular-ai/simulang-js",
3
- "version": "9.0.0",
3
+ "version": "10.0.0",
4
4
  "description": "Node.js bindings for simulang-rs",
5
5
  "main": "wrapped.js",
6
6
  "types": "./wrapped.d.ts",
@@ -91,11 +91,11 @@
91
91
  "@napi-rs/cli": "^3.7.2",
92
92
  "@oxc-node/core": "^0.1.0",
93
93
  "@taplo/cli": "^0.7.0",
94
- "@types/node": "^26.0.0",
94
+ "@types/node": "^26.0.1",
95
95
  "husky": "^9.1.7",
96
96
  "lint-staged": "^17.0.8",
97
97
  "npm-run-all2": "^9.0.2",
98
- "oxlint": "^1.70.0",
98
+ "oxlint": "^1.71.0",
99
99
  "prettier": "^3.8.4",
100
100
  "tinybench": "^6.0.0",
101
101
  "typedoc": "^0.28.19",
@@ -105,7 +105,7 @@
105
105
  "vitest": "^4.1.9"
106
106
  },
107
107
  "lint-staged": {
108
- "*.@(js|ts|tsx)": [
108
+ "*.@(js|mjs|cjs|ts|tsx)": [
109
109
  "oxlint --fix"
110
110
  ],
111
111
  "*.@(js|ts|tsx|yml|yaml|md|json)": [
@@ -123,11 +123,11 @@
123
123
  "arrowParens": "always"
124
124
  },
125
125
  "optionalDependencies": {
126
- "@simular-ai/simulang-js-win32-x64-msvc": "9.0.0",
127
- "@simular-ai/simulang-js-win32-arm64-msvc": "9.0.0",
128
- "@simular-ai/simulang-js-darwin-x64": "9.0.0",
129
- "@simular-ai/simulang-js-darwin-arm64": "9.0.0",
130
- "@simular-ai/simulang-js-linux-x64-gnu": "9.0.0",
131
- "@simular-ai/simulang-js-linux-arm64-gnu": "9.0.0"
126
+ "@simular-ai/simulang-js-win32-x64-msvc": "10.0.0",
127
+ "@simular-ai/simulang-js-win32-arm64-msvc": "10.0.0",
128
+ "@simular-ai/simulang-js-darwin-x64": "10.0.0",
129
+ "@simular-ai/simulang-js-darwin-arm64": "10.0.0",
130
+ "@simular-ai/simulang-js-linux-x64-gnu": "10.0.0",
131
+ "@simular-ai/simulang-js-linux-arm64-gnu": "10.0.0"
132
132
  }
133
133
  }
package/sai.js CHANGED
@@ -589,7 +589,7 @@ function readFile(params) {
589
589
 
590
590
  function writeToFile(params) {
591
591
  const { text, path = 'SimularActionResult.txt', overwrite = false } = params
592
- const append = overwrite ? false : true
592
+ const append = !overwrite
593
593
  return binding().writeFile(path, text, append)
594
594
  }
595
595
 
@@ -630,7 +630,7 @@ function stateSatisfies(params) {
630
630
  const { text, imageBase64 } = pageContent()
631
631
  return StateSatisfiesModel.default().stateSatisfies(condition, text, imageBase64)
632
632
  } catch (error) {
633
- throw new Error(`Failed to check state condition: ${error}`)
633
+ throw new Error(`Failed to check state condition: ${error}`, { cause: error })
634
634
  }
635
635
  }
636
636