@starcite/react 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/LICENSE +201 -0
- package/README.md +86 -0
- package/dist/chat-protocol.cjs +202 -0
- package/dist/chat-protocol.cjs.map +1 -0
- package/dist/chat-protocol.d.cts +48 -0
- package/dist/chat-protocol.d.ts +48 -0
- package/dist/chat-protocol.js +21 -0
- package/dist/chat-protocol.js.map +1 -0
- package/dist/chunk-QG237Z3K.js +171 -0
- package/dist/chunk-QG237Z3K.js.map +1 -0
- package/dist/index.cjs +383 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +29 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.js +214 -0
- package/dist/index.js.map +1 -0
- package/package.json +71 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# @starcite/react
|
|
2
|
+
|
|
3
|
+
React-first chat hook for a single durable Starcite session.
|
|
4
|
+
|
|
5
|
+
This package replaces AI SDK `useChat` wiring for Starcite-backed chats while
|
|
6
|
+
keeping a familiar surface:
|
|
7
|
+
|
|
8
|
+
- `messages`
|
|
9
|
+
- `sendMessage`
|
|
10
|
+
- `status`
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @starcite/react @starcite/sdk ai react
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```tsx
|
|
21
|
+
import { Starcite } from "@starcite/sdk";
|
|
22
|
+
import { useStarciteChat } from "@starcite/react";
|
|
23
|
+
|
|
24
|
+
const starcite = new Starcite({
|
|
25
|
+
baseUrl: process.env.NEXT_PUBLIC_STARCITE_BASE_URL,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export function Chat({ token }: { token: string }) {
|
|
29
|
+
const session = starcite.session({ token });
|
|
30
|
+
|
|
31
|
+
const { messages, sendMessage, status } = useStarciteChat({
|
|
32
|
+
session,
|
|
33
|
+
id: session.id,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<form
|
|
38
|
+
onSubmit={(event) => {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
void sendMessage({ text: "hello" });
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<button type="submit">Send</button>
|
|
44
|
+
<p>Status: {status}</p>
|
|
45
|
+
<pre>{JSON.stringify(messages, null, 2)}</pre>
|
|
46
|
+
</form>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Hook Options
|
|
52
|
+
|
|
53
|
+
- `session` (required): session scoped to the active session token.
|
|
54
|
+
- `id` (optional): reset key for when you swap sessions; defaults to `session.id`.
|
|
55
|
+
- `userMessageSource` (optional, default `"use-chat"`): source string for user append events.
|
|
56
|
+
- `onError` (optional): callback for append/projection/subscription failures.
|
|
57
|
+
|
|
58
|
+
## Behavior
|
|
59
|
+
|
|
60
|
+
- Uses `session.events()` as the durable source of truth for chat state.
|
|
61
|
+
- Subscribes with `session.on("event", ...)` and only consumes:
|
|
62
|
+
- `chat.user.message`
|
|
63
|
+
- `chat.assistant.chunk`
|
|
64
|
+
- Appends outgoing user messages as strict chat envelopes.
|
|
65
|
+
- Rebuilds `UIMessage[]` from durable events whenever new chat events arrive.
|
|
66
|
+
|
|
67
|
+
## Exports
|
|
68
|
+
|
|
69
|
+
- `useStarciteChat`
|
|
70
|
+
- `UseStarciteChatOptions`
|
|
71
|
+
- `UseStarciteChatResult`
|
|
72
|
+
- `SendMessageInput`
|
|
73
|
+
- `StarciteChatSession`
|
|
74
|
+
|
|
75
|
+
### Chat Protocol Helpers
|
|
76
|
+
|
|
77
|
+
Import from `@starcite/react/chat-protocol` when you need chat envelope helpers
|
|
78
|
+
for server agents or custom transports:
|
|
79
|
+
|
|
80
|
+
- `chatUserMessageEventType`
|
|
81
|
+
- `chatAssistantChunkEventType`
|
|
82
|
+
- `createUserMessageEnvelope(...)`
|
|
83
|
+
- `createAssistantChunkEnvelope(...)`
|
|
84
|
+
- `parseChatPayloadEnvelope(...)`
|
|
85
|
+
- `appendUserMessageEvent(...)`
|
|
86
|
+
- `appendAssistantChunkEvent(...)`
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/chat-protocol.ts
|
|
21
|
+
var chat_protocol_exports = {};
|
|
22
|
+
__export(chat_protocol_exports, {
|
|
23
|
+
appendAssistantChunkEvent: () => appendAssistantChunkEvent,
|
|
24
|
+
appendUserMessageEvent: () => appendUserMessageEvent,
|
|
25
|
+
chatAssistantChunkEventType: () => chatAssistantChunkEventType,
|
|
26
|
+
chatUserMessageEventType: () => chatUserMessageEventType,
|
|
27
|
+
createAssistantChunkEnvelope: () => createAssistantChunkEnvelope,
|
|
28
|
+
createUserMessageEnvelope: () => createUserMessageEnvelope,
|
|
29
|
+
parseChatPayloadEnvelope: () => parseChatPayloadEnvelope,
|
|
30
|
+
toUIMessagesFromEvents: () => toUIMessagesFromEvents
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(chat_protocol_exports);
|
|
33
|
+
var import_ai = require("ai");
|
|
34
|
+
var chatUserMessageEventType = "chat.user.message";
|
|
35
|
+
var chatAssistantChunkEventType = "chat.assistant.chunk";
|
|
36
|
+
function isChatEventType(type) {
|
|
37
|
+
return type === chatUserMessageEventType || type === chatAssistantChunkEventType;
|
|
38
|
+
}
|
|
39
|
+
function isRecord(value) {
|
|
40
|
+
return typeof value === "object" && value !== null;
|
|
41
|
+
}
|
|
42
|
+
function parseUserEnvelope(payload) {
|
|
43
|
+
const message = payload.message;
|
|
44
|
+
if (!isRecord(message)) {
|
|
45
|
+
throw new Error("Invalid chat payload envelope: missing message");
|
|
46
|
+
}
|
|
47
|
+
const role = message.role;
|
|
48
|
+
const parts = message.parts;
|
|
49
|
+
if (role !== "system" && role !== "user" && role !== "assistant") {
|
|
50
|
+
throw new Error("Invalid chat payload envelope: invalid message role");
|
|
51
|
+
}
|
|
52
|
+
if (!Array.isArray(parts)) {
|
|
53
|
+
throw new Error("Invalid chat payload envelope: invalid message parts");
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
...payload,
|
|
57
|
+
kind: chatUserMessageEventType,
|
|
58
|
+
message: {
|
|
59
|
+
...message,
|
|
60
|
+
role,
|
|
61
|
+
parts
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function parseAssistantEnvelope(payload) {
|
|
66
|
+
const chunk = payload.chunk;
|
|
67
|
+
if (!isRecord(chunk)) {
|
|
68
|
+
throw new Error("Invalid chat payload envelope: missing chunk");
|
|
69
|
+
}
|
|
70
|
+
const type = chunk.type;
|
|
71
|
+
if (typeof type !== "string" || type.length === 0) {
|
|
72
|
+
throw new Error("Invalid chat payload envelope: invalid chunk type");
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...payload,
|
|
76
|
+
kind: chatAssistantChunkEventType,
|
|
77
|
+
chunk: {
|
|
78
|
+
...chunk,
|
|
79
|
+
type
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function createUserMessageEnvelope(message) {
|
|
84
|
+
return {
|
|
85
|
+
kind: chatUserMessageEventType,
|
|
86
|
+
message
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
function createAssistantChunkEnvelope(chunk) {
|
|
90
|
+
return {
|
|
91
|
+
kind: chatAssistantChunkEventType,
|
|
92
|
+
chunk
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function parseChatPayloadEnvelope(payload) {
|
|
96
|
+
if (!isRecord(payload)) {
|
|
97
|
+
throw new Error("Invalid chat payload envelope: payload must be an object");
|
|
98
|
+
}
|
|
99
|
+
const kind = payload.kind;
|
|
100
|
+
if (kind === chatUserMessageEventType) {
|
|
101
|
+
return parseUserEnvelope(payload);
|
|
102
|
+
}
|
|
103
|
+
if (kind === chatAssistantChunkEventType) {
|
|
104
|
+
return parseAssistantEnvelope(payload);
|
|
105
|
+
}
|
|
106
|
+
throw new Error("Invalid chat payload envelope: unknown kind");
|
|
107
|
+
}
|
|
108
|
+
function appendUserMessageEvent(session, message, options = {}) {
|
|
109
|
+
return session.append({
|
|
110
|
+
type: chatUserMessageEventType,
|
|
111
|
+
source: options.source ?? "use-chat",
|
|
112
|
+
payload: createUserMessageEnvelope(message)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
function appendAssistantChunkEvent(session, chunk, options = {}) {
|
|
116
|
+
return session.append({
|
|
117
|
+
type: chatAssistantChunkEventType,
|
|
118
|
+
source: options.source ?? "openai",
|
|
119
|
+
payload: createAssistantChunkEnvelope(chunk)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
async function buildChunkMessages(chunks) {
|
|
123
|
+
if (chunks.length === 0) {
|
|
124
|
+
return [];
|
|
125
|
+
}
|
|
126
|
+
const messageIds = [];
|
|
127
|
+
const latestById = /* @__PURE__ */ new Map();
|
|
128
|
+
let index = 0;
|
|
129
|
+
const stream = new ReadableStream({
|
|
130
|
+
pull(controller) {
|
|
131
|
+
const chunk = chunks[index];
|
|
132
|
+
if (!chunk) {
|
|
133
|
+
controller.close();
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
controller.enqueue(chunk);
|
|
137
|
+
index += 1;
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
try {
|
|
141
|
+
for await (const message of (0, import_ai.readUIMessageStream)({
|
|
142
|
+
stream,
|
|
143
|
+
terminateOnError: false
|
|
144
|
+
})) {
|
|
145
|
+
if (!latestById.has(message.id)) {
|
|
146
|
+
messageIds.push(message.id);
|
|
147
|
+
}
|
|
148
|
+
latestById.set(message.id, message);
|
|
149
|
+
}
|
|
150
|
+
} catch {
|
|
151
|
+
}
|
|
152
|
+
const messages = [];
|
|
153
|
+
for (const messageId of messageIds) {
|
|
154
|
+
const message = latestById.get(messageId);
|
|
155
|
+
if (message) {
|
|
156
|
+
messages.push(message);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return messages;
|
|
160
|
+
}
|
|
161
|
+
async function toUIMessagesFromEvents(events) {
|
|
162
|
+
const messages = [];
|
|
163
|
+
const bufferedChunks = [];
|
|
164
|
+
const flushBufferedChunks = async () => {
|
|
165
|
+
if (bufferedChunks.length === 0) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
messages.push(...await buildChunkMessages(bufferedChunks));
|
|
169
|
+
bufferedChunks.length = 0;
|
|
170
|
+
};
|
|
171
|
+
for (const event of events) {
|
|
172
|
+
if (!isChatEventType(event.type)) {
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
let envelope;
|
|
176
|
+
try {
|
|
177
|
+
envelope = parseChatPayloadEnvelope(event.payload);
|
|
178
|
+
} catch {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (envelope.kind === chatUserMessageEventType) {
|
|
182
|
+
await flushBufferedChunks();
|
|
183
|
+
messages.push(envelope.message);
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
bufferedChunks.push(envelope.chunk);
|
|
187
|
+
}
|
|
188
|
+
await flushBufferedChunks();
|
|
189
|
+
return messages;
|
|
190
|
+
}
|
|
191
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
192
|
+
0 && (module.exports = {
|
|
193
|
+
appendAssistantChunkEvent,
|
|
194
|
+
appendUserMessageEvent,
|
|
195
|
+
chatAssistantChunkEventType,
|
|
196
|
+
chatUserMessageEventType,
|
|
197
|
+
createAssistantChunkEnvelope,
|
|
198
|
+
createUserMessageEnvelope,
|
|
199
|
+
parseChatPayloadEnvelope,
|
|
200
|
+
toUIMessagesFromEvents
|
|
201
|
+
});
|
|
202
|
+
//# sourceMappingURL=chat-protocol.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/chat-protocol.ts"],"sourcesContent":["import type { AppendResult, SessionAppendInput } from \"@starcite/sdk\";\nimport { readUIMessageStream, type UIMessage, type UIMessageChunk } from \"ai\";\n\nexport const chatUserMessageEventType = \"chat.user.message\";\nexport const chatAssistantChunkEventType = \"chat.assistant.chunk\";\n\ntype ChatRole = \"system\" | \"user\" | \"assistant\";\n\ninterface ChatUserMessagePayload {\n role: ChatRole;\n parts: unknown[];\n [key: string]: unknown;\n}\n\ninterface ChatAssistantChunkPayload {\n type: string;\n [key: string]: unknown;\n}\n\nexport type ChatPayloadEnvelope =\n | {\n kind: typeof chatUserMessageEventType;\n message: ChatUserMessagePayload;\n [key: string]: unknown;\n }\n | {\n kind: typeof chatAssistantChunkEventType;\n chunk: ChatAssistantChunkPayload;\n [key: string]: unknown;\n };\n\ninterface SessionAppender {\n append: (input: SessionAppendInput) => Promise<AppendResult>;\n}\n\nfunction isChatEventType(type: string): boolean {\n return (\n type === chatUserMessageEventType || type === chatAssistantChunkEventType\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null;\n}\n\nfunction parseUserEnvelope(\n payload: Record<string, unknown>\n): ChatPayloadEnvelope {\n const message = payload.message;\n if (!isRecord(message)) {\n throw new Error(\"Invalid chat payload envelope: missing message\");\n }\n\n const role = message.role;\n const parts = message.parts;\n\n if (role !== \"system\" && role !== \"user\" && role !== \"assistant\") {\n throw new Error(\"Invalid chat payload envelope: invalid message role\");\n }\n\n if (!Array.isArray(parts)) {\n throw new Error(\"Invalid chat payload envelope: invalid message parts\");\n }\n\n return {\n ...payload,\n kind: chatUserMessageEventType,\n message: {\n ...message,\n role,\n parts,\n },\n };\n}\n\nfunction parseAssistantEnvelope(\n payload: Record<string, unknown>\n): ChatPayloadEnvelope {\n const chunk = payload.chunk;\n if (!isRecord(chunk)) {\n throw new Error(\"Invalid chat payload envelope: missing chunk\");\n }\n\n const type = chunk.type;\n if (typeof type !== \"string\" || type.length === 0) {\n throw new Error(\"Invalid chat payload envelope: invalid chunk type\");\n }\n\n return {\n ...payload,\n kind: chatAssistantChunkEventType,\n chunk: {\n ...chunk,\n type,\n },\n };\n}\n\nexport function createUserMessageEnvelope<\n TMessage extends Record<string, unknown>,\n>(\n message: TMessage\n): {\n kind: typeof chatUserMessageEventType;\n message: TMessage;\n} {\n return {\n kind: chatUserMessageEventType,\n message,\n };\n}\n\nexport function createAssistantChunkEnvelope<\n TChunk extends Record<string, unknown>,\n>(\n chunk: TChunk\n): {\n kind: typeof chatAssistantChunkEventType;\n chunk: TChunk;\n} {\n return {\n kind: chatAssistantChunkEventType,\n chunk,\n };\n}\n\nexport function parseChatPayloadEnvelope(\n payload: unknown\n): ChatPayloadEnvelope {\n if (!isRecord(payload)) {\n throw new Error(\"Invalid chat payload envelope: payload must be an object\");\n }\n\n const kind = payload.kind;\n if (kind === chatUserMessageEventType) {\n return parseUserEnvelope(payload);\n }\n\n if (kind === chatAssistantChunkEventType) {\n return parseAssistantEnvelope(payload);\n }\n\n throw new Error(\"Invalid chat payload envelope: unknown kind\");\n}\n\nexport function appendUserMessageEvent(\n session: SessionAppender,\n message: Record<string, unknown>,\n options: { source?: string } = {}\n): Promise<AppendResult> {\n return session.append({\n type: chatUserMessageEventType,\n source: options.source ?? \"use-chat\",\n payload: createUserMessageEnvelope(message),\n });\n}\n\nexport function appendAssistantChunkEvent(\n session: SessionAppender,\n chunk: Record<string, unknown>,\n options: { source?: string } = {}\n): Promise<AppendResult> {\n return session.append({\n type: chatAssistantChunkEventType,\n source: options.source ?? \"openai\",\n payload: createAssistantChunkEnvelope(chunk),\n });\n}\n\nasync function buildChunkMessages(\n chunks: readonly UIMessageChunk[]\n): Promise<UIMessage[]> {\n if (chunks.length === 0) {\n return [];\n }\n\n const messageIds: string[] = [];\n const latestById = new Map<string, UIMessage>();\n let index = 0;\n\n const stream = new ReadableStream<UIMessageChunk>({\n pull(controller) {\n const chunk = chunks[index];\n if (!chunk) {\n controller.close();\n return;\n }\n\n controller.enqueue(chunk);\n index += 1;\n },\n });\n\n try {\n for await (const message of readUIMessageStream({\n stream,\n terminateOnError: false,\n })) {\n if (!latestById.has(message.id)) {\n messageIds.push(message.id);\n }\n\n latestById.set(message.id, message);\n }\n } catch {\n // Best effort: keep messages emitted before malformed chunk sequences.\n }\n\n const messages: UIMessage[] = [];\n for (const messageId of messageIds) {\n const message = latestById.get(messageId);\n if (message) {\n messages.push(message);\n }\n }\n\n return messages;\n}\n\nexport async function toUIMessagesFromEvents(\n events: readonly { type: string; payload: unknown }[]\n): Promise<UIMessage[]> {\n const messages: UIMessage[] = [];\n const bufferedChunks: UIMessageChunk[] = [];\n\n const flushBufferedChunks = async (): Promise<void> => {\n if (bufferedChunks.length === 0) {\n return;\n }\n\n messages.push(...(await buildChunkMessages(bufferedChunks)));\n bufferedChunks.length = 0;\n };\n\n for (const event of events) {\n if (!isChatEventType(event.type)) {\n continue;\n }\n\n let envelope: ChatPayloadEnvelope;\n try {\n envelope = parseChatPayloadEnvelope(event.payload);\n } catch {\n // Skip malformed chat payloads and continue projecting the rest.\n continue;\n }\n\n if (envelope.kind === chatUserMessageEventType) {\n await flushBufferedChunks();\n messages.push(envelope.message as unknown as UIMessage);\n continue;\n }\n\n bufferedChunks.push(envelope.chunk as unknown as UIMessageChunk);\n }\n\n await flushBufferedChunks();\n return messages;\n}\n"],"mappings":"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","names":[]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SessionAppendInput, AppendResult } from '@starcite/sdk';
|
|
2
|
+
import { UIMessage } from 'ai';
|
|
3
|
+
|
|
4
|
+
declare const chatUserMessageEventType = "chat.user.message";
|
|
5
|
+
declare const chatAssistantChunkEventType = "chat.assistant.chunk";
|
|
6
|
+
type ChatRole = "system" | "user" | "assistant";
|
|
7
|
+
interface ChatUserMessagePayload {
|
|
8
|
+
role: ChatRole;
|
|
9
|
+
parts: unknown[];
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface ChatAssistantChunkPayload {
|
|
13
|
+
type: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
type ChatPayloadEnvelope = {
|
|
17
|
+
kind: typeof chatUserMessageEventType;
|
|
18
|
+
message: ChatUserMessagePayload;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
} | {
|
|
21
|
+
kind: typeof chatAssistantChunkEventType;
|
|
22
|
+
chunk: ChatAssistantChunkPayload;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
interface SessionAppender {
|
|
26
|
+
append: (input: SessionAppendInput) => Promise<AppendResult>;
|
|
27
|
+
}
|
|
28
|
+
declare function createUserMessageEnvelope<TMessage extends Record<string, unknown>>(message: TMessage): {
|
|
29
|
+
kind: typeof chatUserMessageEventType;
|
|
30
|
+
message: TMessage;
|
|
31
|
+
};
|
|
32
|
+
declare function createAssistantChunkEnvelope<TChunk extends Record<string, unknown>>(chunk: TChunk): {
|
|
33
|
+
kind: typeof chatAssistantChunkEventType;
|
|
34
|
+
chunk: TChunk;
|
|
35
|
+
};
|
|
36
|
+
declare function parseChatPayloadEnvelope(payload: unknown): ChatPayloadEnvelope;
|
|
37
|
+
declare function appendUserMessageEvent(session: SessionAppender, message: Record<string, unknown>, options?: {
|
|
38
|
+
source?: string;
|
|
39
|
+
}): Promise<AppendResult>;
|
|
40
|
+
declare function appendAssistantChunkEvent(session: SessionAppender, chunk: Record<string, unknown>, options?: {
|
|
41
|
+
source?: string;
|
|
42
|
+
}): Promise<AppendResult>;
|
|
43
|
+
declare function toUIMessagesFromEvents(events: readonly {
|
|
44
|
+
type: string;
|
|
45
|
+
payload: unknown;
|
|
46
|
+
}[]): Promise<UIMessage[]>;
|
|
47
|
+
|
|
48
|
+
export { type ChatPayloadEnvelope, appendAssistantChunkEvent, appendUserMessageEvent, chatAssistantChunkEventType, chatUserMessageEventType, createAssistantChunkEnvelope, createUserMessageEnvelope, parseChatPayloadEnvelope, toUIMessagesFromEvents };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SessionAppendInput, AppendResult } from '@starcite/sdk';
|
|
2
|
+
import { UIMessage } from 'ai';
|
|
3
|
+
|
|
4
|
+
declare const chatUserMessageEventType = "chat.user.message";
|
|
5
|
+
declare const chatAssistantChunkEventType = "chat.assistant.chunk";
|
|
6
|
+
type ChatRole = "system" | "user" | "assistant";
|
|
7
|
+
interface ChatUserMessagePayload {
|
|
8
|
+
role: ChatRole;
|
|
9
|
+
parts: unknown[];
|
|
10
|
+
[key: string]: unknown;
|
|
11
|
+
}
|
|
12
|
+
interface ChatAssistantChunkPayload {
|
|
13
|
+
type: string;
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
type ChatPayloadEnvelope = {
|
|
17
|
+
kind: typeof chatUserMessageEventType;
|
|
18
|
+
message: ChatUserMessagePayload;
|
|
19
|
+
[key: string]: unknown;
|
|
20
|
+
} | {
|
|
21
|
+
kind: typeof chatAssistantChunkEventType;
|
|
22
|
+
chunk: ChatAssistantChunkPayload;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
};
|
|
25
|
+
interface SessionAppender {
|
|
26
|
+
append: (input: SessionAppendInput) => Promise<AppendResult>;
|
|
27
|
+
}
|
|
28
|
+
declare function createUserMessageEnvelope<TMessage extends Record<string, unknown>>(message: TMessage): {
|
|
29
|
+
kind: typeof chatUserMessageEventType;
|
|
30
|
+
message: TMessage;
|
|
31
|
+
};
|
|
32
|
+
declare function createAssistantChunkEnvelope<TChunk extends Record<string, unknown>>(chunk: TChunk): {
|
|
33
|
+
kind: typeof chatAssistantChunkEventType;
|
|
34
|
+
chunk: TChunk;
|
|
35
|
+
};
|
|
36
|
+
declare function parseChatPayloadEnvelope(payload: unknown): ChatPayloadEnvelope;
|
|
37
|
+
declare function appendUserMessageEvent(session: SessionAppender, message: Record<string, unknown>, options?: {
|
|
38
|
+
source?: string;
|
|
39
|
+
}): Promise<AppendResult>;
|
|
40
|
+
declare function appendAssistantChunkEvent(session: SessionAppender, chunk: Record<string, unknown>, options?: {
|
|
41
|
+
source?: string;
|
|
42
|
+
}): Promise<AppendResult>;
|
|
43
|
+
declare function toUIMessagesFromEvents(events: readonly {
|
|
44
|
+
type: string;
|
|
45
|
+
payload: unknown;
|
|
46
|
+
}[]): Promise<UIMessage[]>;
|
|
47
|
+
|
|
48
|
+
export { type ChatPayloadEnvelope, appendAssistantChunkEvent, appendUserMessageEvent, chatAssistantChunkEventType, chatUserMessageEventType, createAssistantChunkEnvelope, createUserMessageEnvelope, parseChatPayloadEnvelope, toUIMessagesFromEvents };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {
|
|
2
|
+
appendAssistantChunkEvent,
|
|
3
|
+
appendUserMessageEvent,
|
|
4
|
+
chatAssistantChunkEventType,
|
|
5
|
+
chatUserMessageEventType,
|
|
6
|
+
createAssistantChunkEnvelope,
|
|
7
|
+
createUserMessageEnvelope,
|
|
8
|
+
parseChatPayloadEnvelope,
|
|
9
|
+
toUIMessagesFromEvents
|
|
10
|
+
} from "./chunk-QG237Z3K.js";
|
|
11
|
+
export {
|
|
12
|
+
appendAssistantChunkEvent,
|
|
13
|
+
appendUserMessageEvent,
|
|
14
|
+
chatAssistantChunkEventType,
|
|
15
|
+
chatUserMessageEventType,
|
|
16
|
+
createAssistantChunkEnvelope,
|
|
17
|
+
createUserMessageEnvelope,
|
|
18
|
+
parseChatPayloadEnvelope,
|
|
19
|
+
toUIMessagesFromEvents
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=chat-protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|