@assistant-ui/react 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- package/package.json +6 -15
- package/dist/AssistantRuntime-BM_jVV3g.d.mts +0 -23
- package/dist/AssistantRuntime-CBMSAJqH.d.mts +0 -23
- package/dist/AssistantRuntime-C_BvM7ZT.d.ts +0 -23
- package/dist/AssistantRuntime-DELpXWfG.d.ts +0 -23
- package/dist/ModelConfigTypes-B9UY4zxv.d.mts +0 -55
- package/dist/ModelConfigTypes-B9UY4zxv.d.ts +0 -55
- package/dist/ModelConfigTypes-BF5HxVrH.d.mts +0 -55
- package/dist/ModelConfigTypes-BF5HxVrH.d.ts +0 -55
- package/dist/ModelConfigTypes-Cf3yjaDu.d.mts +0 -55
- package/dist/ModelConfigTypes-Cf3yjaDu.d.ts +0 -55
- package/dist/ModelConfigTypes-CzmXY3sn.d.mts +0 -55
- package/dist/ModelConfigTypes-CzmXY3sn.d.ts +0 -55
- package/dist/Thread-BMASJT4a.d.ts +0 -15
- package/dist/Thread-UEVsUmvl.d.mts +0 -15
- package/dist/chunk-3XZUKECF.mjs +0 -207
- package/dist/chunk-3XZUKECF.mjs.map +0 -1
- package/dist/chunk-4DQ2CIAD.mjs +0 -69
- package/dist/chunk-4DQ2CIAD.mjs.map +0 -1
- package/dist/chunk-5YONSDN4.mjs +0 -200
- package/dist/chunk-5YONSDN4.mjs.map +0 -1
- package/dist/chunk-CY4TTHR7.mjs +0 -76
- package/dist/chunk-CY4TTHR7.mjs.map +0 -1
- package/dist/chunk-DKAWDNW5.mjs +0 -22
- package/dist/chunk-DKAWDNW5.mjs.map +0 -1
- package/dist/chunk-GQKH2ADD.mjs +0 -165
- package/dist/chunk-GQKH2ADD.mjs.map +0 -1
- package/dist/chunk-J5LGTIGS.mjs +0 -10
- package/dist/chunk-J5LGTIGS.mjs.map +0 -1
- package/dist/chunk-NSBOH42A.mjs +0 -200
- package/dist/chunk-NSBOH42A.mjs.map +0 -1
- package/dist/chunk-X4HBDEFP.mjs +0 -30
- package/dist/chunk-X4HBDEFP.mjs.map +0 -1
- package/dist/experimental.d.mts +0 -86
- package/dist/experimental.d.ts +0 -86
- package/dist/experimental.js +0 -123
- package/dist/experimental.js.map +0 -1
- package/dist/experimental.mjs +0 -34
- package/dist/experimental.mjs.map +0 -1
- package/dist/index.d.mts +0 -289
- package/dist/index.d.ts +0 -289
- package/dist/index.js +0 -1500
- package/dist/index.js.map +0 -1
- package/dist/index.mjs +0 -1245
- package/dist/index.mjs.map +0 -1
- package/dist/internal-dlLjX30u.d.mts +0 -75
- package/dist/internal-dlLjX30u.d.ts +0 -75
- package/dist/internal.d.mts +0 -25
- package/dist/internal.d.ts +0 -25
- package/dist/internal.js +0 -225
- package/dist/internal.js.map +0 -1
- package/dist/internal.mjs +0 -10
- package/dist/internal.mjs.map +0 -1
package/dist/chunk-3XZUKECF.mjs
DELETED
@@ -1,207 +0,0 @@
|
|
1
|
-
var __defProp = Object.defineProperty;
|
2
|
-
var __export = (target, all) => {
|
3
|
-
for (var name in all)
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
5
|
-
};
|
6
|
-
|
7
|
-
// src/utils/ModelConfigTypes.ts
|
8
|
-
var mergeModelConfigs = (configs) => {
|
9
|
-
return configs.reduce((acc, config) => {
|
10
|
-
if (config.system) {
|
11
|
-
if (acc.system) {
|
12
|
-
acc.system += `
|
13
|
-
|
14
|
-
${config.system}`;
|
15
|
-
} else {
|
16
|
-
acc.system = config.system;
|
17
|
-
}
|
18
|
-
}
|
19
|
-
if (config.tools) {
|
20
|
-
acc.tools = { ...acc.tools, ...config.tools };
|
21
|
-
}
|
22
|
-
return acc;
|
23
|
-
}, {});
|
24
|
-
};
|
25
|
-
|
26
|
-
// src/utils/ProxyConfigProvider.ts
|
27
|
-
var ProxyConfigProvider = class {
|
28
|
-
_providers = /* @__PURE__ */ new Set();
|
29
|
-
getModelConfig() {
|
30
|
-
return mergeModelConfigs([...this._providers].map((p) => p()));
|
31
|
-
}
|
32
|
-
registerModelConfigProvider(provider) {
|
33
|
-
this._providers.add(provider);
|
34
|
-
return () => {
|
35
|
-
this._providers.delete(provider);
|
36
|
-
};
|
37
|
-
}
|
38
|
-
};
|
39
|
-
|
40
|
-
// src/runtime/utils/idUtils.tsx
|
41
|
-
import { customAlphabet } from "nanoid/non-secure";
|
42
|
-
var generateId = customAlphabet(
|
43
|
-
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
44
|
-
7
|
45
|
-
);
|
46
|
-
var optimisticPrefix = "__optimistic__";
|
47
|
-
var generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;
|
48
|
-
|
49
|
-
// src/runtime/utils/MessageRepository.tsx
|
50
|
-
var findHead = (message) => {
|
51
|
-
if (message.next) return findHead(message.next);
|
52
|
-
return message;
|
53
|
-
};
|
54
|
-
var MessageRepository = class {
|
55
|
-
messages = /* @__PURE__ */ new Map();
|
56
|
-
// message_id -> item
|
57
|
-
head = null;
|
58
|
-
root = {
|
59
|
-
children: []
|
60
|
-
};
|
61
|
-
performOp(newParent, child, operation) {
|
62
|
-
const parentOrRoot = child.prev ?? this.root;
|
63
|
-
const newParentOrRoot = newParent ?? this.root;
|
64
|
-
if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
|
65
|
-
if (operation !== "link") {
|
66
|
-
parentOrRoot.children = parentOrRoot.children.filter(
|
67
|
-
(m) => m !== child.current.id
|
68
|
-
);
|
69
|
-
if (child.prev?.next === child) {
|
70
|
-
const fallbackId = child.prev.children.at(-1);
|
71
|
-
const fallback = fallbackId ? this.messages.get(fallbackId) : null;
|
72
|
-
if (fallback === void 0) {
|
73
|
-
throw new Error(
|
74
|
-
"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui."
|
75
|
-
);
|
76
|
-
}
|
77
|
-
child.prev.next = fallback;
|
78
|
-
}
|
79
|
-
}
|
80
|
-
if (operation !== "cut") {
|
81
|
-
newParentOrRoot.children = [
|
82
|
-
...newParentOrRoot.children,
|
83
|
-
child.current.id
|
84
|
-
];
|
85
|
-
if (newParent && (findHead(child) === this.head || newParent.next === null)) {
|
86
|
-
newParent.next = child;
|
87
|
-
}
|
88
|
-
child.prev = newParent;
|
89
|
-
}
|
90
|
-
}
|
91
|
-
getMessages() {
|
92
|
-
const messages = new Array(this.head?.level ?? 0);
|
93
|
-
for (let current = this.head; current; current = current.prev) {
|
94
|
-
messages[current.level] = current.current;
|
95
|
-
}
|
96
|
-
return messages;
|
97
|
-
}
|
98
|
-
addOrUpdateMessage(parentId, message) {
|
99
|
-
const existingItem = this.messages.get(message.id);
|
100
|
-
const prev = parentId ? this.messages.get(parentId) : null;
|
101
|
-
if (prev === void 0)
|
102
|
-
throw new Error(
|
103
|
-
"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui."
|
104
|
-
);
|
105
|
-
if (existingItem) {
|
106
|
-
existingItem.current = message;
|
107
|
-
this.performOp(prev, existingItem, "relink");
|
108
|
-
return;
|
109
|
-
}
|
110
|
-
const newItem = {
|
111
|
-
prev,
|
112
|
-
current: message,
|
113
|
-
next: null,
|
114
|
-
children: [],
|
115
|
-
level: prev ? prev.level + 1 : 0
|
116
|
-
};
|
117
|
-
this.messages.set(message.id, newItem);
|
118
|
-
this.performOp(prev, newItem, "link");
|
119
|
-
if (this.head === prev) {
|
120
|
-
this.head = newItem;
|
121
|
-
}
|
122
|
-
}
|
123
|
-
appendOptimisticMessage(parentId, message) {
|
124
|
-
let optimisticId;
|
125
|
-
do {
|
126
|
-
optimisticId = generateOptimisticId();
|
127
|
-
} while (this.messages.has(optimisticId));
|
128
|
-
this.addOrUpdateMessage(parentId, {
|
129
|
-
...message,
|
130
|
-
id: optimisticId,
|
131
|
-
createdAt: /* @__PURE__ */ new Date(),
|
132
|
-
...message.role === "assistant" ? { status: "in_progress" } : void 0
|
133
|
-
});
|
134
|
-
return optimisticId;
|
135
|
-
}
|
136
|
-
deleteMessage(messageId, replacementId) {
|
137
|
-
const message = this.messages.get(messageId);
|
138
|
-
if (!message)
|
139
|
-
throw new Error(
|
140
|
-
"MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui."
|
141
|
-
);
|
142
|
-
const replacement = replacementId === void 0 ? message.prev : replacementId === null ? null : this.messages.get(replacementId);
|
143
|
-
if (replacement === void 0)
|
144
|
-
throw new Error(
|
145
|
-
"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui."
|
146
|
-
);
|
147
|
-
for (const child of message.children) {
|
148
|
-
const childMessage = this.messages.get(child);
|
149
|
-
if (!childMessage)
|
150
|
-
throw new Error(
|
151
|
-
"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui."
|
152
|
-
);
|
153
|
-
this.performOp(replacement, childMessage, "relink");
|
154
|
-
}
|
155
|
-
this.performOp(null, message, "cut");
|
156
|
-
this.messages.delete(messageId);
|
157
|
-
if (this.head === message) {
|
158
|
-
this.head = replacement ? findHead(replacement) : null;
|
159
|
-
}
|
160
|
-
}
|
161
|
-
getBranches(messageId) {
|
162
|
-
const message = this.messages.get(messageId);
|
163
|
-
if (!message)
|
164
|
-
throw new Error(
|
165
|
-
"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
|
166
|
-
);
|
167
|
-
const { children } = message.prev ?? this.root;
|
168
|
-
return children;
|
169
|
-
}
|
170
|
-
switchToBranch(messageId) {
|
171
|
-
const message = this.messages.get(messageId);
|
172
|
-
if (!message)
|
173
|
-
throw new Error(
|
174
|
-
"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui."
|
175
|
-
);
|
176
|
-
if (message.prev) {
|
177
|
-
message.prev.next = message;
|
178
|
-
}
|
179
|
-
this.head = findHead(message);
|
180
|
-
}
|
181
|
-
resetHead(messageId) {
|
182
|
-
if (messageId === null) {
|
183
|
-
this.head = null;
|
184
|
-
return;
|
185
|
-
}
|
186
|
-
const message = this.messages.get(messageId);
|
187
|
-
if (!message)
|
188
|
-
throw new Error(
|
189
|
-
"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui."
|
190
|
-
);
|
191
|
-
this.head = message;
|
192
|
-
for (let current = message; current; current = current.prev) {
|
193
|
-
if (current.prev) {
|
194
|
-
current.prev.next = current;
|
195
|
-
}
|
196
|
-
}
|
197
|
-
}
|
198
|
-
};
|
199
|
-
|
200
|
-
export {
|
201
|
-
__export,
|
202
|
-
mergeModelConfigs,
|
203
|
-
generateId,
|
204
|
-
MessageRepository,
|
205
|
-
ProxyConfigProvider
|
206
|
-
};
|
207
|
-
//# sourceMappingURL=chunk-3XZUKECF.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/utils/ModelConfigTypes.ts","../src/utils/ProxyConfigProvider.ts","../src/runtime/utils/idUtils.tsx","../src/runtime/utils/MessageRepository.tsx"],"sourcesContent":["\"use client\";\nimport type { z } from \"zod\";\n\nexport type Tool<TArgs> = {\n description: string;\n parameters: z.ZodSchema<TArgs>;\n execute: (args: TArgs) => unknown; // TODO return type\n};\n\nexport type ModelConfig = {\n system?: string;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n tools?: Record<string, Tool<any>>;\n};\n\nexport type ModelConfigProvider = () => ModelConfig;\n\nexport const mergeModelConfigs = (configs: ModelConfig[]): ModelConfig => {\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n acc.tools = { ...acc.tools, ...config.tools };\n }\n return acc;\n }, {} as ModelConfig);\n};\n","\"use client\";\nimport {\n type ModelConfigProvider,\n mergeModelConfigs,\n} from \"./ModelConfigTypes\";\n\nexport class ProxyConfigProvider {\n private _providers = new Set<ModelConfigProvider>();\n\n getModelConfig() {\n return mergeModelConfigs([...this._providers].map((p) => p()));\n }\n\n registerModelConfigProvider(provider: ModelConfigProvider) {\n this._providers.add(provider);\n return () => {\n this._providers.delete(provider);\n };\n }\n}\n","import { customAlphabet } from \"nanoid/non-secure\";\n\nexport const generateId = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n);\n\nconst optimisticPrefix = \"__optimistic__\";\nexport const generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;\nexport const isOptimisticId = (id: string) => id.startsWith(optimisticPrefix);\n","import type { ThreadMessage } from \"../../utils/AssistantTypes\";\nimport { generateOptimisticId } from \"./idUtils\";\n\ntype RepositoryParent = {\n children: string[];\n};\n\ntype RepositoryMessage = RepositoryParent & {\n prev: RepositoryMessage | null;\n current: ThreadMessage;\n next: RepositoryMessage | null;\n level: number;\n};\n\nconst findHead = (message: RepositoryMessage): RepositoryMessage => {\n if (message.next) return findHead(message.next);\n return message;\n};\n\nexport class MessageRepository {\n private messages = new Map<string, RepositoryMessage>(); // message_id -> item\n private head: RepositoryMessage | null = null;\n private root: RepositoryParent = {\n children: [],\n };\n\n private performOp(\n newParent: RepositoryMessage | null,\n child: RepositoryMessage,\n operation: \"cut\" | \"link\" | \"relink\",\n ) {\n const parentOrRoot = child.prev ?? this.root;\n const newParentOrRoot = newParent ?? this.root;\n\n if (operation === \"relink\" && parentOrRoot === newParentOrRoot) return;\n\n // cut\n if (operation !== \"link\") {\n parentOrRoot.children = parentOrRoot.children.filter(\n (m) => m !== child.current.id,\n );\n\n if (child.prev?.next === child) {\n const fallbackId = child.prev.children.at(-1);\n const fallback = fallbackId ? this.messages.get(fallbackId) : null;\n if (fallback === undefined) {\n throw new Error(\n \"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.\",\n );\n }\n child.prev.next = fallback;\n }\n }\n\n // link\n if (operation !== \"cut\") {\n newParentOrRoot.children = [\n ...newParentOrRoot.children,\n child.current.id,\n ];\n\n if (\n newParent &&\n (findHead(child) === this.head || newParent.next === null)\n ) {\n newParent.next = child;\n }\n\n child.prev = newParent;\n }\n }\n getMessages() {\n const messages = new Array<ThreadMessage>(this.head?.level ?? 0);\n for (let current = this.head; current; current = current.prev) {\n messages[current.level] = current.current;\n }\n return messages;\n }\n\n addOrUpdateMessage(parentId: string | null, message: ThreadMessage) {\n const existingItem = this.messages.get(message.id);\n const prev = parentId ? this.messages.get(parentId) : null;\n if (prev === undefined)\n throw new Error(\n \"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n // update existing message\n if (existingItem) {\n existingItem.current = message;\n this.performOp(prev, existingItem, \"relink\");\n return;\n }\n\n // create a new message\n const newItem: RepositoryMessage = {\n prev,\n current: message,\n next: null,\n children: [],\n level: prev ? prev.level + 1 : 0,\n };\n\n this.messages.set(message.id, newItem);\n this.performOp(prev, newItem, \"link\");\n\n if (this.head === prev) {\n this.head = newItem;\n }\n }\n\n appendOptimisticMessage(\n parentId: string | null,\n message: Omit<ThreadMessage, \"id\" | \"createdAt\">,\n ) {\n let optimisticId: string;\n do {\n optimisticId = generateOptimisticId();\n } while (this.messages.has(optimisticId));\n\n this.addOrUpdateMessage(parentId, {\n ...message,\n id: optimisticId,\n createdAt: new Date(),\n ...(message.role === \"assistant\" ? { status: \"in_progress\" } : undefined),\n } as ThreadMessage);\n\n return optimisticId;\n }\n\n deleteMessage(messageId: string, replacementId?: string | null | undefined) {\n const message = this.messages.get(messageId);\n\n if (!message)\n throw new Error(\n \"MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const replacement =\n replacementId === undefined\n ? message.prev // if no replacementId is provided, use the parent\n : replacementId === null\n ? null\n : this.messages.get(replacementId);\n if (replacement === undefined)\n throw new Error(\n \"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.\",\n );\n\n for (const child of message.children) {\n const childMessage = this.messages.get(child);\n if (!childMessage)\n throw new Error(\n \"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.\",\n );\n this.performOp(replacement, childMessage, \"relink\");\n }\n\n this.performOp(null, message, \"cut\");\n this.messages.delete(messageId);\n\n if (this.head === message) {\n this.head = replacement ? findHead(replacement) : null;\n }\n }\n\n getBranches(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const { children } = message.prev ?? this.root;\n return children;\n }\n\n switchToBranch(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n if (message.prev) {\n message.prev.next = message;\n }\n\n this.head = findHead(message);\n }\n\n resetHead(messageId: string | null) {\n if (messageId === null) {\n this.head = null;\n return;\n }\n\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n this.head = message;\n for (\n let current: RepositoryMessage | null = message;\n current;\n current = current.prev\n ) {\n if (current.prev) {\n current.prev.next = current;\n }\n }\n }\n}\n"],"mappings":";;;;;;;AAiBO,IAAM,oBAAoB,CAAC,YAAwC;AACxE,SAAO,QAAQ,OAAO,CAAC,KAAK,WAAW;AACrC,QAAI,OAAO,QAAQ;AACjB,UAAI,IAAI,QAAQ;AAEd,YAAI,UAAU;AAAA;AAAA,EAAO,OAAO,MAAM;AAAA,MACpC,OAAO;AACL,YAAI,SAAS,OAAO;AAAA,MACtB;AAAA,IACF;AACA,QAAI,OAAO,OAAO;AAChB,UAAI,QAAQ,EAAE,GAAG,IAAI,OAAO,GAAG,OAAO,MAAM;AAAA,IAC9C;AACA,WAAO;AAAA,EACT,GAAG,CAAC,CAAgB;AACtB;;;AC1BO,IAAM,sBAAN,MAA0B;AAAA,EACvB,aAAa,oBAAI,IAAyB;AAAA,EAElD,iBAAiB;AACf,WAAO,kBAAkB,CAAC,GAAG,KAAK,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAAA,EAC/D;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ACA,UAAI,QAAQ,MAAM;AAChB,gBAAQ,KAAK,OAAO;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/chunk-4DQ2CIAD.mjs
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
// src/context/MessageContext.ts
|
2
|
-
import { createContext, useContext } from "react";
|
3
|
-
var MessageContext = createContext(null);
|
4
|
-
var useMessageContext = () => {
|
5
|
-
const context = useContext(MessageContext);
|
6
|
-
if (!context)
|
7
|
-
throw new Error(
|
8
|
-
"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
|
9
|
-
);
|
10
|
-
return context;
|
11
|
-
};
|
12
|
-
|
13
|
-
// src/context/ThreadContext.ts
|
14
|
-
import { createContext as createContext2, useContext as useContext2 } from "react";
|
15
|
-
var ThreadContext = createContext2(null);
|
16
|
-
var useThreadContext = () => {
|
17
|
-
const context = useContext2(ThreadContext);
|
18
|
-
if (!context)
|
19
|
-
throw new Error("This component must be used within an AssistantRuntimeProvider.");
|
20
|
-
return context;
|
21
|
-
};
|
22
|
-
|
23
|
-
// src/context/ComposerContext.ts
|
24
|
-
import { useContext as useContext3, useMemo } from "react";
|
25
|
-
var useComposerContext = () => {
|
26
|
-
const { useComposer } = useThreadContext();
|
27
|
-
const { useComposer: useEditComposer } = useContext3(MessageContext) ?? {};
|
28
|
-
return useMemo(
|
29
|
-
() => ({
|
30
|
-
useComposer: useEditComposer ?? useComposer,
|
31
|
-
type: useEditComposer ? "edit" : "new"
|
32
|
-
}),
|
33
|
-
[useEditComposer, useComposer]
|
34
|
-
);
|
35
|
-
};
|
36
|
-
|
37
|
-
// src/context/ContentPartContext.ts
|
38
|
-
import { createContext as createContext3, useContext as useContext4 } from "react";
|
39
|
-
var ContentPartContext = createContext3(
|
40
|
-
null
|
41
|
-
);
|
42
|
-
var useContentPartContext = () => {
|
43
|
-
const context = useContext4(ContentPartContext);
|
44
|
-
if (!context)
|
45
|
-
throw new Error(
|
46
|
-
"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
|
47
|
-
);
|
48
|
-
return context;
|
49
|
-
};
|
50
|
-
|
51
|
-
// src/context/stores/BaseComposer.ts
|
52
|
-
var makeBaseComposer = (set) => ({
|
53
|
-
value: "",
|
54
|
-
setValue: (value) => {
|
55
|
-
set({ value });
|
56
|
-
}
|
57
|
-
});
|
58
|
-
|
59
|
-
export {
|
60
|
-
MessageContext,
|
61
|
-
useMessageContext,
|
62
|
-
ThreadContext,
|
63
|
-
useThreadContext,
|
64
|
-
makeBaseComposer,
|
65
|
-
useComposerContext,
|
66
|
-
ContentPartContext,
|
67
|
-
useContentPartContext
|
68
|
-
};
|
69
|
-
//# sourceMappingURL=chunk-4DQ2CIAD.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/context/MessageContext.ts","../src/context/ThreadContext.ts","../src/context/ComposerContext.ts","../src/context/ContentPartContext.ts","../src/context/stores/BaseComposer.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { MessageState } from \"./stores/Message\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type MessageContextValue = {\n useMessage: UseBoundStore<StoreApi<MessageState>>;\n useComposer: UseBoundStore<StoreApi<EditComposerState>>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nexport const useMessageContext = () => {\n const context = useContext(MessageContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { ThreadState } from \"./stores/Thread\";\nimport type { ThreadViewportState } from \"./stores/ThreadViewport\";\n\nexport type ThreadContextValue = {\n useThread: UseBoundStore<StoreApi<ThreadState>>;\n useComposer: UseBoundStore<StoreApi<ComposerState>>;\n useViewport: UseBoundStore<StoreApi<ThreadViewportState>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nexport const useThreadContext = (): ThreadContextValue => {\n const context = useContext(ThreadContext);\n if (!context)\n throw new Error(\"This component must be used within an AssistantRuntimeProvider.\");\n return context;\n};\n","import { useContext, useMemo } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport { MessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type ComposerContextValue = {\n useComposer: UseBoundStore<StoreApi<EditComposerState | ComposerState>>;\n type: \"edit\" | \"new\";\n};\n\nexport const useComposerContext = (): ComposerContextValue => {\n const { useComposer } = useThreadContext();\n const { useComposer: useEditComposer } = useContext(MessageContext) ?? {};\n return useMemo(\n () => ({\n useComposer: (useEditComposer ?? useComposer) as UseBoundStore<\n StoreApi<EditComposerState | ComposerState>\n >,\n type: useEditComposer ? (\"edit\" as const) : (\"new\" as const),\n }),\n [useEditComposer, useComposer],\n );\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ContentPartState } from \"./stores/ContentPart\";\n\nexport type ContentPartContextValue = {\n useContentPart: UseBoundStore<StoreApi<ContentPartState>>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nexport const useContentPartContext = (): ContentPartContextValue => {\n const context = useContext(ContentPartContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >.\",\n );\n return context;\n};\n","import type { StateCreator } from \"zustand\";\n\nexport type BaseComposerState = Readonly<{\n value: string;\n setValue: (value: string) => void;\n}>;\n\nexport const makeBaseComposer: StateCreator<\n BaseComposerState,\n [],\n [],\n BaseComposerState\n> = (set) => ({\n value: \"\",\n setValue: (value) => {\n set({ value });\n },\n});\n"],"mappings":";AAAA,SAAS,eAAe,kBAAkB;AAUnC,IAAM,iBAAiB,cAA0C,IAAI;AAErE,IAAM,oBAAoB,MAAM;AACrC,QAAM,UAAU,WAAW,cAAc;AACzC,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACnBA,SAAS,iBAAAA,gBAAe,cAAAC,mBAAkB;AAYnC,IAAM,gBAAgBD,eAAyC,IAAI;AAEnE,IAAM,mBAAmB,MAA0B;AACxD,QAAM,UAAUC,YAAW,aAAa;AACxC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,iEAAiE;AACnF,SAAO;AACT;;;ACnBA,SAAS,cAAAC,aAAY,eAAe;AAY7B,IAAM,qBAAqB,MAA4B;AAC5D,QAAM,EAAE,YAAY,IAAI,iBAAiB;AACzC,QAAM,EAAE,aAAa,gBAAgB,IAAIC,YAAW,cAAc,KAAK,CAAC;AACxE,SAAO;AAAA,IACL,OAAO;AAAA,MACL,aAAc,mBAAmB;AAAA,MAGjC,MAAM,kBAAmB,SAAoB;AAAA,IAC/C;AAAA,IACA,CAAC,iBAAiB,WAAW;AAAA,EAC/B;AACF;;;ACxBA,SAAS,iBAAAC,gBAAe,cAAAC,mBAAkB;AAQnC,IAAM,qBAAqBD;AAAA,EAChC;AACF;AAEO,IAAM,wBAAwB,MAA+B;AAClE,QAAM,UAAUC,YAAW,kBAAkB;AAC7C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACZO,IAAM,mBAKT,CAAC,SAAS;AAAA,EACZ,OAAO;AAAA,EACP,UAAU,CAAC,UAAU;AACnB,QAAI,EAAE,MAAM,CAAC;AAAA,EACf;AACF;","names":["createContext","useContext","useContext","useContext","createContext","useContext"]}
|
package/dist/chunk-5YONSDN4.mjs
DELETED
@@ -1,200 +0,0 @@
|
|
1
|
-
// src/utils/ModelConfigTypes.ts
|
2
|
-
var mergeModelConfigs = (configs) => {
|
3
|
-
return configs.reduce((acc, config) => {
|
4
|
-
if (config.system) {
|
5
|
-
if (acc.system) {
|
6
|
-
acc.system += `
|
7
|
-
|
8
|
-
${config.system}`;
|
9
|
-
} else {
|
10
|
-
acc.system = config.system;
|
11
|
-
}
|
12
|
-
}
|
13
|
-
if (config.tools) {
|
14
|
-
acc.tools = { ...acc.tools, ...config.tools };
|
15
|
-
}
|
16
|
-
return acc;
|
17
|
-
}, {});
|
18
|
-
};
|
19
|
-
|
20
|
-
// src/utils/ProxyConfigProvider.ts
|
21
|
-
var ProxyConfigProvider = class {
|
22
|
-
_providers = /* @__PURE__ */ new Set();
|
23
|
-
getModelConfig() {
|
24
|
-
return mergeModelConfigs([...this._providers].map((p) => p()));
|
25
|
-
}
|
26
|
-
registerModelConfigProvider(provider) {
|
27
|
-
this._providers.add(provider);
|
28
|
-
return () => {
|
29
|
-
this._providers.delete(provider);
|
30
|
-
};
|
31
|
-
}
|
32
|
-
};
|
33
|
-
|
34
|
-
// src/runtime/utils/idUtils.tsx
|
35
|
-
import { customAlphabet } from "nanoid/non-secure";
|
36
|
-
var generateId = customAlphabet(
|
37
|
-
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
38
|
-
7
|
39
|
-
);
|
40
|
-
var optimisticPrefix = "__optimistic__";
|
41
|
-
var generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;
|
42
|
-
|
43
|
-
// src/runtime/utils/MessageRepository.tsx
|
44
|
-
var findHead = (message) => {
|
45
|
-
if (message.next) return findHead(message.next);
|
46
|
-
return message;
|
47
|
-
};
|
48
|
-
var MessageRepository = class {
|
49
|
-
messages = /* @__PURE__ */ new Map();
|
50
|
-
// message_id -> item
|
51
|
-
head = null;
|
52
|
-
root = {
|
53
|
-
children: []
|
54
|
-
};
|
55
|
-
performOp(newParent, child, operation) {
|
56
|
-
const parentOrRoot = child.prev ?? this.root;
|
57
|
-
const newParentOrRoot = newParent ?? this.root;
|
58
|
-
if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
|
59
|
-
if (operation !== "link") {
|
60
|
-
parentOrRoot.children = parentOrRoot.children.filter(
|
61
|
-
(m) => m !== child.current.id
|
62
|
-
);
|
63
|
-
if (child.prev?.next === child) {
|
64
|
-
const fallbackId = child.prev.children.at(-1);
|
65
|
-
const fallback = fallbackId ? this.messages.get(fallbackId) : null;
|
66
|
-
if (fallback === void 0) {
|
67
|
-
throw new Error(
|
68
|
-
"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui."
|
69
|
-
);
|
70
|
-
}
|
71
|
-
child.prev.next = fallback;
|
72
|
-
}
|
73
|
-
}
|
74
|
-
if (operation !== "cut") {
|
75
|
-
newParentOrRoot.children = [
|
76
|
-
...newParentOrRoot.children,
|
77
|
-
child.current.id
|
78
|
-
];
|
79
|
-
if (newParent && (findHead(child) === this.head || newParent.next === null)) {
|
80
|
-
newParent.next = child;
|
81
|
-
}
|
82
|
-
child.prev = newParent;
|
83
|
-
}
|
84
|
-
}
|
85
|
-
getMessages() {
|
86
|
-
const messages = new Array(this.head?.level ?? 0);
|
87
|
-
for (let current = this.head; current; current = current.prev) {
|
88
|
-
messages[current.level] = current.current;
|
89
|
-
}
|
90
|
-
return messages;
|
91
|
-
}
|
92
|
-
addOrUpdateMessage(parentId, message) {
|
93
|
-
const existingItem = this.messages.get(message.id);
|
94
|
-
const prev = parentId ? this.messages.get(parentId) : null;
|
95
|
-
if (prev === void 0)
|
96
|
-
throw new Error(
|
97
|
-
"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui."
|
98
|
-
);
|
99
|
-
if (existingItem) {
|
100
|
-
existingItem.current = message;
|
101
|
-
this.performOp(prev, existingItem, "relink");
|
102
|
-
return;
|
103
|
-
}
|
104
|
-
const newItem = {
|
105
|
-
prev,
|
106
|
-
current: message,
|
107
|
-
next: null,
|
108
|
-
children: [],
|
109
|
-
level: prev ? prev.level + 1 : 0
|
110
|
-
};
|
111
|
-
this.messages.set(message.id, newItem);
|
112
|
-
this.performOp(prev, newItem, "link");
|
113
|
-
if (this.head === prev) {
|
114
|
-
this.head = newItem;
|
115
|
-
}
|
116
|
-
}
|
117
|
-
appendOptimisticMessage(parentId, message) {
|
118
|
-
let optimisticId;
|
119
|
-
do {
|
120
|
-
optimisticId = generateOptimisticId();
|
121
|
-
} while (this.messages.has(optimisticId));
|
122
|
-
this.addOrUpdateMessage(parentId, {
|
123
|
-
...message,
|
124
|
-
id: optimisticId,
|
125
|
-
createdAt: /* @__PURE__ */ new Date(),
|
126
|
-
...message.role === "assistant" ? { status: "in_progress" } : void 0
|
127
|
-
});
|
128
|
-
return optimisticId;
|
129
|
-
}
|
130
|
-
deleteMessage(messageId, replacementId) {
|
131
|
-
const message = this.messages.get(messageId);
|
132
|
-
if (!message)
|
133
|
-
throw new Error(
|
134
|
-
"MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui."
|
135
|
-
);
|
136
|
-
const replacement = replacementId === void 0 ? message.prev : replacementId === null ? null : this.messages.get(replacementId);
|
137
|
-
if (replacement === void 0)
|
138
|
-
throw new Error(
|
139
|
-
"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui."
|
140
|
-
);
|
141
|
-
for (const child of message.children) {
|
142
|
-
const childMessage = this.messages.get(child);
|
143
|
-
if (!childMessage)
|
144
|
-
throw new Error(
|
145
|
-
"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui."
|
146
|
-
);
|
147
|
-
this.performOp(replacement, childMessage, "relink");
|
148
|
-
}
|
149
|
-
this.performOp(null, message, "cut");
|
150
|
-
this.messages.delete(messageId);
|
151
|
-
if (this.head === message) {
|
152
|
-
this.head = replacement ? findHead(replacement) : null;
|
153
|
-
}
|
154
|
-
}
|
155
|
-
getBranches(messageId) {
|
156
|
-
const message = this.messages.get(messageId);
|
157
|
-
if (!message)
|
158
|
-
throw new Error(
|
159
|
-
"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
|
160
|
-
);
|
161
|
-
const { children } = message.prev ?? this.root;
|
162
|
-
return children;
|
163
|
-
}
|
164
|
-
switchToBranch(messageId) {
|
165
|
-
const message = this.messages.get(messageId);
|
166
|
-
if (!message)
|
167
|
-
throw new Error(
|
168
|
-
"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui."
|
169
|
-
);
|
170
|
-
if (message.prev) {
|
171
|
-
message.prev.next = message;
|
172
|
-
}
|
173
|
-
this.head = findHead(message);
|
174
|
-
}
|
175
|
-
resetHead(messageId) {
|
176
|
-
if (messageId === null) {
|
177
|
-
this.head = null;
|
178
|
-
return;
|
179
|
-
}
|
180
|
-
const message = this.messages.get(messageId);
|
181
|
-
if (!message)
|
182
|
-
throw new Error(
|
183
|
-
"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui."
|
184
|
-
);
|
185
|
-
this.head = message;
|
186
|
-
for (let current = message; current; current = current.prev) {
|
187
|
-
if (current.prev) {
|
188
|
-
current.prev.next = current;
|
189
|
-
}
|
190
|
-
}
|
191
|
-
}
|
192
|
-
};
|
193
|
-
|
194
|
-
export {
|
195
|
-
mergeModelConfigs,
|
196
|
-
ProxyConfigProvider,
|
197
|
-
generateId,
|
198
|
-
MessageRepository
|
199
|
-
};
|
200
|
-
//# sourceMappingURL=chunk-5YONSDN4.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/utils/ModelConfigTypes.ts","../src/utils/ProxyConfigProvider.ts","../src/runtime/utils/idUtils.tsx","../src/runtime/utils/MessageRepository.tsx"],"sourcesContent":["\"use client\";\nimport type { z } from \"zod\";\n\nexport type Tool<TArgs> = {\n description: string;\n parameters: z.ZodSchema<TArgs>;\n execute: (args: TArgs) => unknown; // TODO return type\n};\n\nexport type ModelConfig = {\n system?: string;\n // biome-ignore lint/suspicious/noExplicitAny: TODO\n tools?: Record<string, Tool<any>>;\n};\n\nexport type ModelConfigProvider = () => ModelConfig;\n\nexport const mergeModelConfigs = (configs: ModelConfig[]): ModelConfig => {\n return configs.reduce((acc, config) => {\n if (config.system) {\n if (acc.system) {\n // TODO should the separator be configurable?\n acc.system += `\\n\\n${config.system}`;\n } else {\n acc.system = config.system;\n }\n }\n if (config.tools) {\n acc.tools = { ...acc.tools, ...config.tools };\n }\n return acc;\n }, {} as ModelConfig);\n};\n","\"use client\";\nimport {\n type ModelConfigProvider,\n mergeModelConfigs,\n} from \"./ModelConfigTypes\";\n\nexport class ProxyConfigProvider {\n private _providers = new Set<ModelConfigProvider>();\n\n getModelConfig() {\n return mergeModelConfigs([...this._providers].map((p) => p()));\n }\n\n registerModelConfigProvider(provider: ModelConfigProvider) {\n this._providers.add(provider);\n return () => {\n this._providers.delete(provider);\n };\n }\n}\n","import { customAlphabet } from \"nanoid/non-secure\";\n\nexport const generateId = customAlphabet(\n \"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\",\n 7,\n);\n\nconst optimisticPrefix = \"__optimistic__\";\nexport const generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;\nexport const isOptimisticId = (id: string) => id.startsWith(optimisticPrefix);\n","import type { ThreadMessage } from \"../../utils/AssistantTypes\";\nimport { generateOptimisticId } from \"./idUtils\";\n\ntype RepositoryParent = {\n children: string[];\n};\n\ntype RepositoryMessage = RepositoryParent & {\n prev: RepositoryMessage | null;\n current: ThreadMessage;\n next: RepositoryMessage | null;\n level: number;\n};\n\nconst findHead = (message: RepositoryMessage): RepositoryMessage => {\n if (message.next) return findHead(message.next);\n return message;\n};\n\nexport class MessageRepository {\n private messages = new Map<string, RepositoryMessage>(); // message_id -> item\n private head: RepositoryMessage | null = null;\n private root: RepositoryParent = {\n children: [],\n };\n\n private performOp(\n newParent: RepositoryMessage | null,\n child: RepositoryMessage,\n operation: \"cut\" | \"link\" | \"relink\",\n ) {\n const parentOrRoot = child.prev ?? this.root;\n const newParentOrRoot = newParent ?? this.root;\n\n if (operation === \"relink\" && parentOrRoot === newParentOrRoot) return;\n\n // cut\n if (operation !== \"link\") {\n parentOrRoot.children = parentOrRoot.children.filter(\n (m) => m !== child.current.id,\n );\n\n if (child.prev?.next === child) {\n const fallbackId = child.prev.children.at(-1);\n const fallback = fallbackId ? this.messages.get(fallbackId) : null;\n if (fallback === undefined) {\n throw new Error(\n \"MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui.\",\n );\n }\n child.prev.next = fallback;\n }\n }\n\n // link\n if (operation !== \"cut\") {\n newParentOrRoot.children = [\n ...newParentOrRoot.children,\n child.current.id,\n ];\n\n if (\n newParent &&\n (findHead(child) === this.head || newParent.next === null)\n ) {\n newParent.next = child;\n }\n\n child.prev = newParent;\n }\n }\n getMessages() {\n const messages = new Array<ThreadMessage>(this.head?.level ?? 0);\n for (let current = this.head; current; current = current.prev) {\n messages[current.level] = current.current;\n }\n return messages;\n }\n\n addOrUpdateMessage(parentId: string | null, message: ThreadMessage) {\n const existingItem = this.messages.get(message.id);\n const prev = parentId ? this.messages.get(parentId) : null;\n if (prev === undefined)\n throw new Error(\n \"MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n // update existing message\n if (existingItem) {\n existingItem.current = message;\n this.performOp(prev, existingItem, \"relink\");\n return;\n }\n\n // create a new message\n const newItem: RepositoryMessage = {\n prev,\n current: message,\n next: null,\n children: [],\n level: prev ? prev.level + 1 : 0,\n };\n\n this.messages.set(message.id, newItem);\n this.performOp(prev, newItem, \"link\");\n\n if (this.head === prev) {\n this.head = newItem;\n }\n }\n\n appendOptimisticMessage(\n parentId: string | null,\n message: Omit<ThreadMessage, \"id\" | \"createdAt\">,\n ) {\n let optimisticId: string;\n do {\n optimisticId = generateOptimisticId();\n } while (this.messages.has(optimisticId));\n\n this.addOrUpdateMessage(parentId, {\n ...message,\n id: optimisticId,\n createdAt: new Date(),\n ...(message.role === \"assistant\" ? { status: \"in_progress\" } : undefined),\n } as ThreadMessage);\n\n return optimisticId;\n }\n\n deleteMessage(messageId: string, replacementId?: string | null | undefined) {\n const message = this.messages.get(messageId);\n\n if (!message)\n throw new Error(\n \"MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const replacement =\n replacementId === undefined\n ? message.prev // if no replacementId is provided, use the parent\n : replacementId === null\n ? null\n : this.messages.get(replacementId);\n if (replacement === undefined)\n throw new Error(\n \"MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui.\",\n );\n\n for (const child of message.children) {\n const childMessage = this.messages.get(child);\n if (!childMessage)\n throw new Error(\n \"MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui.\",\n );\n this.performOp(replacement, childMessage, \"relink\");\n }\n\n this.performOp(null, message, \"cut\");\n this.messages.delete(messageId);\n\n if (this.head === message) {\n this.head = replacement ? findHead(replacement) : null;\n }\n }\n\n getBranches(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui.\",\n );\n\n const { children } = message.prev ?? this.root;\n return children;\n }\n\n switchToBranch(messageId: string) {\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n if (message.prev) {\n message.prev.next = message;\n }\n\n this.head = findHead(message);\n }\n\n resetHead(messageId: string | null) {\n if (messageId === null) {\n this.head = null;\n return;\n }\n\n const message = this.messages.get(messageId);\n if (!message)\n throw new Error(\n \"MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui.\",\n );\n\n this.head = message;\n for (\n let current: RepositoryMessage | null = message;\n current;\n current = current.prev\n ) {\n if (current.prev) {\n current.prev.next = current;\n }\n }\n }\n}\n"],"mappings":";AAiBO,IAAM,oBAAoB,CAAC,YAAwC;AACxE,SAAO,QAAQ,OAAO,CAAC,KAAK,WAAW;AACrC,QAAI,OAAO,QAAQ;AACjB,UAAI,IAAI,QAAQ;AAEd,YAAI,UAAU;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AAS;AAC3C,QAAI,CAAC;AACH,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAEF,QAAI,QAAQ,MAAM;AAChB,cAAQ,KAAK,OAAO;AAAA,IACtB;AAEA,SAAK,OAAO,SAAS,OAAO;AAAA,EAC9B;AAAA,EAEA,UAAU,WAA0B;AAClC,QAAI,cAAc,MAAM;AACtB,WAAK,OAAO;AACZ;AAAA,IACF;AAEA,UAAM,UAAU,KAAK,SAAS,IAAI,SAAS;AAC3C,QAAI,CAAC;AACH,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAEF,SAAK,OAAO;AACZ,aACM,UAAoC,SACxC,SACA,UAAU,QAAQ,MAClB;AACA,UAAI,QAAQ,MAAM;AAChB,gBAAQ,KAAK,OAAO;AAAA,MACtB;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
package/dist/chunk-CY4TTHR7.mjs
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
// src/context/MessageContext.ts
|
2
|
-
import { createContext, useContext } from "react";
|
3
|
-
var MessageContext = createContext(null);
|
4
|
-
var useMessageContext = () => {
|
5
|
-
const context = useContext(MessageContext);
|
6
|
-
if (!context)
|
7
|
-
throw new Error(
|
8
|
-
"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
|
9
|
-
);
|
10
|
-
return context;
|
11
|
-
};
|
12
|
-
|
13
|
-
// src/context/ThreadContext.ts
|
14
|
-
import { createContext as createContext2, useContext as useContext2 } from "react";
|
15
|
-
var ThreadContext = createContext2(null);
|
16
|
-
var useThreadContext = () => {
|
17
|
-
const context = useContext2(ThreadContext);
|
18
|
-
if (!context)
|
19
|
-
throw new Error("This component must be used within an AssistantRuntimeProvider.");
|
20
|
-
return context;
|
21
|
-
};
|
22
|
-
|
23
|
-
// src/context/ComposerContext.ts
|
24
|
-
import { useContext as useContext3, useMemo } from "react";
|
25
|
-
var useComposerContext = () => {
|
26
|
-
const { useComposer } = useThreadContext();
|
27
|
-
const { useComposer: useEditComposer } = useContext3(MessageContext) ?? {};
|
28
|
-
return useMemo(
|
29
|
-
() => ({
|
30
|
-
useComposer: useEditComposer ?? useComposer,
|
31
|
-
type: useEditComposer ? "edit" : "new"
|
32
|
-
}),
|
33
|
-
[useEditComposer, useComposer]
|
34
|
-
);
|
35
|
-
};
|
36
|
-
|
37
|
-
// src/context/ContentPartContext.ts
|
38
|
-
import { createContext as createContext3, useContext as useContext4 } from "react";
|
39
|
-
var ContentPartContext = createContext3(
|
40
|
-
null
|
41
|
-
);
|
42
|
-
var useContentPartContext = () => {
|
43
|
-
const context = useContext4(ContentPartContext);
|
44
|
-
if (!context)
|
45
|
-
throw new Error(
|
46
|
-
"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
|
47
|
-
);
|
48
|
-
return context;
|
49
|
-
};
|
50
|
-
|
51
|
-
// src/context/AssistantContext.ts
|
52
|
-
import { createContext as createContext4, useContext as useContext5 } from "react";
|
53
|
-
var AssistantContext = createContext4(
|
54
|
-
null
|
55
|
-
);
|
56
|
-
var useAssistantContext = () => {
|
57
|
-
const context = useContext5(AssistantContext);
|
58
|
-
if (!context)
|
59
|
-
throw new Error(
|
60
|
-
"This component must be used within an AssistantRuntimeProvider."
|
61
|
-
);
|
62
|
-
return context;
|
63
|
-
};
|
64
|
-
|
65
|
-
export {
|
66
|
-
MessageContext,
|
67
|
-
useMessageContext,
|
68
|
-
ThreadContext,
|
69
|
-
useThreadContext,
|
70
|
-
useComposerContext,
|
71
|
-
ContentPartContext,
|
72
|
-
useContentPartContext,
|
73
|
-
AssistantContext,
|
74
|
-
useAssistantContext
|
75
|
-
};
|
76
|
-
//# sourceMappingURL=chunk-CY4TTHR7.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/context/MessageContext.ts","../src/context/ThreadContext.ts","../src/context/ComposerContext.ts","../src/context/ContentPartContext.ts","../src/context/AssistantContext.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { MessageState } from \"./stores/Message\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type MessageContextValue = {\n useMessage: UseBoundStore<StoreApi<MessageState>>;\n useComposer: UseBoundStore<StoreApi<EditComposerState>>;\n};\n\nexport const MessageContext = createContext<MessageContextValue | null>(null);\n\nexport const useMessageContext = () => {\n const context = useContext(MessageContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { ThreadState } from \"./stores/Thread\";\nimport type { ThreadViewportState } from \"./stores/ThreadViewport\";\n\nexport type ThreadContextValue = {\n useThread: UseBoundStore<StoreApi<ThreadState>>;\n useComposer: UseBoundStore<StoreApi<ComposerState>>;\n useViewport: UseBoundStore<StoreApi<ThreadViewportState>>;\n};\n\nexport const ThreadContext = createContext<ThreadContextValue | null>(null);\n\nexport const useThreadContext = (): ThreadContextValue => {\n const context = useContext(ThreadContext);\n if (!context)\n throw new Error(\"This component must be used within an AssistantRuntimeProvider.\");\n return context;\n};\n","import { useContext, useMemo } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport { MessageContext } from \"./MessageContext\";\nimport { useThreadContext } from \"./ThreadContext\";\nimport type { ComposerState } from \"./stores/Composer\";\nimport type { EditComposerState } from \"./stores/MessageComposer\";\n\nexport type ComposerContextValue = {\n useComposer: UseBoundStore<StoreApi<EditComposerState | ComposerState>>;\n type: \"edit\" | \"new\";\n};\n\nexport const useComposerContext = (): ComposerContextValue => {\n const { useComposer } = useThreadContext();\n const { useComposer: useEditComposer } = useContext(MessageContext) ?? {};\n return useMemo(\n () => ({\n useComposer: (useEditComposer ?? useComposer) as UseBoundStore<\n StoreApi<EditComposerState | ComposerState>\n >,\n type: useEditComposer ? (\"edit\" as const) : (\"new\" as const),\n }),\n [useEditComposer, useComposer],\n );\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { ContentPartState } from \"./stores/ContentPart\";\n\nexport type ContentPartContextValue = {\n useContentPart: UseBoundStore<StoreApi<ContentPartState>>;\n};\n\nexport const ContentPartContext = createContext<ContentPartContextValue | null>(\n null,\n);\n\nexport const useContentPartContext = (): ContentPartContextValue => {\n const context = useContext(ContentPartContext);\n if (!context)\n throw new Error(\n \"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >.\",\n );\n return context;\n};\n","import { createContext, useContext } from \"react\";\nimport type { StoreApi, UseBoundStore } from \"zustand\";\nimport type { AssistantModelConfigState } from \"./stores/AssistantModelConfig\";\n\nexport type AssistantContextValue = {\n useModelConfig: UseBoundStore<StoreApi<AssistantModelConfigState>>;\n};\n\nexport const AssistantContext = createContext<AssistantContextValue | null>(\n null,\n);\n\nexport const useAssistantContext = (): AssistantContextValue => {\n const context = useContext(AssistantContext);\n if (!context)\n throw new Error(\n \"This component must be used within an AssistantRuntimeProvider.\",\n );\n return context;\n};\n"],"mappings":";AAAA,SAAS,eAAe,kBAAkB;AAUnC,IAAM,iBAAiB,cAA0C,IAAI;AAErE,IAAM,oBAAoB,MAAM;AACrC,QAAM,UAAU,WAAW,cAAc;AACzC,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACnBA,SAAS,iBAAAA,gBAAe,cAAAC,mBAAkB;AAYnC,IAAM,gBAAgBD,eAAyC,IAAI;AAEnE,IAAM,mBAAmB,MAA0B;AACxD,QAAM,UAAUC,YAAW,aAAa;AACxC,MAAI,CAAC;AACH,UAAM,IAAI,MAAM,iEAAiE;AACnF,SAAO;AACT;;;ACnBA,SAAS,cAAAC,aAAY,eAAe;AAY7B,IAAM,qBAAqB,MAA4B;AAC5D,QAAM,EAAE,YAAY,IAAI,iBAAiB;AACzC,QAAM,EAAE,aAAa,gBAAgB,IAAIC,YAAW,cAAc,KAAK,CAAC;AACxE,SAAO;AAAA,IACL,OAAO;AAAA,MACL,aAAc,mBAAmB;AAAA,MAGjC,MAAM,kBAAmB,SAAoB;AAAA,IAC/C;AAAA,IACA,CAAC,iBAAiB,WAAW;AAAA,EAC/B;AACF;;;ACxBA,SAAS,iBAAAC,gBAAe,cAAAC,mBAAkB;AAQnC,IAAM,qBAAqBD;AAAA,EAChC;AACF;AAEO,IAAM,wBAAwB,MAA+B;AAClE,QAAM,UAAUC,YAAW,kBAAkB;AAC7C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;;;ACnBA,SAAS,iBAAAC,gBAAe,cAAAC,mBAAkB;AAQnC,IAAM,mBAAmBD;AAAA,EAC9B;AACF;AAEO,IAAM,sBAAsB,MAA6B;AAC9D,QAAM,UAAUC,YAAW,gBAAgB;AAC3C,MAAI,CAAC;AACH,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AACF,SAAO;AACT;","names":["createContext","useContext","useContext","useContext","createContext","useContext","createContext","useContext"]}
|
package/dist/chunk-DKAWDNW5.mjs
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
mergeModelConfigs
|
3
|
-
} from "./chunk-X4HBDEFP.mjs";
|
4
|
-
|
5
|
-
// src/utils/ProxyConfigProvider.ts
|
6
|
-
var ProxyConfigProvider = class {
|
7
|
-
_providers = /* @__PURE__ */ new Set();
|
8
|
-
getModelConfig() {
|
9
|
-
return mergeModelConfigs([...this._providers].map((p) => p()));
|
10
|
-
}
|
11
|
-
registerModelConfigProvider(provider) {
|
12
|
-
this._providers.add(provider);
|
13
|
-
return () => {
|
14
|
-
this._providers.delete(provider);
|
15
|
-
};
|
16
|
-
}
|
17
|
-
};
|
18
|
-
|
19
|
-
export {
|
20
|
-
ProxyConfigProvider
|
21
|
-
};
|
22
|
-
//# sourceMappingURL=chunk-DKAWDNW5.mjs.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"sources":["../src/utils/ProxyConfigProvider.ts"],"sourcesContent":["\"use client\";\nimport {\n type ModelConfigProvider,\n mergeModelConfigs,\n} from \"./ModelConfigTypes\";\n\nexport class ProxyConfigProvider {\n private _providers = new Set<ModelConfigProvider>();\n\n getModelConfig() {\n return mergeModelConfigs([...this._providers].map((p) => p()));\n }\n\n registerModelConfigProvider(provider: ModelConfigProvider) {\n this._providers.add(provider);\n return () => {\n this._providers.delete(provider);\n };\n }\n}\n"],"mappings":";;;;;AAMO,IAAM,sBAAN,MAA0B;AAAA,EACvB,aAAa,oBAAI,IAAyB;AAAA,EAElD,iBAAiB;AACf,WAAO,kBAAkB,CAAC,GAAG,KAAK,UAAU,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;AAAA,EAC/D;AAAA,EAEA,4BAA4B,UAA+B;AACzD,SAAK,WAAW,IAAI,QAAQ;AAC5B,WAAO,MAAM;AACX,WAAK,WAAW,OAAO,QAAQ;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
|