@tasker-systems/tasker 0.1.1 → 0.1.2

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 ADDED
@@ -0,0 +1,118 @@
1
+ # @tasker-systems/tasker
2
+
3
+ TypeScript worker for the Tasker workflow orchestration system. Supports Bun (native FFI), Node.js (via koffi), and Deno runtimes.
4
+
5
+ ## Status
6
+
7
+ Production ready. TypeScript worker bindings provide full step handler execution via FFI to the shared Rust `tasker-worker` infrastructure.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ # Bun (recommended - native FFI support)
13
+ bun add @tasker-systems/tasker
14
+
15
+ # Node.js (requires koffi for FFI)
16
+ npm install @tasker-systems/tasker koffi
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```typescript
22
+ import { TaskerWorker } from "@tasker-systems/tasker";
23
+
24
+ const worker = new TaskerWorker({
25
+ workerName: "my-worker",
26
+ namespaces: ["default"],
27
+ });
28
+
29
+ // Register a step handler
30
+ worker.registerHandler("process_payment", async (step) => {
31
+ const result = await processPayment(step.context);
32
+ return { status: "complete", data: result };
33
+ });
34
+
35
+ // Start the worker
36
+ await worker.start();
37
+ ```
38
+
39
+ ## Development
40
+
41
+ ### Prerequisites
42
+
43
+ - Bun 1.0+ (recommended) or Node.js 18+
44
+ - Rust 1.70+ (for building the FFI library)
45
+
46
+ ### Setup
47
+
48
+ ```bash
49
+ # Install dependencies
50
+ bun install
51
+
52
+ # Build TypeScript
53
+ bun run build
54
+
55
+ # Run tests
56
+ bun test
57
+
58
+ # Type checking
59
+ bun run typecheck
60
+
61
+ # Linting
62
+ bun run check
63
+ ```
64
+
65
+ ### Building the FFI Library
66
+
67
+ ```bash
68
+ # Build the Rust FFI shared library
69
+ cargo build --release -p tasker-worker-ts
70
+
71
+ # The library will be at target/release/libtasker_worker_ts.{dylib,so,dll}
72
+ ```
73
+
74
+ ## Project Structure
75
+
76
+ ```
77
+ workers/typescript/
78
+ ├── src/ # TypeScript source
79
+ │ ├── bootstrap/ # Worker initialization
80
+ │ ├── events/ # Event system integration
81
+ │ ├── ffi/ # FFI bindings to Rust
82
+ │ ├── handler/ # Step handler base classes
83
+ │ ├── logging/ # Structured logging (pino)
84
+ │ ├── registry/ # Handler registry
85
+ │ ├── server/ # HTTP/gRPC server
86
+ │ ├── subscriber/ # Queue subscriber
87
+ │ ├── types/ # Type definitions
88
+ │ └── index.ts # Package entry point
89
+ ├── src-rust/ # Rust FFI source
90
+ │ └── lib.rs # Neon/FFI module
91
+ ├── tests/ # Test suite
92
+ ├── Cargo.toml # Rust crate configuration
93
+ ├── package.json # npm package configuration
94
+ ├── tsconfig.json # TypeScript configuration
95
+ └── biome.json # Linting configuration
96
+ ```
97
+
98
+ ## Technology Stack
99
+
100
+ - **FFI Layer**: Bun native FFI / koffi (Node.js)
101
+ - **Build Tool**: tsup
102
+ - **Runtime**: Bun, Node.js 18+, or Deno
103
+ - **Testing**: Bun test runner
104
+ - **Linting**: Biome
105
+ - **Logging**: pino
106
+ - **Events**: eventemitter3
107
+
108
+ ## Runtime Support
109
+
110
+ | Runtime | FFI Mechanism | Status |
111
+ |---------|---------------|--------|
112
+ | Bun | Native `bun:ffi` | Recommended |
113
+ | Node.js | koffi | Supported |
114
+ | Deno | `Deno.dlopen` | Experimental |
115
+
116
+ ## License
117
+
118
+ MIT
@@ -1,3 +1,3 @@
1
- export { y as ErrorCallback, n as EventName, o as EventNames, d as EventPoller, z as EventPollerConfig, f as EventSystem, F as EventSystemConfig, G as EventSystemStats, A as MetricsCallback, p as MetricsEventName, q as MetricsEventNames, M as MetricsPayload, P as PollerCyclePayload, r as PollerEventName, s as PollerEventNames, C as PollerState, g as StepCompletionSentPayload, D as StepEventCallback, t as StepEventName, u as StepEventNames, h as StepExecutionCompletedPayload, i as StepExecutionFailedPayload, j as StepExecutionReceivedPayload, k as StepExecutionStartedPayload, T as TaskerEventEmitter, l as TaskerEventMap, W as WorkerErrorPayload, v as WorkerEventName, w as WorkerEventNames, m as WorkerEventPayload, x as createEventPoller } from '../index-B3BcknlZ.js';
1
+ export { y as ErrorCallback, n as EventName, o as EventNames, d as EventPoller, z as EventPollerConfig, f as EventSystem, F as EventSystemConfig, G as EventSystemStats, A as MetricsCallback, p as MetricsEventName, q as MetricsEventNames, M as MetricsPayload, P as PollerCyclePayload, r as PollerEventName, s as PollerEventNames, C as PollerState, g as StepCompletionSentPayload, D as StepEventCallback, t as StepEventName, u as StepEventNames, h as StepExecutionCompletedPayload, i as StepExecutionFailedPayload, j as StepExecutionReceivedPayload, k as StepExecutionStartedPayload, T as TaskerEventEmitter, l as TaskerEventMap, W as WorkerErrorPayload, v as WorkerEventName, w as WorkerEventNames, m as WorkerEventPayload, x as createEventPoller } from '../index-CTl8lGpU.js';
2
2
  import 'eventemitter3';
3
- import '../runtime-interface-CE4viUt7.js';
3
+ import '../runtime-interface-D940vUzy.js';
@@ -1,139 +1,5 @@
1
- import { B as BaseTaskerRuntime, a as BootstrapConfig, b as BootstrapResult, W as WorkerStatus, q as StopResult, l as FfiStepEvent, F as FfiDomainEvent, p as StepExecutionResult, t as CheckpointYieldData, k as FfiDispatchMetrics, L as LogFields, d as ClientResult, T as TaskerRuntime } from '../runtime-interface-CE4viUt7.js';
2
- export { D as DependencyResult, u as FfiDomainEventMetadata, m as HandlerDefinition, O as OrchestrationMetadata, R as RetryConfiguration, S as StepDefinition, n as StepExecutionError, o as StepExecutionMetadata, r as Task, s as WorkflowStep } from '../runtime-interface-CE4viUt7.js';
3
-
4
- /**
5
- * Node.js FFI runtime adapter using koffi.
6
- *
7
- * This adapter uses the koffi package to interface with the Rust native library.
8
- * Koffi is a modern, actively maintained FFI library with prebuilt binaries.
9
- *
10
- * Install: npm install koffi
11
- */
12
-
13
- /**
14
- * Node.js FFI runtime implementation using koffi
15
- */
16
- declare class NodeRuntime extends BaseTaskerRuntime {
17
- readonly name: string;
18
- private lib;
19
- private koffi;
20
- get isLoaded(): boolean;
21
- load(libraryPath: string): Promise<void>;
22
- unload(): void;
23
- private ensureLoaded;
24
- /**
25
- * Read a C string from a pointer and free the Rust-allocated memory.
26
- *
27
- * Uses koffi.decode with 'char' type and -1 length for null-terminated strings.
28
- */
29
- private readAndFreeRustString;
30
- getVersion(): string;
31
- getRustVersion(): string;
32
- healthCheck(): boolean;
33
- bootstrapWorker(config?: BootstrapConfig): BootstrapResult;
34
- isWorkerRunning(): boolean;
35
- getWorkerStatus(): WorkerStatus;
36
- stopWorker(): StopResult;
37
- transitionToGracefulShutdown(): StopResult;
38
- pollStepEvents(): FfiStepEvent | null;
39
- pollInProcessEvents(): FfiDomainEvent | null;
40
- completeStepEvent(eventId: string, result: StepExecutionResult): boolean;
41
- checkpointYieldStepEvent(eventId: string, checkpointData: CheckpointYieldData): boolean;
42
- getFfiDispatchMetrics(): FfiDispatchMetrics;
43
- checkStarvationWarnings(): void;
44
- cleanupTimeouts(): void;
45
- logError(message: string, fields?: LogFields): void;
46
- logWarn(message: string, fields?: LogFields): void;
47
- logInfo(message: string, fields?: LogFields): void;
48
- logDebug(message: string, fields?: LogFields): void;
49
- logTrace(message: string, fields?: LogFields): void;
50
- private parseClientResult;
51
- clientCreateTask(requestJson: string): ClientResult;
52
- clientGetTask(taskUuid: string): ClientResult;
53
- clientListTasks(paramsJson: string): ClientResult;
54
- clientCancelTask(taskUuid: string): ClientResult;
55
- clientListTaskSteps(taskUuid: string): ClientResult;
56
- clientGetStep(taskUuid: string, stepUuid: string): ClientResult;
57
- clientGetStepAuditHistory(taskUuid: string, stepUuid: string): ClientResult;
58
- clientHealthCheck(): ClientResult;
59
- }
60
-
61
- /**
62
- * Bun FFI runtime adapter using koffi (via Node-API).
63
- *
64
- * Bun supports Node-API modules natively, so we use koffi (the same FFI
65
- * library as NodeRuntime) rather than bun:ffi. This gives us:
66
- * - Stable, well-tested string/pointer handling
67
- * - Identical behavior across Node.js and Bun
68
- * - No manual Buffer→pointer conversion bugs
69
- *
70
- * See: https://bun.sh/docs/runtime/node-api
71
- */
72
-
73
- /**
74
- * Bun FFI runtime implementation using koffi (Node-API).
75
- *
76
- * Extends NodeRuntime since both use koffi for FFI. The only difference
77
- * is the runtime name identifier used for logging and diagnostics.
78
- */
79
- declare class BunRuntime extends NodeRuntime {
80
- readonly name = "bun";
81
- }
82
-
83
- /**
84
- * Deno FFI runtime adapter using Deno.dlopen.
85
- *
86
- * This adapter uses Deno's built-in FFI to interface with the Rust native library.
87
- * It requires --unstable-ffi and --allow-ffi flags.
88
- */
89
-
90
- /**
91
- * Deno FFI runtime implementation using Deno.dlopen
92
- */
93
- declare class DenoRuntime extends BaseTaskerRuntime {
94
- readonly name = "deno";
95
- private lib;
96
- private encoder;
97
- get isLoaded(): boolean;
98
- load(libraryPath: string): Promise<void>;
99
- unload(): void;
100
- private ensureLoaded;
101
- /**
102
- * Creates a null-terminated C string buffer.
103
- * With 'buffer' FFI type, we return Uint8Array directly.
104
- */
105
- private toCString;
106
- private fromCString;
107
- getVersion(): string;
108
- getRustVersion(): string;
109
- healthCheck(): boolean;
110
- bootstrapWorker(config?: BootstrapConfig): BootstrapResult;
111
- isWorkerRunning(): boolean;
112
- getWorkerStatus(): WorkerStatus;
113
- stopWorker(): StopResult;
114
- transitionToGracefulShutdown(): StopResult;
115
- pollStepEvents(): FfiStepEvent | null;
116
- pollInProcessEvents(): FfiDomainEvent | null;
117
- completeStepEvent(eventId: string, result: StepExecutionResult): boolean;
118
- checkpointYieldStepEvent(eventId: string, checkpointData: CheckpointYieldData): boolean;
119
- getFfiDispatchMetrics(): FfiDispatchMetrics;
120
- checkStarvationWarnings(): void;
121
- cleanupTimeouts(): void;
122
- logError(message: string, fields?: LogFields): void;
123
- logWarn(message: string, fields?: LogFields): void;
124
- logInfo(message: string, fields?: LogFields): void;
125
- logDebug(message: string, fields?: LogFields): void;
126
- logTrace(message: string, fields?: LogFields): void;
127
- private parseClientResult;
128
- clientCreateTask(requestJson: string): ClientResult;
129
- clientGetTask(taskUuid: string): ClientResult;
130
- clientListTasks(paramsJson: string): ClientResult;
131
- clientCancelTask(taskUuid: string): ClientResult;
132
- clientListTaskSteps(taskUuid: string): ClientResult;
133
- clientGetStep(taskUuid: string, stepUuid: string): ClientResult;
134
- clientGetStepAuditHistory(taskUuid: string, stepUuid: string): ClientResult;
135
- clientHealthCheck(): ClientResult;
136
- }
1
+ import { T as TaskerRuntime, B as BaseTaskerRuntime, e as BootstrapConfig, f as BootstrapResult, W as WorkerStatus, q as StopResult, l as FfiStepEvent, F as FfiDomainEvent, p as StepExecutionResult, t as CheckpointYieldData, k as FfiDispatchMetrics, L as LogFields, h as ClientResult } from '../runtime-interface-D940vUzy.js';
2
+ export { D as DependencyResult, u as FfiDomainEventMetadata, m as HandlerDefinition, O as OrchestrationMetadata, R as RetryConfiguration, S as StepDefinition, n as StepExecutionError, o as StepExecutionMetadata, r as Task, s as WorkflowStep } from '../runtime-interface-D940vUzy.js';
137
3
 
138
4
  /**
139
5
  * Runtime detection for TypeScript/JavaScript workers.
@@ -305,4 +171,138 @@ declare class FfiLayer {
305
171
  private createRuntime;
306
172
  }
307
173
 
174
+ /**
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.
179
+ *
180
+ * Install: npm install koffi
181
+ */
182
+
183
+ /**
184
+ * Node.js FFI runtime implementation using koffi
185
+ */
186
+ declare class NodeRuntime extends BaseTaskerRuntime {
187
+ readonly name: string;
188
+ private lib;
189
+ private koffi;
190
+ get isLoaded(): boolean;
191
+ load(libraryPath: string): Promise<void>;
192
+ unload(): void;
193
+ private ensureLoaded;
194
+ /**
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.
198
+ */
199
+ private readAndFreeRustString;
200
+ getVersion(): string;
201
+ getRustVersion(): string;
202
+ healthCheck(): boolean;
203
+ bootstrapWorker(config?: BootstrapConfig): BootstrapResult;
204
+ isWorkerRunning(): boolean;
205
+ getWorkerStatus(): WorkerStatus;
206
+ stopWorker(): StopResult;
207
+ transitionToGracefulShutdown(): StopResult;
208
+ pollStepEvents(): FfiStepEvent | null;
209
+ pollInProcessEvents(): FfiDomainEvent | null;
210
+ completeStepEvent(eventId: string, result: StepExecutionResult): boolean;
211
+ checkpointYieldStepEvent(eventId: string, checkpointData: CheckpointYieldData): boolean;
212
+ getFfiDispatchMetrics(): FfiDispatchMetrics;
213
+ checkStarvationWarnings(): void;
214
+ cleanupTimeouts(): void;
215
+ logError(message: string, fields?: LogFields): void;
216
+ logWarn(message: string, fields?: LogFields): void;
217
+ logInfo(message: string, fields?: LogFields): void;
218
+ logDebug(message: string, fields?: LogFields): void;
219
+ logTrace(message: string, fields?: LogFields): void;
220
+ private parseClientResult;
221
+ clientCreateTask(requestJson: string): ClientResult;
222
+ clientGetTask(taskUuid: string): ClientResult;
223
+ clientListTasks(paramsJson: string): ClientResult;
224
+ clientCancelTask(taskUuid: string): ClientResult;
225
+ clientListTaskSteps(taskUuid: string): ClientResult;
226
+ clientGetStep(taskUuid: string, stepUuid: string): ClientResult;
227
+ clientGetStepAuditHistory(taskUuid: string, stepUuid: string): ClientResult;
228
+ clientHealthCheck(): ClientResult;
229
+ }
230
+
231
+ /**
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).
245
+ *
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.
255
+ *
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.
258
+ */
259
+
260
+ /**
261
+ * Deno FFI runtime implementation using Deno.dlopen
262
+ */
263
+ declare class DenoRuntime extends BaseTaskerRuntime {
264
+ readonly name = "deno";
265
+ private lib;
266
+ private encoder;
267
+ get isLoaded(): boolean;
268
+ load(libraryPath: string): Promise<void>;
269
+ unload(): void;
270
+ private ensureLoaded;
271
+ /**
272
+ * Creates a null-terminated C string buffer.
273
+ * With 'buffer' FFI type, we return Uint8Array directly.
274
+ */
275
+ private toCString;
276
+ private fromCString;
277
+ getVersion(): string;
278
+ getRustVersion(): string;
279
+ healthCheck(): boolean;
280
+ bootstrapWorker(config?: BootstrapConfig): BootstrapResult;
281
+ isWorkerRunning(): boolean;
282
+ getWorkerStatus(): WorkerStatus;
283
+ stopWorker(): StopResult;
284
+ transitionToGracefulShutdown(): StopResult;
285
+ pollStepEvents(): FfiStepEvent | null;
286
+ pollInProcessEvents(): FfiDomainEvent | null;
287
+ completeStepEvent(eventId: string, result: StepExecutionResult): boolean;
288
+ checkpointYieldStepEvent(eventId: string, checkpointData: CheckpointYieldData): boolean;
289
+ getFfiDispatchMetrics(): FfiDispatchMetrics;
290
+ checkStarvationWarnings(): void;
291
+ cleanupTimeouts(): void;
292
+ logError(message: string, fields?: LogFields): void;
293
+ logWarn(message: string, fields?: LogFields): void;
294
+ logInfo(message: string, fields?: LogFields): void;
295
+ logDebug(message: string, fields?: LogFields): void;
296
+ logTrace(message: string, fields?: LogFields): void;
297
+ private parseClientResult;
298
+ clientCreateTask(requestJson: string): ClientResult;
299
+ clientGetTask(taskUuid: string): ClientResult;
300
+ clientListTasks(paramsJson: string): ClientResult;
301
+ clientCancelTask(taskUuid: string): ClientResult;
302
+ clientListTaskSteps(taskUuid: string): ClientResult;
303
+ clientGetStep(taskUuid: string, stepUuid: string): ClientResult;
304
+ clientGetStepAuditHistory(taskUuid: string, stepUuid: string): ClientResult;
305
+ clientHealthCheck(): ClientResult;
306
+ }
307
+
308
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 };
@@ -1,5 +1,5 @@
1
1
  import { EventEmitter } from 'eventemitter3';
2
- import { l as FfiStepEvent, p as StepExecutionResult, k as FfiDispatchMetrics, T as TaskerRuntime } from './runtime-interface-CE4viUt7.js';
2
+ import { l as FfiStepEvent, p as StepExecutionResult, k as FfiDispatchMetrics, T as TaskerRuntime } from './runtime-interface-D940vUzy.js';
3
3
 
4
4
  /**
5
5
  * Event emitter for TypeScript workers.
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { T as TaskerRuntime, F as FfiDomainEvent, H as HandlerDefinitionDto } from './runtime-interface-CE4viUt7.js';
2
- export { B as BaseTaskerRuntime, C as ClientHealthResponse, c as ClientPaginationInfo, d as ClientResult, e as ClientStepAuditResponse, f as ClientStepReadiness, g as ClientStepResponse, h as ClientTaskListResponse, i as ClientTaskRequest, j as ClientTaskResponse, D as DependencyResult, a as FfiBootstrapConfig, b as FfiBootstrapResult, k as FfiDispatchMetrics, L as FfiLogFields, l as FfiStepEvent, q as FfiStopResult, W as FfiWorkerStatus, m as HandlerDefinition, O as OrchestrationMetadata, R as RetryConfiguration, S as StepDefinition, n as StepExecutionError, o as StepExecutionMetadata, p as StepExecutionResult, r as Task, s as WorkflowStep } from './runtime-interface-CE4viUt7.js';
3
- import { S as StepHandlerResult, a as StepHandler, B as BatchWorkerConfig, b as StepContext, E as ExecutableHandler, c as StepHandlerClass, T as TaskerEventEmitter, d as EventPoller, e as StepExecutionSubscriber, f as EventSystem } from './index-B3BcknlZ.js';
4
- export { y as ErrorCallback, I as ErrorType, n as EventName, o as EventNames, z as EventPollerConfig, F as EventSystemConfig, G as EventSystemStats, A as MetricsCallback, p as MetricsEventName, q as MetricsEventNames, M as MetricsPayload, P as PollerCyclePayload, r as PollerEventName, s as PollerEventNames, C as PollerState, g as StepCompletionSentPayload, L as StepContextParams, D as StepEventCallback, t as StepEventName, u as StepEventNames, h as StepExecutionCompletedPayload, i as StepExecutionFailedPayload, j as StepExecutionReceivedPayload, k as StepExecutionStartedPayload, H as StepExecutionSubscriberConfig, N as StepHandlerResultParams, l as TaskerEventMap, W as WorkerErrorPayload, v as WorkerEventName, w as WorkerEventNames, m as WorkerEventPayload, x as createEventPoller, J as isStandardErrorType, K as isTypicallyRetryable } from './index-B3BcknlZ.js';
5
- import { FfiLayerConfig } from './ffi/index.js';
6
- export { BunRuntime, DenoRuntime, FfiLayer, NodeRuntime, RuntimeInfo, RuntimeType, detectRuntime, getLibraryPath, getRuntimeInfo, isBun, isDeno, isNode } from './ffi/index.js';
1
+ import { T as TaskerRuntime, C as ClientTaskResponse, a as ClientTaskListResponse, b as ClientStepResponse, c as ClientStepAuditResponse, d as ClientHealthResponse, F as FfiDomainEvent, H as HandlerDefinitionDto } from './runtime-interface-D940vUzy.js';
2
+ export { B as BaseTaskerRuntime, g as ClientPaginationInfo, h as ClientResult, i as ClientStepReadiness, j as ClientTaskRequest, D as DependencyResult, e as FfiBootstrapConfig, f as FfiBootstrapResult, k as FfiDispatchMetrics, L as FfiLogFields, l as FfiStepEvent, q as FfiStopResult, W as FfiWorkerStatus, m as HandlerDefinition, O as OrchestrationMetadata, R as RetryConfiguration, S as StepDefinition, n as StepExecutionError, o as StepExecutionMetadata, p as StepExecutionResult, r as Task, s as WorkflowStep } from './runtime-interface-D940vUzy.js';
3
+ import { FfiLayer, FfiLayerConfig } from './ffi/index.js';
4
+ export { BunRuntime, DenoRuntime, NodeRuntime, RuntimeInfo, RuntimeType, detectRuntime, getLibraryPath, getRuntimeInfo, isBun, isDeno, isNode } from './ffi/index.js';
5
+ import { S as StepHandlerResult, a as StepHandler, B as BatchWorkerConfig, b as StepContext, E as ExecutableHandler, c as StepHandlerClass, T as TaskerEventEmitter, d as EventPoller, e as StepExecutionSubscriber, f as EventSystem } from './index-CTl8lGpU.js';
6
+ export { y as ErrorCallback, I as ErrorType, n as EventName, o as EventNames, z as EventPollerConfig, F as EventSystemConfig, G as EventSystemStats, A as MetricsCallback, p as MetricsEventName, q as MetricsEventNames, M as MetricsPayload, P as PollerCyclePayload, r as PollerEventName, s as PollerEventNames, C as PollerState, g as StepCompletionSentPayload, L as StepContextParams, D as StepEventCallback, t as StepEventName, u as StepEventNames, h as StepExecutionCompletedPayload, i as StepExecutionFailedPayload, j as StepExecutionReceivedPayload, k as StepExecutionStartedPayload, H as StepExecutionSubscriberConfig, N as StepHandlerResultParams, l as TaskerEventMap, W as WorkerErrorPayload, v as WorkerEventName, w as WorkerEventNames, m as WorkerEventPayload, x as createEventPoller, J as isStandardErrorType, K as isTypicallyRetryable } from './index-CTl8lGpU.js';
7
7
  import { Logger } from 'pino';
8
8
  import 'eventemitter3';
9
9
 
@@ -225,6 +225,166 @@ declare function getRustVersion(runtime?: TaskerRuntime): string;
225
225
  */
226
226
  declare function healthCheck(runtime?: TaskerRuntime): boolean;
227
227
 
228
+ /**
229
+ * High-level client wrapper for orchestration API operations.
230
+ *
231
+ * The raw FFI exposes `runtime.clientCreateTask(json)` and similar methods
232
+ * that require callers to construct complete JSON request strings with all
233
+ * required fields and return untyped `ClientResult` envelopes.
234
+ *
235
+ * This module provides a `TaskerClient` class with typed methods, sensible
236
+ * defaults, and proper error handling.
237
+ *
238
+ * @example
239
+ * ```typescript
240
+ * import { FfiLayer, TaskerClient } from '@tasker-systems/tasker';
241
+ *
242
+ * const ffiLayer = new FfiLayer();
243
+ * await ffiLayer.load();
244
+ * const client = new TaskerClient(ffiLayer);
245
+ *
246
+ * const task = client.createTask({ name: 'process_order', namespace: 'ecommerce' });
247
+ * console.log(task.task_uuid);
248
+ * ```
249
+ *
250
+ * @packageDocumentation
251
+ */
252
+
253
+ /**
254
+ * Options for creating a task.
255
+ *
256
+ * Only `name` is required; all other fields have sensible defaults.
257
+ */
258
+ interface CreateTaskOptions {
259
+ /** Named task template name */
260
+ name: string;
261
+ /** Task namespace (default: 'default') */
262
+ namespace?: string;
263
+ /** Workflow context passed to step handlers (default: {}) */
264
+ context?: Record<string, unknown>;
265
+ /** Template version (default: '1.0.0') */
266
+ version?: string;
267
+ /** Who initiated the request (default: 'tasker-core-typescript') */
268
+ initiator?: string;
269
+ /** Originating system (default: 'tasker-core') */
270
+ sourceSystem?: string;
271
+ /** Reason for creating the task (default: 'Task requested') */
272
+ reason?: string;
273
+ /** Optional tags */
274
+ tags?: string[];
275
+ /** Optional priority */
276
+ priority?: number | null;
277
+ /** Optional correlation ID (auto-generated if not provided) */
278
+ correlationId?: string;
279
+ /** Optional parent correlation ID */
280
+ parentCorrelationId?: string | null;
281
+ /** Optional idempotency key */
282
+ idempotencyKey?: string | null;
283
+ }
284
+ /**
285
+ * Options for listing tasks.
286
+ */
287
+ interface ListTasksOptions {
288
+ /** Maximum number of results (default: 50) */
289
+ limit?: number;
290
+ /** Pagination offset (default: 0) */
291
+ offset?: number;
292
+ /** Filter by namespace */
293
+ namespace?: string;
294
+ /** Filter by status */
295
+ status?: string;
296
+ }
297
+ /**
298
+ * Error thrown when a client operation fails.
299
+ */
300
+ declare class TaskerClientError extends Error {
301
+ /** Whether the error is potentially recoverable */
302
+ readonly recoverable: boolean;
303
+ constructor(message: string, recoverable?: boolean);
304
+ }
305
+ /**
306
+ * High-level client for orchestration API operations.
307
+ *
308
+ * Wraps the raw FFI methods with typed interfaces, sensible defaults,
309
+ * and proper error handling via `TaskerClientError`.
310
+ */
311
+ declare class TaskerClient {
312
+ private readonly ffiLayer;
313
+ constructor(ffiLayer: FfiLayer);
314
+ /**
315
+ * Create a task via the orchestration API.
316
+ *
317
+ * @param options - Task creation options (only `name` is required)
318
+ * @returns Typed task response
319
+ * @throws TaskerClientError if the operation fails
320
+ */
321
+ createTask(options: CreateTaskOptions): ClientTaskResponse;
322
+ /**
323
+ * Get a task by UUID.
324
+ *
325
+ * @param taskUuid - The task UUID
326
+ * @returns Typed task response
327
+ * @throws TaskerClientError if the operation fails
328
+ */
329
+ getTask(taskUuid: string): ClientTaskResponse;
330
+ /**
331
+ * List tasks with optional filtering and pagination.
332
+ *
333
+ * @param options - Filtering and pagination options
334
+ * @returns Typed task list response with pagination
335
+ * @throws TaskerClientError if the operation fails
336
+ */
337
+ listTasks(options?: ListTasksOptions): ClientTaskListResponse;
338
+ /**
339
+ * Cancel a task by UUID.
340
+ *
341
+ * @param taskUuid - The task UUID
342
+ * @throws TaskerClientError if the operation fails
343
+ */
344
+ cancelTask(taskUuid: string): void;
345
+ /**
346
+ * List workflow steps for a task.
347
+ *
348
+ * @param taskUuid - The task UUID
349
+ * @returns Array of typed step responses
350
+ * @throws TaskerClientError if the operation fails
351
+ */
352
+ listTaskSteps(taskUuid: string): ClientStepResponse[];
353
+ /**
354
+ * Get a specific workflow step.
355
+ *
356
+ * @param taskUuid - The task UUID
357
+ * @param stepUuid - The step UUID
358
+ * @returns Typed step response
359
+ * @throws TaskerClientError if the operation fails
360
+ */
361
+ getStep(taskUuid: string, stepUuid: string): ClientStepResponse;
362
+ /**
363
+ * Get audit history for a workflow step.
364
+ *
365
+ * @param taskUuid - The task UUID
366
+ * @param stepUuid - The step UUID
367
+ * @returns Array of typed audit history entries
368
+ * @throws TaskerClientError if the operation fails
369
+ */
370
+ getStepAuditHistory(taskUuid: string, stepUuid: string): ClientStepAuditResponse[];
371
+ /**
372
+ * Check orchestration API health.
373
+ *
374
+ * @returns Typed health response
375
+ * @throws TaskerClientError if the operation fails
376
+ */
377
+ healthCheck(): ClientHealthResponse;
378
+ /**
379
+ * Unwrap a ClientResult envelope, throwing on error.
380
+ */
381
+ private unwrap;
382
+ /**
383
+ * Get the FFI runtime from the layer.
384
+ */
385
+ private getRuntime;
386
+ }
387
+
228
388
  /**
229
389
  * API mixin for HTTP functionality.
230
390
  *
@@ -4010,4 +4170,4 @@ declare class WorkerServer {
4010
4170
  private cleanupOnError;
4011
4171
  }
4012
4172
 
4013
- export { type APICapable, APIMixin, ApiHandler, ApiResponse, BasePublisher, type BaseResolver, BaseSubscriber, type BatchAggregationResult, type BatchAnalyzerOutcome, type BatchMetadata, type BatchProcessingOutcome, type BatchWorkerContext, type BatchWorkerOutcome, type Batchable, BatchableMixin, type BootstrapConfig, type BootstrapResult, ClassLookupResolver, type CreateBatchesOutcome, type CursorConfig, type DecisionCapable, DecisionHandler, DecisionMixin, type DecisionPointOutcome, DecisionType, DefaultPublisher, type DomainEvent, type DomainEventCallback, type DomainEventErrorCallback, type DomainEventMetadata, type DomainEventPollerConfig, DuplicatePublisherError, type EventDeclaration, EventPoller, EventSystem, ExecutableHandler, ExplicitMappingResolver, type FailureStrategy, FfiLayerConfig, type HandlerEntry, type HandlerFactory, HandlerRegistry, type HandlerSpec, HandlerSystem, InProcessDomainEventPoller, type LogFields, MethodDispatchError, MethodDispatchWrapper, type NoBatchesOutcome, NoResolverMatchError, type PollerStats, type PublishContext, PublisherNotFoundError, PublisherRegistry, PublisherValidationError, RegistryFrozenError, RegistryResolver, type RegistryResolverStatic, ResolutionError, ResolverChain, type ResolverConfig, ResolverNotFoundError, type RustBatchWorkerInputs, type RustCursorConfig, type ServerComponents, type HealthCheckResult as ServerHealthCheckResult, type ServerState, type ServerStatus, ShutdownController, type ShutdownHandler, StepContext, type StepEventContext, StepExecutionSubscriber, StepHandler, StepHandlerClass, StepHandlerResult, type StepResult, type StopResult, type SubscriberClass, SubscriberRegistry, type SubscriberStats, TaskerEventEmitter, TaskerRuntime, WorkerServer, type WorkerServerConfig, type WorkerStatus, aggregateBatchResults, applyAPI, applyBatchable, applyDecision, bootstrapWorker, createBatchWorkerContext, createBatches, createDomainEvent, createFfiPollAdapter, createLogger, createStepEventContext, effectiveMethod, ffiEventToDomainEvent, fromCallable, fromDto, getRustVersion, getVersion, getWorkerStatus, hasResolverHint, healthCheck, isCreateBatches, isNoBatches, isWorkerRunning, logDebug, logError, logInfo, logTrace, logWarn, noBatches, normalizeToDefinition, stopWorker, transitionToGracefulShutdown, usesMethodDispatch };
4173
+ export { type APICapable, APIMixin, ApiHandler, ApiResponse, BasePublisher, type BaseResolver, BaseSubscriber, type BatchAggregationResult, type BatchAnalyzerOutcome, type BatchMetadata, type BatchProcessingOutcome, type BatchWorkerContext, type BatchWorkerOutcome, type Batchable, BatchableMixin, type BootstrapConfig, type BootstrapResult, ClassLookupResolver, ClientHealthResponse, ClientStepAuditResponse, ClientStepResponse, ClientTaskListResponse, ClientTaskResponse, type CreateBatchesOutcome, type CreateTaskOptions, type CursorConfig, type DecisionCapable, DecisionHandler, DecisionMixin, type DecisionPointOutcome, DecisionType, DefaultPublisher, type DomainEvent, type DomainEventCallback, type DomainEventErrorCallback, type DomainEventMetadata, type DomainEventPollerConfig, DuplicatePublisherError, type EventDeclaration, EventPoller, EventSystem, ExecutableHandler, ExplicitMappingResolver, type FailureStrategy, FfiLayer, FfiLayerConfig, type HandlerEntry, type HandlerFactory, HandlerRegistry, type HandlerSpec, HandlerSystem, InProcessDomainEventPoller, type ListTasksOptions, type LogFields, MethodDispatchError, MethodDispatchWrapper, type NoBatchesOutcome, NoResolverMatchError, type PollerStats, type PublishContext, PublisherNotFoundError, PublisherRegistry, PublisherValidationError, RegistryFrozenError, RegistryResolver, type RegistryResolverStatic, ResolutionError, ResolverChain, type ResolverConfig, ResolverNotFoundError, type RustBatchWorkerInputs, type RustCursorConfig, type ServerComponents, type HealthCheckResult as ServerHealthCheckResult, type ServerState, type ServerStatus, ShutdownController, type ShutdownHandler, StepContext, type StepEventContext, StepExecutionSubscriber, StepHandler, StepHandlerClass, StepHandlerResult, type StepResult, type StopResult, type SubscriberClass, SubscriberRegistry, type SubscriberStats, TaskerClient, TaskerClientError, TaskerEventEmitter, TaskerRuntime, WorkerServer, type WorkerServerConfig, type WorkerStatus, aggregateBatchResults, applyAPI, applyBatchable, applyDecision, bootstrapWorker, createBatchWorkerContext, createBatches, createDomainEvent, createFfiPollAdapter, createLogger, createStepEventContext, effectiveMethod, ffiEventToDomainEvent, fromCallable, fromDto, getRustVersion, getVersion, getWorkerStatus, hasResolverHint, healthCheck, isCreateBatches, isNoBatches, isWorkerRunning, logDebug, logError, logInfo, logTrace, logWarn, noBatches, normalizeToDefinition, stopWorker, transitionToGracefulShutdown, usesMethodDispatch };