@tasker-systems/tasker 0.1.2 → 0.1.4

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
@@ -1,6 +1,6 @@
1
1
  # @tasker-systems/tasker
2
2
 
3
- TypeScript worker for the Tasker workflow orchestration system. Supports Bun (native FFI), Node.js (via koffi), and Deno runtimes.
3
+ TypeScript worker for the Tasker workflow orchestration system. Supports Bun, Node.js (both via koffi/Node-API), and Deno runtimes.
4
4
 
5
5
  ## Status
6
6
 
@@ -9,10 +9,10 @@ Production ready. TypeScript worker bindings provide full step handler execution
9
9
  ## Installation
10
10
 
11
11
  ```bash
12
- # Bun (recommended - native FFI support)
13
- bun add @tasker-systems/tasker
12
+ # Bun (recommended)
13
+ bun add @tasker-systems/tasker koffi
14
14
 
15
- # Node.js (requires koffi for FFI)
15
+ # Node.js
16
16
  npm install @tasker-systems/tasker koffi
17
17
  ```
18
18
 
@@ -97,7 +97,7 @@ workers/typescript/
97
97
 
98
98
  ## Technology Stack
99
99
 
100
- - **FFI Layer**: Bun native FFI / koffi (Node.js)
100
+ - **FFI Layer**: koffi (Node-API, works with both Bun and Node.js)
101
101
  - **Build Tool**: tsup
102
102
  - **Runtime**: Bun, Node.js 18+, or Deno
103
103
  - **Testing**: Bun test runner
@@ -109,8 +109,8 @@ workers/typescript/
109
109
 
110
110
  | Runtime | FFI Mechanism | Status |
111
111
  |---------|---------------|--------|
112
- | Bun | Native `bun:ffi` | Recommended |
113
- | Node.js | koffi | Supported |
112
+ | Bun | koffi (Node-API) | Recommended |
113
+ | Node.js | koffi (Node-API) | Supported |
114
114
  | Deno | `Deno.dlopen` | Experimental |
115
115
 
116
116
  ## License
@@ -60,10 +60,12 @@ declare function getLibraryPath(basePath?: string): string;
60
60
  * FfiLayer - Owns FFI runtime loading and lifecycle.
61
61
  *
62
62
  * This class encapsulates the FFI runtime management:
63
- * - Runtime detection (Bun, Node.js, Deno)
63
+ * - Runtime detection (Node.js, Bun, Deno)
64
64
  * - Library path discovery
65
65
  * - Runtime loading and unloading
66
66
  *
67
+ * Both Node.js and Bun use koffi (Node-API) for stable FFI.
68
+ *
67
69
  * Design principles:
68
70
  * - Explicit construction: No singleton pattern
69
71
  * - Clear ownership: Owns the runtime instance
@@ -146,9 +148,9 @@ declare class FfiLayer {
146
148
  * Static method for finding the library path without creating an instance.
147
149
  * Useful for test utilities and pre-flight checks.
148
150
  *
149
- * REQUIRES: TASKER_FFI_LIBRARY_PATH environment variable to be set.
150
- * This explicit requirement prevents confusion from automatic debug/release
151
- * library discovery and ensures intentional configuration at build/runtime.
151
+ * Resolution order:
152
+ * 1. TASKER_FFI_LIBRARY_PATH environment variable (explicit override)
153
+ * 2. Bundled native library in the package's native/ directory
152
154
  *
153
155
  * @param _callerDir Deprecated parameter, kept for API compatibility
154
156
  * @returns Path to the library if found and exists, null otherwise
@@ -163,40 +165,37 @@ declare class FfiLayer {
163
165
  /**
164
166
  * Create a runtime adapter for the configured runtime type.
165
167
  *
166
- * NOTE: We use koffi (NodeRuntime) for both Node.js and Bun because:
167
- * - bun:ffi is experimental with known bugs (per Bun docs)
168
- * - koffi is stable and works with both Node.js and Bun via Node-API
169
- * - See: https://bun.sh/docs/runtime/node-api
168
+ * NOTE: We use koffi (NodeRuntime) for both Node.js and Bun.
169
+ * koffi is stable and works with both runtimes via Node-API.
170
+ * See: https://bun.sh/docs/runtime/node-api
170
171
  */
171
172
  private createRuntime;
172
173
  }
173
174
 
174
175
  /**
175
- * Node.js FFI runtime adapter using koffi.
176
- *
177
- * This adapter uses the koffi package to interface with the Rust native library.
178
- * Koffi is a modern, actively maintained FFI library with prebuilt binaries.
176
+ * Deno FFI runtime adapter using Deno.dlopen.
179
177
  *
180
- * Install: npm install koffi
178
+ * This adapter uses Deno's built-in FFI to interface with the Rust native library.
179
+ * It requires --unstable-ffi and --allow-ffi flags.
181
180
  */
182
181
 
183
182
  /**
184
- * Node.js FFI runtime implementation using koffi
183
+ * Deno FFI runtime implementation using Deno.dlopen
185
184
  */
186
- declare class NodeRuntime extends BaseTaskerRuntime {
187
- readonly name: string;
185
+ declare class DenoRuntime extends BaseTaskerRuntime {
186
+ readonly name = "deno";
188
187
  private lib;
189
- private koffi;
188
+ private encoder;
190
189
  get isLoaded(): boolean;
191
190
  load(libraryPath: string): Promise<void>;
192
191
  unload(): void;
193
192
  private ensureLoaded;
194
193
  /**
195
- * Read a C string from a pointer and free the Rust-allocated memory.
196
- *
197
- * Uses koffi.decode with 'char' type and -1 length for null-terminated strings.
194
+ * Creates a null-terminated C string buffer.
195
+ * With 'buffer' FFI type, we return Uint8Array directly.
198
196
  */
199
- private readAndFreeRustString;
197
+ private toCString;
198
+ private fromCString;
200
199
  getVersion(): string;
201
200
  getRustVersion(): string;
202
201
  healthCheck(): boolean;
@@ -229,51 +228,31 @@ declare class NodeRuntime extends BaseTaskerRuntime {
229
228
  }
230
229
 
231
230
  /**
232
- * Bun FFI runtime adapter using koffi (via Node-API).
233
- *
234
- * Bun supports Node-API modules natively, so we use koffi (the same FFI
235
- * library as NodeRuntime) rather than bun:ffi. This gives us:
236
- * - Stable, well-tested string/pointer handling
237
- * - Identical behavior across Node.js and Bun
238
- * - No manual Buffer→pointer conversion bugs
239
- *
240
- * See: https://bun.sh/docs/runtime/node-api
241
- */
242
-
243
- /**
244
- * Bun FFI runtime implementation using koffi (Node-API).
231
+ * Node.js FFI runtime adapter using koffi.
245
232
  *
246
- * Extends NodeRuntime since both use koffi for FFI. The only difference
247
- * is the runtime name identifier used for logging and diagnostics.
248
- */
249
- declare class BunRuntime extends NodeRuntime {
250
- readonly name = "bun";
251
- }
252
-
253
- /**
254
- * Deno FFI runtime adapter using Deno.dlopen.
233
+ * This adapter uses the koffi package to interface with the Rust native library.
234
+ * Koffi is a modern, actively maintained FFI library with prebuilt binaries.
255
235
  *
256
- * This adapter uses Deno's built-in FFI to interface with the Rust native library.
257
- * It requires --unstable-ffi and --allow-ffi flags.
236
+ * Install: npm install koffi
258
237
  */
259
238
 
260
239
  /**
261
- * Deno FFI runtime implementation using Deno.dlopen
240
+ * Node.js FFI runtime implementation using koffi
262
241
  */
263
- declare class DenoRuntime extends BaseTaskerRuntime {
264
- readonly name = "deno";
242
+ declare class NodeRuntime extends BaseTaskerRuntime {
243
+ readonly name: string;
265
244
  private lib;
266
- private encoder;
245
+ private koffi;
267
246
  get isLoaded(): boolean;
268
247
  load(libraryPath: string): Promise<void>;
269
248
  unload(): void;
270
249
  private ensureLoaded;
271
250
  /**
272
- * Creates a null-terminated C string buffer.
273
- * With 'buffer' FFI type, we return Uint8Array directly.
251
+ * Read a C string from a pointer and free the Rust-allocated memory.
252
+ *
253
+ * Uses koffi.decode with 'char' type and -1 length for null-terminated strings.
274
254
  */
275
- private toCString;
276
- private fromCString;
255
+ private readAndFreeRustString;
277
256
  getVersion(): string;
278
257
  getRustVersion(): string;
279
258
  healthCheck(): boolean;
@@ -305,4 +284,4 @@ declare class DenoRuntime extends BaseTaskerRuntime {
305
284
  clientHealthCheck(): ClientResult;
306
285
  }
307
286
 
308
- export { BaseTaskerRuntime, BootstrapConfig, BootstrapResult, BunRuntime, DenoRuntime, FfiDispatchMetrics, FfiDomainEvent, FfiLayer, type FfiLayerConfig, FfiStepEvent, LogFields, NodeRuntime, type RuntimeInfo, type RuntimeType, StepExecutionResult, StopResult, TaskerRuntime, WorkerStatus, detectRuntime, getLibraryPath, getRuntimeInfo, isBun, isDeno, isNode };
287
+ export { BaseTaskerRuntime, BootstrapConfig, BootstrapResult, DenoRuntime, FfiDispatchMetrics, FfiDomainEvent, FfiLayer, type FfiLayerConfig, FfiStepEvent, LogFields, NodeRuntime, type RuntimeInfo, type RuntimeType, StepExecutionResult, StopResult, TaskerRuntime, WorkerStatus, detectRuntime, getLibraryPath, getRuntimeInfo, isBun, isDeno, isNode };