@case-framework/survey-assistant 0.2.3 → 0.3.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/dist/{authoring-references-ChDTVnms.mjs → authoring-references-yyYC4Ydi.mjs} +2 -2
- package/dist/{authoring-references-ChDTVnms.mjs.map → authoring-references-yyYC4Ydi.mjs.map} +1 -1
- package/dist/capabilities-default.d.mts +1 -1
- package/dist/{constants-BK1-g6pR.d.mts → constants-DrGZXtQf.d.mts} +4 -4
- package/dist/{constants-BK1-g6pR.d.mts.map → constants-DrGZXtQf.d.mts.map} +1 -1
- package/dist/{controller-proxy-DY36XFV3.mjs → controller-proxy-CpkQRezb.mjs} +2 -1
- package/dist/controller-proxy-CpkQRezb.mjs.map +1 -0
- package/dist/{controller-proxy-CIDRd8Wu.d.mts → controller-proxy-DmBdzqKs.d.mts} +5 -2
- package/dist/controller-proxy-DmBdzqKs.d.mts.map +1 -0
- package/dist/engine.d.mts +1 -1
- package/dist/{index-CPOQgkTN.d.mts → index-Bo4dHAo8.d.mts} +3 -2
- package/dist/index-Bo4dHAo8.d.mts.map +1 -0
- package/dist/index-D4OitUg4.d.mts +738 -0
- package/dist/index-D4OitUg4.d.mts.map +1 -0
- package/dist/{index-Bp5W_oPa.d.mts → index-DZk20e3k.d.mts} +26 -24
- package/dist/index-DZk20e3k.d.mts.map +1 -0
- package/dist/{index-SPHf3OoJ.d.mts → index-Dxgg0-D_.d.mts} +6 -3
- package/dist/index-Dxgg0-D_.d.mts.map +1 -0
- package/dist/lifecycle-DWv5CiSu.d.mts +523 -0
- package/dist/lifecycle-DWv5CiSu.d.mts.map +1 -0
- package/dist/protocol-DATvkr1S.mjs.map +1 -1
- package/dist/protocol.d.mts +2 -1
- package/dist/{react-3kSE6WtS.mjs → react-Br5YE8H-.mjs} +7 -5
- package/dist/react-Br5YE8H-.mjs.map +1 -0
- package/dist/react-integration.d.mts +1 -1
- package/dist/react-integration.mjs +1 -1
- package/dist/react.d.mts +2 -2
- package/dist/react.mjs +2 -2
- package/dist/server-agent.d.mts +26 -24
- package/dist/server-agent.d.mts.map +1 -1
- package/dist/server-agent.mjs +4 -4
- package/dist/server-agent.mjs.map +1 -1
- package/dist/server-runtime.d.mts +6 -6
- package/dist/server-runtime.mjs +1 -1
- package/dist/server-tasks.d.mts +1 -1
- package/dist/server-tasks.mjs +3 -2
- package/dist/server-tasks.mjs.map +1 -1
- package/dist/server-tools.d.mts +1 -1
- package/dist/server-tools.mjs +1 -1
- package/dist/server.d.mts +6 -6
- package/dist/server.d.mts.map +1 -1
- package/dist/server.mjs +1 -1
- package/dist/storage-postgres.d.mts +1 -1
- package/dist/{tasks-DIZgr4nD.d.mts → tasks-DQgL449A.d.mts} +3 -3
- package/dist/{tasks-DIZgr4nD.d.mts.map → tasks-DQgL449A.d.mts.map} +1 -1
- package/dist/{thread-documents-C3kf0Vds.d.mts → thread-documents-Dvo6XS7o.d.mts} +1 -1
- package/dist/{thread-documents-C3kf0Vds.d.mts.map → thread-documents-Dvo6XS7o.d.mts.map} +1 -1
- package/dist/{thread-handlers-DZ1WsorO.d.mts → thread-handlers-CeYl45xG.d.mts} +5 -5
- package/dist/{thread-handlers-DZ1WsorO.d.mts.map → thread-handlers-CeYl45xG.d.mts.map} +1 -1
- package/dist/{tools-GDd5_GUh.mjs → tools-Dg9HZrYU.mjs} +4 -4
- package/dist/tools-Dg9HZrYU.mjs.map +1 -0
- package/dist/ui.css +2 -2
- package/dist/ui.d.mts +94 -10
- package/dist/ui.d.mts.map +1 -1
- package/dist/ui.mjs +193 -78
- package/dist/ui.mjs.map +1 -1
- package/docs/integration.md +1 -1
- package/package.json +23 -17
- package/dist/controller-proxy-CIDRd8Wu.d.mts.map +0 -1
- package/dist/controller-proxy-DY36XFV3.mjs.map +0 -1
- package/dist/index-Bp5W_oPa.d.mts.map +0 -1
- package/dist/index-CPOQgkTN.d.mts.map +0 -1
- package/dist/index-EDL1V168.d.mts +0 -1257
- package/dist/index-EDL1V168.d.mts.map +0 -1
- package/dist/index-SPHf3OoJ.d.mts.map +0 -1
- package/dist/react-3kSE6WtS.mjs.map +0 -1
- package/dist/tools-GDd5_GUh.mjs.map +0 -1
package/dist/ui.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jt as parseSurveyAssistantError, l as surveyAssistantTurnFinalSchema, n as SURVEY_ASSISTANT_TURN_FINAL_PART_TYPE } from "./protocol-DATvkr1S.mjs";
|
|
3
|
-
import { f as unwrapSurveyAssistantToolOutput, i as createSurveyAssistantThreadClient, l as parseSurveyChangeSet, p as isSurveyAssistantTurnActive, r as useSurveyAssistantModelCatalog, t as useSurveyAssistantSession } from "./react-
|
|
4
|
-
import { o as connectSurveyAssistantThreadLauncher } from "./controller-proxy-
|
|
3
|
+
import { f as unwrapSurveyAssistantToolOutput, i as createSurveyAssistantThreadClient, l as parseSurveyChangeSet, p as isSurveyAssistantTurnActive, r as useSurveyAssistantModelCatalog, t as useSurveyAssistantSession } from "./react-Br5YE8H-.mjs";
|
|
4
|
+
import { o as connectSurveyAssistantThreadLauncher } from "./controller-proxy-CpkQRezb.mjs";
|
|
5
5
|
import { getToolName, isFileUIPart, isReasoningUIPart, isToolUIPart } from "ai";
|
|
6
6
|
import { createContext, createElement, memo, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
|
|
7
7
|
import { Collapsible, Select, Slot } from "radix-ui";
|
|
@@ -708,7 +708,7 @@ const Message = ({ className, from, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
|
708
708
|
...props
|
|
709
709
|
});
|
|
710
710
|
const MessageContent = ({ children, className, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
711
|
-
className: cn("w-fit min-w-0 max-w-full break-words text-sm", "group-data-[role=user]:whitespace-pre-wrap group-data-[role=user]:rounded-xl group-data-[role=user]:border group-data-[role=user]:border-blue-200/70 group-data-[role=user]:bg-blue-50 group-data-[role=user]:px-3 group-data-[role=user]:py-2 group-data-[role=user]:text-foreground group-data-[role=user]:shadow-xs dark:group-data-[role=user]:border-blue-800/60 dark:group-data-[role=user]:bg-blue-950/50", "group-data-[role=assistant]:text-foreground", className),
|
|
711
|
+
className: cn("w-fit min-w-0 max-w-full break-words text-sm", "group-data-[role=user]:whitespace-pre-wrap group-data-[role=user]:rounded-xl group-data-[role=user]:border group-data-[role=user]:border-blue-200/70 group-data-[role=user]:bg-blue-50/80 group-data-[role=user]:px-3 group-data-[role=user]:py-2 group-data-[role=user]:text-foreground group-data-[role=user]:shadow-xs dark:group-data-[role=user]:border-blue-800/60 dark:group-data-[role=user]:bg-blue-950/50", "group-data-[role=assistant]:text-foreground", className),
|
|
712
712
|
...props,
|
|
713
713
|
children
|
|
714
714
|
});
|
|
@@ -739,13 +739,18 @@ const usePromptInput = () => {
|
|
|
739
739
|
if (!context) throw new Error("PromptInput components must be used within PromptInput.");
|
|
740
740
|
return context;
|
|
741
741
|
};
|
|
742
|
-
const PromptInput = ({ attachmentsDisabled = false, children, className, onDragEnter, onDragLeave, onDragOver, onDrop, onPaste, onSubmit, ...props }) => {
|
|
743
|
-
const [
|
|
742
|
+
const PromptInput = ({ attachmentsDisabled = false, children, className, onDragEnter, onDragLeave, onDragOver, onDrop, onPaste, onSubmit, onValueChange, value: controlledValue, ...props }) => {
|
|
743
|
+
const [uncontrolledValue, setUncontrolledValue] = useState("");
|
|
744
744
|
const [files, setFiles] = useState([]);
|
|
745
745
|
const [isDraggingFiles, setIsDraggingFiles] = useState(false);
|
|
746
746
|
const [unsupportedFileNames, setUnsupportedFileNames] = useState([]);
|
|
747
747
|
const fileDragDepthRef = useRef(0);
|
|
748
748
|
const t = useSurveyAssistantTranslation();
|
|
749
|
+
const value = controlledValue ?? uncontrolledValue;
|
|
750
|
+
const setValue = useCallback((nextValue) => {
|
|
751
|
+
if (controlledValue === void 0) setUncontrolledValue(nextValue);
|
|
752
|
+
onValueChange?.(nextValue);
|
|
753
|
+
}, [controlledValue, onValueChange]);
|
|
749
754
|
const addFiles = useCallback((fileList) => {
|
|
750
755
|
const nextFiles = Array.from(fileList ?? []);
|
|
751
756
|
const supportedFiles = nextFiles.filter(isSupportedFile);
|
|
@@ -947,15 +952,6 @@ const PromptInputSubmit = ({ className, status, onStop, onClick, ...props }) =>
|
|
|
947
952
|
});
|
|
948
953
|
};
|
|
949
954
|
//#endregion
|
|
950
|
-
//#region src/ui/internal/tool-technical-details.ts
|
|
951
|
-
const formatOmittedLength = (length) => length.toLocaleString("en-US");
|
|
952
|
-
const stringifyToolTechnicalDetails = (value) => JSON.stringify(value, function redactEmbeddedBinary(key, currentValue) {
|
|
953
|
-
const parent = this && typeof this === "object" ? this : void 0;
|
|
954
|
-
if (key === "data" && typeof currentValue === "string" && parent?.type === "embedded" && parent.encoding === "base64") return `[embedded base64 omitted: ${formatOmittedLength(currentValue.length)} characters]`;
|
|
955
|
-
if (typeof currentValue === "string" && currentValue.length > 512 && /^data:[^;,]+;base64,/.test(currentValue)) return `[base64 data URL omitted: ${formatOmittedLength(currentValue.length)} characters]`;
|
|
956
|
-
return currentValue;
|
|
957
|
-
}, 2);
|
|
958
|
-
//#endregion
|
|
959
955
|
//#region src/ui/internal/select.tsx
|
|
960
956
|
function Select$1({ ...props }) {
|
|
961
957
|
return /* @__PURE__ */ jsx(Select.Root, {
|
|
@@ -1030,6 +1026,88 @@ function SelectScrollDownButton({ className, ...props }) {
|
|
|
1030
1026
|
});
|
|
1031
1027
|
}
|
|
1032
1028
|
//#endregion
|
|
1029
|
+
//#region src/ui/survey-assistant-prompt-input.tsx
|
|
1030
|
+
const SurveyAssistantModelSelect = ({ disabled = false, modelId, models, onModelChange }) => {
|
|
1031
|
+
const t = useSurveyAssistantTranslation();
|
|
1032
|
+
const selectedModelLabel = models.find((model) => model.id === modelId)?.label ?? modelId ?? t("input.defaultModel");
|
|
1033
|
+
if (models.length > 1) return /* @__PURE__ */ jsxs(Select$1, {
|
|
1034
|
+
disabled,
|
|
1035
|
+
onValueChange: onModelChange,
|
|
1036
|
+
value: modelId ?? "",
|
|
1037
|
+
children: [/* @__PURE__ */ jsxs(SelectTrigger, {
|
|
1038
|
+
"aria-label": t("input.model"),
|
|
1039
|
+
className: "h-8 min-w-0 max-w-48 gap-1.5 border-0 bg-transparent px-2 text-xs shadow-none hover:bg-muted hover:text-foreground focus-visible:ring-1",
|
|
1040
|
+
size: "sm",
|
|
1041
|
+
title: modelId,
|
|
1042
|
+
children: [/* @__PURE__ */ jsx(BotIcon, { className: "size-3.5" }), /* @__PURE__ */ jsx(SelectValue, {})]
|
|
1043
|
+
}), /* @__PURE__ */ jsx(SelectContent, {
|
|
1044
|
+
align: "end",
|
|
1045
|
+
className: "min-w-52 rounded-lg border-border p-0 shadow-lg",
|
|
1046
|
+
position: "popper",
|
|
1047
|
+
children: models.map((model) => /* @__PURE__ */ jsx(SelectItem, {
|
|
1048
|
+
className: "min-h-9 rounded-md px-2 py-2 text-xs focus:bg-muted",
|
|
1049
|
+
title: model.id,
|
|
1050
|
+
value: model.id,
|
|
1051
|
+
children: model.label
|
|
1052
|
+
}, model.id))
|
|
1053
|
+
})]
|
|
1054
|
+
});
|
|
1055
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1056
|
+
className: "flex h-8 min-w-0 max-w-48 items-center gap-1.5 px-2 text-muted-foreground text-xs",
|
|
1057
|
+
title: modelId,
|
|
1058
|
+
children: [/* @__PURE__ */ jsx(BotIcon, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ jsx("span", {
|
|
1059
|
+
className: "truncate",
|
|
1060
|
+
children: selectedModelLabel
|
|
1061
|
+
})]
|
|
1062
|
+
});
|
|
1063
|
+
};
|
|
1064
|
+
const SurveyAssistantPromptInput = ({ attachmentsDisabled = false, attachmentButtonClassName, className, disabled = false, footerClassName, formProps, modelDisabled = false, modelId, models, onModelChange, onStop, onSubmit, onValueChange, placeholder, status, textareaClassName, textareaProps, textareaRef, value }) => {
|
|
1065
|
+
const t = useSurveyAssistantTranslation();
|
|
1066
|
+
const canStop = Boolean(onStop) && (status === "submitted" || status === "streaming");
|
|
1067
|
+
return /* @__PURE__ */ jsxs(PromptInput, {
|
|
1068
|
+
...formProps,
|
|
1069
|
+
attachmentsDisabled: attachmentsDisabled || disabled,
|
|
1070
|
+
className: cn("rounded-xl border-border bg-background shadow-sm", className),
|
|
1071
|
+
onSubmit,
|
|
1072
|
+
onValueChange,
|
|
1073
|
+
value,
|
|
1074
|
+
children: [/* @__PURE__ */ jsx(PromptInputBody, { children: /* @__PURE__ */ jsx(PromptInputTextarea, {
|
|
1075
|
+
...textareaProps,
|
|
1076
|
+
className: cn("min-h-20 px-3 py-2 disabled:cursor-not-allowed disabled:text-muted-foreground", textareaClassName),
|
|
1077
|
+
disabled,
|
|
1078
|
+
placeholder: placeholder ?? t("input.placeholder"),
|
|
1079
|
+
ref: textareaRef
|
|
1080
|
+
}) }), /* @__PURE__ */ jsxs(PromptInputFooter, {
|
|
1081
|
+
className: cn("justify-between border-0 px-1.5 pt-0 pb-1.5", footerClassName),
|
|
1082
|
+
children: [/* @__PURE__ */ jsx(PromptInputAttachmentButton, {
|
|
1083
|
+
className: attachmentButtonClassName,
|
|
1084
|
+
disabled: attachmentsDisabled || disabled
|
|
1085
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
1086
|
+
className: "flex min-w-0 items-center justify-end gap-1",
|
|
1087
|
+
children: [/* @__PURE__ */ jsx(SurveyAssistantModelSelect, {
|
|
1088
|
+
disabled: disabled || modelDisabled,
|
|
1089
|
+
modelId,
|
|
1090
|
+
models,
|
|
1091
|
+
onModelChange
|
|
1092
|
+
}), /* @__PURE__ */ jsx(PromptInputSubmit, {
|
|
1093
|
+
disabled: disabled && !canStop,
|
|
1094
|
+
onStop,
|
|
1095
|
+
status
|
|
1096
|
+
})]
|
|
1097
|
+
})]
|
|
1098
|
+
})]
|
|
1099
|
+
});
|
|
1100
|
+
};
|
|
1101
|
+
//#endregion
|
|
1102
|
+
//#region src/ui/internal/tool-technical-details.ts
|
|
1103
|
+
const formatOmittedLength = (length) => length.toLocaleString("en-US");
|
|
1104
|
+
const stringifyToolTechnicalDetails = (value) => JSON.stringify(value, function redactEmbeddedBinary(key, currentValue) {
|
|
1105
|
+
const parent = this && typeof this === "object" ? this : void 0;
|
|
1106
|
+
if (key === "data" && typeof currentValue === "string" && parent?.type === "embedded" && parent.encoding === "base64") return `[embedded base64 omitted: ${formatOmittedLength(currentValue.length)} characters]`;
|
|
1107
|
+
if (typeof currentValue === "string" && currentValue.length > 512 && /^data:[^;,]+;base64,/.test(currentValue)) return `[base64 data URL omitted: ${formatOmittedLength(currentValue.length)} characters]`;
|
|
1108
|
+
return currentValue;
|
|
1109
|
+
}, 2);
|
|
1110
|
+
//#endregion
|
|
1033
1111
|
//#region src/ui/internal/code-block.tsx
|
|
1034
1112
|
const isItalic = (fontStyle) => fontStyle && fontStyle & 1;
|
|
1035
1113
|
const isBold = (fontStyle) => fontStyle && fontStyle & 2;
|
|
@@ -1349,7 +1427,7 @@ const SurveyAssistantToolOutputSummary = ({ applyResult, output }) => {
|
|
|
1349
1427
|
const statusLabel = status === "applied" ? t("changes.applied") : status === "stale" ? t("changes.stale") : status === "failed" ? t("changes.failed") : isValid ? t("changes.prepared") : t("changes.rejected");
|
|
1350
1428
|
const statusMessage = applyResult?.message ?? unwrappedOutput.summary;
|
|
1351
1429
|
return /* @__PURE__ */ jsxs("div", {
|
|
1352
|
-
className: cn("relative rounded-md border px-2.5 py-2 text-xs", isPositiveStatus ? "border-emerald-200/
|
|
1430
|
+
className: cn("relative rounded-md border px-2.5 py-2 text-xs", isPositiveStatus ? "border-emerald-200/70 bg-emerald-50/40 text-emerald-950" : status === "stale" ? "border-amber-200/70 bg-amber-50/40 text-amber-900" : "border-red-200/70 bg-red-50/40 text-red-900"),
|
|
1353
1431
|
children: [
|
|
1354
1432
|
/* @__PURE__ */ jsxs("div", {
|
|
1355
1433
|
className: "flex items-center gap-2 font-medium",
|
|
@@ -1447,11 +1525,20 @@ const SurveyAssistantToolStep = ({ applyResultsByChangeId, terminalTurnStatus, p
|
|
|
1447
1525
|
const errorText = getToolErrorText(part);
|
|
1448
1526
|
const changeSet = output === void 0 ? null : getChangeSet(output);
|
|
1449
1527
|
const applyResult = changeSet ? applyResultsByChangeId[changeSet.id] : void 0;
|
|
1528
|
+
const changeHasError = changeSet?.status === "rejected" || applyResult?.status === "rejected" || applyResult?.status === "failed";
|
|
1450
1529
|
const title = changeSet ? toolName === "survey_expression" ? t("activity.expressionChange") : t("activity.surveyChange") : getToolTitle(t, toolName, part.state);
|
|
1451
1530
|
const meta = terminalTurnStatus && toolStatusMeta[part.state].stepStatus === "active" ? terminalTurnStatus === "aborted" ? getStoppedToolStatusMeta(t) : {
|
|
1452
1531
|
icon: /* @__PURE__ */ jsx(XCircleIcon, { className: "size-3 text-red-600" }),
|
|
1453
1532
|
label: t("activity.failed"),
|
|
1454
1533
|
stepStatus: "complete"
|
|
1534
|
+
} : changeHasError ? {
|
|
1535
|
+
icon: /* @__PURE__ */ jsx(XCircleIcon, { className: "size-3 text-red-900" }),
|
|
1536
|
+
label: null,
|
|
1537
|
+
stepStatus: "complete"
|
|
1538
|
+
} : applyResult?.status === "stale" ? {
|
|
1539
|
+
icon: /* @__PURE__ */ jsx(ClockIcon, { className: "size-3 text-amber-600" }),
|
|
1540
|
+
label: null,
|
|
1541
|
+
stepStatus: "complete"
|
|
1455
1542
|
} : toolStatusMeta[part.state];
|
|
1456
1543
|
const metaTitle = meta.label ?? (part.state === "output-denied" ? t("activity.skipped") : part.state === "output-error" ? t("activity.failed") : meta.stepStatus === "active" ? t("activity.workingShort") : t("activity.done"));
|
|
1457
1544
|
const [detailsOpen, setDetailsOpen] = useState(part.state === "output-error");
|
|
@@ -1483,16 +1570,16 @@ const SurveyAssistantToolStep = ({ applyResultsByChangeId, terminalTurnStatus, p
|
|
|
1483
1570
|
onOpenChange: setDetailsOpen,
|
|
1484
1571
|
open: detailsOpen,
|
|
1485
1572
|
children: [/* @__PURE__ */ jsxs(CollapsibleTrigger, {
|
|
1486
|
-
className: "flex items-center gap-1 text-muted-foreground
|
|
1573
|
+
className: "-ml-1 flex items-center gap-0.5 rounded px-1 py-0.5 text-[11px] text-muted-foreground/80 transition-colors hover:bg-background/60 hover:text-foreground",
|
|
1487
1574
|
children: [/* @__PURE__ */ jsx(ChevronRightIcon, { className: cn("size-3 transition-transform", detailsOpen && "rotate-90") }), t(detailsOpen ? "activity.hideTechnicalDetails" : "activity.technicalDetails")]
|
|
1488
1575
|
}), /* @__PURE__ */ jsxs(CollapsibleContent, {
|
|
1489
|
-
className: "mt-
|
|
1576
|
+
className: "mt-1.5 space-y-1.5",
|
|
1490
1577
|
children: [part.input !== void 0 && /* @__PURE__ */ jsx(CodeBlock, {
|
|
1491
|
-
className: "border-border/
|
|
1578
|
+
className: "border-border/60 bg-background/70 [&_code]:text-xs [&_pre]:p-2.5 [&_pre]:text-xs",
|
|
1492
1579
|
code: stringifyToolTechnicalDetails(part.input),
|
|
1493
1580
|
language: "json"
|
|
1494
1581
|
}), (output !== void 0 || errorText) && /* @__PURE__ */ jsx(CodeBlock, {
|
|
1495
|
-
className: cn("bg-
|
|
1582
|
+
className: cn("bg-background/70 [&_code]:text-xs [&_pre]:p-2.5 [&_pre]:text-xs", errorText ? "border-destructive/25" : "border-border/60"),
|
|
1496
1583
|
code: errorText ?? stringifyToolTechnicalDetails(output),
|
|
1497
1584
|
language: "json"
|
|
1498
1585
|
})]
|
|
@@ -1625,7 +1712,7 @@ const SurveyAssistantMessageParts = ({ applyResultsByChangeId, isLastMessage, is
|
|
|
1625
1712
|
const isChainActive = isLastMessage && isStreaming && isLastBlock;
|
|
1626
1713
|
return /* @__PURE__ */ jsxs(ChainOfThought, {
|
|
1627
1714
|
autoClose: true,
|
|
1628
|
-
className: "w-full rounded-md bg-muted/
|
|
1715
|
+
className: "w-full rounded-md bg-muted/60 px-2 py-1.5",
|
|
1629
1716
|
defaultDuration: persistedDuration,
|
|
1630
1717
|
defaultOpen: isChainActive,
|
|
1631
1718
|
duration: isChainActive ? void 0 : persistedDuration,
|
|
@@ -1741,7 +1828,6 @@ const SurveyAssistantChatPanel = ({ api, applyPolicy, controller, embedded = fal
|
|
|
1741
1828
|
const hasSubmittedMessageRef = useRef((initialMessages?.length ?? 0) > 0);
|
|
1742
1829
|
const showAssistantError = Boolean(authorizationError) || Boolean(error);
|
|
1743
1830
|
const assistantErrorPresentation = getAssistantErrorPresentation(authorizationError ?? error, t);
|
|
1744
|
-
const selectedModelLabel = models.find((model) => model.id === modelId)?.label ?? modelId ?? t("input.defaultModel");
|
|
1745
1831
|
const lastMessage = messages.at(-1);
|
|
1746
1832
|
const isAssistantTurnActive = isSurveyAssistantTurnActive({
|
|
1747
1833
|
isStreaming,
|
|
@@ -1815,8 +1901,10 @@ const SurveyAssistantChatPanel = ({ api, applyPolicy, controller, embedded = fal
|
|
|
1815
1901
|
}), [handleSubmit]);
|
|
1816
1902
|
useEffect(() => {
|
|
1817
1903
|
if (!initialLaunch) return;
|
|
1904
|
+
if (initialLaunch.modelId) onModelChange(initialLaunch.modelId);
|
|
1818
1905
|
if (submit({
|
|
1819
1906
|
files: initialLaunch.files ?? [],
|
|
1907
|
+
modelId: initialLaunch.modelId,
|
|
1820
1908
|
text: initialLaunch.prompt,
|
|
1821
1909
|
uiContext: initialLaunch.uiContext
|
|
1822
1910
|
})) {
|
|
@@ -1830,6 +1918,7 @@ const SurveyAssistantChatPanel = ({ api, applyPolicy, controller, embedded = fal
|
|
|
1830
1918
|
initialLaunch,
|
|
1831
1919
|
onFirstSubmit,
|
|
1832
1920
|
onInitialLaunchHandled,
|
|
1921
|
+
onModelChange,
|
|
1833
1922
|
submit
|
|
1834
1923
|
]);
|
|
1835
1924
|
return /* @__PURE__ */ jsxs("aside", {
|
|
@@ -1837,7 +1926,7 @@ const SurveyAssistantChatPanel = ({ api, applyPolicy, controller, embedded = fal
|
|
|
1837
1926
|
className: cn("flex h-full min-h-0 flex-col overflow-visible bg-background", !embedded && "rounded-xl border border-border shadow-sm"),
|
|
1838
1927
|
children: [
|
|
1839
1928
|
/* @__PURE__ */ jsxs("header", {
|
|
1840
|
-
className: "box-content flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border bg-
|
|
1929
|
+
className: "box-content flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border bg-background px-2.5",
|
|
1841
1930
|
children: [/* @__PURE__ */ jsx(SurveyAssistantHeaderIdentity, {
|
|
1842
1931
|
indicatorClassName: showAssistantError || state === "failed" ? "bg-destructive" : isAssistantTurnActive ? "animate-pulse bg-blue-500" : state === "aborted" ? "bg-muted-foreground" : "bg-emerald-500",
|
|
1843
1932
|
status: sessionStatusLabel,
|
|
@@ -1845,7 +1934,7 @@ const SurveyAssistantChatPanel = ({ api, applyPolicy, controller, embedded = fal
|
|
|
1845
1934
|
}), threadControls]
|
|
1846
1935
|
}),
|
|
1847
1936
|
/* @__PURE__ */ jsxs(Conversation, {
|
|
1848
|
-
className: "min-h-0",
|
|
1937
|
+
className: "min-h-0 bg-(--surface-bg-color)",
|
|
1849
1938
|
children: [/* @__PURE__ */ jsx(ConversationContent, {
|
|
1850
1939
|
className: "gap-3 px-3 py-2.5",
|
|
1851
1940
|
children: messages.length === 0 ? /* @__PURE__ */ jsx(ConversationEmptyState, {
|
|
@@ -1868,7 +1957,7 @@ const SurveyAssistantChatPanel = ({ api, applyPolicy, controller, embedded = fal
|
|
|
1868
1957
|
/* @__PURE__ */ jsx("div", {
|
|
1869
1958
|
className: "mt-4 flex flex-col gap-1.5",
|
|
1870
1959
|
children: assistantQuickPrompts.map(({ label, description, icon: Icon, prompt }) => /* @__PURE__ */ jsxs("button", {
|
|
1871
|
-
className: "group flex w-full items-center gap-2.5 rounded-lg border border-border bg-
|
|
1960
|
+
className: "group flex w-full items-center gap-2.5 rounded-lg border border-border bg-popover px-2.5 py-2 text-left shadow-xs transition-colors hover:border-foreground/20 hover:bg-muted/60",
|
|
1872
1961
|
onClick: () => handleQuickPrompt(prompt),
|
|
1873
1962
|
type: "button",
|
|
1874
1963
|
children: [
|
|
@@ -1965,58 +2054,21 @@ const SurveyAssistantChatPanel = ({ api, applyPolicy, controller, embedded = fal
|
|
|
1965
2054
|
})]
|
|
1966
2055
|
}),
|
|
1967
2056
|
/* @__PURE__ */ jsx("div", {
|
|
1968
|
-
className: "shrink-0 border-t border-border bg-
|
|
1969
|
-
children: /* @__PURE__ */
|
|
1970
|
-
"
|
|
1971
|
-
|
|
1972
|
-
|
|
2057
|
+
className: "shrink-0 border-t border-border bg-background p-2",
|
|
2058
|
+
children: /* @__PURE__ */ jsx(SurveyAssistantPromptInput, {
|
|
2059
|
+
attachmentButtonClassName: "size-8",
|
|
2060
|
+
className: cn("rounded-xl border-border bg-popover shadow-sm transition-colors", isAssistantTurnActive && "border-border/60 bg-muted/50 shadow-none"),
|
|
2061
|
+
disabled: isAssistantTurnActive,
|
|
2062
|
+
footerClassName: cn("transition-colors", isAssistantTurnActive && "bg-muted/30"),
|
|
2063
|
+
formProps: { "aria-busy": isAssistantTurnActive },
|
|
2064
|
+
modelId,
|
|
2065
|
+
models,
|
|
2066
|
+
onModelChange,
|
|
2067
|
+
onStop: stop,
|
|
1973
2068
|
onSubmit: handleSubmit,
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
placeholder: t("input.placeholder"),
|
|
1978
|
-
ref: promptTextareaRef
|
|
1979
|
-
}) }), /* @__PURE__ */ jsxs(PromptInputFooter, {
|
|
1980
|
-
className: cn("justify-between border-0 px-1.5 pt-0 pb-1.5 transition-colors", isAssistantTurnActive && "bg-muted/30"),
|
|
1981
|
-
children: [/* @__PURE__ */ jsx(PromptInputAttachmentButton, {
|
|
1982
|
-
className: "size-8",
|
|
1983
|
-
disabled: isAssistantTurnActive
|
|
1984
|
-
}), /* @__PURE__ */ jsxs("div", {
|
|
1985
|
-
className: "flex min-w-0 items-center justify-end gap-1",
|
|
1986
|
-
children: [models.length > 1 && modelId ? /* @__PURE__ */ jsxs(Select$1, {
|
|
1987
|
-
disabled: isAssistantTurnActive,
|
|
1988
|
-
onValueChange: onModelChange,
|
|
1989
|
-
value: modelId,
|
|
1990
|
-
children: [/* @__PURE__ */ jsxs(SelectTrigger, {
|
|
1991
|
-
"aria-label": t("input.model"),
|
|
1992
|
-
className: "h-8 min-w-0 max-w-48 gap-1.5 border-0 bg-transparent px-2 text-xs shadow-none hover:bg-muted hover:text-foreground focus-visible:ring-1",
|
|
1993
|
-
size: "sm",
|
|
1994
|
-
title: modelId,
|
|
1995
|
-
children: [/* @__PURE__ */ jsx(BotIcon, { className: "size-3.5" }), /* @__PURE__ */ jsx(SelectValue, {})]
|
|
1996
|
-
}), /* @__PURE__ */ jsx(SelectContent, {
|
|
1997
|
-
align: "end",
|
|
1998
|
-
className: "min-w-52 rounded-lg border-border p-0 shadow-lg",
|
|
1999
|
-
position: "popper",
|
|
2000
|
-
children: models.map((model) => /* @__PURE__ */ jsx(SelectItem, {
|
|
2001
|
-
className: "min-h-9 rounded-md px-2 py-2 text-xs focus:bg-muted",
|
|
2002
|
-
title: model.id,
|
|
2003
|
-
value: model.id,
|
|
2004
|
-
children: model.label
|
|
2005
|
-
}, model.id))
|
|
2006
|
-
})]
|
|
2007
|
-
}) : /* @__PURE__ */ jsxs("div", {
|
|
2008
|
-
className: "flex h-8 min-w-0 max-w-48 items-center gap-1.5 px-2 text-muted-foreground text-xs",
|
|
2009
|
-
title: modelId,
|
|
2010
|
-
children: [/* @__PURE__ */ jsx(BotIcon, { className: "size-3.5 shrink-0" }), /* @__PURE__ */ jsx("span", {
|
|
2011
|
-
className: "truncate",
|
|
2012
|
-
children: selectedModelLabel
|
|
2013
|
-
})]
|
|
2014
|
-
}), /* @__PURE__ */ jsx(PromptInputSubmit, {
|
|
2015
|
-
onStop: stop,
|
|
2016
|
-
status
|
|
2017
|
-
})]
|
|
2018
|
-
})]
|
|
2019
|
-
})]
|
|
2069
|
+
status,
|
|
2070
|
+
textareaClassName: "min-h-11 max-h-28 px-3 pt-2.5 pb-1.5 transition-colors disabled:placeholder:text-muted-foreground/60",
|
|
2071
|
+
textareaRef: promptTextareaRef
|
|
2020
2072
|
})
|
|
2021
2073
|
})
|
|
2022
2074
|
]
|
|
@@ -2289,7 +2341,7 @@ const SurveyAssistantPanelContent = ({ embedded = false, modelId, models = [], o
|
|
|
2289
2341
|
if (loadingThread || !selectedThread) return /* @__PURE__ */ jsxs("aside", {
|
|
2290
2342
|
className: cn("flex h-full min-h-0 flex-col overflow-visible bg-background", !embedded && "rounded-xl border border-border shadow-sm"),
|
|
2291
2343
|
children: [/* @__PURE__ */ jsx("header", {
|
|
2292
|
-
className: "box-content flex h-9 shrink-0 items-center border-b border-border bg-
|
|
2344
|
+
className: "box-content flex h-9 shrink-0 items-center border-b border-border bg-background px-2.5",
|
|
2293
2345
|
children: /* @__PURE__ */ jsx(SurveyAssistantHeaderIdentity, {
|
|
2294
2346
|
indicatorClassName: "animate-pulse bg-blue-500",
|
|
2295
2347
|
status: t("panel.loadingChats"),
|
|
@@ -2408,7 +2460,7 @@ const SurveyAssistantPanelContent = ({ embedded = false, modelId, models = [], o
|
|
|
2408
2460
|
threadId: selectedThread.id,
|
|
2409
2461
|
threadTitle: selectedThread.title
|
|
2410
2462
|
}), threadError && /* @__PURE__ */ jsxs("div", {
|
|
2411
|
-
className: "absolute right-3 bottom-3 left-3 z-40 rounded-lg border border-destructive/20 bg-
|
|
2463
|
+
className: "absolute right-3 bottom-3 left-3 z-40 rounded-lg border border-destructive/20 bg-popover px-3 py-2 text-xs shadow-lg",
|
|
2412
2464
|
children: [
|
|
2413
2465
|
/* @__PURE__ */ jsx("div", {
|
|
2414
2466
|
className: "font-medium",
|
|
@@ -2440,6 +2492,69 @@ const SurveyAssistantPanel = ({ language, localizations, ...props }) => /* @__PU
|
|
|
2440
2492
|
})
|
|
2441
2493
|
});
|
|
2442
2494
|
//#endregion
|
|
2495
|
+
//#region src/ui/survey-assistant-thread-launcher-prompt.tsx
|
|
2496
|
+
const SurveyAssistantThreadLauncherPromptContent = ({ className, disabled = false, modelCatalogApi, modelStorageKey, onError, onModelCatalogError, onSubmitted, onValueChange, placeholder, textareaClassName, textareaProps, textareaRef, threadLauncher, uiContext, value }) => {
|
|
2497
|
+
const catalog = useSurveyAssistantModelCatalog({
|
|
2498
|
+
api: modelCatalogApi,
|
|
2499
|
+
storageKey: modelStorageKey
|
|
2500
|
+
});
|
|
2501
|
+
const [submitting, setSubmitting] = useState(false);
|
|
2502
|
+
useEffect(() => {
|
|
2503
|
+
if (catalog.error) onModelCatalogError?.(catalog.error);
|
|
2504
|
+
}, [catalog.error, onModelCatalogError]);
|
|
2505
|
+
const submit = useCallback(async ({ files, text }) => {
|
|
2506
|
+
if (disabled || submitting) return false;
|
|
2507
|
+
setSubmitting(true);
|
|
2508
|
+
try {
|
|
2509
|
+
await threadLauncher.startThread({
|
|
2510
|
+
files,
|
|
2511
|
+
modelId: catalog.modelId,
|
|
2512
|
+
prompt: text,
|
|
2513
|
+
uiContext
|
|
2514
|
+
});
|
|
2515
|
+
onSubmitted();
|
|
2516
|
+
return true;
|
|
2517
|
+
} catch (error) {
|
|
2518
|
+
onError?.(error);
|
|
2519
|
+
return false;
|
|
2520
|
+
} finally {
|
|
2521
|
+
setSubmitting(false);
|
|
2522
|
+
}
|
|
2523
|
+
}, [
|
|
2524
|
+
catalog.modelId,
|
|
2525
|
+
disabled,
|
|
2526
|
+
onError,
|
|
2527
|
+
onSubmitted,
|
|
2528
|
+
submitting,
|
|
2529
|
+
threadLauncher,
|
|
2530
|
+
uiContext
|
|
2531
|
+
]);
|
|
2532
|
+
return /* @__PURE__ */ jsx(SurveyAssistantPromptInput, {
|
|
2533
|
+
attachmentsDisabled: submitting,
|
|
2534
|
+
className,
|
|
2535
|
+
disabled: disabled || submitting,
|
|
2536
|
+
modelDisabled: catalog.loading || submitting,
|
|
2537
|
+
modelId: catalog.modelId,
|
|
2538
|
+
models: catalog.models,
|
|
2539
|
+
onModelChange: catalog.selectModel,
|
|
2540
|
+
onSubmit: submit,
|
|
2541
|
+
onValueChange,
|
|
2542
|
+
placeholder,
|
|
2543
|
+
textareaClassName,
|
|
2544
|
+
textareaProps,
|
|
2545
|
+
textareaRef,
|
|
2546
|
+
value
|
|
2547
|
+
});
|
|
2548
|
+
};
|
|
2549
|
+
const SurveyAssistantThreadLauncherPrompt = ({ language, localizations, ...props }) => /* @__PURE__ */ jsx("div", {
|
|
2550
|
+
className: "case-survey-assistant",
|
|
2551
|
+
children: /* @__PURE__ */ jsx(SurveyAssistantLocalizationProvider, {
|
|
2552
|
+
language,
|
|
2553
|
+
localizations,
|
|
2554
|
+
children: /* @__PURE__ */ jsx(SurveyAssistantThreadLauncherPromptContent, { ...props })
|
|
2555
|
+
})
|
|
2556
|
+
});
|
|
2557
|
+
//#endregion
|
|
2443
2558
|
//#region src/ui/connected-survey-assistant-panel.tsx
|
|
2444
2559
|
const ConnectedSurveyAssistantPanel = ({ modelCatalogApi, modelStorageKey, onModelCatalogError, onModelChange, ...props }) => {
|
|
2445
2560
|
const catalog = useSurveyAssistantModelCatalog({
|
|
@@ -2458,6 +2573,6 @@ const ConnectedSurveyAssistantPanel = ({ modelCatalogApi, modelStorageKey, onMod
|
|
|
2458
2573
|
});
|
|
2459
2574
|
};
|
|
2460
2575
|
//#endregion
|
|
2461
|
-
export { ConnectedSurveyAssistantPanel, SurveyAssistantLocalizationProvider, SurveyAssistantPanel, defaultSurveyAssistantLocalizations, surveyAssistantEnMessages, surveyAssistantNlMessages, useSurveyAssistantTranslation };
|
|
2576
|
+
export { ConnectedSurveyAssistantPanel, SurveyAssistantLocalizationProvider, SurveyAssistantPanel, SurveyAssistantPromptInput, SurveyAssistantThreadLauncherPrompt, defaultSurveyAssistantLocalizations, surveyAssistantEnMessages, surveyAssistantNlMessages, useSurveyAssistantTranslation };
|
|
2462
2577
|
|
|
2463
2578
|
//# sourceMappingURL=ui.mjs.map
|