@done-coding/forge-kit-agent 0.0.0-stage → 0.100.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 +53 -2
- 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 +83 -4
- 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,253 @@
|
|
|
1
|
+
import { computed, onMounted, onBeforeUnmount, watch } from "vue";
|
|
2
|
+
const DEFAULTS = {
|
|
3
|
+
colorPrimary: "#409eff",
|
|
4
|
+
colorSuccess: "#67c23a",
|
|
5
|
+
colorWarning: "#e6a23c",
|
|
6
|
+
colorDanger: "#f56c6c",
|
|
7
|
+
colorError: "#f56c6c",
|
|
8
|
+
colorInfo: "#909399",
|
|
9
|
+
text: "#303133",
|
|
10
|
+
// 暗色下文字终极兜底(Element Plus 暗色默认正文色)——host 未注入暗色 --el-text-color-primary /
|
|
11
|
+
// --dc-core-base-color 时,--dc-agent-text 终极 fallback 随明暗切换,避免暗背景上退化深字。
|
|
12
|
+
textDark: "#e5eaf3",
|
|
13
|
+
// 次级文本(工具卡入参预览 / 空列表文案等弱化信息;q21yfk 判据 2/9)
|
|
14
|
+
textSecondary: "#909399",
|
|
15
|
+
bg: "#ffffff",
|
|
16
|
+
border: "#dcdfe6",
|
|
17
|
+
radius: "4px",
|
|
18
|
+
shadow: "0 2px 12px 0 rgba(0,0,0,.1)",
|
|
19
|
+
surface: "#ffffff",
|
|
20
|
+
// 默认 focus-ring 经 color-mix 派生自主色 → 切 26 主题随主色变(仍保留 --dc-core-focus-ring 覆盖优先)
|
|
21
|
+
focusRing: "0 0 0 2px color-mix(in srgb, var(--dc-agent-color-primary) 30%, transparent)",
|
|
22
|
+
bubbleBgDark: "rgba(255, 255, 255, 0.08)",
|
|
23
|
+
bubbleBgLight: "rgba(0, 0, 0, 0.05)",
|
|
24
|
+
// 消费依赖 XMarkdown 代码块头部 chrome 的兜底原值(vitesse-light),桥接链末位
|
|
25
|
+
codeHeaderBg: "#fafafa",
|
|
26
|
+
codeHeaderBtnBg: "#ebedf0"
|
|
27
|
+
};
|
|
28
|
+
const REFERENCE_REM_PX = 39;
|
|
29
|
+
const AGENT_UI_DENSITY_TOKENS = [
|
|
30
|
+
// —— 排版字阶(scale) ——
|
|
31
|
+
{
|
|
32
|
+
// 空态欢迎语专档(q21yfk 判据 8/D7:与 lg 拉开量级;不取豆包 28px——常嵌窄浮层/侧栏)
|
|
33
|
+
cssVar: "--dc-agent-font-size-xl",
|
|
34
|
+
pcDefault: "22px",
|
|
35
|
+
unit: "scale",
|
|
36
|
+
basePx: 22
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
cssVar: "--dc-agent-font-size-lg",
|
|
40
|
+
pcDefault: "18px",
|
|
41
|
+
unit: "scale",
|
|
42
|
+
basePx: 18
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
cssVar: "--dc-agent-font-size-base",
|
|
46
|
+
pcDefault: "16px",
|
|
47
|
+
unit: "scale",
|
|
48
|
+
basePx: 16
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
cssVar: "--dc-agent-font-size-sm",
|
|
52
|
+
pcDefault: "13px",
|
|
53
|
+
unit: "scale",
|
|
54
|
+
basePx: 13
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
cssVar: "--dc-agent-font-size-xs",
|
|
58
|
+
pcDefault: "12px",
|
|
59
|
+
unit: "scale",
|
|
60
|
+
basePx: 12
|
|
61
|
+
},
|
|
62
|
+
// —— 间距阶梯(scale) ——
|
|
63
|
+
{
|
|
64
|
+
cssVar: "--dc-agent-space-1",
|
|
65
|
+
pcDefault: "4px",
|
|
66
|
+
unit: "scale",
|
|
67
|
+
basePx: 4
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
cssVar: "--dc-agent-space-2",
|
|
71
|
+
pcDefault: "8px",
|
|
72
|
+
unit: "scale",
|
|
73
|
+
basePx: 8
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
cssVar: "--dc-agent-space-3",
|
|
77
|
+
pcDefault: "12px",
|
|
78
|
+
unit: "scale",
|
|
79
|
+
basePx: 12
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
cssVar: "--dc-agent-space-4",
|
|
83
|
+
pcDefault: "16px",
|
|
84
|
+
unit: "scale",
|
|
85
|
+
basePx: 16
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
cssVar: "--dc-agent-space-6",
|
|
89
|
+
pcDefault: "24px",
|
|
90
|
+
unit: "scale",
|
|
91
|
+
basePx: 24
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
cssVar: "--dc-agent-space-8",
|
|
95
|
+
pcDefault: "32px",
|
|
96
|
+
unit: "scale",
|
|
97
|
+
basePx: 32
|
|
98
|
+
},
|
|
99
|
+
// —— 圆角(scale) ——
|
|
100
|
+
{
|
|
101
|
+
cssVar: "--dc-agent-radius-lg",
|
|
102
|
+
pcDefault: "12px",
|
|
103
|
+
unit: "scale",
|
|
104
|
+
basePx: 12
|
|
105
|
+
},
|
|
106
|
+
// —— 阅读列宽(viewport:移动端满宽,PC 768px 上限) ——
|
|
107
|
+
{
|
|
108
|
+
cssVar: "--dc-agent-read-width",
|
|
109
|
+
pcDefault: "768px",
|
|
110
|
+
unit: "viewport",
|
|
111
|
+
mobileValue: "100%"
|
|
112
|
+
},
|
|
113
|
+
// —— 触摸目标 / 输入栏高度(移动端新增缩放档;PC touch-target 不约束=auto) ——
|
|
114
|
+
{
|
|
115
|
+
cssVar: "--dc-agent-touch-target",
|
|
116
|
+
pcDefault: "auto",
|
|
117
|
+
unit: "scale",
|
|
118
|
+
basePx: 44
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
cssVar: "--dc-agent-sender-height",
|
|
122
|
+
pcDefault: "112px",
|
|
123
|
+
unit: "scale",
|
|
124
|
+
basePx: 112
|
|
125
|
+
},
|
|
126
|
+
// —— 面板形态(viewport:移动端全屏贴边、PC 浮卡) ——
|
|
127
|
+
{
|
|
128
|
+
cssVar: "--dc-agent-panel-width",
|
|
129
|
+
pcDefault: "clamp(400px, var(--dc-core-viewport-width, 100vw), 1000px)",
|
|
130
|
+
unit: "viewport",
|
|
131
|
+
mobileValue: "100vw"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
cssVar: "--dc-agent-panel-height",
|
|
135
|
+
pcDefault: "var(--dc-core-viewport-height, 100vh)",
|
|
136
|
+
unit: "viewport",
|
|
137
|
+
mobileValue: "100svh"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
cssVar: "--dc-agent-panel-radius",
|
|
141
|
+
pcDefault: "var(--dc-agent-radius-lg)",
|
|
142
|
+
unit: "viewport",
|
|
143
|
+
mobileValue: "0"
|
|
144
|
+
},
|
|
145
|
+
// —— 保 px(不随密度缩放:亚像素发虚 / 焦点环宽度) ——
|
|
146
|
+
{
|
|
147
|
+
cssVar: "--dc-agent-border-width-hairline",
|
|
148
|
+
pcDefault: "1px",
|
|
149
|
+
unit: "keep-px"
|
|
150
|
+
},
|
|
151
|
+
{ cssVar: "--dc-agent-focus-ring-width", pcDefault: "2px", unit: "keep-px" }
|
|
152
|
+
];
|
|
153
|
+
const buildClassATokens = () => `
|
|
154
|
+
--dc-agent-color-primary: var(--dc-core-primary-color, var(--el-color-primary, ${DEFAULTS.colorPrimary}));
|
|
155
|
+
--dc-agent-color-success: var(--dc-core-success-color, var(--el-color-success, ${DEFAULTS.colorSuccess}));
|
|
156
|
+
--dc-agent-color-warning: var(--dc-core-warning-color, var(--el-color-warning, ${DEFAULTS.colorWarning}));
|
|
157
|
+
--dc-agent-color-danger: var(--dc-core-danger-color, var(--el-color-danger, ${DEFAULTS.colorDanger}));
|
|
158
|
+
--dc-agent-color-error: var(--dc-core-error-color, var(--el-color-error, ${DEFAULTS.colorError}));
|
|
159
|
+
--dc-agent-color-info: var(--dc-core-info-color, var(--el-color-info, ${DEFAULTS.colorInfo}));
|
|
160
|
+
--dc-agent-text: var(--dc-core-base-color, var(--el-text-color-primary, var(--dc-agent-text-fallback)));
|
|
161
|
+
--dc-agent-text-secondary: var(--dc-core-text-secondary, var(--el-text-color-secondary, ${DEFAULTS.textSecondary}));
|
|
162
|
+
--dc-agent-bg: var(--dc-core-body-color, var(--el-bg-color, ${DEFAULTS.bg}));
|
|
163
|
+
--dc-agent-border: var(--dc-core-border-color, var(--el-border-color, ${DEFAULTS.border}));
|
|
164
|
+
--dc-agent-radius: var(--dc-core-radius, var(--el-border-radius-base, ${DEFAULTS.radius}));
|
|
165
|
+
--dc-agent-shadow: var(--dc-core-shadow, var(--el-box-shadow, ${DEFAULTS.shadow}));`;
|
|
166
|
+
const buildClassBTokens = () => `
|
|
167
|
+
--dc-agent-surface: var(--dc-core-surface, ${DEFAULTS.surface});
|
|
168
|
+
--dc-agent-accent: var(--dc-core-accent, var(--dc-agent-color-primary));
|
|
169
|
+
--dc-agent-focus-ring: var(--dc-core-focus-ring, ${DEFAULTS.focusRing});`;
|
|
170
|
+
const buildFormTokens = () => `
|
|
171
|
+
--dc-agent-line-height-base: 1.6;
|
|
172
|
+
--dc-agent-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
173
|
+
--dc-agent-motion-fast: 150ms;
|
|
174
|
+
--dc-agent-motion-base: 220ms;
|
|
175
|
+
--dc-agent-motion-spin: 3000ms;
|
|
176
|
+
--dc-agent-ease: cubic-bezier(.4, 0, .2, 1);
|
|
177
|
+
--dc-agent-shimmer-duration: 1000ms;`;
|
|
178
|
+
const buildDensityDefaultTokens = () => AGENT_UI_DENSITY_TOKENS.map((t) => ` ${t.cssVar}: ${t.pcDefault};`).join(
|
|
179
|
+
"\n"
|
|
180
|
+
);
|
|
181
|
+
const buildEnvTokens = () => `
|
|
182
|
+
--dc-agent-safe-top: env(safe-area-inset-top, 0px);
|
|
183
|
+
--dc-agent-safe-bottom: env(safe-area-inset-bottom, 0px);
|
|
184
|
+
--dc-agent-keyboard-inset: 0px;`;
|
|
185
|
+
const buildElBridgeRules = () => `
|
|
186
|
+
[data-agent-ui-density] {
|
|
187
|
+
--el-font-size-base: var(--dc-agent-font-size-base);
|
|
188
|
+
--el-component-size: var(--dc-agent-touch-target);
|
|
189
|
+
}`;
|
|
190
|
+
const buildDarkDependentTokens = (isDark) => `
|
|
191
|
+
--dc-agent-bubble-bg: var(--dc-core-bubble-bg, ${isDark ? DEFAULTS.bubbleBgDark : DEFAULTS.bubbleBgLight});
|
|
192
|
+
--dc-agent-text-fallback: ${isDark ? DEFAULTS.textDark : DEFAULTS.text};`;
|
|
193
|
+
const buildMarkdownBridgeTokens = () => `
|
|
194
|
+
--shiki-code-header-bg: var(--dc-core-code-header-bg, var(--dc-agent-bubble-bg, ${DEFAULTS.codeHeaderBg}));
|
|
195
|
+
--shiki-code-header-span-color: var(--dc-core-base-color, var(--dc-agent-text, ${DEFAULTS.text}));
|
|
196
|
+
--shiki-code-header-btn-bg: var(--dc-core-code-header-btn-bg, var(--dc-agent-bubble-bg, ${DEFAULTS.codeHeaderBtnBg}));`;
|
|
197
|
+
const buildMarkdownRules = (isDark) => `
|
|
198
|
+
:root body .elx-xmarkdown-container .inline-code-tag {
|
|
199
|
+
background: color-mix(in srgb, var(--dc-agent-color-primary) 12%, transparent)!important;
|
|
200
|
+
color: var(--dc-agent-color-primary)!important;
|
|
201
|
+
border-color: color-mix(in srgb, var(--dc-agent-color-primary) 24%, transparent)!important;
|
|
202
|
+
}${isDark ? `
|
|
203
|
+
:root body .elx-xmarkdown-container .shiki {
|
|
204
|
+
background-color: var(--shiki-dark-bg)!important;
|
|
205
|
+
}
|
|
206
|
+
:root body .elx-xmarkdown-container .shiki,
|
|
207
|
+
:root body .elx-xmarkdown-container .shiki span {
|
|
208
|
+
color: var(--shiki-dark)!important;
|
|
209
|
+
}` : ""}`;
|
|
210
|
+
const useAiModuleTheme = (getIsDark) => {
|
|
211
|
+
const isDark = computed(getIsDark);
|
|
212
|
+
const style = document.createElement("style");
|
|
213
|
+
style.id = `ai-module-theme_${Math.random().toString(36).slice(2)}`;
|
|
214
|
+
const changeAiModuleTheme = (dark) => {
|
|
215
|
+
style.innerHTML = `:root body {
|
|
216
|
+
${buildClassATokens()}
|
|
217
|
+
${buildClassBTokens()}
|
|
218
|
+
${buildFormTokens()}
|
|
219
|
+
${buildDensityDefaultTokens()}
|
|
220
|
+
${buildEnvTokens()}
|
|
221
|
+
${buildDarkDependentTokens(dark)}
|
|
222
|
+
${buildMarkdownBridgeTokens()}
|
|
223
|
+
}
|
|
224
|
+
:root body .el-bubble-list-default-back-button {
|
|
225
|
+
transform: none!important;
|
|
226
|
+
}
|
|
227
|
+
:root body .el-bubble-list-back-to-bottom-icon svg {
|
|
228
|
+
color: var(--dc-agent-color-primary)!important;
|
|
229
|
+
}
|
|
230
|
+
${buildElBridgeRules()}
|
|
231
|
+
${buildMarkdownRules(dark)}`;
|
|
232
|
+
};
|
|
233
|
+
onMounted(() => {
|
|
234
|
+
document.head.appendChild(style);
|
|
235
|
+
});
|
|
236
|
+
onBeforeUnmount(() => {
|
|
237
|
+
style.remove();
|
|
238
|
+
});
|
|
239
|
+
watch(
|
|
240
|
+
isDark,
|
|
241
|
+
(n) => {
|
|
242
|
+
changeAiModuleTheme(n);
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
immediate: true
|
|
246
|
+
}
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
export {
|
|
250
|
+
AGENT_UI_DENSITY_TOKENS,
|
|
251
|
+
REFERENCE_REM_PX,
|
|
252
|
+
useAiModuleTheme
|
|
253
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
var _a;
|
|
2
|
+
import { onMounted, onBeforeUnmount, watch, toValue } from "vue";
|
|
3
|
+
import { AGENT_UI_DENSITY_TOKENS, REFERENCE_REM_PX } from "./theme.mjs";
|
|
4
|
+
const REM_MIN_PX = 16;
|
|
5
|
+
const REM_CAP = { phone: 43, ipad: 52 };
|
|
6
|
+
const FONT_SIZE_BASE_PX = ((_a = AGENT_UI_DENSITY_TOKENS.find((t) => t.cssVar === "--dc-agent-font-size-base")) == null ? void 0 : _a.basePx) ?? 16;
|
|
7
|
+
function detectDeviceKind(override, probe) {
|
|
8
|
+
if (override === "mobile") return "phone";
|
|
9
|
+
if (override === "desktop") return "pc";
|
|
10
|
+
if (probe.uaDataMobile === true) return "phone";
|
|
11
|
+
const ua = probe.userAgent;
|
|
12
|
+
if (/iPad/.test(ua)) return "ipad";
|
|
13
|
+
if (/iPhone|iPod|HarmonyOS|OpenHarmony/.test(ua)) return "phone";
|
|
14
|
+
if (/Android/.test(ua)) return /Mobile/.test(ua) ? "phone" : "ipad";
|
|
15
|
+
if (/Silk/.test(ua) || /\bTablet\b/.test(ua) && !/Mobile/.test(ua)) {
|
|
16
|
+
return "ipad";
|
|
17
|
+
}
|
|
18
|
+
if (/Mobile/.test(ua)) return "phone";
|
|
19
|
+
if (/Macintosh/.test(ua) && probe.maxTouchPoints > 1) return "ipad";
|
|
20
|
+
return "pc";
|
|
21
|
+
}
|
|
22
|
+
function isMobileKind(kind) {
|
|
23
|
+
return kind !== "pc";
|
|
24
|
+
}
|
|
25
|
+
function computeAgentRemPx(kind, viewportWidth) {
|
|
26
|
+
const cap = kind === "ipad" ? REM_CAP.ipad : REM_CAP.phone;
|
|
27
|
+
return Math.min(Math.max(REM_MIN_PX, viewportWidth / 10), cap);
|
|
28
|
+
}
|
|
29
|
+
function readProbe() {
|
|
30
|
+
var _a2;
|
|
31
|
+
const nav = navigator;
|
|
32
|
+
return {
|
|
33
|
+
userAgent: nav.userAgent,
|
|
34
|
+
uaDataMobile: (_a2 = nav.userAgentData) == null ? void 0 : _a2.mobile,
|
|
35
|
+
maxTouchPoints: nav.maxTouchPoints ?? 0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function useAgentUiDensity(scope, options = {}) {
|
|
39
|
+
let restore = [];
|
|
40
|
+
const revert = () => {
|
|
41
|
+
restore.splice(0).reverse().forEach((fn) => fn());
|
|
42
|
+
};
|
|
43
|
+
const apply = () => {
|
|
44
|
+
const el = scope.value;
|
|
45
|
+
if (!el) return;
|
|
46
|
+
revert();
|
|
47
|
+
const kind = detectDeviceKind(toValue(options.mode) ?? "auto", readProbe());
|
|
48
|
+
if (!isMobileKind(kind)) return;
|
|
49
|
+
const remPx = computeAgentRemPx(kind, window.innerWidth);
|
|
50
|
+
const scale = remPx / REFERENCE_REM_PX;
|
|
51
|
+
const prevDensityAttr = el.getAttribute("data-agent-ui-density");
|
|
52
|
+
restore.push(() => {
|
|
53
|
+
if (prevDensityAttr === null) el.removeAttribute("data-agent-ui-density");
|
|
54
|
+
else el.setAttribute("data-agent-ui-density", prevDensityAttr);
|
|
55
|
+
});
|
|
56
|
+
el.setAttribute("data-agent-ui-density", kind);
|
|
57
|
+
const prevFontSize = el.style.fontSize;
|
|
58
|
+
restore.push(() => {
|
|
59
|
+
el.style.fontSize = prevFontSize;
|
|
60
|
+
});
|
|
61
|
+
el.style.fontSize = `${FONT_SIZE_BASE_PX * scale}px`;
|
|
62
|
+
const setVar = (name, value) => {
|
|
63
|
+
const prev = el.style.getPropertyValue(name);
|
|
64
|
+
restore.push(() => {
|
|
65
|
+
if (prev) el.style.setProperty(name, prev);
|
|
66
|
+
else el.style.removeProperty(name);
|
|
67
|
+
});
|
|
68
|
+
el.style.setProperty(name, value);
|
|
69
|
+
};
|
|
70
|
+
for (const token of AGENT_UI_DENSITY_TOKENS) {
|
|
71
|
+
if (token.unit === "scale" && typeof token.basePx === "number") {
|
|
72
|
+
setVar(token.cssVar, `${token.basePx * scale}px`);
|
|
73
|
+
} else if (token.unit === "viewport" && typeof token.mobileValue === "string") {
|
|
74
|
+
setVar(token.cssVar, token.mobileValue);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const onViewportChange = () => apply();
|
|
79
|
+
onMounted(() => {
|
|
80
|
+
window.addEventListener("resize", onViewportChange);
|
|
81
|
+
window.addEventListener("orientationchange", onViewportChange);
|
|
82
|
+
});
|
|
83
|
+
onBeforeUnmount(() => {
|
|
84
|
+
window.removeEventListener("resize", onViewportChange);
|
|
85
|
+
window.removeEventListener("orientationchange", onViewportChange);
|
|
86
|
+
revert();
|
|
87
|
+
});
|
|
88
|
+
watch([scope, () => toValue(options.mode)], () => apply(), {
|
|
89
|
+
immediate: true
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
export {
|
|
93
|
+
REFERENCE_REM_PX,
|
|
94
|
+
REM_CAP,
|
|
95
|
+
REM_MIN_PX,
|
|
96
|
+
computeAgentRemPx,
|
|
97
|
+
detectDeviceKind,
|
|
98
|
+
isMobileKind,
|
|
99
|
+
useAgentUiDensity
|
|
100
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { ref, watch, onScopeDispose, computed } from "vue";
|
|
2
|
+
const useEmptyStateCenter = (getEl, enabled) => {
|
|
3
|
+
const headerHeight = ref(0);
|
|
4
|
+
let observer;
|
|
5
|
+
const stop = () => {
|
|
6
|
+
observer == null ? void 0 : observer.disconnect();
|
|
7
|
+
observer = void 0;
|
|
8
|
+
};
|
|
9
|
+
const start = () => {
|
|
10
|
+
stop();
|
|
11
|
+
const el = getEl();
|
|
12
|
+
if (!el) return;
|
|
13
|
+
headerHeight.value = el.getBoundingClientRect().height;
|
|
14
|
+
if (typeof ResizeObserver === "undefined") return;
|
|
15
|
+
observer = new ResizeObserver(([entry]) => {
|
|
16
|
+
headerHeight.value = entry.contentRect.height;
|
|
17
|
+
});
|
|
18
|
+
observer.observe(el);
|
|
19
|
+
};
|
|
20
|
+
watch(
|
|
21
|
+
enabled,
|
|
22
|
+
(on) => {
|
|
23
|
+
if (on) {
|
|
24
|
+
requestAnimationFrame(start);
|
|
25
|
+
} else {
|
|
26
|
+
stop();
|
|
27
|
+
headerHeight.value = 0;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
{ immediate: true }
|
|
31
|
+
);
|
|
32
|
+
onScopeDispose(stop);
|
|
33
|
+
const offsetPx = computed(
|
|
34
|
+
() => enabled.value ? `${Math.round(headerHeight.value / 2)}px` : "0px"
|
|
35
|
+
);
|
|
36
|
+
return { offsetPx, headerHeight };
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
useEmptyStateCenter
|
|
40
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { onMounted, onBeforeUnmount, watch, toValue } from "vue";
|
|
2
|
+
import { isMobileKind, detectDeviceKind } from "./use-density.mjs";
|
|
3
|
+
function computeKeyboardInset(layoutHeight, visualViewportHeight, visualViewportOffsetTop) {
|
|
4
|
+
return Math.max(
|
|
5
|
+
0,
|
|
6
|
+
layoutHeight - visualViewportHeight - visualViewportOffsetTop
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
function shouldZeroInsetForResizesContent(deltaLayout, deltaVisual, tolerance = 12) {
|
|
10
|
+
return deltaVisual > tolerance && Math.abs(deltaLayout - deltaVisual) <= tolerance;
|
|
11
|
+
}
|
|
12
|
+
const KEYBOARD_INSET_VAR = "--dc-agent-keyboard-inset";
|
|
13
|
+
const KEYBOARD_OPEN_ATTR = "data-agent-ui-keyboard-open";
|
|
14
|
+
function readDeviceKind(mode) {
|
|
15
|
+
var _a;
|
|
16
|
+
const nav = navigator;
|
|
17
|
+
return detectDeviceKind(mode, {
|
|
18
|
+
userAgent: nav.userAgent,
|
|
19
|
+
uaDataMobile: (_a = nav.userAgentData) == null ? void 0 : _a.mobile,
|
|
20
|
+
maxTouchPoints: nav.maxTouchPoints ?? 0
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function useKeyboardInset(scope, options = {}) {
|
|
24
|
+
const vv = window.visualViewport;
|
|
25
|
+
let baseInnerHeight = window.innerHeight;
|
|
26
|
+
let baseVisualHeight = (vv == null ? void 0 : vv.height) ?? window.innerHeight;
|
|
27
|
+
let restore = [];
|
|
28
|
+
let recorded = false;
|
|
29
|
+
const recordOnce = (el) => {
|
|
30
|
+
if (recorded) return;
|
|
31
|
+
recorded = true;
|
|
32
|
+
const prevInset = el.style.getPropertyValue(KEYBOARD_INSET_VAR);
|
|
33
|
+
const prevInsetPriority = el.style.getPropertyPriority(KEYBOARD_INSET_VAR);
|
|
34
|
+
const prevOpen = el.getAttribute(KEYBOARD_OPEN_ATTR);
|
|
35
|
+
restore.push(() => {
|
|
36
|
+
if (prevInset) {
|
|
37
|
+
el.style.setProperty(KEYBOARD_INSET_VAR, prevInset, prevInsetPriority);
|
|
38
|
+
} else {
|
|
39
|
+
el.style.removeProperty(KEYBOARD_INSET_VAR);
|
|
40
|
+
}
|
|
41
|
+
if (prevOpen === null) el.removeAttribute(KEYBOARD_OPEN_ATTR);
|
|
42
|
+
else el.setAttribute(KEYBOARD_OPEN_ATTR, prevOpen);
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
const revert = () => {
|
|
46
|
+
recorded = false;
|
|
47
|
+
restore.splice(0).reverse().forEach((fn) => fn());
|
|
48
|
+
};
|
|
49
|
+
const update = () => {
|
|
50
|
+
const el = scope.value;
|
|
51
|
+
if (!el || !vv) return;
|
|
52
|
+
if (!isMobileKind(readDeviceKind(toValue(options.mode) ?? "auto"))) {
|
|
53
|
+
revert();
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
recordOnce(el);
|
|
57
|
+
const deltaLayout = baseInnerHeight - window.innerHeight;
|
|
58
|
+
const deltaVisual = baseVisualHeight - vv.height;
|
|
59
|
+
const inset = shouldZeroInsetForResizesContent(deltaLayout, deltaVisual) ? 0 : computeKeyboardInset(window.innerHeight, vv.height, vv.offsetTop);
|
|
60
|
+
el.style.setProperty(KEYBOARD_INSET_VAR, `${inset}px`);
|
|
61
|
+
if (inset > 0) el.setAttribute(KEYBOARD_OPEN_ATTR, "");
|
|
62
|
+
else el.removeAttribute(KEYBOARD_OPEN_ATTR);
|
|
63
|
+
};
|
|
64
|
+
const onViewportChange = () => update();
|
|
65
|
+
onMounted(() => {
|
|
66
|
+
if (!vv) return;
|
|
67
|
+
baseInnerHeight = window.innerHeight;
|
|
68
|
+
baseVisualHeight = vv.height;
|
|
69
|
+
vv.addEventListener("resize", onViewportChange);
|
|
70
|
+
vv.addEventListener("scroll", onViewportChange);
|
|
71
|
+
});
|
|
72
|
+
onBeforeUnmount(() => {
|
|
73
|
+
if (vv) {
|
|
74
|
+
vv.removeEventListener("resize", onViewportChange);
|
|
75
|
+
vv.removeEventListener("scroll", onViewportChange);
|
|
76
|
+
}
|
|
77
|
+
revert();
|
|
78
|
+
});
|
|
79
|
+
watch([scope, () => toValue(options.mode)], () => update(), {
|
|
80
|
+
immediate: true
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
export {
|
|
84
|
+
computeKeyboardInset,
|
|
85
|
+
shouldZeroInsetForResizesContent,
|
|
86
|
+
useKeyboardInset
|
|
87
|
+
};
|
package/es/index.mjs
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { default as default2 } from "./components/dialogue/AiDialogue.vue.mjs";
|
|
2
|
+
import { default as default3 } from "./components/dialogue/AiDialogueWrap.vue.mjs";
|
|
3
|
+
import { default as default4 } from "./components/dialogue/AiDialogueGroup.vue.mjs";
|
|
4
|
+
import { default as default5 } from "./components/config/AiConfigProvider.vue.mjs";
|
|
5
|
+
import { default as default6 } from "./components/dialogue/AiMessageList.vue.mjs";
|
|
6
|
+
import { default as default7 } from "./components/sender/AiSender.vue.mjs";
|
|
7
|
+
import { default as default8 } from "./components/bubble/AiPartRenderer.vue.mjs";
|
|
8
|
+
import { AiToolDeniedError, aiDataPartToWireText, aiIsDataPart, toOpenAIMessages } from "./types/index.mjs";
|
|
9
|
+
import { defaultSSEConverter, mergeToolCallsDeltas, parseAiToolArguments, parseOpenAIChunk, parseSSEEventLine, upsertAiMessageParts, useAiSSE } from "./hooks/sse.mjs";
|
|
10
|
+
import { AI_AGENT_DEFAULT_MAX_STEPS, useAiAgent } from "./hooks/agent.mjs";
|
|
11
|
+
import { useSenderScoped } from "./hooks/sender.mjs";
|
|
12
|
+
import { useBubbleListScoped } from "./hooks/bubble-list.mjs";
|
|
13
|
+
import { useFixBubbleListBug } from "./hooks/fix-bubble-list-bug.mjs";
|
|
14
|
+
import { AGENT_UI_DENSITY_TOKENS, REFERENCE_REM_PX, useAiModuleTheme } from "./hooks/theme.mjs";
|
|
15
|
+
import { useCodeXSlot } from "./hooks/CodeXSlot.mjs";
|
|
16
|
+
import { createNewSessionInfo, useSessionListScoped } from "./hooks/session-list.mjs";
|
|
17
|
+
import { AI_EXPOSE_PROVIDE, useAiExposeInject, useAiExposeProvide, useAiSessionInject, useAiSessionProvide, useExposeCtrl } from "./hooks/expose.mjs";
|
|
18
|
+
import { useSessionExpose, useSessionOperateMount } from "./hooks/SessionExpose.mjs";
|
|
19
|
+
import { AiDb, createAiDb, useMessageListStorage, useSessionListStorage } from "./hooks/storage.mjs";
|
|
20
|
+
import { default as default9 } from "./components/json-trigger/LlmJsonTrigger.vue.mjs";
|
|
21
|
+
import { getJsonFromLlm } from "./utils/json-from-llm.mjs";
|
|
22
|
+
import { requestLlmText } from "./utils/request-llm.mjs";
|
|
23
|
+
export {
|
|
24
|
+
AGENT_UI_DENSITY_TOKENS,
|
|
25
|
+
AI_AGENT_DEFAULT_MAX_STEPS,
|
|
26
|
+
AI_EXPOSE_PROVIDE,
|
|
27
|
+
default5 as AiConfigProvider,
|
|
28
|
+
AiDb,
|
|
29
|
+
default2 as AiDialogue,
|
|
30
|
+
default4 as AiDialogueGroup,
|
|
31
|
+
default3 as AiDialogueWrap,
|
|
32
|
+
default6 as AiMessageList,
|
|
33
|
+
default8 as AiPartRenderer,
|
|
34
|
+
default7 as AiSender,
|
|
35
|
+
AiToolDeniedError,
|
|
36
|
+
default9 as LlmJsonTrigger,
|
|
37
|
+
REFERENCE_REM_PX,
|
|
38
|
+
aiDataPartToWireText,
|
|
39
|
+
aiIsDataPart,
|
|
40
|
+
createAiDb,
|
|
41
|
+
createNewSessionInfo,
|
|
42
|
+
defaultSSEConverter,
|
|
43
|
+
getJsonFromLlm,
|
|
44
|
+
mergeToolCallsDeltas,
|
|
45
|
+
parseAiToolArguments,
|
|
46
|
+
parseOpenAIChunk,
|
|
47
|
+
parseSSEEventLine,
|
|
48
|
+
requestLlmText,
|
|
49
|
+
toOpenAIMessages,
|
|
50
|
+
upsertAiMessageParts,
|
|
51
|
+
useAiAgent,
|
|
52
|
+
useAiExposeInject,
|
|
53
|
+
useAiExposeProvide,
|
|
54
|
+
useAiModuleTheme,
|
|
55
|
+
useAiSSE,
|
|
56
|
+
useAiSessionInject,
|
|
57
|
+
useAiSessionProvide,
|
|
58
|
+
useBubbleListScoped,
|
|
59
|
+
useCodeXSlot,
|
|
60
|
+
useExposeCtrl,
|
|
61
|
+
useFixBubbleListBug,
|
|
62
|
+
useMessageListStorage,
|
|
63
|
+
useSenderScoped,
|
|
64
|
+
useSessionExpose,
|
|
65
|
+
useSessionListScoped,
|
|
66
|
+
useSessionListStorage,
|
|
67
|
+
useSessionOperateMount
|
|
68
|
+
};
|