@free-intelligence/core 1.1.0 → 1.1.1

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 +55 -0
  2. package/package.json +1 -1
package/README.md ADDED
@@ -0,0 +1,55 @@
1
+ # @free-intelligence/core
2
+
3
+ The **framework-agnostic contract layer** for Free Intelligence chat & agent
4
+ frontends. Pure TypeScript — no React, no DOM, no styling. It defines the
5
+ events a streaming agent emits and the reducers that fold them into UI state,
6
+ so any view layer (fi-glass, or your own) consumes one stable contract.
7
+
8
+ `@free-intelligence/core` is the data spine; [`fi-glass`](https://www.npmjs.com/package/fi-glass)
9
+ is the glassmorphism skin built on top of it.
10
+
11
+ ## What's inside
12
+
13
+ | Export | What it is |
14
+ |---|---|
15
+ | `AgentStreamEvent` | The discriminated union an agent stream emits: `open`, `plan`, `step_started`, `step_done`, `tool_call`, `text`, `result`, `error`, `done` (+ plan lifecycle). |
16
+ | `applyAgentEvent` | Pure reducer: `(state, event) → state`. Folds a stream into an `AgentTurnState` (live text, plan checklist, tool calls, sources). |
17
+ | `initialAgentTurnState` | The empty turn state to seed the reducer. |
18
+ | `AgentHook` | The transport interface a consumer implements: `{ turn, isStreaming, send, reset, abort }`. |
19
+ | `ChatMessage`, `ConversationSummary` | Plain message / conversation shapes shared across the surface. |
20
+ | conversation helpers | Pure helpers for building and merging conversation transcripts. |
21
+
22
+ ## Install
23
+
24
+ ```bash
25
+ npm install @free-intelligence/core
26
+ # or, with the matching UI:
27
+ npm install @free-intelligence/core fi-glass
28
+ ```
29
+
30
+ ## Usage
31
+
32
+ Implement a transport that maps your backend's stream onto `AgentStreamEvent`,
33
+ then fold it with the reducer:
34
+
35
+ ```ts
36
+ import {
37
+ applyAgentEvent,
38
+ initialAgentTurnState,
39
+ type AgentStreamEvent,
40
+ } from '@free-intelligence/core';
41
+
42
+ let state = initialAgentTurnState();
43
+ for await (const raw of yourSSEStream()) {
44
+ const event: AgentStreamEvent | null = mapToCore(raw); // your wire → core
45
+ if (event) state = applyAgentEvent(state, event); // pure, testable
46
+ }
47
+ ```
48
+
49
+ The reducer is pure and has no side effects, so it's trivial to unit-test and
50
+ to drive any rendering layer. `fi-glass`'s `useAgentConversation` wraps exactly
51
+ this contract.
52
+
53
+ ## License
54
+
55
+ See [LICENSE](./LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@free-intelligence/core",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "license": "PolyForm-Noncommercial-1.0.0",
5
5
  "type": "module",
6
6
  "description": "Material-agnostic substrate-facing layer: theme-token contract, agent event contract, fi-runner client. Consumed directly by apps and by every fi-<material> skin.",