@starcite/sdk 0.0.6 → 0.0.7
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 +15 -15
- package/dist/index.cjs +357 -144
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -83
- package/dist/index.d.ts +137 -83
- package/dist/index.js +355 -141
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ The SDK normalizes the API URL to `/v1` automatically.
|
|
|
23
23
|
|
|
24
24
|
- `Starcite`: tenant-scoped client
|
|
25
25
|
- `StarciteIdentity`: `user` or `agent` principal tied to tenant
|
|
26
|
-
- `StarciteSession`: session-scoped handle for append/tail/
|
|
26
|
+
- `StarciteSession`: session-scoped handle for append/tail/live-sync
|
|
27
27
|
|
|
28
28
|
The key split:
|
|
29
29
|
|
|
@@ -39,16 +39,15 @@ This is the practical shape teams end up using in production.
|
|
|
39
39
|
Use the identity flow. This creates or binds a session and mints a session token.
|
|
40
40
|
|
|
41
41
|
```ts
|
|
42
|
-
import {
|
|
42
|
+
import { MemoryStore, Starcite } from "@starcite/sdk";
|
|
43
43
|
|
|
44
44
|
const starcite = new Starcite({
|
|
45
45
|
baseUrl: process.env.STARCITE_BASE_URL,
|
|
46
46
|
apiKey: process.env.STARCITE_API_KEY,
|
|
47
|
+
// Use a durable SessionStore in production.
|
|
48
|
+
store: new MemoryStore(),
|
|
47
49
|
});
|
|
48
50
|
|
|
49
|
-
// Use a persistent store in production
|
|
50
|
-
const cursorStore = new InMemoryCursorStore();
|
|
51
|
-
|
|
52
51
|
export async function runPlanner(prompt: string, sessionId?: string) {
|
|
53
52
|
const planner = starcite.agent({ id: "planner" });
|
|
54
53
|
|
|
@@ -61,17 +60,17 @@ export async function runPlanner(prompt: string, sessionId?: string) {
|
|
|
61
60
|
|
|
62
61
|
await session.append({ text: `Planning started: ${prompt}` });
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
},
|
|
63
|
+
const stop = session.on("event", async (event, context) => {
|
|
64
|
+
if (context.replayed) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (event.type === "content") {
|
|
68
|
+
// Your business logic here.
|
|
69
|
+
}
|
|
72
70
|
});
|
|
73
71
|
|
|
74
72
|
await session.append({ text: "Planning complete." });
|
|
73
|
+
stop();
|
|
75
74
|
|
|
76
75
|
return {
|
|
77
76
|
sessionId: session.id,
|
|
@@ -215,7 +214,7 @@ const starcite = new Starcite({
|
|
|
215
214
|
authUrl: process.env.STARCITE_AUTH_URL, // overrides iss-derived auth URL for token minting
|
|
216
215
|
fetch: globalThis.fetch,
|
|
217
216
|
websocketFactory: (url) => new WebSocket(url),
|
|
218
|
-
store: new MemoryStore(), // cursor + event persistence
|
|
217
|
+
store: new MemoryStore(), // cursor + event persistence
|
|
219
218
|
});
|
|
220
219
|
|
|
221
220
|
// WebSocketFactory — simplified, auth is always in access_token query string.
|
|
@@ -295,7 +294,8 @@ This is designed for robust reconnect + resume semantics in long-running multi-a
|
|
|
295
294
|
`new Starcite({ store })` accepts a `SessionStore` for cursor + retained-event
|
|
296
295
|
persistence across session rebinds.
|
|
297
296
|
|
|
298
|
-
-
|
|
297
|
+
- No default store is configured. When omitted, startup catch-up replays from
|
|
298
|
+
stream cursor `0`.
|
|
299
299
|
- Bring your own by implementing:
|
|
300
300
|
- `load(sessionId)`
|
|
301
301
|
- `save(sessionId, { cursor, events })`
|