wstp-node 0.7.3 → 1.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.
package/README.md CHANGED
@@ -496,13 +496,36 @@ immediately with `"Session is closed"`.
496
496
 
497
497
  ---
498
498
 
499
- ### `isOpen` / `isDialogOpen`
499
+ ### `isOpen` / `isDialogOpen` / `kernelState`
500
500
 
501
501
  ```ts
502
502
  session.isOpen: boolean // true while the link is open and the kernel is running
503
503
  session.isDialogOpen: boolean // true while inside a Dialog[] subsession
504
+ session.kernelState: string // multi-dimensional state snapshot
504
505
  ```
505
506
 
507
+ `kernelState` returns a space-separated `dimension=value` string covering five
508
+ independent state dimensions that can be active in parallel:
509
+
510
+ | Dimension | Values | Description |
511
+ |------------|---------------------------------------|-------------|
512
+ | `activity` | `Idle`, `Eval`, `SubIdle`, `WhenIdle` | Main job the kernel is doing |
513
+ | `dialog` | `None`, `UserDialog`, `DynDialog` | Dialog subsession type |
514
+ | `sub` | `None`, `DynExpr`, `SubBusy` | Sub-work inside a dialog |
515
+ | `abort` | `None`, `Aborting` | Abort in progress |
516
+ | `link` | `Alive`, `Dead` | WSTP link health |
517
+
518
+ Example:
519
+ ```ts
520
+ console.log(session.kernelState);
521
+ // "activity=Eval dialog=DynDialog sub=DynExpr abort=None link=Alive"
522
+ ```
523
+
524
+ Every transition is logged via `setDiagHandler` with a `[State:<dim>]` category
525
+ tag (e.g. `[State:activity] Idle -> Eval (MaybeStartNext:eval)`). Internal
526
+ safeguards use these dimensions to prevent dangerous operations — e.g. blocking
527
+ `WSInterruptMessage` when the link is dead or an abort is already in progress.
528
+
506
529
  ---
507
530
 
508
531
  ### Dynamic eval API
Binary file
package/index.d.ts CHANGED
@@ -295,6 +295,28 @@ export class WstpSession {
295
295
  */
296
296
  readonly kernelPid: number;
297
297
 
298
+ /**
299
+ * Multi-dimensional kernel state snapshot as a human-readable string.
300
+ *
301
+ * Returns a space-separated list of `dimension=value` pairs covering
302
+ * five independent state dimensions:
303
+ *
304
+ * | Dimension | Values |
305
+ * |------------|-----------------------------------------------|
306
+ * | `activity` | `Idle`, `Eval`, `SubIdle`, `WhenIdle` |
307
+ * | `dialog` | `None`, `UserDialog`, `DynDialog` |
308
+ * | `sub` | `None`, `DynExpr`, `SubBusy` |
309
+ * | `abort` | `None`, `Aborting` |
310
+ * | `link` | `Alive`, `Dead` |
311
+ *
312
+ * Example: `"activity=Eval dialog=DynDialog sub=DynExpr abort=None link=Alive"`
313
+ *
314
+ * Dimensions are independent — e.g. `activity=Eval` and `dialog=DynDialog`
315
+ * can be active simultaneously. Every transition is logged via `setDiagHandler`
316
+ * with the `[State:<dim>]` category tag.
317
+ */
318
+ readonly kernelState: string;
319
+
298
320
  // ── Dynamic eval API ────────────────────────────────────────────────────
299
321
 
300
322
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wstp-node",
3
- "version": "0.7.3",
3
+ "version": "1.0.0",
4
4
  "description": "Native Node.js addon for Wolfram/Mathematica WSTP — kernel sessions with evaluation queue, streaming Print/messages, Dialog subsessions, and side-channel WstpReader",
5
5
  "main": "build/Release/wstp.node",
6
6
  "types": "index.d.ts",
package/src/addon.cc CHANGED
@@ -1,5 +1,5 @@
1
1
  // =============================================================================
2
- // wstp-backend/src/addon.cc (v0.7.2 — thin entry point after refactor)
2
+ // wstp-backend/src/addon.cc (v1.0.0 — thin entry point after refactor)
3
3
  //
4
4
  // This file is intentionally minimal. All implementation lives in the
5
5
  // other source files listed in binding.gyp:
@@ -47,7 +47,7 @@ Napi::Object InitModule(Napi::Env env, Napi::Object exports) {
47
47
  WstpReader::Init(env, exports);
48
48
  exports.Set("setDiagHandler",
49
49
  Napi::Function::New(env, SetDiagHandler, "setDiagHandler"));
50
- exports.Set("version", Napi::String::New(env, "0.7.2"));
50
+ exports.Set("version", Napi::String::New(env, "1.0.0"));
51
51
  return exports;
52
52
  }
53
53