@assistant-ui/react 0.5.5 → 0.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -1
- package/edge/README.md +1 -0
- package/edge/package.json +5 -0
- package/package.json +2 -1
package/dist/index.d.mts
CHANGED
@@ -239,6 +239,7 @@ declare class LocalThreadRuntime implements ThreadRuntime {
|
|
239
239
|
private abortController;
|
240
240
|
private readonly repository;
|
241
241
|
readonly capabilities: Readonly<{
|
242
|
+
switchToBranch: true;
|
242
243
|
edit: true;
|
243
244
|
reload: true;
|
244
245
|
cancel: true;
|
@@ -641,6 +642,7 @@ declare class ExternalStoreThreadRuntime implements ReactThreadRuntime {
|
|
641
642
|
private assistantOptimisticId;
|
642
643
|
private useStore;
|
643
644
|
get capabilities(): {
|
645
|
+
switchToBranch: boolean;
|
644
646
|
edit: boolean;
|
645
647
|
reload: boolean;
|
646
648
|
cancel: boolean;
|
@@ -683,13 +685,15 @@ type AddToolResultOptions = {
|
|
683
685
|
toolCallId: string;
|
684
686
|
result: any;
|
685
687
|
};
|
688
|
+
type RuntimeCapabilities = {
|
689
|
+
switchToBranch: boolean;
|
690
|
+
edit: boolean;
|
691
|
+
reload: boolean;
|
692
|
+
cancel: boolean;
|
693
|
+
copy: boolean;
|
694
|
+
};
|
686
695
|
type ThreadActionsState = Readonly<{
|
687
|
-
capabilities: Readonly<
|
688
|
-
edit: boolean;
|
689
|
-
reload: boolean;
|
690
|
-
cancel: boolean;
|
691
|
-
copy: boolean;
|
692
|
-
}>;
|
696
|
+
capabilities: Readonly<RuntimeCapabilities>;
|
693
697
|
getBranches: (messageId: string) => readonly string[];
|
694
698
|
switchToBranch: (branchId: string) => void;
|
695
699
|
append: (message: AppendMessage) => void;
|
@@ -1219,6 +1223,9 @@ type AssistantMessageConfig = {
|
|
1219
1223
|
Text?: TextContentPartComponent | undefined;
|
1220
1224
|
} | undefined;
|
1221
1225
|
};
|
1226
|
+
type BranchPickerConfig = {
|
1227
|
+
allowBranchPicker?: boolean | undefined;
|
1228
|
+
};
|
1222
1229
|
type StringsConfig = {
|
1223
1230
|
assistantModal?: {
|
1224
1231
|
open: {
|
@@ -1291,6 +1298,7 @@ type ThreadConfig = {
|
|
1291
1298
|
welcome?: ThreadWelcomeConfig;
|
1292
1299
|
assistantMessage?: AssistantMessageConfig;
|
1293
1300
|
userMessage?: UserMessageConfig;
|
1301
|
+
branchPicker?: BranchPickerConfig;
|
1294
1302
|
strings?: StringsConfig;
|
1295
1303
|
};
|
1296
1304
|
declare const useThreadConfig: () => Omit<ThreadConfig, "runtime">;
|
package/dist/index.d.ts
CHANGED
@@ -239,6 +239,7 @@ declare class LocalThreadRuntime implements ThreadRuntime {
|
|
239
239
|
private abortController;
|
240
240
|
private readonly repository;
|
241
241
|
readonly capabilities: Readonly<{
|
242
|
+
switchToBranch: true;
|
242
243
|
edit: true;
|
243
244
|
reload: true;
|
244
245
|
cancel: true;
|
@@ -641,6 +642,7 @@ declare class ExternalStoreThreadRuntime implements ReactThreadRuntime {
|
|
641
642
|
private assistantOptimisticId;
|
642
643
|
private useStore;
|
643
644
|
get capabilities(): {
|
645
|
+
switchToBranch: boolean;
|
644
646
|
edit: boolean;
|
645
647
|
reload: boolean;
|
646
648
|
cancel: boolean;
|
@@ -683,13 +685,15 @@ type AddToolResultOptions = {
|
|
683
685
|
toolCallId: string;
|
684
686
|
result: any;
|
685
687
|
};
|
688
|
+
type RuntimeCapabilities = {
|
689
|
+
switchToBranch: boolean;
|
690
|
+
edit: boolean;
|
691
|
+
reload: boolean;
|
692
|
+
cancel: boolean;
|
693
|
+
copy: boolean;
|
694
|
+
};
|
686
695
|
type ThreadActionsState = Readonly<{
|
687
|
-
capabilities: Readonly<
|
688
|
-
edit: boolean;
|
689
|
-
reload: boolean;
|
690
|
-
cancel: boolean;
|
691
|
-
copy: boolean;
|
692
|
-
}>;
|
696
|
+
capabilities: Readonly<RuntimeCapabilities>;
|
693
697
|
getBranches: (messageId: string) => readonly string[];
|
694
698
|
switchToBranch: (branchId: string) => void;
|
695
699
|
append: (message: AppendMessage) => void;
|
@@ -1219,6 +1223,9 @@ type AssistantMessageConfig = {
|
|
1219
1223
|
Text?: TextContentPartComponent | undefined;
|
1220
1224
|
} | undefined;
|
1221
1225
|
};
|
1226
|
+
type BranchPickerConfig = {
|
1227
|
+
allowBranchPicker?: boolean | undefined;
|
1228
|
+
};
|
1222
1229
|
type StringsConfig = {
|
1223
1230
|
assistantModal?: {
|
1224
1231
|
open: {
|
@@ -1291,6 +1298,7 @@ type ThreadConfig = {
|
|
1291
1298
|
welcome?: ThreadWelcomeConfig;
|
1292
1299
|
assistantMessage?: AssistantMessageConfig;
|
1293
1300
|
userMessage?: UserMessageConfig;
|
1301
|
+
branchPicker?: BranchPickerConfig;
|
1294
1302
|
strings?: StringsConfig;
|
1295
1303
|
};
|
1296
1304
|
declare const useThreadConfig: () => Omit<ThreadConfig, "runtime">;
|
package/dist/index.js
CHANGED
@@ -3440,6 +3440,7 @@ var shouldContinue = (result) => result.status?.type === "requires-action" && re
|
|
3440
3440
|
|
3441
3441
|
// src/runtimes/local/LocalThreadRuntime.tsx
|
3442
3442
|
var CAPABILITIES = Object.freeze({
|
3443
|
+
switchToBranch: true,
|
3443
3444
|
edit: true,
|
3444
3445
|
reload: true,
|
3445
3446
|
cancel: true,
|
@@ -3713,6 +3714,7 @@ var ExternalStoreThreadRuntime = class {
|
|
3713
3714
|
useStore;
|
3714
3715
|
get capabilities() {
|
3715
3716
|
return {
|
3717
|
+
switchToBranch: this.store.setMessages !== void 0,
|
3716
3718
|
edit: this.store.onEdit !== void 0,
|
3717
3719
|
reload: this.store.onReload !== void 0,
|
3718
3720
|
cancel: this.store.onCancel !== void 0,
|
@@ -3725,6 +3727,8 @@ var ExternalStoreThreadRuntime = class {
|
|
3725
3727
|
return this.repository.getBranches(messageId);
|
3726
3728
|
}
|
3727
3729
|
switchToBranch(branchId) {
|
3730
|
+
if (!this.store.setMessages)
|
3731
|
+
throw new Error("Runtime does not support switching branches.");
|
3728
3732
|
this.repository.switchToBranch(branchId);
|
3729
3733
|
this.updateMessages(this.repository.getMessages());
|
3730
3734
|
}
|
@@ -3954,7 +3958,15 @@ var import_react60 = require("react");
|
|
3954
3958
|
var import_react59 = require("react");
|
3955
3959
|
var import_lucide_react2 = require("lucide-react");
|
3956
3960
|
var import_jsx_runtime31 = require("react/jsx-runtime");
|
3961
|
+
var useAllowBranchPicker = () => {
|
3962
|
+
const { branchPicker: { allowBranchPicker = true } = {} } = useThreadConfig();
|
3963
|
+
const { useThreadActions } = useThreadContext();
|
3964
|
+
const branchPickerSupported = useThreadActions((t) => t.capabilities.edit);
|
3965
|
+
return branchPickerSupported && allowBranchPicker;
|
3966
|
+
};
|
3957
3967
|
var BranchPicker = () => {
|
3968
|
+
const allowBranchPicker = useAllowBranchPicker();
|
3969
|
+
if (!allowBranchPicker) return null;
|
3958
3970
|
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(BranchPickerRoot, { hideWhenSingleBranch: true, children: [
|
3959
3971
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(BranchPickerPrevious2, {}),
|
3960
3972
|
/* @__PURE__ */ (0, import_jsx_runtime31.jsx)(BranchPickerState, {}),
|