@taskcast/react 0.1.1 → 0.2.0

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.
Files changed (2) hide show
  1. package/README.md +53 -0
  2. package/package.json +3 -3
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # @taskcast/react
2
+
3
+ React hook for [Taskcast](https://github.com/weightwave/taskcast) SSE event subscriptions.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ pnpm add @taskcast/react @taskcast/client @taskcast/core react
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```tsx
14
+ import { useTaskEvents } from '@taskcast/react'
15
+
16
+ function TaskStream({ taskId }: { taskId: string }) {
17
+ const { events, isDone, doneReason, error } = useTaskEvents(taskId, {
18
+ baseUrl: 'http://localhost:3721',
19
+ filter: { types: ['llm.*'] },
20
+ })
21
+
22
+ return (
23
+ <div>
24
+ {events.map((e) => (
25
+ <span key={e.eventId}>{e.data.text}</span>
26
+ ))}
27
+ {isDone && <p>Done: {doneReason}</p>}
28
+ {error && <p>Error: {error.message}</p>}
29
+ </div>
30
+ )
31
+ }
32
+ ```
33
+
34
+ ## API
35
+
36
+ ### `useTaskEvents(taskId, options)`
37
+
38
+ Returns:
39
+
40
+ | Field | Type | Description |
41
+ |-------|------|-------------|
42
+ | `events` | `SSEEnvelope[]` | Accumulated events |
43
+ | `isDone` | `boolean` | Whether the task has reached a terminal state |
44
+ | `doneReason` | `string \| null` | Terminal status (`completed`, `failed`, etc.) |
45
+ | `error` | `Error \| null` | Connection or parse errors |
46
+
47
+ ## Part of Taskcast
48
+
49
+ This is the React integration package. See the [Taskcast monorepo](https://github.com/weightwave/taskcast) for the full project.
50
+
51
+ ## License
52
+
53
+ [MIT](https://github.com/weightwave/taskcast/blob/main/LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taskcast/react",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "React hook useTaskEvents for Taskcast SSE subscriptions.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -28,8 +28,8 @@
28
28
  "provenance": true
29
29
  },
30
30
  "dependencies": {
31
- "@taskcast/client": "0.1.1",
32
- "@taskcast/core": "0.1.1"
31
+ "@taskcast/client": "0.2.0",
32
+ "@taskcast/core": "0.2.0"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.0.0"