@stll/chat 0.5.1 → 0.6.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.
- package/dist/durable-transport.d.ts +13 -0
- package/dist/durable-transport.js +14 -9
- package/package.json +6 -6
|
@@ -35,6 +35,19 @@ type DurableChatTransportOptions<TMessages extends UIMessage[]> = {
|
|
|
35
35
|
now?: () => number;
|
|
36
36
|
wait?: typeof waitForReconnect;
|
|
37
37
|
};
|
|
38
|
+
type TerminalChatResponseOptions = {
|
|
39
|
+
runId: string;
|
|
40
|
+
resume?: Extract<ChatTurnResumeProbe, {
|
|
41
|
+
type: "transcript";
|
|
42
|
+
}>["resumeSnapshot"];
|
|
43
|
+
onTranscript: () => void;
|
|
44
|
+
onReconnectChange: (reconnecting: boolean) => void;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* A stream that only ends run `runId`: what a client reads when the turn's
|
|
48
|
+
* live stream is not the place to follow it, and the stored thread is.
|
|
49
|
+
*/
|
|
50
|
+
export declare const finishedChatRunResponse: (runId: string, resume?: TerminalChatResponseOptions["resume"]) => Response;
|
|
38
51
|
/** Shared by hosts: cache no legal text or run pointer on the device. The
|
|
39
52
|
* SDK's persistence contract restores its run from the authenticated server. */
|
|
40
53
|
export declare const createDurableChatTransport: <TMessages extends UIMessage[]>({ initialMessages, initialTurn, threadId, probe, joinUrl, sendUrl, fetchClient, onReconnectChange, onTranscript, onError, random, now, wait }: DurableChatTransportOptions<TMessages>) => {
|
|
@@ -38,17 +38,22 @@ const loadedTurnNeedsRefresh = (loaded, transcript) => {
|
|
|
38
38
|
default: return panic(loaded);
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* A stream that only ends run `runId`: what a client reads when the turn's
|
|
43
|
+
* live stream is not the place to follow it, and the stored thread is.
|
|
44
|
+
*/
|
|
45
|
+
const finishedChatRunResponse = (runId, resume) => new Response(`data: ${JSON.stringify({
|
|
46
|
+
type: "RUN_FINISHED",
|
|
47
|
+
runId,
|
|
48
|
+
...resume?.pendingInterrupts !== void 0 ? { outcome: {
|
|
49
|
+
type: "interrupt",
|
|
50
|
+
interrupts: resume.pendingInterrupts
|
|
51
|
+
} } : {}
|
|
52
|
+
})}\n\n`, { headers: { "Content-Type": "text/event-stream" } });
|
|
41
53
|
const terminalChatResponse = ({ runId, resume, onTranscript, onReconnectChange }) => {
|
|
42
54
|
onTranscript();
|
|
43
55
|
onReconnectChange(false);
|
|
44
|
-
return
|
|
45
|
-
type: "RUN_FINISHED",
|
|
46
|
-
runId,
|
|
47
|
-
...resume?.pendingInterrupts !== void 0 ? { outcome: {
|
|
48
|
-
type: "interrupt",
|
|
49
|
-
interrupts: resume.pendingInterrupts
|
|
50
|
-
} } : {}
|
|
51
|
-
})}\n\n`, { headers: { "Content-Type": "text/event-stream" } });
|
|
56
|
+
return finishedChatRunResponse(runId, resume);
|
|
52
57
|
};
|
|
53
58
|
const createChatResumePersistence = ({ initialMessages, initialTurn, probe, onReconnectChange, onTranscript, onError, random, now, wait }) => {
|
|
54
59
|
let initialTurnState = initialTurn;
|
|
@@ -239,4 +244,4 @@ const createDurableChatTransport = ({ initialMessages, initialTurn, threadId, pr
|
|
|
239
244
|
persistence
|
|
240
245
|
};
|
|
241
246
|
};
|
|
242
|
-
export { ChatReconnectError, createDurableChatTransport };
|
|
247
|
+
export { ChatReconnectError, createDurableChatTransport, finishedChatRunResponse };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/chat",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Typed React chat composer, message stream, model selector, and transport runtime primitives.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ai",
|
|
@@ -90,22 +90,22 @@
|
|
|
90
90
|
},
|
|
91
91
|
"dependencies": {
|
|
92
92
|
"@ag-ui/core": "1.0.4",
|
|
93
|
-
"@stll/ai-catalog": "^0.
|
|
93
|
+
"@stll/ai-catalog": "^0.15.0",
|
|
94
94
|
"@stll/html": "0.1.2",
|
|
95
|
-
"@stll/ui": "^0.
|
|
95
|
+
"@stll/ui": "^0.75.0",
|
|
96
96
|
"@tanstack/ai-client": "1.1.0",
|
|
97
97
|
"@types/hast": "^3.0.5",
|
|
98
98
|
"better-result": "3.0.1",
|
|
99
99
|
"linkify-it": "6.1.0",
|
|
100
|
-
"tldts": "7.4.
|
|
100
|
+
"tldts": "7.4.21",
|
|
101
101
|
"valibot": "1.5.0",
|
|
102
102
|
"zod": "^4.6.6"
|
|
103
103
|
},
|
|
104
104
|
"devDependencies": {
|
|
105
105
|
"@stll/property-testing": "0.0.0",
|
|
106
106
|
"@stll/typescript-config": "0.0.0",
|
|
107
|
-
"@tiptap/core": "^3.33.
|
|
108
|
-
"@tiptap/pm": "^3.33.
|
|
107
|
+
"@tiptap/core": "^3.33.1",
|
|
108
|
+
"@tiptap/pm": "^3.33.1",
|
|
109
109
|
"@types/react": "^19.3.0",
|
|
110
110
|
"bun-types": "1.4.4",
|
|
111
111
|
"fast-check": "^4.10.2",
|