@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 +46 -85
- package/dist/events/index.d.ts +2 -2
- package/dist/events/index.js +374 -295
- package/dist/events/index.js.map +1 -1
- package/dist/ffi/index.d.ts +323 -221
- package/dist/ffi/index.js +58 -1887
- package/dist/ffi/index.js.map +1 -1
- package/dist/{index-CTl8lGpU.d.ts → index-Bvdub2HH.d.ts} +77 -36
- package/dist/index.d.ts +75 -141
- package/dist/index.js +618 -2486
- package/dist/index.js.map +1 -1
- package/package.json +14 -7
- package/{native/libtasker_ts-darwin-arm64.dylib → tasker_ts.darwin-arm64.node} +0 -0
- package/{native/libtasker_ts-linux-x64.so → tasker_ts.linux-x64-gnu.node} +0 -0
- package/dist/koffi-3HFAASOB.node +0 -0
- package/dist/koffi-AHHUCM3C.node +0 -0
- package/dist/koffi-AVDVVSXH.node +0 -0
- package/dist/koffi-BMO5K7B3.node +0 -0
- package/dist/koffi-G4D35B2D.node +0 -0
- package/dist/koffi-GG4SDSYA.node +0 -0
- package/dist/koffi-GOENU54R.node +0 -0
- package/dist/koffi-IDX6JEDH.node +0 -0
- package/dist/koffi-KFZAXWPQ.node +0 -0
- package/dist/koffi-LOH6WKRQ.node +0 -0
- package/dist/koffi-LUY2JHJP.node +0 -0
- package/dist/koffi-OMHWL3D6.node +0 -0
- package/dist/koffi-QKY2KSXW.node +0 -0
- package/dist/koffi-ROB3FRHA.node +0 -0
- package/dist/koffi-SE4ZI36U.node +0 -0
- package/dist/koffi-X3YT67KE.node +0 -0
- package/dist/koffi-X7JMBSZH.node +0 -0
- package/dist/koffi-YNQDUF3Q.node +0 -0
- package/dist/runtime-interface-D940vUzy.d.ts +0 -694
package/README.md
CHANGED
|
@@ -1,117 +1,78 @@
|
|
|
1
1
|
# @tasker-systems/tasker
|
|
2
2
|
|
|
3
|
-
TypeScript worker for the Tasker workflow orchestration system.
|
|
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
|
|
9
|
+
bun add @tasker-systems/tasker
|
|
14
10
|
|
|
15
11
|
# Node.js
|
|
16
|
-
npm install @tasker-systems/tasker
|
|
12
|
+
npm install @tasker-systems/tasker
|
|
17
13
|
```
|
|
18
14
|
|
|
19
15
|
## Quick Start
|
|
20
16
|
|
|
21
17
|
```typescript
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
|
|
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
|
-
|
|
36
|
-
|
|
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
|
|
58
|
+
- Rust 1.70+ (for building the napi-rs native addon)
|
|
45
59
|
|
|
46
|
-
###
|
|
60
|
+
### Build
|
|
47
61
|
|
|
48
62
|
```bash
|
|
49
|
-
# Install dependencies
|
|
50
|
-
bun
|
|
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
|
-
#
|
|
53
|
-
bun run
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
package/dist/events/index.d.ts
CHANGED
|
@@ -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-
|
|
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 '../
|
|
3
|
+
import '../ffi/index.js';
|