@assistant-ui/react 0.5.85 → 0.5.87
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-TWIMAOZR.mjs → chunk-HLFNKW7L.mjs} +2 -2
- package/dist/chunk-HLFNKW7L.mjs.map +1 -0
- package/dist/{chunk-C6UZOY5A.js → chunk-VKXHYCAI.js} +2 -2
- package/dist/{chunk-C6UZOY5A.js.map → chunk-VKXHYCAI.js.map} +1 -1
- package/dist/edge.js +1 -1
- package/dist/edge.js.map +1 -1
- package/dist/edge.mjs +1 -1
- package/dist/edge.mjs.map +1 -1
- package/dist/index.d.mts +20 -2
- package/dist/index.d.ts +20 -2
- package/dist/index.js +85 -85
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -73
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-TWIMAOZR.mjs.map +0 -1
package/dist/index.mjs
CHANGED
@@ -10,7 +10,7 @@ import {
|
|
10
10
|
toLanguageModelMessages,
|
11
11
|
toLanguageModelTools,
|
12
12
|
toolResultStream
|
13
|
-
} from "./chunk-
|
13
|
+
} from "./chunk-HLFNKW7L.mjs";
|
14
14
|
import {
|
15
15
|
__export
|
16
16
|
} from "./chunk-BJPOCE4O.mjs";
|
@@ -437,6 +437,62 @@ function useComposerRuntime(options) {
|
|
437
437
|
return messageRuntime ? messageRuntime.composer : threadRuntime?.composer ?? null;
|
438
438
|
}
|
439
439
|
|
440
|
+
// src/context/react/AttachmentContext.ts
|
441
|
+
import { createContext as createContext5, useContext as useContext2 } from "react";
|
442
|
+
var AttachmentContext = createContext5(
|
443
|
+
null
|
444
|
+
);
|
445
|
+
function useAttachmentContext(options) {
|
446
|
+
const context = useContext2(AttachmentContext);
|
447
|
+
if (!options?.optional && !context)
|
448
|
+
throw new Error(
|
449
|
+
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
450
|
+
);
|
451
|
+
return context;
|
452
|
+
}
|
453
|
+
function useThreadComposerAttachmentContext(options) {
|
454
|
+
const context = useAttachmentContext(options);
|
455
|
+
if (!context) return null;
|
456
|
+
if (context.source !== "thread-composer")
|
457
|
+
throw new Error(
|
458
|
+
"This component must be used within a thread's ComposerPrimitive.Attachments component."
|
459
|
+
);
|
460
|
+
return context;
|
461
|
+
}
|
462
|
+
function useEditComposerAttachmentContext(options) {
|
463
|
+
const context = useAttachmentContext(options);
|
464
|
+
if (!context) return null;
|
465
|
+
if (context.source !== "edit-composer")
|
466
|
+
throw new Error(
|
467
|
+
"This component must be used within a messages's ComposerPrimitive.Attachments component."
|
468
|
+
);
|
469
|
+
return context;
|
470
|
+
}
|
471
|
+
function useMessageAttachmentContext(options) {
|
472
|
+
const context = useAttachmentContext(options);
|
473
|
+
if (!context) return null;
|
474
|
+
if (context.source !== "message")
|
475
|
+
throw new Error(
|
476
|
+
"This component must be used within a MessagePrimitive.Attachments component."
|
477
|
+
);
|
478
|
+
return context;
|
479
|
+
}
|
480
|
+
function useAttachmentRuntime(options) {
|
481
|
+
const attachmentRuntime = useAttachmentContext(options);
|
482
|
+
if (!attachmentRuntime) return null;
|
483
|
+
return attachmentRuntime.useAttachmentRuntime();
|
484
|
+
}
|
485
|
+
var { useAttachment } = createContextStoreHook(
|
486
|
+
useAttachmentContext,
|
487
|
+
"useAttachment"
|
488
|
+
);
|
489
|
+
var { useAttachment: useThreadComposerAttachment } = createContextStoreHook(useThreadComposerAttachmentContext, "useAttachment");
|
490
|
+
var { useAttachment: useEditComposerAttachment } = createContextStoreHook(useEditComposerAttachmentContext, "useAttachment");
|
491
|
+
var { useAttachment: useMessageAttachment } = createContextStoreHook(
|
492
|
+
useMessageAttachmentContext,
|
493
|
+
"useAttachment"
|
494
|
+
);
|
495
|
+
|
440
496
|
// src/hooks/useAppendMessage.tsx
|
441
497
|
import { useCallback } from "react";
|
442
498
|
var useAppendMessage = () => {
|
@@ -1244,64 +1300,6 @@ AttachmentPrimitiveRoot.displayName = "AttachmentPrimitive.Root";
|
|
1244
1300
|
|
1245
1301
|
// src/primitives/attachment/AttachmentThumb.tsx
|
1246
1302
|
import { forwardRef as forwardRef11 } from "react";
|
1247
|
-
|
1248
|
-
// src/context/react/AttachmentContext.ts
|
1249
|
-
import { createContext as createContext5, useContext as useContext2 } from "react";
|
1250
|
-
var AttachmentContext = createContext5(
|
1251
|
-
null
|
1252
|
-
);
|
1253
|
-
function useAttachmentContext(options) {
|
1254
|
-
const context = useContext2(AttachmentContext);
|
1255
|
-
if (!options?.optional && !context)
|
1256
|
-
throw new Error(
|
1257
|
-
"This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component."
|
1258
|
-
);
|
1259
|
-
return context;
|
1260
|
-
}
|
1261
|
-
function useThreadComposerAttachmentContext(options) {
|
1262
|
-
const context = useAttachmentContext(options);
|
1263
|
-
if (!context) return null;
|
1264
|
-
if (context.source !== "thread-composer")
|
1265
|
-
throw new Error(
|
1266
|
-
"This component must be used within a thread's ComposerPrimitive.Attachments component."
|
1267
|
-
);
|
1268
|
-
return context;
|
1269
|
-
}
|
1270
|
-
function useEditComposerAttachmentContext(options) {
|
1271
|
-
const context = useAttachmentContext(options);
|
1272
|
-
if (!context) return null;
|
1273
|
-
if (context.source !== "edit-composer")
|
1274
|
-
throw new Error(
|
1275
|
-
"This component must be used within a messages's ComposerPrimitive.Attachments component."
|
1276
|
-
);
|
1277
|
-
return context;
|
1278
|
-
}
|
1279
|
-
function useMessageAttachmentContext(options) {
|
1280
|
-
const context = useAttachmentContext(options);
|
1281
|
-
if (!context) return null;
|
1282
|
-
if (context.source !== "message")
|
1283
|
-
throw new Error(
|
1284
|
-
"This component must be used within a MessagePrimitive.Attachments component."
|
1285
|
-
);
|
1286
|
-
return context;
|
1287
|
-
}
|
1288
|
-
function useAttachmentRuntime(options) {
|
1289
|
-
const attachmentRuntime = useAttachmentContext(options);
|
1290
|
-
if (!attachmentRuntime) return null;
|
1291
|
-
return attachmentRuntime.useAttachmentRuntime();
|
1292
|
-
}
|
1293
|
-
var { useAttachment } = createContextStoreHook(
|
1294
|
-
useAttachmentContext,
|
1295
|
-
"useAttachment"
|
1296
|
-
);
|
1297
|
-
var { useAttachment: useThreadComposerAttachment } = createContextStoreHook(useThreadComposerAttachmentContext, "useAttachment");
|
1298
|
-
var { useAttachment: useEditComposerAttachment } = createContextStoreHook(useEditComposerAttachmentContext, "useAttachment");
|
1299
|
-
var { useAttachment: useMessageAttachment } = createContextStoreHook(
|
1300
|
-
useMessageAttachmentContext,
|
1301
|
-
"useAttachment"
|
1302
|
-
);
|
1303
|
-
|
1304
|
-
// src/primitives/attachment/AttachmentThumb.tsx
|
1305
1303
|
import { Primitive as Primitive8 } from "@radix-ui/react-primitive";
|
1306
1304
|
import { jsxs } from "react/jsx-runtime";
|
1307
1305
|
var AttachmentPrimitiveThumb = forwardRef11((props, ref) => {
|
@@ -3061,7 +3059,7 @@ var subscribeToMainThread = (runtime, callback) => {
|
|
3061
3059
|
};
|
3062
3060
|
|
3063
3061
|
// src/runtimes/local/useLocalRuntime.tsx
|
3064
|
-
import { useEffect as useEffect17, useMemo as useMemo11, useState as
|
3062
|
+
import { useEffect as useEffect17, useMemo as useMemo11, useState as useState12 } from "react";
|
3065
3063
|
|
3066
3064
|
// src/utils/ProxyConfigProvider.ts
|
3067
3065
|
var ProxyConfigProvider = class {
|
@@ -4101,9 +4099,6 @@ var streamUtils = {
|
|
4101
4099
|
streamPartDecoderStream
|
4102
4100
|
};
|
4103
4101
|
|
4104
|
-
// src/runtimes/edge/useEdgeRuntime.ts
|
4105
|
-
import { useState as useState12 } from "react";
|
4106
|
-
|
4107
4102
|
// src/runtimes/edge/streams/assistantDecoderStream.ts
|
4108
4103
|
function assistantDecoderStream() {
|
4109
4104
|
const toolCallNames = /* @__PURE__ */ new Map();
|
@@ -4182,6 +4177,7 @@ function assistantDecoderStream() {
|
|
4182
4177
|
}
|
4183
4178
|
case "9" /* ToolCall */: {
|
4184
4179
|
const { toolCallId, toolName, args } = value;
|
4180
|
+
toolCallNames.set(toolCallId, toolName);
|
4185
4181
|
const argsText = JSON.stringify(args);
|
4186
4182
|
controller.enqueue({
|
4187
4183
|
type: "tool-call-delta",
|
@@ -4283,8 +4279,10 @@ var splitLocalRuntimeOptions = (options) => {
|
|
4283
4279
|
// src/runtimes/edge/useEdgeRuntime.ts
|
4284
4280
|
var useEdgeRuntime = (options) => {
|
4285
4281
|
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
4286
|
-
|
4287
|
-
|
4282
|
+
return useLocalRuntime(
|
4283
|
+
new EdgeChatAdapter(otherOptions),
|
4284
|
+
localRuntimeOptions
|
4285
|
+
);
|
4288
4286
|
};
|
4289
4287
|
|
4290
4288
|
// src/runtimes/local/shouldContinue.tsx
|
@@ -4834,7 +4832,7 @@ var useLocalRuntime = (adapter, options = {}) => {
|
|
4834
4832
|
chatModel: adapter
|
4835
4833
|
}
|
4836
4834
|
};
|
4837
|
-
const [runtime] =
|
4835
|
+
const [runtime] = useState12(() => new LocalRuntimeCore(opt));
|
4838
4836
|
useEffect17(() => {
|
4839
4837
|
runtime.setOptions(opt);
|
4840
4838
|
});
|
@@ -4842,7 +4840,7 @@ var useLocalRuntime = (adapter, options = {}) => {
|
|
4842
4840
|
};
|
4843
4841
|
|
4844
4842
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
4845
|
-
import { useEffect as useEffect18, useMemo as useMemo12, useState as
|
4843
|
+
import { useEffect as useEffect18, useMemo as useMemo12, useState as useState13 } from "react";
|
4846
4844
|
|
4847
4845
|
// src/runtimes/external-store/ExternalStoreThreadManagementAdapter.tsx
|
4848
4846
|
var EMPTY_ARRAY2 = Object.freeze([]);
|
@@ -5228,7 +5226,7 @@ var ExternalStoreRuntimeCore = class extends BaseAssistantRuntimeCore {
|
|
5228
5226
|
|
5229
5227
|
// src/runtimes/external-store/useExternalStoreRuntime.tsx
|
5230
5228
|
var useExternalStoreRuntime = (store) => {
|
5231
|
-
const [runtime] =
|
5229
|
+
const [runtime] = useState13(() => new ExternalStoreRuntimeCore(store));
|
5232
5230
|
useEffect18(() => {
|
5233
5231
|
runtime.setStore(store);
|
5234
5232
|
});
|
@@ -5385,7 +5383,7 @@ var shallowArrayEqual = (a, b) => {
|
|
5385
5383
|
};
|
5386
5384
|
|
5387
5385
|
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
5388
|
-
import { useState as
|
5386
|
+
import { useState as useState14 } from "react";
|
5389
5387
|
|
5390
5388
|
// src/runtimes/dangerous-in-browser/DangerousInBrowserAdapter.ts
|
5391
5389
|
var DangerousInBrowserAdapter = class {
|
@@ -5414,7 +5412,7 @@ var DangerousInBrowserAdapter = class {
|
|
5414
5412
|
// src/runtimes/dangerous-in-browser/useDangerousInBrowserRuntime.ts
|
5415
5413
|
var useDangerousInBrowserRuntime = (options) => {
|
5416
5414
|
const { localRuntimeOptions, otherOptions } = splitLocalRuntimeOptions(options);
|
5417
|
-
const [adapter] =
|
5415
|
+
const [adapter] = useState14(() => new DangerousInBrowserAdapter(otherOptions));
|
5418
5416
|
return useLocalRuntime(adapter, localRuntimeOptions);
|
5419
5417
|
};
|
5420
5418
|
|
@@ -6001,7 +5999,7 @@ CircleStopIcon.displayName = "CircleStopIcon";
|
|
6001
5999
|
import {
|
6002
6000
|
forwardRef as forwardRef28,
|
6003
6001
|
useEffect as useEffect19,
|
6004
|
-
useState as
|
6002
|
+
useState as useState15
|
6005
6003
|
} from "react";
|
6006
6004
|
import { CircleXIcon, FileIcon } from "lucide-react";
|
6007
6005
|
|
@@ -6044,7 +6042,7 @@ var AttachmentRoot = withDefaults(attachment_exports.Root, {
|
|
6044
6042
|
});
|
6045
6043
|
AttachmentRoot.displayName = "AttachmentRoot";
|
6046
6044
|
var useFileSrc = (file) => {
|
6047
|
-
const [src, setSrc] =
|
6045
|
+
const [src, setSrc] = useState15(void 0);
|
6048
6046
|
useEffect19(() => {
|
6049
6047
|
if (!file) {
|
6050
6048
|
setSrc(void 0);
|
@@ -6069,7 +6067,7 @@ var useAttachmentSrc = () => {
|
|
6069
6067
|
return useFileSrc(file) ?? src;
|
6070
6068
|
};
|
6071
6069
|
var AttachmentPreview = ({ src }) => {
|
6072
|
-
const [isLoaded, setIsLoaded] =
|
6070
|
+
const [isLoaded, setIsLoaded] = useState15(false);
|
6073
6071
|
return (
|
6074
6072
|
// eslint-disable-next-line @next/next/no-img-element
|
6075
6073
|
/* @__PURE__ */ jsx46(
|
@@ -6730,6 +6728,8 @@ export {
|
|
6730
6728
|
useAssistantRuntimeStore,
|
6731
6729
|
useAssistantTool,
|
6732
6730
|
useAssistantToolUI,
|
6731
|
+
useAttachment,
|
6732
|
+
useAttachmentRuntime,
|
6733
6733
|
useBranchPickerCount,
|
6734
6734
|
useBranchPickerNext,
|
6735
6735
|
useBranchPickerNumber,
|