@taskcast/core 0.1.0 → 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 +63 -0
- package/package.json +17 -2
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# @taskcast/core
|
|
2
|
+
|
|
3
|
+
Task engine, state machine, filtering, and series merging for [Taskcast](https://github.com/weightwave/taskcast). Zero HTTP dependencies.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @taskcast/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import {
|
|
15
|
+
TaskEngine,
|
|
16
|
+
MemoryBroadcastProvider,
|
|
17
|
+
MemoryShortTermStore,
|
|
18
|
+
} from '@taskcast/core'
|
|
19
|
+
|
|
20
|
+
const engine = new TaskEngine({
|
|
21
|
+
broadcast: new MemoryBroadcastProvider(),
|
|
22
|
+
shortTermStore: new MemoryShortTermStore(),
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
// Create a task
|
|
26
|
+
const task = await engine.createTask({
|
|
27
|
+
type: 'llm.chat',
|
|
28
|
+
params: { prompt: 'Tell me a story' },
|
|
29
|
+
ttl: 3600,
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
// Transition to running
|
|
33
|
+
await engine.transitionTask(task.id, 'running')
|
|
34
|
+
|
|
35
|
+
// Publish streaming events
|
|
36
|
+
await engine.publishEvent(task.id, {
|
|
37
|
+
type: 'llm.delta',
|
|
38
|
+
level: 'info',
|
|
39
|
+
data: { text: 'Once upon a time...' },
|
|
40
|
+
seriesId: 'response',
|
|
41
|
+
seriesMode: 'accumulate',
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
// Complete the task
|
|
45
|
+
await engine.transitionTask(task.id, 'completed', {
|
|
46
|
+
result: { output: 'The End.' },
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Key Concepts
|
|
51
|
+
|
|
52
|
+
- **State Machine** — Task lifecycle: `pending` -> `running` -> `completed` | `failed` | `timeout` | `cancelled`
|
|
53
|
+
- **Event Filtering** — Wildcard type matching (`llm.*`), level filtering, cursor-based resumption
|
|
54
|
+
- **Series Merging** — `keep-all` (full history), `accumulate` (text concatenation), `latest` (replace)
|
|
55
|
+
- **Storage Adapters** — Pluggable `BroadcastProvider`, `ShortTermStore`, and `LongTermStore` interfaces
|
|
56
|
+
|
|
57
|
+
## Part of Taskcast
|
|
58
|
+
|
|
59
|
+
This is the core engine package. See the [Taskcast monorepo](https://github.com/weightwave/taskcast) for the full project, including HTTP server, client SDKs, and storage adapters.
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
[MIT](https://github.com/weightwave/taskcast/blob/main/LICENSE)
|
package/package.json
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taskcast/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
|
+
"description": "Task engine, state machine, filtering, series merging. Zero HTTP deps.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/weightwave/taskcast.git",
|
|
8
|
+
"directory": "packages/core"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/weightwave/taskcast/tree/main/packages/core#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/weightwave/taskcast/issues"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
4
15
|
"files": [
|
|
5
16
|
"dist",
|
|
6
|
-
"LICENSE"
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"README.md"
|
|
7
19
|
],
|
|
8
20
|
"type": "module",
|
|
9
21
|
"exports": {
|
|
@@ -12,6 +24,9 @@
|
|
|
12
24
|
"import": "./dist/index.js"
|
|
13
25
|
}
|
|
14
26
|
},
|
|
27
|
+
"publishConfig": {
|
|
28
|
+
"provenance": true
|
|
29
|
+
},
|
|
15
30
|
"dependencies": {
|
|
16
31
|
"js-yaml": "^4.1.0",
|
|
17
32
|
"ulidx": "^2.3.0",
|