@openharness/react 0.2.1 → 0.2.3
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 +94 -0
- package/package.json +26 -6
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
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
|
+
If you pass `messages`, the hook will also hydrate them when they arrive after the first render, which is useful for async persistence loads.
|
|
65
|
+
|
|
66
|
+
`onFinish` receives the full finish event, including `isAbort`, so persistence code can skip saving aborted assistant messages when desired.
|
|
67
|
+
|
|
68
|
+
### `useSubagentStatus()`
|
|
69
|
+
|
|
70
|
+
Derives reactive state from `data-oh:subagent.*` stream events:
|
|
71
|
+
|
|
72
|
+
- `activeSubagents` -- currently running subagents
|
|
73
|
+
- `recentSubagents` -- all subagents seen in this session
|
|
74
|
+
- `hasActiveSubagents` -- boolean shorthand
|
|
75
|
+
|
|
76
|
+
### `useSessionStatus()`
|
|
77
|
+
|
|
78
|
+
Tracks turn index, compaction state, and retry info from `data-oh:*` stream events.
|
|
79
|
+
|
|
80
|
+
### `useSandboxStatus()`
|
|
81
|
+
|
|
82
|
+
Tracks sandbox-related state from stream events.
|
|
83
|
+
|
|
84
|
+
### `createOHTransport(options)`
|
|
85
|
+
|
|
86
|
+
Low-level transport factory for custom integrations. Creates the SSE connection with OpenHarness data part handling.
|
|
87
|
+
|
|
88
|
+
## Documentation
|
|
89
|
+
|
|
90
|
+
See the [full documentation](https://github.com/MaxGfeller/open-harness#readme) for server setup, middleware composition, and the complete streaming protocol.
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
ISC
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openharness/react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "React hooks and provider for OpenHarness AI SDK 5 integration",
|
|
6
6
|
"exports": {
|
|
@@ -10,22 +10,42 @@
|
|
|
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
|
-
"
|
|
18
|
+
"@openharness/core": "^0.4.4",
|
|
19
|
+
"react": "^18 || ~19.0.1 || ~19.1.2 || ^19.2.1"
|
|
19
20
|
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"ai": "^6.0.97"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/MaxGfeller/open-harness/tree/main/packages/react#readme",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/MaxGfeller/open-harness.git",
|
|
28
|
+
"directory": "packages/react"
|
|
29
|
+
},
|
|
30
|
+
"bugs": {
|
|
31
|
+
"url": "https://github.com/MaxGfeller/open-harness/issues"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"agent",
|
|
35
|
+
"ai",
|
|
36
|
+
"react",
|
|
37
|
+
"hooks",
|
|
38
|
+
"chat",
|
|
39
|
+
"openharness"
|
|
40
|
+
],
|
|
20
41
|
"devDependencies": {
|
|
21
42
|
"@ai-sdk/react": "^3.0.0",
|
|
22
43
|
"@testing-library/react": "^16.3.0",
|
|
23
44
|
"@types/react": "^19.0.0",
|
|
24
|
-
"ai": "^6.0.97",
|
|
25
45
|
"react": "^19.1.0",
|
|
26
46
|
"react-dom": "^19.1.0",
|
|
27
47
|
"typescript": "^5.9.3",
|
|
28
|
-
"@openharness/core": "0.
|
|
48
|
+
"@openharness/core": "0.4.4"
|
|
29
49
|
},
|
|
30
50
|
"license": "ISC",
|
|
31
51
|
"scripts": {
|