@tasker-systems/tasker 0.1.4 → 0.1.5

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,117 +1,78 @@
1
1
  # @tasker-systems/tasker
2
2
 
3
- TypeScript worker for the Tasker workflow orchestration system. Supports Bun, Node.js (both via koffi/Node-API), 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.
3
+ TypeScript worker for the [Tasker](https://github.com/tasker-systems/tasker-core) workflow orchestration system. Uses napi-rs native addons for high-performance FFI to the shared Rust worker infrastructure. Supports Bun (primary) and Node.js runtimes.
8
4
 
9
5
  ## Installation
10
6
 
11
7
  ```bash
12
8
  # Bun (recommended)
13
- bun add @tasker-systems/tasker koffi
9
+ bun add @tasker-systems/tasker
14
10
 
15
11
  # Node.js
16
- npm install @tasker-systems/tasker koffi
12
+ npm install @tasker-systems/tasker
17
13
  ```
18
14
 
19
15
  ## Quick Start
20
16
 
21
17
  ```typescript
22
- import { TaskerWorker } from "@tasker-systems/tasker";
23
-
24
- const worker = new TaskerWorker({
25
- workerName: "my-worker",
26
- namespaces: ["default"],
27
- });
18
+ import { WorkerServer, StepHandler, type StepContext, type StepHandlerResult } from "@tasker-systems/tasker";
19
+
20
+ // Define a step handler
21
+ class ProcessPaymentHandler extends StepHandler {
22
+ static handlerName = "process_payment";
23
+ static handlerVersion = "1.0.0";
24
+
25
+ async call(context: StepContext): Promise<StepHandlerResult> {
26
+ const amount = context.getInput<number>("amount");
27
+ // ... business logic ...
28
+ return this.success({ amount, status: "processed" });
29
+ }
30
+ }
31
+
32
+ // Create and start the worker server
33
+ const server = new WorkerServer();
34
+ await server.start({ namespace: "default" });
35
+
36
+ // Register handlers
37
+ const handlerSystem = server.getHandlerSystem();
38
+ handlerSystem.register(ProcessPaymentHandler.handlerName, ProcessPaymentHandler);
39
+
40
+ // Server is now processing tasks — shut down gracefully on exit
41
+ process.on("SIGINT", () => server.shutdown());
42
+ ```
28
43
 
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
- });
44
+ ## Handler Types
34
45
 
35
- // Start the worker
36
- await worker.start();
37
- ```
46
+ | Type | Use Case |
47
+ |------|----------|
48
+ | `StepHandler` | General-purpose step execution |
49
+ | `ApiHandler` | HTTP API integration with automatic error classification |
50
+ | `DecisionHandler` | Dynamic workflow routing |
51
+ | `BatchableStepHandler` | Large dataset processing in chunks |
38
52
 
39
53
  ## Development
40
54
 
41
55
  ### Prerequisites
42
56
 
43
57
  - Bun 1.0+ (recommended) or Node.js 18+
44
- - Rust 1.70+ (for building the FFI library)
58
+ - Rust 1.70+ (for building the napi-rs native addon)
45
59
 
46
- ### Setup
60
+ ### Build
47
61
 
48
62
  ```bash
49
- # Install dependencies
50
- bun install
63
+ bun install # Install dependencies
64
+ bun run build:napi # Build napi-rs native addon (debug)
65
+ bun run build # Build TypeScript
51
66
 
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
67
+ bun test # Run tests
68
+ bun run typecheck # Type checking
69
+ bun run check # Lint (Biome)
63
70
  ```
64
71
 
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**: koffi (Node-API, works with both Bun and 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
72
+ ## Documentation
109
73
 
110
- | Runtime | FFI Mechanism | Status |
111
- |---------|---------------|--------|
112
- | Bun | koffi (Node-API) | Recommended |
113
- | Node.js | koffi (Node-API) | Supported |
114
- | Deno | `Deno.dlopen` | Experimental |
74
+ - [TypeScript Worker Guide](../../docs/workers/typescript.md) full API reference, handler patterns, event system, configuration
75
+ - [Example App (Bun + Hono)](https://github.com/tasker-systems/tasker-contrib/tree/main/examples/bun-app) — production-style example with multiple handler types
115
76
 
116
77
  ## License
117
78
 
@@ -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-CTl8lGpU.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-Bvdub2HH.js';
2
2
  import 'eventemitter3';
3
- import '../runtime-interface-D940vUzy.js';
3
+ import '../ffi/index.js';