@ekairos/story-react 1.22.34-beta.development.0 → 1.22.36-beta.development.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 +12 -57
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,80 +1,35 @@
1
1
  # @ekairos/story-react
2
2
 
3
- React primitives for Ekairos **Story** UIs.
3
+ React client primitives for Ekairos story/context UIs.
4
4
 
5
- This package ships the core client hook: **`useStory()`**.
5
+ ## Main hook
6
6
 
7
- ## Install
7
+ - `useStory()`
8
8
 
9
- ```bash
10
- pnpm add @ekairos/story-react
11
- ```
12
-
13
- ## What `useStory` does
9
+ ## What it gives you
14
10
 
15
- - **Timeline DX**: merges **persisted events** (InstantDB) + **optimistic user events** + **streaming assistant overlay**
16
- - **Streaming**: consumes `ai` UIMessage stream (SSE) and updates the timeline live
17
- - **Resumable streams (optional)**: stores `runId` + `chunkIndex` in `localStorage` and can resume with GET `?runId=...&startIndex=...`
11
+ - persisted timeline + optimistic overlay
12
+ - streaming assistant updates
13
+ - optional resumable streams
18
14
 
19
- ## Usage
15
+ ## Example
20
16
 
21
17
  ```tsx
22
18
  "use client";
23
19
 
24
20
  import { useStory } from "@ekairos/story-react";
25
21
 
26
- export function MyStoryUI({ db, apiUrl, contextId }: { db: any; apiUrl: string; contextId?: string }) {
22
+ export function StoryUI({ db, apiUrl, contextId }: { db: any; apiUrl: string; contextId?: string }) {
27
23
  const story = useStory(db, {
28
24
  apiUrl,
29
25
  initialContextId: contextId,
30
26
  enableResumableStreams: true,
31
- onContextUpdate: (id) => console.log("contextId:", id),
32
27
  });
33
28
 
34
29
  return (
35
- <div>
36
- <pre>status: {story.contextStatus}</pre>
37
- <button
38
- disabled={story.sendStatus === "submitting"}
39
- onClick={() => story.append({ parts: [{ type: "text", text: "Hola" }] })}
40
- >
41
- Send
42
- </button>
43
- <pre>{JSON.stringify(story.events, null, 2)}</pre>
44
- </div>
30
+ <button onClick={() => story.append({ parts: [{ type: "text", text: "Hola" }] })}>
31
+ Send
32
+ </button>
45
33
  );
46
34
  }
47
35
  ```
48
-
49
- ## Default InstantDB queries (overrideable)
50
-
51
- By default, `useStory` expects these namespaces:
52
-
53
- - `context_contexts` (by `id`)
54
- - `context_events` (by `context.id`, ordered by `createdAt: "asc"`)
55
-
56
- If your schema differs, pass overrides (they MUST be hooks):
57
-
58
- ```ts
59
- useStory(db, {
60
- apiUrl,
61
- context: (db, { contextId }) => {
62
- const res = db.useQuery(/* your query */);
63
- return { context: res.data?...., contextStatus: "open" };
64
- },
65
- events: (db, { contextId }) => {
66
- const res = db.useQuery(/* your query */);
67
- return { events: res.data?.... ?? [] };
68
- },
69
- });
70
- ```
71
-
72
- ## API contract (server)
73
-
74
- `useStory` sends:
75
-
76
- - `POST apiUrl` with JSON `{ messages: [uiMessage], webSearch, reasoningLevel, contextId }`
77
- - `GET apiUrl?runId=...&startIndex=...` (only if `enableResumableStreams` is enabled)
78
-
79
- The server must respond with an `ai` SSE stream (`createUIMessageStreamResponse`).
80
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ekairos/story-react",
3
- "version": "1.22.34-beta.development.0",
3
+ "version": "1.22.36-beta.development.0",
4
4
  "description": "Ekairos Story React - useStory hook",
5
5
  "type": "commonjs",
6
6
  "main": "dist/index.js",