@assistant-ui/react 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.d.mts +31 -29
- package/dist/index.d.ts +31 -29
- package/dist/index.js +152 -141
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +154 -143
- package/dist/index.mjs.map +1 -1
- package/dist/styles/index.css.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
@@ -204,17 +204,33 @@ declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRu
|
|
204
204
|
private subscriptionHandler;
|
205
205
|
}
|
206
206
|
|
207
|
+
type TextContentPartProps = {
|
208
|
+
part: TextContentPart;
|
209
|
+
status: ContentPartStatus;
|
210
|
+
};
|
211
|
+
type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
212
|
+
type ImageContentPartProps = {
|
213
|
+
part: ImageContentPart;
|
214
|
+
status: ContentPartStatus;
|
215
|
+
};
|
216
|
+
type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
217
|
+
type UIContentPartProps = {
|
218
|
+
part: UIContentPart;
|
219
|
+
status: ContentPartStatus;
|
220
|
+
};
|
221
|
+
type UIContentPartComponent = ComponentType<UIContentPartProps>;
|
222
|
+
type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = {
|
223
|
+
part: ToolCallContentPart<TArgs, TResult>;
|
224
|
+
status: ToolContentPartStatus;
|
225
|
+
addResult: (result: any) => void;
|
226
|
+
};
|
227
|
+
type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
228
|
+
|
207
229
|
type LocalRuntimeOptions = {
|
208
230
|
initialMessages?: readonly CoreMessage[] | undefined;
|
209
231
|
maxToolRoundtrips?: number;
|
210
232
|
};
|
211
|
-
|
212
|
-
private readonly _proxyConfigProvider;
|
213
|
-
constructor(adapter: ChatModelAdapter, options?: LocalRuntimeOptions);
|
214
|
-
set adapter(adapter: ChatModelAdapter);
|
215
|
-
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
216
|
-
switchToThread(threadId: string | null): LocalThreadRuntime;
|
217
|
-
}
|
233
|
+
|
218
234
|
declare class LocalThreadRuntime implements ThreadRuntime {
|
219
235
|
private configProvider;
|
220
236
|
adapter: ChatModelAdapter;
|
@@ -242,32 +258,18 @@ declare class LocalThreadRuntime implements ThreadRuntime {
|
|
242
258
|
addToolResult({ messageId, toolCallId, result }: AddToolResultOptions): void;
|
243
259
|
}
|
244
260
|
|
261
|
+
declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
|
262
|
+
private readonly _proxyConfigProvider;
|
263
|
+
constructor(adapter: ChatModelAdapter, options?: LocalRuntimeOptions);
|
264
|
+
set adapter(adapter: ChatModelAdapter);
|
265
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
266
|
+
switchToThread(threadId: string | null): LocalThreadRuntime;
|
267
|
+
}
|
268
|
+
|
245
269
|
declare const useLocalRuntime: (adapter: ChatModelAdapter, options?: LocalRuntimeOptions) => LocalRuntime;
|
246
270
|
|
247
271
|
declare function toLanguageModelMessages(message: readonly CoreMessage[] | readonly ThreadMessage[]): LanguageModelV1Message[];
|
248
272
|
|
249
|
-
type TextContentPartProps = {
|
250
|
-
part: TextContentPart;
|
251
|
-
status: ContentPartStatus;
|
252
|
-
};
|
253
|
-
type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
254
|
-
type ImageContentPartProps = {
|
255
|
-
part: ImageContentPart;
|
256
|
-
status: ContentPartStatus;
|
257
|
-
};
|
258
|
-
type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
259
|
-
type UIContentPartProps = {
|
260
|
-
part: UIContentPart;
|
261
|
-
status: ContentPartStatus;
|
262
|
-
};
|
263
|
-
type UIContentPartComponent = ComponentType<UIContentPartProps>;
|
264
|
-
type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = {
|
265
|
-
part: ToolCallContentPart<TArgs, TResult>;
|
266
|
-
status: ToolContentPartStatus;
|
267
|
-
addResult: (result: any) => void;
|
268
|
-
};
|
269
|
-
type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
270
|
-
|
271
273
|
type fromLanguageModelMessagesOptions = {
|
272
274
|
mergeRoundtrips: boolean;
|
273
275
|
};
|
package/dist/index.d.ts
CHANGED
@@ -204,17 +204,33 @@ declare abstract class BaseAssistantRuntime<TThreadRuntime extends ReactThreadRu
|
|
204
204
|
private subscriptionHandler;
|
205
205
|
}
|
206
206
|
|
207
|
+
type TextContentPartProps = {
|
208
|
+
part: TextContentPart;
|
209
|
+
status: ContentPartStatus;
|
210
|
+
};
|
211
|
+
type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
212
|
+
type ImageContentPartProps = {
|
213
|
+
part: ImageContentPart;
|
214
|
+
status: ContentPartStatus;
|
215
|
+
};
|
216
|
+
type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
217
|
+
type UIContentPartProps = {
|
218
|
+
part: UIContentPart;
|
219
|
+
status: ContentPartStatus;
|
220
|
+
};
|
221
|
+
type UIContentPartComponent = ComponentType<UIContentPartProps>;
|
222
|
+
type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = {
|
223
|
+
part: ToolCallContentPart<TArgs, TResult>;
|
224
|
+
status: ToolContentPartStatus;
|
225
|
+
addResult: (result: any) => void;
|
226
|
+
};
|
227
|
+
type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
228
|
+
|
207
229
|
type LocalRuntimeOptions = {
|
208
230
|
initialMessages?: readonly CoreMessage[] | undefined;
|
209
231
|
maxToolRoundtrips?: number;
|
210
232
|
};
|
211
|
-
|
212
|
-
private readonly _proxyConfigProvider;
|
213
|
-
constructor(adapter: ChatModelAdapter, options?: LocalRuntimeOptions);
|
214
|
-
set adapter(adapter: ChatModelAdapter);
|
215
|
-
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
216
|
-
switchToThread(threadId: string | null): LocalThreadRuntime;
|
217
|
-
}
|
233
|
+
|
218
234
|
declare class LocalThreadRuntime implements ThreadRuntime {
|
219
235
|
private configProvider;
|
220
236
|
adapter: ChatModelAdapter;
|
@@ -242,32 +258,18 @@ declare class LocalThreadRuntime implements ThreadRuntime {
|
|
242
258
|
addToolResult({ messageId, toolCallId, result }: AddToolResultOptions): void;
|
243
259
|
}
|
244
260
|
|
261
|
+
declare class LocalRuntime extends BaseAssistantRuntime<LocalThreadRuntime> {
|
262
|
+
private readonly _proxyConfigProvider;
|
263
|
+
constructor(adapter: ChatModelAdapter, options?: LocalRuntimeOptions);
|
264
|
+
set adapter(adapter: ChatModelAdapter);
|
265
|
+
registerModelConfigProvider(provider: ModelConfigProvider): () => void;
|
266
|
+
switchToThread(threadId: string | null): LocalThreadRuntime;
|
267
|
+
}
|
268
|
+
|
245
269
|
declare const useLocalRuntime: (adapter: ChatModelAdapter, options?: LocalRuntimeOptions) => LocalRuntime;
|
246
270
|
|
247
271
|
declare function toLanguageModelMessages(message: readonly CoreMessage[] | readonly ThreadMessage[]): LanguageModelV1Message[];
|
248
272
|
|
249
|
-
type TextContentPartProps = {
|
250
|
-
part: TextContentPart;
|
251
|
-
status: ContentPartStatus;
|
252
|
-
};
|
253
|
-
type TextContentPartComponent = ComponentType<TextContentPartProps>;
|
254
|
-
type ImageContentPartProps = {
|
255
|
-
part: ImageContentPart;
|
256
|
-
status: ContentPartStatus;
|
257
|
-
};
|
258
|
-
type ImageContentPartComponent = ComponentType<ImageContentPartProps>;
|
259
|
-
type UIContentPartProps = {
|
260
|
-
part: UIContentPart;
|
261
|
-
status: ContentPartStatus;
|
262
|
-
};
|
263
|
-
type UIContentPartComponent = ComponentType<UIContentPartProps>;
|
264
|
-
type ToolCallContentPartProps<TArgs extends Record<string, unknown> = any, TResult = unknown> = {
|
265
|
-
part: ToolCallContentPart<TArgs, TResult>;
|
266
|
-
status: ToolContentPartStatus;
|
267
|
-
addResult: (result: any) => void;
|
268
|
-
};
|
269
|
-
type ToolCallContentPartComponent<TArgs extends Record<string, unknown> = any, TResult = any> = ComponentType<ToolCallContentPartProps<TArgs, TResult>>;
|
270
|
-
|
271
273
|
type fromLanguageModelMessagesOptions = {
|
272
274
|
mergeRoundtrips: boolean;
|
273
275
|
};
|
package/dist/index.js
CHANGED
@@ -1267,7 +1267,7 @@ var COMPLETE_STATUS = {
|
|
1267
1267
|
};
|
1268
1268
|
var toContentPartStatus = (message, partIndex, part) => {
|
1269
1269
|
if (message.role !== "assistant") return COMPLETE_STATUS;
|
1270
|
-
const isLastPart = partIndex === message.content.length - 1;
|
1270
|
+
const isLastPart = partIndex === Math.max(0, message.content.length - 1);
|
1271
1271
|
if (part.type !== "tool-call") {
|
1272
1272
|
if ("reason" in message.status && message.status.reason === "tool-calls" && isLastPart)
|
1273
1273
|
throw new Error(
|
@@ -1280,9 +1280,16 @@ var toContentPartStatus = (message, partIndex, part) => {
|
|
1280
1280
|
}
|
1281
1281
|
return message.status;
|
1282
1282
|
};
|
1283
|
+
var EMPTY_CONTENT = Object.freeze({ type: "text", text: "" });
|
1283
1284
|
var syncContentPart = ({ message }, useContentPart, partIndex) => {
|
1284
|
-
|
1285
|
-
if (!part)
|
1285
|
+
let part = message.content[partIndex];
|
1286
|
+
if (!part) {
|
1287
|
+
if (message.content.length === 0 && partIndex === 0) {
|
1288
|
+
part = EMPTY_CONTENT;
|
1289
|
+
} else {
|
1290
|
+
return;
|
1291
|
+
}
|
1292
|
+
}
|
1286
1293
|
const status = toContentPartStatus(message, partIndex, part);
|
1287
1294
|
const currentState = useContentPart.getState();
|
1288
1295
|
if (currentState.part === part && currentState.status === status) return;
|
@@ -1408,7 +1415,7 @@ var ContentPartPrimitiveText = (0, import_react36.forwardRef)(({ smooth = true,
|
|
1408
1415
|
part: { text }
|
1409
1416
|
} = useContentPartText();
|
1410
1417
|
const smoothText = useSmooth(text, smooth);
|
1411
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_primitive4.Primitive.span, { "data-status": status, ...rest, ref: forwardedRef, children: smoothText });
|
1418
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_react_primitive4.Primitive.span, { "data-status": status.type, ...rest, ref: forwardedRef, children: smoothText });
|
1412
1419
|
});
|
1413
1420
|
ContentPartPrimitiveText.displayName = "ContentPartPrimitive.Text";
|
1414
1421
|
|
@@ -1514,7 +1521,7 @@ var MessagePrimitiveContent = ({
|
|
1514
1521
|
components
|
1515
1522
|
}) => {
|
1516
1523
|
const { useMessage } = useMessageContext();
|
1517
|
-
const contentLength = useMessage((s) => s.message.content.length);
|
1524
|
+
const contentLength = useMessage((s) => s.message.content.length) || 1;
|
1518
1525
|
return new Array(contentLength).fill(null).map((_, idx) => {
|
1519
1526
|
const partIndex = idx;
|
1520
1527
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
@@ -1811,7 +1818,7 @@ var useThreadViewportAutoScroll = ({
|
|
1811
1818
|
const div = divRef.current;
|
1812
1819
|
if (!div) return;
|
1813
1820
|
const isAtBottom = useViewport.getState().isAtBottom;
|
1814
|
-
const newIsAtBottom = div.scrollHeight - div.scrollTop <= div.clientHeight;
|
1821
|
+
const newIsAtBottom = div.scrollHeight - div.scrollTop <= div.clientHeight + 1;
|
1815
1822
|
if (!newIsAtBottom && lastScrollTop.current < div.scrollTop) {
|
1816
1823
|
} else {
|
1817
1824
|
if (newIsAtBottom) {
|
@@ -2047,26 +2054,6 @@ var ThreadPrimitiveSuggestion = createActionButton(
|
|
2047
2054
|
// src/runtimes/local/useLocalRuntime.tsx
|
2048
2055
|
var import_react54 = require("react");
|
2049
2056
|
|
2050
|
-
// src/utils/idUtils.tsx
|
2051
|
-
var import_non_secure = require("nanoid/non-secure");
|
2052
|
-
var generateId = (0, import_non_secure.customAlphabet)(
|
2053
|
-
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
2054
|
-
7
|
2055
|
-
);
|
2056
|
-
var optimisticPrefix = "__optimistic__";
|
2057
|
-
var generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;
|
2058
|
-
|
2059
|
-
// src/internal.ts
|
2060
|
-
var internal_exports = {};
|
2061
|
-
__export(internal_exports, {
|
2062
|
-
BaseAssistantRuntime: () => BaseAssistantRuntime,
|
2063
|
-
MessageRepository: () => MessageRepository,
|
2064
|
-
ProxyConfigProvider: () => ProxyConfigProvider,
|
2065
|
-
TooltipIconButton: () => TooltipIconButton,
|
2066
|
-
generateId: () => generateId,
|
2067
|
-
useSmooth: () => useSmooth
|
2068
|
-
});
|
2069
|
-
|
2070
2057
|
// src/runtimes/core/BaseAssistantRuntime.tsx
|
2071
2058
|
var BaseAssistantRuntime = class {
|
2072
2059
|
constructor(_thread) {
|
@@ -2090,99 +2077,25 @@ var BaseAssistantRuntime = class {
|
|
2090
2077
|
};
|
2091
2078
|
};
|
2092
2079
|
|
2093
|
-
// src/
|
2094
|
-
var
|
2095
|
-
|
2096
|
-
|
2097
|
-
|
2098
|
-
|
2099
|
-
|
2100
|
-
|
2101
|
-
|
2102
|
-
var import_jsx_runtime25 = require("react/jsx-runtime");
|
2103
|
-
var withDefaultProps = ({
|
2104
|
-
className,
|
2105
|
-
...defaultProps
|
2106
|
-
}) => ({ className: classNameProp, ...props }) => {
|
2107
|
-
return {
|
2108
|
-
className: (0, import_classnames.default)(className, classNameProp),
|
2109
|
-
...defaultProps,
|
2110
|
-
...props
|
2111
|
-
};
|
2112
|
-
};
|
2113
|
-
var withDefaults = (Component, defaultProps) => {
|
2114
|
-
const getProps = withDefaultProps(defaultProps);
|
2115
|
-
const WithDefaults = (0, import_react50.forwardRef)(
|
2116
|
-
(props, ref) => {
|
2117
|
-
const ComponentAsAny = Component;
|
2118
|
-
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ComponentAsAny, { ...getProps(props), ref });
|
2119
|
-
}
|
2120
|
-
);
|
2121
|
-
WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
|
2122
|
-
return WithDefaults;
|
2123
|
-
};
|
2124
|
-
|
2125
|
-
// src/ui/base/tooltip.tsx
|
2126
|
-
var import_jsx_runtime26 = require("react/jsx-runtime");
|
2127
|
-
var Tooltip = (props) => {
|
2128
|
-
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TooltipPrimitive.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TooltipPrimitive.Root, { ...props }) });
|
2129
|
-
};
|
2130
|
-
Tooltip.displayName = "Tooltip";
|
2131
|
-
var TooltipTrigger = TooltipPrimitive.Trigger;
|
2132
|
-
var TooltipContent = withDefaults(TooltipPrimitive.Content, {
|
2133
|
-
sideOffset: 4,
|
2134
|
-
className: "aui-tooltip-content"
|
2080
|
+
// src/internal.ts
|
2081
|
+
var internal_exports = {};
|
2082
|
+
__export(internal_exports, {
|
2083
|
+
BaseAssistantRuntime: () => BaseAssistantRuntime,
|
2084
|
+
MessageRepository: () => MessageRepository,
|
2085
|
+
ProxyConfigProvider: () => ProxyConfigProvider,
|
2086
|
+
TooltipIconButton: () => TooltipIconButton,
|
2087
|
+
generateId: () => generateId,
|
2088
|
+
useSmooth: () => useSmooth
|
2135
2089
|
});
|
2136
|
-
TooltipContent.displayName = "TooltipContent";
|
2137
2090
|
|
2138
|
-
// src/
|
2139
|
-
var
|
2140
|
-
var
|
2141
|
-
|
2142
|
-
|
2143
|
-
var buttonVariants = (0, import_class_variance_authority.cva)("aui-button", {
|
2144
|
-
variants: {
|
2145
|
-
variant: {
|
2146
|
-
default: "aui-button-primary",
|
2147
|
-
outline: "aui-button-outline",
|
2148
|
-
ghost: "aui-button-ghost"
|
2149
|
-
},
|
2150
|
-
size: {
|
2151
|
-
default: "aui-button-medium",
|
2152
|
-
icon: "aui-button-icon"
|
2153
|
-
}
|
2154
|
-
},
|
2155
|
-
defaultVariants: {
|
2156
|
-
variant: "default",
|
2157
|
-
size: "default"
|
2158
|
-
}
|
2159
|
-
});
|
2160
|
-
var Button = (0, import_react51.forwardRef)(
|
2161
|
-
({ className, variant, size, ...props }, ref) => {
|
2162
|
-
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
2163
|
-
import_react_primitive11.Primitive.button,
|
2164
|
-
{
|
2165
|
-
className: buttonVariants({ variant, size, className }),
|
2166
|
-
...props,
|
2167
|
-
ref
|
2168
|
-
}
|
2169
|
-
);
|
2170
|
-
}
|
2091
|
+
// src/utils/idUtils.tsx
|
2092
|
+
var import_non_secure = require("nanoid/non-secure");
|
2093
|
+
var generateId = (0, import_non_secure.customAlphabet)(
|
2094
|
+
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
2095
|
+
7
|
2171
2096
|
);
|
2172
|
-
|
2173
|
-
|
2174
|
-
// src/ui/base/tooltip-icon-button.tsx
|
2175
|
-
var import_jsx_runtime28 = require("react/jsx-runtime");
|
2176
|
-
var TooltipIconButton = (0, import_react52.forwardRef)(({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
2177
|
-
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tooltip, { children: [
|
2178
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
|
2179
|
-
children,
|
2180
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "aui-sr-only", children: tooltip })
|
2181
|
-
] }) }),
|
2182
|
-
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipContent, { side, children: tooltip })
|
2183
|
-
] });
|
2184
|
-
});
|
2185
|
-
TooltipIconButton.displayName = "TooltipIconButton";
|
2097
|
+
var optimisticPrefix = "__optimistic__";
|
2098
|
+
var generateOptimisticId = () => `${optimisticPrefix}${generateId()}`;
|
2186
2099
|
|
2187
2100
|
// src/runtimes/edge/converters/fromCoreMessage.ts
|
2188
2101
|
var fromCoreMessages = (message) => {
|
@@ -2395,6 +2308,100 @@ var MessageRepository = class {
|
|
2395
2308
|
}
|
2396
2309
|
};
|
2397
2310
|
|
2311
|
+
// src/ui/base/tooltip-icon-button.tsx
|
2312
|
+
var import_react52 = require("react");
|
2313
|
+
|
2314
|
+
// src/ui/base/tooltip.tsx
|
2315
|
+
var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"));
|
2316
|
+
|
2317
|
+
// src/ui/utils/withDefaults.tsx
|
2318
|
+
var import_react50 = require("react");
|
2319
|
+
var import_classnames = __toESM(require("classnames"));
|
2320
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
2321
|
+
var withDefaultProps = ({
|
2322
|
+
className,
|
2323
|
+
...defaultProps
|
2324
|
+
}) => ({ className: classNameProp, ...props }) => {
|
2325
|
+
return {
|
2326
|
+
className: (0, import_classnames.default)(className, classNameProp),
|
2327
|
+
...defaultProps,
|
2328
|
+
...props
|
2329
|
+
};
|
2330
|
+
};
|
2331
|
+
var withDefaults = (Component, defaultProps) => {
|
2332
|
+
const getProps = withDefaultProps(defaultProps);
|
2333
|
+
const WithDefaults = (0, import_react50.forwardRef)(
|
2334
|
+
(props, ref) => {
|
2335
|
+
const ComponentAsAny = Component;
|
2336
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(ComponentAsAny, { ...getProps(props), ref });
|
2337
|
+
}
|
2338
|
+
);
|
2339
|
+
WithDefaults.displayName = "withDefaults(" + (typeof Component === "string" ? Component : Component.displayName) + ")";
|
2340
|
+
return WithDefaults;
|
2341
|
+
};
|
2342
|
+
|
2343
|
+
// src/ui/base/tooltip.tsx
|
2344
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
2345
|
+
var Tooltip = (props) => {
|
2346
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TooltipPrimitive.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(TooltipPrimitive.Root, { ...props }) });
|
2347
|
+
};
|
2348
|
+
Tooltip.displayName = "Tooltip";
|
2349
|
+
var TooltipTrigger = TooltipPrimitive.Trigger;
|
2350
|
+
var TooltipContent = withDefaults(TooltipPrimitive.Content, {
|
2351
|
+
sideOffset: 4,
|
2352
|
+
className: "aui-tooltip-content"
|
2353
|
+
});
|
2354
|
+
TooltipContent.displayName = "TooltipContent";
|
2355
|
+
|
2356
|
+
// src/ui/base/button.tsx
|
2357
|
+
var import_class_variance_authority = require("class-variance-authority");
|
2358
|
+
var import_react_primitive11 = require("@radix-ui/react-primitive");
|
2359
|
+
var import_react51 = require("react");
|
2360
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
2361
|
+
var buttonVariants = (0, import_class_variance_authority.cva)("aui-button", {
|
2362
|
+
variants: {
|
2363
|
+
variant: {
|
2364
|
+
default: "aui-button-primary",
|
2365
|
+
outline: "aui-button-outline",
|
2366
|
+
ghost: "aui-button-ghost"
|
2367
|
+
},
|
2368
|
+
size: {
|
2369
|
+
default: "aui-button-medium",
|
2370
|
+
icon: "aui-button-icon"
|
2371
|
+
}
|
2372
|
+
},
|
2373
|
+
defaultVariants: {
|
2374
|
+
variant: "default",
|
2375
|
+
size: "default"
|
2376
|
+
}
|
2377
|
+
});
|
2378
|
+
var Button = (0, import_react51.forwardRef)(
|
2379
|
+
({ className, variant, size, ...props }, ref) => {
|
2380
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
2381
|
+
import_react_primitive11.Primitive.button,
|
2382
|
+
{
|
2383
|
+
className: buttonVariants({ variant, size, className }),
|
2384
|
+
...props,
|
2385
|
+
ref
|
2386
|
+
}
|
2387
|
+
);
|
2388
|
+
}
|
2389
|
+
);
|
2390
|
+
Button.displayName = "Button";
|
2391
|
+
|
2392
|
+
// src/ui/base/tooltip-icon-button.tsx
|
2393
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
2394
|
+
var TooltipIconButton = (0, import_react52.forwardRef)(({ children, tooltip, side = "bottom", ...rest }, ref) => {
|
2395
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Tooltip, { children: [
|
2396
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(Button, { variant: "ghost", size: "icon", ...rest, ref, children: [
|
2397
|
+
children,
|
2398
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("span", { className: "aui-sr-only", children: tooltip })
|
2399
|
+
] }) }),
|
2400
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(TooltipContent, { side, children: tooltip })
|
2401
|
+
] });
|
2402
|
+
});
|
2403
|
+
TooltipIconButton.displayName = "TooltipIconButton";
|
2404
|
+
|
2398
2405
|
// src/runtimes/edge/converters/toLanguageModelMessages.ts
|
2399
2406
|
var assistantMessageSplitter = () => {
|
2400
2407
|
const stash = [];
|
@@ -3427,31 +3434,10 @@ var useEdgeRuntime = ({
|
|
3427
3434
|
return useLocalRuntime(adapter, { initialMessages });
|
3428
3435
|
};
|
3429
3436
|
|
3430
|
-
// src/runtimes/local/
|
3437
|
+
// src/runtimes/local/shouldContinue.tsx
|
3431
3438
|
var shouldContinue = (result) => result.status?.type === "requires-action" && result.status.reason === "tool-calls" && result.content.every((c) => c.type !== "tool-call" || !!c.result);
|
3432
|
-
|
3433
|
-
|
3434
|
-
constructor(adapter, options) {
|
3435
|
-
const proxyConfigProvider = new ProxyConfigProvider();
|
3436
|
-
super(new LocalThreadRuntime(proxyConfigProvider, adapter, options));
|
3437
|
-
this._proxyConfigProvider = proxyConfigProvider;
|
3438
|
-
}
|
3439
|
-
set adapter(adapter) {
|
3440
|
-
this.thread.adapter = adapter;
|
3441
|
-
}
|
3442
|
-
registerModelConfigProvider(provider) {
|
3443
|
-
return this._proxyConfigProvider.registerModelConfigProvider(provider);
|
3444
|
-
}
|
3445
|
-
switchToThread(threadId) {
|
3446
|
-
if (threadId) {
|
3447
|
-
throw new Error("LocalRuntime does not yet support switching threads");
|
3448
|
-
}
|
3449
|
-
return this.thread = new LocalThreadRuntime(
|
3450
|
-
this._proxyConfigProvider,
|
3451
|
-
this.thread.adapter
|
3452
|
-
);
|
3453
|
-
}
|
3454
|
-
};
|
3439
|
+
|
3440
|
+
// src/runtimes/local/LocalThreadRuntime.tsx
|
3455
3441
|
var CAPABILITIES = Object.freeze({
|
3456
3442
|
edit: true,
|
3457
3443
|
reload: true,
|
@@ -3511,7 +3497,7 @@ var LocalThreadRuntime = class {
|
|
3511
3497
|
id,
|
3512
3498
|
role: "assistant",
|
3513
3499
|
status: { type: "running" },
|
3514
|
-
content: [
|
3500
|
+
content: [],
|
3515
3501
|
createdAt: /* @__PURE__ */ new Date()
|
3516
3502
|
};
|
3517
3503
|
do {
|
@@ -3623,6 +3609,31 @@ var LocalThreadRuntime = class {
|
|
3623
3609
|
}
|
3624
3610
|
};
|
3625
3611
|
|
3612
|
+
// src/runtimes/local/LocalRuntime.tsx
|
3613
|
+
var LocalRuntime = class extends BaseAssistantRuntime {
|
3614
|
+
_proxyConfigProvider;
|
3615
|
+
constructor(adapter, options) {
|
3616
|
+
const proxyConfigProvider = new ProxyConfigProvider();
|
3617
|
+
super(new LocalThreadRuntime(proxyConfigProvider, adapter, options));
|
3618
|
+
this._proxyConfigProvider = proxyConfigProvider;
|
3619
|
+
}
|
3620
|
+
set adapter(adapter) {
|
3621
|
+
this.thread.adapter = adapter;
|
3622
|
+
}
|
3623
|
+
registerModelConfigProvider(provider) {
|
3624
|
+
return this._proxyConfigProvider.registerModelConfigProvider(provider);
|
3625
|
+
}
|
3626
|
+
switchToThread(threadId) {
|
3627
|
+
if (threadId) {
|
3628
|
+
throw new Error("LocalRuntime does not yet support switching threads");
|
3629
|
+
}
|
3630
|
+
return this.thread = new LocalThreadRuntime(
|
3631
|
+
this._proxyConfigProvider,
|
3632
|
+
this.thread.adapter
|
3633
|
+
);
|
3634
|
+
}
|
3635
|
+
};
|
3636
|
+
|
3626
3637
|
// src/runtimes/local/useLocalRuntime.tsx
|
3627
3638
|
var useLocalRuntime = (adapter, options) => {
|
3628
3639
|
const [runtime] = (0, import_react54.useState)(() => new LocalRuntime(adapter, options));
|