@rodrigocoliveira/agno-react 2.0.0 → 2.1.0
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/README.md +1 -1
- package/dist/hooks/useAgnoToolExecution.d.ts +7 -11
- package/dist/hooks/useAgnoToolExecution.d.ts.map +1 -1
- package/dist/index.d.ts +3 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +645 -986
- package/dist/index.js.map +7 -10
- package/dist/index.mjs +564 -905
- package/dist/index.mjs.map +7 -10
- package/dist/ui/components/chart.d.ts +63 -0
- package/dist/ui/components/chart.d.ts.map +1 -0
- package/dist/ui/composed/agno-chat/agno-chat.d.ts +6 -4
- package/dist/ui/composed/agno-chat/agno-chat.d.ts.map +1 -1
- package/dist/ui/composed/agno-chat/tool-building-blocks.d.ts +0 -4
- package/dist/ui/composed/agno-chat/tool-building-blocks.d.ts.map +1 -1
- package/dist/ui/composed/agno-message/tools.d.ts.map +1 -1
- package/dist/ui/composed/generative-components/card-grid.d.ts +4 -0
- package/dist/ui/composed/generative-components/card-grid.d.ts.map +1 -0
- package/dist/ui/composed/generative-components/charts.d.ts +7 -0
- package/dist/ui/composed/generative-components/charts.d.ts.map +1 -0
- package/dist/ui/composed/index.d.ts +6 -2
- package/dist/ui/composed/index.d.ts.map +1 -1
- package/dist/ui/index.d.ts +8 -2
- package/dist/ui/index.d.ts.map +1 -1
- package/dist/ui.js +586 -424
- package/dist/ui.js.map +9 -11
- package/dist/ui.mjs +606 -430
- package/dist/ui.mjs.map +9 -11
- package/package.json +8 -3
- package/dist/components/GenerativeUIRenderer.d.ts +0 -21
- package/dist/components/GenerativeUIRenderer.d.ts.map +0 -1
- package/dist/utils/component-registry.d.ts +0 -63
- package/dist/utils/component-registry.d.ts.map +0 -1
package/dist/ui.mjs
CHANGED
|
@@ -2693,7 +2693,7 @@ var PromptInputCommandSeparator = ({ className, ...props }) => /* @__PURE__ */ j
|
|
|
2693
2693
|
...props
|
|
2694
2694
|
});
|
|
2695
2695
|
// src/ui/composed/agno-message/message.tsx
|
|
2696
|
-
import { useMemo as
|
|
2696
|
+
import { useMemo as useMemo3, useState as useState8 } from "react";
|
|
2697
2697
|
import { AlertCircle as AlertCircle2, FileIcon as FileIcon4, Music as Music2 } from "lucide-react";
|
|
2698
2698
|
|
|
2699
2699
|
// src/ui/composed/agno-message/context.ts
|
|
@@ -3016,311 +3016,25 @@ function useAgnoChatContext() {
|
|
|
3016
3016
|
return ctx;
|
|
3017
3017
|
}
|
|
3018
3018
|
|
|
3019
|
-
// src/components/GenerativeUIRenderer.tsx
|
|
3020
|
-
import React13 from "react";
|
|
3021
|
-
|
|
3022
|
-
// src/utils/component-registry.ts
|
|
3023
|
-
class ComponentRegistry {
|
|
3024
|
-
static instance;
|
|
3025
|
-
components = new Map;
|
|
3026
|
-
constructor() {}
|
|
3027
|
-
static getInstance() {
|
|
3028
|
-
if (!ComponentRegistry.instance) {
|
|
3029
|
-
ComponentRegistry.instance = new ComponentRegistry;
|
|
3030
|
-
}
|
|
3031
|
-
return ComponentRegistry.instance;
|
|
3032
|
-
}
|
|
3033
|
-
register(type, renderer) {
|
|
3034
|
-
this.components.set(type, renderer);
|
|
3035
|
-
}
|
|
3036
|
-
registerBatch(components) {
|
|
3037
|
-
Object.entries(components).forEach(([type, renderer]) => {
|
|
3038
|
-
this.register(type, renderer);
|
|
3039
|
-
});
|
|
3040
|
-
}
|
|
3041
|
-
get(type) {
|
|
3042
|
-
return this.components.get(type);
|
|
3043
|
-
}
|
|
3044
|
-
has(type) {
|
|
3045
|
-
return this.components.has(type);
|
|
3046
|
-
}
|
|
3047
|
-
unregister(type) {
|
|
3048
|
-
this.components.delete(type);
|
|
3049
|
-
}
|
|
3050
|
-
getRegisteredTypes() {
|
|
3051
|
-
return Array.from(this.components.keys());
|
|
3052
|
-
}
|
|
3053
|
-
clear() {
|
|
3054
|
-
this.components.clear();
|
|
3055
|
-
}
|
|
3056
|
-
}
|
|
3057
|
-
function getComponentRegistry() {
|
|
3058
|
-
return ComponentRegistry.getInstance();
|
|
3059
|
-
}
|
|
3060
|
-
|
|
3061
|
-
// src/hooks/useAgnoToolExecution.ts
|
|
3062
|
-
import { useState as useState9, useEffect as useEffect7, useCallback as useCallback8, useMemo as useMemo4 } from "react";
|
|
3063
|
-
|
|
3064
|
-
// src/context/AgnoContext.tsx
|
|
3065
|
-
import { createContext as createContext5, useContext as useContext5, useMemo as useMemo3, useEffect as useEffect6 } from "react";
|
|
3066
|
-
import { AgnoClient } from "@rodrigocoliveira/agno-client";
|
|
3067
|
-
import { jsx as jsx37 } from "react/jsx-runtime";
|
|
3068
|
-
var AgnoContext = createContext5(null);
|
|
3069
|
-
|
|
3070
|
-
// src/context/ToolHandlerContext.tsx
|
|
3071
|
-
import { createContext as createContext6, useContext as useContext6, useState as useState8, useCallback as useCallback7 } from "react";
|
|
3072
|
-
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
3073
|
-
var ToolHandlerContext = createContext6(null);
|
|
3074
|
-
|
|
3075
|
-
// src/hooks/useAgnoToolExecution.ts
|
|
3076
|
-
var customRenderRegistry = new Map;
|
|
3077
|
-
function getCustomRender(key) {
|
|
3078
|
-
return customRenderRegistry.get(key);
|
|
3079
|
-
}
|
|
3080
|
-
|
|
3081
|
-
// src/components/GenerativeUIRenderer.tsx
|
|
3082
|
-
import { jsx as jsx39, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3083
|
-
|
|
3084
|
-
class UIErrorBoundary extends React13.Component {
|
|
3085
|
-
constructor(props) {
|
|
3086
|
-
super(props);
|
|
3087
|
-
this.state = { hasError: false };
|
|
3088
|
-
}
|
|
3089
|
-
static getDerivedStateFromError(error) {
|
|
3090
|
-
return { hasError: true, error };
|
|
3091
|
-
}
|
|
3092
|
-
componentDidCatch(error, errorInfo) {
|
|
3093
|
-
console.error("[GenerativeUIRenderer] Error rendering component:", error, errorInfo);
|
|
3094
|
-
this.props.onError?.(error);
|
|
3095
|
-
}
|
|
3096
|
-
render() {
|
|
3097
|
-
if (this.state.hasError) {
|
|
3098
|
-
return this.props.fallback || /* @__PURE__ */ jsxs22("div", {
|
|
3099
|
-
className: "p-4 border border-red-300 rounded-md bg-red-50 text-red-800",
|
|
3100
|
-
children: [
|
|
3101
|
-
/* @__PURE__ */ jsx39("p", {
|
|
3102
|
-
className: "font-semibold",
|
|
3103
|
-
children: "Failed to render UI component"
|
|
3104
|
-
}),
|
|
3105
|
-
/* @__PURE__ */ jsx39("p", {
|
|
3106
|
-
className: "text-sm mt-1",
|
|
3107
|
-
children: this.state.error?.message || "Unknown error"
|
|
3108
|
-
})
|
|
3109
|
-
]
|
|
3110
|
-
});
|
|
3111
|
-
}
|
|
3112
|
-
return this.props.children;
|
|
3113
|
-
}
|
|
3114
|
-
}
|
|
3115
|
-
function GenerativeUIRenderer({
|
|
3116
|
-
spec,
|
|
3117
|
-
className,
|
|
3118
|
-
onError
|
|
3119
|
-
}) {
|
|
3120
|
-
const registry = getComponentRegistry();
|
|
3121
|
-
if (spec.type === "custom") {
|
|
3122
|
-
const customSpec = spec;
|
|
3123
|
-
if (customSpec.renderKey) {
|
|
3124
|
-
const renderFn = getCustomRender(customSpec.renderKey);
|
|
3125
|
-
if (renderFn) {
|
|
3126
|
-
return /* @__PURE__ */ jsx39(UIErrorBoundary, {
|
|
3127
|
-
onError,
|
|
3128
|
-
children: /* @__PURE__ */ jsx39("div", {
|
|
3129
|
-
className,
|
|
3130
|
-
children: renderFn(customSpec.props || {})
|
|
3131
|
-
})
|
|
3132
|
-
});
|
|
3133
|
-
}
|
|
3134
|
-
}
|
|
3135
|
-
return /* @__PURE__ */ jsxs22("div", {
|
|
3136
|
-
className: `p-4 border border-yellow-300 rounded-md bg-yellow-50 text-yellow-800 ${className || ""}`,
|
|
3137
|
-
children: [
|
|
3138
|
-
/* @__PURE__ */ jsx39("p", {
|
|
3139
|
-
className: "font-semibold",
|
|
3140
|
-
children: "Custom component not available"
|
|
3141
|
-
}),
|
|
3142
|
-
/* @__PURE__ */ jsx39("p", {
|
|
3143
|
-
className: "text-sm mt-1",
|
|
3144
|
-
children: "The custom render function for this component is not available."
|
|
3145
|
-
})
|
|
3146
|
-
]
|
|
3147
|
-
});
|
|
3148
|
-
}
|
|
3149
|
-
if (spec.type === "chart") {
|
|
3150
|
-
const chartSpec = spec;
|
|
3151
|
-
const chartType = `chart:${chartSpec.component}`;
|
|
3152
|
-
if (registry.has(chartType)) {
|
|
3153
|
-
const ChartRenderer = registry.get(chartType);
|
|
3154
|
-
return /* @__PURE__ */ jsx39(UIErrorBoundary, {
|
|
3155
|
-
onError,
|
|
3156
|
-
children: /* @__PURE__ */ jsxs22("div", {
|
|
3157
|
-
className,
|
|
3158
|
-
children: [
|
|
3159
|
-
chartSpec.title && /* @__PURE__ */ jsx39("h3", {
|
|
3160
|
-
className: "font-semibold mb-2",
|
|
3161
|
-
children: chartSpec.title
|
|
3162
|
-
}),
|
|
3163
|
-
chartSpec.description && /* @__PURE__ */ jsx39("p", {
|
|
3164
|
-
className: "text-sm text-gray-600 mb-4",
|
|
3165
|
-
children: chartSpec.description
|
|
3166
|
-
}),
|
|
3167
|
-
/* @__PURE__ */ jsx39(ChartRenderer, {
|
|
3168
|
-
...chartSpec.props
|
|
3169
|
-
})
|
|
3170
|
-
]
|
|
3171
|
-
})
|
|
3172
|
-
});
|
|
3173
|
-
}
|
|
3174
|
-
return /* @__PURE__ */ jsxs22("div", {
|
|
3175
|
-
className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
|
|
3176
|
-
children: [
|
|
3177
|
-
/* @__PURE__ */ jsx39("p", {
|
|
3178
|
-
className: "font-semibold mb-2",
|
|
3179
|
-
children: chartSpec.title || "Chart Data"
|
|
3180
|
-
}),
|
|
3181
|
-
chartSpec.description && /* @__PURE__ */ jsx39("p", {
|
|
3182
|
-
className: "text-sm text-gray-600 mb-2",
|
|
3183
|
-
children: chartSpec.description
|
|
3184
|
-
}),
|
|
3185
|
-
/* @__PURE__ */ jsx39("pre", {
|
|
3186
|
-
className: "text-xs bg-gray-100 p-2 rounded overflow-auto",
|
|
3187
|
-
children: JSON.stringify(chartSpec.props.data, null, 2)
|
|
3188
|
-
})
|
|
3189
|
-
]
|
|
3190
|
-
});
|
|
3191
|
-
}
|
|
3192
|
-
if (spec.type === "card-grid") {
|
|
3193
|
-
const cardGridSpec = spec;
|
|
3194
|
-
if (registry.has("card-grid")) {
|
|
3195
|
-
const CardGridRenderer = registry.get("card-grid");
|
|
3196
|
-
return /* @__PURE__ */ jsx39(UIErrorBoundary, {
|
|
3197
|
-
onError,
|
|
3198
|
-
children: /* @__PURE__ */ jsxs22("div", {
|
|
3199
|
-
className,
|
|
3200
|
-
children: [
|
|
3201
|
-
cardGridSpec.title && /* @__PURE__ */ jsx39("h3", {
|
|
3202
|
-
className: "font-semibold mb-2",
|
|
3203
|
-
children: cardGridSpec.title
|
|
3204
|
-
}),
|
|
3205
|
-
cardGridSpec.description && /* @__PURE__ */ jsx39("p", {
|
|
3206
|
-
className: "text-sm text-gray-600 mb-4",
|
|
3207
|
-
children: cardGridSpec.description
|
|
3208
|
-
}),
|
|
3209
|
-
/* @__PURE__ */ jsx39(CardGridRenderer, {
|
|
3210
|
-
...cardGridSpec.props
|
|
3211
|
-
})
|
|
3212
|
-
]
|
|
3213
|
-
})
|
|
3214
|
-
});
|
|
3215
|
-
}
|
|
3216
|
-
}
|
|
3217
|
-
if (spec.type === "table") {
|
|
3218
|
-
const tableSpec = spec;
|
|
3219
|
-
if (registry.has("table")) {
|
|
3220
|
-
const TableRenderer = registry.get("table");
|
|
3221
|
-
return /* @__PURE__ */ jsx39(UIErrorBoundary, {
|
|
3222
|
-
onError,
|
|
3223
|
-
children: /* @__PURE__ */ jsxs22("div", {
|
|
3224
|
-
className,
|
|
3225
|
-
children: [
|
|
3226
|
-
tableSpec.title && /* @__PURE__ */ jsx39("h3", {
|
|
3227
|
-
className: "font-semibold mb-2",
|
|
3228
|
-
children: tableSpec.title
|
|
3229
|
-
}),
|
|
3230
|
-
tableSpec.description && /* @__PURE__ */ jsx39("p", {
|
|
3231
|
-
className: "text-sm text-gray-600 mb-4",
|
|
3232
|
-
children: tableSpec.description
|
|
3233
|
-
}),
|
|
3234
|
-
/* @__PURE__ */ jsx39(TableRenderer, {
|
|
3235
|
-
...tableSpec.props
|
|
3236
|
-
})
|
|
3237
|
-
]
|
|
3238
|
-
})
|
|
3239
|
-
});
|
|
3240
|
-
}
|
|
3241
|
-
}
|
|
3242
|
-
if (spec.type === "markdown") {
|
|
3243
|
-
const markdownSpec = spec;
|
|
3244
|
-
if (registry.has("markdown")) {
|
|
3245
|
-
const MarkdownRenderer = registry.get("markdown");
|
|
3246
|
-
return /* @__PURE__ */ jsx39(UIErrorBoundary, {
|
|
3247
|
-
onError,
|
|
3248
|
-
children: /* @__PURE__ */ jsx39("div", {
|
|
3249
|
-
className,
|
|
3250
|
-
children: /* @__PURE__ */ jsx39(MarkdownRenderer, {
|
|
3251
|
-
...markdownSpec.props
|
|
3252
|
-
})
|
|
3253
|
-
})
|
|
3254
|
-
});
|
|
3255
|
-
}
|
|
3256
|
-
return /* @__PURE__ */ jsx39("div", {
|
|
3257
|
-
className,
|
|
3258
|
-
children: markdownSpec.props.content
|
|
3259
|
-
});
|
|
3260
|
-
}
|
|
3261
|
-
if (spec.type === "artifact") {
|
|
3262
|
-
const artifactSpec = spec;
|
|
3263
|
-
return /* @__PURE__ */ jsx39(UIErrorBoundary, {
|
|
3264
|
-
onError,
|
|
3265
|
-
children: /* @__PURE__ */ jsxs22("div", {
|
|
3266
|
-
className: `p-4 border rounded-md ${className || ""}`,
|
|
3267
|
-
children: [
|
|
3268
|
-
artifactSpec.title && /* @__PURE__ */ jsx39("h3", {
|
|
3269
|
-
className: "font-semibold mb-4",
|
|
3270
|
-
children: artifactSpec.title
|
|
3271
|
-
}),
|
|
3272
|
-
artifactSpec.description && /* @__PURE__ */ jsx39("p", {
|
|
3273
|
-
className: "text-sm text-gray-600 mb-4",
|
|
3274
|
-
children: artifactSpec.description
|
|
3275
|
-
}),
|
|
3276
|
-
/* @__PURE__ */ jsx39("div", {
|
|
3277
|
-
className: "space-y-4",
|
|
3278
|
-
children: artifactSpec.props.content?.map((childSpec, index) => /* @__PURE__ */ jsx39(GenerativeUIRenderer, {
|
|
3279
|
-
spec: childSpec,
|
|
3280
|
-
onError
|
|
3281
|
-
}, index))
|
|
3282
|
-
})
|
|
3283
|
-
]
|
|
3284
|
-
})
|
|
3285
|
-
});
|
|
3286
|
-
}
|
|
3287
|
-
return /* @__PURE__ */ jsxs22("div", {
|
|
3288
|
-
className: `p-4 border border-gray-300 rounded-md ${className || ""}`,
|
|
3289
|
-
children: [
|
|
3290
|
-
/* @__PURE__ */ jsx39("p", {
|
|
3291
|
-
className: "font-semibold",
|
|
3292
|
-
children: "Unsupported UI component"
|
|
3293
|
-
}),
|
|
3294
|
-
/* @__PURE__ */ jsxs22("p", {
|
|
3295
|
-
className: "text-sm text-gray-600 mt-1",
|
|
3296
|
-
children: [
|
|
3297
|
-
"Component type: ",
|
|
3298
|
-
spec.type
|
|
3299
|
-
]
|
|
3300
|
-
})
|
|
3301
|
-
]
|
|
3302
|
-
});
|
|
3303
|
-
}
|
|
3304
|
-
|
|
3305
3019
|
// src/ui/composed/agno-chat/tool-building-blocks.tsx
|
|
3306
|
-
import { jsx as
|
|
3020
|
+
import { jsx as jsx37, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
3307
3021
|
var getToolState = (tool) => tool.tool_call_error ? "output-error" : "output-available";
|
|
3308
3022
|
function ToolDebugCard({ tool, defaultOpen }) {
|
|
3309
3023
|
const output = tool.result ?? tool.content;
|
|
3310
|
-
return /* @__PURE__ */
|
|
3024
|
+
return /* @__PURE__ */ jsxs22(Tool, {
|
|
3311
3025
|
defaultOpen,
|
|
3312
3026
|
children: [
|
|
3313
|
-
/* @__PURE__ */
|
|
3027
|
+
/* @__PURE__ */ jsx37(ToolHeader, {
|
|
3314
3028
|
title: tool.tool_name,
|
|
3315
3029
|
type: "tool-use",
|
|
3316
3030
|
state: getToolState(tool)
|
|
3317
3031
|
}),
|
|
3318
|
-
/* @__PURE__ */
|
|
3032
|
+
/* @__PURE__ */ jsxs22(ToolContent, {
|
|
3319
3033
|
children: [
|
|
3320
|
-
/* @__PURE__ */
|
|
3034
|
+
/* @__PURE__ */ jsx37(ToolInput, {
|
|
3321
3035
|
input: tool.tool_args
|
|
3322
3036
|
}),
|
|
3323
|
-
output ? /* @__PURE__ */
|
|
3037
|
+
output ? /* @__PURE__ */ jsx37(ToolOutput, {
|
|
3324
3038
|
output,
|
|
3325
3039
|
errorText: tool.tool_call_error ? "Tool execution failed" : undefined
|
|
3326
3040
|
}) : null
|
|
@@ -3329,47 +3043,26 @@ function ToolDebugCard({ tool, defaultOpen }) {
|
|
|
3329
3043
|
]
|
|
3330
3044
|
});
|
|
3331
3045
|
}
|
|
3332
|
-
function ToolGenerativeUI({ tool }) {
|
|
3333
|
-
const uiComponent = tool.ui_component;
|
|
3334
|
-
if (!uiComponent)
|
|
3335
|
-
return null;
|
|
3336
|
-
return uiComponent.layout === "artifact" ? /* @__PURE__ */ jsx40(Artifact, {
|
|
3337
|
-
children: /* @__PURE__ */ jsx40(GenerativeUIRenderer, {
|
|
3338
|
-
spec: uiComponent,
|
|
3339
|
-
className: "w-full p-2"
|
|
3340
|
-
})
|
|
3341
|
-
}) : /* @__PURE__ */ jsx40(GenerativeUIRenderer, {
|
|
3342
|
-
spec: uiComponent,
|
|
3343
|
-
className: "w-full"
|
|
3344
|
-
});
|
|
3345
|
-
}
|
|
3346
3046
|
|
|
3347
3047
|
// src/ui/composed/agno-message/tools.tsx
|
|
3348
|
-
import { jsx as
|
|
3048
|
+
import { jsx as jsx38 } from "react/jsx-runtime";
|
|
3349
3049
|
function AgnoMessageTools({ renderTool: renderToolProp } = {}) {
|
|
3350
3050
|
const { message, classNames, renderTool: ctxMsgRenderTool } = useAgnoMessageContext();
|
|
3351
3051
|
const { renderTool: ctxChatRenderTool, isDebug } = useAgnoChatContext();
|
|
3352
3052
|
const renderTool = renderToolProp ?? ctxMsgRenderTool ?? ctxChatRenderTool;
|
|
3353
3053
|
if (!message.tool_calls || message.tool_calls.length === 0)
|
|
3354
3054
|
return null;
|
|
3355
|
-
return /* @__PURE__ */
|
|
3055
|
+
return /* @__PURE__ */ jsx38("div", {
|
|
3356
3056
|
className: cn("space-y-2 pt-1", classNames?.assistant?.toolCalls),
|
|
3357
3057
|
children: message.tool_calls.map((tool, idx) => {
|
|
3358
|
-
const defaultRender = () => /* @__PURE__ */
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
}),
|
|
3363
|
-
isDebug ? /* @__PURE__ */ jsx41(ToolDebugCard, {
|
|
3364
|
-
tool,
|
|
3365
|
-
defaultOpen: idx === 0
|
|
3366
|
-
}) : null
|
|
3367
|
-
]
|
|
3368
|
-
});
|
|
3058
|
+
const defaultRender = () => isDebug ? /* @__PURE__ */ jsx38(ToolDebugCard, {
|
|
3059
|
+
tool,
|
|
3060
|
+
defaultOpen: idx === 0
|
|
3061
|
+
}) : null;
|
|
3369
3062
|
const node = renderTool ? renderTool(tool, { index: idx, isDebug, defaultRender }) : defaultRender();
|
|
3370
3063
|
if (node === null || node === undefined)
|
|
3371
3064
|
return null;
|
|
3372
|
-
return /* @__PURE__ */
|
|
3065
|
+
return /* @__PURE__ */ jsx38("div", {
|
|
3373
3066
|
children: node
|
|
3374
3067
|
}, tool.tool_call_id || idx);
|
|
3375
3068
|
})
|
|
@@ -3377,14 +3070,14 @@ function AgnoMessageTools({ renderTool: renderToolProp } = {}) {
|
|
|
3377
3070
|
}
|
|
3378
3071
|
|
|
3379
3072
|
// src/ui/composed/agno-message/content.tsx
|
|
3380
|
-
import { jsx as
|
|
3073
|
+
import { jsx as jsx39 } from "react/jsx-runtime";
|
|
3381
3074
|
function AgnoMessageContent() {
|
|
3382
3075
|
const { message } = useAgnoMessageContext();
|
|
3383
3076
|
if (!message.content)
|
|
3384
3077
|
return null;
|
|
3385
|
-
return /* @__PURE__ */
|
|
3078
|
+
return /* @__PURE__ */ jsx39("div", {
|
|
3386
3079
|
className: "prose prose-sm dark:prose-invert max-w-none prose-p:leading-relaxed prose-pre:bg-muted prose-pre:border prose-pre:border-border",
|
|
3387
|
-
children: /* @__PURE__ */
|
|
3080
|
+
children: /* @__PURE__ */ jsx39(Response, {
|
|
3388
3081
|
children: message.content
|
|
3389
3082
|
})
|
|
3390
3083
|
});
|
|
@@ -3392,19 +3085,19 @@ function AgnoMessageContent() {
|
|
|
3392
3085
|
|
|
3393
3086
|
// src/ui/composed/agno-message/references.tsx
|
|
3394
3087
|
import { FileText } from "lucide-react";
|
|
3395
|
-
import { jsx as
|
|
3088
|
+
import { jsx as jsx40, jsxs as jsxs23 } from "react/jsx-runtime";
|
|
3396
3089
|
function AgnoMessageReferences() {
|
|
3397
3090
|
const { message, classNames } = useAgnoMessageContext();
|
|
3398
3091
|
const references = message.extra_data?.references;
|
|
3399
3092
|
if (!references || references.length === 0)
|
|
3400
3093
|
return null;
|
|
3401
|
-
return /* @__PURE__ */
|
|
3094
|
+
return /* @__PURE__ */ jsxs23("div", {
|
|
3402
3095
|
className: cn("space-y-2 pt-1", classNames?.assistant?.references),
|
|
3403
3096
|
children: [
|
|
3404
|
-
/* @__PURE__ */
|
|
3097
|
+
/* @__PURE__ */ jsxs23("div", {
|
|
3405
3098
|
className: "flex items-center gap-2 text-xs font-medium text-muted-foreground",
|
|
3406
3099
|
children: [
|
|
3407
|
-
/* @__PURE__ */
|
|
3100
|
+
/* @__PURE__ */ jsx40(FileText, {
|
|
3408
3101
|
className: "h-3.5 w-3.5"
|
|
3409
3102
|
}),
|
|
3410
3103
|
"References (",
|
|
@@ -3412,22 +3105,22 @@ function AgnoMessageReferences() {
|
|
|
3412
3105
|
")"
|
|
3413
3106
|
]
|
|
3414
3107
|
}),
|
|
3415
|
-
/* @__PURE__ */
|
|
3108
|
+
/* @__PURE__ */ jsx40("div", {
|
|
3416
3109
|
className: "space-y-2",
|
|
3417
|
-
children: references.map((refData, idx) => /* @__PURE__ */
|
|
3110
|
+
children: references.map((refData, idx) => /* @__PURE__ */ jsxs23("div", {
|
|
3418
3111
|
className: "text-xs space-y-1.5",
|
|
3419
3112
|
children: [
|
|
3420
|
-
refData.query && /* @__PURE__ */
|
|
3113
|
+
refData.query && /* @__PURE__ */ jsxs23("div", {
|
|
3421
3114
|
className: "font-medium text-foreground",
|
|
3422
3115
|
children: [
|
|
3423
3116
|
"Query: ",
|
|
3424
3117
|
refData.query
|
|
3425
3118
|
]
|
|
3426
3119
|
}),
|
|
3427
|
-
refData.references.map((ref, refIdx) => /* @__PURE__ */
|
|
3120
|
+
refData.references.map((ref, refIdx) => /* @__PURE__ */ jsxs23("div", {
|
|
3428
3121
|
className: "bg-muted/50 border border-border p-2.5 rounded-lg",
|
|
3429
3122
|
children: [
|
|
3430
|
-
/* @__PURE__ */
|
|
3123
|
+
/* @__PURE__ */ jsxs23("div", {
|
|
3431
3124
|
className: "italic text-muted-foreground mb-1",
|
|
3432
3125
|
children: [
|
|
3433
3126
|
'"',
|
|
@@ -3435,7 +3128,7 @@ function AgnoMessageReferences() {
|
|
|
3435
3128
|
'"'
|
|
3436
3129
|
]
|
|
3437
3130
|
}),
|
|
3438
|
-
/* @__PURE__ */
|
|
3131
|
+
/* @__PURE__ */ jsxs23("div", {
|
|
3439
3132
|
className: "text-muted-foreground/70",
|
|
3440
3133
|
children: [
|
|
3441
3134
|
"Source: ",
|
|
@@ -3458,7 +3151,7 @@ function AgnoMessageReferences() {
|
|
|
3458
3151
|
|
|
3459
3152
|
// src/ui/composed/agno-message/footer.tsx
|
|
3460
3153
|
import { AlertCircle } from "lucide-react";
|
|
3461
|
-
import { jsx as
|
|
3154
|
+
import { jsx as jsx41, jsxs as jsxs24 } from "react/jsx-runtime";
|
|
3462
3155
|
function AgnoMessageFooter({ showTimestamp = true } = {}) {
|
|
3463
3156
|
const { message, classNames, actions, isLastAssistantMessage, formatTimestamp } = useAgnoMessageContext();
|
|
3464
3157
|
const hasError = message.streamingError;
|
|
@@ -3466,7 +3159,7 @@ function AgnoMessageFooter({ showTimestamp = true } = {}) {
|
|
|
3466
3159
|
const resolvedFormatTimestamp = formatTimestamp ?? formatSmartTimestamp;
|
|
3467
3160
|
if (!actions?.assistant && !showTimestamp && !hasError)
|
|
3468
3161
|
return null;
|
|
3469
|
-
return /* @__PURE__ */
|
|
3162
|
+
return /* @__PURE__ */ jsxs24("div", {
|
|
3470
3163
|
className: "flex items-center gap-2 pt-1",
|
|
3471
3164
|
children: [
|
|
3472
3165
|
actions?.assistant && (() => {
|
|
@@ -3474,21 +3167,21 @@ function AgnoMessageFooter({ showTimestamp = true } = {}) {
|
|
|
3474
3167
|
if (visibility === "last-assistant" && !isLastAssistantMessage)
|
|
3475
3168
|
return null;
|
|
3476
3169
|
const useHover = visibility === "hover" || visibility === "hover-last-visible" && !isLastAssistantMessage;
|
|
3477
|
-
return /* @__PURE__ */
|
|
3170
|
+
return /* @__PURE__ */ jsx41("div", {
|
|
3478
3171
|
className: cn("flex items-center gap-1 transition-opacity", useHover && "opacity-0 group-hover/message:opacity-100", classNames?.assistant?.actions),
|
|
3479
3172
|
children: actions.assistant(message)
|
|
3480
3173
|
});
|
|
3481
3174
|
})(),
|
|
3482
|
-
hasError && /* @__PURE__ */
|
|
3175
|
+
hasError && /* @__PURE__ */ jsxs24("span", {
|
|
3483
3176
|
className: "flex items-center gap-1 text-[11px] text-destructive",
|
|
3484
3177
|
children: [
|
|
3485
|
-
/* @__PURE__ */
|
|
3178
|
+
/* @__PURE__ */ jsx41(AlertCircle, {
|
|
3486
3179
|
className: "h-3 w-3"
|
|
3487
3180
|
}),
|
|
3488
3181
|
"Error"
|
|
3489
3182
|
]
|
|
3490
3183
|
}),
|
|
3491
|
-
showTimestamp && /* @__PURE__ */
|
|
3184
|
+
showTimestamp && /* @__PURE__ */ jsx41(SmartTimestamp, {
|
|
3492
3185
|
date: new Date(message.created_at * 1000),
|
|
3493
3186
|
formatShort: isCustomTimestamp ? resolvedFormatTimestamp : undefined,
|
|
3494
3187
|
className: "text-[11px] text-muted-foreground"
|
|
@@ -3498,16 +3191,16 @@ function AgnoMessageFooter({ showTimestamp = true } = {}) {
|
|
|
3498
3191
|
}
|
|
3499
3192
|
|
|
3500
3193
|
// src/ui/composed/agno-message/message.tsx
|
|
3501
|
-
import { jsx as
|
|
3194
|
+
import { jsx as jsx42, jsxs as jsxs25, Fragment as Fragment6 } from "react/jsx-runtime";
|
|
3502
3195
|
function DefaultAssistantComposition({ showTimestamp }) {
|
|
3503
|
-
return /* @__PURE__ */
|
|
3196
|
+
return /* @__PURE__ */ jsxs25(Fragment6, {
|
|
3504
3197
|
children: [
|
|
3505
|
-
/* @__PURE__ */
|
|
3506
|
-
/* @__PURE__ */
|
|
3507
|
-
/* @__PURE__ */
|
|
3508
|
-
/* @__PURE__ */
|
|
3509
|
-
/* @__PURE__ */
|
|
3510
|
-
/* @__PURE__ */
|
|
3198
|
+
/* @__PURE__ */ jsx42(AgnoMessageReasoning, {}),
|
|
3199
|
+
/* @__PURE__ */ jsx42(AgnoMessageMedia, {}),
|
|
3200
|
+
/* @__PURE__ */ jsx42(AgnoMessageTools, {}),
|
|
3201
|
+
/* @__PURE__ */ jsx42(AgnoMessageContent, {}),
|
|
3202
|
+
/* @__PURE__ */ jsx42(AgnoMessageReferences, {}),
|
|
3203
|
+
/* @__PURE__ */ jsx42(AgnoMessageFooter, {
|
|
3511
3204
|
showTimestamp
|
|
3512
3205
|
})
|
|
3513
3206
|
]
|
|
@@ -3529,10 +3222,10 @@ function AgnoMessage({
|
|
|
3529
3222
|
}) {
|
|
3530
3223
|
const isUser = message.role === "user";
|
|
3531
3224
|
const hasError = message.streamingError;
|
|
3532
|
-
const [preview, setPreview] =
|
|
3225
|
+
const [preview, setPreview] = useState8(null);
|
|
3533
3226
|
const isCustomTimestamp = !!formatTimestamp;
|
|
3534
3227
|
const resolvedFormatTimestamp = formatTimestamp ?? formatSmartTimestamp;
|
|
3535
|
-
const ctx =
|
|
3228
|
+
const ctx = useMemo3(() => ({
|
|
3536
3229
|
message,
|
|
3537
3230
|
isLastAssistantMessage,
|
|
3538
3231
|
classNames,
|
|
@@ -3564,12 +3257,12 @@ function AgnoMessage({
|
|
|
3564
3257
|
renderTool
|
|
3565
3258
|
]);
|
|
3566
3259
|
const closePreview = () => setPreview(null);
|
|
3567
|
-
return /* @__PURE__ */
|
|
3260
|
+
return /* @__PURE__ */ jsx42(AgnoMessageContext.Provider, {
|
|
3568
3261
|
value: ctx,
|
|
3569
|
-
children: /* @__PURE__ */
|
|
3262
|
+
children: /* @__PURE__ */ jsxs25("div", {
|
|
3570
3263
|
className: cn("py-5 first:pt-2", isUser ? "flex justify-end" : "", classNames?.root, className),
|
|
3571
3264
|
children: [
|
|
3572
|
-
isUser ? /* @__PURE__ */
|
|
3265
|
+
isUser ? /* @__PURE__ */ jsx42(UserMessageLayout, {
|
|
3573
3266
|
message,
|
|
3574
3267
|
classNames,
|
|
3575
3268
|
avatars,
|
|
@@ -3582,19 +3275,19 @@ function AgnoMessage({
|
|
|
3582
3275
|
openImageLightbox: ctx.openImageLightbox,
|
|
3583
3276
|
openFilePreview: ctx.openFilePreview,
|
|
3584
3277
|
hasError
|
|
3585
|
-
}) : /* @__PURE__ */
|
|
3278
|
+
}) : /* @__PURE__ */ jsxs25("div", {
|
|
3586
3279
|
className: "flex items-start gap-3 group/message",
|
|
3587
3280
|
children: [
|
|
3588
3281
|
avatars?.assistant,
|
|
3589
|
-
/* @__PURE__ */
|
|
3282
|
+
/* @__PURE__ */ jsx42("div", {
|
|
3590
3283
|
className: cn("flex-1 min-w-0 space-y-3", classNames?.assistant?.container),
|
|
3591
|
-
children: children ?? /* @__PURE__ */
|
|
3284
|
+
children: children ?? /* @__PURE__ */ jsx42(DefaultAssistantComposition, {
|
|
3592
3285
|
showTimestamp
|
|
3593
3286
|
})
|
|
3594
3287
|
})
|
|
3595
3288
|
]
|
|
3596
3289
|
}),
|
|
3597
|
-
preview?.type === "image" && /* @__PURE__ */
|
|
3290
|
+
preview?.type === "image" && /* @__PURE__ */ jsx42(ImageLightbox, {
|
|
3598
3291
|
open: true,
|
|
3599
3292
|
onOpenChange: (open) => {
|
|
3600
3293
|
if (!open)
|
|
@@ -3603,7 +3296,7 @@ function AgnoMessage({
|
|
|
3603
3296
|
images: preview.images,
|
|
3604
3297
|
initialIndex: preview.initialIndex
|
|
3605
3298
|
}),
|
|
3606
|
-
preview?.type === "file" && /* @__PURE__ */
|
|
3299
|
+
preview?.type === "file" && /* @__PURE__ */ jsx42(FilePreviewModal, {
|
|
3607
3300
|
open: true,
|
|
3608
3301
|
onOpenChange: (open) => {
|
|
3609
3302
|
if (!open)
|
|
@@ -3635,42 +3328,42 @@ function UserMessageLayout({
|
|
|
3635
3328
|
openFilePreview,
|
|
3636
3329
|
hasError
|
|
3637
3330
|
}) {
|
|
3638
|
-
return /* @__PURE__ */
|
|
3331
|
+
return /* @__PURE__ */ jsxs25("div", {
|
|
3639
3332
|
className: "flex items-start gap-2.5 max-w-[80%] flex-row-reverse",
|
|
3640
3333
|
children: [
|
|
3641
3334
|
avatars?.user,
|
|
3642
|
-
/* @__PURE__ */
|
|
3335
|
+
/* @__PURE__ */ jsxs25("div", {
|
|
3643
3336
|
className: "space-y-1.5 flex flex-col items-end min-w-0",
|
|
3644
3337
|
children: [
|
|
3645
|
-
(message.images && message.images.length > 0 || message.audio && message.audio.length > 0 || message.files && message.files.length > 0) && /* @__PURE__ */
|
|
3338
|
+
(message.images && message.images.length > 0 || message.audio && message.audio.length > 0 || message.files && message.files.length > 0) && /* @__PURE__ */ jsxs25("div", {
|
|
3646
3339
|
className: "flex flex-wrap gap-2 justify-end",
|
|
3647
3340
|
children: [
|
|
3648
|
-
message.images?.map((img, idx) => /* @__PURE__ */
|
|
3341
|
+
message.images?.map((img, idx) => /* @__PURE__ */ jsx42(FilePreviewCard, {
|
|
3649
3342
|
file: { name: img.revised_prompt || `Image ${idx + 1}`, type: "image/png", url: img.url },
|
|
3650
3343
|
onClick: showImageLightbox ? () => openImageLightbox(message.images.map((i) => ({ url: i.url, alt: i.revised_prompt })), idx) : undefined
|
|
3651
3344
|
}, `img-${idx}`)),
|
|
3652
|
-
message.audio?.map((audio, idx) => /* @__PURE__ */
|
|
3345
|
+
message.audio?.map((audio, idx) => /* @__PURE__ */ jsxs25("div", {
|
|
3653
3346
|
className: "flex items-center gap-1.5 rounded-lg border border-border bg-muted/50 px-2.5 py-1.5 text-xs text-foreground self-end",
|
|
3654
3347
|
children: [
|
|
3655
|
-
/* @__PURE__ */
|
|
3348
|
+
/* @__PURE__ */ jsx42(Music2, {
|
|
3656
3349
|
className: "h-3.5 w-3.5 text-muted-foreground"
|
|
3657
3350
|
}),
|
|
3658
|
-
/* @__PURE__ */
|
|
3351
|
+
/* @__PURE__ */ jsx42("span", {
|
|
3659
3352
|
className: "truncate max-w-[150px]",
|
|
3660
3353
|
children: audio.id || `Audio ${idx + 1}`
|
|
3661
3354
|
})
|
|
3662
3355
|
]
|
|
3663
3356
|
}, `audio-${idx}`)),
|
|
3664
|
-
message.files?.map((file, idx) => showFilePreview ? /* @__PURE__ */
|
|
3357
|
+
message.files?.map((file, idx) => showFilePreview ? /* @__PURE__ */ jsx42(FilePreviewCard, {
|
|
3665
3358
|
file: { name: file.name, type: file.type, url: file.url, size: file.size },
|
|
3666
3359
|
onClick: () => openFilePreview({ name: file.name, type: file.type, url: file.url, size: file.size })
|
|
3667
|
-
}, `file-${idx}`) : /* @__PURE__ */
|
|
3360
|
+
}, `file-${idx}`) : /* @__PURE__ */ jsxs25("div", {
|
|
3668
3361
|
className: "flex items-center gap-1.5 rounded-lg border border-border bg-muted/50 px-2.5 py-1.5 text-xs text-foreground self-end",
|
|
3669
3362
|
children: [
|
|
3670
|
-
/* @__PURE__ */
|
|
3363
|
+
/* @__PURE__ */ jsx42(FileIcon4, {
|
|
3671
3364
|
className: "h-3.5 w-3.5 text-muted-foreground"
|
|
3672
3365
|
}),
|
|
3673
|
-
/* @__PURE__ */
|
|
3366
|
+
/* @__PURE__ */ jsx42("span", {
|
|
3674
3367
|
className: "truncate max-w-[150px]",
|
|
3675
3368
|
children: file.name
|
|
3676
3369
|
})
|
|
@@ -3678,26 +3371,26 @@ function UserMessageLayout({
|
|
|
3678
3371
|
}, `file-${idx}`))
|
|
3679
3372
|
]
|
|
3680
3373
|
}),
|
|
3681
|
-
message.content && /* @__PURE__ */
|
|
3374
|
+
message.content && /* @__PURE__ */ jsx42("div", {
|
|
3682
3375
|
className: cn("rounded-2xl rounded-br-md px-4 py-2.5", classNames?.user?.bubble ?? "bg-primary text-primary-foreground", hasError && "opacity-70"),
|
|
3683
|
-
children: /* @__PURE__ */
|
|
3376
|
+
children: /* @__PURE__ */ jsx42("p", {
|
|
3684
3377
|
className: "text-sm whitespace-pre-wrap",
|
|
3685
3378
|
children: message.content
|
|
3686
3379
|
})
|
|
3687
3380
|
}),
|
|
3688
|
-
(showTimestamp || actions?.user) && /* @__PURE__ */
|
|
3381
|
+
(showTimestamp || actions?.user) && /* @__PURE__ */ jsxs25("div", {
|
|
3689
3382
|
className: "flex items-center justify-end gap-1.5 px-1",
|
|
3690
3383
|
children: [
|
|
3691
|
-
actions?.user && /* @__PURE__ */
|
|
3384
|
+
actions?.user && /* @__PURE__ */ jsx42("div", {
|
|
3692
3385
|
className: "flex items-center gap-1",
|
|
3693
3386
|
children: actions.user(message)
|
|
3694
3387
|
}),
|
|
3695
|
-
/* @__PURE__ */
|
|
3388
|
+
/* @__PURE__ */ jsx42(SmartTimestamp, {
|
|
3696
3389
|
date: new Date(message.created_at * 1000),
|
|
3697
3390
|
formatShort: isCustomTimestamp ? resolvedFormatTimestamp : undefined,
|
|
3698
3391
|
className: "text-[11px] text-muted-foreground"
|
|
3699
3392
|
}),
|
|
3700
|
-
hasError && /* @__PURE__ */
|
|
3393
|
+
hasError && /* @__PURE__ */ jsx42(AlertCircle2, {
|
|
3701
3394
|
className: "h-3 w-3 text-destructive"
|
|
3702
3395
|
})
|
|
3703
3396
|
]
|
|
@@ -3709,7 +3402,7 @@ function UserMessageLayout({
|
|
|
3709
3402
|
}
|
|
3710
3403
|
|
|
3711
3404
|
// src/ui/composed/AgnoMessageItem.tsx
|
|
3712
|
-
import { jsx as
|
|
3405
|
+
import { jsx as jsx43, jsxs as jsxs26 } from "react/jsx-runtime";
|
|
3713
3406
|
function AgnoMessageItem({
|
|
3714
3407
|
message,
|
|
3715
3408
|
className,
|
|
@@ -3725,7 +3418,7 @@ function AgnoMessageItem({
|
|
|
3725
3418
|
formatTimestamp,
|
|
3726
3419
|
renderTool
|
|
3727
3420
|
}) {
|
|
3728
|
-
return /* @__PURE__ */
|
|
3421
|
+
return /* @__PURE__ */ jsxs26(AgnoMessage, {
|
|
3729
3422
|
message,
|
|
3730
3423
|
className,
|
|
3731
3424
|
classNames,
|
|
@@ -3738,12 +3431,12 @@ function AgnoMessageItem({
|
|
|
3738
3431
|
formatTimestamp,
|
|
3739
3432
|
renderTool,
|
|
3740
3433
|
children: [
|
|
3741
|
-
showReasoning && /* @__PURE__ */
|
|
3742
|
-
/* @__PURE__ */
|
|
3743
|
-
/* @__PURE__ */
|
|
3744
|
-
/* @__PURE__ */
|
|
3745
|
-
showReferences && /* @__PURE__ */
|
|
3746
|
-
/* @__PURE__ */
|
|
3434
|
+
showReasoning && /* @__PURE__ */ jsx43(AgnoMessage.Reasoning, {}),
|
|
3435
|
+
/* @__PURE__ */ jsx43(AgnoMessage.Media, {}),
|
|
3436
|
+
/* @__PURE__ */ jsx43(AgnoMessage.Tools, {}),
|
|
3437
|
+
/* @__PURE__ */ jsx43(AgnoMessage.Content, {}),
|
|
3438
|
+
showReferences && /* @__PURE__ */ jsx43(AgnoMessage.References, {}),
|
|
3439
|
+
/* @__PURE__ */ jsx43(AgnoMessage.Footer, {
|
|
3747
3440
|
showTimestamp
|
|
3748
3441
|
})
|
|
3749
3442
|
]
|
|
@@ -3751,7 +3444,7 @@ function AgnoMessageItem({
|
|
|
3751
3444
|
}
|
|
3752
3445
|
// src/ui/composed/AgnoChatInput.tsx
|
|
3753
3446
|
import { CircleStop } from "lucide-react";
|
|
3754
|
-
import { jsx as
|
|
3447
|
+
import { jsx as jsx44, jsxs as jsxs27 } from "react/jsx-runtime";
|
|
3755
3448
|
var DEFAULT_ACCEPTED_FILE_TYPES = "image/*,audio/*,.pdf,.doc,.docx,.txt,.csv,.xlsx,.xls,.ppt,.pptx,.md,.json,.xml";
|
|
3756
3449
|
function normalizeAudio(audio) {
|
|
3757
3450
|
if (audio === true)
|
|
@@ -3771,14 +3464,14 @@ function dataUrlToBlob(dataUrl) {
|
|
|
3771
3464
|
return new Blob([buf], { type: mime });
|
|
3772
3465
|
}
|
|
3773
3466
|
function CancelButton({ onCancel }) {
|
|
3774
|
-
return /* @__PURE__ */
|
|
3467
|
+
return /* @__PURE__ */ jsx44(Button, {
|
|
3775
3468
|
type: "button",
|
|
3776
3469
|
variant: "destructive",
|
|
3777
3470
|
size: "icon",
|
|
3778
3471
|
className: "h-8 w-8 rounded-lg",
|
|
3779
3472
|
onClick: onCancel,
|
|
3780
3473
|
"aria-label": "Stop",
|
|
3781
|
-
children: /* @__PURE__ */
|
|
3474
|
+
children: /* @__PURE__ */ jsx44(CircleStop, {
|
|
3782
3475
|
className: "size-4"
|
|
3783
3476
|
})
|
|
3784
3477
|
});
|
|
@@ -3786,7 +3479,7 @@ function CancelButton({ onCancel }) {
|
|
|
3786
3479
|
function SubmitButton({ disabled, status }) {
|
|
3787
3480
|
const { textInput } = usePromptInputController();
|
|
3788
3481
|
const hasText = textInput.value.trim().length > 0;
|
|
3789
|
-
return /* @__PURE__ */
|
|
3482
|
+
return /* @__PURE__ */ jsx44(PromptInputSubmit, {
|
|
3790
3483
|
disabled: disabled || !hasText,
|
|
3791
3484
|
status
|
|
3792
3485
|
});
|
|
@@ -3795,9 +3488,9 @@ function AttachmentHeader() {
|
|
|
3795
3488
|
const { files } = usePromptInputAttachments();
|
|
3796
3489
|
if (files.length === 0)
|
|
3797
3490
|
return null;
|
|
3798
|
-
return /* @__PURE__ */
|
|
3799
|
-
children: /* @__PURE__ */
|
|
3800
|
-
children: (attachment) => /* @__PURE__ */
|
|
3491
|
+
return /* @__PURE__ */ jsx44(PromptInputHeader, {
|
|
3492
|
+
children: /* @__PURE__ */ jsx44(PromptInputAttachments, {
|
|
3493
|
+
children: (attachment) => /* @__PURE__ */ jsx44(PromptInputAttachment, {
|
|
3801
3494
|
data: attachment
|
|
3802
3495
|
})
|
|
3803
3496
|
})
|
|
@@ -3812,7 +3505,7 @@ function TranscribeAudioRecorder({
|
|
|
3812
3505
|
labels
|
|
3813
3506
|
}) {
|
|
3814
3507
|
const { textInput } = usePromptInputController();
|
|
3815
|
-
return /* @__PURE__ */
|
|
3508
|
+
return /* @__PURE__ */ jsx44(AudioRecorder, {
|
|
3816
3509
|
mode: "transcribe",
|
|
3817
3510
|
transcriptionEndpoint: endpoint,
|
|
3818
3511
|
transcriptionHeaders: headers,
|
|
@@ -3876,8 +3569,8 @@ function AgnoChatInput({
|
|
|
3876
3569
|
};
|
|
3877
3570
|
const computedStatus = status ?? (disabled ? "submitted" : undefined);
|
|
3878
3571
|
const showCancelButton = allowCancelRun && isStreaming && onCancel;
|
|
3879
|
-
return /* @__PURE__ */
|
|
3880
|
-
children: /* @__PURE__ */
|
|
3572
|
+
return /* @__PURE__ */ jsx44(PromptInputProvider, {
|
|
3573
|
+
children: /* @__PURE__ */ jsxs27(PromptInput, {
|
|
3881
3574
|
onSubmit: handleSubmit,
|
|
3882
3575
|
accept: fileUpload?.accept ?? DEFAULT_ACCEPTED_FILE_TYPES,
|
|
3883
3576
|
multiple: fileUpload?.multiple ?? true,
|
|
@@ -3887,35 +3580,35 @@ function AgnoChatInput({
|
|
|
3887
3580
|
dragListenerTarget: dropZoneContainerRef,
|
|
3888
3581
|
className: cn("w-full", className),
|
|
3889
3582
|
children: [
|
|
3890
|
-
/* @__PURE__ */
|
|
3891
|
-
/* @__PURE__ */
|
|
3892
|
-
children: /* @__PURE__ */
|
|
3583
|
+
/* @__PURE__ */ jsx44(AttachmentHeader, {}),
|
|
3584
|
+
/* @__PURE__ */ jsx44(PromptInputBody, {
|
|
3585
|
+
children: /* @__PURE__ */ jsx44(PromptInputTextarea, {
|
|
3893
3586
|
placeholder: placeholder || "Type your message... (Enter to send, Shift+Enter for new line)",
|
|
3894
3587
|
disabled
|
|
3895
3588
|
})
|
|
3896
3589
|
}),
|
|
3897
|
-
/* @__PURE__ */
|
|
3590
|
+
/* @__PURE__ */ jsxs27(PromptInputFooter, {
|
|
3898
3591
|
children: [
|
|
3899
|
-
/* @__PURE__ */
|
|
3592
|
+
/* @__PURE__ */ jsxs27(PromptInputTools, {
|
|
3900
3593
|
children: [
|
|
3901
|
-
showAttachments && /* @__PURE__ */
|
|
3594
|
+
showAttachments && /* @__PURE__ */ jsxs27(PromptInputActionMenu, {
|
|
3902
3595
|
children: [
|
|
3903
|
-
/* @__PURE__ */
|
|
3904
|
-
/* @__PURE__ */
|
|
3905
|
-
children: /* @__PURE__ */
|
|
3596
|
+
/* @__PURE__ */ jsx44(PromptInputActionMenuTrigger, {}),
|
|
3597
|
+
/* @__PURE__ */ jsx44(PromptInputActionMenuContent, {
|
|
3598
|
+
children: /* @__PURE__ */ jsx44(PromptInputActionAddAttachments, {
|
|
3906
3599
|
label: "Add files"
|
|
3907
3600
|
})
|
|
3908
3601
|
})
|
|
3909
3602
|
]
|
|
3910
3603
|
}),
|
|
3911
|
-
audioEnabled && (audioMode === "transcribe" && resolvedAudio?.endpoint ? /* @__PURE__ */
|
|
3604
|
+
audioEnabled && (audioMode === "transcribe" && resolvedAudio?.endpoint ? /* @__PURE__ */ jsx44(TranscribeAudioRecorder, {
|
|
3912
3605
|
endpoint: resolvedAudio.endpoint,
|
|
3913
3606
|
headers: resolvedAudio.headers,
|
|
3914
3607
|
disabled,
|
|
3915
3608
|
parseResponse: resolvedAudio.parseResponse,
|
|
3916
3609
|
onRequestPermission: resolvedAudio.requestPermission,
|
|
3917
3610
|
labels: resolvedAudio.labels
|
|
3918
|
-
}) : /* @__PURE__ */
|
|
3611
|
+
}) : /* @__PURE__ */ jsx44(AudioRecorder, {
|
|
3919
3612
|
onRecordingComplete: handleAudioRecording,
|
|
3920
3613
|
disabled,
|
|
3921
3614
|
onRequestPermission: resolvedAudio?.requestPermission,
|
|
@@ -3924,15 +3617,15 @@ function AgnoChatInput({
|
|
|
3924
3617
|
extraTools
|
|
3925
3618
|
]
|
|
3926
3619
|
}),
|
|
3927
|
-
showCancelButton ? /* @__PURE__ */
|
|
3620
|
+
showCancelButton ? /* @__PURE__ */ jsx44(CancelButton, {
|
|
3928
3621
|
onCancel
|
|
3929
|
-
}) : /* @__PURE__ */
|
|
3622
|
+
}) : /* @__PURE__ */ jsx44(SubmitButton, {
|
|
3930
3623
|
disabled,
|
|
3931
3624
|
status: computedStatus
|
|
3932
3625
|
})
|
|
3933
3626
|
]
|
|
3934
3627
|
}),
|
|
3935
|
-
showAttachments && /* @__PURE__ */
|
|
3628
|
+
showAttachments && /* @__PURE__ */ jsx44(PromptInputDropZone, {
|
|
3936
3629
|
...dropZoneProps,
|
|
3937
3630
|
container: dropZoneContainerRef
|
|
3938
3631
|
})
|
|
@@ -3952,8 +3645,481 @@ function byToolName(map, fallback) {
|
|
|
3952
3645
|
return entry(tool, args);
|
|
3953
3646
|
};
|
|
3954
3647
|
}
|
|
3648
|
+
// src/ui/composed/generative-components/charts.tsx
|
|
3649
|
+
import {
|
|
3650
|
+
BarChart as RechartsBarChart,
|
|
3651
|
+
Bar,
|
|
3652
|
+
LineChart as RechartsLineChart,
|
|
3653
|
+
Line,
|
|
3654
|
+
AreaChart as RechartsAreaChart,
|
|
3655
|
+
Area,
|
|
3656
|
+
PieChart as RechartsPieChart,
|
|
3657
|
+
Pie,
|
|
3658
|
+
Cell,
|
|
3659
|
+
XAxis,
|
|
3660
|
+
YAxis,
|
|
3661
|
+
CartesianGrid,
|
|
3662
|
+
Legend as Legend2
|
|
3663
|
+
} from "recharts";
|
|
3664
|
+
|
|
3665
|
+
// src/ui/components/chart.tsx
|
|
3666
|
+
import * as React11 from "react";
|
|
3667
|
+
import * as RechartsPrimitive from "recharts";
|
|
3668
|
+
import { jsx as jsx45, jsxs as jsxs28, Fragment as Fragment7 } from "react/jsx-runtime";
|
|
3669
|
+
var THEMES = { light: "", dark: ".dark" };
|
|
3670
|
+
var ChartContext = React11.createContext(null);
|
|
3671
|
+
function useChart() {
|
|
3672
|
+
const context = React11.useContext(ChartContext);
|
|
3673
|
+
if (!context) {
|
|
3674
|
+
throw new Error("useChart must be used within a <ChartContainer />");
|
|
3675
|
+
}
|
|
3676
|
+
return context;
|
|
3677
|
+
}
|
|
3678
|
+
var ChartContainer = React11.forwardRef(({ id, className, children, config, ...props }, ref) => {
|
|
3679
|
+
const uniqueId = React11.useId();
|
|
3680
|
+
const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
|
|
3681
|
+
return /* @__PURE__ */ jsx45(ChartContext.Provider, {
|
|
3682
|
+
value: { config },
|
|
3683
|
+
children: /* @__PURE__ */ jsxs28("div", {
|
|
3684
|
+
"data-chart": chartId,
|
|
3685
|
+
ref,
|
|
3686
|
+
className: cn("flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-none [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-sector]:outline-none [&_.recharts-surface]:outline-none", className),
|
|
3687
|
+
...props,
|
|
3688
|
+
children: [
|
|
3689
|
+
/* @__PURE__ */ jsx45(ChartStyle, {
|
|
3690
|
+
id: chartId,
|
|
3691
|
+
config
|
|
3692
|
+
}),
|
|
3693
|
+
/* @__PURE__ */ jsx45(RechartsPrimitive.ResponsiveContainer, {
|
|
3694
|
+
children
|
|
3695
|
+
})
|
|
3696
|
+
]
|
|
3697
|
+
})
|
|
3698
|
+
});
|
|
3699
|
+
});
|
|
3700
|
+
ChartContainer.displayName = "Chart";
|
|
3701
|
+
var ChartStyle = ({ id, config }) => {
|
|
3702
|
+
const colorConfig = Object.entries(config).filter(([, config2]) => config2.theme || config2.color);
|
|
3703
|
+
if (!colorConfig.length) {
|
|
3704
|
+
return null;
|
|
3705
|
+
}
|
|
3706
|
+
return /* @__PURE__ */ jsx45("style", {
|
|
3707
|
+
dangerouslySetInnerHTML: {
|
|
3708
|
+
__html: Object.entries(THEMES).map(([theme, prefix]) => `
|
|
3709
|
+
${prefix} [data-chart=${id}] {
|
|
3710
|
+
${colorConfig.map(([key, itemConfig]) => {
|
|
3711
|
+
const color = itemConfig.theme?.[theme] || itemConfig.color;
|
|
3712
|
+
return color ? ` --color-${key}: ${color};` : null;
|
|
3713
|
+
}).join(`
|
|
3714
|
+
`)}
|
|
3715
|
+
}
|
|
3716
|
+
`).join(`
|
|
3717
|
+
`)
|
|
3718
|
+
}
|
|
3719
|
+
});
|
|
3720
|
+
};
|
|
3721
|
+
var ChartTooltip = RechartsPrimitive.Tooltip;
|
|
3722
|
+
var ChartTooltipContent = React11.forwardRef(({
|
|
3723
|
+
active,
|
|
3724
|
+
payload,
|
|
3725
|
+
className,
|
|
3726
|
+
indicator = "dot",
|
|
3727
|
+
hideLabel = false,
|
|
3728
|
+
hideIndicator = false,
|
|
3729
|
+
label,
|
|
3730
|
+
labelFormatter,
|
|
3731
|
+
labelClassName,
|
|
3732
|
+
formatter,
|
|
3733
|
+
color,
|
|
3734
|
+
nameKey,
|
|
3735
|
+
labelKey
|
|
3736
|
+
}, ref) => {
|
|
3737
|
+
const { config } = useChart();
|
|
3738
|
+
const tooltipLabel = React11.useMemo(() => {
|
|
3739
|
+
if (hideLabel || !payload?.length) {
|
|
3740
|
+
return null;
|
|
3741
|
+
}
|
|
3742
|
+
const [item] = payload;
|
|
3743
|
+
const key = `${labelKey || item?.dataKey || item?.name || "value"}`;
|
|
3744
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
3745
|
+
const value = !labelKey && typeof label === "string" ? config[label]?.label || label : itemConfig?.label;
|
|
3746
|
+
if (labelFormatter) {
|
|
3747
|
+
return /* @__PURE__ */ jsx45("div", {
|
|
3748
|
+
className: cn("font-medium", labelClassName),
|
|
3749
|
+
children: labelFormatter(value, payload)
|
|
3750
|
+
});
|
|
3751
|
+
}
|
|
3752
|
+
if (!value) {
|
|
3753
|
+
return null;
|
|
3754
|
+
}
|
|
3755
|
+
return /* @__PURE__ */ jsx45("div", {
|
|
3756
|
+
className: cn("font-medium", labelClassName),
|
|
3757
|
+
children: value
|
|
3758
|
+
});
|
|
3759
|
+
}, [
|
|
3760
|
+
label,
|
|
3761
|
+
labelFormatter,
|
|
3762
|
+
payload,
|
|
3763
|
+
hideLabel,
|
|
3764
|
+
labelClassName,
|
|
3765
|
+
config,
|
|
3766
|
+
labelKey
|
|
3767
|
+
]);
|
|
3768
|
+
if (!active || !payload?.length) {
|
|
3769
|
+
return null;
|
|
3770
|
+
}
|
|
3771
|
+
const nestLabel = payload.length === 1 && indicator !== "dot";
|
|
3772
|
+
return /* @__PURE__ */ jsxs28("div", {
|
|
3773
|
+
ref,
|
|
3774
|
+
className: cn("grid min-w-[8rem] items-start gap-1.5 rounded-lg border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl", className),
|
|
3775
|
+
children: [
|
|
3776
|
+
!nestLabel ? tooltipLabel : null,
|
|
3777
|
+
/* @__PURE__ */ jsx45("div", {
|
|
3778
|
+
className: "grid gap-1.5",
|
|
3779
|
+
children: payload.filter((item) => item.type !== "none").map((item, index) => {
|
|
3780
|
+
const key = `${nameKey || item.name || item.dataKey || "value"}`;
|
|
3781
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
3782
|
+
const indicatorColor = color || item.payload.fill || item.color;
|
|
3783
|
+
return /* @__PURE__ */ jsx45("div", {
|
|
3784
|
+
className: cn("flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground", indicator === "dot" && "items-center"),
|
|
3785
|
+
children: formatter && item?.value !== undefined && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs28(Fragment7, {
|
|
3786
|
+
children: [
|
|
3787
|
+
itemConfig?.icon ? /* @__PURE__ */ jsx45(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx45("div", {
|
|
3788
|
+
className: cn("shrink-0 rounded-[2px] border-[--color-border] bg-[--color-bg]", {
|
|
3789
|
+
"h-2.5 w-2.5": indicator === "dot",
|
|
3790
|
+
"w-1": indicator === "line",
|
|
3791
|
+
"w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
|
|
3792
|
+
"my-0.5": nestLabel && indicator === "dashed"
|
|
3793
|
+
}),
|
|
3794
|
+
style: {
|
|
3795
|
+
"--color-bg": indicatorColor,
|
|
3796
|
+
"--color-border": indicatorColor
|
|
3797
|
+
}
|
|
3798
|
+
}),
|
|
3799
|
+
/* @__PURE__ */ jsxs28("div", {
|
|
3800
|
+
className: cn("flex flex-1 justify-between leading-none", nestLabel ? "items-end" : "items-center"),
|
|
3801
|
+
children: [
|
|
3802
|
+
/* @__PURE__ */ jsxs28("div", {
|
|
3803
|
+
className: "grid gap-1.5",
|
|
3804
|
+
children: [
|
|
3805
|
+
nestLabel ? tooltipLabel : null,
|
|
3806
|
+
/* @__PURE__ */ jsx45("span", {
|
|
3807
|
+
className: "text-muted-foreground",
|
|
3808
|
+
children: itemConfig?.label || item.name
|
|
3809
|
+
})
|
|
3810
|
+
]
|
|
3811
|
+
}),
|
|
3812
|
+
item.value && /* @__PURE__ */ jsx45("span", {
|
|
3813
|
+
className: "font-mono font-medium tabular-nums text-foreground",
|
|
3814
|
+
children: item.value.toLocaleString()
|
|
3815
|
+
})
|
|
3816
|
+
]
|
|
3817
|
+
})
|
|
3818
|
+
]
|
|
3819
|
+
})
|
|
3820
|
+
}, item.dataKey);
|
|
3821
|
+
})
|
|
3822
|
+
})
|
|
3823
|
+
]
|
|
3824
|
+
});
|
|
3825
|
+
});
|
|
3826
|
+
ChartTooltipContent.displayName = "ChartTooltip";
|
|
3827
|
+
var ChartLegend = RechartsPrimitive.Legend;
|
|
3828
|
+
var ChartLegendContent = React11.forwardRef(({ className, hideIcon = false, payload, verticalAlign = "bottom", nameKey }, ref) => {
|
|
3829
|
+
const { config } = useChart();
|
|
3830
|
+
if (!payload?.length) {
|
|
3831
|
+
return null;
|
|
3832
|
+
}
|
|
3833
|
+
return /* @__PURE__ */ jsx45("div", {
|
|
3834
|
+
ref,
|
|
3835
|
+
className: cn("flex items-center justify-center gap-4", verticalAlign === "top" ? "pb-3" : "pt-3", className),
|
|
3836
|
+
children: payload.filter((item) => item.type !== "none").map((item) => {
|
|
3837
|
+
const key = `${nameKey || item.dataKey || "value"}`;
|
|
3838
|
+
const itemConfig = getPayloadConfigFromPayload(config, item, key);
|
|
3839
|
+
return /* @__PURE__ */ jsxs28("div", {
|
|
3840
|
+
className: cn("flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground"),
|
|
3841
|
+
children: [
|
|
3842
|
+
itemConfig?.icon && !hideIcon ? /* @__PURE__ */ jsx45(itemConfig.icon, {}) : /* @__PURE__ */ jsx45("div", {
|
|
3843
|
+
className: "h-2 w-2 shrink-0 rounded-[2px]",
|
|
3844
|
+
style: {
|
|
3845
|
+
backgroundColor: item.color
|
|
3846
|
+
}
|
|
3847
|
+
}),
|
|
3848
|
+
itemConfig?.label
|
|
3849
|
+
]
|
|
3850
|
+
}, item.value);
|
|
3851
|
+
})
|
|
3852
|
+
});
|
|
3853
|
+
});
|
|
3854
|
+
ChartLegendContent.displayName = "ChartLegend";
|
|
3855
|
+
function getPayloadConfigFromPayload(config, payload, key) {
|
|
3856
|
+
if (typeof payload !== "object" || payload === null) {
|
|
3857
|
+
return;
|
|
3858
|
+
}
|
|
3859
|
+
const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : undefined;
|
|
3860
|
+
let configLabelKey = key;
|
|
3861
|
+
if (key in payload && typeof payload[key] === "string") {
|
|
3862
|
+
configLabelKey = payload[key];
|
|
3863
|
+
} else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
|
|
3864
|
+
configLabelKey = payloadPayload[key];
|
|
3865
|
+
}
|
|
3866
|
+
return configLabelKey in config ? config[configLabelKey] : config[key];
|
|
3867
|
+
}
|
|
3868
|
+
|
|
3869
|
+
// src/ui/composed/generative-components/charts.tsx
|
|
3870
|
+
import { jsx as jsx46, jsxs as jsxs29 } from "react/jsx-runtime";
|
|
3871
|
+
var DEFAULT_COLORS = [
|
|
3872
|
+
"hsl(var(--chart-1))",
|
|
3873
|
+
"hsl(var(--chart-2))",
|
|
3874
|
+
"hsl(var(--chart-3))",
|
|
3875
|
+
"hsl(var(--chart-4))",
|
|
3876
|
+
"hsl(var(--chart-5))"
|
|
3877
|
+
];
|
|
3878
|
+
function generateChartConfig(series = []) {
|
|
3879
|
+
const config = {};
|
|
3880
|
+
series.forEach((item, index) => {
|
|
3881
|
+
config[item.key] = {
|
|
3882
|
+
label: item.label || item.key,
|
|
3883
|
+
color: item.color || DEFAULT_COLORS[index % DEFAULT_COLORS.length]
|
|
3884
|
+
};
|
|
3885
|
+
});
|
|
3886
|
+
return config;
|
|
3887
|
+
}
|
|
3888
|
+
function EmptyState({ message = "No data available" }) {
|
|
3889
|
+
return /* @__PURE__ */ jsx46("div", {
|
|
3890
|
+
className: "flex items-center justify-center h-[350px] border rounded-md bg-muted/10",
|
|
3891
|
+
children: /* @__PURE__ */ jsx46("p", {
|
|
3892
|
+
className: "text-sm text-muted-foreground",
|
|
3893
|
+
children: message
|
|
3894
|
+
})
|
|
3895
|
+
});
|
|
3896
|
+
}
|
|
3897
|
+
function BarChart(props) {
|
|
3898
|
+
const { data, xKey, bars = [], showLegend = true, showGrid = true, height = 350 } = props;
|
|
3899
|
+
if (!data || data.length === 0)
|
|
3900
|
+
return /* @__PURE__ */ jsx46(EmptyState, {});
|
|
3901
|
+
const config = generateChartConfig(bars);
|
|
3902
|
+
return /* @__PURE__ */ jsx46(ChartContainer, {
|
|
3903
|
+
config,
|
|
3904
|
+
className: "h-[350px]",
|
|
3905
|
+
children: /* @__PURE__ */ jsxs29(RechartsBarChart, {
|
|
3906
|
+
data,
|
|
3907
|
+
height,
|
|
3908
|
+
children: [
|
|
3909
|
+
showGrid && /* @__PURE__ */ jsx46(CartesianGrid, {
|
|
3910
|
+
strokeDasharray: "3 3"
|
|
3911
|
+
}),
|
|
3912
|
+
/* @__PURE__ */ jsx46(XAxis, {
|
|
3913
|
+
dataKey: xKey
|
|
3914
|
+
}),
|
|
3915
|
+
/* @__PURE__ */ jsx46(YAxis, {}),
|
|
3916
|
+
/* @__PURE__ */ jsx46(ChartTooltip, {
|
|
3917
|
+
content: /* @__PURE__ */ jsx46(ChartTooltipContent, {})
|
|
3918
|
+
}),
|
|
3919
|
+
showLegend && /* @__PURE__ */ jsx46(Legend2, {}),
|
|
3920
|
+
bars.map((bar) => /* @__PURE__ */ jsx46(Bar, {
|
|
3921
|
+
dataKey: bar.key,
|
|
3922
|
+
fill: bar.color || `var(--color-${bar.key})`,
|
|
3923
|
+
radius: [4, 4, 0, 0]
|
|
3924
|
+
}, bar.key))
|
|
3925
|
+
]
|
|
3926
|
+
})
|
|
3927
|
+
});
|
|
3928
|
+
}
|
|
3929
|
+
function LineChart(props) {
|
|
3930
|
+
const { data, xKey, lines = [], showLegend = true, showGrid = true, height = 350 } = props;
|
|
3931
|
+
if (!data || data.length === 0)
|
|
3932
|
+
return /* @__PURE__ */ jsx46(EmptyState, {});
|
|
3933
|
+
const config = generateChartConfig(lines);
|
|
3934
|
+
return /* @__PURE__ */ jsx46(ChartContainer, {
|
|
3935
|
+
config,
|
|
3936
|
+
className: "h-[350px]",
|
|
3937
|
+
children: /* @__PURE__ */ jsxs29(RechartsLineChart, {
|
|
3938
|
+
data,
|
|
3939
|
+
height,
|
|
3940
|
+
children: [
|
|
3941
|
+
showGrid && /* @__PURE__ */ jsx46(CartesianGrid, {
|
|
3942
|
+
strokeDasharray: "3 3"
|
|
3943
|
+
}),
|
|
3944
|
+
/* @__PURE__ */ jsx46(XAxis, {
|
|
3945
|
+
dataKey: xKey
|
|
3946
|
+
}),
|
|
3947
|
+
/* @__PURE__ */ jsx46(YAxis, {}),
|
|
3948
|
+
/* @__PURE__ */ jsx46(ChartTooltip, {
|
|
3949
|
+
content: /* @__PURE__ */ jsx46(ChartTooltipContent, {})
|
|
3950
|
+
}),
|
|
3951
|
+
showLegend && /* @__PURE__ */ jsx46(Legend2, {}),
|
|
3952
|
+
lines.map((line) => /* @__PURE__ */ jsx46(Line, {
|
|
3953
|
+
type: "monotone",
|
|
3954
|
+
dataKey: line.key,
|
|
3955
|
+
stroke: line.color || `var(--color-${line.key})`,
|
|
3956
|
+
strokeWidth: 2,
|
|
3957
|
+
dot: { r: 4 }
|
|
3958
|
+
}, line.key))
|
|
3959
|
+
]
|
|
3960
|
+
})
|
|
3961
|
+
});
|
|
3962
|
+
}
|
|
3963
|
+
function AreaChart(props) {
|
|
3964
|
+
const { data, xKey, areas = [], showLegend = true, showGrid = true, height = 350 } = props;
|
|
3965
|
+
if (!data || data.length === 0)
|
|
3966
|
+
return /* @__PURE__ */ jsx46(EmptyState, {});
|
|
3967
|
+
const config = generateChartConfig(areas);
|
|
3968
|
+
return /* @__PURE__ */ jsx46(ChartContainer, {
|
|
3969
|
+
config,
|
|
3970
|
+
className: "h-[350px]",
|
|
3971
|
+
children: /* @__PURE__ */ jsxs29(RechartsAreaChart, {
|
|
3972
|
+
data,
|
|
3973
|
+
height,
|
|
3974
|
+
children: [
|
|
3975
|
+
showGrid && /* @__PURE__ */ jsx46(CartesianGrid, {
|
|
3976
|
+
strokeDasharray: "3 3"
|
|
3977
|
+
}),
|
|
3978
|
+
/* @__PURE__ */ jsx46(XAxis, {
|
|
3979
|
+
dataKey: xKey
|
|
3980
|
+
}),
|
|
3981
|
+
/* @__PURE__ */ jsx46(YAxis, {}),
|
|
3982
|
+
/* @__PURE__ */ jsx46(ChartTooltip, {
|
|
3983
|
+
content: /* @__PURE__ */ jsx46(ChartTooltipContent, {})
|
|
3984
|
+
}),
|
|
3985
|
+
showLegend && /* @__PURE__ */ jsx46(Legend2, {}),
|
|
3986
|
+
areas.map((area) => /* @__PURE__ */ jsx46(Area, {
|
|
3987
|
+
type: "monotone",
|
|
3988
|
+
dataKey: area.key,
|
|
3989
|
+
stroke: area.color || `var(--color-${area.key})`,
|
|
3990
|
+
fill: area.color || `var(--color-${area.key})`,
|
|
3991
|
+
fillOpacity: 0.6
|
|
3992
|
+
}, area.key))
|
|
3993
|
+
]
|
|
3994
|
+
})
|
|
3995
|
+
});
|
|
3996
|
+
}
|
|
3997
|
+
function PieChart(props) {
|
|
3998
|
+
const { data, pie, showLegend = true, height = 350 } = props;
|
|
3999
|
+
if (!data || data.length === 0 || !pie)
|
|
4000
|
+
return /* @__PURE__ */ jsx46(EmptyState, {});
|
|
4001
|
+
const nameKey = pie.nameKey || "name";
|
|
4002
|
+
const config = generateChartConfig(data.map((item) => ({
|
|
4003
|
+
key: item[nameKey],
|
|
4004
|
+
label: item[nameKey]
|
|
4005
|
+
})));
|
|
4006
|
+
return /* @__PURE__ */ jsx46(ChartContainer, {
|
|
4007
|
+
config,
|
|
4008
|
+
className: "h-[350px]",
|
|
4009
|
+
children: /* @__PURE__ */ jsxs29(RechartsPieChart, {
|
|
4010
|
+
height,
|
|
4011
|
+
children: [
|
|
4012
|
+
/* @__PURE__ */ jsx46(Pie, {
|
|
4013
|
+
data,
|
|
4014
|
+
dataKey: pie.dataKey,
|
|
4015
|
+
nameKey,
|
|
4016
|
+
cx: "50%",
|
|
4017
|
+
cy: "50%",
|
|
4018
|
+
outerRadius: 100,
|
|
4019
|
+
label: pie.label,
|
|
4020
|
+
children: data.map((_entry, index) => /* @__PURE__ */ jsx46(Cell, {
|
|
4021
|
+
fill: DEFAULT_COLORS[index % DEFAULT_COLORS.length]
|
|
4022
|
+
}, `cell-${index}`))
|
|
4023
|
+
}),
|
|
4024
|
+
/* @__PURE__ */ jsx46(ChartTooltip, {
|
|
4025
|
+
content: /* @__PURE__ */ jsx46(ChartTooltipContent, {})
|
|
4026
|
+
}),
|
|
4027
|
+
showLegend && /* @__PURE__ */ jsx46(Legend2, {})
|
|
4028
|
+
]
|
|
4029
|
+
})
|
|
4030
|
+
});
|
|
4031
|
+
}
|
|
4032
|
+
// src/ui/composed/generative-components/card-grid.tsx
|
|
4033
|
+
import { jsx as jsx47, jsxs as jsxs30 } from "react/jsx-runtime";
|
|
4034
|
+
function CardGrid(props) {
|
|
4035
|
+
const { cards, columns = { default: 1, md: 2, lg: 3 }, variant = "default" } = props;
|
|
4036
|
+
if (!cards || cards.length === 0) {
|
|
4037
|
+
return /* @__PURE__ */ jsx47("div", {
|
|
4038
|
+
className: "flex items-center justify-center p-8 border rounded-md bg-muted/10",
|
|
4039
|
+
children: /* @__PURE__ */ jsx47("p", {
|
|
4040
|
+
className: "text-sm text-muted-foreground",
|
|
4041
|
+
children: "No items available"
|
|
4042
|
+
})
|
|
4043
|
+
});
|
|
4044
|
+
}
|
|
4045
|
+
const gridCols = {
|
|
4046
|
+
default: columns.default || 1,
|
|
4047
|
+
sm: columns.sm,
|
|
4048
|
+
md: columns.md || 2,
|
|
4049
|
+
lg: columns.lg || 3,
|
|
4050
|
+
xl: columns.xl
|
|
4051
|
+
};
|
|
4052
|
+
const gridClass = cn("grid gap-4", gridCols.default === 1 ? "grid-cols-1" : `grid-cols-${gridCols.default}`, gridCols.sm && `sm:grid-cols-${gridCols.sm}`, gridCols.md && `md:grid-cols-${gridCols.md}`, gridCols.lg && `lg:grid-cols-${gridCols.lg}`, gridCols.xl && `xl:grid-cols-${gridCols.xl}`);
|
|
4053
|
+
const cardClass = cn("rounded-lg border bg-card text-card-foreground shadow-sm", variant === "bordered" && "border-2", variant === "elevated" && "shadow-lg");
|
|
4054
|
+
return /* @__PURE__ */ jsx47("div", {
|
|
4055
|
+
className: gridClass,
|
|
4056
|
+
children: cards.map((card) => /* @__PURE__ */ jsxs30("div", {
|
|
4057
|
+
className: cardClass,
|
|
4058
|
+
children: [
|
|
4059
|
+
card.image && /* @__PURE__ */ jsx47("div", {
|
|
4060
|
+
className: "aspect-video w-full overflow-hidden rounded-t-lg",
|
|
4061
|
+
children: /* @__PURE__ */ jsx47("img", {
|
|
4062
|
+
src: card.image,
|
|
4063
|
+
alt: card.title,
|
|
4064
|
+
className: "h-full w-full object-cover"
|
|
4065
|
+
})
|
|
4066
|
+
}),
|
|
4067
|
+
/* @__PURE__ */ jsxs30("div", {
|
|
4068
|
+
className: "flex flex-col space-y-1.5 p-6",
|
|
4069
|
+
children: [
|
|
4070
|
+
/* @__PURE__ */ jsx47("h3", {
|
|
4071
|
+
className: "text-lg font-semibold leading-none tracking-tight",
|
|
4072
|
+
children: card.title
|
|
4073
|
+
}),
|
|
4074
|
+
card.description && /* @__PURE__ */ jsx47("p", {
|
|
4075
|
+
className: "text-sm text-muted-foreground",
|
|
4076
|
+
children: card.description
|
|
4077
|
+
})
|
|
4078
|
+
]
|
|
4079
|
+
}),
|
|
4080
|
+
card.metadata && Object.keys(card.metadata).length > 0 && /* @__PURE__ */ jsx47("div", {
|
|
4081
|
+
className: "px-6 pb-4",
|
|
4082
|
+
children: /* @__PURE__ */ jsx47("dl", {
|
|
4083
|
+
className: "space-y-1 text-sm",
|
|
4084
|
+
children: Object.entries(card.metadata).map(([key, value]) => /* @__PURE__ */ jsxs30("div", {
|
|
4085
|
+
className: "flex justify-between",
|
|
4086
|
+
children: [
|
|
4087
|
+
/* @__PURE__ */ jsxs30("dt", {
|
|
4088
|
+
className: "text-muted-foreground",
|
|
4089
|
+
children: [
|
|
4090
|
+
key,
|
|
4091
|
+
":"
|
|
4092
|
+
]
|
|
4093
|
+
}),
|
|
4094
|
+
/* @__PURE__ */ jsx47("dd", {
|
|
4095
|
+
className: "font-medium",
|
|
4096
|
+
children: String(value)
|
|
4097
|
+
})
|
|
4098
|
+
]
|
|
4099
|
+
}, key))
|
|
4100
|
+
})
|
|
4101
|
+
}),
|
|
4102
|
+
card.actions && card.actions.length > 0 && /* @__PURE__ */ jsx47("div", {
|
|
4103
|
+
className: "flex items-center gap-2 p-6 pt-0",
|
|
4104
|
+
children: card.actions.map((action, index) => /* @__PURE__ */ jsx47(Button, {
|
|
4105
|
+
variant: action.variant || "default",
|
|
4106
|
+
size: "sm",
|
|
4107
|
+
onClick: () => {
|
|
4108
|
+
if (action.onClick) {
|
|
4109
|
+
window.dispatchEvent(new CustomEvent("generative-ui-action", {
|
|
4110
|
+
detail: { action: action.onClick, cardId: card.id }
|
|
4111
|
+
}));
|
|
4112
|
+
}
|
|
4113
|
+
},
|
|
4114
|
+
children: action.label
|
|
4115
|
+
}, index))
|
|
4116
|
+
})
|
|
4117
|
+
]
|
|
4118
|
+
}, card.id))
|
|
4119
|
+
});
|
|
4120
|
+
}
|
|
3955
4121
|
// src/ui/composed/agno-chat/agno-chat.tsx
|
|
3956
|
-
import { useCallback as
|
|
4122
|
+
import { useCallback as useCallback7, useMemo as useMemo5, useRef as useRef6 } from "react";
|
|
3957
4123
|
import { useAgnoChat, useAgnoToolExecution } from "@rodrigocoliveira/agno-react";
|
|
3958
4124
|
import { jsx as jsx48 } from "react/jsx-runtime";
|
|
3959
4125
|
function resolveDebug(debug) {
|
|
@@ -3967,19 +4133,19 @@ function AgnoChatRoot({
|
|
|
3967
4133
|
autoExecuteTools = true,
|
|
3968
4134
|
renderTool,
|
|
3969
4135
|
debug,
|
|
3970
|
-
|
|
4136
|
+
skipToolsOnSessionLoad,
|
|
3971
4137
|
className,
|
|
3972
4138
|
...divProps
|
|
3973
4139
|
}) {
|
|
3974
4140
|
const chat = useAgnoChat();
|
|
3975
4141
|
const toolExec = useAgnoToolExecution(toolHandlers, autoExecuteTools, {
|
|
3976
|
-
|
|
4142
|
+
skipToolsOnSessionLoad
|
|
3977
4143
|
});
|
|
3978
4144
|
const containerRef = useRef6(null);
|
|
3979
4145
|
const isDebug = resolveDebug(debug);
|
|
3980
4146
|
const sendRef = useRef6(chat.sendMessage);
|
|
3981
4147
|
sendRef.current = chat.sendMessage;
|
|
3982
|
-
const handleSend =
|
|
4148
|
+
const handleSend = useCallback7(async (message) => {
|
|
3983
4149
|
try {
|
|
3984
4150
|
await sendRef.current(message);
|
|
3985
4151
|
} catch {}
|
|
@@ -4005,7 +4171,7 @@ function AgnoChatRoot({
|
|
|
4005
4171
|
continueWithResults,
|
|
4006
4172
|
executionError
|
|
4007
4173
|
} = toolExec;
|
|
4008
|
-
const contextValue =
|
|
4174
|
+
const contextValue = useMemo5(() => ({
|
|
4009
4175
|
messages,
|
|
4010
4176
|
sendMessage,
|
|
4011
4177
|
clearMessages,
|
|
@@ -4062,17 +4228,17 @@ function AgnoChatRoot({
|
|
|
4062
4228
|
}
|
|
4063
4229
|
|
|
4064
4230
|
// src/ui/composed/agno-chat/messages.tsx
|
|
4065
|
-
import { isValidElement as isValidElement2, useEffect as
|
|
4231
|
+
import { isValidElement as isValidElement2, useEffect as useEffect6, useRef as useRef7 } from "react";
|
|
4066
4232
|
|
|
4067
4233
|
// src/ui/composed/agno-chat/suggested-prompts.tsx
|
|
4068
|
-
import { jsx as jsx49, jsxs as
|
|
4234
|
+
import { jsx as jsx49, jsxs as jsxs31 } from "react/jsx-runtime";
|
|
4069
4235
|
function AgnoChatSuggestedPrompts({ className, prompts }) {
|
|
4070
4236
|
const { handleSend } = useAgnoChatContext();
|
|
4071
4237
|
if (prompts.length === 0)
|
|
4072
4238
|
return null;
|
|
4073
4239
|
return /* @__PURE__ */ jsx49("div", {
|
|
4074
4240
|
className: cn("grid grid-cols-2 gap-2 w-full max-w-md", className),
|
|
4075
|
-
children: prompts.map((prompt, idx) => /* @__PURE__ */
|
|
4241
|
+
children: prompts.map((prompt, idx) => /* @__PURE__ */ jsxs31("button", {
|
|
4076
4242
|
onClick: () => handleSend(prompt.text),
|
|
4077
4243
|
className: "flex items-center gap-2 px-3 py-2.5 rounded-xl border border-border bg-card hover:bg-accent/50 hover:border-primary/20 transition-all duration-200 text-left text-sm group",
|
|
4078
4244
|
children: [
|
|
@@ -4091,11 +4257,11 @@ function AgnoChatSuggestedPrompts({ className, prompts }) {
|
|
|
4091
4257
|
|
|
4092
4258
|
// src/ui/composed/agno-chat/messages.tsx
|
|
4093
4259
|
import { Bot as Bot2 } from "lucide-react";
|
|
4094
|
-
import { jsx as jsx50, jsxs as
|
|
4260
|
+
import { jsx as jsx50, jsxs as jsxs32 } from "react/jsx-runtime";
|
|
4095
4261
|
function ScrollOnNewUserMessage({ messageCount }) {
|
|
4096
4262
|
const { scrollToBottom } = useStickToBottomContext2();
|
|
4097
4263
|
const prevCount = useRef7(messageCount);
|
|
4098
|
-
|
|
4264
|
+
useEffect6(() => {
|
|
4099
4265
|
if (messageCount > prevCount.current) {
|
|
4100
4266
|
scrollToBottom("smooth");
|
|
4101
4267
|
}
|
|
@@ -4163,10 +4329,10 @@ function AgnoChatMessages({
|
|
|
4163
4329
|
...messageClassNames !== undefined && { classNames: messageClassNames },
|
|
4164
4330
|
...propRenderTool !== undefined && { renderTool: propRenderTool }
|
|
4165
4331
|
};
|
|
4166
|
-
const resolvedEmptyState = children ?? emptyState ?? /* @__PURE__ */
|
|
4332
|
+
const resolvedEmptyState = children ?? emptyState ?? /* @__PURE__ */ jsxs32("div", {
|
|
4167
4333
|
className: "flex flex-col items-center gap-6",
|
|
4168
4334
|
children: [
|
|
4169
|
-
/* @__PURE__ */
|
|
4335
|
+
/* @__PURE__ */ jsxs32("div", {
|
|
4170
4336
|
className: "relative",
|
|
4171
4337
|
children: [
|
|
4172
4338
|
/* @__PURE__ */ jsx50("div", {
|
|
@@ -4183,7 +4349,7 @@ function AgnoChatMessages({
|
|
|
4183
4349
|
})
|
|
4184
4350
|
]
|
|
4185
4351
|
}),
|
|
4186
|
-
/* @__PURE__ */
|
|
4352
|
+
/* @__PURE__ */ jsxs32("div", {
|
|
4187
4353
|
className: "space-y-2 text-center",
|
|
4188
4354
|
children: [
|
|
4189
4355
|
/* @__PURE__ */ jsx50("h3", {
|
|
@@ -4201,14 +4367,14 @@ function AgnoChatMessages({
|
|
|
4201
4367
|
})
|
|
4202
4368
|
]
|
|
4203
4369
|
});
|
|
4204
|
-
return /* @__PURE__ */
|
|
4370
|
+
return /* @__PURE__ */ jsxs32(Conversation, {
|
|
4205
4371
|
className: cn("relative flex-1 w-full", className),
|
|
4206
4372
|
scrollBehavior,
|
|
4207
4373
|
children: [
|
|
4208
4374
|
/* @__PURE__ */ jsx50(ScrollOnNewUserMessage, {
|
|
4209
4375
|
messageCount: messages.length
|
|
4210
4376
|
}),
|
|
4211
|
-
/* @__PURE__ */
|
|
4377
|
+
/* @__PURE__ */ jsxs32(ConversationContent, {
|
|
4212
4378
|
className: "max-w-3xl mx-auto",
|
|
4213
4379
|
children: [
|
|
4214
4380
|
messages.length === 0 ? /* @__PURE__ */ jsx50(ConversationEmptyState, {
|
|
@@ -4248,8 +4414,8 @@ function AgnoChatEmptyState({ children, className, ...props }) {
|
|
|
4248
4414
|
}
|
|
4249
4415
|
|
|
4250
4416
|
// src/ui/composed/agno-chat/error-bar.tsx
|
|
4251
|
-
import { useState as
|
|
4252
|
-
import { jsx as jsx52, jsxs as
|
|
4417
|
+
import { useState as useState9, useEffect as useEffect7, useRef as useRef8 } from "react";
|
|
4418
|
+
import { jsx as jsx52, jsxs as jsxs33 } from "react/jsx-runtime";
|
|
4253
4419
|
function AgnoChatErrorBar({
|
|
4254
4420
|
className,
|
|
4255
4421
|
text,
|
|
@@ -4259,10 +4425,10 @@ function AgnoChatErrorBar({
|
|
|
4259
4425
|
children
|
|
4260
4426
|
}) {
|
|
4261
4427
|
const { error, executionError } = useAgnoChatContext();
|
|
4262
|
-
const [hidden, setHidden] =
|
|
4428
|
+
const [hidden, setHidden] = useState9(false);
|
|
4263
4429
|
const timerRef = useRef8(null);
|
|
4264
4430
|
const rawMessage = error || executionError;
|
|
4265
|
-
|
|
4431
|
+
useEffect7(() => {
|
|
4266
4432
|
if (!rawMessage)
|
|
4267
4433
|
return;
|
|
4268
4434
|
setHidden(false);
|
|
@@ -4289,7 +4455,7 @@ function AgnoChatErrorBar({
|
|
|
4289
4455
|
if (children) {
|
|
4290
4456
|
return typeof children === "function" ? children(rawMessage) : children;
|
|
4291
4457
|
}
|
|
4292
|
-
return /* @__PURE__ */
|
|
4458
|
+
return /* @__PURE__ */ jsxs33("div", {
|
|
4293
4459
|
className: "flex items-center gap-2 max-w-3xl mx-auto",
|
|
4294
4460
|
children: [
|
|
4295
4461
|
icon && /* @__PURE__ */ jsx52("span", {
|
|
@@ -4305,7 +4471,7 @@ function AgnoChatErrorBar({
|
|
|
4305
4471
|
onClick: () => setHidden(true),
|
|
4306
4472
|
className: "shrink-0 text-destructive/60 hover:text-destructive transition-colors",
|
|
4307
4473
|
"aria-label": "Dismiss error",
|
|
4308
|
-
children: /* @__PURE__ */
|
|
4474
|
+
children: /* @__PURE__ */ jsxs33("svg", {
|
|
4309
4475
|
xmlns: "http://www.w3.org/2000/svg",
|
|
4310
4476
|
width: "16",
|
|
4311
4477
|
height: "16",
|
|
@@ -4402,7 +4568,6 @@ export {
|
|
|
4402
4568
|
ToolOutput,
|
|
4403
4569
|
ToolInput,
|
|
4404
4570
|
ToolHeader,
|
|
4405
|
-
ToolGenerativeUI,
|
|
4406
4571
|
ToolDebugCard,
|
|
4407
4572
|
ToolContent,
|
|
4408
4573
|
Tool,
|
|
@@ -4454,9 +4619,11 @@ export {
|
|
|
4454
4619
|
PromptInputActionMenu,
|
|
4455
4620
|
PromptInputActionAddAttachments,
|
|
4456
4621
|
PromptInput,
|
|
4622
|
+
PieChart,
|
|
4457
4623
|
MessageContent,
|
|
4458
4624
|
MessageAvatar,
|
|
4459
4625
|
Message,
|
|
4626
|
+
LineChart,
|
|
4460
4627
|
InputGroupTextarea,
|
|
4461
4628
|
InputGroupText,
|
|
4462
4629
|
InputGroupInput,
|
|
@@ -4511,7 +4678,15 @@ export {
|
|
|
4511
4678
|
Collapsible,
|
|
4512
4679
|
CodeBlockCopyButton,
|
|
4513
4680
|
CodeBlock,
|
|
4681
|
+
ChartTooltipContent,
|
|
4682
|
+
ChartTooltip,
|
|
4683
|
+
ChartStyle,
|
|
4684
|
+
ChartLegendContent,
|
|
4685
|
+
ChartLegend,
|
|
4686
|
+
ChartContainer,
|
|
4687
|
+
CardGrid,
|
|
4514
4688
|
Button,
|
|
4689
|
+
BarChart,
|
|
4515
4690
|
Badge,
|
|
4516
4691
|
AvatarImage,
|
|
4517
4692
|
AvatarFallback,
|
|
@@ -4525,6 +4700,7 @@ export {
|
|
|
4525
4700
|
ArtifactActions,
|
|
4526
4701
|
ArtifactAction,
|
|
4527
4702
|
Artifact,
|
|
4703
|
+
AreaChart,
|
|
4528
4704
|
AgnoMessageTools,
|
|
4529
4705
|
AgnoMessageReferences,
|
|
4530
4706
|
AgnoMessageReasoning,
|
|
@@ -4548,4 +4724,4 @@ export {
|
|
|
4548
4724
|
Accordion
|
|
4549
4725
|
};
|
|
4550
4726
|
|
|
4551
|
-
//# debugId=
|
|
4727
|
+
//# debugId=762A645DC01D022A64756E2164756E21
|