@assistant-ui/react 0.5.21 → 0.5.23
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{AssistantTypes-D93BmqD5.d.mts → AssistantTypes-BNB-knVq.d.mts} +1 -1
- package/dist/{AssistantTypes-D93BmqD5.d.ts → AssistantTypes-BNB-knVq.d.ts} +1 -1
- package/dist/chunk-DCHYNTHI.js +11 -0
- package/dist/chunk-DCHYNTHI.js.map +1 -0
- package/dist/chunk-NSPHKRLF.js +819 -0
- package/dist/chunk-NSPHKRLF.js.map +1 -0
- package/dist/{chunk-2RKUKZSZ.mjs → chunk-ZWRFAYHH.mjs} +61 -3
- package/dist/chunk-ZWRFAYHH.mjs.map +1 -0
- package/dist/edge.d.mts +90 -5
- package/dist/edge.d.ts +90 -5
- package/dist/edge.js +0 -1
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +799 -49
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +164 -7
- package/dist/index.d.ts +164 -7
- package/dist/index.js +761 -1607
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +833 -252
- package/dist/index.mjs.map +1 -1
- package/dist/tailwindcss/index.js +24 -53
- package/dist/tailwindcss/index.js.map +1 -1
- package/package.json +1 -12
- package/dist/Thread-BbLf1cc4.d.mts +0 -156
- package/dist/Thread-jfAlPLli.d.ts +0 -156
- package/dist/chunk-2RKUKZSZ.mjs.map +0 -1
- package/dist/chunk-QBS6JLLN.mjs +0 -63
- package/dist/chunk-QBS6JLLN.mjs.map +0 -1
- package/dist/chunk-V66MVXBH.mjs +0 -608
- package/dist/chunk-V66MVXBH.mjs.map +0 -1
- package/dist/internal.d.mts +0 -9
- package/dist/internal.d.ts +0 -9
- package/dist/internal.js +0 -620
- package/dist/internal.js.map +0 -1
- package/dist/internal.mjs +0 -24
- package/dist/internal.mjs.map +0 -1
- package/internal/README.md +0 -1
- package/internal/package.json +0 -5
package/dist/index.js
CHANGED
@@ -1,119 +1,31 @@
|
|
1
|
-
"use client";
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
var
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
15
|
-
for (let key of __getOwnPropNames(from))
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
18
|
-
}
|
19
|
-
return to;
|
20
|
-
};
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
27
|
-
mod
|
28
|
-
));
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
30
|
-
|
31
|
-
// src/index.ts
|
32
|
-
var src_exports = {};
|
33
|
-
__export(src_exports, {
|
34
|
-
ActionBarPrimitive: () => actionBar_exports,
|
35
|
-
AssistantActionBar: () => assistant_action_bar_default,
|
36
|
-
AssistantMessage: () => assistant_message_default,
|
37
|
-
AssistantModal: () => assistant_modal_default,
|
38
|
-
AssistantModalPrimitive: () => assistantModal_exports,
|
39
|
-
AssistantRuntimeProvider: () => AssistantRuntimeProvider,
|
40
|
-
BranchPicker: () => branch_picker_default,
|
41
|
-
BranchPickerPrimitive: () => branchPicker_exports,
|
42
|
-
Composer: () => composer_default,
|
43
|
-
ComposerPrimitive: () => composer_exports,
|
44
|
-
ContentPart: () => content_part_default,
|
45
|
-
ContentPartPrimitive: () => contentPart_exports,
|
46
|
-
EdgeChatAdapter: () => EdgeChatAdapter,
|
47
|
-
EditComposer: () => edit_composer_default,
|
48
|
-
ExternalStoreRuntime: () => ExternalStoreRuntime,
|
49
|
-
INTERNAL: () => internal_exports,
|
50
|
-
MessagePrimitive: () => message_exports,
|
51
|
-
Thread: () => thread_default,
|
52
|
-
ThreadConfigProvider: () => ThreadConfigProvider,
|
53
|
-
ThreadPrimitive: () => thread_exports,
|
54
|
-
ThreadWelcome: () => thread_welcome_default,
|
55
|
-
UserActionBar: () => user_action_bar_default,
|
56
|
-
UserMessage: () => user_message_default,
|
57
|
-
fromCoreMessage: () => fromCoreMessage,
|
58
|
-
fromCoreMessages: () => fromCoreMessages,
|
59
|
-
fromLanguageModelMessages: () => fromLanguageModelMessages,
|
60
|
-
fromLanguageModelTools: () => fromLanguageModelTools,
|
61
|
-
getExternalStoreMessage: () => getExternalStoreMessage,
|
62
|
-
makeAssistantTool: () => makeAssistantTool,
|
63
|
-
makeAssistantToolUI: () => makeAssistantToolUI,
|
64
|
-
toCoreMessage: () => toCoreMessage,
|
65
|
-
toCoreMessages: () => toCoreMessages,
|
66
|
-
toLanguageModelMessages: () => toLanguageModelMessages,
|
67
|
-
toLanguageModelTools: () => toLanguageModelTools,
|
68
|
-
useActionBarCopy: () => useActionBarCopy,
|
69
|
-
useActionBarEdit: () => useActionBarEdit,
|
70
|
-
useActionBarReload: () => useActionBarReload,
|
71
|
-
useAppendMessage: () => useAppendMessage,
|
72
|
-
useAssistantContext: () => useAssistantContext,
|
73
|
-
useAssistantInstructions: () => useAssistantInstructions,
|
74
|
-
useAssistantTool: () => useAssistantTool,
|
75
|
-
useAssistantToolUI: () => useAssistantToolUI,
|
76
|
-
useBranchPickerCount: () => useBranchPickerCount,
|
77
|
-
useBranchPickerNext: () => useBranchPickerNext,
|
78
|
-
useBranchPickerNumber: () => useBranchPickerNumber,
|
79
|
-
useBranchPickerPrevious: () => useBranchPickerPrevious,
|
80
|
-
useComposerCancel: () => useComposerCancel,
|
81
|
-
useComposerContext: () => useComposerContext,
|
82
|
-
useComposerIf: () => useComposerIf,
|
83
|
-
useComposerSend: () => useComposerSend,
|
84
|
-
useContentPartContext: () => useContentPartContext,
|
85
|
-
useContentPartDisplay: () => useContentPartDisplay,
|
86
|
-
useContentPartImage: () => useContentPartImage,
|
87
|
-
useContentPartText: () => useContentPartText,
|
88
|
-
useEdgeRuntime: () => useEdgeRuntime,
|
89
|
-
useExternalStoreRuntime: () => useExternalStoreRuntime,
|
90
|
-
useLocalRuntime: () => useLocalRuntime,
|
91
|
-
useMessageContext: () => useMessageContext,
|
92
|
-
useMessageIf: () => useMessageIf,
|
93
|
-
useSwitchToNewThread: () => useSwitchToNewThread,
|
94
|
-
useThreadConfig: () => useThreadConfig,
|
95
|
-
useThreadContext: () => useThreadContext,
|
96
|
-
useThreadEmpty: () => useThreadEmpty,
|
97
|
-
useThreadIf: () => useThreadIf,
|
98
|
-
useThreadScrollToBottom: () => useThreadScrollToBottom,
|
99
|
-
useThreadSuggestion: () => useThreadSuggestion
|
100
|
-
});
|
101
|
-
module.exports = __toCommonJS(src_exports);
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } var _class; var _class2; var _class3; var _class4; var _class5; var _class6; var _class7; var _class8;"use client";
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
var _chunkNSPHKRLFjs = require('./chunk-NSPHKRLF.js');
|
11
|
+
|
12
|
+
|
13
|
+
var _chunkDCHYNTHIjs = require('./chunk-DCHYNTHI.js');
|
102
14
|
|
103
15
|
// src/context/providers/AssistantRuntimeProvider.tsx
|
104
|
-
var
|
16
|
+
var _react = require('react');
|
105
17
|
|
106
18
|
// src/context/providers/AssistantProvider.tsx
|
107
|
-
|
19
|
+
|
108
20
|
|
109
21
|
// src/context/react/AssistantContext.ts
|
110
|
-
|
111
|
-
var AssistantContext = (0,
|
22
|
+
|
23
|
+
var AssistantContext = _react.createContext.call(void 0,
|
112
24
|
null
|
113
25
|
);
|
114
26
|
function useAssistantContext(options) {
|
115
|
-
const context = (0,
|
116
|
-
if (!options
|
27
|
+
const context = _react.useContext.call(void 0, AssistantContext);
|
28
|
+
if (!_optionalChain([options, 'optionalAccess', _2 => _2.optional]) && !context)
|
117
29
|
throw new Error(
|
118
30
|
"This component must be used within an AssistantRuntimeProvider."
|
119
31
|
);
|
@@ -121,68 +33,13 @@ function useAssistantContext(options) {
|
|
121
33
|
}
|
122
34
|
|
123
35
|
// src/context/stores/AssistantModelConfig.ts
|
124
|
-
var
|
125
|
-
|
126
|
-
// src/types/ModelConfigTypes.ts
|
127
|
-
var import_zod = require("zod");
|
128
|
-
var LanguageModelV1CallSettingsSchema = import_zod.z.object({
|
129
|
-
maxTokens: import_zod.z.number().int().positive().optional(),
|
130
|
-
temperature: import_zod.z.number().optional(),
|
131
|
-
topP: import_zod.z.number().optional(),
|
132
|
-
presencePenalty: import_zod.z.number().optional(),
|
133
|
-
frequencyPenalty: import_zod.z.number().optional(),
|
134
|
-
seed: import_zod.z.number().int().optional(),
|
135
|
-
headers: import_zod.z.record(import_zod.z.string().optional()).optional()
|
136
|
-
});
|
137
|
-
var LanguageModelConfigSchema = import_zod.z.object({
|
138
|
-
apiKey: import_zod.z.string().optional(),
|
139
|
-
baseUrl: import_zod.z.string().optional(),
|
140
|
-
modelName: import_zod.z.string().optional()
|
141
|
-
});
|
142
|
-
var mergeModelConfigs = (configSet) => {
|
143
|
-
const configs = Array.from(configSet).map((c) => c.getModelConfig()).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
144
|
-
return configs.reduce((acc, config) => {
|
145
|
-
if (config.system) {
|
146
|
-
if (acc.system) {
|
147
|
-
acc.system += `
|
148
|
-
|
149
|
-
${config.system}`;
|
150
|
-
} else {
|
151
|
-
acc.system = config.system;
|
152
|
-
}
|
153
|
-
}
|
154
|
-
if (config.tools) {
|
155
|
-
for (const [name, tool] of Object.entries(config.tools)) {
|
156
|
-
if (acc.tools?.[name]) {
|
157
|
-
throw new Error(
|
158
|
-
`You tried to define a tool with the name ${name}, but it already exists.`
|
159
|
-
);
|
160
|
-
}
|
161
|
-
if (!acc.tools) acc.tools = {};
|
162
|
-
acc.tools[name] = tool;
|
163
|
-
}
|
164
|
-
}
|
165
|
-
if (config.config) {
|
166
|
-
acc.config = {
|
167
|
-
...acc.config,
|
168
|
-
...config.config
|
169
|
-
};
|
170
|
-
}
|
171
|
-
if (config.callSettings) {
|
172
|
-
acc.callSettings = {
|
173
|
-
...acc.callSettings,
|
174
|
-
...config.callSettings
|
175
|
-
};
|
176
|
-
}
|
177
|
-
return acc;
|
178
|
-
}, {});
|
179
|
-
};
|
36
|
+
var _zustand = require('zustand');
|
180
37
|
|
181
38
|
// src/utils/ProxyConfigProvider.ts
|
182
|
-
var ProxyConfigProvider = class {
|
183
|
-
_providers = /* @__PURE__ */ new Set()
|
39
|
+
var ProxyConfigProvider = (_class = class {constructor() { _class.prototype.__init.call(this); }
|
40
|
+
__init() {this._providers = /* @__PURE__ */ new Set()}
|
184
41
|
getModelConfig() {
|
185
|
-
return mergeModelConfigs(this._providers);
|
42
|
+
return _chunkNSPHKRLFjs.mergeModelConfigs.call(void 0, this._providers);
|
186
43
|
}
|
187
44
|
registerModelConfigProvider(provider) {
|
188
45
|
this._providers.add(provider);
|
@@ -190,10 +47,10 @@ var ProxyConfigProvider = class {
|
|
190
47
|
this._providers.delete(provider);
|
191
48
|
};
|
192
49
|
}
|
193
|
-
};
|
50
|
+
}, _class);
|
194
51
|
|
195
52
|
// src/context/stores/AssistantModelConfig.ts
|
196
|
-
var makeAssistantModelConfigStore = () => (0,
|
53
|
+
var makeAssistantModelConfigStore = () => _zustand.create.call(void 0, () => {
|
197
54
|
const proxy = new ProxyConfigProvider();
|
198
55
|
return Object.freeze({
|
199
56
|
getModelConfig: () => {
|
@@ -206,13 +63,13 @@ var makeAssistantModelConfigStore = () => (0, import_zustand.create)(() => {
|
|
206
63
|
});
|
207
64
|
|
208
65
|
// src/context/stores/AssistantToolUIs.ts
|
209
|
-
|
210
|
-
var makeAssistantToolUIsStore = () => (0,
|
66
|
+
|
67
|
+
var makeAssistantToolUIsStore = () => _zustand.create.call(void 0, (set) => {
|
211
68
|
const renderers = /* @__PURE__ */ new Map();
|
212
69
|
return Object.freeze({
|
213
70
|
getToolUI: (name) => {
|
214
71
|
const arr = renderers.get(name);
|
215
|
-
const last = arr
|
72
|
+
const last = _optionalChain([arr, 'optionalAccess', _3 => _3.at, 'call', _4 => _4(-1)]);
|
216
73
|
if (last) return last;
|
217
74
|
return null;
|
218
75
|
},
|
@@ -238,14 +95,14 @@ var makeAssistantToolUIsStore = () => (0, import_zustand2.create)((set) => {
|
|
238
95
|
});
|
239
96
|
|
240
97
|
// src/context/providers/ThreadProvider.tsx
|
241
|
-
|
98
|
+
|
242
99
|
|
243
100
|
// src/context/react/ThreadContext.ts
|
244
|
-
|
245
|
-
var ThreadContext = (0,
|
101
|
+
|
102
|
+
var ThreadContext = _react.createContext.call(void 0, null);
|
246
103
|
function useThreadContext(options) {
|
247
|
-
const context = (0,
|
248
|
-
if (!options
|
104
|
+
const context = _react.useContext.call(void 0, ThreadContext);
|
105
|
+
if (!_optionalChain([options, 'optionalAccess', _5 => _5.optional]) && !context)
|
249
106
|
throw new Error(
|
250
107
|
"This component must be used within an AssistantRuntimeProvider."
|
251
108
|
);
|
@@ -253,7 +110,7 @@ function useThreadContext(options) {
|
|
253
110
|
}
|
254
111
|
|
255
112
|
// src/context/stores/Composer.ts
|
256
|
-
|
113
|
+
|
257
114
|
|
258
115
|
// src/context/stores/BaseComposer.ts
|
259
116
|
var makeBaseComposer = (set) => ({
|
@@ -266,7 +123,7 @@ var makeBaseComposer = (set) => ({
|
|
266
123
|
// src/context/stores/Composer.ts
|
267
124
|
var makeComposerStore = (useThreadMessages, useThreadActions) => {
|
268
125
|
const focusListeners = /* @__PURE__ */ new Set();
|
269
|
-
return (0,
|
126
|
+
return _zustand.create.call(void 0, )((set, get, store) => {
|
270
127
|
return {
|
271
128
|
...makeBaseComposer(set, get, store),
|
272
129
|
get canCancel() {
|
@@ -277,7 +134,7 @@ var makeComposerStore = (useThreadMessages, useThreadActions) => {
|
|
277
134
|
const { setValue, value } = get();
|
278
135
|
setValue("");
|
279
136
|
useThreadActions.getState().append({
|
280
|
-
parentId: useThreadMessages.getState().at(-1)
|
137
|
+
parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _6 => _6.getState, 'call', _7 => _7(), 'access', _8 => _8.at, 'call', _9 => _9(-1), 'optionalAccess', _10 => _10.id]), () => ( null)),
|
281
138
|
role: "user",
|
282
139
|
content: [{ type: "text", text: value }]
|
283
140
|
});
|
@@ -301,19 +158,19 @@ var makeComposerStore = (useThreadMessages, useThreadActions) => {
|
|
301
158
|
};
|
302
159
|
|
303
160
|
// src/context/stores/Thread.ts
|
304
|
-
|
161
|
+
|
305
162
|
var makeThreadStore = (runtimeRef) => {
|
306
|
-
return (0,
|
163
|
+
return _zustand.create.call(void 0, () => ({
|
307
164
|
isDisabled: runtimeRef.getState().isDisabled,
|
308
165
|
isRunning: runtimeRef.getState().isRunning
|
309
166
|
}));
|
310
167
|
};
|
311
168
|
|
312
169
|
// src/context/stores/ThreadViewport.tsx
|
313
|
-
|
170
|
+
|
314
171
|
var makeThreadViewportStore = () => {
|
315
172
|
const scrollToBottomListeners = /* @__PURE__ */ new Set();
|
316
|
-
return (0,
|
173
|
+
return _zustand.create.call(void 0, () => ({
|
317
174
|
isAtBottom: true,
|
318
175
|
scrollToBottom: () => {
|
319
176
|
for (const listener of scrollToBottomListeners) {
|
@@ -330,9 +187,9 @@ var makeThreadViewportStore = () => {
|
|
330
187
|
};
|
331
188
|
|
332
189
|
// src/context/stores/ThreadActions.ts
|
333
|
-
|
190
|
+
|
334
191
|
var makeThreadActionStore = (runtimeStore) => {
|
335
|
-
return (0,
|
192
|
+
return _zustand.create.call(void 0,
|
336
193
|
() => Object.freeze({
|
337
194
|
get capabilities() {
|
338
195
|
return runtimeStore.getState().capabilities;
|
@@ -348,22 +205,22 @@ var makeThreadActionStore = (runtimeStore) => {
|
|
348
205
|
};
|
349
206
|
|
350
207
|
// src/context/stores/ThreadMessages.ts
|
351
|
-
|
208
|
+
|
352
209
|
var makeThreadMessagesStore = (runtimeRef) => {
|
353
|
-
return (0,
|
210
|
+
return _zustand.create.call(void 0, () => runtimeRef.getState().messages);
|
354
211
|
};
|
355
212
|
|
356
213
|
// src/context/stores/ThreadRuntime.tsx
|
357
|
-
|
214
|
+
|
358
215
|
var makeThreadRuntimeStore = (runtime) => {
|
359
|
-
return (0,
|
216
|
+
return _zustand.create.call(void 0, () => runtime);
|
360
217
|
};
|
361
218
|
|
362
219
|
// src/utils/hooks/useManagedRef.ts
|
363
|
-
|
220
|
+
|
364
221
|
var useManagedRef = (callback) => {
|
365
|
-
const cleanupRef = (0,
|
366
|
-
const ref = (0,
|
222
|
+
const cleanupRef = _react.useRef.call(void 0, );
|
223
|
+
const ref = _react.useCallback.call(void 0,
|
367
224
|
(el) => {
|
368
225
|
if (cleanupRef.current) {
|
369
226
|
cleanupRef.current();
|
@@ -378,12 +235,12 @@ var useManagedRef = (callback) => {
|
|
378
235
|
};
|
379
236
|
|
380
237
|
// src/context/providers/ThreadProvider.tsx
|
381
|
-
var
|
238
|
+
var _jsxruntime = require('react/jsx-runtime');
|
382
239
|
var ThreadProvider = ({
|
383
240
|
children,
|
384
241
|
provider
|
385
242
|
}) => {
|
386
|
-
const [context] = (0,
|
243
|
+
const [context] = _react.useState.call(void 0, () => {
|
387
244
|
const useThreadRuntime = makeThreadRuntimeStore(provider.thread);
|
388
245
|
const useThread = makeThreadStore(useThreadRuntime);
|
389
246
|
const useThreadMessages = makeThreadMessagesStore(useThreadRuntime);
|
@@ -400,7 +257,7 @@ var ThreadProvider = ({
|
|
400
257
|
};
|
401
258
|
});
|
402
259
|
const threadRef = useManagedRef(
|
403
|
-
(0,
|
260
|
+
_react.useCallback.call(void 0,
|
404
261
|
(thread) => {
|
405
262
|
const onThreadUpdate = () => {
|
406
263
|
const threadState = context.useThread.getState();
|
@@ -423,7 +280,7 @@ var ThreadProvider = ({
|
|
423
280
|
[context]
|
424
281
|
)
|
425
282
|
);
|
426
|
-
(0,
|
283
|
+
_react.useInsertionEffect.call(void 0, () => {
|
427
284
|
const unsubscribe = provider.subscribe(() => {
|
428
285
|
context.useThreadRuntime.setState(provider.thread, true);
|
429
286
|
threadRef(provider.thread);
|
@@ -437,15 +294,15 @@ var ThreadProvider = ({
|
|
437
294
|
const Synchronizer = context.useThreadRuntime(
|
438
295
|
(t) => t.unstable_synchronizer
|
439
296
|
);
|
440
|
-
return /* @__PURE__ */ (0,
|
441
|
-
Synchronizer && /* @__PURE__ */ (0,
|
297
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadContext.Provider, { value: context, children: [
|
298
|
+
Synchronizer && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Synchronizer, {}),
|
442
299
|
children
|
443
300
|
] });
|
444
301
|
};
|
445
302
|
|
446
303
|
// src/context/stores/AssistantActions.tsx
|
447
|
-
|
448
|
-
var makeAssistantActionsStore = (runtimeRef) => (0,
|
304
|
+
|
305
|
+
var makeAssistantActionsStore = (runtimeRef) => _zustand.create.call(void 0,
|
449
306
|
() => Object.freeze({
|
450
307
|
switchToThread: () => runtimeRef.current.switchToThread(null),
|
451
308
|
getRuntime: () => runtimeRef.current
|
@@ -453,41 +310,41 @@ var makeAssistantActionsStore = (runtimeRef) => (0, import_zustand9.create)(
|
|
453
310
|
);
|
454
311
|
|
455
312
|
// src/context/providers/AssistantProvider.tsx
|
456
|
-
|
313
|
+
|
457
314
|
var AssistantProvider = ({ children, runtime }) => {
|
458
|
-
const runtimeRef = (0,
|
459
|
-
(0,
|
315
|
+
const runtimeRef = _react.useRef.call(void 0, runtime);
|
316
|
+
_react.useInsertionEffect.call(void 0, () => {
|
460
317
|
runtimeRef.current = runtime;
|
461
318
|
});
|
462
|
-
const [context] = (0,
|
319
|
+
const [context] = _react.useState.call(void 0, () => {
|
463
320
|
const useModelConfig = makeAssistantModelConfigStore();
|
464
321
|
const useToolUIs = makeAssistantToolUIsStore();
|
465
322
|
const useAssistantActions = makeAssistantActionsStore(runtimeRef);
|
466
323
|
return { useModelConfig, useToolUIs, useAssistantActions };
|
467
324
|
});
|
468
325
|
const getModelConfig = context.useModelConfig();
|
469
|
-
(0,
|
326
|
+
_react.useEffect.call(void 0, () => {
|
470
327
|
return runtime.registerModelConfigProvider(getModelConfig);
|
471
328
|
}, [runtime, getModelConfig]);
|
472
|
-
return /* @__PURE__ */ (0,
|
329
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantContext.Provider, { value: context, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadProvider, { provider: runtime, children }) });
|
473
330
|
};
|
474
331
|
|
475
332
|
// src/context/providers/AssistantRuntimeProvider.tsx
|
476
|
-
|
333
|
+
|
477
334
|
var AssistantRuntimeProviderImpl = ({ children, runtime }) => {
|
478
|
-
return /* @__PURE__ */ (0,
|
335
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantProvider, { runtime, children });
|
479
336
|
};
|
480
|
-
var AssistantRuntimeProvider = (0,
|
337
|
+
var AssistantRuntimeProvider = _react.memo.call(void 0, AssistantRuntimeProviderImpl);
|
481
338
|
|
482
339
|
// src/context/react/ComposerContext.ts
|
483
|
-
|
340
|
+
|
484
341
|
|
485
342
|
// src/context/react/MessageContext.ts
|
486
|
-
|
487
|
-
var MessageContext = (0,
|
343
|
+
|
344
|
+
var MessageContext = _react.createContext.call(void 0, null);
|
488
345
|
function useMessageContext(options) {
|
489
|
-
const context = (0,
|
490
|
-
if (!options
|
346
|
+
const context = _react.useContext.call(void 0, MessageContext);
|
347
|
+
if (!_optionalChain([options, 'optionalAccess', _11 => _11.optional]) && !context)
|
491
348
|
throw new Error(
|
492
349
|
"This component can only be used inside a component passed to <ThreadPrimitive.Messages components={...} />."
|
493
350
|
);
|
@@ -497,10 +354,10 @@ function useMessageContext(options) {
|
|
497
354
|
// src/context/react/ComposerContext.ts
|
498
355
|
var useComposerContext = () => {
|
499
356
|
const { useComposer } = useThreadContext();
|
500
|
-
const { useEditComposer } = useMessageContext({ optional: true })
|
501
|
-
return (0,
|
357
|
+
const { useEditComposer } = _nullishCoalesce(useMessageContext({ optional: true }), () => ( {}));
|
358
|
+
return _react.useMemo.call(void 0,
|
502
359
|
() => ({
|
503
|
-
useComposer: useEditComposer
|
360
|
+
useComposer: _nullishCoalesce(useEditComposer, () => ( useComposer)),
|
504
361
|
type: useEditComposer ? "edit" : "new"
|
505
362
|
}),
|
506
363
|
[useEditComposer, useComposer]
|
@@ -508,13 +365,13 @@ var useComposerContext = () => {
|
|
508
365
|
};
|
509
366
|
|
510
367
|
// src/context/react/ContentPartContext.ts
|
511
|
-
|
512
|
-
var ContentPartContext = (0,
|
368
|
+
|
369
|
+
var ContentPartContext = _react.createContext.call(void 0,
|
513
370
|
null
|
514
371
|
);
|
515
372
|
function useContentPartContext(options) {
|
516
|
-
const context = (0,
|
517
|
-
if (!options
|
373
|
+
const context = _react.useContext.call(void 0, ContentPartContext);
|
374
|
+
if (!_optionalChain([options, 'optionalAccess', _12 => _12.optional]) && !context)
|
518
375
|
throw new Error(
|
519
376
|
"This component can only be used inside a component passed to <MessagePrimitive.Content components={...} >."
|
520
377
|
);
|
@@ -522,24 +379,24 @@ function useContentPartContext(options) {
|
|
522
379
|
}
|
523
380
|
|
524
381
|
// src/hooks/useAppendMessage.tsx
|
525
|
-
|
382
|
+
|
526
383
|
var toAppendMessage = (useThreadMessages, message) => {
|
527
384
|
if (typeof message === "string") {
|
528
385
|
return {
|
529
|
-
parentId: useThreadMessages.getState().at(-1)
|
386
|
+
parentId: _nullishCoalesce(_optionalChain([useThreadMessages, 'access', _13 => _13.getState, 'call', _14 => _14(), 'access', _15 => _15.at, 'call', _16 => _16(-1), 'optionalAccess', _17 => _17.id]), () => ( null)),
|
530
387
|
role: "user",
|
531
388
|
content: [{ type: "text", text: message }]
|
532
389
|
};
|
533
390
|
}
|
534
391
|
return {
|
535
|
-
parentId: message.parentId
|
536
|
-
role: message.role
|
392
|
+
parentId: _nullishCoalesce(_nullishCoalesce(message.parentId, () => ( _optionalChain([useThreadMessages, 'access', _18 => _18.getState, 'call', _19 => _19(), 'access', _20 => _20.at, 'call', _21 => _21(-1), 'optionalAccess', _22 => _22.id]))), () => ( null)),
|
393
|
+
role: _nullishCoalesce(message.role, () => ( "user")),
|
537
394
|
content: message.content
|
538
395
|
};
|
539
396
|
};
|
540
397
|
var useAppendMessage = () => {
|
541
398
|
const { useThreadMessages, useThreadActions, useViewport, useComposer } = useThreadContext();
|
542
|
-
const append = (0,
|
399
|
+
const append = _react.useCallback.call(void 0,
|
543
400
|
(message) => {
|
544
401
|
const appendMessage = toAppendMessage(useThreadMessages, message);
|
545
402
|
useThreadActions.getState().append(appendMessage);
|
@@ -552,11 +409,11 @@ var useAppendMessage = () => {
|
|
552
409
|
};
|
553
410
|
|
554
411
|
// src/hooks/useSwitchToNewThread.tsx
|
555
|
-
|
412
|
+
|
556
413
|
var useSwitchToNewThread = () => {
|
557
414
|
const { useAssistantActions } = useAssistantContext();
|
558
415
|
const { useComposer } = useThreadContext();
|
559
|
-
const switchToNewThread = (0,
|
416
|
+
const switchToNewThread = _react.useCallback.call(void 0, () => {
|
560
417
|
useAssistantActions.getState().switchToThread(null);
|
561
418
|
useComposer.getState().focus();
|
562
419
|
}, [useAssistantActions, useComposer]);
|
@@ -564,14 +421,14 @@ var useSwitchToNewThread = () => {
|
|
564
421
|
};
|
565
422
|
|
566
423
|
// src/model-config/useAssistantTool.tsx
|
567
|
-
|
424
|
+
|
568
425
|
var useAssistantTool = (tool) => {
|
569
426
|
const { useModelConfig, useToolUIs } = useAssistantContext();
|
570
427
|
const registerModelConfigProvider = useModelConfig(
|
571
428
|
(s) => s.registerModelConfigProvider
|
572
429
|
);
|
573
430
|
const setToolUI = useToolUIs((s) => s.setToolUI);
|
574
|
-
(0,
|
431
|
+
_react.useEffect.call(void 0, () => {
|
575
432
|
const { toolName, render, ...rest } = tool;
|
576
433
|
const config = {
|
577
434
|
tools: {
|
@@ -584,7 +441,7 @@ var useAssistantTool = (tool) => {
|
|
584
441
|
const unsub2 = render ? setToolUI(toolName, render) : void 0;
|
585
442
|
return () => {
|
586
443
|
unsub1();
|
587
|
-
unsub2
|
444
|
+
_optionalChain([unsub2, 'optionalCall', _23 => _23()]);
|
588
445
|
};
|
589
446
|
}, [registerModelConfigProvider, setToolUI, tool]);
|
590
447
|
};
|
@@ -599,11 +456,11 @@ var makeAssistantTool = (tool) => {
|
|
599
456
|
};
|
600
457
|
|
601
458
|
// src/model-config/useAssistantToolUI.tsx
|
602
|
-
|
459
|
+
|
603
460
|
var useAssistantToolUI = (tool) => {
|
604
461
|
const { useToolUIs } = useAssistantContext();
|
605
462
|
const setToolUI = useToolUIs((s) => s.setToolUI);
|
606
|
-
(0,
|
463
|
+
_react.useEffect.call(void 0, () => {
|
607
464
|
if (!tool) return;
|
608
465
|
const { toolName, render } = tool;
|
609
466
|
return setToolUI(toolName, render);
|
@@ -620,13 +477,13 @@ var makeAssistantToolUI = (tool) => {
|
|
620
477
|
};
|
621
478
|
|
622
479
|
// src/model-config/useAssistantInstructions.tsx
|
623
|
-
|
480
|
+
|
624
481
|
var useAssistantInstructions = (instruction) => {
|
625
482
|
const { useModelConfig } = useAssistantContext();
|
626
483
|
const registerModelConfigProvider = useModelConfig(
|
627
484
|
(s) => s.registerModelConfigProvider
|
628
485
|
);
|
629
|
-
(0,
|
486
|
+
_react.useEffect.call(void 0, () => {
|
630
487
|
const config = {
|
631
488
|
system: instruction
|
632
489
|
};
|
@@ -635,13 +492,13 @@ var useAssistantInstructions = (instruction) => {
|
|
635
492
|
};
|
636
493
|
|
637
494
|
// src/primitive-hooks/actionBar/useActionBarCopy.tsx
|
638
|
-
|
495
|
+
|
639
496
|
|
640
497
|
// src/utils/combined/useCombinedStore.ts
|
641
|
-
|
498
|
+
|
642
499
|
|
643
500
|
// src/utils/combined/createCombinedStore.ts
|
644
|
-
|
501
|
+
|
645
502
|
var createCombinedStore = (stores) => {
|
646
503
|
const subscribe = (callback) => {
|
647
504
|
const unsubscribes = stores.map((store) => store.subscribe(callback));
|
@@ -653,13 +510,13 @@ var createCombinedStore = (stores) => {
|
|
653
510
|
};
|
654
511
|
return (selector) => {
|
655
512
|
const getSnapshot = () => selector(...stores.map((store) => store.getState()));
|
656
|
-
return (0,
|
513
|
+
return _react.useSyncExternalStore.call(void 0, subscribe, getSnapshot, getSnapshot);
|
657
514
|
};
|
658
515
|
};
|
659
516
|
|
660
517
|
// src/utils/combined/useCombinedStore.ts
|
661
518
|
var useCombinedStore = (stores, selector) => {
|
662
|
-
const useCombined = (0,
|
519
|
+
const useCombined = _react.useMemo.call(void 0, () => createCombinedStore(stores), stores);
|
663
520
|
return useCombined(selector);
|
664
521
|
};
|
665
522
|
|
@@ -682,7 +539,7 @@ var useActionBarCopy = ({
|
|
682
539
|
return !c.isEditing && m.message.content.some((c2) => c2.type === "text" && c2.text.length > 0);
|
683
540
|
}
|
684
541
|
);
|
685
|
-
const callback = (0,
|
542
|
+
const callback = _react.useCallback.call(void 0, () => {
|
686
543
|
const { message } = useMessage.getState();
|
687
544
|
const { setIsCopied } = useMessageUtils.getState();
|
688
545
|
const { isEditing, value: composerValue } = useEditComposer.getState();
|
@@ -697,14 +554,14 @@ var useActionBarCopy = ({
|
|
697
554
|
};
|
698
555
|
|
699
556
|
// src/primitive-hooks/actionBar/useActionBarEdit.tsx
|
700
|
-
|
557
|
+
|
701
558
|
var useActionBarEdit = () => {
|
702
559
|
const { useMessage, useEditComposer } = useMessageContext();
|
703
560
|
const disabled = useCombinedStore(
|
704
561
|
[useMessage, useEditComposer],
|
705
562
|
(m, c) => m.message.role !== "user" || c.isEditing
|
706
563
|
);
|
707
|
-
const callback = (0,
|
564
|
+
const callback = _react.useCallback.call(void 0, () => {
|
708
565
|
const { edit } = useEditComposer.getState();
|
709
566
|
edit();
|
710
567
|
}, [useEditComposer]);
|
@@ -713,7 +570,7 @@ var useActionBarEdit = () => {
|
|
713
570
|
};
|
714
571
|
|
715
572
|
// src/primitive-hooks/actionBar/useActionBarReload.tsx
|
716
|
-
|
573
|
+
|
717
574
|
var useActionBarReload = () => {
|
718
575
|
const { useThread, useThreadActions, useComposer, useViewport } = useThreadContext();
|
719
576
|
const { useMessage } = useMessageContext();
|
@@ -721,7 +578,7 @@ var useActionBarReload = () => {
|
|
721
578
|
[useThread, useMessage],
|
722
579
|
(t, m) => t.isRunning || t.isDisabled || m.message.role !== "assistant"
|
723
580
|
);
|
724
|
-
const callback = (0,
|
581
|
+
const callback = _react.useCallback.call(void 0, () => {
|
725
582
|
const { parentId } = useMessage.getState();
|
726
583
|
useThreadActions.getState().startRun(parentId);
|
727
584
|
useViewport.getState().scrollToBottom();
|
@@ -739,7 +596,7 @@ var useBranchPickerCount = () => {
|
|
739
596
|
};
|
740
597
|
|
741
598
|
// src/primitive-hooks/branchPicker/useBranchPickerNext.tsx
|
742
|
-
|
599
|
+
|
743
600
|
var useBranchPickerNext = () => {
|
744
601
|
const { useThreadActions } = useThreadContext();
|
745
602
|
const { useMessage, useEditComposer } = useMessageContext();
|
@@ -747,7 +604,7 @@ var useBranchPickerNext = () => {
|
|
747
604
|
[useMessage, useEditComposer],
|
748
605
|
(m, c) => c.isEditing || m.branches.indexOf(m.message.id) + 1 >= m.branches.length
|
749
606
|
);
|
750
|
-
const callback = (0,
|
607
|
+
const callback = _react.useCallback.call(void 0, () => {
|
751
608
|
const { message, branches } = useMessage.getState();
|
752
609
|
useThreadActions.getState().switchToBranch(branches[branches.indexOf(message.id) + 1]);
|
753
610
|
}, [useThreadActions, useMessage]);
|
@@ -763,7 +620,7 @@ var useBranchPickerNumber = () => {
|
|
763
620
|
};
|
764
621
|
|
765
622
|
// src/primitive-hooks/branchPicker/useBranchPickerPrevious.tsx
|
766
|
-
|
623
|
+
|
767
624
|
var useBranchPickerPrevious = () => {
|
768
625
|
const { useThreadActions } = useThreadContext();
|
769
626
|
const { useMessage, useEditComposer } = useMessageContext();
|
@@ -771,7 +628,7 @@ var useBranchPickerPrevious = () => {
|
|
771
628
|
[useMessage, useEditComposer],
|
772
629
|
(m, c) => c.isEditing || m.branches.indexOf(m.message.id) <= 0
|
773
630
|
);
|
774
|
-
const callback = (0,
|
631
|
+
const callback = _react.useCallback.call(void 0, () => {
|
775
632
|
const { message, branches } = useMessage.getState();
|
776
633
|
useThreadActions.getState().switchToBranch(branches[branches.indexOf(message.id) - 1]);
|
777
634
|
}, [useThreadActions, useMessage]);
|
@@ -780,11 +637,11 @@ var useBranchPickerPrevious = () => {
|
|
780
637
|
};
|
781
638
|
|
782
639
|
// src/primitive-hooks/composer/useComposerCancel.tsx
|
783
|
-
|
640
|
+
|
784
641
|
var useComposerCancel = () => {
|
785
642
|
const { useComposer } = useComposerContext();
|
786
643
|
const disabled = useComposer((c) => !c.canCancel);
|
787
|
-
const callback = (0,
|
644
|
+
const callback = _react.useCallback.call(void 0, () => {
|
788
645
|
const { cancel } = useComposer.getState();
|
789
646
|
cancel();
|
790
647
|
}, [useComposer]);
|
@@ -803,7 +660,7 @@ var useComposerIf = (props) => {
|
|
803
660
|
};
|
804
661
|
|
805
662
|
// src/primitive-hooks/composer/useComposerSend.tsx
|
806
|
-
|
663
|
+
|
807
664
|
var useComposerSend = () => {
|
808
665
|
const {
|
809
666
|
useThread,
|
@@ -815,7 +672,7 @@ var useComposerSend = () => {
|
|
815
672
|
[useThread, useComposer],
|
816
673
|
(t, c) => t.isDisabled || t.isRunning || !c.isEditing || c.value.length === 0
|
817
674
|
);
|
818
|
-
const callback = (0,
|
675
|
+
const callback = _react.useCallback.call(void 0, () => {
|
819
676
|
const composerState = useComposer.getState();
|
820
677
|
if (!composerState.isEditing) return;
|
821
678
|
composerState.send();
|
@@ -906,11 +763,11 @@ var useThreadEmpty = () => {
|
|
906
763
|
};
|
907
764
|
|
908
765
|
// src/primitive-hooks/thread/useThreadScrollToBottom.tsx
|
909
|
-
|
766
|
+
|
910
767
|
var useThreadScrollToBottom = () => {
|
911
768
|
const { useComposer, useViewport } = useThreadContext();
|
912
769
|
const isAtBottom = useViewport((s) => s.isAtBottom);
|
913
|
-
const handleScrollToBottom = (0,
|
770
|
+
const handleScrollToBottom = _react.useCallback.call(void 0, () => {
|
914
771
|
useViewport.getState().scrollToBottom();
|
915
772
|
useComposer.getState().focus();
|
916
773
|
}, [useViewport, useComposer]);
|
@@ -919,7 +776,7 @@ var useThreadScrollToBottom = () => {
|
|
919
776
|
};
|
920
777
|
|
921
778
|
// src/primitive-hooks/thread/useThreadSuggestion.tsx
|
922
|
-
|
779
|
+
|
923
780
|
var useThreadSuggestion = ({
|
924
781
|
prompt,
|
925
782
|
autoSend
|
@@ -927,7 +784,7 @@ var useThreadSuggestion = ({
|
|
927
784
|
const { useThread, useComposer } = useThreadContext();
|
928
785
|
const append = useAppendMessage();
|
929
786
|
const disabled = useThread((t) => t.isDisabled);
|
930
|
-
const callback = (0,
|
787
|
+
const callback = _react.useCallback.call(void 0, () => {
|
931
788
|
const thread = useThread.getState();
|
932
789
|
const composer = useComposer.getState();
|
933
790
|
if (autoSend && !thread.isRunning) {
|
@@ -943,7 +800,7 @@ var useThreadSuggestion = ({
|
|
943
800
|
|
944
801
|
// src/primitives/actionBar/index.ts
|
945
802
|
var actionBar_exports = {};
|
946
|
-
__export(actionBar_exports, {
|
803
|
+
_chunkDCHYNTHIjs.__export.call(void 0, actionBar_exports, {
|
947
804
|
Copy: () => ActionBarPrimitiveCopy,
|
948
805
|
Edit: () => ActionBarPrimitiveEdit,
|
949
806
|
Reload: () => ActionBarPrimitiveReload,
|
@@ -951,8 +808,8 @@ __export(actionBar_exports, {
|
|
951
808
|
});
|
952
809
|
|
953
810
|
// src/primitives/actionBar/ActionBarRoot.tsx
|
954
|
-
var
|
955
|
-
|
811
|
+
var _reactprimitive = require('@radix-ui/react-primitive');
|
812
|
+
|
956
813
|
|
957
814
|
// src/primitives/actionBar/useActionBarFloatStatus.tsx
|
958
815
|
var useActionBarFloatStatus = ({
|
@@ -977,16 +834,16 @@ var useActionBarFloatStatus = ({
|
|
977
834
|
};
|
978
835
|
|
979
836
|
// src/primitives/actionBar/ActionBarRoot.tsx
|
980
|
-
|
981
|
-
var ActionBarPrimitiveRoot = (0,
|
837
|
+
|
838
|
+
var ActionBarPrimitiveRoot = _react.forwardRef.call(void 0, ({ hideWhenRunning, autohide, autohideFloat, ...rest }, ref) => {
|
982
839
|
const hideAndfloatStatus = useActionBarFloatStatus({
|
983
840
|
hideWhenRunning,
|
984
841
|
autohide,
|
985
842
|
autohideFloat
|
986
843
|
});
|
987
844
|
if (hideAndfloatStatus === "hidden" /* Hidden */) return null;
|
988
|
-
return /* @__PURE__ */ (0,
|
989
|
-
|
845
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
846
|
+
_reactprimitive.Primitive.div,
|
990
847
|
{
|
991
848
|
...hideAndfloatStatus === "floating" /* Floating */ ? { "data-floating": "true" } : null,
|
992
849
|
...rest,
|
@@ -997,12 +854,12 @@ var ActionBarPrimitiveRoot = (0, import_react26.forwardRef)(({ hideWhenRunning,
|
|
997
854
|
ActionBarPrimitiveRoot.displayName = "ActionBarPrimitive.Root";
|
998
855
|
|
999
856
|
// src/utils/createActionButton.tsx
|
1000
|
-
|
1001
|
-
|
1002
|
-
var
|
1003
|
-
|
857
|
+
|
858
|
+
|
859
|
+
var _primitive = require('@radix-ui/primitive');
|
860
|
+
|
1004
861
|
var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
1005
|
-
const ActionButton = (0,
|
862
|
+
const ActionButton = _react.forwardRef.call(void 0, (props, forwardedRef) => {
|
1006
863
|
const forwardedProps = {};
|
1007
864
|
const primitiveProps = {};
|
1008
865
|
Object.keys(props).forEach((key) => {
|
@@ -1013,15 +870,15 @@ var createActionButton = (displayName, useActionButton, forwardProps = []) => {
|
|
1013
870
|
}
|
1014
871
|
});
|
1015
872
|
const callback = useActionButton(forwardedProps);
|
1016
|
-
return /* @__PURE__ */ (0,
|
1017
|
-
|
873
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
874
|
+
_reactprimitive.Primitive.button,
|
1018
875
|
{
|
1019
876
|
type: "button",
|
1020
877
|
disabled: !callback,
|
1021
878
|
...primitiveProps,
|
1022
879
|
ref: forwardedRef,
|
1023
|
-
onClick: (0,
|
1024
|
-
callback
|
880
|
+
onClick: _primitive.composeEventHandlers.call(void 0, primitiveProps.onClick, () => {
|
881
|
+
_optionalChain([callback, 'optionalCall', _24 => _24()]);
|
1025
882
|
})
|
1026
883
|
}
|
1027
884
|
);
|
@@ -1051,7 +908,7 @@ var ActionBarPrimitiveEdit = createActionButton(
|
|
1051
908
|
|
1052
909
|
// src/primitives/assistantModal/index.ts
|
1053
910
|
var assistantModal_exports = {};
|
1054
|
-
__export(assistantModal_exports, {
|
911
|
+
_chunkDCHYNTHIjs.__export.call(void 0, assistantModal_exports, {
|
1055
912
|
Anchor: () => AssistantModalPrimitiveAnchor,
|
1056
913
|
Content: () => AssistantModalPrimitiveContent,
|
1057
914
|
Root: () => AssistantModalPrimitiveRoot,
|
@@ -1059,17 +916,17 @@ __export(assistantModal_exports, {
|
|
1059
916
|
});
|
1060
917
|
|
1061
918
|
// src/primitives/assistantModal/AssistantModalRoot.tsx
|
1062
|
-
|
1063
|
-
var
|
1064
|
-
|
919
|
+
|
920
|
+
var _reactpopover = require('@radix-ui/react-popover'); var PopoverPrimitive2 = _interopRequireWildcard(_reactpopover); var PopoverPrimitive = _interopRequireWildcard(_reactpopover); var PopoverPrimitive3 = _interopRequireWildcard(_reactpopover); var PopoverPrimitive4 = _interopRequireWildcard(_reactpopover); var PopoverPrimitive5 = _interopRequireWildcard(_reactpopover);
|
921
|
+
|
1065
922
|
|
1066
923
|
// src/utils/hooks/useOnComposerFocus.tsx
|
1067
|
-
var
|
1068
|
-
|
924
|
+
var _reactusecallbackref = require('@radix-ui/react-use-callback-ref');
|
925
|
+
|
1069
926
|
var useOnComposerFocus = (callback) => {
|
1070
|
-
const callbackRef = (0,
|
927
|
+
const callbackRef = _reactusecallbackref.useCallbackRef.call(void 0, callback);
|
1071
928
|
const { useComposer } = useThreadContext();
|
1072
|
-
(0,
|
929
|
+
_react.useEffect.call(void 0, () => {
|
1073
930
|
return useComposer.getState().onFocus(() => {
|
1074
931
|
callbackRef();
|
1075
932
|
});
|
@@ -1077,13 +934,13 @@ var useOnComposerFocus = (callback) => {
|
|
1077
934
|
};
|
1078
935
|
|
1079
936
|
// src/primitives/assistantModal/scope.tsx
|
1080
|
-
|
937
|
+
|
1081
938
|
var usePopoverScope = PopoverPrimitive.createPopoverScope();
|
1082
939
|
|
1083
940
|
// src/primitives/assistantModal/AssistantModalRoot.tsx
|
1084
|
-
|
941
|
+
|
1085
942
|
var useAssistantModalOpenState = (defaultOpen = false) => {
|
1086
|
-
const state = (0,
|
943
|
+
const state = _react.useState.call(void 0, defaultOpen);
|
1087
944
|
const [, setOpen] = state;
|
1088
945
|
useOnComposerFocus(() => {
|
1089
946
|
setOpen(true);
|
@@ -1099,12 +956,12 @@ var AssistantModalPrimitiveRoot = ({
|
|
1099
956
|
}) => {
|
1100
957
|
const scope = usePopoverScope(__scopeAssistantModal);
|
1101
958
|
const [modalOpen, setOpen] = useAssistantModalOpenState(defaultOpen);
|
1102
|
-
return /* @__PURE__ */ (0,
|
959
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
1103
960
|
PopoverPrimitive2.Root,
|
1104
961
|
{
|
1105
962
|
...scope,
|
1106
963
|
open: open === void 0 ? modalOpen : open,
|
1107
|
-
onOpenChange: (0,
|
964
|
+
onOpenChange: _primitive.composeEventHandlers.call(void 0, onOpenChange, setOpen),
|
1108
965
|
...rest
|
1109
966
|
}
|
1110
967
|
);
|
@@ -1112,26 +969,26 @@ var AssistantModalPrimitiveRoot = ({
|
|
1112
969
|
AssistantModalPrimitiveRoot.displayName = "AssistantModalPrimitive.Root";
|
1113
970
|
|
1114
971
|
// src/primitives/assistantModal/AssistantModalTrigger.tsx
|
1115
|
-
|
1116
|
-
|
1117
|
-
|
1118
|
-
var AssistantModalPrimitiveTrigger = (0,
|
972
|
+
|
973
|
+
|
974
|
+
|
975
|
+
var AssistantModalPrimitiveTrigger = _react.forwardRef.call(void 0,
|
1119
976
|
({
|
1120
977
|
__scopeAssistantModal,
|
1121
978
|
...rest
|
1122
979
|
}, ref) => {
|
1123
980
|
const scope = usePopoverScope(__scopeAssistantModal);
|
1124
|
-
return /* @__PURE__ */ (0,
|
981
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverPrimitive3.Trigger, { ...scope, ...rest, ref });
|
1125
982
|
}
|
1126
983
|
);
|
1127
984
|
AssistantModalPrimitiveTrigger.displayName = "AssistantModalPrimitive.Trigger";
|
1128
985
|
|
1129
986
|
// src/primitives/assistantModal/AssistantModalContent.tsx
|
1130
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
1134
|
-
var AssistantModalPrimitiveContent = (0,
|
987
|
+
|
988
|
+
|
989
|
+
|
990
|
+
|
991
|
+
var AssistantModalPrimitiveContent = _react.forwardRef.call(void 0,
|
1135
992
|
({
|
1136
993
|
__scopeAssistantModal,
|
1137
994
|
side,
|
@@ -1141,15 +998,15 @@ var AssistantModalPrimitiveContent = (0, import_react31.forwardRef)(
|
|
1141
998
|
...props
|
1142
999
|
}, forwardedRef) => {
|
1143
1000
|
const scope = usePopoverScope(__scopeAssistantModal);
|
1144
|
-
return /* @__PURE__ */ (0,
|
1001
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverPrimitive4.Portal, { ...scope, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
1145
1002
|
PopoverPrimitive4.Content,
|
1146
1003
|
{
|
1147
1004
|
...scope,
|
1148
1005
|
...props,
|
1149
1006
|
ref: forwardedRef,
|
1150
|
-
side: side
|
1151
|
-
align: align
|
1152
|
-
onInteractOutside: (0,
|
1007
|
+
side: _nullishCoalesce(side, () => ( "top")),
|
1008
|
+
align: _nullishCoalesce(align, () => ( "end")),
|
1009
|
+
onInteractOutside: _primitive.composeEventHandlers.call(void 0,
|
1153
1010
|
onInteractOutside,
|
1154
1011
|
dissmissOnInteractOutside ? void 0 : (e) => e.preventDefault()
|
1155
1012
|
)
|
@@ -1160,23 +1017,23 @@ var AssistantModalPrimitiveContent = (0, import_react31.forwardRef)(
|
|
1160
1017
|
AssistantModalPrimitiveContent.displayName = "AssistantModalPrimitive.Content";
|
1161
1018
|
|
1162
1019
|
// src/primitives/assistantModal/AssistantModalAnchor.tsx
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
var AssistantModalPrimitiveAnchor = (0,
|
1020
|
+
|
1021
|
+
|
1022
|
+
|
1023
|
+
var AssistantModalPrimitiveAnchor = _react.forwardRef.call(void 0,
|
1167
1024
|
({
|
1168
1025
|
__scopeAssistantModal,
|
1169
1026
|
...rest
|
1170
1027
|
}, ref) => {
|
1171
1028
|
const scope = usePopoverScope(__scopeAssistantModal);
|
1172
|
-
return /* @__PURE__ */ (0,
|
1029
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PopoverPrimitive5.Anchor, { ...scope, ...rest, ref });
|
1173
1030
|
}
|
1174
1031
|
);
|
1175
1032
|
AssistantModalPrimitiveAnchor.displayName = "AssistantModalPrimitive.Anchor";
|
1176
1033
|
|
1177
1034
|
// src/primitives/branchPicker/index.ts
|
1178
1035
|
var branchPicker_exports = {};
|
1179
|
-
__export(branchPicker_exports, {
|
1036
|
+
_chunkDCHYNTHIjs.__export.call(void 0, branchPicker_exports, {
|
1180
1037
|
Count: () => BranchPickerPrimitiveCount,
|
1181
1038
|
Next: () => BranchPickerPrimitiveNext,
|
1182
1039
|
Number: () => BranchPickerPrimitiveNumber,
|
@@ -1197,28 +1054,28 @@ var BranchPickerPrevious = createActionButton(
|
|
1197
1054
|
);
|
1198
1055
|
|
1199
1056
|
// src/primitives/branchPicker/BranchPickerCount.tsx
|
1200
|
-
|
1057
|
+
|
1201
1058
|
var BranchPickerPrimitiveCount = () => {
|
1202
1059
|
const branchCount = useBranchPickerCount();
|
1203
|
-
return /* @__PURE__ */ (0,
|
1060
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: branchCount });
|
1204
1061
|
};
|
1205
1062
|
BranchPickerPrimitiveCount.displayName = "BranchPickerPrimitive.Count";
|
1206
1063
|
|
1207
1064
|
// src/primitives/branchPicker/BranchPickerNumber.tsx
|
1208
|
-
|
1065
|
+
|
1209
1066
|
var BranchPickerPrimitiveNumber = () => {
|
1210
1067
|
const branchNumber = useBranchPickerNumber();
|
1211
|
-
return /* @__PURE__ */ (0,
|
1068
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: branchNumber });
|
1212
1069
|
};
|
1213
1070
|
BranchPickerPrimitiveNumber.displayName = "BranchPickerPrimitive.Number";
|
1214
1071
|
|
1215
1072
|
// src/primitives/branchPicker/BranchPickerRoot.tsx
|
1216
|
-
|
1217
|
-
|
1073
|
+
|
1074
|
+
|
1218
1075
|
|
1219
1076
|
// src/primitives/message/index.ts
|
1220
1077
|
var message_exports = {};
|
1221
|
-
__export(message_exports, {
|
1078
|
+
_chunkDCHYNTHIjs.__export.call(void 0, message_exports, {
|
1222
1079
|
Content: () => MessagePrimitiveContent,
|
1223
1080
|
If: () => MessagePrimitiveIf,
|
1224
1081
|
InProgress: () => MessagePrimitiveInProgress,
|
@@ -1226,13 +1083,16 @@ __export(message_exports, {
|
|
1226
1083
|
});
|
1227
1084
|
|
1228
1085
|
// src/primitives/message/MessageRoot.tsx
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1086
|
+
|
1087
|
+
|
1088
|
+
|
1089
|
+
|
1090
|
+
|
1091
|
+
var _reactcomposerefs = require('@radix-ui/react-compose-refs');
|
1092
|
+
|
1233
1093
|
var useIsHoveringRef = () => {
|
1234
1094
|
const { useMessageUtils } = useMessageContext();
|
1235
|
-
const callbackRef = (0,
|
1095
|
+
const callbackRef = _react.useCallback.call(void 0,
|
1236
1096
|
(el) => {
|
1237
1097
|
const setIsHovering = useMessageUtils.getState().setIsHovering;
|
1238
1098
|
const handleMouseEnter = () => {
|
@@ -1253,10 +1113,10 @@ var useIsHoveringRef = () => {
|
|
1253
1113
|
);
|
1254
1114
|
return useManagedRef(callbackRef);
|
1255
1115
|
};
|
1256
|
-
var MessagePrimitiveRoot = (0,
|
1116
|
+
var MessagePrimitiveRoot = _react.forwardRef.call(void 0, ({ onMouseEnter, onMouseLeave, ...rest }, forwardRef29) => {
|
1257
1117
|
const isHoveringRef = useIsHoveringRef();
|
1258
|
-
const ref = (0,
|
1259
|
-
return /* @__PURE__ */ (0,
|
1118
|
+
const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardRef29, isHoveringRef);
|
1119
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...rest, ref });
|
1260
1120
|
});
|
1261
1121
|
MessagePrimitiveRoot.displayName = "MessagePrimitive.Root";
|
1262
1122
|
|
@@ -1271,12 +1131,12 @@ var MessagePrimitiveIf = ({
|
|
1271
1131
|
MessagePrimitiveIf.displayName = "MessagePrimitive.If";
|
1272
1132
|
|
1273
1133
|
// src/primitives/message/MessageContent.tsx
|
1274
|
-
|
1134
|
+
|
1275
1135
|
|
1276
1136
|
// src/context/providers/ContentPartProvider.tsx
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
1137
|
+
|
1138
|
+
|
1139
|
+
|
1280
1140
|
var COMPLETE_STATUS = {
|
1281
1141
|
type: "complete"
|
1282
1142
|
};
|
@@ -1306,20 +1166,20 @@ var getContentPartState = ({ message }, useContentPart, partIndex) => {
|
|
1306
1166
|
}
|
1307
1167
|
}
|
1308
1168
|
const status = toContentPartStatus(message, partIndex, part);
|
1309
|
-
const currentState = useContentPart
|
1169
|
+
const currentState = _optionalChain([useContentPart, 'optionalAccess', _25 => _25.getState, 'call', _26 => _26()]);
|
1310
1170
|
if (currentState && currentState.part === part && currentState.status === status)
|
1311
1171
|
return null;
|
1312
1172
|
return Object.freeze({ part, status });
|
1313
1173
|
};
|
1314
1174
|
var useContentPartContext2 = (partIndex) => {
|
1315
1175
|
const { useMessage } = useMessageContext();
|
1316
|
-
const [context] = (0,
|
1317
|
-
const useContentPart = (0,
|
1176
|
+
const [context] = _react.useState.call(void 0, () => {
|
1177
|
+
const useContentPart = _zustand.create.call(void 0,
|
1318
1178
|
() => getContentPartState(useMessage.getState(), void 0, partIndex)
|
1319
1179
|
);
|
1320
1180
|
return { useContentPart };
|
1321
1181
|
});
|
1322
|
-
(0,
|
1182
|
+
_react.useEffect.call(void 0, () => {
|
1323
1183
|
const syncContentPart = (message) => {
|
1324
1184
|
const newState = getContentPartState(
|
1325
1185
|
message,
|
@@ -1339,43 +1199,50 @@ var ContentPartProvider = ({
|
|
1339
1199
|
children
|
1340
1200
|
}) => {
|
1341
1201
|
const context = useContentPartContext2(partIndex);
|
1342
|
-
return /* @__PURE__ */ (0,
|
1202
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartContext.Provider, { value: context, children });
|
1343
1203
|
};
|
1344
1204
|
|
1345
1205
|
// src/primitives/contentPart/ContentPartText.tsx
|
1346
|
-
|
1206
|
+
|
1207
|
+
|
1208
|
+
|
1347
1209
|
|
1348
1210
|
// src/utils/smooth/useSmooth.tsx
|
1349
|
-
|
1211
|
+
|
1350
1212
|
|
1351
1213
|
// src/utils/smooth/SmoothContext.tsx
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1214
|
+
|
1215
|
+
|
1216
|
+
|
1217
|
+
|
1218
|
+
|
1219
|
+
|
1220
|
+
|
1221
|
+
|
1222
|
+
var SmoothContext = _react.createContext.call(void 0, null);
|
1356
1223
|
var makeSmoothContext = (initialState) => {
|
1357
|
-
const useSmoothStatus2 = (0,
|
1224
|
+
const useSmoothStatus2 = _zustand.create.call(void 0, () => initialState);
|
1358
1225
|
return { useSmoothStatus: useSmoothStatus2 };
|
1359
1226
|
};
|
1360
1227
|
var SmoothContextProvider = ({ children }) => {
|
1361
1228
|
const outer = useSmoothContext({ optional: true });
|
1362
1229
|
const { useContentPart } = useContentPartContext();
|
1363
|
-
const [context] = (0,
|
1230
|
+
const [context] = _react.useState.call(void 0,
|
1364
1231
|
() => makeSmoothContext(useContentPart.getState().status)
|
1365
1232
|
);
|
1366
1233
|
if (outer) return children;
|
1367
|
-
return /* @__PURE__ */ (0,
|
1234
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmoothContext.Provider, { value: context, children });
|
1368
1235
|
};
|
1369
1236
|
var withSmoothContextProvider = (Component) => {
|
1370
|
-
const Wrapped = (0,
|
1371
|
-
return /* @__PURE__ */ (0,
|
1237
|
+
const Wrapped = _react.forwardRef.call(void 0, (props, ref) => {
|
1238
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SmoothContextProvider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { ...props, ref }) });
|
1372
1239
|
});
|
1373
1240
|
Wrapped.displayName = Component.displayName;
|
1374
1241
|
return Wrapped;
|
1375
1242
|
};
|
1376
1243
|
function useSmoothContext(options) {
|
1377
|
-
const context = (0,
|
1378
|
-
if (!options
|
1244
|
+
const context = _react.useContext.call(void 0, SmoothContext);
|
1245
|
+
if (!_optionalChain([options, 'optionalAccess', _27 => _27.optional]) && !context)
|
1379
1246
|
throw new Error(
|
1380
1247
|
"This component must be used within a SmoothContextProvider."
|
1381
1248
|
);
|
@@ -1387,15 +1254,15 @@ var useSmoothStatus = () => {
|
|
1387
1254
|
};
|
1388
1255
|
|
1389
1256
|
// src/utils/smooth/useSmooth.tsx
|
1390
|
-
|
1391
|
-
var TextStreamAnimator = class {
|
1392
|
-
constructor(currentText, setText) {
|
1257
|
+
|
1258
|
+
var TextStreamAnimator = (_class2 = class {
|
1259
|
+
constructor(currentText, setText) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);
|
1393
1260
|
this.currentText = currentText;
|
1394
1261
|
this.setText = setText;
|
1395
1262
|
}
|
1396
|
-
animationFrameId = null
|
1397
|
-
lastUpdateTime = Date.now()
|
1398
|
-
targetText = ""
|
1263
|
+
__init2() {this.animationFrameId = null}
|
1264
|
+
__init3() {this.lastUpdateTime = Date.now()}
|
1265
|
+
__init4() {this.targetText = ""}
|
1399
1266
|
start() {
|
1400
1267
|
if (this.animationFrameId !== null) return;
|
1401
1268
|
this.lastUpdateTime = Date.now();
|
@@ -1407,7 +1274,7 @@ var TextStreamAnimator = class {
|
|
1407
1274
|
this.animationFrameId = null;
|
1408
1275
|
}
|
1409
1276
|
}
|
1410
|
-
animate = () => {
|
1277
|
+
__init5() {this.animate = () => {
|
1411
1278
|
const currentTime = Date.now();
|
1412
1279
|
const deltaTime = currentTime - this.lastUpdateTime;
|
1413
1280
|
let timeToConsume = deltaTime;
|
@@ -1430,28 +1297,28 @@ var TextStreamAnimator = class {
|
|
1430
1297
|
);
|
1431
1298
|
this.lastUpdateTime = currentTime - timeToConsume;
|
1432
1299
|
this.setText(this.currentText);
|
1433
|
-
}
|
1434
|
-
};
|
1300
|
+
}}
|
1301
|
+
}, _class2);
|
1435
1302
|
var SMOOTH_STATUS = Object.freeze({
|
1436
1303
|
type: "running"
|
1437
1304
|
});
|
1438
1305
|
var useSmooth = (state, smooth = false) => {
|
1439
|
-
const { useSmoothStatus: useSmoothStatus2 } = useSmoothContext({ optional: true })
|
1306
|
+
const { useSmoothStatus: useSmoothStatus2 } = _nullishCoalesce(useSmoothContext({ optional: true }), () => ( {}));
|
1440
1307
|
const {
|
1441
1308
|
part: { text }
|
1442
1309
|
} = state;
|
1443
1310
|
const { useMessage } = useMessageContext();
|
1444
1311
|
const id = useMessage((m) => m.message.id);
|
1445
|
-
const idRef = (0,
|
1446
|
-
const [displayedText, setDisplayedText] = (0,
|
1447
|
-
const setText = (0,
|
1312
|
+
const idRef = _react.useRef.call(void 0, id);
|
1313
|
+
const [displayedText, setDisplayedText] = _react.useState.call(void 0, text);
|
1314
|
+
const setText = _reactusecallbackref.useCallbackRef.call(void 0, (text2) => {
|
1448
1315
|
setDisplayedText(text2);
|
1449
|
-
useSmoothStatus2
|
1316
|
+
_optionalChain([useSmoothStatus2, 'optionalAccess', _28 => _28.setState, 'call', _29 => _29(text2 !== state.part.text ? SMOOTH_STATUS : state.status)]);
|
1450
1317
|
});
|
1451
|
-
const [animatorRef] = (0,
|
1318
|
+
const [animatorRef] = _react.useState.call(void 0,
|
1452
1319
|
new TextStreamAnimator(text, setText)
|
1453
1320
|
);
|
1454
|
-
(0,
|
1321
|
+
_react.useEffect.call(void 0, () => {
|
1455
1322
|
if (!smooth) {
|
1456
1323
|
animatorRef.stop();
|
1457
1324
|
return;
|
@@ -1467,12 +1334,12 @@ var useSmooth = (state, smooth = false) => {
|
|
1467
1334
|
animatorRef.targetText = text;
|
1468
1335
|
animatorRef.start();
|
1469
1336
|
}, [setText, animatorRef, id, smooth, text]);
|
1470
|
-
(0,
|
1337
|
+
_react.useEffect.call(void 0, () => {
|
1471
1338
|
return () => {
|
1472
1339
|
animatorRef.stop();
|
1473
1340
|
};
|
1474
1341
|
}, [animatorRef]);
|
1475
|
-
return (0,
|
1342
|
+
return _react.useMemo.call(void 0,
|
1476
1343
|
() => smooth ? {
|
1477
1344
|
part: { type: "text", text: displayedText },
|
1478
1345
|
status: text === displayedText ? state.status : SMOOTH_STATUS
|
@@ -1482,25 +1349,25 @@ var useSmooth = (state, smooth = false) => {
|
|
1482
1349
|
};
|
1483
1350
|
|
1484
1351
|
// src/primitives/contentPart/ContentPartText.tsx
|
1485
|
-
|
1486
|
-
var ContentPartPrimitiveText = (0,
|
1352
|
+
|
1353
|
+
var ContentPartPrimitiveText = _react.forwardRef.call(void 0, ({ smooth = true, component: Component = "span", ...rest }, forwardedRef) => {
|
1487
1354
|
const {
|
1488
1355
|
part: { text },
|
1489
1356
|
status
|
1490
1357
|
} = useSmooth(useContentPartText(), smooth);
|
1491
|
-
return /* @__PURE__ */ (0,
|
1358
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Component, { "data-status": status.type, ...rest, ref: forwardedRef, children: text });
|
1492
1359
|
});
|
1493
1360
|
ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
|
1494
1361
|
|
1495
1362
|
// src/primitives/contentPart/ContentPartImage.tsx
|
1496
|
-
|
1497
|
-
|
1498
|
-
|
1499
|
-
var ContentPartPrimitiveImage = (0,
|
1363
|
+
|
1364
|
+
|
1365
|
+
|
1366
|
+
var ContentPartPrimitiveImage = _react.forwardRef.call(void 0, (props, forwardedRef) => {
|
1500
1367
|
const {
|
1501
1368
|
part: { image }
|
1502
1369
|
} = useContentPartImage();
|
1503
|
-
return /* @__PURE__ */ (0,
|
1370
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.img, { src: image, ...props, ref: forwardedRef });
|
1504
1371
|
});
|
1505
1372
|
ContentPartPrimitiveImage.displayName = "ContentPartPrimitive.Image";
|
1506
1373
|
|
@@ -1509,7 +1376,7 @@ var ContentPartPrimitiveDisplay = () => {
|
|
1509
1376
|
const {
|
1510
1377
|
part: { display }
|
1511
1378
|
} = useContentPartDisplay();
|
1512
|
-
return display
|
1379
|
+
return _nullishCoalesce(display, () => ( null));
|
1513
1380
|
};
|
1514
1381
|
ContentPartPrimitiveDisplay.displayName = "ContentPartPrimitive.Display";
|
1515
1382
|
|
@@ -1522,20 +1389,20 @@ var ContentPartPrimitiveInProgress = ({ children }) => {
|
|
1522
1389
|
ContentPartPrimitiveInProgress.displayName = "ContentPartPrimitive.InProgress";
|
1523
1390
|
|
1524
1391
|
// src/primitives/message/MessageContent.tsx
|
1525
|
-
|
1392
|
+
|
1526
1393
|
var defaultComponents = {
|
1527
|
-
Text: () => /* @__PURE__ */ (0,
|
1528
|
-
/* @__PURE__ */ (0,
|
1529
|
-
/* @__PURE__ */ (0,
|
1394
|
+
Text: () => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { style: { whiteSpace: "pre-line" }, children: [
|
1395
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveText, {}),
|
1396
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
|
1530
1397
|
] }),
|
1531
|
-
Image: () => /* @__PURE__ */ (0,
|
1532
|
-
UI: () => /* @__PURE__ */ (0,
|
1398
|
+
Image: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveImage, {}),
|
1399
|
+
UI: () => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartPrimitiveDisplay, {}),
|
1533
1400
|
tools: {
|
1534
1401
|
Fallback: (props) => {
|
1535
1402
|
const { useToolUIs } = useAssistantContext();
|
1536
1403
|
const Render = useToolUIs((s) => s.getToolUI(props.part.toolName));
|
1537
1404
|
if (!Render) return null;
|
1538
|
-
return /* @__PURE__ */ (0,
|
1405
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Render, { ...props });
|
1539
1406
|
}
|
1540
1407
|
}
|
1541
1408
|
};
|
@@ -1558,16 +1425,16 @@ var MessageContentPartComponent = ({
|
|
1558
1425
|
case "text":
|
1559
1426
|
if (status.type === "requires-action")
|
1560
1427
|
throw new Error("Encountered unexpected requires-action status");
|
1561
|
-
if (part === EMPTY_CONTENT) return /* @__PURE__ */ (0,
|
1562
|
-
return /* @__PURE__ */ (0,
|
1428
|
+
if (part === EMPTY_CONTENT) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Empty, { part, status });
|
1429
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Text2, { part, status });
|
1563
1430
|
case "image":
|
1564
1431
|
if (status.type === "requires-action")
|
1565
1432
|
throw new Error("Encountered unexpected requires-action status");
|
1566
|
-
return /* @__PURE__ */ (0,
|
1433
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Image2, { part, status });
|
1567
1434
|
case "ui":
|
1568
1435
|
if (status.type === "requires-action")
|
1569
1436
|
throw new Error("Encountered unexpected requires-action status");
|
1570
|
-
return /* @__PURE__ */ (0,
|
1437
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UI, { part, status });
|
1571
1438
|
case "tool-call": {
|
1572
1439
|
const Tool = by_name[part.toolName] || Fallback2;
|
1573
1440
|
const addResult = (result) => addToolResult({
|
@@ -1575,7 +1442,7 @@ var MessageContentPartComponent = ({
|
|
1575
1442
|
toolCallId: part.toolCallId,
|
1576
1443
|
result
|
1577
1444
|
});
|
1578
|
-
return /* @__PURE__ */ (0,
|
1445
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tool, { part, status, addResult });
|
1579
1446
|
}
|
1580
1447
|
default:
|
1581
1448
|
const unhandledType = type;
|
@@ -1586,11 +1453,11 @@ var MessageContentPartImpl = ({
|
|
1586
1453
|
partIndex,
|
1587
1454
|
components
|
1588
1455
|
}) => {
|
1589
|
-
return /* @__PURE__ */ (0,
|
1456
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ContentPartProvider, { partIndex, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContentPartComponent, { components }) });
|
1590
1457
|
};
|
1591
|
-
var MessageContentPart = (0,
|
1458
|
+
var MessageContentPart = _react.memo.call(void 0,
|
1592
1459
|
MessageContentPartImpl,
|
1593
|
-
(prev, next) => prev.partIndex === next.partIndex && prev.components
|
1460
|
+
(prev, next) => prev.partIndex === next.partIndex && _optionalChain([prev, 'access', _30 => _30.components, 'optionalAccess', _31 => _31.Text]) === _optionalChain([next, 'access', _32 => _32.components, 'optionalAccess', _33 => _33.Text]) && _optionalChain([prev, 'access', _34 => _34.components, 'optionalAccess', _35 => _35.Image]) === _optionalChain([next, 'access', _36 => _36.components, 'optionalAccess', _37 => _37.Image]) && _optionalChain([prev, 'access', _38 => _38.components, 'optionalAccess', _39 => _39.UI]) === _optionalChain([next, 'access', _40 => _40.components, 'optionalAccess', _41 => _41.UI]) && _optionalChain([prev, 'access', _42 => _42.components, 'optionalAccess', _43 => _43.tools]) === _optionalChain([next, 'access', _44 => _44.components, 'optionalAccess', _45 => _45.tools])
|
1594
1461
|
);
|
1595
1462
|
var MessagePrimitiveContent = ({
|
1596
1463
|
components
|
@@ -1599,7 +1466,7 @@ var MessagePrimitiveContent = ({
|
|
1599
1466
|
const contentLength = useMessage((s) => s.message.content.length) || 1;
|
1600
1467
|
return new Array(contentLength).fill(null).map((_, idx) => {
|
1601
1468
|
const partIndex = idx;
|
1602
|
-
return /* @__PURE__ */ (0,
|
1469
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
1603
1470
|
MessageContentPart,
|
1604
1471
|
{
|
1605
1472
|
partIndex,
|
@@ -1618,15 +1485,15 @@ var MessagePrimitiveInProgress = () => {
|
|
1618
1485
|
MessagePrimitiveInProgress.displayName = "MessagePrimitive.InProgress";
|
1619
1486
|
|
1620
1487
|
// src/primitives/branchPicker/BranchPickerRoot.tsx
|
1621
|
-
|
1622
|
-
var BranchPickerPrimitiveRoot = (0,
|
1623
|
-
return /* @__PURE__ */ (0,
|
1488
|
+
|
1489
|
+
var BranchPickerPrimitiveRoot = _react.forwardRef.call(void 0, ({ hideWhenSingleBranch, ...rest }, ref) => {
|
1490
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { hasBranches: hideWhenSingleBranch ? true : void 0, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...rest, ref }) });
|
1624
1491
|
});
|
1625
1492
|
BranchPickerPrimitiveRoot.displayName = "BranchPickerPrimitive.Root";
|
1626
1493
|
|
1627
1494
|
// src/primitives/composer/index.ts
|
1628
1495
|
var composer_exports = {};
|
1629
|
-
__export(composer_exports, {
|
1496
|
+
_chunkDCHYNTHIjs.__export.call(void 0, composer_exports, {
|
1630
1497
|
Cancel: () => ComposerPrimitiveCancel,
|
1631
1498
|
If: () => ComposerPrimitiveIf,
|
1632
1499
|
Input: () => ComposerPrimitiveInput,
|
@@ -1635,37 +1502,44 @@ __export(composer_exports, {
|
|
1635
1502
|
});
|
1636
1503
|
|
1637
1504
|
// src/primitives/composer/ComposerRoot.tsx
|
1638
|
-
|
1639
|
-
|
1640
|
-
|
1641
|
-
|
1642
|
-
|
1505
|
+
|
1506
|
+
|
1507
|
+
|
1508
|
+
|
1509
|
+
|
1510
|
+
|
1511
|
+
var ComposerPrimitiveRoot = _react.forwardRef.call(void 0, ({ onSubmit, ...rest }, forwardedRef) => {
|
1643
1512
|
const send = useComposerSend();
|
1644
1513
|
const handleSubmit = (e) => {
|
1645
1514
|
e.preventDefault();
|
1646
1515
|
if (!send) return;
|
1647
1516
|
send();
|
1648
1517
|
};
|
1649
|
-
return /* @__PURE__ */ (0,
|
1650
|
-
|
1518
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
1519
|
+
_reactprimitive.Primitive.form,
|
1651
1520
|
{
|
1652
1521
|
...rest,
|
1653
1522
|
ref: forwardedRef,
|
1654
|
-
onSubmit: (0,
|
1523
|
+
onSubmit: _primitive.composeEventHandlers.call(void 0, onSubmit, handleSubmit)
|
1655
1524
|
}
|
1656
1525
|
);
|
1657
1526
|
});
|
1658
1527
|
ComposerPrimitiveRoot.displayName = "ComposerPrimitive.Root";
|
1659
1528
|
|
1660
1529
|
// src/primitives/composer/ComposerInput.tsx
|
1661
|
-
|
1662
|
-
|
1663
|
-
var
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1530
|
+
|
1531
|
+
|
1532
|
+
var _reactslot = require('@radix-ui/react-slot');
|
1533
|
+
|
1534
|
+
|
1535
|
+
|
1536
|
+
|
1537
|
+
|
1538
|
+
|
1539
|
+
var _reacttextareaautosize = require('react-textarea-autosize'); var _reacttextareaautosize2 = _interopRequireDefault(_reacttextareaautosize);
|
1540
|
+
var _reactuseescapekeydown = require('@radix-ui/react-use-escape-keydown');
|
1541
|
+
|
1542
|
+
var ComposerPrimitiveInput = _react.forwardRef.call(void 0,
|
1669
1543
|
({
|
1670
1544
|
autoFocus = false,
|
1671
1545
|
asChild,
|
@@ -1680,11 +1554,11 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
|
|
1680
1554
|
if (!c.isEditing) return "";
|
1681
1555
|
return c.value;
|
1682
1556
|
});
|
1683
|
-
const Component = asChild ?
|
1684
|
-
const isDisabled = useThread((t) => t.isDisabled)
|
1685
|
-
const textareaRef = (0,
|
1686
|
-
const ref = (0,
|
1687
|
-
(0,
|
1557
|
+
const Component = asChild ? _reactslot.Slot : _reacttextareaautosize2.default;
|
1558
|
+
const isDisabled = _nullishCoalesce(_nullishCoalesce(useThread((t) => t.isDisabled), () => ( disabledProp)), () => ( false));
|
1559
|
+
const textareaRef = _react.useRef.call(void 0, null);
|
1560
|
+
const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardedRef, textareaRef);
|
1561
|
+
_reactuseescapekeydown.useEscapeKeydown.call(void 0, (e) => {
|
1688
1562
|
const composer = useComposer.getState();
|
1689
1563
|
if (composer.canCancel) {
|
1690
1564
|
composer.cancel();
|
@@ -1697,12 +1571,12 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
|
|
1697
1571
|
const isRunning = useThread.getState().isRunning;
|
1698
1572
|
if (!isRunning) {
|
1699
1573
|
e.preventDefault();
|
1700
|
-
textareaRef.current
|
1574
|
+
_optionalChain([textareaRef, 'access', _46 => _46.current, 'optionalAccess', _47 => _47.closest, 'call', _48 => _48("form"), 'optionalAccess', _49 => _49.requestSubmit, 'call', _50 => _50()]);
|
1701
1575
|
}
|
1702
1576
|
}
|
1703
1577
|
};
|
1704
1578
|
const autoFocusEnabled = autoFocus && !isDisabled;
|
1705
|
-
const focus = (0,
|
1579
|
+
const focus = _react.useCallback.call(void 0, () => {
|
1706
1580
|
const textarea = textareaRef.current;
|
1707
1581
|
if (!textarea || !autoFocusEnabled) return;
|
1708
1582
|
textarea.focus({ preventScroll: true });
|
@@ -1711,13 +1585,13 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
|
|
1711
1585
|
textareaRef.current.value.length
|
1712
1586
|
);
|
1713
1587
|
}, [autoFocusEnabled]);
|
1714
|
-
(0,
|
1588
|
+
_react.useEffect.call(void 0, () => focus(), [focus]);
|
1715
1589
|
useOnComposerFocus(() => {
|
1716
1590
|
if (type === "new") {
|
1717
1591
|
focus();
|
1718
1592
|
}
|
1719
1593
|
});
|
1720
|
-
return /* @__PURE__ */ (0,
|
1594
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
1721
1595
|
Component,
|
1722
1596
|
{
|
1723
1597
|
name: "input",
|
@@ -1725,12 +1599,12 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
|
|
1725
1599
|
...rest,
|
1726
1600
|
ref,
|
1727
1601
|
disabled: isDisabled,
|
1728
|
-
onChange: (0,
|
1602
|
+
onChange: _primitive.composeEventHandlers.call(void 0, onChange, (e) => {
|
1729
1603
|
const composerState = useComposer.getState();
|
1730
1604
|
if (!composerState.isEditing) return;
|
1731
1605
|
return composerState.setValue(e.target.value);
|
1732
1606
|
}),
|
1733
|
-
onKeyDown: (0,
|
1607
|
+
onKeyDown: _primitive.composeEventHandlers.call(void 0, onKeyDown, handleKeyPress)
|
1734
1608
|
}
|
1735
1609
|
);
|
1736
1610
|
}
|
@@ -1738,14 +1612,14 @@ var ComposerPrimitiveInput = (0, import_react42.forwardRef)(
|
|
1738
1612
|
ComposerPrimitiveInput.displayName = "ComposerPrimitive.Input";
|
1739
1613
|
|
1740
1614
|
// src/primitives/composer/ComposerSend.tsx
|
1741
|
-
|
1742
|
-
|
1743
|
-
|
1744
|
-
var ComposerPrimitiveSend = (0,
|
1615
|
+
|
1616
|
+
|
1617
|
+
|
1618
|
+
var ComposerPrimitiveSend = _react.forwardRef.call(void 0, ({ disabled, ...rest }, ref) => {
|
1745
1619
|
const { useComposer } = useComposerContext();
|
1746
1620
|
const hasValue = useComposer((c) => c.isEditing && c.value.length > 0);
|
1747
|
-
return /* @__PURE__ */ (0,
|
1748
|
-
|
1621
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
1622
|
+
_reactprimitive.Primitive.button,
|
1749
1623
|
{
|
1750
1624
|
type: "submit",
|
1751
1625
|
...rest,
|
@@ -1774,7 +1648,7 @@ ComposerPrimitiveIf.displayName = "ComposerPrimitive.If";
|
|
1774
1648
|
|
1775
1649
|
// src/primitives/contentPart/index.ts
|
1776
1650
|
var contentPart_exports = {};
|
1777
|
-
__export(contentPart_exports, {
|
1651
|
+
_chunkDCHYNTHIjs.__export.call(void 0, contentPart_exports, {
|
1778
1652
|
Display: () => ContentPartPrimitiveDisplay,
|
1779
1653
|
Image: () => ContentPartPrimitiveImage,
|
1780
1654
|
InProgress: () => ContentPartPrimitiveInProgress,
|
@@ -1783,7 +1657,7 @@ __export(contentPart_exports, {
|
|
1783
1657
|
|
1784
1658
|
// src/primitives/thread/index.ts
|
1785
1659
|
var thread_exports = {};
|
1786
|
-
__export(thread_exports, {
|
1660
|
+
_chunkDCHYNTHIjs.__export.call(void 0, thread_exports, {
|
1787
1661
|
Empty: () => ThreadPrimitiveEmpty,
|
1788
1662
|
If: () => ThreadPrimitiveIf,
|
1789
1663
|
Messages: () => ThreadPrimitiveMessages,
|
@@ -1794,11 +1668,11 @@ __export(thread_exports, {
|
|
1794
1668
|
});
|
1795
1669
|
|
1796
1670
|
// src/primitives/thread/ThreadRoot.tsx
|
1797
|
-
|
1798
|
-
|
1799
|
-
|
1800
|
-
var ThreadPrimitiveRoot = (0,
|
1801
|
-
return /* @__PURE__ */ (0,
|
1671
|
+
|
1672
|
+
|
1673
|
+
|
1674
|
+
var ThreadPrimitiveRoot = _react.forwardRef.call(void 0, (props, ref) => {
|
1675
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...props, ref });
|
1802
1676
|
});
|
1803
1677
|
ThreadPrimitiveRoot.displayName = "ThreadPrimitive.Root";
|
1804
1678
|
|
@@ -1822,20 +1696,20 @@ var ThreadPrimitiveIf = ({
|
|
1822
1696
|
ThreadPrimitiveIf.displayName = "ThreadPrimitive.If";
|
1823
1697
|
|
1824
1698
|
// src/primitives/thread/ThreadViewport.tsx
|
1825
|
-
|
1826
|
-
|
1827
|
-
|
1699
|
+
|
1700
|
+
|
1701
|
+
|
1828
1702
|
|
1829
1703
|
// src/primitive-hooks/thread/useThreadViewportAutoScroll.tsx
|
1830
|
-
|
1831
|
-
|
1704
|
+
|
1705
|
+
|
1832
1706
|
|
1833
1707
|
// src/utils/hooks/useOnResizeContent.tsx
|
1834
|
-
|
1835
|
-
|
1708
|
+
|
1709
|
+
|
1836
1710
|
var useOnResizeContent = (callback) => {
|
1837
|
-
const callbackRef = (0,
|
1838
|
-
const refCallback = (0,
|
1711
|
+
const callbackRef = _reactusecallbackref.useCallbackRef.call(void 0, callback);
|
1712
|
+
const refCallback = _react.useCallback.call(void 0,
|
1839
1713
|
(el) => {
|
1840
1714
|
const resizeObserver = new ResizeObserver(() => {
|
1841
1715
|
callbackRef();
|
@@ -1871,12 +1745,12 @@ var useOnResizeContent = (callback) => {
|
|
1871
1745
|
};
|
1872
1746
|
|
1873
1747
|
// src/utils/hooks/useOnScrollToBottom.tsx
|
1874
|
-
|
1875
|
-
|
1748
|
+
|
1749
|
+
|
1876
1750
|
var useOnScrollToBottom = (callback) => {
|
1877
|
-
const callbackRef = (0,
|
1751
|
+
const callbackRef = _reactusecallbackref.useCallbackRef.call(void 0, callback);
|
1878
1752
|
const { useViewport } = useThreadContext();
|
1879
|
-
(0,
|
1753
|
+
_react.useEffect.call(void 0, () => {
|
1880
1754
|
return useViewport.getState().onScrollToBottom(() => {
|
1881
1755
|
callbackRef();
|
1882
1756
|
});
|
@@ -1887,10 +1761,10 @@ var useOnScrollToBottom = (callback) => {
|
|
1887
1761
|
var useThreadViewportAutoScroll = ({
|
1888
1762
|
autoScroll = true
|
1889
1763
|
}) => {
|
1890
|
-
const divRef = (0,
|
1764
|
+
const divRef = _react.useRef.call(void 0, null);
|
1891
1765
|
const { useViewport } = useThreadContext();
|
1892
|
-
const lastScrollTop = (0,
|
1893
|
-
const isScrollingToBottomRef = (0,
|
1766
|
+
const lastScrollTop = _react.useRef.call(void 0, 0);
|
1767
|
+
const isScrollingToBottomRef = _react.useRef.call(void 0, false);
|
1894
1768
|
const scrollToBottom = (behavior) => {
|
1895
1769
|
const div = divRef.current;
|
1896
1770
|
if (!div || !autoScroll) return;
|
@@ -1927,7 +1801,7 @@ var useThreadViewportAutoScroll = ({
|
|
1927
1801
|
el.removeEventListener("scroll", handleScroll);
|
1928
1802
|
};
|
1929
1803
|
});
|
1930
|
-
const autoScrollRef = (0,
|
1804
|
+
const autoScrollRef = _reactcomposerefs.useComposedRefs.call(void 0, resizeRef, scrollRef, divRef);
|
1931
1805
|
useOnScrollToBottom(() => {
|
1932
1806
|
scrollToBottom("auto");
|
1933
1807
|
});
|
@@ -1935,29 +1809,29 @@ var useThreadViewportAutoScroll = ({
|
|
1935
1809
|
};
|
1936
1810
|
|
1937
1811
|
// src/primitives/thread/ThreadViewport.tsx
|
1938
|
-
|
1939
|
-
var ThreadPrimitiveViewport = (0,
|
1812
|
+
|
1813
|
+
var ThreadPrimitiveViewport = _react.forwardRef.call(void 0, ({ autoScroll, onScroll, children, ...rest }, forwardedRef) => {
|
1940
1814
|
const autoScrollRef = useThreadViewportAutoScroll({
|
1941
1815
|
autoScroll
|
1942
1816
|
});
|
1943
|
-
const ref = (0,
|
1944
|
-
return /* @__PURE__ */ (0,
|
1817
|
+
const ref = _reactcomposerefs.useComposedRefs.call(void 0, forwardedRef, autoScrollRef);
|
1818
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _reactprimitive.Primitive.div, { ...rest, ref, children });
|
1945
1819
|
});
|
1946
1820
|
ThreadPrimitiveViewport.displayName = "ThreadPrimitive.Viewport";
|
1947
1821
|
|
1948
1822
|
// src/primitives/thread/ThreadMessages.tsx
|
1949
|
-
|
1823
|
+
|
1950
1824
|
|
1951
1825
|
// src/context/providers/MessageProvider.tsx
|
1952
|
-
|
1953
|
-
|
1826
|
+
|
1827
|
+
|
1954
1828
|
|
1955
1829
|
// src/context/stores/EditComposer.ts
|
1956
|
-
|
1830
|
+
|
1957
1831
|
var makeEditComposerStore = ({
|
1958
1832
|
onEdit,
|
1959
1833
|
onSend
|
1960
|
-
}) => (0,
|
1834
|
+
}) => _zustand.create.call(void 0, )((set, get, store) => ({
|
1961
1835
|
...makeBaseComposer(set, get, store),
|
1962
1836
|
canCancel: false,
|
1963
1837
|
isEditing: false,
|
@@ -1976,8 +1850,8 @@ var makeEditComposerStore = ({
|
|
1976
1850
|
}));
|
1977
1851
|
|
1978
1852
|
// src/context/stores/MessageUtils.ts
|
1979
|
-
|
1980
|
-
var makeMessageUtilsStore = () => (0,
|
1853
|
+
|
1854
|
+
var makeMessageUtilsStore = () => _zustand.create.call(void 0, (set) => ({
|
1981
1855
|
isCopied: false,
|
1982
1856
|
setIsCopied: (value) => {
|
1983
1857
|
set({ isCopied: value });
|
@@ -1989,17 +1863,17 @@ var makeMessageUtilsStore = () => (0, import_zustand13.create)((set) => ({
|
|
1989
1863
|
}));
|
1990
1864
|
|
1991
1865
|
// src/context/providers/MessageProvider.tsx
|
1992
|
-
|
1866
|
+
|
1993
1867
|
var getIsLast = (messages, message) => {
|
1994
|
-
return messages[messages.length - 1]
|
1868
|
+
return _optionalChain([messages, 'access', _51 => _51[messages.length - 1], 'optionalAccess', _52 => _52.id]) === message.id;
|
1995
1869
|
};
|
1996
1870
|
var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
1997
|
-
const parentId = messages[messageIndex - 1]
|
1871
|
+
const parentId = _nullishCoalesce(_optionalChain([messages, 'access', _53 => _53[messageIndex - 1], 'optionalAccess', _54 => _54.id]), () => ( null));
|
1998
1872
|
const message = messages[messageIndex];
|
1999
1873
|
if (!message) return null;
|
2000
1874
|
const isLast = getIsLast(messages, message);
|
2001
1875
|
const branches = getBranches(message.id);
|
2002
|
-
const currentState = useMessage
|
1876
|
+
const currentState = _optionalChain([useMessage, 'optionalAccess', _55 => _55.getState, 'call', _56 => _56()]);
|
2003
1877
|
if (currentState && currentState.message === message && currentState.parentId === parentId && currentState.branches === branches && currentState.isLast === isLast)
|
2004
1878
|
return null;
|
2005
1879
|
return Object.freeze({
|
@@ -2011,8 +1885,8 @@ var getMessageState = (messages, getBranches, useMessage, messageIndex) => {
|
|
2011
1885
|
};
|
2012
1886
|
var useMessageContext2 = (messageIndex) => {
|
2013
1887
|
const { useThreadMessages, useThreadActions } = useThreadContext();
|
2014
|
-
const [context] = (0,
|
2015
|
-
const useMessage = (0,
|
1888
|
+
const [context] = _react.useState.call(void 0, () => {
|
1889
|
+
const useMessage = _zustand.create.call(void 0,
|
2016
1890
|
() => getMessageState(
|
2017
1891
|
useThreadMessages.getState(),
|
2018
1892
|
useThreadActions.getState().getBranches,
|
@@ -2049,7 +1923,7 @@ var useMessageContext2 = (messageIndex) => {
|
|
2049
1923
|
});
|
2050
1924
|
return { useMessage, useMessageUtils, useEditComposer };
|
2051
1925
|
});
|
2052
|
-
(0,
|
1926
|
+
_react.useEffect.call(void 0, () => {
|
2053
1927
|
const syncMessage = (thread) => {
|
2054
1928
|
const newState = getMessageState(
|
2055
1929
|
thread,
|
@@ -2073,18 +1947,18 @@ var MessageProvider = ({
|
|
2073
1947
|
children
|
2074
1948
|
}) => {
|
2075
1949
|
const context = useMessageContext2(messageIndex);
|
2076
|
-
return /* @__PURE__ */ (0,
|
1950
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageContext.Provider, { value: context, children });
|
2077
1951
|
};
|
2078
1952
|
|
2079
1953
|
// src/primitives/thread/ThreadMessages.tsx
|
2080
|
-
|
1954
|
+
|
2081
1955
|
var DEFAULT_SYSTEM_MESSAGE = () => null;
|
2082
1956
|
var getComponents = (components) => {
|
2083
1957
|
return {
|
2084
|
-
EditComposer: components.EditComposer
|
2085
|
-
UserMessage: components.UserMessage
|
2086
|
-
AssistantMessage: components.AssistantMessage
|
2087
|
-
SystemMessage: components.SystemMessage
|
1958
|
+
EditComposer: _nullishCoalesce(_nullishCoalesce(components.EditComposer, () => ( components.UserMessage)), () => ( components.Message)),
|
1959
|
+
UserMessage: _nullishCoalesce(components.UserMessage, () => ( components.Message)),
|
1960
|
+
AssistantMessage: _nullishCoalesce(components.AssistantMessage, () => ( components.Message)),
|
1961
|
+
SystemMessage: _nullishCoalesce(components.SystemMessage, () => ( DEFAULT_SYSTEM_MESSAGE))
|
2088
1962
|
};
|
2089
1963
|
};
|
2090
1964
|
var ThreadMessageImpl = ({
|
@@ -2092,16 +1966,16 @@ var ThreadMessageImpl = ({
|
|
2092
1966
|
components
|
2093
1967
|
}) => {
|
2094
1968
|
const { UserMessage: UserMessage2, EditComposer: EditComposer2, AssistantMessage: AssistantMessage2, SystemMessage: SystemMessage2 } = getComponents(components);
|
2095
|
-
return /* @__PURE__ */ (0,
|
2096
|
-
/* @__PURE__ */ (0,
|
2097
|
-
/* @__PURE__ */ (0,
|
2098
|
-
/* @__PURE__ */ (0,
|
1969
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, MessageProvider, { messageIndex, children: [
|
1970
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, MessagePrimitiveIf, { user: true, children: [
|
1971
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerPrimitiveIf, { editing: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessage2, {}) }),
|
1972
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerPrimitiveIf, { editing: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposer2, {}) })
|
2099
1973
|
] }),
|
2100
|
-
/* @__PURE__ */ (0,
|
2101
|
-
/* @__PURE__ */ (0,
|
1974
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { assistant: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessage2, {}) }),
|
1975
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessagePrimitiveIf, { system: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SystemMessage2, {}) })
|
2102
1976
|
] });
|
2103
1977
|
};
|
2104
|
-
var ThreadMessage = (0,
|
1978
|
+
var ThreadMessage = _react.memo.call(void 0,
|
2105
1979
|
ThreadMessageImpl,
|
2106
1980
|
(prev, next) => prev.messageIndex === next.messageIndex && prev.components.Message === next.components.Message && prev.components.UserMessage === next.components.UserMessage && prev.components.EditComposer === next.components.EditComposer && prev.components.AssistantMessage === next.components.AssistantMessage && prev.components.SystemMessage === next.components.SystemMessage
|
2107
1981
|
);
|
@@ -2113,7 +1987,7 @@ var ThreadPrimitiveMessagesImpl = ({
|
|
2113
1987
|
if (messagesLength === 0) return null;
|
2114
1988
|
return new Array(messagesLength).fill(null).map((_, idx) => {
|
2115
1989
|
const messageIndex = idx;
|
2116
|
-
return /* @__PURE__ */ (0,
|
1990
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
2117
1991
|
ThreadMessage,
|
2118
1992
|
{
|
2119
1993
|
messageIndex,
|
@@ -2124,9 +1998,9 @@ var ThreadPrimitiveMessagesImpl = ({
|
|
2124
1998
|
});
|
2125
1999
|
};
|
2126
2000
|
ThreadPrimitiveMessagesImpl.displayName = "ThreadPrimitive.Messages";
|
2127
|
-
var ThreadPrimitiveMessages = (0,
|
2001
|
+
var ThreadPrimitiveMessages = _react.memo.call(void 0,
|
2128
2002
|
ThreadPrimitiveMessagesImpl,
|
2129
|
-
(prev, next) => prev.components
|
2003
|
+
(prev, next) => _optionalChain([prev, 'access', _57 => _57.components, 'optionalAccess', _58 => _58.Message]) === _optionalChain([next, 'access', _59 => _59.components, 'optionalAccess', _60 => _60.Message]) && _optionalChain([prev, 'access', _61 => _61.components, 'optionalAccess', _62 => _62.UserMessage]) === _optionalChain([next, 'access', _63 => _63.components, 'optionalAccess', _64 => _64.UserMessage]) && _optionalChain([prev, 'access', _65 => _65.components, 'optionalAccess', _66 => _66.EditComposer]) === _optionalChain([next, 'access', _67 => _67.components, 'optionalAccess', _68 => _68.EditComposer]) && _optionalChain([prev, 'access', _69 => _69.components, 'optionalAccess', _70 => _70.AssistantMessage]) === _optionalChain([next, 'access', _71 => _71.components, 'optionalAccess', _72 => _72.AssistantMessage]) && _optionalChain([prev, 'access', _73 => _73.components, 'optionalAccess', _74 => _74.SystemMessage]) === _optionalChain([next, 'access', _75 => _75.components, 'optionalAccess', _76 => _76.SystemMessage])
|
2130
2004
|
);
|
2131
2005
|
|
2132
2006
|
// src/primitives/thread/ThreadScrollToBottom.tsx
|
@@ -2143,11 +2017,11 @@ var ThreadPrimitiveSuggestion = createActionButton(
|
|
2143
2017
|
);
|
2144
2018
|
|
2145
2019
|
// src/runtimes/local/useLocalRuntime.tsx
|
2146
|
-
|
2020
|
+
|
2147
2021
|
|
2148
2022
|
// src/runtimes/core/BaseAssistantRuntime.tsx
|
2149
|
-
var BaseAssistantRuntime = class {
|
2150
|
-
constructor(_thread) {
|
2023
|
+
var BaseAssistantRuntime = (_class3 = class {
|
2024
|
+
constructor(_thread) {;_class3.prototype.__init6.call(this);_class3.prototype.__init7.call(this);
|
2151
2025
|
this._thread = _thread;
|
2152
2026
|
this._thread = _thread;
|
2153
2027
|
}
|
@@ -2158,19 +2032,19 @@ var BaseAssistantRuntime = class {
|
|
2158
2032
|
this._thread = thread;
|
2159
2033
|
this.subscriptionHandler();
|
2160
2034
|
}
|
2161
|
-
_subscriptions = /* @__PURE__ */ new Set()
|
2035
|
+
__init6() {this._subscriptions = /* @__PURE__ */ new Set()}
|
2162
2036
|
subscribe(callback) {
|
2163
2037
|
this._subscriptions.add(callback);
|
2164
2038
|
return () => this._subscriptions.delete(callback);
|
2165
2039
|
}
|
2166
|
-
subscriptionHandler = () => {
|
2040
|
+
__init7() {this.subscriptionHandler = () => {
|
2167
2041
|
for (const callback of this._subscriptions) callback();
|
2168
|
-
}
|
2169
|
-
};
|
2042
|
+
}}
|
2043
|
+
}, _class3);
|
2170
2044
|
|
2171
2045
|
// src/internal.ts
|
2172
2046
|
var internal_exports = {};
|
2173
|
-
__export(internal_exports, {
|
2047
|
+
_chunkDCHYNTHIjs.__export.call(void 0, internal_exports, {
|
2174
2048
|
BaseAssistantRuntime: () => BaseAssistantRuntime,
|
2175
2049
|
MessageRepository: () => MessageRepository,
|
2176
2050
|
ProxyConfigProvider: () => ProxyConfigProvider,
|
@@ -2182,8 +2056,8 @@ __export(internal_exports, {
|
|
2182
2056
|
});
|
2183
2057
|
|
2184
2058
|
// src/utils/idUtils.tsx
|
2185
|
-
var
|
2186
|
-
var generateId = (0,
|
2059
|
+
var _nonsecure = require('nanoid/non-secure');
|
2060
|
+
var generateId = _nonsecure.customAlphabet.call(void 0,
|
2187
2061
|
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
2188
2062
|
7
|
2189
2063
|
);
|
@@ -2243,22 +2117,22 @@ var findHead = (message) => {
|
|
2243
2117
|
if (message.next) return findHead(message.next);
|
2244
2118
|
return message;
|
2245
2119
|
};
|
2246
|
-
var MessageRepository = class {
|
2247
|
-
messages = /* @__PURE__ */ new Map()
|
2120
|
+
var MessageRepository = (_class4 = class {constructor() { _class4.prototype.__init8.call(this);_class4.prototype.__init9.call(this);_class4.prototype.__init10.call(this); }
|
2121
|
+
__init8() {this.messages = /* @__PURE__ */ new Map()}
|
2248
2122
|
// message_id -> item
|
2249
|
-
head = null
|
2250
|
-
root = {
|
2123
|
+
__init9() {this.head = null}
|
2124
|
+
__init10() {this.root = {
|
2251
2125
|
children: []
|
2252
|
-
}
|
2126
|
+
}}
|
2253
2127
|
performOp(newParent, child, operation) {
|
2254
|
-
const parentOrRoot = child.prev
|
2255
|
-
const newParentOrRoot = newParent
|
2128
|
+
const parentOrRoot = _nullishCoalesce(child.prev, () => ( this.root));
|
2129
|
+
const newParentOrRoot = _nullishCoalesce(newParent, () => ( this.root));
|
2256
2130
|
if (operation === "relink" && parentOrRoot === newParentOrRoot) return;
|
2257
2131
|
if (operation !== "link") {
|
2258
2132
|
parentOrRoot.children = parentOrRoot.children.filter(
|
2259
2133
|
(m) => m !== child.current.id
|
2260
2134
|
);
|
2261
|
-
if (child.prev
|
2135
|
+
if (_optionalChain([child, 'access', _77 => _77.prev, 'optionalAccess', _78 => _78.next]) === child) {
|
2262
2136
|
const fallbackId = child.prev.children.at(-1);
|
2263
2137
|
const fallback = fallbackId ? this.messages.get(fallbackId) : null;
|
2264
2138
|
if (fallback === void 0) {
|
@@ -2281,7 +2155,7 @@ var MessageRepository = class {
|
|
2281
2155
|
}
|
2282
2156
|
}
|
2283
2157
|
getMessages() {
|
2284
|
-
const messages = new Array(this.head
|
2158
|
+
const messages = new Array(_nullishCoalesce(_optionalChain([this, 'access', _79 => _79.head, 'optionalAccess', _80 => _80.level]), () => ( 0)));
|
2285
2159
|
for (let current = this.head; current; current = current.prev) {
|
2286
2160
|
messages[current.level] = current.current;
|
2287
2161
|
}
|
@@ -2319,7 +2193,7 @@ var MessageRepository = class {
|
|
2319
2193
|
"MessageRepository(updateMessage): Message not found. This is likely an internal bug in assistant-ui."
|
2320
2194
|
);
|
2321
2195
|
return {
|
2322
|
-
parentId: message.prev
|
2196
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _81 => _81.prev, 'optionalAccess', _82 => _82.current, 'access', _83 => _83.id]), () => ( null)),
|
2323
2197
|
message: message.current
|
2324
2198
|
};
|
2325
2199
|
}
|
@@ -2368,7 +2242,7 @@ var MessageRepository = class {
|
|
2368
2242
|
throw new Error(
|
2369
2243
|
"MessageRepository(getBranches): Message not found. This is likely an internal bug in assistant-ui."
|
2370
2244
|
);
|
2371
|
-
const { children } = message.prev
|
2245
|
+
const { children } = _nullishCoalesce(message.prev, () => ( this.root));
|
2372
2246
|
return children;
|
2373
2247
|
}
|
2374
2248
|
switchToBranch(messageId) {
|
@@ -2399,34 +2273,55 @@ var MessageRepository = class {
|
|
2399
2273
|
}
|
2400
2274
|
}
|
2401
2275
|
}
|
2402
|
-
|
2276
|
+
export() {
|
2277
|
+
const exportItems = [];
|
2278
|
+
for (const [, message] of this.messages) {
|
2279
|
+
exportItems.push({
|
2280
|
+
message: message.current,
|
2281
|
+
parentId: _nullishCoalesce(_optionalChain([message, 'access', _84 => _84.prev, 'optionalAccess', _85 => _85.current, 'access', _86 => _86.id]), () => ( null))
|
2282
|
+
});
|
2283
|
+
}
|
2284
|
+
return {
|
2285
|
+
headId: _nullishCoalesce(_optionalChain([this, 'access', _87 => _87.head, 'optionalAccess', _88 => _88.current, 'access', _89 => _89.id]), () => ( null)),
|
2286
|
+
messages: exportItems
|
2287
|
+
};
|
2288
|
+
}
|
2289
|
+
import({ headId, messages }) {
|
2290
|
+
for (const { message, parentId } of messages) {
|
2291
|
+
this.addOrUpdateMessage(parentId, message);
|
2292
|
+
}
|
2293
|
+
this.resetHead(_nullishCoalesce(_nullishCoalesce(headId, () => ( _optionalChain([messages, 'access', _90 => _90.at, 'call', _91 => _91(-1), 'optionalAccess', _92 => _92.message, 'access', _93 => _93.id]))), () => ( null)));
|
2294
|
+
}
|
2295
|
+
}, _class4);
|
2403
2296
|
|
2404
2297
|
// src/ui/base/tooltip-icon-button.tsx
|
2405
|
-
|
2298
|
+
|
2406
2299
|
|
2407
2300
|
// src/ui/base/tooltip.tsx
|
2408
|
-
var
|
2301
|
+
var _reacttooltip = require('@radix-ui/react-tooltip'); var TooltipPrimitive = _interopRequireWildcard(_reacttooltip);
|
2409
2302
|
|
2410
2303
|
// src/ui/utils/withDefaults.tsx
|
2411
|
-
|
2412
|
-
|
2413
|
-
|
2304
|
+
|
2305
|
+
|
2306
|
+
|
2307
|
+
var _classnames = require('classnames'); var _classnames2 = _interopRequireDefault(_classnames);
|
2308
|
+
|
2414
2309
|
var withDefaultProps = ({
|
2415
2310
|
className,
|
2416
2311
|
...defaultProps
|
2417
2312
|
}) => ({ className: classNameProp, ...props }) => {
|
2418
2313
|
return {
|
2419
|
-
className: (0,
|
2314
|
+
className: _classnames2.default.call(void 0, className, classNameProp),
|
2420
2315
|
...defaultProps,
|
2421
2316
|
...props
|
2422
2317
|
};
|
2423
2318
|
};
|
2424
2319
|
var withDefaults = (Component, defaultProps) => {
|
2425
2320
|
const getProps = withDefaultProps(defaultProps);
|
2426
|
-
const WithDefaults = (0,
|
2321
|
+
const WithDefaults = _react.forwardRef.call(void 0,
|
2427
2322
|
(props, ref) => {
|
2428
2323
|
const ComponentAsAny = Component;
|
2429
|
-
return /* @__PURE__ */ (0,
|
2324
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComponentAsAny, { ...getProps(props), ref });
|
2430
2325
|
}
|
2431
2326
|
);
|
2432
2327
|
WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
|
@@ -2434,9 +2329,9 @@ var withDefaults = (Component, defaultProps) => {
|
|
2434
2329
|
};
|
2435
2330
|
|
2436
2331
|
// src/ui/base/tooltip.tsx
|
2437
|
-
|
2332
|
+
|
2438
2333
|
var Tooltip = (props) => {
|
2439
|
-
return /* @__PURE__ */ (0,
|
2334
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipPrimitive.Provider, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipPrimitive.Root, { ...props }) });
|
2440
2335
|
};
|
2441
2336
|
Tooltip.displayName = "Tooltip";
|
2442
2337
|
var TooltipTrigger = TooltipPrimitive.Trigger;
|
@@ -2447,11 +2342,11 @@ var TooltipContent = withDefaults(TooltipPrimitive.Content, {
|
|
2447
2342
|
TooltipContent.displayName = "TooltipContent";
|
2448
2343
|
|
2449
2344
|
// src/ui/base/button.tsx
|
2450
|
-
var
|
2451
|
-
|
2452
|
-
|
2453
|
-
|
2454
|
-
var buttonVariants = (0,
|
2345
|
+
var _classvarianceauthority = require('class-variance-authority');
|
2346
|
+
|
2347
|
+
|
2348
|
+
|
2349
|
+
var buttonVariants = _classvarianceauthority.cva.call(void 0, "aui-button", {
|
2455
2350
|
variants: {
|
2456
2351
|
variant: {
|
2457
2352
|
default: "aui-button-primary",
|
@@ -2468,10 +2363,10 @@ var buttonVariants = (0, import_class_variance_authority.cva)("aui-button", {
|
|
2468
2363
|
size: "default"
|
2469
2364
|
}
|
2470
2365
|
});
|
2471
|
-
var Button = (0,
|
2366
|
+
var Button = _react.forwardRef.call(void 0,
|
2472
2367
|
({ className, variant, size, ...props }, ref) => {
|
2473
|
-
return /* @__PURE__ */ (0,
|
2474
|
-
|
2368
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
2369
|
+
_reactprimitive.Primitive.button,
|
2475
2370
|
{
|
2476
2371
|
className: buttonVariants({ variant, size, className }),
|
2477
2372
|
...props,
|
@@ -2483,134 +2378,18 @@ var Button = (0, import_react52.forwardRef)(
|
|
2483
2378
|
Button.displayName = "Button";
|
2484
2379
|
|
2485
2380
|
// src/ui/base/tooltip-icon-button.tsx
|
2486
|
-
|
2487
|
-
var TooltipIconButton = (0,
|
2488
|
-
return /* @__PURE__ */ (0,
|
2489
|
-
/* @__PURE__ */ (0,
|
2381
|
+
|
2382
|
+
var TooltipIconButton = _react.forwardRef.call(void 0, ({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
2383
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Tooltip, { children: [
|
2384
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipTrigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
|
2490
2385
|
children,
|
2491
|
-
/* @__PURE__ */ (0,
|
2386
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-sr-only", children: tooltip })
|
2492
2387
|
] }) }),
|
2493
|
-
/* @__PURE__ */ (0,
|
2388
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipContent, { side, children: tooltip })
|
2494
2389
|
] });
|
2495
2390
|
});
|
2496
2391
|
TooltipIconButton.displayName = "TooltipIconButton";
|
2497
2392
|
|
2498
|
-
// src/runtimes/edge/converters/toLanguageModelMessages.ts
|
2499
|
-
var assistantMessageSplitter = () => {
|
2500
|
-
const stash = [];
|
2501
|
-
let assistantMessage = {
|
2502
|
-
role: "assistant",
|
2503
|
-
content: []
|
2504
|
-
};
|
2505
|
-
let toolMessage = {
|
2506
|
-
role: "tool",
|
2507
|
-
content: []
|
2508
|
-
};
|
2509
|
-
return {
|
2510
|
-
addTextContentPart: (part) => {
|
2511
|
-
if (toolMessage.content.length > 0) {
|
2512
|
-
stash.push(assistantMessage);
|
2513
|
-
stash.push(toolMessage);
|
2514
|
-
assistantMessage = {
|
2515
|
-
role: "assistant",
|
2516
|
-
content: []
|
2517
|
-
};
|
2518
|
-
toolMessage = {
|
2519
|
-
role: "tool",
|
2520
|
-
content: []
|
2521
|
-
};
|
2522
|
-
}
|
2523
|
-
assistantMessage.content.push(part);
|
2524
|
-
},
|
2525
|
-
addToolCallPart: (part) => {
|
2526
|
-
assistantMessage.content.push({
|
2527
|
-
type: "tool-call",
|
2528
|
-
toolCallId: part.toolCallId,
|
2529
|
-
toolName: part.toolName,
|
2530
|
-
args: part.args
|
2531
|
-
});
|
2532
|
-
if (part.result) {
|
2533
|
-
toolMessage.content.push({
|
2534
|
-
type: "tool-result",
|
2535
|
-
toolCallId: part.toolCallId,
|
2536
|
-
toolName: part.toolName,
|
2537
|
-
result: part.result
|
2538
|
-
// isError
|
2539
|
-
});
|
2540
|
-
}
|
2541
|
-
},
|
2542
|
-
getMessages: () => {
|
2543
|
-
if (toolMessage.content.length > 0) {
|
2544
|
-
return [...stash, assistantMessage, toolMessage];
|
2545
|
-
}
|
2546
|
-
return [...stash, assistantMessage];
|
2547
|
-
}
|
2548
|
-
};
|
2549
|
-
};
|
2550
|
-
function toLanguageModelMessages(message) {
|
2551
|
-
return message.flatMap((message2) => {
|
2552
|
-
const role = message2.role;
|
2553
|
-
switch (role) {
|
2554
|
-
case "system": {
|
2555
|
-
return [{ role: "system", content: message2.content[0].text }];
|
2556
|
-
}
|
2557
|
-
case "user": {
|
2558
|
-
const msg = {
|
2559
|
-
role: "user",
|
2560
|
-
content: message2.content.map(
|
2561
|
-
(part) => {
|
2562
|
-
const type = part.type;
|
2563
|
-
switch (type) {
|
2564
|
-
case "text": {
|
2565
|
-
return part;
|
2566
|
-
}
|
2567
|
-
case "image": {
|
2568
|
-
return {
|
2569
|
-
type: "image",
|
2570
|
-
image: new URL(part.image)
|
2571
|
-
};
|
2572
|
-
}
|
2573
|
-
default: {
|
2574
|
-
const unhandledType = type;
|
2575
|
-
throw new Error(
|
2576
|
-
`Unspported content part type: ${unhandledType}`
|
2577
|
-
);
|
2578
|
-
}
|
2579
|
-
}
|
2580
|
-
}
|
2581
|
-
)
|
2582
|
-
};
|
2583
|
-
return [msg];
|
2584
|
-
}
|
2585
|
-
case "assistant": {
|
2586
|
-
const splitter = assistantMessageSplitter();
|
2587
|
-
for (const part of message2.content) {
|
2588
|
-
const type = part.type;
|
2589
|
-
switch (type) {
|
2590
|
-
case "text": {
|
2591
|
-
splitter.addTextContentPart(part);
|
2592
|
-
break;
|
2593
|
-
}
|
2594
|
-
case "tool-call": {
|
2595
|
-
splitter.addToolCallPart(part);
|
2596
|
-
break;
|
2597
|
-
}
|
2598
|
-
default: {
|
2599
|
-
const unhandledType = type;
|
2600
|
-
throw new Error(`Unhandled content part type: ${unhandledType}`);
|
2601
|
-
}
|
2602
|
-
}
|
2603
|
-
}
|
2604
|
-
return splitter.getMessages();
|
2605
|
-
}
|
2606
|
-
default: {
|
2607
|
-
const unhandledRole = role;
|
2608
|
-
throw new Error(`Unknown message role: ${unhandledRole}`);
|
2609
|
-
}
|
2610
|
-
}
|
2611
|
-
});
|
2612
|
-
}
|
2613
|
-
|
2614
2393
|
// src/runtimes/edge/converters/fromLanguageModelMessages.ts
|
2615
2394
|
var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
2616
2395
|
const messages = [];
|
@@ -2674,7 +2453,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
2674
2453
|
});
|
2675
2454
|
if (mergeRoundtrips) {
|
2676
2455
|
const previousMessage = messages[messages.length - 1];
|
2677
|
-
if (previousMessage
|
2456
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _94 => _94.role]) === "assistant") {
|
2678
2457
|
previousMessage.content.push(...newContent);
|
2679
2458
|
break;
|
2680
2459
|
}
|
@@ -2687,7 +2466,7 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
2687
2466
|
}
|
2688
2467
|
case "tool": {
|
2689
2468
|
const previousMessage = messages[messages.length - 1];
|
2690
|
-
if (previousMessage
|
2469
|
+
if (_optionalChain([previousMessage, 'optionalAccess', _95 => _95.role]) !== "assistant")
|
2691
2470
|
throw new Error(
|
2692
2471
|
"A tool message must be preceded by an assistant message."
|
2693
2472
|
);
|
@@ -2715,72 +2494,21 @@ var fromLanguageModelMessages = (lm, { mergeRoundtrips }) => {
|
|
2715
2494
|
return messages;
|
2716
2495
|
};
|
2717
2496
|
|
2718
|
-
// src/runtimes/edge/converters/
|
2719
|
-
var
|
2720
|
-
return
|
2721
|
-
|
2722
|
-
|
2723
|
-
|
2724
|
-
|
2725
|
-
|
2726
|
-
|
2727
|
-
|
2728
|
-
|
2729
|
-
if (part.type === "ui") throw new Error("UI parts are not supported");
|
2730
|
-
if (part.type === "tool-call") {
|
2731
|
-
const { argsText, ...rest } = part;
|
2732
|
-
return rest;
|
2733
|
-
}
|
2734
|
-
return part;
|
2735
|
-
})
|
2736
|
-
};
|
2737
|
-
case "user":
|
2738
|
-
return {
|
2739
|
-
role,
|
2740
|
-
content: message.content.map((part) => {
|
2741
|
-
if (part.type === "ui") throw new Error("UI parts are not supported");
|
2742
|
-
return part;
|
2743
|
-
})
|
2744
|
-
};
|
2745
|
-
case "system":
|
2746
|
-
return {
|
2747
|
-
role,
|
2748
|
-
content: message.content
|
2749
|
-
};
|
2750
|
-
default: {
|
2751
|
-
const unsupportedRole = role;
|
2752
|
-
throw new Error(`Unknown message role: ${unsupportedRole}`);
|
2753
|
-
}
|
2754
|
-
}
|
2755
|
-
};
|
2756
|
-
|
2757
|
-
// src/runtimes/edge/converters/fromLanguageModelTools.ts
|
2758
|
-
var fromLanguageModelTools = (tools) => {
|
2759
|
-
return Object.fromEntries(
|
2760
|
-
tools.map((tool) => [
|
2761
|
-
tool.name,
|
2762
|
-
{
|
2763
|
-
description: tool.description,
|
2764
|
-
parameters: tool.parameters
|
2765
|
-
}
|
2766
|
-
])
|
2767
|
-
);
|
2768
|
-
};
|
2769
|
-
|
2770
|
-
// src/runtimes/edge/converters/toLanguageModelTools.ts
|
2771
|
-
var import_zod2 = require("zod");
|
2772
|
-
var import_zod_to_json_schema = __toESM(require("zod-to-json-schema"));
|
2773
|
-
var toLanguageModelTools = (tools) => {
|
2774
|
-
return Object.entries(tools).map(([name, tool]) => ({
|
2775
|
-
type: "function",
|
2776
|
-
name,
|
2777
|
-
...tool.description ? { description: tool.description } : void 0,
|
2778
|
-
parameters: tool.parameters instanceof import_zod2.z.ZodType ? (0, import_zod_to_json_schema.default)(tool.parameters) : tool.parameters
|
2779
|
-
}));
|
2497
|
+
// src/runtimes/edge/converters/fromLanguageModelTools.ts
|
2498
|
+
var fromLanguageModelTools = (tools) => {
|
2499
|
+
return Object.fromEntries(
|
2500
|
+
tools.map((tool) => [
|
2501
|
+
tool.name,
|
2502
|
+
{
|
2503
|
+
description: tool.description,
|
2504
|
+
parameters: tool.parameters
|
2505
|
+
}
|
2506
|
+
])
|
2507
|
+
);
|
2780
2508
|
};
|
2781
2509
|
|
2782
2510
|
// src/runtimes/edge/useEdgeRuntime.ts
|
2783
|
-
|
2511
|
+
|
2784
2512
|
|
2785
2513
|
// src/runtimes/edge/streams/assistantDecoderStream.ts
|
2786
2514
|
function assistantDecoderStream() {
|
@@ -2886,589 +2614,6 @@ function chunkByLineStream() {
|
|
2886
2614
|
});
|
2887
2615
|
}
|
2888
2616
|
|
2889
|
-
// src/runtimes/edge/partial-json/parse-partial-json.ts
|
2890
|
-
var import_secure_json_parse = __toESM(require("secure-json-parse"));
|
2891
|
-
|
2892
|
-
// src/runtimes/edge/partial-json/fix-json.ts
|
2893
|
-
function fixJson(input) {
|
2894
|
-
const stack = ["ROOT"];
|
2895
|
-
let lastValidIndex = -1;
|
2896
|
-
let literalStart = null;
|
2897
|
-
function processValueStart(char, i, swapState) {
|
2898
|
-
{
|
2899
|
-
switch (char) {
|
2900
|
-
case '"': {
|
2901
|
-
lastValidIndex = i;
|
2902
|
-
stack.pop();
|
2903
|
-
stack.push(swapState);
|
2904
|
-
stack.push("INSIDE_STRING");
|
2905
|
-
break;
|
2906
|
-
}
|
2907
|
-
case "f":
|
2908
|
-
case "t":
|
2909
|
-
case "n": {
|
2910
|
-
lastValidIndex = i;
|
2911
|
-
literalStart = i;
|
2912
|
-
stack.pop();
|
2913
|
-
stack.push(swapState);
|
2914
|
-
stack.push("INSIDE_LITERAL");
|
2915
|
-
break;
|
2916
|
-
}
|
2917
|
-
case "-": {
|
2918
|
-
stack.pop();
|
2919
|
-
stack.push(swapState);
|
2920
|
-
stack.push("INSIDE_NUMBER");
|
2921
|
-
break;
|
2922
|
-
}
|
2923
|
-
case "0":
|
2924
|
-
case "1":
|
2925
|
-
case "2":
|
2926
|
-
case "3":
|
2927
|
-
case "4":
|
2928
|
-
case "5":
|
2929
|
-
case "6":
|
2930
|
-
case "7":
|
2931
|
-
case "8":
|
2932
|
-
case "9": {
|
2933
|
-
lastValidIndex = i;
|
2934
|
-
stack.pop();
|
2935
|
-
stack.push(swapState);
|
2936
|
-
stack.push("INSIDE_NUMBER");
|
2937
|
-
break;
|
2938
|
-
}
|
2939
|
-
case "{": {
|
2940
|
-
lastValidIndex = i;
|
2941
|
-
stack.pop();
|
2942
|
-
stack.push(swapState);
|
2943
|
-
stack.push("INSIDE_OBJECT_START");
|
2944
|
-
break;
|
2945
|
-
}
|
2946
|
-
case "[": {
|
2947
|
-
lastValidIndex = i;
|
2948
|
-
stack.pop();
|
2949
|
-
stack.push(swapState);
|
2950
|
-
stack.push("INSIDE_ARRAY_START");
|
2951
|
-
break;
|
2952
|
-
}
|
2953
|
-
}
|
2954
|
-
}
|
2955
|
-
}
|
2956
|
-
function processAfterObjectValue(char, i) {
|
2957
|
-
switch (char) {
|
2958
|
-
case ",": {
|
2959
|
-
stack.pop();
|
2960
|
-
stack.push("INSIDE_OBJECT_AFTER_COMMA");
|
2961
|
-
break;
|
2962
|
-
}
|
2963
|
-
case "}": {
|
2964
|
-
lastValidIndex = i;
|
2965
|
-
stack.pop();
|
2966
|
-
break;
|
2967
|
-
}
|
2968
|
-
}
|
2969
|
-
}
|
2970
|
-
function processAfterArrayValue(char, i) {
|
2971
|
-
switch (char) {
|
2972
|
-
case ",": {
|
2973
|
-
stack.pop();
|
2974
|
-
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
2975
|
-
break;
|
2976
|
-
}
|
2977
|
-
case "]": {
|
2978
|
-
lastValidIndex = i;
|
2979
|
-
stack.pop();
|
2980
|
-
break;
|
2981
|
-
}
|
2982
|
-
}
|
2983
|
-
}
|
2984
|
-
for (let i = 0; i < input.length; i++) {
|
2985
|
-
const char = input[i];
|
2986
|
-
const currentState = stack[stack.length - 1];
|
2987
|
-
switch (currentState) {
|
2988
|
-
case "ROOT":
|
2989
|
-
processValueStart(char, i, "FINISH");
|
2990
|
-
break;
|
2991
|
-
case "INSIDE_OBJECT_START": {
|
2992
|
-
switch (char) {
|
2993
|
-
case '"': {
|
2994
|
-
stack.pop();
|
2995
|
-
stack.push("INSIDE_OBJECT_KEY");
|
2996
|
-
break;
|
2997
|
-
}
|
2998
|
-
case "}": {
|
2999
|
-
lastValidIndex = i;
|
3000
|
-
stack.pop();
|
3001
|
-
break;
|
3002
|
-
}
|
3003
|
-
}
|
3004
|
-
break;
|
3005
|
-
}
|
3006
|
-
case "INSIDE_OBJECT_AFTER_COMMA": {
|
3007
|
-
switch (char) {
|
3008
|
-
case '"': {
|
3009
|
-
stack.pop();
|
3010
|
-
stack.push("INSIDE_OBJECT_KEY");
|
3011
|
-
break;
|
3012
|
-
}
|
3013
|
-
}
|
3014
|
-
break;
|
3015
|
-
}
|
3016
|
-
case "INSIDE_OBJECT_KEY": {
|
3017
|
-
switch (char) {
|
3018
|
-
case '"': {
|
3019
|
-
stack.pop();
|
3020
|
-
stack.push("INSIDE_OBJECT_AFTER_KEY");
|
3021
|
-
break;
|
3022
|
-
}
|
3023
|
-
}
|
3024
|
-
break;
|
3025
|
-
}
|
3026
|
-
case "INSIDE_OBJECT_AFTER_KEY": {
|
3027
|
-
switch (char) {
|
3028
|
-
case ":": {
|
3029
|
-
stack.pop();
|
3030
|
-
stack.push("INSIDE_OBJECT_BEFORE_VALUE");
|
3031
|
-
break;
|
3032
|
-
}
|
3033
|
-
}
|
3034
|
-
break;
|
3035
|
-
}
|
3036
|
-
case "INSIDE_OBJECT_BEFORE_VALUE": {
|
3037
|
-
processValueStart(char, i, "INSIDE_OBJECT_AFTER_VALUE");
|
3038
|
-
break;
|
3039
|
-
}
|
3040
|
-
case "INSIDE_OBJECT_AFTER_VALUE": {
|
3041
|
-
processAfterObjectValue(char, i);
|
3042
|
-
break;
|
3043
|
-
}
|
3044
|
-
case "INSIDE_STRING": {
|
3045
|
-
switch (char) {
|
3046
|
-
case '"': {
|
3047
|
-
stack.pop();
|
3048
|
-
lastValidIndex = i;
|
3049
|
-
break;
|
3050
|
-
}
|
3051
|
-
case "\\": {
|
3052
|
-
stack.push("INSIDE_STRING_ESCAPE");
|
3053
|
-
break;
|
3054
|
-
}
|
3055
|
-
default: {
|
3056
|
-
lastValidIndex = i;
|
3057
|
-
}
|
3058
|
-
}
|
3059
|
-
break;
|
3060
|
-
}
|
3061
|
-
case "INSIDE_ARRAY_START": {
|
3062
|
-
switch (char) {
|
3063
|
-
case "]": {
|
3064
|
-
lastValidIndex = i;
|
3065
|
-
stack.pop();
|
3066
|
-
break;
|
3067
|
-
}
|
3068
|
-
default: {
|
3069
|
-
lastValidIndex = i;
|
3070
|
-
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
3071
|
-
break;
|
3072
|
-
}
|
3073
|
-
}
|
3074
|
-
break;
|
3075
|
-
}
|
3076
|
-
case "INSIDE_ARRAY_AFTER_VALUE": {
|
3077
|
-
switch (char) {
|
3078
|
-
case ",": {
|
3079
|
-
stack.pop();
|
3080
|
-
stack.push("INSIDE_ARRAY_AFTER_COMMA");
|
3081
|
-
break;
|
3082
|
-
}
|
3083
|
-
case "]": {
|
3084
|
-
lastValidIndex = i;
|
3085
|
-
stack.pop();
|
3086
|
-
break;
|
3087
|
-
}
|
3088
|
-
default: {
|
3089
|
-
lastValidIndex = i;
|
3090
|
-
break;
|
3091
|
-
}
|
3092
|
-
}
|
3093
|
-
break;
|
3094
|
-
}
|
3095
|
-
case "INSIDE_ARRAY_AFTER_COMMA": {
|
3096
|
-
processValueStart(char, i, "INSIDE_ARRAY_AFTER_VALUE");
|
3097
|
-
break;
|
3098
|
-
}
|
3099
|
-
case "INSIDE_STRING_ESCAPE": {
|
3100
|
-
stack.pop();
|
3101
|
-
lastValidIndex = i;
|
3102
|
-
break;
|
3103
|
-
}
|
3104
|
-
case "INSIDE_NUMBER": {
|
3105
|
-
switch (char) {
|
3106
|
-
case "0":
|
3107
|
-
case "1":
|
3108
|
-
case "2":
|
3109
|
-
case "3":
|
3110
|
-
case "4":
|
3111
|
-
case "5":
|
3112
|
-
case "6":
|
3113
|
-
case "7":
|
3114
|
-
case "8":
|
3115
|
-
case "9": {
|
3116
|
-
lastValidIndex = i;
|
3117
|
-
break;
|
3118
|
-
}
|
3119
|
-
case "e":
|
3120
|
-
case "E":
|
3121
|
-
case "-":
|
3122
|
-
case ".": {
|
3123
|
-
break;
|
3124
|
-
}
|
3125
|
-
case ",": {
|
3126
|
-
stack.pop();
|
3127
|
-
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
3128
|
-
processAfterArrayValue(char, i);
|
3129
|
-
}
|
3130
|
-
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
3131
|
-
processAfterObjectValue(char, i);
|
3132
|
-
}
|
3133
|
-
break;
|
3134
|
-
}
|
3135
|
-
case "}": {
|
3136
|
-
stack.pop();
|
3137
|
-
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
3138
|
-
processAfterObjectValue(char, i);
|
3139
|
-
}
|
3140
|
-
break;
|
3141
|
-
}
|
3142
|
-
case "]": {
|
3143
|
-
stack.pop();
|
3144
|
-
if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
3145
|
-
processAfterArrayValue(char, i);
|
3146
|
-
}
|
3147
|
-
break;
|
3148
|
-
}
|
3149
|
-
default: {
|
3150
|
-
stack.pop();
|
3151
|
-
break;
|
3152
|
-
}
|
3153
|
-
}
|
3154
|
-
break;
|
3155
|
-
}
|
3156
|
-
case "INSIDE_LITERAL": {
|
3157
|
-
const partialLiteral = input.substring(literalStart, i + 1);
|
3158
|
-
if (!"false".startsWith(partialLiteral) && !"true".startsWith(partialLiteral) && !"null".startsWith(partialLiteral)) {
|
3159
|
-
stack.pop();
|
3160
|
-
if (stack[stack.length - 1] === "INSIDE_OBJECT_AFTER_VALUE") {
|
3161
|
-
processAfterObjectValue(char, i);
|
3162
|
-
} else if (stack[stack.length - 1] === "INSIDE_ARRAY_AFTER_VALUE") {
|
3163
|
-
processAfterArrayValue(char, i);
|
3164
|
-
}
|
3165
|
-
} else {
|
3166
|
-
lastValidIndex = i;
|
3167
|
-
}
|
3168
|
-
break;
|
3169
|
-
}
|
3170
|
-
}
|
3171
|
-
}
|
3172
|
-
let result = input.slice(0, lastValidIndex + 1);
|
3173
|
-
for (let i = stack.length - 1; i >= 0; i--) {
|
3174
|
-
const state = stack[i];
|
3175
|
-
switch (state) {
|
3176
|
-
case "INSIDE_STRING": {
|
3177
|
-
result += '"';
|
3178
|
-
break;
|
3179
|
-
}
|
3180
|
-
case "INSIDE_OBJECT_KEY":
|
3181
|
-
case "INSIDE_OBJECT_AFTER_KEY":
|
3182
|
-
case "INSIDE_OBJECT_AFTER_COMMA":
|
3183
|
-
case "INSIDE_OBJECT_START":
|
3184
|
-
case "INSIDE_OBJECT_BEFORE_VALUE":
|
3185
|
-
case "INSIDE_OBJECT_AFTER_VALUE": {
|
3186
|
-
result += "}";
|
3187
|
-
break;
|
3188
|
-
}
|
3189
|
-
case "INSIDE_ARRAY_START":
|
3190
|
-
case "INSIDE_ARRAY_AFTER_COMMA":
|
3191
|
-
case "INSIDE_ARRAY_AFTER_VALUE": {
|
3192
|
-
result += "]";
|
3193
|
-
break;
|
3194
|
-
}
|
3195
|
-
case "INSIDE_LITERAL": {
|
3196
|
-
const partialLiteral = input.substring(literalStart, input.length);
|
3197
|
-
if ("true".startsWith(partialLiteral)) {
|
3198
|
-
result += "true".slice(partialLiteral.length);
|
3199
|
-
} else if ("false".startsWith(partialLiteral)) {
|
3200
|
-
result += "false".slice(partialLiteral.length);
|
3201
|
-
} else if ("null".startsWith(partialLiteral)) {
|
3202
|
-
result += "null".slice(partialLiteral.length);
|
3203
|
-
}
|
3204
|
-
}
|
3205
|
-
}
|
3206
|
-
}
|
3207
|
-
return result;
|
3208
|
-
}
|
3209
|
-
|
3210
|
-
// src/runtimes/edge/partial-json/parse-partial-json.ts
|
3211
|
-
var parsePartialJson = (json) => {
|
3212
|
-
try {
|
3213
|
-
return import_secure_json_parse.default.parse(json);
|
3214
|
-
} catch {
|
3215
|
-
try {
|
3216
|
-
return import_secure_json_parse.default.parse(fixJson(json));
|
3217
|
-
} catch {
|
3218
|
-
return void 0;
|
3219
|
-
}
|
3220
|
-
}
|
3221
|
-
};
|
3222
|
-
|
3223
|
-
// src/runtimes/edge/streams/runResultStream.ts
|
3224
|
-
function runResultStream() {
|
3225
|
-
let message = {
|
3226
|
-
content: [],
|
3227
|
-
status: { type: "running" }
|
3228
|
-
};
|
3229
|
-
const currentToolCall = { toolCallId: "", argsText: "" };
|
3230
|
-
return new TransformStream({
|
3231
|
-
transform(chunk, controller) {
|
3232
|
-
const chunkType = chunk.type;
|
3233
|
-
switch (chunkType) {
|
3234
|
-
case "text-delta": {
|
3235
|
-
message = appendOrUpdateText(message, chunk.textDelta);
|
3236
|
-
controller.enqueue(message);
|
3237
|
-
break;
|
3238
|
-
}
|
3239
|
-
case "tool-call-delta": {
|
3240
|
-
const { toolCallId, toolName, argsTextDelta } = chunk;
|
3241
|
-
if (currentToolCall.toolCallId !== toolCallId) {
|
3242
|
-
currentToolCall.toolCallId = toolCallId;
|
3243
|
-
currentToolCall.argsText = argsTextDelta;
|
3244
|
-
} else {
|
3245
|
-
currentToolCall.argsText += argsTextDelta;
|
3246
|
-
}
|
3247
|
-
message = appendOrUpdateToolCall(
|
3248
|
-
message,
|
3249
|
-
toolCallId,
|
3250
|
-
toolName,
|
3251
|
-
currentToolCall.argsText
|
3252
|
-
);
|
3253
|
-
controller.enqueue(message);
|
3254
|
-
break;
|
3255
|
-
}
|
3256
|
-
case "tool-call": {
|
3257
|
-
break;
|
3258
|
-
}
|
3259
|
-
case "tool-result": {
|
3260
|
-
message = appendOrUpdateToolResult(
|
3261
|
-
message,
|
3262
|
-
chunk.toolCallId,
|
3263
|
-
chunk.toolName,
|
3264
|
-
chunk.result
|
3265
|
-
);
|
3266
|
-
controller.enqueue(message);
|
3267
|
-
break;
|
3268
|
-
}
|
3269
|
-
case "finish": {
|
3270
|
-
message = appendOrUpdateFinish(message, chunk);
|
3271
|
-
controller.enqueue(message);
|
3272
|
-
break;
|
3273
|
-
}
|
3274
|
-
case "error": {
|
3275
|
-
if (chunk.error instanceof Error && chunk.error.name === "AbortError") {
|
3276
|
-
message = appendOrUpdateCancel(message);
|
3277
|
-
controller.enqueue(message);
|
3278
|
-
break;
|
3279
|
-
} else {
|
3280
|
-
throw chunk.error;
|
3281
|
-
}
|
3282
|
-
}
|
3283
|
-
default: {
|
3284
|
-
const unhandledType = chunkType;
|
3285
|
-
throw new Error(`Unhandled chunk type: ${unhandledType}`);
|
3286
|
-
}
|
3287
|
-
}
|
3288
|
-
}
|
3289
|
-
});
|
3290
|
-
}
|
3291
|
-
var appendOrUpdateText = (message, textDelta) => {
|
3292
|
-
let contentParts = message.content;
|
3293
|
-
let contentPart = message.content.at(-1);
|
3294
|
-
if (contentPart?.type !== "text") {
|
3295
|
-
contentPart = { type: "text", text: textDelta };
|
3296
|
-
} else {
|
3297
|
-
contentParts = contentParts.slice(0, -1);
|
3298
|
-
contentPart = { type: "text", text: contentPart.text + textDelta };
|
3299
|
-
}
|
3300
|
-
return {
|
3301
|
-
...message,
|
3302
|
-
content: contentParts.concat([contentPart])
|
3303
|
-
};
|
3304
|
-
};
|
3305
|
-
var appendOrUpdateToolCall = (message, toolCallId, toolName, argsText) => {
|
3306
|
-
let contentParts = message.content;
|
3307
|
-
let contentPart = message.content.at(-1);
|
3308
|
-
if (contentPart?.type !== "tool-call" || contentPart.toolCallId !== toolCallId) {
|
3309
|
-
contentPart = {
|
3310
|
-
type: "tool-call",
|
3311
|
-
toolCallId,
|
3312
|
-
toolName,
|
3313
|
-
argsText,
|
3314
|
-
args: parsePartialJson(argsText)
|
3315
|
-
};
|
3316
|
-
} else {
|
3317
|
-
contentParts = contentParts.slice(0, -1);
|
3318
|
-
contentPart = {
|
3319
|
-
...contentPart,
|
3320
|
-
argsText,
|
3321
|
-
args: parsePartialJson(argsText)
|
3322
|
-
};
|
3323
|
-
}
|
3324
|
-
return {
|
3325
|
-
...message,
|
3326
|
-
content: contentParts.concat([contentPart])
|
3327
|
-
};
|
3328
|
-
};
|
3329
|
-
var appendOrUpdateToolResult = (message, toolCallId, toolName, result) => {
|
3330
|
-
let found = false;
|
3331
|
-
const newContentParts = message.content.map((part) => {
|
3332
|
-
if (part.type !== "tool-call" || part.toolCallId !== toolCallId)
|
3333
|
-
return part;
|
3334
|
-
found = true;
|
3335
|
-
if (part.toolName !== toolName)
|
3336
|
-
throw new Error(
|
3337
|
-
`Tool call ${toolCallId} found with tool name ${part.toolName}, but expected ${toolName}`
|
3338
|
-
);
|
3339
|
-
return {
|
3340
|
-
...part,
|
3341
|
-
result
|
3342
|
-
};
|
3343
|
-
});
|
3344
|
-
if (!found)
|
3345
|
-
throw new Error(
|
3346
|
-
`Received tool result for unknown tool call "${toolName}" / "${toolCallId}". This is likely an internal bug in assistant-ui.`
|
3347
|
-
);
|
3348
|
-
return {
|
3349
|
-
...message,
|
3350
|
-
content: newContentParts
|
3351
|
-
};
|
3352
|
-
};
|
3353
|
-
var appendOrUpdateFinish = (message, chunk) => {
|
3354
|
-
const { type, ...rest } = chunk;
|
3355
|
-
return {
|
3356
|
-
...message,
|
3357
|
-
status: getStatus(chunk),
|
3358
|
-
roundtrips: [
|
3359
|
-
...message.roundtrips ?? [],
|
3360
|
-
{
|
3361
|
-
logprobs: rest.logprobs,
|
3362
|
-
usage: rest.usage
|
3363
|
-
}
|
3364
|
-
]
|
3365
|
-
};
|
3366
|
-
};
|
3367
|
-
var getStatus = (chunk) => {
|
3368
|
-
if (chunk.finishReason === "tool-calls") {
|
3369
|
-
return {
|
3370
|
-
type: "requires-action",
|
3371
|
-
reason: "tool-calls"
|
3372
|
-
};
|
3373
|
-
} else if (chunk.finishReason === "stop" || chunk.finishReason === "unknown") {
|
3374
|
-
return {
|
3375
|
-
type: "complete",
|
3376
|
-
reason: chunk.finishReason
|
3377
|
-
};
|
3378
|
-
} else {
|
3379
|
-
return {
|
3380
|
-
type: "incomplete",
|
3381
|
-
reason: chunk.finishReason
|
3382
|
-
};
|
3383
|
-
}
|
3384
|
-
};
|
3385
|
-
var appendOrUpdateCancel = (message) => {
|
3386
|
-
return {
|
3387
|
-
...message,
|
3388
|
-
status: {
|
3389
|
-
type: "incomplete",
|
3390
|
-
reason: "cancelled"
|
3391
|
-
}
|
3392
|
-
};
|
3393
|
-
};
|
3394
|
-
|
3395
|
-
// src/runtimes/edge/streams/toolResultStream.ts
|
3396
|
-
var import_zod3 = require("zod");
|
3397
|
-
var import_secure_json_parse2 = __toESM(require("secure-json-parse"));
|
3398
|
-
function toolResultStream(tools) {
|
3399
|
-
const toolCallExecutions = /* @__PURE__ */ new Map();
|
3400
|
-
return new TransformStream({
|
3401
|
-
transform(chunk, controller) {
|
3402
|
-
controller.enqueue(chunk);
|
3403
|
-
const chunkType = chunk.type;
|
3404
|
-
switch (chunkType) {
|
3405
|
-
case "tool-call": {
|
3406
|
-
const { toolCallId, toolCallType, toolName, args: argsText } = chunk;
|
3407
|
-
const tool = tools?.[toolName];
|
3408
|
-
if (!tool || !tool.execute) return;
|
3409
|
-
const args = import_secure_json_parse2.default.parse(argsText);
|
3410
|
-
if (tool.parameters instanceof import_zod3.z.ZodType) {
|
3411
|
-
const result = tool.parameters.safeParse(args);
|
3412
|
-
if (!result.success) {
|
3413
|
-
controller.enqueue({
|
3414
|
-
type: "tool-result",
|
3415
|
-
toolCallType,
|
3416
|
-
toolCallId,
|
3417
|
-
toolName,
|
3418
|
-
result: "Function parameter validation failed. " + JSON.stringify(result.error.issues),
|
3419
|
-
isError: true
|
3420
|
-
});
|
3421
|
-
return;
|
3422
|
-
} else {
|
3423
|
-
toolCallExecutions.set(
|
3424
|
-
toolCallId,
|
3425
|
-
(async () => {
|
3426
|
-
try {
|
3427
|
-
const result2 = await tool.execute(args);
|
3428
|
-
controller.enqueue({
|
3429
|
-
type: "tool-result",
|
3430
|
-
toolCallType,
|
3431
|
-
toolCallId,
|
3432
|
-
toolName,
|
3433
|
-
result: result2
|
3434
|
-
});
|
3435
|
-
} catch (error) {
|
3436
|
-
console.error("Error: ", error);
|
3437
|
-
controller.enqueue({
|
3438
|
-
type: "tool-result",
|
3439
|
-
toolCallType,
|
3440
|
-
toolCallId,
|
3441
|
-
toolName,
|
3442
|
-
result: "Error: " + error,
|
3443
|
-
isError: true
|
3444
|
-
});
|
3445
|
-
} finally {
|
3446
|
-
toolCallExecutions.delete(toolCallId);
|
3447
|
-
}
|
3448
|
-
})()
|
3449
|
-
);
|
3450
|
-
}
|
3451
|
-
}
|
3452
|
-
break;
|
3453
|
-
}
|
3454
|
-
case "text-delta":
|
3455
|
-
case "tool-call-delta":
|
3456
|
-
case "tool-result":
|
3457
|
-
case "finish":
|
3458
|
-
case "error":
|
3459
|
-
break;
|
3460
|
-
default: {
|
3461
|
-
const unhandledType = chunkType;
|
3462
|
-
throw new Error(`Unhandled chunk type: ${unhandledType}`);
|
3463
|
-
}
|
3464
|
-
}
|
3465
|
-
},
|
3466
|
-
async flush() {
|
3467
|
-
await Promise.all(toolCallExecutions.values());
|
3468
|
-
}
|
3469
|
-
});
|
3470
|
-
}
|
3471
|
-
|
3472
2617
|
// src/runtimes/edge/EdgeChatAdapter.ts
|
3473
2618
|
function asAsyncIterable(source) {
|
3474
2619
|
return {
|
@@ -3495,8 +2640,8 @@ var EdgeChatAdapter = class {
|
|
3495
2640
|
},
|
3496
2641
|
body: JSON.stringify({
|
3497
2642
|
system: config.system,
|
3498
|
-
messages: toCoreMessages(messages),
|
3499
|
-
tools: config.tools ? toLanguageModelTools(config.tools) : [],
|
2643
|
+
messages: _chunkNSPHKRLFjs.toCoreMessages.call(void 0, messages),
|
2644
|
+
tools: config.tools ? _chunkNSPHKRLFjs.toLanguageModelTools.call(void 0, config.tools) : [],
|
3500
2645
|
...config.callSettings,
|
3501
2646
|
...config.config
|
3502
2647
|
}),
|
@@ -3505,7 +2650,7 @@ var EdgeChatAdapter = class {
|
|
3505
2650
|
if (result.status !== 200) {
|
3506
2651
|
throw new Error(`Status ${result.status}: ${await result.text()}`);
|
3507
2652
|
}
|
3508
|
-
const stream = result.body.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(assistantDecoderStream()).pipeThrough(toolResultStream(config.tools)).pipeThrough(runResultStream());
|
2653
|
+
const stream = result.body.pipeThrough(new TextDecoderStream()).pipeThrough(chunkByLineStream()).pipeThrough(assistantDecoderStream()).pipeThrough(_chunkNSPHKRLFjs.toolResultStream.call(void 0, config.tools)).pipeThrough(_chunkNSPHKRLFjs.runResultStream.call(void 0, ));
|
3509
2654
|
let update;
|
3510
2655
|
for await (update of asAsyncIterable(stream)) {
|
3511
2656
|
yield update;
|
@@ -3520,12 +2665,12 @@ var useEdgeRuntime = ({
|
|
3520
2665
|
initialMessages,
|
3521
2666
|
...options
|
3522
2667
|
}) => {
|
3523
|
-
const [adapter] = (0,
|
2668
|
+
const [adapter] = _react.useState.call(void 0, () => new EdgeChatAdapter(options));
|
3524
2669
|
return useLocalRuntime(adapter, { initialMessages });
|
3525
2670
|
};
|
3526
2671
|
|
3527
2672
|
// src/runtimes/local/shouldContinue.tsx
|
3528
|
-
var shouldContinue = (result) => result.status
|
2673
|
+
var shouldContinue = (result) => _optionalChain([result, 'access', _96 => _96.status, 'optionalAccess', _97 => _97.type]) === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
3529
2674
|
|
3530
2675
|
// src/runtimes/local/LocalThreadRuntime.tsx
|
3531
2676
|
var CAPABILITIES = Object.freeze({
|
@@ -3535,12 +2680,12 @@ var CAPABILITIES = Object.freeze({
|
|
3535
2680
|
cancel: true,
|
3536
2681
|
copy: true
|
3537
2682
|
});
|
3538
|
-
var LocalThreadRuntime = class {
|
3539
|
-
constructor(configProvider, adapter, options) {
|
2683
|
+
var LocalThreadRuntime = (_class5 = class {
|
2684
|
+
constructor(configProvider, adapter, options) {;_class5.prototype.__init11.call(this);_class5.prototype.__init12.call(this);_class5.prototype.__init13.call(this);_class5.prototype.__init14.call(this);_class5.prototype.__init15.call(this);
|
3540
2685
|
this.configProvider = configProvider;
|
3541
2686
|
this.adapter = adapter;
|
3542
2687
|
this.options = options;
|
3543
|
-
if (options
|
2688
|
+
if (_optionalChain([options, 'optionalAccess', _98 => _98.initialMessages])) {
|
3544
2689
|
let parentId = null;
|
3545
2690
|
const messages = fromCoreMessages(options.initialMessages);
|
3546
2691
|
for (const message of messages) {
|
@@ -3549,11 +2694,11 @@ var LocalThreadRuntime = class {
|
|
3549
2694
|
}
|
3550
2695
|
}
|
3551
2696
|
}
|
3552
|
-
_subscriptions = /* @__PURE__ */ new Set()
|
3553
|
-
abortController = null
|
3554
|
-
repository = new MessageRepository()
|
3555
|
-
capabilities = CAPABILITIES
|
3556
|
-
isDisabled = false
|
2697
|
+
__init11() {this._subscriptions = /* @__PURE__ */ new Set()}
|
2698
|
+
__init12() {this.abortController = null}
|
2699
|
+
__init13() {this.repository = new MessageRepository()}
|
2700
|
+
__init14() {this.capabilities = CAPABILITIES}
|
2701
|
+
__init15() {this.isDisabled = false}
|
3557
2702
|
get messages() {
|
3558
2703
|
return this.repository.getMessages();
|
3559
2704
|
}
|
@@ -3598,22 +2743,22 @@ var LocalThreadRuntime = class {
|
|
3598
2743
|
}
|
3599
2744
|
async performRoundtrip(parentId, message) {
|
3600
2745
|
const messages = this.repository.getMessages();
|
3601
|
-
this.abortController
|
2746
|
+
_optionalChain([this, 'access', _99 => _99.abortController, 'optionalAccess', _100 => _100.abort, 'call', _101 => _101()]);
|
3602
2747
|
this.abortController = new AbortController();
|
3603
2748
|
const initialContent = message.content;
|
3604
2749
|
const initialRoundtrips = message.roundtrips;
|
3605
2750
|
const updateMessage = (m) => {
|
3606
2751
|
message = {
|
3607
2752
|
...message,
|
3608
|
-
...m.content ? { content: [...initialContent, ...m.content
|
3609
|
-
status: m.status
|
3610
|
-
...m.roundtrips
|
2753
|
+
...m.content ? { content: [...initialContent, ..._nullishCoalesce(m.content, () => ( []))] } : void 0,
|
2754
|
+
status: _nullishCoalesce(m.status, () => ( message.status)),
|
2755
|
+
..._optionalChain([m, 'access', _102 => _102.roundtrips, 'optionalAccess', _103 => _103.length]) ? { roundtrips: [..._nullishCoalesce(initialRoundtrips, () => ( [])), ...m.roundtrips] } : void 0
|
3611
2756
|
};
|
3612
2757
|
this.repository.addOrUpdateMessage(parentId, message);
|
3613
2758
|
this.notifySubscribers();
|
3614
2759
|
};
|
3615
|
-
const maxToolRoundtrips = this.options
|
3616
|
-
const toolRoundtrips = message.roundtrips
|
2760
|
+
const maxToolRoundtrips = _nullishCoalesce(_optionalChain([this, 'access', _104 => _104.options, 'optionalAccess', _105 => _105.maxToolRoundtrips]), () => ( 1));
|
2761
|
+
const toolRoundtrips = _nullishCoalesce(_optionalChain([message, 'access', _106 => _106.roundtrips, 'optionalAccess', _107 => _107.length]), () => ( 0));
|
3617
2762
|
if (toolRoundtrips > maxToolRoundtrips) {
|
3618
2763
|
updateMessage({
|
3619
2764
|
status: {
|
@@ -3705,11 +2850,18 @@ var LocalThreadRuntime = class {
|
|
3705
2850
|
this.performRoundtrip(parentId, message);
|
3706
2851
|
}
|
3707
2852
|
}
|
3708
|
-
|
2853
|
+
export() {
|
2854
|
+
return this.repository.export();
|
2855
|
+
}
|
2856
|
+
import(data) {
|
2857
|
+
this.repository.import(data);
|
2858
|
+
this.notifySubscribers();
|
2859
|
+
}
|
2860
|
+
}, _class5);
|
3709
2861
|
|
3710
2862
|
// src/runtimes/local/LocalRuntime.tsx
|
3711
2863
|
var LocalRuntime = class extends BaseAssistantRuntime {
|
3712
|
-
|
2864
|
+
|
3713
2865
|
constructor(adapter, options) {
|
3714
2866
|
const proxyConfigProvider = new ProxyConfigProvider();
|
3715
2867
|
super(new LocalThreadRuntime(proxyConfigProvider, adapter, options));
|
@@ -3734,15 +2886,15 @@ var LocalRuntime = class extends BaseAssistantRuntime {
|
|
3734
2886
|
|
3735
2887
|
// src/runtimes/local/useLocalRuntime.tsx
|
3736
2888
|
var useLocalRuntime = (adapter, options) => {
|
3737
|
-
const [runtime] = (0,
|
3738
|
-
(0,
|
2889
|
+
const [runtime] = _react.useState.call(void 0, () => new LocalRuntime(adapter, options));
|
2890
|
+
_react.useInsertionEffect.call(void 0, () => {
|
3739
2891
|
runtime.adapter = adapter;
|
3740
2892
|
});
|
3741
2893
|
return runtime;
|
3742
2894
|
};
|
3743
2895
|
|
3744
2896
|
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
3745
|
-
|
2897
|
+
|
3746
2898
|
|
3747
2899
|
// src/runtimes/external-store/getExternalStoreMessage.tsx
|
3748
2900
|
var symbolInnerMessage = Symbol("innerMessage");
|
@@ -3751,11 +2903,11 @@ var getExternalStoreMessage = (message) => {
|
|
3751
2903
|
};
|
3752
2904
|
|
3753
2905
|
// src/runtimes/external-store/useExternalStoreSync.tsx
|
3754
|
-
|
2906
|
+
|
3755
2907
|
|
3756
2908
|
// src/runtimes/external-store/ThreadMessageConverter.ts
|
3757
|
-
var ThreadMessageConverter = class {
|
3758
|
-
cache = /* @__PURE__ */ new WeakMap()
|
2909
|
+
var ThreadMessageConverter = (_class6 = class {constructor() { _class6.prototype.__init16.call(this); }
|
2910
|
+
__init16() {this.cache = /* @__PURE__ */ new WeakMap()}
|
3759
2911
|
convertMessages(messages, converter, keyMapper = (key) => key) {
|
3760
2912
|
return messages.map((m, idx) => {
|
3761
2913
|
const key = keyMapper(m);
|
@@ -3765,7 +2917,7 @@ var ThreadMessageConverter = class {
|
|
3765
2917
|
return newMessage;
|
3766
2918
|
});
|
3767
2919
|
}
|
3768
|
-
};
|
2920
|
+
}, _class6);
|
3769
2921
|
|
3770
2922
|
// src/runtimes/external-store/auto-status.tsx
|
3771
2923
|
var AUTO_STATUS_RUNNING = Object.freeze({ type: "running" });
|
@@ -3779,8 +2931,8 @@ var getAutoStatus = (isLast, isRunning) => isLast && isRunning ? AUTO_STATUS_RUN
|
|
3779
2931
|
var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
3780
2932
|
const { role, content, id, createdAt, status } = like;
|
3781
2933
|
const common = {
|
3782
|
-
id: id
|
3783
|
-
createdAt: createdAt
|
2934
|
+
id: _nullishCoalesce(id, () => ( fallbackId)),
|
2935
|
+
createdAt: _nullishCoalesce(createdAt, () => ( /* @__PURE__ */ new Date()))
|
3784
2936
|
};
|
3785
2937
|
switch (role) {
|
3786
2938
|
case "assistant":
|
@@ -3806,7 +2958,7 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
3806
2958
|
}
|
3807
2959
|
}
|
3808
2960
|
}),
|
3809
|
-
status: status
|
2961
|
+
status: _nullishCoalesce(status, () => ( fallbackStatus))
|
3810
2962
|
};
|
3811
2963
|
case "user":
|
3812
2964
|
return {
|
@@ -3845,16 +2997,16 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
|
|
3845
2997
|
|
3846
2998
|
// src/runtimes/external-store/useExternalStoreSync.tsx
|
3847
2999
|
var useExternalStoreSync = (adapter, updateData) => {
|
3848
|
-
const adapterRef = (0,
|
3849
|
-
(0,
|
3000
|
+
const adapterRef = _react.useRef.call(void 0, adapter);
|
3001
|
+
_react.useInsertionEffect.call(void 0, () => {
|
3850
3002
|
adapterRef.current = adapter;
|
3851
3003
|
});
|
3852
|
-
const [converter, convertCallback] = (0,
|
3853
|
-
const converter2 = adapter.convertMessage
|
3004
|
+
const [converter, convertCallback] = _react.useMemo.call(void 0, () => {
|
3005
|
+
const converter2 = _nullishCoalesce(adapter.convertMessage, () => ( ((m) => m)));
|
3854
3006
|
const convertCallback2 = (cache, m, idx) => {
|
3855
3007
|
const autoStatus = getAutoStatus(
|
3856
3008
|
adapterRef.current.messages.at(-1) === m,
|
3857
|
-
adapterRef.current.isRunning
|
3009
|
+
_nullishCoalesce(adapterRef.current.isRunning, () => ( false))
|
3858
3010
|
);
|
3859
3011
|
if (cache && (cache.role !== "assistant" || cache.status === autoStatus))
|
3860
3012
|
return cache;
|
@@ -3868,10 +3020,10 @@ var useExternalStoreSync = (adapter, updateData) => {
|
|
3868
3020
|
};
|
3869
3021
|
return [new ThreadMessageConverter(), convertCallback2];
|
3870
3022
|
}, [adapter.convertMessage]);
|
3871
|
-
(0,
|
3023
|
+
_react.useEffect.call(void 0, () => {
|
3872
3024
|
updateData(
|
3873
|
-
adapter.isDisabled
|
3874
|
-
adapter.isRunning
|
3025
|
+
_nullishCoalesce(adapter.isDisabled, () => ( false)),
|
3026
|
+
_nullishCoalesce(adapter.isRunning, () => ( false)),
|
3875
3027
|
converter.convertMessages(adapter.messages, convertCallback)
|
3876
3028
|
);
|
3877
3029
|
}, [
|
@@ -3886,24 +3038,24 @@ var useExternalStoreSync = (adapter, updateData) => {
|
|
3886
3038
|
|
3887
3039
|
// src/runtimes/external-store/ExternalStoreThreadRuntime.tsx
|
3888
3040
|
var hasUpcomingMessage = (isRunning, messages) => {
|
3889
|
-
return isRunning && messages[messages.length - 1]
|
3041
|
+
return isRunning && _optionalChain([messages, 'access', _108 => _108[messages.length - 1], 'optionalAccess', _109 => _109.role]) !== "assistant";
|
3890
3042
|
};
|
3891
|
-
var ExternalStoreThreadRuntime = class {
|
3892
|
-
constructor(store) {
|
3043
|
+
var ExternalStoreThreadRuntime = (_class7 = class {
|
3044
|
+
constructor(store) {;_class7.prototype.__init17.call(this);_class7.prototype.__init18.call(this);_class7.prototype.__init19.call(this);_class7.prototype.__init20.call(this);_class7.prototype.__init21.call(this);_class7.prototype.__init22.call(this);_class7.prototype.__init23.call(this);_class7.prototype.__init24.call(this);_class7.prototype.__init25.call(this);
|
3893
3045
|
this.store = store;
|
3894
3046
|
this.updateData(
|
3895
|
-
store.isDisabled
|
3896
|
-
store.isRunning
|
3047
|
+
_nullishCoalesce(store.isDisabled, () => ( false)),
|
3048
|
+
_nullishCoalesce(store.isRunning, () => ( false)),
|
3897
3049
|
store.messages
|
3898
3050
|
);
|
3899
|
-
this.useStore = (0,
|
3051
|
+
this.useStore = _zustand.create.call(void 0, () => ({
|
3900
3052
|
store
|
3901
3053
|
}));
|
3902
3054
|
}
|
3903
|
-
_subscriptions = /* @__PURE__ */ new Set()
|
3904
|
-
repository = new MessageRepository()
|
3905
|
-
assistantOptimisticId = null
|
3906
|
-
|
3055
|
+
__init17() {this._subscriptions = /* @__PURE__ */ new Set()}
|
3056
|
+
__init18() {this.repository = new MessageRepository()}
|
3057
|
+
__init19() {this.assistantOptimisticId = null}
|
3058
|
+
|
3907
3059
|
get capabilities() {
|
3908
3060
|
return {
|
3909
3061
|
switchToBranch: this.store.setMessages !== void 0,
|
@@ -3913,9 +3065,9 @@ var ExternalStoreThreadRuntime = class {
|
|
3913
3065
|
copy: this.store.onCopy !== null
|
3914
3066
|
};
|
3915
3067
|
}
|
3916
|
-
messages = []
|
3917
|
-
isDisabled = false
|
3918
|
-
isRunning = false
|
3068
|
+
__init20() {this.messages = []}
|
3069
|
+
__init21() {this.isDisabled = false}
|
3070
|
+
__init22() {this.isRunning = false}
|
3919
3071
|
getBranches(messageId) {
|
3920
3072
|
return this.repository.getBranches(messageId);
|
3921
3073
|
}
|
@@ -3926,7 +3078,7 @@ var ExternalStoreThreadRuntime = class {
|
|
3926
3078
|
this.updateMessages(this.repository.getMessages());
|
3927
3079
|
}
|
3928
3080
|
async append(message) {
|
3929
|
-
if (message.parentId !== (this.messages.at(-1)
|
3081
|
+
if (message.parentId !== (_nullishCoalesce(_optionalChain([this, 'access', _120 => _120.messages, 'access', _121 => _121.at, 'call', _122 => _122(-1), 'optionalAccess', _123 => _123.id]), () => ( null)))) {
|
3930
3082
|
if (!this.store.onEdit)
|
3931
3083
|
throw new Error("Runtime does not support editing messages.");
|
3932
3084
|
await this.store.onEdit(message);
|
@@ -3956,21 +3108,21 @@ var ExternalStoreThreadRuntime = class {
|
|
3956
3108
|
this._subscriptions.add(callback);
|
3957
3109
|
return () => this._subscriptions.delete(callback);
|
3958
3110
|
}
|
3959
|
-
updateMessages = (messages) => {
|
3960
|
-
this.store.setMessages
|
3111
|
+
__init23() {this.updateMessages = (messages) => {
|
3112
|
+
_optionalChain([this, 'access', _124 => _124.store, 'access', _125 => _125.setMessages, 'optionalCall', _126 => _126(
|
3961
3113
|
messages.flatMap(getExternalStoreMessage).filter((m) => m != null)
|
3962
|
-
);
|
3963
|
-
}
|
3114
|
+
)]);
|
3115
|
+
}}
|
3964
3116
|
onStoreUpdated() {
|
3965
3117
|
if (this.useStore.getState().store !== this.store) {
|
3966
3118
|
this.useStore.setState({ store: this.store });
|
3967
3119
|
}
|
3968
3120
|
}
|
3969
|
-
updateData = (isDisabled, isRunning, vm) => {
|
3121
|
+
__init24() {this.updateData = (isDisabled, isRunning, vm) => {
|
3970
3122
|
for (let i = 0; i < vm.length; i++) {
|
3971
3123
|
const message = vm[i];
|
3972
3124
|
const parent = vm[i - 1];
|
3973
|
-
this.repository.addOrUpdateMessage(parent
|
3125
|
+
this.repository.addOrUpdateMessage(_nullishCoalesce(_optionalChain([parent, 'optionalAccess', _127 => _127.id]), () => ( null)), message);
|
3974
3126
|
}
|
3975
3127
|
if (this.assistantOptimisticId) {
|
3976
3128
|
this.repository.deleteMessage(this.assistantOptimisticId);
|
@@ -3978,7 +3130,7 @@ var ExternalStoreThreadRuntime = class {
|
|
3978
3130
|
}
|
3979
3131
|
if (hasUpcomingMessage(isRunning, vm)) {
|
3980
3132
|
this.assistantOptimisticId = this.repository.appendOptimisticMessage(
|
3981
|
-
vm.at(-1)
|
3133
|
+
_nullishCoalesce(_optionalChain([vm, 'access', _128 => _128.at, 'call', _129 => _129(-1), 'optionalAccess', _130 => _130.id]), () => ( null)),
|
3982
3134
|
{
|
3983
3135
|
role: "assistant",
|
3984
3136
|
content: []
|
@@ -3986,30 +3138,30 @@ var ExternalStoreThreadRuntime = class {
|
|
3986
3138
|
);
|
3987
3139
|
}
|
3988
3140
|
this.repository.resetHead(
|
3989
|
-
this.assistantOptimisticId
|
3141
|
+
_nullishCoalesce(_nullishCoalesce(this.assistantOptimisticId, () => ( _optionalChain([vm, 'access', _131 => _131.at, 'call', _132 => _132(-1), 'optionalAccess', _133 => _133.id]))), () => ( null))
|
3990
3142
|
);
|
3991
3143
|
this.messages = this.repository.getMessages();
|
3992
3144
|
this.isDisabled = isDisabled;
|
3993
3145
|
this.isRunning = isRunning;
|
3994
3146
|
for (const callback of this._subscriptions) callback();
|
3995
|
-
}
|
3996
|
-
unstable_synchronizer = () => {
|
3147
|
+
}}
|
3148
|
+
__init25() {this.unstable_synchronizer = () => {
|
3997
3149
|
const { store } = this.useStore();
|
3998
3150
|
useExternalStoreSync(store, this.updateData);
|
3999
3151
|
return null;
|
4000
|
-
}
|
3152
|
+
}}
|
4001
3153
|
addToolResult(options) {
|
4002
3154
|
if (!this.store.onAddToolResult)
|
4003
3155
|
throw new Error("Runtime does not support tool results.");
|
4004
3156
|
this.store.onAddToolResult(options);
|
4005
3157
|
}
|
4006
|
-
};
|
3158
|
+
}, _class7);
|
4007
3159
|
|
4008
3160
|
// src/runtimes/external-store/ExternalStoreRuntime.tsx
|
4009
|
-
var ExternalStoreRuntime = class extends BaseAssistantRuntime {
|
4010
|
-
_proxyConfigProvider = new ProxyConfigProvider()
|
3161
|
+
var ExternalStoreRuntime = (_class8 = class extends BaseAssistantRuntime {
|
3162
|
+
__init26() {this._proxyConfigProvider = new ProxyConfigProvider()}
|
4011
3163
|
constructor(store) {
|
4012
|
-
super(new ExternalStoreThreadRuntime(store));
|
3164
|
+
super(new ExternalStoreThreadRuntime(store));_class8.prototype.__init26.call(this);;
|
4013
3165
|
}
|
4014
3166
|
set store(store) {
|
4015
3167
|
this.thread.store = store;
|
@@ -4034,48 +3186,51 @@ var ExternalStoreRuntime = class extends BaseAssistantRuntime {
|
|
4034
3186
|
return this.store.onNewThread();
|
4035
3187
|
}
|
4036
3188
|
}
|
4037
|
-
};
|
3189
|
+
}, _class8);
|
4038
3190
|
|
4039
3191
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
4040
|
-
|
3192
|
+
|
4041
3193
|
var useExternalStoreRuntime = (store) => {
|
4042
|
-
const [runtime] = (0,
|
4043
|
-
(0,
|
3194
|
+
const [runtime] = _react.useState.call(void 0, () => new ExternalStoreRuntime(store));
|
3195
|
+
_react.useInsertionEffect.call(void 0, () => {
|
4044
3196
|
runtime.store = store;
|
4045
3197
|
});
|
4046
|
-
(0,
|
3198
|
+
_react.useEffect.call(void 0, () => {
|
4047
3199
|
runtime.onStoreUpdated();
|
4048
3200
|
});
|
4049
3201
|
return runtime;
|
4050
3202
|
};
|
4051
3203
|
|
4052
3204
|
// src/ui/thread-config.tsx
|
4053
|
-
|
4054
|
-
|
4055
|
-
|
3205
|
+
|
3206
|
+
|
3207
|
+
|
3208
|
+
|
3209
|
+
|
3210
|
+
var ThreadConfigContext = _react.createContext.call(void 0, {});
|
4056
3211
|
var useThreadConfig = () => {
|
4057
|
-
return (0,
|
3212
|
+
return _react.useContext.call(void 0, ThreadConfigContext);
|
4058
3213
|
};
|
4059
3214
|
var ThreadConfigProvider = ({
|
4060
3215
|
children,
|
4061
3216
|
config
|
4062
3217
|
}) => {
|
4063
3218
|
const assistant = useAssistantContext({ optional: true });
|
4064
|
-
const configProvider = config && Object.keys(config
|
4065
|
-
if (!config
|
3219
|
+
const configProvider = config && Object.keys(_nullishCoalesce(config, () => ( {}))).length > 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigContext.Provider, { value: config, children }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children });
|
3220
|
+
if (!_optionalChain([config, 'optionalAccess', _134 => _134.runtime])) return configProvider;
|
4066
3221
|
if (assistant) {
|
4067
3222
|
throw new Error(
|
4068
3223
|
"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed."
|
4069
3224
|
);
|
4070
3225
|
}
|
4071
|
-
return /* @__PURE__ */ (0,
|
3226
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantRuntimeProvider, { runtime: config.runtime, children: configProvider });
|
4072
3227
|
};
|
4073
3228
|
ThreadConfigProvider.displayName = "ThreadConfigProvider";
|
4074
3229
|
|
4075
3230
|
// src/ui/assistant-action-bar.tsx
|
4076
|
-
|
4077
|
-
var
|
4078
|
-
|
3231
|
+
|
3232
|
+
var _lucidereact = require('lucide-react');
|
3233
|
+
|
4079
3234
|
var useAllowCopy = () => {
|
4080
3235
|
const { assistantMessage: { allowCopy = true } = {} } = useThreadConfig();
|
4081
3236
|
const { useThreadActions } = useThreadContext();
|
@@ -4092,15 +3247,15 @@ var AssistantActionBar = () => {
|
|
4092
3247
|
const allowCopy = useAllowCopy();
|
4093
3248
|
const allowReload = useAllowReload();
|
4094
3249
|
if (!allowCopy && !allowReload) return null;
|
4095
|
-
return /* @__PURE__ */ (0,
|
3250
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
4096
3251
|
AssistantActionBarRoot,
|
4097
3252
|
{
|
4098
3253
|
hideWhenRunning: true,
|
4099
3254
|
autohide: "not-last",
|
4100
3255
|
autohideFloat: "single-branch",
|
4101
3256
|
children: [
|
4102
|
-
/* @__PURE__ */ (0,
|
4103
|
-
/* @__PURE__ */ (0,
|
3257
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantActionBarCopy, {}),
|
3258
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantActionBarReload, {})
|
4104
3259
|
]
|
4105
3260
|
}
|
4106
3261
|
);
|
@@ -4110,7 +3265,7 @@ var AssistantActionBarRoot = withDefaults(actionBar_exports.Root, {
|
|
4110
3265
|
className: "aui-assistant-action-bar-root"
|
4111
3266
|
});
|
4112
3267
|
AssistantActionBarRoot.displayName = "AssistantActionBarRoot";
|
4113
|
-
var AssistantActionBarCopy = (0,
|
3268
|
+
var AssistantActionBarCopy = _react.forwardRef.call(void 0, (props, ref) => {
|
4114
3269
|
const {
|
4115
3270
|
strings: {
|
4116
3271
|
assistantMessage: { reload: { tooltip = "Copy" } = {} } = {}
|
@@ -4118,13 +3273,13 @@ var AssistantActionBarCopy = (0, import_react59.forwardRef)((props, ref) => {
|
|
4118
3273
|
} = useThreadConfig();
|
4119
3274
|
const allowCopy = useAllowCopy();
|
4120
3275
|
if (!allowCopy) return null;
|
4121
|
-
return /* @__PURE__ */ (0,
|
4122
|
-
/* @__PURE__ */ (0,
|
4123
|
-
/* @__PURE__ */ (0,
|
4124
|
-
] }) }) });
|
3276
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Copy, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
3277
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { copied: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CheckIcon, {}) }),
|
3278
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, message_exports.If, { copied: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.CopyIcon, {}) })
|
3279
|
+
] }))) }) });
|
4125
3280
|
});
|
4126
3281
|
AssistantActionBarCopy.displayName = "AssistantActionBarCopy";
|
4127
|
-
var AssistantActionBarReload = (0,
|
3282
|
+
var AssistantActionBarReload = _react.forwardRef.call(void 0, (props, ref) => {
|
4128
3283
|
const {
|
4129
3284
|
strings: {
|
4130
3285
|
assistantMessage: { reload: { tooltip = "Refresh" } = {} } = {}
|
@@ -4132,26 +3287,26 @@ var AssistantActionBarReload = (0, import_react59.forwardRef)((props, ref) => {
|
|
4132
3287
|
} = useThreadConfig();
|
4133
3288
|
const allowReload = useAllowReload();
|
4134
3289
|
if (!allowReload) return null;
|
4135
|
-
return /* @__PURE__ */ (0,
|
3290
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Reload, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.RefreshCwIcon, {}) }) });
|
4136
3291
|
});
|
4137
3292
|
AssistantActionBarReload.displayName = "AssistantActionBarReload";
|
4138
|
-
var
|
3293
|
+
var exports = {
|
4139
3294
|
Root: AssistantActionBarRoot,
|
4140
3295
|
Reload: AssistantActionBarReload,
|
4141
3296
|
Copy: AssistantActionBarCopy
|
4142
3297
|
};
|
4143
3298
|
var assistant_action_bar_default = Object.assign(
|
4144
3299
|
AssistantActionBar,
|
4145
|
-
|
3300
|
+
exports
|
4146
3301
|
);
|
4147
3302
|
|
4148
3303
|
// src/ui/assistant-message.tsx
|
4149
|
-
|
3304
|
+
|
4150
3305
|
|
4151
3306
|
// src/ui/branch-picker.tsx
|
4152
|
-
|
4153
|
-
|
4154
|
-
|
3307
|
+
|
3308
|
+
|
3309
|
+
|
4155
3310
|
var useAllowBranchPicker = () => {
|
4156
3311
|
const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
|
4157
3312
|
const { useThreadActions } = useThreadContext();
|
@@ -4161,10 +3316,10 @@ var useAllowBranchPicker = () => {
|
|
4161
3316
|
var BranchPicker = () => {
|
4162
3317
|
const allowBranchPicker = useAllowBranchPicker();
|
4163
3318
|
if (!allowBranchPicker) return null;
|
4164
|
-
return /* @__PURE__ */ (0,
|
4165
|
-
/* @__PURE__ */ (0,
|
4166
|
-
/* @__PURE__ */ (0,
|
4167
|
-
/* @__PURE__ */ (0,
|
3319
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, BranchPickerRoot, { hideWhenSingleBranch: true, children: [
|
3320
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerPrevious2, {}),
|
3321
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerState, {}),
|
3322
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BranchPickerNext, {})
|
4168
3323
|
] });
|
4169
3324
|
};
|
4170
3325
|
BranchPicker.displayName = "BranchPicker";
|
@@ -4172,48 +3327,48 @@ var BranchPickerRoot = withDefaults(branchPicker_exports.Root, {
|
|
4172
3327
|
className: "aui-branch-picker-root"
|
4173
3328
|
});
|
4174
3329
|
BranchPickerRoot.displayName = "BranchPickerRoot";
|
4175
|
-
var BranchPickerPrevious2 = (0,
|
3330
|
+
var BranchPickerPrevious2 = _react.forwardRef.call(void 0, (props, ref) => {
|
4176
3331
|
const {
|
4177
3332
|
strings: {
|
4178
3333
|
branchPicker: { previous: { tooltip = "Previous" } = {} } = {}
|
4179
3334
|
} = {}
|
4180
3335
|
} = useThreadConfig();
|
4181
|
-
return /* @__PURE__ */ (0,
|
3336
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Previous, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ChevronLeftIcon, {}))) }) });
|
4182
3337
|
});
|
4183
3338
|
BranchPickerPrevious2.displayName = "BranchPickerPrevious";
|
4184
3339
|
var BranchPickerStateWrapper = withDefaults("span", {
|
4185
3340
|
className: "aui-branch-picker-state"
|
4186
3341
|
});
|
4187
|
-
var BranchPickerState = (0,
|
4188
|
-
return /* @__PURE__ */ (0,
|
4189
|
-
/* @__PURE__ */ (0,
|
3342
|
+
var BranchPickerState = _react.forwardRef.call(void 0, (props, ref) => {
|
3343
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, BranchPickerStateWrapper, { ...props, ref, children: [
|
3344
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Number, {}),
|
4190
3345
|
" / ",
|
4191
|
-
/* @__PURE__ */ (0,
|
3346
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Count, {})
|
4192
3347
|
] });
|
4193
3348
|
});
|
4194
3349
|
BranchPickerState.displayName = "BranchPickerState";
|
4195
|
-
var BranchPickerNext = (0,
|
3350
|
+
var BranchPickerNext = _react.forwardRef.call(void 0, (props, ref) => {
|
4196
3351
|
const {
|
4197
3352
|
strings: { branchPicker: { next: { tooltip = "Next" } = {} } = {} } = {}
|
4198
3353
|
} = useThreadConfig();
|
4199
|
-
return /* @__PURE__ */ (0,
|
3354
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, branchPicker_exports.Next, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ChevronRightIcon, {}))) }) });
|
4200
3355
|
});
|
4201
3356
|
BranchPickerNext.displayName = "BranchPickerNext";
|
4202
|
-
var
|
3357
|
+
var exports2 = {
|
4203
3358
|
Root: BranchPickerRoot,
|
4204
3359
|
Previous: BranchPickerPrevious2,
|
4205
3360
|
Next: BranchPickerNext
|
4206
3361
|
};
|
4207
|
-
var branch_picker_default = Object.assign(BranchPicker,
|
3362
|
+
var branch_picker_default = Object.assign(BranchPicker, exports2);
|
4208
3363
|
|
4209
3364
|
// src/ui/base/avatar.tsx
|
4210
|
-
var
|
4211
|
-
|
3365
|
+
var _reactavatar = require('@radix-ui/react-avatar'); var AvatarPrimitive = _interopRequireWildcard(_reactavatar);
|
3366
|
+
|
4212
3367
|
var Avatar = ({ src, alt, fallback }) => {
|
4213
3368
|
if (src == null && fallback == null) return null;
|
4214
|
-
return /* @__PURE__ */ (0,
|
4215
|
-
src != null && /* @__PURE__ */ (0,
|
4216
|
-
fallback != null && /* @__PURE__ */ (0,
|
3369
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AvatarRoot, { children: [
|
3370
|
+
src != null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AvatarImage, { src, alt }),
|
3371
|
+
fallback != null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AvatarFallback, { children: fallback })
|
4217
3372
|
] });
|
4218
3373
|
};
|
4219
3374
|
Avatar.displayName = "Avatar";
|
@@ -4231,14 +3386,14 @@ var AvatarFallback = withDefaults(AvatarPrimitive.Fallback, {
|
|
4231
3386
|
AvatarFallback.displayName = "AvatarFallback";
|
4232
3387
|
|
4233
3388
|
// src/ui/content-part.tsx
|
4234
|
-
|
4235
|
-
|
3389
|
+
|
3390
|
+
|
4236
3391
|
var Text = () => {
|
4237
3392
|
const status = useSmoothStatus();
|
4238
|
-
return /* @__PURE__ */ (0,
|
3393
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4239
3394
|
contentPart_exports.Text,
|
4240
3395
|
{
|
4241
|
-
className: (0,
|
3396
|
+
className: _classnames2.default.call(void 0,
|
4242
3397
|
"aui-text",
|
4243
3398
|
status.type === "running" && "aui-text-running"
|
4244
3399
|
),
|
@@ -4246,23 +3401,23 @@ var Text = () => {
|
|
4246
3401
|
}
|
4247
3402
|
);
|
4248
3403
|
};
|
4249
|
-
var
|
4250
|
-
var content_part_default =
|
3404
|
+
var exports3 = { Text: withSmoothContextProvider(Text) };
|
3405
|
+
var content_part_default = exports3;
|
4251
3406
|
|
4252
3407
|
// src/ui/assistant-message.tsx
|
4253
|
-
|
3408
|
+
|
4254
3409
|
var AssistantMessage = () => {
|
4255
|
-
return /* @__PURE__ */ (0,
|
4256
|
-
/* @__PURE__ */ (0,
|
4257
|
-
/* @__PURE__ */ (0,
|
4258
|
-
/* @__PURE__ */ (0,
|
4259
|
-
/* @__PURE__ */ (0,
|
3410
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AssistantMessageRoot, { children: [
|
3411
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessageAvatar, {}),
|
3412
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessageContent, {}),
|
3413
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, branch_picker_default, {}),
|
3414
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, assistant_action_bar_default, {})
|
4260
3415
|
] });
|
4261
3416
|
};
|
4262
3417
|
AssistantMessage.displayName = "AssistantMessage";
|
4263
3418
|
var AssistantMessageAvatar = () => {
|
4264
3419
|
const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
|
4265
|
-
return /* @__PURE__ */ (0,
|
3420
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Avatar, { ...avatar });
|
4266
3421
|
};
|
4267
3422
|
var AssistantMessageRoot = withDefaults(message_exports.Root, {
|
4268
3423
|
className: "aui-assistant-message-root"
|
@@ -4271,62 +3426,62 @@ AssistantMessageRoot.displayName = "AssistantMessageRoot";
|
|
4271
3426
|
var AssistantMessageContentWrapper = withDefaults("div", {
|
4272
3427
|
className: "aui-assistant-message-content"
|
4273
3428
|
});
|
4274
|
-
var AssistantMessageContent = (0,
|
3429
|
+
var AssistantMessageContent = _react.forwardRef.call(void 0, ({ components: componentsProp, ...rest }, ref) => {
|
4275
3430
|
const { assistantMessage: { components = {} } = {} } = useThreadConfig();
|
4276
|
-
return /* @__PURE__ */ (0,
|
3431
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantMessageContentWrapper, { ...rest, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4277
3432
|
message_exports.Content,
|
4278
3433
|
{
|
4279
3434
|
components: {
|
4280
3435
|
...componentsProp,
|
4281
|
-
Text: componentsProp
|
3436
|
+
Text: _nullishCoalesce(_nullishCoalesce(_optionalChain([componentsProp, 'optionalAccess', _135 => _135.Text]), () => ( components.Text)), () => ( content_part_default.Text))
|
4282
3437
|
}
|
4283
3438
|
}
|
4284
3439
|
) });
|
4285
3440
|
});
|
4286
3441
|
AssistantMessageContent.displayName = "AssistantMessageContent";
|
4287
|
-
var
|
3442
|
+
var exports4 = {
|
4288
3443
|
Root: AssistantMessageRoot,
|
4289
3444
|
Avatar: AssistantMessageAvatar,
|
4290
3445
|
Content: AssistantMessageContent
|
4291
3446
|
};
|
4292
3447
|
var assistant_message_default = Object.assign(
|
4293
3448
|
AssistantMessage,
|
4294
|
-
|
3449
|
+
exports4
|
4295
3450
|
);
|
4296
3451
|
|
4297
3452
|
// src/ui/assistant-modal.tsx
|
4298
|
-
|
4299
|
-
|
3453
|
+
|
3454
|
+
|
4300
3455
|
|
4301
3456
|
// src/ui/thread.tsx
|
4302
|
-
|
4303
|
-
|
3457
|
+
|
3458
|
+
|
4304
3459
|
|
4305
3460
|
// src/ui/composer.tsx
|
4306
|
-
|
4307
|
-
|
3461
|
+
|
3462
|
+
|
4308
3463
|
|
4309
3464
|
// src/ui/base/CircleStopIcon.tsx
|
4310
|
-
|
3465
|
+
|
4311
3466
|
var CircleStopIcon = () => {
|
4312
|
-
return /* @__PURE__ */ (0,
|
3467
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4313
3468
|
"svg",
|
4314
3469
|
{
|
4315
3470
|
xmlns: "http://www.w3.org/2000/svg",
|
4316
3471
|
viewBox: "0 0 16 16",
|
4317
3472
|
fill: "currentColor",
|
4318
|
-
children: /* @__PURE__ */ (0,
|
3473
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "rect", { width: "10", height: "10", x: "3", y: "3", rx: "2" })
|
4319
3474
|
}
|
4320
3475
|
);
|
4321
3476
|
};
|
4322
3477
|
CircleStopIcon.displayName = "CircleStopIcon";
|
4323
3478
|
|
4324
3479
|
// src/ui/composer.tsx
|
4325
|
-
|
3480
|
+
|
4326
3481
|
var Composer = () => {
|
4327
|
-
return /* @__PURE__ */ (0,
|
4328
|
-
/* @__PURE__ */ (0,
|
4329
|
-
/* @__PURE__ */ (0,
|
3482
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ComposerRoot, { children: [
|
3483
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerInput, { autoFocus: true }),
|
3484
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerAction, {})
|
4330
3485
|
] });
|
4331
3486
|
};
|
4332
3487
|
Composer.displayName = "Composer";
|
@@ -4339,14 +3494,14 @@ var ComposerInputStyled = withDefaults(composer_exports.Input, {
|
|
4339
3494
|
autoFocus: true,
|
4340
3495
|
className: "aui-composer-input"
|
4341
3496
|
});
|
4342
|
-
var ComposerInput = (0,
|
3497
|
+
var ComposerInput = _react.forwardRef.call(void 0,
|
4343
3498
|
(props, ref) => {
|
4344
3499
|
const {
|
4345
3500
|
strings: {
|
4346
3501
|
composer: { input: { placeholder = "Write a message..." } = {} } = {}
|
4347
3502
|
} = {}
|
4348
3503
|
} = useThreadConfig();
|
4349
|
-
return /* @__PURE__ */ (0,
|
3504
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerInputStyled, { placeholder, ...props, ref });
|
4350
3505
|
}
|
4351
3506
|
);
|
4352
3507
|
ComposerInput.displayName = "ComposerInput";
|
@@ -4357,10 +3512,10 @@ var useAllowCancel = () => {
|
|
4357
3512
|
};
|
4358
3513
|
var ComposerAction = () => {
|
4359
3514
|
const allowCancel = useAllowCancel();
|
4360
|
-
if (!allowCancel) return /* @__PURE__ */ (0,
|
4361
|
-
return /* @__PURE__ */ (0,
|
4362
|
-
/* @__PURE__ */ (0,
|
4363
|
-
/* @__PURE__ */ (0,
|
3515
|
+
if (!allowCancel) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerSend, {});
|
3516
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
3517
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { running: false, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerSend, {}) }),
|
3518
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.If, { running: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerCancel, {}) })
|
4364
3519
|
] });
|
4365
3520
|
};
|
4366
3521
|
ComposerAction.displayName = "ComposerAction";
|
@@ -4368,43 +3523,43 @@ var ComposerSendButton = withDefaults(TooltipIconButton, {
|
|
4368
3523
|
variant: "default",
|
4369
3524
|
className: "aui-composer-send"
|
4370
3525
|
});
|
4371
|
-
var ComposerSend = (0,
|
3526
|
+
var ComposerSend = _react.forwardRef.call(void 0, (props, ref) => {
|
4372
3527
|
const {
|
4373
3528
|
strings: { composer: { send: { tooltip = "Send" } = {} } = {} } = {}
|
4374
3529
|
} = useThreadConfig();
|
4375
|
-
return /* @__PURE__ */ (0,
|
3530
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Send, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerSendButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.SendHorizontalIcon, {}))) }) });
|
4376
3531
|
});
|
4377
3532
|
ComposerSend.displayName = "ComposerSend";
|
4378
3533
|
var ComposerCancelButton = withDefaults(TooltipIconButton, {
|
4379
3534
|
variant: "default",
|
4380
3535
|
className: "aui-composer-cancel"
|
4381
3536
|
});
|
4382
|
-
var ComposerCancel = (0,
|
3537
|
+
var ComposerCancel = _react.forwardRef.call(void 0, (props, ref) => {
|
4383
3538
|
const {
|
4384
3539
|
strings: { composer: { cancel: { tooltip = "Cancel" } = {} } = {} } = {}
|
4385
3540
|
} = useThreadConfig();
|
4386
|
-
return /* @__PURE__ */ (0,
|
3541
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ComposerCancelButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CircleStopIcon, {}))) }) });
|
4387
3542
|
});
|
4388
3543
|
ComposerCancel.displayName = "ComposerCancel";
|
4389
|
-
var
|
3544
|
+
var exports5 = {
|
4390
3545
|
Root: ComposerRoot,
|
4391
3546
|
Input: ComposerInput,
|
4392
3547
|
Action: ComposerAction,
|
4393
3548
|
Send: ComposerSend,
|
4394
3549
|
Cancel: ComposerCancel
|
4395
3550
|
};
|
4396
|
-
var composer_default = Object.assign(Composer,
|
3551
|
+
var composer_default = Object.assign(Composer, exports5);
|
4397
3552
|
|
4398
3553
|
// src/ui/thread-welcome.tsx
|
4399
|
-
|
4400
|
-
|
3554
|
+
|
3555
|
+
|
4401
3556
|
var ThreadWelcome = () => {
|
4402
|
-
return /* @__PURE__ */ (0,
|
4403
|
-
/* @__PURE__ */ (0,
|
4404
|
-
/* @__PURE__ */ (0,
|
4405
|
-
/* @__PURE__ */ (0,
|
3557
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadWelcomeRoot, { children: [
|
3558
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadWelcomeCenter, { children: [
|
3559
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeAvatar, {}),
|
3560
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeMessage, {})
|
4406
3561
|
] }),
|
4407
|
-
/* @__PURE__ */ (0,
|
3562
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestions, {})
|
4408
3563
|
] });
|
4409
3564
|
};
|
4410
3565
|
ThreadWelcome.displayName = "ThreadWelcome";
|
@@ -4414,22 +3569,22 @@ var ThreadWelcomeRootStyled = withDefaults("div", {
|
|
4414
3569
|
var ThreadWelcomeCenter = withDefaults("div", {
|
4415
3570
|
className: "aui-thread-welcome-center"
|
4416
3571
|
});
|
4417
|
-
var ThreadWelcomeRoot = (0,
|
3572
|
+
var ThreadWelcomeRoot = _react.forwardRef.call(void 0,
|
4418
3573
|
(props, ref) => {
|
4419
|
-
return /* @__PURE__ */ (0,
|
3574
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.Empty, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeRootStyled, { ...props, ref }) });
|
4420
3575
|
}
|
4421
3576
|
);
|
4422
3577
|
ThreadWelcomeRoot.displayName = "ThreadWelcomeRoot";
|
4423
3578
|
var ThreadWelcomeAvatar = () => {
|
4424
3579
|
const { assistantAvatar: avatar = { fallback: "A" } } = useThreadConfig();
|
4425
|
-
return /* @__PURE__ */ (0,
|
3580
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Avatar, { ...avatar });
|
4426
3581
|
};
|
4427
3582
|
var ThreadWelcomeMessageStyled = withDefaults("p", {
|
4428
3583
|
className: "aui-thread-welcome-message"
|
4429
3584
|
});
|
4430
|
-
var ThreadWelcomeMessage = (0,
|
3585
|
+
var ThreadWelcomeMessage = _react.forwardRef.call(void 0, ({ message: messageProp, ...rest }, ref) => {
|
4431
3586
|
const { welcome: { message = "How can I help you today?" } = {} } = useThreadConfig();
|
4432
|
-
return /* @__PURE__ */ (0,
|
3587
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeMessageStyled, { ...rest, ref, children: _nullishCoalesce(messageProp, () => ( message)) });
|
4433
3588
|
});
|
4434
3589
|
ThreadWelcomeMessage.displayName = "ThreadWelcomeMessage";
|
4435
3590
|
var ThreadWelcomeSuggestionContainer = withDefaults("div", {
|
@@ -4441,25 +3596,25 @@ var ThreadWelcomeSuggestionStyled = withDefaults(thread_exports.Suggestion, {
|
|
4441
3596
|
var ThreadWelcomeSuggestion = ({
|
4442
3597
|
suggestion: { text, prompt }
|
4443
3598
|
}) => {
|
4444
|
-
return /* @__PURE__ */ (0,
|
3599
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4445
3600
|
ThreadWelcomeSuggestionStyled,
|
4446
3601
|
{
|
4447
3602
|
prompt,
|
4448
3603
|
method: "replace",
|
4449
3604
|
autoSend: true,
|
4450
|
-
children: /* @__PURE__ */ (0,
|
3605
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "aui-thread-welcome-suggestion-text", children: _nullishCoalesce(text, () => ( prompt)) })
|
4451
3606
|
}
|
4452
3607
|
);
|
4453
3608
|
};
|
4454
3609
|
var ThreadWelcomeSuggestions = () => {
|
4455
3610
|
const { welcome: { suggestions } = {} } = useThreadConfig();
|
4456
|
-
return /* @__PURE__ */ (0,
|
3611
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestionContainer, { children: _optionalChain([suggestions, 'optionalAccess', _136 => _136.map, 'call', _137 => _137((suggestion, idx) => {
|
4457
3612
|
const key = `${suggestion.prompt}-${idx}`;
|
4458
|
-
return /* @__PURE__ */ (0,
|
4459
|
-
}) });
|
3613
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadWelcomeSuggestion, { suggestion }, key);
|
3614
|
+
})]) });
|
4460
3615
|
};
|
4461
3616
|
ThreadWelcomeSuggestions.displayName = "ThreadWelcomeSuggestions";
|
4462
|
-
var
|
3617
|
+
var exports6 = {
|
4463
3618
|
Root: ThreadWelcomeRoot,
|
4464
3619
|
Center: ThreadWelcomeCenter,
|
4465
3620
|
Avatar: ThreadWelcomeAvatar,
|
@@ -4467,15 +3622,15 @@ var exports7 = {
|
|
4467
3622
|
Suggestions: ThreadWelcomeSuggestions,
|
4468
3623
|
Suggestion: ThreadWelcomeSuggestion
|
4469
3624
|
};
|
4470
|
-
var thread_welcome_default = Object.assign(ThreadWelcome,
|
3625
|
+
var thread_welcome_default = Object.assign(ThreadWelcome, exports6);
|
4471
3626
|
|
4472
3627
|
// src/ui/user-message.tsx
|
4473
|
-
|
3628
|
+
|
4474
3629
|
|
4475
3630
|
// src/ui/user-action-bar.tsx
|
4476
|
-
|
4477
|
-
|
4478
|
-
|
3631
|
+
|
3632
|
+
|
3633
|
+
|
4479
3634
|
var useAllowEdit = () => {
|
4480
3635
|
const { userMessage: { allowEdit = true } = {} } = useThreadConfig();
|
4481
3636
|
const { useThreadActions } = useThreadContext();
|
@@ -4485,35 +3640,35 @@ var useAllowEdit = () => {
|
|
4485
3640
|
var UserActionBar = () => {
|
4486
3641
|
const allowEdit = useAllowEdit();
|
4487
3642
|
if (!allowEdit) return null;
|
4488
|
-
return /* @__PURE__ */ (0,
|
3643
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserActionBarRoot, { hideWhenRunning: true, autohide: "not-last", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserActionBarEdit, {}) });
|
4489
3644
|
};
|
4490
3645
|
UserActionBar.displayName = "UserActionBar";
|
4491
3646
|
var UserActionBarRoot = withDefaults(actionBar_exports.Root, {
|
4492
3647
|
className: "aui-user-action-bar-root"
|
4493
3648
|
});
|
4494
3649
|
UserActionBarRoot.displayName = "UserActionBarRoot";
|
4495
|
-
var UserActionBarEdit = (0,
|
3650
|
+
var UserActionBarEdit = _react.forwardRef.call(void 0, (props, ref) => {
|
4496
3651
|
const {
|
4497
3652
|
strings: { userMessage: { edit: { tooltip = "Edit" } = {} } = {} } = {}
|
4498
3653
|
} = useThreadConfig();
|
4499
3654
|
const allowEdit = useAllowEdit();
|
4500
3655
|
if (!allowEdit) return null;
|
4501
|
-
return /* @__PURE__ */ (0,
|
3656
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, actionBar_exports.Edit, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TooltipIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.PencilIcon, {}))) }) });
|
4502
3657
|
});
|
4503
3658
|
UserActionBarEdit.displayName = "UserActionBarEdit";
|
4504
|
-
var
|
3659
|
+
var exports7 = {
|
4505
3660
|
Root: UserActionBarRoot,
|
4506
3661
|
Edit: UserActionBarEdit
|
4507
3662
|
};
|
4508
|
-
var user_action_bar_default = Object.assign(UserActionBar,
|
3663
|
+
var user_action_bar_default = Object.assign(UserActionBar, exports7);
|
4509
3664
|
|
4510
3665
|
// src/ui/user-message.tsx
|
4511
|
-
|
3666
|
+
|
4512
3667
|
var UserMessage = () => {
|
4513
|
-
return /* @__PURE__ */ (0,
|
4514
|
-
/* @__PURE__ */ (0,
|
4515
|
-
/* @__PURE__ */ (0,
|
4516
|
-
/* @__PURE__ */ (0,
|
3668
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, UserMessageRoot, { children: [
|
3669
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, user_action_bar_default, {}),
|
3670
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContent, {}),
|
3671
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, branch_picker_default, {})
|
4517
3672
|
] });
|
4518
3673
|
};
|
4519
3674
|
UserMessage.displayName = "UserMessage";
|
@@ -4524,35 +3679,35 @@ UserMessageRoot.displayName = "UserMessageRoot";
|
|
4524
3679
|
var UserMessageContentWrapper = withDefaults("div", {
|
4525
3680
|
className: "aui-user-message-content"
|
4526
3681
|
});
|
4527
|
-
var UserMessageContent = (0,
|
3682
|
+
var UserMessageContent = _react.forwardRef.call(void 0,
|
4528
3683
|
({ components, ...props }, ref) => {
|
4529
|
-
return /* @__PURE__ */ (0,
|
3684
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, UserMessageContentWrapper, { ...props, ref, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4530
3685
|
message_exports.Content,
|
4531
3686
|
{
|
4532
3687
|
components: {
|
4533
3688
|
...components,
|
4534
|
-
Text: components
|
3689
|
+
Text: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _138 => _138.Text]), () => ( content_part_default.Text))
|
4535
3690
|
}
|
4536
3691
|
}
|
4537
3692
|
) });
|
4538
3693
|
}
|
4539
3694
|
);
|
4540
3695
|
UserMessageContent.displayName = "UserMessageContent";
|
4541
|
-
var
|
3696
|
+
var exports8 = {
|
4542
3697
|
Root: UserMessageRoot,
|
4543
3698
|
Content: UserMessageContent
|
4544
3699
|
};
|
4545
|
-
var user_message_default = Object.assign(UserMessage,
|
3700
|
+
var user_message_default = Object.assign(UserMessage, exports8);
|
4546
3701
|
|
4547
3702
|
// src/ui/edit-composer.tsx
|
4548
|
-
|
4549
|
-
|
3703
|
+
|
3704
|
+
|
4550
3705
|
var EditComposer = () => {
|
4551
|
-
return /* @__PURE__ */ (0,
|
4552
|
-
/* @__PURE__ */ (0,
|
4553
|
-
/* @__PURE__ */ (0,
|
4554
|
-
/* @__PURE__ */ (0,
|
4555
|
-
/* @__PURE__ */ (0,
|
3706
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, EditComposerRoot, { children: [
|
3707
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposerInput, {}),
|
3708
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, EditComposerFooter, { children: [
|
3709
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposerCancel, {}),
|
3710
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, EditComposerSend, {})
|
4556
3711
|
] })
|
4557
3712
|
] });
|
4558
3713
|
};
|
@@ -4569,53 +3724,53 @@ var EditComposerFooter = withDefaults("div", {
|
|
4569
3724
|
className: "aui-edit-composer-footer"
|
4570
3725
|
});
|
4571
3726
|
EditComposerFooter.displayName = "EditComposerFooter";
|
4572
|
-
var EditComposerCancel = (0,
|
3727
|
+
var EditComposerCancel = _react.forwardRef.call(void 0,
|
4573
3728
|
(props, ref) => {
|
4574
3729
|
const {
|
4575
3730
|
strings: {
|
4576
3731
|
editComposer: { cancel: { label = "Cancel" } = {} } = {}
|
4577
3732
|
} = {}
|
4578
3733
|
} = useThreadConfig();
|
4579
|
-
return /* @__PURE__ */ (0,
|
3734
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Cancel, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { variant: "ghost", ...props, ref, children: _nullishCoalesce(props.children, () => ( label)) }) });
|
4580
3735
|
}
|
4581
3736
|
);
|
4582
3737
|
EditComposerCancel.displayName = "EditComposerCancel";
|
4583
|
-
var EditComposerSend = (0,
|
3738
|
+
var EditComposerSend = _react.forwardRef.call(void 0,
|
4584
3739
|
(props, ref) => {
|
4585
3740
|
const {
|
4586
3741
|
strings: { editComposer: { send: { label = "Send" } = {} } = {} } = {}
|
4587
3742
|
} = useThreadConfig();
|
4588
|
-
return /* @__PURE__ */ (0,
|
3743
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_exports.Send, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Button, { ...props, ref, children: _nullishCoalesce(props.children, () => ( label)) }) });
|
4589
3744
|
}
|
4590
3745
|
);
|
4591
3746
|
EditComposerSend.displayName = "EditComposerSend";
|
4592
|
-
var
|
3747
|
+
var exports9 = {
|
4593
3748
|
Root: EditComposerRoot,
|
4594
3749
|
Input: EditComposerInput,
|
4595
3750
|
Footer: EditComposerFooter,
|
4596
3751
|
Cancel: EditComposerCancel,
|
4597
3752
|
Send: EditComposerSend
|
4598
3753
|
};
|
4599
|
-
var edit_composer_default = Object.assign(EditComposer,
|
3754
|
+
var edit_composer_default = Object.assign(EditComposer, exports9);
|
4600
3755
|
|
4601
3756
|
// src/ui/thread.tsx
|
4602
|
-
|
3757
|
+
|
4603
3758
|
var Thread = (config) => {
|
4604
|
-
return /* @__PURE__ */ (0,
|
4605
|
-
/* @__PURE__ */ (0,
|
4606
|
-
/* @__PURE__ */ (0,
|
4607
|
-
/* @__PURE__ */ (0,
|
4608
|
-
/* @__PURE__ */ (0,
|
4609
|
-
/* @__PURE__ */ (0,
|
3759
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRoot, { config, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewport, { children: [
|
3760
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_welcome_default, {}),
|
3761
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadMessages, {}),
|
3762
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, ThreadViewportFooter, { children: [
|
3763
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadScrollToBottom, {}),
|
3764
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, composer_default, {})
|
4610
3765
|
] })
|
4611
3766
|
] }) });
|
4612
3767
|
};
|
4613
3768
|
var ThreadRootStyled = withDefaults(thread_exports.Root, {
|
4614
3769
|
className: "aui-root aui-thread-root"
|
4615
3770
|
});
|
4616
|
-
var ThreadRoot = (0,
|
3771
|
+
var ThreadRoot = _react.forwardRef.call(void 0,
|
4617
3772
|
({ config, ...props }, ref) => {
|
4618
|
-
return /* @__PURE__ */ (0,
|
3773
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigProvider, { config, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadRootStyled, { ...props, ref }) });
|
4619
3774
|
}
|
4620
3775
|
);
|
4621
3776
|
ThreadRoot.displayName = "ThreadRoot";
|
@@ -4629,14 +3784,14 @@ var ThreadViewportFooter = withDefaults("div", {
|
|
4629
3784
|
ThreadViewportFooter.displayName = "ThreadViewportFooter";
|
4630
3785
|
var SystemMessage = () => null;
|
4631
3786
|
var ThreadMessages = ({ components, ...rest }) => {
|
4632
|
-
return /* @__PURE__ */ (0,
|
3787
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4633
3788
|
thread_exports.Messages,
|
4634
3789
|
{
|
4635
3790
|
components: {
|
4636
|
-
UserMessage: components
|
4637
|
-
EditComposer: components
|
4638
|
-
AssistantMessage: components
|
4639
|
-
SystemMessage: components
|
3791
|
+
UserMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _139 => _139.UserMessage]), () => ( user_message_default)),
|
3792
|
+
EditComposer: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _140 => _140.EditComposer]), () => ( edit_composer_default)),
|
3793
|
+
AssistantMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _141 => _141.AssistantMessage]), () => ( assistant_message_default)),
|
3794
|
+
SystemMessage: _nullishCoalesce(_optionalChain([components, 'optionalAccess', _142 => _142.SystemMessage]), () => ( SystemMessage))
|
4640
3795
|
},
|
4641
3796
|
...rest
|
4642
3797
|
}
|
@@ -4647,39 +3802,39 @@ var ThreadScrollToBottomIconButton = withDefaults(TooltipIconButton, {
|
|
4647
3802
|
variant: "outline",
|
4648
3803
|
className: "aui-thread-scroll-to-bottom"
|
4649
3804
|
});
|
4650
|
-
var ThreadScrollToBottom = (0,
|
3805
|
+
var ThreadScrollToBottom = _react.forwardRef.call(void 0, (props, ref) => {
|
4651
3806
|
const {
|
4652
3807
|
strings: {
|
4653
3808
|
thread: { scrollToBottom: { tooltip = "Scroll to bottom" } = {} } = {}
|
4654
3809
|
} = {}
|
4655
3810
|
} = useThreadConfig();
|
4656
|
-
return /* @__PURE__ */ (0,
|
3811
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_exports.ScrollToBottom, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadScrollToBottomIconButton, { tooltip, ...props, ref, children: _nullishCoalesce(props.children, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _lucidereact.ArrowDownIcon, {}))) }) });
|
4657
3812
|
});
|
4658
3813
|
ThreadScrollToBottom.displayName = "ThreadScrollToBottom";
|
4659
|
-
var
|
3814
|
+
var exports10 = {
|
4660
3815
|
Root: ThreadRoot,
|
4661
3816
|
Viewport: ThreadViewport,
|
4662
3817
|
Messages: ThreadMessages,
|
4663
3818
|
ScrollToBottom: ThreadScrollToBottom,
|
4664
3819
|
ViewportFooter: ThreadViewportFooter
|
4665
3820
|
};
|
4666
|
-
var thread_default = Object.assign(Thread,
|
3821
|
+
var thread_default = Object.assign(Thread, exports10);
|
4667
3822
|
|
4668
3823
|
// src/ui/assistant-modal.tsx
|
4669
|
-
|
3824
|
+
|
4670
3825
|
var AssistantModal = (config) => {
|
4671
|
-
return /* @__PURE__ */ (0,
|
4672
|
-
/* @__PURE__ */ (0,
|
4673
|
-
/* @__PURE__ */ (0,
|
3826
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, AssistantModalRoot, { config, children: [
|
3827
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantModalTrigger, {}),
|
3828
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantModalContent, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, thread_default, {}) })
|
4674
3829
|
] });
|
4675
3830
|
};
|
4676
3831
|
AssistantModal.displayName = "AssistantModal";
|
4677
3832
|
var AssistantModalRoot = ({ config, ...props }) => {
|
4678
|
-
return /* @__PURE__ */ (0,
|
3833
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ThreadConfigProvider, { config, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, assistantModal_exports.Root, { ...props }) });
|
4679
3834
|
};
|
4680
3835
|
AssistantModalRoot.displayName = "AssistantModalRoot";
|
4681
|
-
var AssistantModalTrigger = (0,
|
4682
|
-
return /* @__PURE__ */ (0,
|
3836
|
+
var AssistantModalTrigger = _react.forwardRef.call(void 0, (props, ref) => {
|
3837
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantModalAnchor, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, assistantModal_exports.Trigger, { asChild: true, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssistantModalButton, { ...props, ref }) }) });
|
4683
3838
|
});
|
4684
3839
|
AssistantModalTrigger.displayName = "AssistantModalTrigger";
|
4685
3840
|
var AssistantModalAnchor = withDefaults(assistantModal_exports.Anchor, {
|
@@ -4690,7 +3845,7 @@ var ModalButtonStyled = withDefaults(TooltipIconButton, {
|
|
4690
3845
|
variant: "default",
|
4691
3846
|
className: "aui-modal-button"
|
4692
3847
|
});
|
4693
|
-
var AssistantModalButton = (0,
|
3848
|
+
var AssistantModalButton = _react.forwardRef.call(void 0, ({ "data-state": state, ...rest }, ref) => {
|
4694
3849
|
const {
|
4695
3850
|
strings: {
|
4696
3851
|
assistantModal: {
|
@@ -4704,7 +3859,7 @@ var AssistantModalButton = (0, import_react68.forwardRef)(({ "data-state": state
|
|
4704
3859
|
} = {}
|
4705
3860
|
} = useThreadConfig();
|
4706
3861
|
const tooltip = state === "open" ? openTooltip : closedTooltip;
|
4707
|
-
return /* @__PURE__ */ (0,
|
3862
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
4708
3863
|
ModalButtonStyled,
|
4709
3864
|
{
|
4710
3865
|
side: "left",
|
@@ -4712,22 +3867,22 @@ var AssistantModalButton = (0, import_react68.forwardRef)(({ "data-state": state
|
|
4712
3867
|
"data-state": state,
|
4713
3868
|
...rest,
|
4714
3869
|
ref,
|
4715
|
-
children: rest.children
|
4716
|
-
/* @__PURE__ */ (0,
|
4717
|
-
|
3870
|
+
children: _nullishCoalesce(rest.children, () => ( /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
3871
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
3872
|
+
_lucidereact.BotIcon,
|
4718
3873
|
{
|
4719
3874
|
"data-state": state,
|
4720
3875
|
className: "aui-modal-button-closed-icon"
|
4721
3876
|
}
|
4722
3877
|
),
|
4723
|
-
/* @__PURE__ */ (0,
|
4724
|
-
|
3878
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
3879
|
+
_lucidereact.ChevronDownIcon,
|
4725
3880
|
{
|
4726
3881
|
"data-state": state,
|
4727
3882
|
className: "aui-modal-button-open-icon"
|
4728
3883
|
}
|
4729
3884
|
)
|
4730
|
-
] })
|
3885
|
+
] })))
|
4731
3886
|
}
|
4732
3887
|
);
|
4733
3888
|
});
|
@@ -4737,79 +3892,78 @@ var AssistantModalContent = withDefaults(assistantModal_exports.Content, {
|
|
4737
3892
|
sideOffset: 16
|
4738
3893
|
});
|
4739
3894
|
AssistantModalContent.displayName = "AssistantModalContent";
|
4740
|
-
var
|
3895
|
+
var exports11 = {
|
4741
3896
|
Root: AssistantModalRoot,
|
4742
3897
|
Trigger: AssistantModalTrigger,
|
4743
3898
|
Content: AssistantModalContent
|
4744
3899
|
};
|
4745
|
-
var assistant_modal_default = Object.assign(AssistantModal,
|
4746
|
-
|
4747
|
-
|
4748
|
-
|
4749
|
-
|
4750
|
-
|
4751
|
-
|
4752
|
-
|
4753
|
-
|
4754
|
-
|
4755
|
-
|
4756
|
-
|
4757
|
-
|
4758
|
-
|
4759
|
-
|
4760
|
-
|
4761
|
-
|
4762
|
-
|
4763
|
-
|
4764
|
-
|
4765
|
-
|
4766
|
-
|
4767
|
-
|
4768
|
-
|
4769
|
-
|
4770
|
-
|
4771
|
-
|
4772
|
-
|
4773
|
-
|
4774
|
-
|
4775
|
-
|
4776
|
-
|
4777
|
-
|
4778
|
-
|
4779
|
-
|
4780
|
-
|
4781
|
-
|
4782
|
-
|
4783
|
-
|
4784
|
-
|
4785
|
-
|
4786
|
-
|
4787
|
-
|
4788
|
-
|
4789
|
-
|
4790
|
-
|
4791
|
-
|
4792
|
-
|
4793
|
-
|
4794
|
-
|
4795
|
-
|
4796
|
-
|
4797
|
-
|
4798
|
-
|
4799
|
-
|
4800
|
-
|
4801
|
-
|
4802
|
-
|
4803
|
-
|
4804
|
-
|
4805
|
-
|
4806
|
-
|
4807
|
-
|
4808
|
-
|
4809
|
-
|
4810
|
-
|
4811
|
-
|
4812
|
-
|
4813
|
-
|
4814
|
-
});
|
3900
|
+
var assistant_modal_default = Object.assign(AssistantModal, exports11);
|
3901
|
+
|
3902
|
+
|
3903
|
+
|
3904
|
+
|
3905
|
+
|
3906
|
+
|
3907
|
+
|
3908
|
+
|
3909
|
+
|
3910
|
+
|
3911
|
+
|
3912
|
+
|
3913
|
+
|
3914
|
+
|
3915
|
+
|
3916
|
+
|
3917
|
+
|
3918
|
+
|
3919
|
+
|
3920
|
+
|
3921
|
+
|
3922
|
+
|
3923
|
+
|
3924
|
+
|
3925
|
+
|
3926
|
+
|
3927
|
+
|
3928
|
+
|
3929
|
+
|
3930
|
+
|
3931
|
+
|
3932
|
+
|
3933
|
+
|
3934
|
+
|
3935
|
+
|
3936
|
+
|
3937
|
+
|
3938
|
+
|
3939
|
+
|
3940
|
+
|
3941
|
+
|
3942
|
+
|
3943
|
+
|
3944
|
+
|
3945
|
+
|
3946
|
+
|
3947
|
+
|
3948
|
+
|
3949
|
+
|
3950
|
+
|
3951
|
+
|
3952
|
+
|
3953
|
+
|
3954
|
+
|
3955
|
+
|
3956
|
+
|
3957
|
+
|
3958
|
+
|
3959
|
+
|
3960
|
+
|
3961
|
+
|
3962
|
+
|
3963
|
+
|
3964
|
+
|
3965
|
+
|
3966
|
+
|
3967
|
+
|
3968
|
+
exports.ActionBarPrimitive = actionBar_exports; exports.AssistantActionBar = assistant_action_bar_default; exports.AssistantMessage = assistant_message_default; exports.AssistantModal = assistant_modal_default; exports.AssistantModalPrimitive = assistantModal_exports; exports.AssistantRuntimeProvider = AssistantRuntimeProvider; exports.BranchPicker = branch_picker_default; exports.BranchPickerPrimitive = branchPicker_exports; exports.Composer = composer_default; exports.ComposerPrimitive = composer_exports; exports.ContentPart = content_part_default; exports.ContentPartPrimitive = contentPart_exports; exports.EdgeChatAdapter = EdgeChatAdapter; exports.EditComposer = edit_composer_default; exports.ExternalStoreRuntime = ExternalStoreRuntime; exports.INTERNAL = internal_exports; exports.MessagePrimitive = message_exports; exports.Thread = thread_default; exports.ThreadConfigProvider = ThreadConfigProvider; exports.ThreadPrimitive = thread_exports; exports.ThreadWelcome = thread_welcome_default; exports.UserActionBar = user_action_bar_default; exports.UserMessage = user_message_default; exports.fromCoreMessage = fromCoreMessage; exports.fromCoreMessages = fromCoreMessages; exports.fromLanguageModelMessages = fromLanguageModelMessages; exports.fromLanguageModelTools = fromLanguageModelTools; exports.getExternalStoreMessage = getExternalStoreMessage; exports.makeAssistantTool = makeAssistantTool; exports.makeAssistantToolUI = makeAssistantToolUI; exports.toCoreMessage = _chunkNSPHKRLFjs.toCoreMessage; exports.toCoreMessages = _chunkNSPHKRLFjs.toCoreMessages; exports.toLanguageModelMessages = _chunkNSPHKRLFjs.toLanguageModelMessages; exports.toLanguageModelTools = _chunkNSPHKRLFjs.toLanguageModelTools; exports.useActionBarCopy = useActionBarCopy; exports.useActionBarEdit = useActionBarEdit; exports.useActionBarReload = useActionBarReload; exports.useAppendMessage = useAppendMessage; exports.useAssistantContext = useAssistantContext; exports.useAssistantInstructions = useAssistantInstructions; exports.useAssistantTool = useAssistantTool; exports.useAssistantToolUI = useAssistantToolUI; exports.useBranchPickerCount = useBranchPickerCount; exports.useBranchPickerNext = useBranchPickerNext; exports.useBranchPickerNumber = useBranchPickerNumber; exports.useBranchPickerPrevious = useBranchPickerPrevious; exports.useComposerCancel = useComposerCancel; exports.useComposerContext = useComposerContext; exports.useComposerIf = useComposerIf; exports.useComposerSend = useComposerSend; exports.useContentPartContext = useContentPartContext; exports.useContentPartDisplay = useContentPartDisplay; exports.useContentPartImage = useContentPartImage; exports.useContentPartText = useContentPartText; exports.useEdgeRuntime = useEdgeRuntime; exports.useExternalStoreRuntime = useExternalStoreRuntime; exports.useLocalRuntime = useLocalRuntime; exports.useMessageContext = useMessageContext; exports.useMessageIf = useMessageIf; exports.useSwitchToNewThread = useSwitchToNewThread; exports.useThreadConfig = useThreadConfig; exports.useThreadContext = useThreadContext; exports.useThreadEmpty = useThreadEmpty; exports.useThreadIf = useThreadIf; exports.useThreadScrollToBottom = useThreadScrollToBottom; exports.useThreadSuggestion = useThreadSuggestion;
|
4815
3969
|
//# sourceMappingURL=index.js.map
|