@openharness/react 0.2.1 → 0.2.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.
Files changed (2) hide show
  1. package/README.md +90 -0
  2. package/package.json +22 -4
package/README.md ADDED
@@ -0,0 +1,90 @@
1
+ # @openharness/react
2
+
3
+ React hooks and provider for [OpenHarness](https://github.com/MaxGfeller/open-harness) AI SDK 5 chat UIs.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @openharness/react
9
+ ```
10
+
11
+ Peer dependencies: `@openharness/core`, `@ai-sdk/react`, `react`
12
+
13
+ ## Quick start
14
+
15
+ ```tsx
16
+ import {
17
+ OpenHarnessProvider,
18
+ useOpenHarness,
19
+ useSubagentStatus,
20
+ useSessionStatus,
21
+ } from "@openharness/react";
22
+
23
+ function App() {
24
+ return (
25
+ <OpenHarnessProvider>
26
+ <Chat />
27
+ </OpenHarnessProvider>
28
+ );
29
+ }
30
+
31
+ function Chat() {
32
+ const { messages, sendMessage, status } = useOpenHarness({
33
+ endpoint: "/api/chat",
34
+ });
35
+ const { activeSubagents, hasActiveSubagents } = useSubagentStatus();
36
+ const session = useSessionStatus();
37
+
38
+ return (
39
+ <div>
40
+ {messages.map((msg) => (
41
+ <div key={msg.id}>
42
+ {msg.parts.map((part, i) =>
43
+ part.type === "text" ? <span key={i}>{part.text}</span> : null
44
+ )}
45
+ </div>
46
+ ))}
47
+ {hasActiveSubagents && <p>Subagents working...</p>}
48
+ <button onClick={() => sendMessage({ text: "Hello" })}>Send</button>
49
+ </div>
50
+ );
51
+ }
52
+ ```
53
+
54
+ ## API
55
+
56
+ ### `<OpenHarnessProvider>`
57
+
58
+ Context provider that holds subagent, session, and sandbox state. Wrap your app or chat component with this.
59
+
60
+ ### `useOpenHarness(config)`
61
+
62
+ Creates a chat session connected to your API endpoint. Returns the same interface as AI SDK 5's `useChat` (`messages`, `sendMessage`, `status`, `stop`, etc.), typed with `OHUIMessage`.
63
+
64
+ ### `useSubagentStatus()`
65
+
66
+ Derives reactive state from `data-oh:subagent.*` stream events:
67
+
68
+ - `activeSubagents` -- currently running subagents
69
+ - `recentSubagents` -- all subagents seen in this session
70
+ - `hasActiveSubagents` -- boolean shorthand
71
+
72
+ ### `useSessionStatus()`
73
+
74
+ Tracks turn index, compaction state, and retry info from `data-oh:*` stream events.
75
+
76
+ ### `useSandboxStatus()`
77
+
78
+ Tracks sandbox-related state from stream events.
79
+
80
+ ### `createOHTransport(options)`
81
+
82
+ Low-level transport factory for custom integrations. Creates the SSE connection with OpenHarness data part handling.
83
+
84
+ ## Documentation
85
+
86
+ See the [full documentation](https://github.com/MaxGfeller/open-harness#readme) for server setup, middleware composition, and the complete streaming protocol.
87
+
88
+ ## License
89
+
90
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openharness/react",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "type": "module",
5
5
  "description": "React hooks and provider for OpenHarness AI SDK 5 integration",
6
6
  "exports": {
@@ -10,13 +10,31 @@
10
10
  }
11
11
  },
12
12
  "files": [
13
- "dist"
13
+ "dist",
14
+ "README.md"
14
15
  ],
15
16
  "peerDependencies": {
16
17
  "@ai-sdk/react": "^3.0.0",
17
18
  "react": "^18.0.0 || ^19.0.0",
18
- "@openharness/core": "0.3.1"
19
+ "@openharness/core": "0.4.2"
19
20
  },
21
+ "homepage": "https://github.com/MaxGfeller/open-harness/tree/main/packages/react#readme",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/MaxGfeller/open-harness.git",
25
+ "directory": "packages/react"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/MaxGfeller/open-harness/issues"
29
+ },
30
+ "keywords": [
31
+ "agent",
32
+ "ai",
33
+ "react",
34
+ "hooks",
35
+ "chat",
36
+ "openharness"
37
+ ],
20
38
  "devDependencies": {
21
39
  "@ai-sdk/react": "^3.0.0",
22
40
  "@testing-library/react": "^16.3.0",
@@ -25,7 +43,7 @@
25
43
  "react": "^19.1.0",
26
44
  "react-dom": "^19.1.0",
27
45
  "typescript": "^5.9.3",
28
- "@openharness/core": "0.3.1"
46
+ "@openharness/core": "0.4.2"
29
47
  },
30
48
  "license": "ISC",
31
49
  "scripts": {