@done-coding/forge-kit-agent 0.0.0-placeholder.0 → 0.100.0-alpha.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/LICENSE +21 -0
- package/README.md +54 -0
- package/es/_virtual/_plugin-vue_export-helper.mjs +10 -0
- package/es/components/bubble/AiBubbleContent.vue.mjs +7 -0
- package/es/components/bubble/AiBubbleContent.vue2.mjs +209 -0
- package/es/components/bubble/AiBubbleFooter.vue.mjs +7 -0
- package/es/components/bubble/AiBubbleFooter.vue2.mjs +91 -0
- package/es/components/bubble/AiCodeHeaderControl.vue.mjs +7 -0
- package/es/components/bubble/AiCodeHeaderControl.vue2.mjs +97 -0
- package/es/components/bubble/AiContentSplit.vue.mjs +70 -0
- package/es/components/bubble/AiContentSplit.vue2.mjs +4 -0
- package/es/components/bubble/AiPartRenderer.vue.mjs +7 -0
- package/es/components/bubble/AiPartRenderer.vue2.mjs +184 -0
- package/es/components/bubble/AiThinkBox.vue.mjs +7 -0
- package/es/components/bubble/AiThinkBox.vue2.mjs +155 -0
- package/es/components/bubble/AiTypewriter.vue.mjs +81 -0
- package/es/components/bubble/AiTypewriter.vue2.mjs +4 -0
- package/es/components/config/AiConfigProvider.vue.mjs +31 -0
- package/es/components/config/AiConfigProvider.vue2.mjs +4 -0
- package/es/components/dialogue/AiDialogue.vue.mjs +7 -0
- package/es/components/dialogue/AiDialogue.vue2.mjs +242 -0
- package/es/components/dialogue/AiDialogueGroup.vue.mjs +7 -0
- package/es/components/dialogue/AiDialogueGroup.vue2.mjs +133 -0
- package/es/components/dialogue/AiDialogueWrap.vue.mjs +7 -0
- package/es/components/dialogue/AiDialogueWrap.vue2.mjs +73 -0
- package/es/components/dialogue/AiMessageList.vue.mjs +7 -0
- package/es/components/dialogue/AiMessageList.vue2.mjs +111 -0
- package/es/components/json-trigger/LlmJsonTrigger.vue.mjs +7 -0
- package/es/components/json-trigger/LlmJsonTrigger.vue2.mjs +130 -0
- package/es/components/operation/AiOperationBar.vue.mjs +7 -0
- package/es/components/operation/AiOperationBar.vue2.mjs +174 -0
- package/es/components/operation/AiOperationBtns.vue.mjs +7 -0
- package/es/components/operation/AiOperationBtns.vue2.mjs +140 -0
- package/es/components/sender/AiSender.vue.mjs +7 -0
- package/es/components/sender/AiSender.vue2.mjs +74 -0
- package/es/components/sender/AiSenderHeader.vue.mjs +7 -0
- package/es/components/sender/AiSenderHeader.vue2.mjs +78 -0
- package/es/hooks/CodeXSlot.mjs +20 -0
- package/es/hooks/SessionExpose.mjs +81 -0
- package/es/hooks/agent-tools.mjs +95 -0
- package/es/hooks/agent.mjs +143 -0
- package/es/hooks/bubble-list.mjs +64 -0
- package/es/hooks/expose.mjs +133 -0
- package/es/hooks/fix-bubble-list-bug.mjs +65 -0
- package/es/hooks/sender-history.mjs +28 -0
- package/es/hooks/sender.mjs +197 -0
- package/es/hooks/session-list.mjs +154 -0
- package/es/hooks/sse.mjs +401 -0
- package/es/hooks/storage.mjs +217 -0
- package/es/hooks/theme.mjs +253 -0
- package/es/hooks/use-density.mjs +100 -0
- package/es/hooks/use-empty-state-center.mjs +40 -0
- package/es/hooks/use-keyboard-inset.mjs +87 -0
- package/es/index.mjs +68 -0
- package/es/style.css +836 -0
- package/es/types/index.mjs +54 -0
- package/es/utils/index.mjs +34 -0
- package/es/utils/json-from-llm.mjs +26 -0
- package/es/utils/request-llm.mjs +60 -0
- package/package.json +85 -1
- package/types/bridge/config-hook.d.ts +21 -0
- package/types/bridge/index.d.ts +69 -0
- package/types/bridge/plugin.d.ts +39 -0
- package/types/bridge/state.d.ts +26 -0
- package/types/bridge/storage.d.ts +10 -0
- package/types/components/bubble/AiBubbleContent.vue.d.ts +57 -0
- package/types/components/bubble/AiBubbleFooter.vue.d.ts +6 -0
- package/types/components/bubble/AiCodeHeaderControl.vue.d.ts +7 -0
- package/types/components/bubble/AiContentSplit.vue.d.ts +36 -0
- package/types/components/bubble/AiPartRenderer.vue.d.ts +9 -0
- package/types/components/bubble/AiThinkBox.vue.d.ts +31 -0
- package/types/components/bubble/AiTypewriter.vue.d.ts +28 -0
- package/types/components/config/AiConfigProvider.vue.d.ts +28 -0
- package/types/components/dialogue/AiDialogue.vue.d.ts +546 -0
- package/types/components/dialogue/AiDialogueGroup.vue.d.ts +49 -0
- package/types/components/dialogue/AiDialogueWrap.vue.d.ts +38 -0
- package/types/components/dialogue/AiMessageList.vue.d.ts +65 -0
- package/types/components/json-trigger/LlmJsonTrigger.vue.d.ts +43 -0
- package/types/components/json-trigger/types.d.ts +12 -0
- package/types/components/operation/AiOperationBar.vue.d.ts +36 -0
- package/types/components/operation/AiOperationBtns.vue.d.ts +27 -0
- package/types/components/sender/AiSender.vue.d.ts +38 -0
- package/types/components/sender/AiSenderHeader.vue.d.ts +28 -0
- package/types/hooks/CodeXSlot.d.ts +7 -0
- package/types/hooks/SessionExpose.d.ts +20 -0
- package/types/hooks/agent-tools.d.ts +67 -0
- package/types/hooks/agent.d.ts +43 -0
- package/types/hooks/bubble-list.d.ts +22 -0
- package/types/hooks/expose.d.ts +111 -0
- package/types/hooks/fix-bubble-list-bug.d.ts +8 -0
- package/types/hooks/sender-history.d.ts +41 -0
- package/types/hooks/sender.d.ts +101 -0
- package/types/hooks/session-list.d.ts +36 -0
- package/types/hooks/sse.d.ts +239 -0
- package/types/hooks/storage.d.ts +70 -0
- package/types/hooks/theme.d.ts +37 -0
- package/types/hooks/use-density.d.ts +66 -0
- package/types/hooks/use-empty-state-center.d.ts +23 -0
- package/types/hooks/use-keyboard-inset.d.ts +37 -0
- package/types/index.d.ts +26 -0
- package/types/inject/key.d.ts +20 -0
- package/types/types/index.d.ts +612 -0
- package/types/utils/index.d.ts +29 -0
- package/types/utils/json-from-llm.d.ts +35 -0
- package/types/utils/request-llm.d.ts +44 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, openBlock, createBlock, withCtx, createElementVNode, toDisplayString, createElementBlock, createCommentVNode, normalizeClass, createVNode, unref, resolveDynamicComponent, createTextVNode, Fragment } from "vue";
|
|
2
|
+
import { ElIcon } from "element-plus";
|
|
3
|
+
import { Clock, Remove, CircleClose, CircleCheck, Loading, ArrowDown, Document } from "@element-plus/icons-vue";
|
|
4
|
+
import AiThinkBox from "./AiThinkBox.vue.mjs";
|
|
5
|
+
const _hoisted_1 = { class: "ai-part-renderer-reasoning-text" };
|
|
6
|
+
const _hoisted_2 = {
|
|
7
|
+
key: 1,
|
|
8
|
+
class: "ai-part-renderer ai-part-renderer_tool"
|
|
9
|
+
};
|
|
10
|
+
const _hoisted_3 = ["aria-expanded"];
|
|
11
|
+
const _hoisted_4 = { class: "ai-part-renderer-tool-name" };
|
|
12
|
+
const _hoisted_5 = {
|
|
13
|
+
key: 0,
|
|
14
|
+
class: "ai-part-renderer-tool-preview"
|
|
15
|
+
};
|
|
16
|
+
const _hoisted_6 = {
|
|
17
|
+
key: 0,
|
|
18
|
+
class: "ai-part-renderer-tool-body"
|
|
19
|
+
};
|
|
20
|
+
const _hoisted_7 = { class: "ai-part-renderer-pre" };
|
|
21
|
+
const _hoisted_8 = { class: "ai-part-renderer-pre" };
|
|
22
|
+
const _hoisted_9 = {
|
|
23
|
+
key: 2,
|
|
24
|
+
class: "ai-part-renderer-error"
|
|
25
|
+
};
|
|
26
|
+
const _hoisted_10 = {
|
|
27
|
+
key: 2,
|
|
28
|
+
class: "ai-part-renderer ai-part-renderer_file"
|
|
29
|
+
};
|
|
30
|
+
const _hoisted_11 = ["src", "alt"];
|
|
31
|
+
const _hoisted_12 = {
|
|
32
|
+
key: 1,
|
|
33
|
+
class: "ai-part-renderer-file"
|
|
34
|
+
};
|
|
35
|
+
const _hoisted_13 = {
|
|
36
|
+
key: 3,
|
|
37
|
+
class: "ai-part-renderer ai-part-renderer_unsupported"
|
|
38
|
+
};
|
|
39
|
+
const _hoisted_14 = { class: "ai-message-list-unsupported" };
|
|
40
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
41
|
+
__name: "AiPartRenderer",
|
|
42
|
+
props: {
|
|
43
|
+
part: {},
|
|
44
|
+
item: {}
|
|
45
|
+
},
|
|
46
|
+
setup(__props) {
|
|
47
|
+
const props = __props;
|
|
48
|
+
const isCollapsed = ref(true);
|
|
49
|
+
const toggle = () => {
|
|
50
|
+
isCollapsed.value = !isCollapsed.value;
|
|
51
|
+
};
|
|
52
|
+
const TOOL_STATE_META = {
|
|
53
|
+
"input-streaming": { label: "参数流式中", kind: "streaming", icon: Loading },
|
|
54
|
+
"input-available": { label: "待执行", kind: "pending", icon: Clock },
|
|
55
|
+
"output-available": { label: "已完成", kind: "success", icon: CircleCheck },
|
|
56
|
+
"output-error": { label: "失败", kind: "danger", icon: CircleClose },
|
|
57
|
+
"output-denied": { label: "已拒绝", kind: "warning", icon: Remove }
|
|
58
|
+
};
|
|
59
|
+
const toolStateMeta = computed(() => {
|
|
60
|
+
if (props.part.type !== "tool-call") {
|
|
61
|
+
return { label: "", kind: "pending", icon: Clock };
|
|
62
|
+
}
|
|
63
|
+
return TOOL_STATE_META[props.part.state] ?? {
|
|
64
|
+
// 未知态原样展示(中性 pill),[MUST NOT] 吞掉 wire 上的新状态
|
|
65
|
+
label: props.part.state,
|
|
66
|
+
kind: "pending",
|
|
67
|
+
icon: Clock
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
const inputPreview = computed(() => {
|
|
71
|
+
if (props.part.type !== "tool-call" || props.part.input === void 0) {
|
|
72
|
+
return "";
|
|
73
|
+
}
|
|
74
|
+
const raw = typeof props.part.input === "string" ? props.part.input : stringifyCompact(props.part.input);
|
|
75
|
+
return raw.length > 120 ? `${raw.slice(0, 120)}…` : raw;
|
|
76
|
+
});
|
|
77
|
+
const isImage = (mediaType) => mediaType.startsWith("image/");
|
|
78
|
+
const stringifyCompact = (value) => {
|
|
79
|
+
try {
|
|
80
|
+
return JSON.stringify(value) ?? String(value);
|
|
81
|
+
} catch {
|
|
82
|
+
return String(value);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const stringify = (value) => {
|
|
86
|
+
if (typeof value === "string") {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
try {
|
|
90
|
+
return JSON.stringify(value, null, 2);
|
|
91
|
+
} catch {
|
|
92
|
+
return String(value);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const warnedKeys = /* @__PURE__ */ new Set();
|
|
96
|
+
const unsupportedHint = (part) => {
|
|
97
|
+
if (!warnedKeys.has(part.type)) {
|
|
98
|
+
warnedKeys.add(part.type);
|
|
99
|
+
console.warn(
|
|
100
|
+
`[AiMessageList] 未提供 #part slot,data part「${part.type}」未被渲染。`
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
return `[unsupported part: ${part.type}]`;
|
|
104
|
+
};
|
|
105
|
+
return (_ctx, _cache) => {
|
|
106
|
+
return __props.part.type === "reasoning" ? (openBlock(), createBlock(AiThinkBox, {
|
|
107
|
+
key: 0,
|
|
108
|
+
class: "ai-part-renderer ai-part-renderer_reasoning",
|
|
109
|
+
"is-thinking": __props.part.state === "streaming",
|
|
110
|
+
item: __props.item,
|
|
111
|
+
"think-time": __props.part.thinkTime
|
|
112
|
+
}, {
|
|
113
|
+
default: withCtx(() => [
|
|
114
|
+
createElementVNode("div", _hoisted_1, toDisplayString(__props.part.text), 1)
|
|
115
|
+
]),
|
|
116
|
+
_: 1
|
|
117
|
+
}, 8, ["is-thinking", "item", "think-time"])) : __props.part.type === "tool-call" ? (openBlock(), createElementBlock("div", _hoisted_2, [
|
|
118
|
+
createElementVNode("button", {
|
|
119
|
+
class: "ai-part-renderer-tool-head",
|
|
120
|
+
type: "button",
|
|
121
|
+
"aria-expanded": !isCollapsed.value,
|
|
122
|
+
onClick: toggle
|
|
123
|
+
}, [
|
|
124
|
+
createElementVNode("span", _hoisted_4, toDisplayString(__props.part.name), 1),
|
|
125
|
+
inputPreview.value ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(inputPreview.value), 1)) : createCommentVNode("", true),
|
|
126
|
+
createElementVNode("span", {
|
|
127
|
+
class: normalizeClass(["ai-part-renderer-tool-pill", `ai-part-renderer-tool-pill_${toolStateMeta.value.kind}`])
|
|
128
|
+
}, [
|
|
129
|
+
createVNode(unref(ElIcon), {
|
|
130
|
+
class: normalizeClass({
|
|
131
|
+
"ai-part-renderer-tool-pill-spin": toolStateMeta.value.kind === "streaming"
|
|
132
|
+
})
|
|
133
|
+
}, {
|
|
134
|
+
default: withCtx(() => [
|
|
135
|
+
(openBlock(), createBlock(resolveDynamicComponent(toolStateMeta.value.icon)))
|
|
136
|
+
]),
|
|
137
|
+
_: 1
|
|
138
|
+
}, 8, ["class"]),
|
|
139
|
+
createTextVNode(" " + toDisplayString(toolStateMeta.value.label), 1)
|
|
140
|
+
], 2),
|
|
141
|
+
createVNode(unref(ElIcon), {
|
|
142
|
+
class: normalizeClass(["ai-part-renderer-arrow", { "ai-part-renderer-arrow_collapsed": isCollapsed.value }])
|
|
143
|
+
}, {
|
|
144
|
+
default: withCtx(() => [
|
|
145
|
+
createVNode(unref(ArrowDown))
|
|
146
|
+
]),
|
|
147
|
+
_: 1
|
|
148
|
+
}, 8, ["class"])
|
|
149
|
+
], 8, _hoisted_3),
|
|
150
|
+
!isCollapsed.value ? (openBlock(), createElementBlock("div", _hoisted_6, [
|
|
151
|
+
__props.part.input !== void 0 ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
152
|
+
_cache[0] || (_cache[0] = createElementVNode("div", { class: "ai-part-renderer-label" }, "入参", -1)),
|
|
153
|
+
createElementVNode("pre", _hoisted_7, toDisplayString(stringify(__props.part.input)), 1)
|
|
154
|
+
], 64)) : createCommentVNode("", true),
|
|
155
|
+
__props.part.output !== void 0 ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
156
|
+
_cache[1] || (_cache[1] = createElementVNode("div", { class: "ai-part-renderer-label" }, "结果", -1)),
|
|
157
|
+
createElementVNode("pre", _hoisted_8, toDisplayString(stringify(__props.part.output)), 1)
|
|
158
|
+
], 64)) : createCommentVNode("", true),
|
|
159
|
+
__props.part.errorText ? (openBlock(), createElementBlock("span", _hoisted_9, toDisplayString(__props.part.errorText), 1)) : createCommentVNode("", true)
|
|
160
|
+
])) : createCommentVNode("", true)
|
|
161
|
+
])) : __props.part.type === "file" ? (openBlock(), createElementBlock("div", _hoisted_10, [
|
|
162
|
+
isImage(__props.part.mediaType) && __props.part.url ? (openBlock(), createElementBlock("img", {
|
|
163
|
+
key: 0,
|
|
164
|
+
class: "ai-part-renderer-img",
|
|
165
|
+
src: __props.part.url,
|
|
166
|
+
alt: __props.part.filename || "附件"
|
|
167
|
+
}, null, 8, _hoisted_11)) : (openBlock(), createElementBlock("div", _hoisted_12, [
|
|
168
|
+
createVNode(unref(ElIcon), null, {
|
|
169
|
+
default: withCtx(() => [
|
|
170
|
+
createVNode(unref(Document))
|
|
171
|
+
]),
|
|
172
|
+
_: 1
|
|
173
|
+
}),
|
|
174
|
+
createElementVNode("span", null, toDisplayString(__props.part.filename || __props.part.mediaType), 1)
|
|
175
|
+
]))
|
|
176
|
+
])) : (openBlock(), createElementBlock("div", _hoisted_13, [
|
|
177
|
+
createElementVNode("span", _hoisted_14, toDisplayString(unsupportedHint(__props.part)), 1)
|
|
178
|
+
]));
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
export {
|
|
183
|
+
_sfc_main as default
|
|
184
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _sfc_main from "./AiThinkBox.vue2.mjs";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
|
|
4
|
+
const AiThinkBox = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-02b60f7b"]]);
|
|
5
|
+
export {
|
|
6
|
+
AiThinkBox as default
|
|
7
|
+
};
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { defineComponent, useCssVars, computed, ref, watch, shallowRef, onMounted, onBeforeUnmount, openBlock, createElementBlock, createElementVNode, withKeys, withModifiers, Fragment, createTextVNode, toDisplayString, createCommentVNode, normalizeClass, createVNode, unref, withCtx, normalizeStyle, renderSlot } from "vue";
|
|
2
|
+
import { ArrowDown } from "@element-plus/icons-vue";
|
|
3
|
+
import { ElIcon } from "element-plus";
|
|
4
|
+
import _debounce from "lodash/debounce.js";
|
|
5
|
+
const _hoisted_1 = { class: "ai-think-box" };
|
|
6
|
+
const _hoisted_2 = ["aria-expanded", "onKeydown"];
|
|
7
|
+
const _hoisted_3 = { key: 0 };
|
|
8
|
+
const _hoisted_4 = { key: 0 };
|
|
9
|
+
const _hoisted_5 = { key: 1 };
|
|
10
|
+
const _hoisted_6 = { key: 0 };
|
|
11
|
+
const _hoisted_7 = ["id"];
|
|
12
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
13
|
+
__name: "AiThinkBox",
|
|
14
|
+
props: {
|
|
15
|
+
isThinking: { type: Boolean, default: true },
|
|
16
|
+
item: {},
|
|
17
|
+
thinkTime: {}
|
|
18
|
+
},
|
|
19
|
+
setup(__props) {
|
|
20
|
+
useCssVars((_ctx) => ({
|
|
21
|
+
"v172804b0": innerHeight.value
|
|
22
|
+
}));
|
|
23
|
+
const props = __props;
|
|
24
|
+
const thinkTimeShow = computed(() => {
|
|
25
|
+
var _a;
|
|
26
|
+
return props.thinkTime ?? ((_a = props.item) == null ? void 0 : _a.thinkTime);
|
|
27
|
+
});
|
|
28
|
+
const isCollapsed = ref(false);
|
|
29
|
+
const userToggled = ref(false);
|
|
30
|
+
watch(
|
|
31
|
+
() => props.isThinking,
|
|
32
|
+
(thinking) => {
|
|
33
|
+
if (userToggled.value) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
isCollapsed.value = thinking;
|
|
37
|
+
},
|
|
38
|
+
{ immediate: true }
|
|
39
|
+
);
|
|
40
|
+
const aiThinkContentInnerId = ref(
|
|
41
|
+
`ai-think-content-inner_${Math.random().toString(36).slice(2)}`
|
|
42
|
+
);
|
|
43
|
+
const innerHeight = ref();
|
|
44
|
+
const openContentHeightTransition = ref(false);
|
|
45
|
+
const timer = ref();
|
|
46
|
+
const resizeObserver = shallowRef();
|
|
47
|
+
const contentStyle = computed(() => {
|
|
48
|
+
return !props.isThinking || openContentHeightTransition.value ? {
|
|
49
|
+
transition: "height 0.3s"
|
|
50
|
+
} : {};
|
|
51
|
+
});
|
|
52
|
+
const clearTimer = () => {
|
|
53
|
+
if (timer.value) {
|
|
54
|
+
clearTimeout(timer.value);
|
|
55
|
+
timer.value = void 0;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const handleToggle = () => {
|
|
59
|
+
clearTimer();
|
|
60
|
+
userToggled.value = true;
|
|
61
|
+
openContentHeightTransition.value = true;
|
|
62
|
+
isCollapsed.value = !isCollapsed.value;
|
|
63
|
+
timer.value = setTimeout(() => {
|
|
64
|
+
const dom = document.getElementById(aiThinkContentInnerId.value);
|
|
65
|
+
if (!dom) {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const listParent = dom.closest(".el-bubble-list");
|
|
69
|
+
if (listParent) {
|
|
70
|
+
const event = new Event("scroll");
|
|
71
|
+
listParent.dispatchEvent(event);
|
|
72
|
+
}
|
|
73
|
+
}, 301);
|
|
74
|
+
};
|
|
75
|
+
const handleResize = _debounce(
|
|
76
|
+
(entries) => {
|
|
77
|
+
const dom = document.getElementById(aiThinkContentInnerId.value);
|
|
78
|
+
if (!dom) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const targetDom = Object.values(entries).find((e) => e.target === dom);
|
|
82
|
+
if (targetDom) {
|
|
83
|
+
innerHeight.value = `${targetDom.contentRect.height}px`;
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
100,
|
|
87
|
+
{
|
|
88
|
+
maxWait: 300
|
|
89
|
+
}
|
|
90
|
+
);
|
|
91
|
+
onMounted(() => {
|
|
92
|
+
const dom = document.getElementById(aiThinkContentInnerId.value);
|
|
93
|
+
resizeObserver.value = new ResizeObserver(handleResize);
|
|
94
|
+
if (!dom) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
resizeObserver.value.observe(dom);
|
|
98
|
+
});
|
|
99
|
+
onBeforeUnmount(() => {
|
|
100
|
+
var _a;
|
|
101
|
+
handleResize.cancel();
|
|
102
|
+
(_a = resizeObserver.value) == null ? void 0 : _a.disconnect();
|
|
103
|
+
resizeObserver.value = void 0;
|
|
104
|
+
clearTimer();
|
|
105
|
+
});
|
|
106
|
+
return (_ctx, _cache) => {
|
|
107
|
+
var _a;
|
|
108
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
109
|
+
createElementVNode("div", {
|
|
110
|
+
class: "ai-think-title",
|
|
111
|
+
role: "button",
|
|
112
|
+
tabindex: "0",
|
|
113
|
+
"aria-expanded": isCollapsed.value,
|
|
114
|
+
onClick: handleToggle,
|
|
115
|
+
onKeydown: [
|
|
116
|
+
withKeys(withModifiers(handleToggle, ["prevent"]), ["enter"]),
|
|
117
|
+
withKeys(withModifiers(handleToggle, ["prevent"]), ["space"])
|
|
118
|
+
]
|
|
119
|
+
}, [
|
|
120
|
+
__props.isThinking ? (openBlock(), createElementBlock("span", _hoisted_3, "正在思考")) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
121
|
+
((_a = __props.item) == null ? void 0 : _a.isAborted) ? (openBlock(), createElementBlock("span", _hoisted_4, "已停止")) : (openBlock(), createElementBlock("span", _hoisted_5, [
|
|
122
|
+
_cache[2] || (_cache[2] = createTextVNode("已思考", -1)),
|
|
123
|
+
thinkTimeShow.value ? (openBlock(), createElementBlock("span", _hoisted_6, [
|
|
124
|
+
_cache[0] || (_cache[0] = createTextVNode("(", -1)),
|
|
125
|
+
createElementVNode("span", null, toDisplayString(thinkTimeShow.value) + "秒", 1),
|
|
126
|
+
_cache[1] || (_cache[1] = createTextVNode(")", -1))
|
|
127
|
+
])) : createCommentVNode("", true)
|
|
128
|
+
]))
|
|
129
|
+
], 64)),
|
|
130
|
+
createElementVNode("span", {
|
|
131
|
+
class: normalizeClass(["ai-think-icon", { "ai-think-icon_collapse": isCollapsed.value }])
|
|
132
|
+
}, [
|
|
133
|
+
createVNode(unref(ElIcon), null, {
|
|
134
|
+
default: withCtx(() => [
|
|
135
|
+
createVNode(unref(ArrowDown))
|
|
136
|
+
]),
|
|
137
|
+
_: 1
|
|
138
|
+
})
|
|
139
|
+
], 2)
|
|
140
|
+
], 40, _hoisted_2),
|
|
141
|
+
createElementVNode("div", {
|
|
142
|
+
class: normalizeClass(["ai-think-content", { "ai-think-content_collapse": isCollapsed.value }]),
|
|
143
|
+
style: normalizeStyle(contentStyle.value)
|
|
144
|
+
}, [
|
|
145
|
+
createElementVNode("div", { id: aiThinkContentInnerId.value }, [
|
|
146
|
+
renderSlot(_ctx.$slots, "default", {}, void 0, true)
|
|
147
|
+
], 8, _hoisted_7)
|
|
148
|
+
], 6)
|
|
149
|
+
]);
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
export {
|
|
154
|
+
_sfc_main as default
|
|
155
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { defineComponent, ref, computed, watch, onBeforeUnmount, renderSlot } from "vue";
|
|
2
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
3
|
+
__name: "AiTypewriter",
|
|
4
|
+
props: {
|
|
5
|
+
item: {},
|
|
6
|
+
disabled: { type: Boolean },
|
|
7
|
+
step: { default: 2 },
|
|
8
|
+
interval: { default: 50 },
|
|
9
|
+
suffix: { default: "|" }
|
|
10
|
+
},
|
|
11
|
+
emits: ["finished"],
|
|
12
|
+
setup(__props, { emit: __emit }) {
|
|
13
|
+
const props = __props;
|
|
14
|
+
const emits = __emit;
|
|
15
|
+
const timer = ref();
|
|
16
|
+
const index = ref(Math.ceil(7 / props.step));
|
|
17
|
+
const content = computed(() => props.item.content || "");
|
|
18
|
+
const textShow = computed(() => {
|
|
19
|
+
if (props.disabled) {
|
|
20
|
+
return content.value;
|
|
21
|
+
}
|
|
22
|
+
return content.value.slice(0, index.value * props.step);
|
|
23
|
+
});
|
|
24
|
+
const needChangeIndex = computed(() => {
|
|
25
|
+
return content.value.length > textShow.value.length && !props.disabled;
|
|
26
|
+
});
|
|
27
|
+
const textShowWithSuffix = computed(
|
|
28
|
+
() => `${textShow.value}${needChangeIndex.value ? props.suffix : ""}`
|
|
29
|
+
);
|
|
30
|
+
const clearTimer = () => {
|
|
31
|
+
if (timer.value) {
|
|
32
|
+
clearTimeout(timer.value);
|
|
33
|
+
timer.value = void 0;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const changeIndex = () => {
|
|
37
|
+
if (timer.value) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
index.value += 1;
|
|
41
|
+
if (needChangeIndex.value) {
|
|
42
|
+
timer.value = setTimeout(() => {
|
|
43
|
+
clearTimer();
|
|
44
|
+
changeIndex();
|
|
45
|
+
}, props.interval);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const unwatch = watch(
|
|
49
|
+
[() => content.value.length, () => textShow.value.length],
|
|
50
|
+
() => {
|
|
51
|
+
if (needChangeIndex.value) {
|
|
52
|
+
changeIndex();
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
immediate: true
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
watch(
|
|
60
|
+
() => !props.disabled && props.item.isFinished && !needChangeIndex.value,
|
|
61
|
+
(n) => {
|
|
62
|
+
if (n) {
|
|
63
|
+
emits("finished");
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
immediate: true
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
onBeforeUnmount(() => {
|
|
71
|
+
unwatch();
|
|
72
|
+
clearTimer();
|
|
73
|
+
});
|
|
74
|
+
return (_ctx, _cache) => {
|
|
75
|
+
return renderSlot(_ctx.$slots, "default", { textShow: textShowWithSuffix.value });
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
export {
|
|
80
|
+
_sfc_main as default
|
|
81
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { defineComponent, renderSlot } from "vue";
|
|
2
|
+
import { useAiExposeProvide } from "../../hooks/expose.mjs";
|
|
3
|
+
import { useAiModuleTheme } from "../../hooks/theme.mjs";
|
|
4
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
5
|
+
__name: "AiConfigProvider",
|
|
6
|
+
props: {
|
|
7
|
+
isDarkTheme: { type: Boolean }
|
|
8
|
+
},
|
|
9
|
+
setup(__props, { expose: __expose }) {
|
|
10
|
+
const props = __props;
|
|
11
|
+
const { aiExpose } = useAiExposeProvide();
|
|
12
|
+
useAiModuleTheme(() => props.isDarkTheme);
|
|
13
|
+
__expose({
|
|
14
|
+
/** 向**当前激活会话**发一条消息(等价快捷问题卡的点击) */
|
|
15
|
+
ask: (params) => {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
return (_b = (_a = aiExpose.value).ask) == null ? void 0 : _b.call(_a, params);
|
|
18
|
+
},
|
|
19
|
+
/** 当前激活会话的输入框(focus / blur / openHeader / closeHeader) */
|
|
20
|
+
sender: () => aiExpose.value.sender,
|
|
21
|
+
/** 会话级操作(create / switch)——由 AiDialogueGroup 注册,单会话场景为 undefined */
|
|
22
|
+
sessionOperate: () => aiExpose.value.sessionOperate
|
|
23
|
+
});
|
|
24
|
+
return (_ctx, _cache) => {
|
|
25
|
+
return renderSlot(_ctx.$slots, "default");
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
export {
|
|
30
|
+
_sfc_main as default
|
|
31
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import _sfc_main from "./AiDialogue.vue2.mjs";
|
|
2
|
+
/* empty css */
|
|
3
|
+
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.mjs";
|
|
4
|
+
const AiDialogue = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-2da88577"]]);
|
|
5
|
+
export {
|
|
6
|
+
AiDialogue as default
|
|
7
|
+
};
|