@assistant-ui/react 0.0.28 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. package/README.md +1 -1
  2. package/dist/AssistantRuntime-BM_jVV3g.d.mts +23 -0
  3. package/dist/AssistantRuntime-CBMSAJqH.d.mts +23 -0
  4. package/dist/AssistantRuntime-C_BvM7ZT.d.ts +23 -0
  5. package/dist/AssistantRuntime-DELpXWfG.d.ts +23 -0
  6. package/dist/ModelConfigTypes-B9UY4zxv.d.mts +55 -0
  7. package/dist/ModelConfigTypes-B9UY4zxv.d.ts +55 -0
  8. package/dist/ModelConfigTypes-BF5HxVrH.d.mts +55 -0
  9. package/dist/ModelConfigTypes-BF5HxVrH.d.ts +55 -0
  10. package/dist/ModelConfigTypes-Cf3yjaDu.d.mts +55 -0
  11. package/dist/ModelConfigTypes-Cf3yjaDu.d.ts +55 -0
  12. package/dist/chunk-3XZUKECF.mjs +207 -0
  13. package/dist/chunk-3XZUKECF.mjs.map +1 -0
  14. package/dist/chunk-4DQ2CIAD.mjs +69 -0
  15. package/dist/chunk-4DQ2CIAD.mjs.map +1 -0
  16. package/dist/chunk-5YONSDN4.mjs +200 -0
  17. package/dist/chunk-5YONSDN4.mjs.map +1 -0
  18. package/dist/chunk-CY4TTHR7.mjs +76 -0
  19. package/dist/chunk-CY4TTHR7.mjs.map +1 -0
  20. package/dist/chunk-DKAWDNW5.mjs +22 -0
  21. package/dist/chunk-DKAWDNW5.mjs.map +1 -0
  22. package/dist/chunk-GQKH2ADD.mjs +165 -0
  23. package/dist/chunk-GQKH2ADD.mjs.map +1 -0
  24. package/dist/chunk-J5LGTIGS.mjs +10 -0
  25. package/dist/chunk-J5LGTIGS.mjs.map +1 -0
  26. package/dist/chunk-X4HBDEFP.mjs +30 -0
  27. package/dist/chunk-X4HBDEFP.mjs.map +1 -0
  28. package/dist/experimental.d.mts +120 -0
  29. package/dist/experimental.d.ts +120 -0
  30. package/dist/experimental.js +407 -0
  31. package/dist/experimental.js.map +1 -0
  32. package/dist/experimental.mjs +144 -0
  33. package/dist/experimental.mjs.map +1 -0
  34. package/dist/index.d.mts +6 -266
  35. package/dist/index.d.ts +6 -266
  36. package/dist/index.js +77 -730
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.mjs +62 -786
  39. package/dist/index.mjs.map +1 -1
  40. package/dist/internal-dlLjX30u.d.mts +75 -0
  41. package/dist/internal-dlLjX30u.d.ts +75 -0
  42. package/dist/internal.d.mts +25 -0
  43. package/dist/internal.d.ts +25 -0
  44. package/dist/internal.js +225 -0
  45. package/dist/internal.js.map +1 -0
  46. package/dist/internal.mjs +12 -0
  47. package/dist/internal.mjs.map +1 -0
  48. package/package.json +25 -5
@@ -0,0 +1,75 @@
1
+ import { z } from 'zod';
2
+ import { ReactNode } from 'react';
3
+
4
+ type TextContentPart = {
5
+ type: "text";
6
+ text: string;
7
+ };
8
+ type ImageContentPart = {
9
+ type: "image";
10
+ image: string;
11
+ };
12
+ type UIContentPart = {
13
+ type: "ui";
14
+ display: ReactNode;
15
+ };
16
+ type ToolCallContentPart = {
17
+ type: "tool-call";
18
+ name: string;
19
+ args: object;
20
+ result?: object;
21
+ };
22
+ type UserContentPart = TextContentPart | ImageContentPart | UIContentPart;
23
+ type AssistantContentPart = TextContentPart | UIContentPart | ToolCallContentPart;
24
+ type AppendContentPart = TextContentPart | ImageContentPart;
25
+ type BaseMessage = {
26
+ id: string;
27
+ createdAt: Date;
28
+ };
29
+ type UserMessage = BaseMessage & {
30
+ role: "user";
31
+ content: UserContentPart[];
32
+ };
33
+ type AssistantMessage = BaseMessage & {
34
+ role: "assistant";
35
+ content: AssistantContentPart[];
36
+ status: "in_progress" | "done" | "error";
37
+ };
38
+ type AppendMessage = {
39
+ parentId: string | null;
40
+ content: AppendContentPart[];
41
+ };
42
+ type ThreadMessage = UserMessage | AssistantMessage;
43
+
44
+ type Tool<TArgs> = {
45
+ description: string;
46
+ parameters: z.ZodSchema<TArgs>;
47
+ execute: (args: TArgs) => unknown;
48
+ };
49
+ type ModelConfig = {
50
+ system?: string;
51
+ tools?: Record<string, Tool<any>>;
52
+ };
53
+ type ModelConfigProvider = () => ModelConfig;
54
+
55
+ declare class ProxyConfigProvider {
56
+ private _providers;
57
+ getModelConfig(): ModelConfig;
58
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
59
+ }
60
+
61
+ declare class MessageRepository {
62
+ private messages;
63
+ private head;
64
+ private root;
65
+ private performOp;
66
+ getMessages(): ThreadMessage[];
67
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
68
+ appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
69
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
70
+ getBranches(messageId: string): string[];
71
+ switchToBranch(messageId: string): void;
72
+ resetHead(messageId: string | null): void;
73
+ }
74
+
75
+ export { type AppendMessage as A, type ImageContentPart as I, type ModelConfigProvider as M, ProxyConfigProvider as P, type TextContentPart as T, type UIContentPart as U, type ToolCallContentPart as a, type ThreadMessage as b, type ModelConfig as c, type AssistantContentPart as d, type AssistantMessage as e, type UserMessage as f, type UserContentPart as g, type AppendContentPart as h, MessageRepository as i };
@@ -0,0 +1,25 @@
1
+ import { M as ModelConfig, h as ModelConfigProvider, b as ThreadMessage } from './ModelConfigTypes-B9UY4zxv.mjs';
2
+ import 'react';
3
+ import 'zod';
4
+
5
+ declare class ProxyConfigProvider {
6
+ private _providers;
7
+ getModelConfig(): ModelConfig;
8
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
9
+ }
10
+
11
+ declare class MessageRepository {
12
+ private messages;
13
+ private head;
14
+ private root;
15
+ private performOp;
16
+ getMessages(): ThreadMessage[];
17
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
18
+ appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
19
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
20
+ getBranches(messageId: string): string[];
21
+ switchToBranch(messageId: string): void;
22
+ resetHead(messageId: string | null): void;
23
+ }
24
+
25
+ export { MessageRepository, ProxyConfigProvider };
@@ -0,0 +1,25 @@
1
+ import { M as ModelConfig, h as ModelConfigProvider, b as ThreadMessage } from './ModelConfigTypes-B9UY4zxv.js';
2
+ import 'react';
3
+ import 'zod';
4
+
5
+ declare class ProxyConfigProvider {
6
+ private _providers;
7
+ getModelConfig(): ModelConfig;
8
+ registerModelConfigProvider(provider: ModelConfigProvider): () => void;
9
+ }
10
+
11
+ declare class MessageRepository {
12
+ private messages;
13
+ private head;
14
+ private root;
15
+ private performOp;
16
+ getMessages(): ThreadMessage[];
17
+ addOrUpdateMessage(parentId: string | null, message: ThreadMessage): void;
18
+ appendOptimisticMessage(parentId: string | null, message: Omit<ThreadMessage, "id" | "createdAt">): string;
19
+ deleteMessage(messageId: string, replacementId?: string | null | undefined): void;
20
+ getBranches(messageId: string): string[];
21
+ switchToBranch(messageId: string): void;
22
+ resetHead(messageId: string | null): void;
23
+ }
24
+
25
+ export { MessageRepository, ProxyConfigProvider };
@@ -0,0 +1,225 @@
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/internal.ts
21
+ var internal_exports = {};
22
+ __export(internal_exports, {
23
+ MessageRepository: () => MessageRepository,
24
+ ProxyConfigProvider: () => ProxyConfigProvider
25
+ });
26
+ module.exports = __toCommonJS(internal_exports);
27
+
28
+ // src/utils/ModelConfigTypes.ts
29
+ var mergeModelConfigs = (configs) => {
30
+ return configs.reduce((acc, config) => {
31
+ if (config.system) {
32
+ if (acc.system) {
33
+ acc.system += `
34
+
35
+ ${config.system}`;
36
+ } else {
37
+ acc.system = config.system;
38
+ }
39
+ }
40
+ if (config.tools) {
41
+ acc.tools = { ...acc.tools, ...config.tools };
42
+ }
43
+ return acc;
44
+ }, {});
45
+ };
46
+
47
+ // src/utils/ProxyConfigProvider.ts
48
+ var ProxyConfigProvider = class {
49
+ _providers = /* @__PURE__ */ new Set();
50
+ getModelConfig() {
51
+ return mergeModelConfigs([...this._providers].map((p) => p()));
52
+ }
53
+ registerModelConfigProvider(provider) {
54
+ this._providers.add(provider);
55
+ return () => {
56
+ this._providers.delete(provider);
57
+ };
58
+ }
59
+ };
60
+
61
+ // src/runtime/utils/idUtils.tsx
62
+ var import_non_secure = require("nanoid/non-secure");
63
+ var generateId = (0, import_non_secure.customAlphabet)(
64
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
65
+ 7
66
+ );
67
+ var optimisticPrefix = "__optimistic__";
68
+ var generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;
69
+
70
+ // src/runtime/utils/MessageRepository.tsx
71
+ var findHead = (message) => {
72
+ if (message.next) return findHead(message.next);
73
+ return message;
74
+ };
75
+ var MessageRepository = class {
76
+ messages = /* @__PURE__ */ new Map();
77
+ // message_id -> item
78
+ head = null;
79
+ root = {
80
+ children: []
81
+ };
82
+ performOp(newParent, child, operation) {
83
+ const parentOrRoot = child.prev ?? this.root;
84
+ const newParentOrRoot = newParent ?? this.root;
85
+ if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
86
+ if (operation !== "link") {
87
+ parentOrRoot.children = parentOrRoot.children.filter(
88
+ (m) => m !== child.current.id
89
+ );
90
+ if (child.prev?.next === child) {
91
+ const fallbackId = child.prev.children.at(-1);
92
+ const fallback = fallbackId ? this.messages.get(fallbackId) : null;
93
+ if (fallback === void 0) {
94
+ throw new Error(
95
+ "MessageRepository(performOp/cut): Fallback sibling message not found. This is likely an internal bug in assistant-ui."
96
+ );
97
+ }
98
+ child.prev.next = fallback;
99
+ }
100
+ }
101
+ if (operation !== "cut") {
102
+ newParentOrRoot.children = [
103
+ ...newParentOrRoot.children,
104
+ child.current.id
105
+ ];
106
+ if (newParent && (findHead(child) === this.head || newParent.next === null)) {
107
+ newParent.next = child;
108
+ }
109
+ child.prev = newParent;
110
+ }
111
+ }
112
+ getMessages() {
113
+ const messages = new Array(this.head?.level ?? 0);
114
+ for (let current = this.head; current; current = current.prev) {
115
+ messages[current.level] = current.current;
116
+ }
117
+ return messages;
118
+ }
119
+ addOrUpdateMessage(parentId, message) {
120
+ const existingItem = this.messages.get(message.id);
121
+ const prev = parentId ? this.messages.get(parentId) : null;
122
+ if (prev === void 0)
123
+ throw new Error(
124
+ "MessageRepository(addOrUpdateMessage): Parent message not found. This is likely an internal bug in assistant-ui."
125
+ );
126
+ if (existingItem) {
127
+ existingItem.current = message;
128
+ this.performOp(prev, existingItem, "relink");
129
+ return;
130
+ }
131
+ const newItem = {
132
+ prev,
133
+ current: message,
134
+ next: null,
135
+ children: [],
136
+ level: prev ? prev.level + 1 : 0
137
+ };
138
+ this.messages.set(message.id, newItem);
139
+ this.performOp(prev, newItem, "link");
140
+ if (this.head === prev) {
141
+ this.head = newItem;
142
+ }
143
+ }
144
+ appendOptimisticMessage(parentId, message) {
145
+ let optimisticId;
146
+ do {
147
+ optimisticId = generateOptimisticId();
148
+ } while (this.messages.has(optimisticId));
149
+ this.addOrUpdateMessage(parentId, {
150
+ ...message,
151
+ id: optimisticId,
152
+ createdAt: /* @__PURE__ */ new Date(),
153
+ ...message.role === "assistant" ? { status: "in_progress" } : void 0
154
+ });
155
+ return optimisticId;
156
+ }
157
+ deleteMessage(messageId, replacementId) {
158
+ const message = this.messages.get(messageId);
159
+ if (!message)
160
+ throw new Error(
161
+ "MessageRepository(deleteMessage): Optimistic message not found. This is likely an internal bug in assistant-ui."
162
+ );
163
+ const replacement = replacementId === void 0 ? message.prev : replacementId === null ? null : this.messages.get(replacementId);
164
+ if (replacement === void 0)
165
+ throw new Error(
166
+ "MessageRepository(deleteMessage): Replacement not found. This is likely an internal bug in assistant-ui."
167
+ );
168
+ for (const child of message.children) {
169
+ const childMessage = this.messages.get(child);
170
+ if (!childMessage)
171
+ throw new Error(
172
+ "MessageRepository(deleteMessage): Child message not found. This is likely an internal bug in assistant-ui."
173
+ );
174
+ this.performOp(replacement, childMessage, "relink");
175
+ }
176
+ this.performOp(null, message, "cut");
177
+ this.messages.delete(messageId);
178
+ if (this.head === message) {
179
+ this.head = replacement ? findHead(replacement) : null;
180
+ }
181
+ }
182
+ getBranches(messageId) {
183
+ const message = this.messages.get(messageId);
184
+ if (!message)
185
+ throw new Error(
186
+ "MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
187
+ );
188
+ const { children } = message.prev ?? this.root;
189
+ return children;
190
+ }
191
+ switchToBranch(messageId) {
192
+ const message = this.messages.get(messageId);
193
+ if (!message)
194
+ throw new Error(
195
+ "MessageRepository(switchToBranch): Branch not found. This is likely an internal bug in assistant-ui."
196
+ );
197
+ if (message.prev) {
198
+ message.prev.next = message;
199
+ }
200
+ this.head = findHead(message);
201
+ }
202
+ resetHead(messageId) {
203
+ if (messageId === null) {
204
+ this.head = null;
205
+ return;
206
+ }
207
+ const message = this.messages.get(messageId);
208
+ if (!message)
209
+ throw new Error(
210
+ "MessageRepository(resetHead): Branch not found. This is likely an internal bug in assistant-ui."
211
+ );
212
+ this.head = message;
213
+ for (let current = message; current; current = current.prev) {
214
+ if (current.prev) {
215
+ current.prev.next = current;
216
+ }
217
+ }
218
+ }
219
+ };
220
+ // Annotate the CommonJS export names for ESM import in node:
221
+ 0 && (module.exports = {
222
+ MessageRepository,
223
+ ProxyConfigProvider
224
+ });
225
+ //# sourceMappingURL=internal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/internal.ts","../src/utils/ModelConfigTypes.ts","../src/utils/ProxyConfigProvider.ts","../src/runtime/utils/idUtils.tsx","../src/runtime/utils/MessageRepository.tsx"],"sourcesContent":["export { ProxyConfigProvider } from \"./utils/ProxyConfigProvider\";\nexport { MessageRepository } from \"./runtime/utils/MessageRepository\";\n","\"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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,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;AAAA,EAEA,4BAA4B,UAA+B;AACzD,SAAK,WAAW,IAAI,QAAQ;AAC5B,WAAO,MAAM;AACX,WAAK,WAAW,OAAO,QAAQ;AAAA,IACjC;AAAA,EACF;AACF;;;ACnBA,wBAA+B;AAExB,IAAM,iBAAa;AAAA,EACxB;AAAA,EACA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} from "./chunk-GQKH2ADD.mjs";
7
+ import "./chunk-X4HBDEFP.mjs";
8
+ export {
9
+ MessageRepository,
10
+ ProxyConfigProvider
11
+ };
12
+ //# sourceMappingURL=internal.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "conversational-ui",
30
30
  "conversational-ai"
31
31
  ],
32
- "version": "0.0.28",
32
+ "version": "0.1.0",
33
33
  "license": "MIT",
34
34
  "exports": {
35
35
  ".": {
@@ -41,6 +41,26 @@
41
41
  "types": "./dist/index.d.ts",
42
42
  "default": "./dist/index.js"
43
43
  }
44
+ },
45
+ "./internal": {
46
+ "import": {
47
+ "types": "./dist/internal.d.mts",
48
+ "default": "./dist/internal.mjs"
49
+ },
50
+ "require": {
51
+ "types": "./dist/internal.d.ts",
52
+ "default": "./dist/internal.js"
53
+ }
54
+ },
55
+ "./experimental": {
56
+ "import": {
57
+ "types": "./dist/experimental.d.mts",
58
+ "default": "./dist/experimental.mjs"
59
+ },
60
+ "require": {
61
+ "types": "./dist/experimental.d.ts",
62
+ "default": "./dist/experimental.js"
63
+ }
44
64
  }
45
65
  },
46
66
  "source": "./src/index.ts",
@@ -60,6 +80,7 @@
60
80
  "@radix-ui/react-use-callback-ref": "^1.0.1",
61
81
  "nanoid": "^5.0.7",
62
82
  "react-textarea-autosize": "^8.5.3",
83
+ "zod": "^3.23.8",
63
84
  "zustand": "^4.5.2"
64
85
  },
65
86
  "peerDependencies": {
@@ -75,11 +96,10 @@
75
96
  "access": "public"
76
97
  },
77
98
  "devDependencies": {
78
- "@ai-sdk/react": "^0.0.1",
99
+ "@ai-sdk/react": "^0.0.2",
79
100
  "@types/node": "^20.14.2",
80
101
  "tsup": "^8.1.0",
81
- "@assistant-ui/tsconfig": "0.0.0",
82
- "@assistant-ui/react-ai-sdk": "0.0.2"
102
+ "@assistant-ui/tsconfig": "0.0.0"
83
103
  },
84
104
  "homepage": "https://assistant-ui.com/",
85
105
  "repository": {
@@ -90,7 +110,7 @@
90
110
  "url": "https://github.com/Yonom/assistant-ui/issues"
91
111
  },
92
112
  "scripts": {
93
- "build": "tsup src/index.ts --format cjs,esm --dts --sourcemap",
113
+ "build": "tsup src/index.ts src/internal.ts src/experimental.ts --format cjs,esm --dts --sourcemap",
94
114
  "prepublish": "cp ../../README.md ./README.md"
95
115
  }
96
116
  }