@openharness/core 0.4.1 → 0.4.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 +116 -0
  2. package/package.json +13 -2
package/README.md ADDED
@@ -0,0 +1,116 @@
1
+ # @openharness/core
2
+
3
+ Building blocks for capable, general-purpose AI agents. Part of [OpenHarness](https://github.com/MaxGfeller/open-harness).
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @openharness/core
9
+ ```
10
+
11
+ ## What's inside
12
+
13
+ - **Agent** -- stateless multi-step executor wrapping any AI SDK `LanguageModel` with tools, subagents, MCP, and skills
14
+ - **Session** -- batteries-included stateful wrapper with compaction, retry, persistence, and hooks
15
+ - **Runner & Middleware** -- composable FP-style middleware (`withRetry`, `withCompaction`, `withTurnTracking`, `withPersistence`, `withHooks`) for pick-and-choose behavior
16
+ - **Conversation** -- lightweight stateful wrapper over a composed Runner, with `toResponse()` for AI SDK 5 streaming
17
+ - **Stream combinators** -- `tap`, `filter`, `map`, `takeUntil` for async generator transforms
18
+ - **Tools** -- filesystem tools (`readFile`, `writeFile`, `editFile`, `listFiles`, `grep`, `deleteFile`) and a `bash` tool
19
+ - **UI streaming** -- `sessionEventsToUIStream()` maps agent events to AI SDK 5 `UIMessageChunk` streams
20
+
21
+ ## Quick start
22
+
23
+ ### Agent (stateless)
24
+
25
+ ```typescript
26
+ import { Agent } from "@openharness/core";
27
+ import { openai } from "@ai-sdk/openai";
28
+ import { fsTools } from "@openharness/core/tools/fs";
29
+ import { bash } from "@openharness/core/tools/bash";
30
+
31
+ const agent = new Agent({
32
+ name: "dev",
33
+ model: openai("gpt-5.2"),
34
+ tools: { ...fsTools, bash },
35
+ });
36
+
37
+ for await (const event of agent.run([], "Fix the auth bug")) {
38
+ if (event.type === "text.delta") process.stdout.write(event.text);
39
+ if (event.type === "done") console.log(event.result);
40
+ }
41
+ ```
42
+
43
+ ### Middleware + Conversation (composable)
44
+
45
+ ```typescript
46
+ import {
47
+ Agent, Conversation, toRunner, apply,
48
+ withTurnTracking, withCompaction, withRetry,
49
+ } from "@openharness/core";
50
+
51
+ const runner = apply(
52
+ toRunner(agent),
53
+ withTurnTracking(),
54
+ withCompaction({ contextWindow: 200_000, model: agent.model }),
55
+ withRetry(),
56
+ );
57
+
58
+ const chat = new Conversation({ runner });
59
+
60
+ for await (const event of chat.send("Refactor the config parser")) {
61
+ if (event.type === "text.delta") process.stdout.write(event.text);
62
+ }
63
+ ```
64
+
65
+ ### Session (batteries-included)
66
+
67
+ ```typescript
68
+ import { Session } from "@openharness/core";
69
+
70
+ const session = new Session({ agent, contextWindow: 200_000 });
71
+
72
+ for await (const event of session.send("Refactor the config parser")) {
73
+ if (event.type === "text.delta") process.stdout.write(event.text);
74
+ }
75
+ ```
76
+
77
+ ### Next.js route handler
78
+
79
+ ```typescript
80
+ import {
81
+ Agent, Conversation, toRunner, apply,
82
+ withTurnTracking, withCompaction, withRetry,
83
+ extractUserInput,
84
+ } from "@openharness/core";
85
+
86
+ const runner = apply(
87
+ toRunner(agent),
88
+ withTurnTracking(),
89
+ withCompaction({ contextWindow: 128_000, model: agent.model }),
90
+ withRetry(),
91
+ );
92
+
93
+ const chat = new Conversation({ runner });
94
+
95
+ export async function POST(req: Request) {
96
+ const { messages } = await req.json();
97
+ const input = await extractUserInput(messages);
98
+ return chat.toResponse(input);
99
+ }
100
+ ```
101
+
102
+ ## Documentation
103
+
104
+ See the [full documentation](https://github.com/MaxGfeller/open-harness#readme) for:
105
+
106
+ - Agent configuration, events, and lifecycle
107
+ - Subagents (foreground & background)
108
+ - Middleware reference and custom middleware
109
+ - Compaction strategies
110
+ - MCP server integration
111
+ - Skills system
112
+ - AI SDK 5 UI integration
113
+
114
+ ## License
115
+
116
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openharness/core",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "type": "module",
5
5
  "description": "Building blocks for capable, general-purpose agents",
6
6
  "exports": {
@@ -26,8 +26,19 @@
26
26
  "ai",
27
27
  "llm",
28
28
  "tools",
29
- "mcp"
29
+ "mcp",
30
+ "middleware",
31
+ "runner"
30
32
  ],
33
+ "homepage": "https://github.com/MaxGfeller/open-harness/tree/main/packages/core#readme",
34
+ "repository": {
35
+ "type": "git",
36
+ "url": "https://github.com/MaxGfeller/open-harness.git",
37
+ "directory": "packages/core"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/MaxGfeller/open-harness/issues"
41
+ },
31
42
  "license": "ISC",
32
43
  "dependencies": {
33
44
  "@ai-sdk/mcp": "^1.0.21",